[Glade-users] Save as... button



Here's a C/GTK+ snippet showing how I used a save as dialog from glade a 
while back...

gchar *
save_file_dialog()
{
        GladeXML                *gxml=NULL;
        GtkWidget               *dialog=NULL;
        GtkResponseType         response;
        gchar                   *glade_file;
        gchar                   *filename = NULL;
       
        /* setup glade */
        glade_file = gnome_program_locate_file (NULL,
                        GNOME_FILE_DOMAIN_APP_DATADIR,
                        GLADE_FILENAME, TRUE, NULL);       
        g_assert (glade_file);
        gxml = glade_xml_new (glade_file, "file_chooser_dialog", NULL);
        g_free (glade_file);
       
        /* setup dialog */
        dialog = glade_xml_get_widget (gxml, "file_chooser_dialog");
        gtk_window_set_title(GTK_WINDOW(dialog), _("Save File As..."));
        gtk_window_set_icon_name (GTK_WINDOW(dialog), "gtk-save");
        gtk_file_chooser_set_action(GTK_FILE_CHOOSER(dialog),
                        GTK_FILE_CHOOSER_ACTION_SAVE);
        gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER(dialog),
                        get_last_filechooser_path ());
                               
        /* present user with a file selection dialog */
        response = gtk_dialog_run (GTK_DIALOG (dialog));

        if (response == GTK_RESPONSE_OK)
        {
                filename = 
gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
        }
       
        save_last_filechooser_path (gtk_file_chooser_get_current_folder(
                        GTK_FILE_CHOOSER(dialog)));
                       
        gtk_widget_destroy(dialog);
       
        return filename;
}

Mehdi Rabah wrote:
You create a FileChooser dialog in glade, and in options you choose as 
type action "save"
(also "visible" option to false if you want)
Then you load the widget in your application and call the show() and 
run() method of this dialog box.
Finally you get the result of the run() to see the type of action the 
user did
There is also a method to see what file was choosen

I have a java gnome example if you want

On 6/1/06, *Dim elef* <roulhs gmail com <mailto:roulhs gmail com>> wrote:

    Hi everyone i m new to Glade and i want to ask how can i create a
    working "save as" button.
    _______________________________________________
    Glade-users maillist  -   Glade-users lists ximian com
    <mailto:Glade-users lists ximian com>
    http://lists.ximian.com/mailman/listinfo/glade-users


------------------------------------------------------------------------

_______________________________________________
Glade-users maillist  -  Glade-users lists ximian com
http://lists.ximian.com/mailman/listinfo/glade-users
  

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/glade-users/attachments/20060604/3cd0994c/attachment.html



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]