From a1a10f1ebef52168ec01c99f9f952cf13c099d54 Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Mon, 11 Nov 2002 23:06:00 +0000 Subject: change around a little, still ifdefed though. 2002-11-11 Chris Toshok * gui/contact-editor/e-contact-editor.c (_arrow_pressed): change around a little, still ifdefed though. * gui/contact-editor/e-contact-save-as.c (file_exists): same. (save_it): deal with the GtkDialog response ids. * gui/contact-editor/e-contact-editor.c (e_contact_editor_confirm_delete): just build the dialog here (using gtk_message_dialog*). * gui/contact-editor/Makefile.am (glade_DATA): remove file-exists.glade and e-contact-editor-confirm-delete.glade. svn path=/trunk/; revision=18712 --- addressbook/gui/contact-editor/Makefile.am | 4 +- .../e-contact-editor-confirm-delete.glade | 69 ------------------- addressbook/gui/contact-editor/e-contact-editor.c | 58 +++++++++------- addressbook/gui/contact-editor/e-contact-save-as.c | 50 ++++++-------- addressbook/gui/contact-editor/file-exists.glade | 80 ---------------------- 5 files changed, 57 insertions(+), 204 deletions(-) delete mode 100644 addressbook/gui/contact-editor/e-contact-editor-confirm-delete.glade delete mode 100644 addressbook/gui/contact-editor/file-exists.glade (limited to 'addressbook/gui/contact-editor') diff --git a/addressbook/gui/contact-editor/Makefile.am b/addressbook/gui/contact-editor/Makefile.am index fb61b1a97b..dbbd0350a7 100644 --- a/addressbook/gui/contact-editor/Makefile.am +++ b/addressbook/gui/contact-editor/Makefile.am @@ -55,9 +55,7 @@ gladedir = $(datadir)/evolution/glade glade_DATA = \ contact-editor.glade \ fulladdr.glade \ - fullname.glade \ - file-exists.glade \ - e-contact-editor-confirm-delete.glade + fullname.glade BUILT_SOURCES = $(MARSHAL_GENERATED) CLEANFILES = $(BUILT_SOURCES) diff --git a/addressbook/gui/contact-editor/e-contact-editor-confirm-delete.glade b/addressbook/gui/contact-editor/e-contact-editor-confirm-delete.glade deleted file mode 100644 index 66921f4ccc..0000000000 --- a/addressbook/gui/contact-editor/e-contact-editor-confirm-delete.glade +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - Are you sure you want -to delete this contact? - Delete Contact? - no - no - no - yes - no - yes - question - GTK_WIN_POS_NONE - - - - no - 8 - yes - - - - GTK_BUTTONBOX_END - 8 - yes - - - - yes - yes - yes - gtk-ok - yes - yes - - - - - - yes - yes - yes - gtk-cancel - yes - yes - - - - - 0 - no - yes - GTK_PACK_END - - - - - 4 - yes - yes - - - - diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index c78715008c..c7298819f1 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -1041,12 +1041,12 @@ prompt_to_save_changes (EContactEditor *editor) return TRUE; switch (e_addressbook_prompt_save_dialog (GTK_WINDOW(editor->app))) { - case 0: /* Save */ + case GTK_RESPONSE_YES: save_card (editor, FALSE); return TRUE; - case 1: /* Discard */ + case GTK_RESPONSE_NO: return TRUE; - case 2: /* Cancel */ + case GTK_RESPONSE_CANCEL: default: return FALSE; } @@ -1123,25 +1123,34 @@ file_send_to_cb (GtkWidget *widget, gpointer data) } gboolean -e_contact_editor_confirm_delete(GtkWindow *parent) -{ - GtkDialog *dialog; - GladeXML *gui; - int result; - - gui = glade_xml_new (EVOLUTION_GLADEDIR "/e-contact-editor-confirm-delete.glade", NULL, NULL); - - dialog = GTK_DIALOG(glade_xml_get_widget(gui, "confirm-dialog")); +e_contact_editor_confirm_delete (GtkWindow *parent) +{ + GtkWidget *dialog; + gint result; + + dialog = gtk_message_dialog_new (parent, + 0, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_NONE, +#if notyet + /* XXX we really need to handle the plural case here.. */ + (plural + ? _("Are you sure you want\n" + "to delete these contacts?")) +#endif + _("Are you sure you want\n" + "to delete this contact?")); - gtk_window_set_transient_for (GTK_WINDOW (dialog), parent); - - result = gtk_dialog_run(dialog); + gtk_dialog_add_buttons (GTK_DIALOG (dialog), + _("Delete"), GTK_RESPONSE_ACCEPT, + GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, + NULL); - gtk_widget_hide (GTK_WIDGET (dialog)); + result = gtk_dialog_run(GTK_DIALOG (dialog)); - g_object_unref(gui); + gtk_widget_destroy (dialog); - return !result; + return (result == GTK_RESPONSE_ACCEPT); } static void @@ -1732,8 +1741,8 @@ _popup_position(GtkMenu *menu, GtkRequisition request; int mh, mw; gdk_window_get_origin (button->window, x, y); - *x += button->allocation.width; - *y += button->allocation.height; + *x += button->allocation.x; + *y += button->allocation.y; gtk_widget_size_request(GTK_WIDGET(menu), &request); @@ -1754,15 +1763,18 @@ _popup_position(GtkMenu *menu, *y = gdk_screen_height () - mh; /* XXX? */ - *push_in = FALSE; + *push_in = TRUE; } static gint _arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor, GtkWidget *popup, GList **list, GnomeUIInfo **info, gchar *label, gchar *entry, gchar *dialog_title) { gint menu_item; -#if 0 - g_signal_emit_by_name(widget, "button_press_event"); + +#if PENDING_PORT_WORK + g_signal_handlers_block_matched (widget, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, editor); + g_signal_emit_by_name (widget, "button_press_event", NULL, NULL, NULL); + g_signal_handlers_unblock_matched (widget, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, editor); #endif gtk_widget_realize(popup); menu_item = gnome_popup_menu_do_popup_modal(popup, _popup_position, widget, button, editor, widget); diff --git a/addressbook/gui/contact-editor/e-contact-save-as.c b/addressbook/gui/contact-editor/e-contact-save-as.c index d044332be1..73651b9f21 100644 --- a/addressbook/gui/contact-editor/e-contact-save-as.c +++ b/addressbook/gui/contact-editor/e-contact-save-as.c @@ -34,7 +34,7 @@ #include #include -static int file_exists(GtkFileSelection *filesel, const char *filename); +static gint file_exists(GtkFileSelection *filesel, const char *filename); typedef struct { GtkFileSelection *filesel; @@ -54,10 +54,10 @@ save_it(GtkWidget *widget, SaveAsInfo *info) if (error == EEXIST) { response = file_exists(info->filesel, filename); switch (response) { - case 0 : /* Overwrite */ + case GTK_RESPONSE_ACCEPT : /* Overwrite */ e_write_file(filename, info->vcard, O_WRONLY | O_CREAT | O_TRUNC); break; - case 1 : /* cancel */ + case GTK_RESPONSE_REJECT : /* cancel */ return; } } else if (error != 0) { @@ -204,32 +204,24 @@ e_contact_list_save_as(char *title, GList *list, GtkWindow *parent_window) gtk_widget_show(GTK_WIDGET(filesel)); } -static int +static gint file_exists(GtkFileSelection *filesel, const char *filename) { - GtkDialog *dialog = NULL; - GtkWidget *label; - GladeXML *gui = NULL; - int result = 0; - char *string; - - gui = glade_xml_new (EVOLUTION_GLADEDIR "/file-exists.glade", NULL, NULL); - dialog = GTK_DIALOG(glade_xml_get_widget(gui, "dialog-exists")); - - label = glade_xml_get_widget (gui, "label-exists"); - if (GTK_IS_LABEL (label)) { - string = g_strdup_printf (_("%s already exists\nDo you want to overwrite it?"), filename); - gtk_label_set_text (GTK_LABEL (label), string); - g_free (string); - } - - gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW(filesel)); - - gtk_widget_show (GTK_WIDGET (dialog)); - result = gtk_dialog_run(dialog); - gtk_widget_destroy (GTK_WIDGET (dialog)); - - g_free(gui); - - return result; + GtkWidget *dialog; + gint response; + + dialog = gtk_message_dialog_new (GTK_WINDOW (filesel), + 0, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_NONE, + _("%s already exists\nDo you want to overwrite it?"), filename); + + gtk_dialog_add_buttons (GTK_DIALOG (dialog), + _("Overwrite"), GTK_RESPONSE_ACCEPT, + GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, + NULL); + + response = gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + return response; } diff --git a/addressbook/gui/contact-editor/file-exists.glade b/addressbook/gui/contact-editor/file-exists.glade deleted file mode 100644 index aa886f1f80..0000000000 --- a/addressbook/gui/contact-editor/file-exists.glade +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - no - Confirm Overwrite - GTK_WINDOW_TOPLEVEL - no - no - no - GTK_WIN_POS_NONE - - - - no - 8 - yes - - - - GTK_BUTTONBOX_END - 8 - yes - - - - yes - yes - Overwrite - yes - - - - - - yes - yes - yes - yes - gtk-cancel - yes - yes - - - - - 0 - no - yes - GTK_PACK_END - - - - - - Don't bother translating this string. It's not used. - GTK_JUSTIFY_CENTER - no - 0.5 - 0.5 - 0 - 0 - yes - - - 0 - no - no - - - - - 4 - yes - yes - - - - -- cgit v1.2.3