diff options
author | JP Rosevear <jpr@novell.com> | 2004-06-23 06:35:41 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2004-06-23 06:35:41 +0800 |
commit | 2e266d5ae53296ce9b647c2318b42b2d9111a7b1 (patch) | |
tree | ae3635b63e45a7d0d4ef9e2c46ee0d860da27601 /calendar/gui/dialogs/comp-editor.c | |
parent | 433db9d759e49c0200d9b27553add4afcddc100d (diff) | |
download | gsoc2013-evolution-2e266d5ae53296ce9b647c2318b42b2d9111a7b1.tar gsoc2013-evolution-2e266d5ae53296ce9b647c2318b42b2d9111a7b1.tar.gz gsoc2013-evolution-2e266d5ae53296ce9b647c2318b42b2d9111a7b1.tar.bz2 gsoc2013-evolution-2e266d5ae53296ce9b647c2318b42b2d9111a7b1.tar.lz gsoc2013-evolution-2e266d5ae53296ce9b647c2318b42b2d9111a7b1.tar.xz gsoc2013-evolution-2e266d5ae53296ce9b647c2318b42b2d9111a7b1.tar.zst gsoc2013-evolution-2e266d5ae53296ce9b647c2318b42b2d9111a7b1.zip |
HIGify and newer design; alarm page is gone, Cancel/OK buttons for the
2004-06-22 JP Rosevear <jpr@novell.com>
* gui/dialogs/Makefile.am, gui/dialogs/alarm-dialog.c,
gui/dialogs/alarm-dialog.glade, gui/dialogs/alarm-dialog.h,
gui/dialogs/alarm-list-dialog.c,
gui/dialogs/alarm-list-dialog.glade,
gui/dialogs/alarm-list-dialog.h, gui/dialogs/alarm-options.c,
gui/dialogs/alarm-options.h, gui/dialogs/alarm-page.c,
gui/dialogs/alarm-page.glade, gui/dialogs/alarm-page.h,
gui/dialogs/comp-editor.c, gui/dialogs/comp-editor.h,
gui/dialogs/event-editor.c, gui/dialogs/event-page.c,
gui/dialogs/event-page.glade, gui/dialogs/meeting-page.c,
gui/dialogs/meeting-page.glade, gui/dialogs/recurrence-page.c,
gui/dialogs/recurrence-page.glade,
gui/dialogs/task-details-page.c,
gui/dialogs/task-details-page.glade, gui/dialogs/task-editor.c,
gui/dialogs/task-page.c, gui/dialogs/task-page.glade: HIGify and
newer design; alarm page is gone, Cancel/OK buttons for the
dialog, no more menus; slightly improve read-only workings for
entry areas
svn path=/trunk/; revision=26463
Diffstat (limited to 'calendar/gui/dialogs/comp-editor.c')
-rw-r--r-- | calendar/gui/dialogs/comp-editor.c | 553 |
1 files changed, 171 insertions, 382 deletions
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c index 9dcbf1d80a..16d89055c2 100644 --- a/calendar/gui/dialogs/comp-editor.c +++ b/calendar/gui/dialogs/comp-editor.c @@ -34,8 +34,6 @@ #include <libgnomeui/gnome-dialog.h> #include <libgnomeui/gnome-dialog-util.h> #include <libgnomeui/gnome-messagebox.h> -#include <bonobo/bonobo-ui-container.h> -#include <bonobo/bonobo-ui-util.h> #include <e-util/e-dialog-utils.h> #include <e-util/e-icon-factory.h> #include <evolution-shell-component-utils.h> @@ -68,14 +66,9 @@ struct _CompEditorPrivate { /* The pages we have */ GList *pages; - /* UI Component for the dialog */ - BonoboUIComponent *uic; - /* Notebook to hold the pages */ GtkNotebook *notebook; - - GtkWidget *filesel; - + gboolean changed; gboolean needs_send; @@ -119,42 +112,12 @@ static void close_cmd (GtkWidget *widget, gpointer data); static gint delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data); -static EPixmap pixmaps [] = -{ - E_PIXMAP ("/menu/File/FileSave", "stock_save", E_ICON_SIZE_MENU), - E_PIXMAP ("/menu/File/FileSaveAndClose", "stock_save", E_ICON_SIZE_MENU), - E_PIXMAP ("/menu/File/FileSaveAs", "stock_save-as", E_ICON_SIZE_MENU), - - E_PIXMAP ("/menu/File/FileDelete", "stock_delete", E_ICON_SIZE_MENU), - - E_PIXMAP ("/menu/File/FilePrint", "stock_print", E_ICON_SIZE_MENU), - E_PIXMAP ("/menu/File/FilePrintPreview", "stock_print-preview", E_ICON_SIZE_MENU), - - E_PIXMAP ("/Toolbar/FileSaveAndClose", "stock_save", E_ICON_SIZE_LARGE_TOOLBAR), - E_PIXMAP ("/Toolbar/FilePrint", "stock_print", E_ICON_SIZE_LARGE_TOOLBAR), - E_PIXMAP ("/Toolbar/FileDelete", "stock_delete", E_ICON_SIZE_LARGE_TOOLBAR), - - E_PIXMAP_END -}; - -static BonoboUIVerb verbs [] = { - BONOBO_UI_UNSAFE_VERB ("FileSaveAndClose", save_close_cmd), - BONOBO_UI_UNSAFE_VERB ("FileSaveAs", save_as_cmd), - BONOBO_UI_UNSAFE_VERB ("FileDelete", delete_cmd), - BONOBO_UI_UNSAFE_VERB ("FilePrint", print_cmd), - BONOBO_UI_UNSAFE_VERB ("FilePrintPreview", print_preview_cmd), - BONOBO_UI_UNSAFE_VERB ("FilePrintSetup", print_setup_cmd), - BONOBO_UI_UNSAFE_VERB ("FileClose", close_cmd), - - BONOBO_UI_VERB_END -}; - static GtkObjectClass *parent_class; E_MAKE_TYPE (comp_editor, "CompEditor", CompEditor, comp_editor_class_init, comp_editor_init, - BONOBO_TYPE_WINDOW); + GTK_TYPE_DIALOG); /* Class initialization function for the calendar component editor */ static void @@ -163,11 +126,10 @@ comp_editor_class_init (CompEditorClass *klass) GObjectClass *object_class; GtkWidgetClass *widget_class; + parent_class = g_type_class_peek_parent (klass); object_class = G_OBJECT_CLASS (klass); widget_class = GTK_WIDGET_CLASS (klass); - parent_class = g_type_class_ref(BONOBO_TYPE_WINDOW); - klass->set_e_cal = real_set_e_cal; klass->edit_comp = real_edit_comp; klass->send_comp = real_send_comp; @@ -176,135 +138,6 @@ comp_editor_class_init (CompEditorClass *klass) object_class->finalize = comp_editor_finalize; } -/* Creates the basic in the editor */ -static void -setup_widgets (CompEditor *editor) -{ - CompEditorPrivate *priv; - BonoboUIContainer *container; - GtkWidget *vbox; - - priv = editor->priv; - - /* Window and basic vbox */ - container = bonobo_ui_container_new (); - editor = (CompEditor *) bonobo_window_construct (BONOBO_WINDOW (editor), container, - "event-editor", "iCalendar Editor"); - g_signal_connect((editor), "delete_event", - G_CALLBACK (delete_event_cb), editor); - - priv->uic = bonobo_ui_component_new_default (); - bonobo_ui_component_set_container (priv->uic, - bonobo_object_corba_objref (BONOBO_OBJECT (container)), - NULL); - bonobo_ui_engine_config_set_path (bonobo_window_get_ui_engine (BONOBO_WINDOW (editor)), - "/evolution/UIConf/kvps"); - - bonobo_ui_component_add_verb_list_with_data (priv->uic, verbs, editor); - bonobo_ui_util_set_ui (priv->uic, PREFIX, - EVOLUTION_UIDIR "/evolution-comp-editor.xml", - "evolution-calendar", NULL); - e_pixmaps_update (priv->uic, pixmaps); - - vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); - gtk_widget_show (vbox); - gtk_container_set_border_width (GTK_CONTAINER (vbox), GNOME_PAD_SMALL); - bonobo_window_set_contents (BONOBO_WINDOW (editor), vbox); - - /* Notebook */ - priv->notebook = GTK_NOTEBOOK (gtk_notebook_new ()); - gtk_widget_show (GTK_WIDGET (priv->notebook)); - gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (priv->notebook), - TRUE, TRUE, 6); -} - -/* Object initialization function for the calendar component editor */ -static void -comp_editor_init (CompEditor *editor) -{ - CompEditorPrivate *priv; - - priv = g_new0 (CompEditorPrivate, 1); - editor->priv = priv; - - setup_widgets (editor); - - priv->pages = NULL; - priv->changed = FALSE; - priv->needs_send = FALSE; - priv->mod = CALOBJ_MOD_ALL; - priv->existing_org = FALSE; - priv->user_org = FALSE; - priv->warned = FALSE; -} - - -static gint -comp_editor_key_press_event (GtkWidget *d, GdkEventKey *e) -{ - if (e->keyval == GDK_Escape) { - if (prompt_to_save_changes (COMP_EDITOR (d), TRUE)) - close_dialog (COMP_EDITOR (d)); - return TRUE; - } - - if (GTK_WIDGET_CLASS (parent_class)->key_press_event) - return (* GTK_WIDGET_CLASS (parent_class)->key_press_event) (d, e); - - return FALSE; -} - -/* Destroy handler for the calendar component editor */ -static void -comp_editor_finalize (GObject *object) -{ - CompEditor *editor; - CompEditorPrivate *priv; - GList *l; - - editor = COMP_EDITOR (object); - priv = editor->priv; - - if (priv->client) { - g_object_unref (priv->client); - priv->client = NULL; - } - - if (priv->source_client) { - g_object_unref (priv->source_client); - priv->source_client = NULL; - } - - if (priv->view) { - g_signal_handlers_disconnect_matched (G_OBJECT (priv->view), - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, - editor); - - g_object_unref (priv->view); - priv->view = NULL; - } - - /* We want to destroy the pages after the widgets get destroyed, - since they have lots of signal handlers connected to the widgets - with the pages as the data. */ - for (l = priv->pages; l != NULL; l = l->next) - g_object_unref (l->data); - - if (priv->comp) { - g_object_unref (priv->comp); - priv->comp = NULL; - } - - bonobo_object_unref (priv->uic); - - g_free (priv); - editor->priv = NULL; - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - static void listen_for_changes (CompEditor *editor) { @@ -332,7 +165,6 @@ listen_for_changes (CompEditor *editor) char *query; query = g_strdup_printf ("(uid? \"%s\")", uid); - g_message ("%s", query); e_cal_get_query (priv->source_client, query, &priv->view, NULL); g_free (query); } @@ -348,6 +180,19 @@ listen_for_changes (CompEditor *editor) } } +/* This sets the focus to the toplevel, so any field being edited is committed. + FIXME: In future we may also want to check some of the fields are valid, + e.g. the EDateEdit fields. */ +static void +commit_all_fields (CompEditor *editor) +{ + CompEditorPrivate *priv; + + priv = editor->priv; + + gtk_window_set_focus (GTK_WINDOW (editor), NULL); +} + static void send_timezone (gpointer key, gpointer value, gpointer user_data) { @@ -481,19 +326,6 @@ save_comp_with_send (CompEditor *editor) return TRUE; } -static void -delete_comp (CompEditor *editor) -{ - CompEditorPrivate *priv; - const char *uid; - - priv = editor->priv; - - e_cal_component_get_uid (priv->comp, &uid); - e_cal_remove_object (priv->client, uid, NULL); - close_dialog (editor); -} - static gboolean prompt_to_save_changes (CompEditor *editor, gboolean send) { @@ -528,17 +360,164 @@ prompt_to_save_changes (CompEditor *editor, gboolean send) } } -/* This sets the focus to the toplevel, so any field being edited is committed. - FIXME: In future we may also want to check some of the fields are valid, - e.g. the EDateEdit fields. */ static void -commit_all_fields (CompEditor *editor) +response_cb (GtkWidget *widget, int response, gpointer data) { + CompEditor *editor = COMP_EDITOR (data); CompEditorPrivate *priv; + + priv = editor->priv; + + switch (response) { + case GTK_RESPONSE_OK: + commit_all_fields (editor); + + if (e_cal_component_is_instance (priv->comp)) + if (!recur_component_dialog (priv->client, priv->comp, &priv->mod, GTK_WINDOW (editor))) + return; + + if (save_comp_with_send (editor)) + close_dialog (editor); + break; + case GTK_RESPONSE_CANCEL: + case GTK_RESPONSE_DELETE_EVENT: + commit_all_fields (editor); + + if (prompt_to_save_changes (editor, TRUE)) + close_dialog (editor); + break; + } +} + +/* Creates the basic in the editor */ +static void +setup_widgets (CompEditor *editor) +{ + CompEditorPrivate *priv; + GtkWidget *vbox; priv = editor->priv; - gtk_window_set_focus (GTK_WINDOW (editor), NULL); + /* Basic vbox */ + vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); + gtk_widget_show (vbox); + gtk_container_set_border_width (GTK_CONTAINER (vbox), GNOME_PAD_SMALL); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (editor)->vbox), vbox, + TRUE, TRUE, 6); + + /* Notebook */ + priv->notebook = GTK_NOTEBOOK (gtk_notebook_new ()); + gtk_widget_show (GTK_WIDGET (priv->notebook)); + gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (priv->notebook), + TRUE, TRUE, 6); + + /* Buttons */ + gtk_dialog_add_button (GTK_DIALOG (editor), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); + gtk_dialog_add_button (GTK_DIALOG (editor), GTK_STOCK_OK, GTK_RESPONSE_OK); + gtk_dialog_set_response_sensitive (GTK_DIALOG (editor), GTK_RESPONSE_OK, FALSE); + + g_signal_connect (editor, "response", G_CALLBACK (response_cb), editor); +} + +/* Object initialization function for the calendar component editor */ +static void +comp_editor_init (CompEditor *editor) +{ + CompEditorPrivate *priv; + + priv = g_new0 (CompEditorPrivate, 1); + editor->priv = priv; + + setup_widgets (editor); + + priv->pages = NULL; + priv->changed = FALSE; + priv->needs_send = FALSE; + priv->mod = CALOBJ_MOD_ALL; + priv->existing_org = FALSE; + priv->user_org = FALSE; + priv->warned = FALSE; +} + + +static gint +comp_editor_key_press_event (GtkWidget *d, GdkEventKey *e) +{ +#if 0 + if (e->keyval == GDK_Escape) { + if (prompt_to_save_changes (COMP_EDITOR (d), TRUE)) + close_dialog (COMP_EDITOR (d)); + return TRUE; + } +#endif + + if (GTK_WIDGET_CLASS (parent_class)->key_press_event) + return (* GTK_WIDGET_CLASS (parent_class)->key_press_event) (d, e); + + return FALSE; +} + +/* Destroy handler for the calendar component editor */ +static void +comp_editor_finalize (GObject *object) +{ + CompEditor *editor; + CompEditorPrivate *priv; + GList *l; + + editor = COMP_EDITOR (object); + priv = editor->priv; + + if (priv->client) { + g_object_unref (priv->client); + priv->client = NULL; + } + + if (priv->source_client) { + g_object_unref (priv->source_client); + priv->source_client = NULL; + } + + if (priv->view) { + g_signal_handlers_disconnect_matched (G_OBJECT (priv->view), + G_SIGNAL_MATCH_DATA, + 0, 0, NULL, NULL, + editor); + + g_object_unref (priv->view); + priv->view = NULL; + } + + /* We want to destroy the pages after the widgets get destroyed, + since they have lots of signal handlers connected to the widgets + with the pages as the data. */ + for (l = priv->pages; l != NULL; l = l->next) + g_object_unref (l->data); + + if (priv->comp) { + g_object_unref (priv->comp); + priv->comp = NULL; + } + + g_free (priv); + editor->priv = NULL; + + if (G_OBJECT_CLASS (parent_class)->finalize) + (* G_OBJECT_CLASS (parent_class)->finalize) (object); +} + + +static void +delete_comp (CompEditor *editor) +{ + CompEditorPrivate *priv; + const char *uid; + + priv = editor->priv; + + e_cal_component_get_uid (priv->comp, &uid); + e_cal_remove_object (priv->client, uid, NULL); + close_dialog (editor); } /* Closes the dialog box and emits the appropriate signals */ @@ -629,6 +608,9 @@ comp_editor_set_changed (CompEditor *editor, gboolean changed) priv = editor->priv; priv->changed = changed; + + gtk_dialog_set_response_sensitive (GTK_DIALOG (editor), GTK_RESPONSE_OK, changed); + gtk_dialog_set_default_response (GTK_DIALOG (editor), GTK_RESPONSE_OK); } /** @@ -1254,65 +1236,6 @@ comp_editor_close (CompEditor *editor) return close; } -/** - * comp_editor_merge_ui: - * @editor: - * @filename: - * @verbs: - * - * - **/ -void -comp_editor_merge_ui (CompEditor *editor, - const char *filename, - BonoboUIVerb *verbs, - EPixmap *component_pixmaps) -{ - CompEditorPrivate *priv; - char *path; - - g_return_if_fail (editor != NULL); - g_return_if_fail (IS_COMP_EDITOR (editor)); - - priv = editor->priv; - - path = g_strconcat (EVOLUTION_UIDIR "/", filename, NULL); - - bonobo_ui_util_set_ui (priv->uic, EVOLUTION_DATADIR, path, "evolution-calendar", NULL); - bonobo_ui_component_add_verb_list_with_data (priv->uic, verbs, editor); - - g_free (path); - - if (component_pixmaps != NULL) - e_pixmaps_update (priv->uic, component_pixmaps); -} - -/** - * comp_editor_set_ui_prop: - * @editor: - * @path: - * @attr: - * @val: - * - * - **/ -void -comp_editor_set_ui_prop (CompEditor *editor, - const char *path, - const char *attr, - const char *val) -{ - CompEditorPrivate *priv; - - g_return_if_fail (editor != NULL); - g_return_if_fail (IS_COMP_EDITOR (editor)); - - priv = editor->priv; - - bonobo_ui_component_set_prop (priv->uic, path, attr, val, NULL); -} - - /* Brings attention to a window by raising it and giving it focus */ static void raise_and_focus (GtkWidget *widget) @@ -1367,129 +1290,6 @@ comp_editor_notify_client_changed (CompEditor *editor, ECal *client) comp_editor_page_notify_client_changed (COMP_EDITOR_PAGE (l->data), client); } -/* Menu Commands */ -static void -save_close_cmd (GtkWidget *widget, gpointer data) -{ - CompEditor *editor = COMP_EDITOR (data); - CompEditorPrivate *priv; - - priv = editor->priv; - - commit_all_fields (editor); - - if (e_cal_component_is_instance (priv->comp)) - if (!recur_component_dialog (priv->client, priv->comp, &priv->mod, GTK_WINDOW (editor))) - return; - - if (save_comp_with_send (editor)) - close_dialog (editor); -} - -static void -save_as_cmd (GtkWidget *widget, gpointer data) -{ - CompEditor *editor = COMP_EDITOR (data); - CompEditorPrivate *priv; - char *filename; - char *ical_string; - FILE *file; - - priv = editor->priv; - - commit_all_fields (editor); - - filename = e_file_dialog_save (_("Save as...")); - if (filename == NULL) - return; - - ical_string = e_cal_get_component_as_string (priv->client, - e_cal_component_get_icalcomponent (priv->comp)); - if (ical_string == NULL) { - g_warning ("Couldn't convert item to a string"); - return; - } - - file = fopen (filename, "w"); - if (file == NULL) { - g_warning ("Couldn't save item"); - return; - } - - fprintf (file, ical_string); - g_free (ical_string); - fclose (file); -} - -static void -delete_cmd (GtkWidget *widget, gpointer data) -{ - CompEditor *editor = COMP_EDITOR (data); - CompEditorPrivate *priv; - ECalComponentVType vtype; - - priv = editor->priv; - - vtype = e_cal_component_get_vtype (priv->comp); - - if (delete_component_dialog (priv->comp, FALSE, 1, vtype, GTK_WIDGET (editor))) { - if (itip_organizer_is_user (priv->comp, priv->client) - && cancel_component_dialog ((GtkWindow *) editor, - priv->client, priv->comp, TRUE)) - itip_send_comp (E_CAL_COMPONENT_METHOD_CANCEL, priv->comp, priv->client, NULL); - - delete_comp (editor); - } -} - -static void -print_cmd (GtkWidget *widget, gpointer data) -{ - CompEditor *editor = COMP_EDITOR (data); - ECalComponent *comp; - - commit_all_fields (editor); - - comp = comp_editor_get_current_comp (editor); - print_comp (comp, editor->priv->client, FALSE); - g_object_unref (comp); -} - -static void -print_preview_cmd (GtkWidget *widget, gpointer data) -{ - CompEditor *editor = COMP_EDITOR (data); - ECalComponent *comp; - - commit_all_fields (editor); - - comp = comp_editor_get_current_comp (editor); - print_comp (comp, editor->priv->client, TRUE); - g_object_unref (comp); -} - -static void -print_setup_cmd (GtkWidget *widget, gpointer data) -{ - CompEditor *editor = COMP_EDITOR (data); - CompEditorPrivate *priv; - - priv = editor->priv; - - print_setup (); -} - -static void -close_cmd (GtkWidget *widget, gpointer data) -{ - CompEditor *editor = COMP_EDITOR (data); - - commit_all_fields (editor); - - if (prompt_to_save_changes (editor, TRUE)) - close_dialog (editor); -} - static void page_changed_cb (GtkObject *obj, gpointer data) { @@ -1607,14 +1407,3 @@ obj_removed_cb (ECal *client, GList *uids, gpointer data) if (changed_component_dialog ((GtkWindow *) editor, priv->comp, TRUE, priv->changed)) close_dialog (editor); } - -static gint -delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data) -{ - CompEditor *editor = COMP_EDITOR (data); - - if (prompt_to_save_changes (editor, TRUE)) - close_dialog (editor); - - return TRUE; -} |