diff options
author | Hans Petter Jansson <hpj@ximian.com> | 2004-08-21 07:35:20 +0800 |
---|---|---|
committer | Hans Petter <hansp@src.gnome.org> | 2004-08-21 07:35:20 +0800 |
commit | 3f62ea5c855b2ba4325edd29aaa2fc3feb0eebbf (patch) | |
tree | 476c1cc27b74ab07c91c76f57a120a30798148b4 /addressbook | |
parent | c4b88ab6297a1167c8afd1bdc4b96d87ca81aba4 (diff) | |
download | gsoc2013-evolution-3f62ea5c855b2ba4325edd29aaa2fc3feb0eebbf.tar.gz gsoc2013-evolution-3f62ea5c855b2ba4325edd29aaa2fc3feb0eebbf.tar.zst gsoc2013-evolution-3f62ea5c855b2ba4325edd29aaa2fc3feb0eebbf.zip |
Makes the contact image selector use GtkFileChooser if available.
2004-08-19 Hans Petter Jansson <hpj@ximian.com>
Makes the contact image selector use GtkFileChooser if available.
* gui/contact-editor/e-contact-editor.c (image_selected_cb): Take just
the editor as an argument, so we can call from other places without
having to supply dummy args. Rename to image_selected, since it's no
longer strictly a callback. Include optional code to use the new
GtkFileChooser.
(image_cleared_cb): Ditto. Rename to image_cleared.
(file_chooser_response): Optional response handling for GtkFileChooser.
(image_clicked): Include optional code to use the new GtkFileChooser.
Move common strings to variables. For GtkFileSelection, swap callback
parameters for the modified image_selected () and image_cleared ().
svn path=/trunk/; revision=26979
Diffstat (limited to 'addressbook')
-rw-r--r-- | addressbook/ChangeLog | 15 | ||||
-rw-r--r-- | addressbook/gui/contact-editor/e-contact-editor.c | 62 |
2 files changed, 65 insertions, 12 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 90f9133d0d..c41fc4276a 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,18 @@ +2004-08-19 Hans Petter Jansson <hpj@ximian.com> + + Makes the contact image selector use GtkFileChooser if available. + + * gui/contact-editor/e-contact-editor.c (image_selected_cb): Take just + the editor as an argument, so we can call from other places without + having to supply dummy args. Rename to image_selected, since it's no + longer strictly a callback. Include optional code to use the new + GtkFileChooser. + (image_cleared_cb): Ditto. Rename to image_cleared. + (file_chooser_response): Optional response handling for GtkFileChooser. + (image_clicked): Include optional code to use the new GtkFileChooser. + Move common strings to variables. For GtkFileSelection, swap callback + parameters for the modified image_selected () and image_cleared (). + 2004-08-19 Chris Toshok <toshok@ximian.com> [ likely fixes #61500 ] diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index f08434ab3d..180db61d24 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -2447,12 +2447,17 @@ categories_clicked (GtkWidget *button, EContactEditor *editor) } static void -image_selected_cb (GtkWidget *widget, EContactEditor *editor) +image_selected (EContactEditor *editor) { - const gchar *file_name; - GtkWidget *image_chooser; + gchar *file_name; + GtkWidget *image_chooser; + +#ifdef USE_GTKFILECHOOSER + file_name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (editor->file_selector)); +#else + file_name = (gchar *) gtk_file_selection_get_filename (GTK_FILE_SELECTION (editor->file_selector)); +#endif - file_name = gtk_file_selection_get_filename (GTK_FILE_SELECTION (editor->file_selector)); if (!file_name) return; @@ -2467,7 +2472,7 @@ image_selected_cb (GtkWidget *widget, EContactEditor *editor) } static void -image_cleared_cb (GtkWidget *widget, EContactEditor *editor) +image_cleared (EContactEditor *editor) { GtkWidget *image_chooser; gchar *file_name; @@ -2486,6 +2491,21 @@ image_cleared_cb (GtkWidget *widget, EContactEditor *editor) object_changed (G_OBJECT (image_chooser), editor); } +#ifdef USE_GTKFILECHOOSER + +static void +file_chooser_response (GtkWidget *widget, gint response, EContactEditor *editor) +{ + if (response == GTK_RESPONSE_ACCEPT) + image_selected (editor); + else if (response == GTK_RESPONSE_NO) + image_cleared (editor); + + gtk_widget_hide (editor->file_selector); +} + +#endif + static gboolean file_selector_deleted (GtkWidget *widget) { @@ -2498,23 +2518,40 @@ image_clicked (GtkWidget *button, EContactEditor *editor) { GtkWidget *clear_button; GtkWidget *dialog; + const gchar *title = _("Please select an image for this contact"); + const gchar *no_image = _("No image"); if (!editor->file_selector) { +#ifdef USE_GTKFILECHOOSER + editor->file_selector = gtk_file_chooser_dialog_new (title, + GTK_WINDOW (editor->app), + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + no_image, GTK_RESPONSE_NO, + NULL); + gtk_dialog_set_default_response (GTK_DIALOG (editor->file_selector), GTK_RESPONSE_ACCEPT); + + gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (editor->file_selector), g_get_home_dir ()); + + g_signal_connect (editor->file_selector, "response", + G_CALLBACK (file_chooser_response), editor); +#else /* Create the selector */ - editor->file_selector = gtk_file_selection_new (_("Please select an image for this contact")); + editor->file_selector = gtk_file_selection_new (title); dialog = GTK_FILE_SELECTION (editor->file_selector)->fileop_dialog; - clear_button = gtk_dialog_add_button (GTK_DIALOG (editor->file_selector), _("No image"), 0); + clear_button = gtk_dialog_add_button (GTK_DIALOG (editor->file_selector), no_image, 0); - g_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (editor->file_selector)->ok_button), - "clicked", G_CALLBACK (image_selected_cb), editor); + g_signal_connect_swapped (GTK_OBJECT (GTK_FILE_SELECTION (editor->file_selector)->ok_button), + "clicked", G_CALLBACK (image_selected), editor); - g_signal_connect (clear_button, - "clicked", G_CALLBACK (image_cleared_cb), editor); + g_signal_connect_swapped (clear_button, + "clicked", G_CALLBACK (image_cleared), editor); - /* Ensure that the dialog box is hidden when the user clicks a button */ + /* Ensure that the dialog box gets hidden when the user clicks a button */ g_signal_connect_swapped (GTK_OBJECT (GTK_FILE_SELECTION (editor->file_selector)->ok_button), "clicked", G_CALLBACK (gtk_widget_hide), editor->file_selector); @@ -2524,6 +2561,7 @@ image_clicked (GtkWidget *button, EContactEditor *editor) g_signal_connect_swapped (clear_button, "clicked", G_CALLBACK (gtk_widget_hide), editor->file_selector); +#endif g_signal_connect_after (editor->file_selector, "delete-event", G_CALLBACK (file_selector_deleted), |