Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 03-23-2007, 05:08 AM   #1
Registered: Dec 2006
Posts: 362

Rep: Reputation: 30
file selection

hi all
i am doing on file selection concept
i got a problem with this code
initially ok_button must be sensitive FALSE
after selecting a file in the list ok_button have set sensitive TRUE
is it possible.
how can i do this

here is the code
which i tried
#include <gtk/gtk.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <linux/sockios.h>
#include <string.h>
#include <math.h>
#include <dirent.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <syslog.h>

GtkWidget *filew;
GtkWidget *selection_entry;

/* Get the selected filename and print it to the console */
static void file_ok_sel( GtkWidget        *w,
                         GtkFileSelection *fs )
     char *file;
     file=gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs));

     g_print ("%s\n",file );


static void set_selected(GtkWidget        *w,
                         GtkFileSelection *fs,
                         GtkEntry        *entry)
  // char *file1;
  /*  file1=gtk_file_selection_get_filename(GTK_FILE_SELECTION(filew));
    if(GTK_FILE_SELECTION (filew)->selection_entry!=NULL)
    { */   
//	gtk_widget_set_sensitive(G_OBJECT (GTK_FILE_SELECTION (filew)->ok_button),TRUE);
    char *file1;
   // file1=gtk_file_selection_get_filename(GTK_FILE_SELECTION(fs));
   // gtk_entry_set_text (GTK_FILE_SELECTION (filew)->selection_entry,file1);

   file1=gtk_entry_get_text (GTK_FILE_SELECTION (fs)->selection_entry);
     g_print ("file1 = %s\n",file1 );


int main( int   argc,
          char *argv[] )
    //GtkWidget *filew;
    gtk_init (&argc, &argv);
    /* Create a new file selection widget */
    filew = gtk_file_selection_new ("File selection");
    g_signal_connect (G_OBJECT (filew), "destroy",
	              G_CALLBACK (gtk_main_quit), NULL);
    /* Connect the ok_button to file_ok_sel function */
    g_signal_connect (G_OBJECT (GTK_FILE_SELECTION (filew)->ok_button),
		      "clicked", G_CALLBACK (file_ok_sel), (gpointer) filew);

   /* Ensure that the dialog box is destroyed when the user clicks a button. */
    g_signal_connect_swapped (GTK_FILE_SELECTION (filew)->ok_button,
                             G_CALLBACK (gtk_widget_destroy), 
                             (gpointer) filew);

    gtk_widget_set_sensitive(G_OBJECT (GTK_FILE_SELECTION (filew)->ok_button),FALSE); 
    /* Connect the cancel_button to destroy the widget */
    g_signal_connect_swapped (G_OBJECT (GTK_FILE_SELECTION (filew)->cancel_button),
	                      "clicked", G_CALLBACK (gtk_widget_destroy),
			      G_OBJECT (filew));

    g_signal_connect(G_OBJECT(GTK_FILE_SELECTION (filew)->selection_entry), "insert_text",
		     G_OBJECT (filew)); 

    /* Lets set the filename, as if this were a save dialog, and we are giving
     a default filename */
    gtk_file_selection_set_filename (GTK_FILE_SELECTION(filew), 
				     " ");

    // gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(filew));

    gtk_widget_show (filew);
    gtk_main ();
    return 0;

save it one.c
and compile like
gcc one.c -o one `pkg-config gtk+-2.0 --cflags --libs`
can please provide latest file selection gui code.
can you please help me

thank you in advance


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
cp and file selection Calgarian Linux - Newbie 7 07-16-2006 10:23 AM
GTK File Selection Question EnigmaX Programming 3 02-14-2006 01:02 AM
GTK Getting Filename From A File Selection Button HELP animehair Linux - Software 1 02-13-2006 11:58 PM
I miss my lovely GTK+ file selection melinda_sayang Slackware 0 07-12-2004 11:55 PM
How to get Source code of Gtk File Selection Widget chaits Linux - General 0 04-14-2004 10:43 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:30 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration