diff options
author | Chenthill Palanisamy <pchen@src.gnome.org> | 2006-01-13 18:31:05 +0800 |
---|---|---|
committer | Chenthill Palanisamy <pchen@src.gnome.org> | 2006-01-13 18:31:05 +0800 |
commit | c8ca795c9291d5b85f5ed5ed818188477b012ed9 (patch) | |
tree | 2bc851870de67c3318cf59394474bc7098cbf614 /calendar | |
parent | 796c0f96c7f20f1a0e2b188e79eb909f8ebf6665 (diff) | |
download | gsoc2013-evolution-c8ca795c9291d5b85f5ed5ed818188477b012ed9.tar.gz gsoc2013-evolution-c8ca795c9291d5b85f5ed5ed818188477b012ed9.tar.zst gsoc2013-evolution-c8ca795c9291d5b85f5ed5ed818188477b012ed9.zip |
edit menu implementation
svn path=/trunk/; revision=31163
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 15 | ||||
-rw-r--r-- | calendar/gui/dialogs/comp-editor-page.c | 53 | ||||
-rw-r--r-- | calendar/gui/dialogs/comp-editor-page.h | 3 | ||||
-rw-r--r-- | calendar/gui/dialogs/comp-editor.c | 81 | ||||
-rw-r--r-- | calendar/gui/dialogs/event-page.c | 37 | ||||
-rw-r--r-- | calendar/gui/dialogs/task-page.c | 33 |
6 files changed, 212 insertions, 10 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 050c6201e7..b83b5474b7 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,18 @@ +2006-01-13 Johnny Jacob <johnnyjacob@gmail.com> + + * gui/dialogs/comp-editor-page.c: (comp_editor_page_class_init), + (comp_editor_page_unset_focused_widget), + (comp_editor_page_set_focused_widget): + * gui/dialogs/comp-editor-page.h: + * gui/dialogs/comp-editor.c: (menu_edit_copy_cb), + (menu_edit_paste_cb), (menu_edit_selectall_cb), (menu_edit_cut_cb), + (comp_editor_init), (comp_editor_append_page), + (page_focus_out_widget_cb), (page_focus_in_widget_cb): + * gui/dialogs/event-page.c: (widget_focus_in_cb), + (widget_focus_out_cb), (init_widgets): + * gui/dialogs/task-page.c: (widget_focus_in_cb), + (widget_focus_out_cb), (init_widgets): Implementation for the edit button. + 2006-01-13 Chenthill Palanisamy <pchenthill@novell.com> Fixes #313112 diff --git a/calendar/gui/dialogs/comp-editor-page.c b/calendar/gui/dialogs/comp-editor-page.c index 2d656060e7..22461c5107 100644 --- a/calendar/gui/dialogs/comp-editor-page.c +++ b/calendar/gui/dialogs/comp-editor-page.c @@ -44,6 +44,8 @@ enum { SUMMARY_CHANGED, DATES_CHANGED, CLIENT_CHANGED, + FOCUS_IN, + FOCUS_OUT, LAST_SIGNAL }; @@ -140,7 +142,23 @@ comp_editor_page_class_init (CompEditorPageClass *class) NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT); - + comp_editor_page_signals[FOCUS_IN] = + g_signal_new ("focus_in", + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (CompEditorPageClass, focus_in), + NULL, NULL, + g_cclosure_marshal_VOID__POINTER, + G_TYPE_NONE, 1, G_TYPE_POINTER); + comp_editor_page_signals[FOCUS_OUT] = + g_signal_new ("focus_out", + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (CompEditorPageClass, focus_out), + NULL, NULL, + g_cclosure_marshal_VOID__POINTER, + G_TYPE_NONE, 1, G_TYPE_POINTER); + class->changed = NULL; class->summary_changed = NULL; class->dates_changed = NULL; @@ -333,6 +351,39 @@ comp_editor_page_set_summary (CompEditorPage *page, const char *summary) } /** + * comp_editor_page_unset_focused_widget + * @page: An editor page + * @widget: The widget that has the current focus +**/ +void +comp_editor_page_unset_focused_widget (CompEditorPage *page, GtkWidget *widget) +{ + g_return_if_fail (page!= NULL); + g_return_if_fail (IS_COMP_EDITOR_PAGE (page)); + + gtk_signal_emit (GTK_OBJECT (page), + comp_editor_page_signals[FOCUS_OUT], + widget); + +} + +/** + * comp_editor_page_set_focussed_widget: + * @page: An editor page + * @widget: The widget that has the current focus +**/ +void +comp_editor_page_set_focused_widget (CompEditorPage *page, GtkWidget *widget) +{ + g_return_if_fail (page!= NULL); + g_return_if_fail (IS_COMP_EDITOR_PAGE (page)); + + gtk_signal_emit (GTK_OBJECT (page), + comp_editor_page_signals[FOCUS_IN], + widget); + +} +/** * comp_editor_page_set_dates: * @page: An editor page * @dates: A collection of various dates in time_t format diff --git a/calendar/gui/dialogs/comp-editor-page.h b/calendar/gui/dialogs/comp-editor-page.h index 9da69da076..3859202098 100644 --- a/calendar/gui/dialogs/comp-editor-page.h +++ b/calendar/gui/dialogs/comp-editor-page.h @@ -79,7 +79,8 @@ typedef struct { void (* summary_changed) (CompEditorPage *page, const char *summary); void (* dates_changed) (CompEditorPage *page, const char *dates); void (* client_changed) (CompEditorPage *page, ECal *client); - + void (* focus_in) (CompEditorPage *page, GtkWidget *widget); + void (* focus_out) (CompEditorPage *page, GtkWidget *widget); /* Virtual methods */ GtkWidget *(* get_widget) (CompEditorPage *page); diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c index f17999334e..fa23b7b78a 100644 --- a/calendar/gui/dialogs/comp-editor.c +++ b/calendar/gui/dialogs/comp-editor.c @@ -97,6 +97,9 @@ struct _CompEditorPrivate { /* Notebook to hold the pages */ GtkNotebook *notebook; + /* Focussed Widget*/ + GtkWidget *focused_entry; + /* Attachment handling */ GtkWidget *attachment_bar; GtkWidget *attachment_scrolled_window; @@ -142,6 +145,8 @@ static void page_changed_cb (GtkObject *obj, gpointer data); static void needs_send_cb (GtkObject *obj, gpointer data); static void page_summary_changed_cb (GtkObject *obj, const char *summary, gpointer data); static void page_dates_changed_cb (GtkObject *obj, CompEditorPageDates *dates, gpointer data); +static void page_focus_in_widget_cb (GtkObject *obj, GtkWidget *widget, gpointer data); +static void page_focus_out_widget_cb (GtkObject *obj, GtkWidget *widget, gpointer data); static void obj_modified_cb (ECal *client, GList *objs, gpointer data); static void obj_removed_cb (ECal *client, GList *uids, gpointer data); @@ -1290,9 +1295,13 @@ menu_edit_copy_cb (BonoboUIComponent *uic, void *data, const char *path) { - /*TODO Implement the function - CompEditor *editor = (CompEditor *) data; */ + CompEditor *editor = (CompEditor *) data; + CompEditorPrivate *priv = editor->priv; + if (GTK_IS_ENTRY (priv->focused_entry)) + gtk_editable_copy_clipboard (GTK_EDITABLE (priv->focused_entry)); + if (GTK_IS_TEXT_VIEW (priv->focused_entry)) + g_signal_emit_by_name (priv->focused_entry, "copy-clipboard"); } static void @@ -1300,18 +1309,46 @@ menu_edit_paste_cb (BonoboUIComponent *uic, void *data, const char *path) { - /*TODO Implement the function - CompEditor *editor = (CompEditor *) data; */ + CompEditor *editor = (CompEditor *) data; + CompEditorPrivate *priv = editor->priv; + + if (GTK_IS_ENTRY (priv->focused_entry)) + gtk_editable_paste_clipboard (GTK_EDITABLE (priv->focused_entry)); + if (GTK_IS_TEXT_VIEW (priv->focused_entry)) + g_signal_emit_by_name (priv->focused_entry, "paste-clipboard"); + } static void +menu_edit_selectall_cb (BonoboUIComponent *uic, + void *data, + const char *path) +{ + CompEditor *editor = (CompEditor *) data; + CompEditorPrivate *priv = editor->priv; + + if (GTK_IS_ENTRY (priv->focused_entry)) { + gtk_editable_set_position (GTK_EDITABLE (priv->focused_entry), -1); + gtk_editable_select_region (GTK_EDITABLE (priv->focused_entry), 0, -1); + } + if (GTK_IS_TEXT_VIEW (priv->focused_entry)) + g_signal_emit_by_name (priv->focused_entry, "select-all", TRUE); +} + +static void menu_edit_cut_cb (BonoboUIComponent *uic, void *data, const char *path) { - /*TODO Implement the function - CompEditor *editor = (CompEditor *) data; */ + CompEditor *editor = data; + CompEditorPrivate *priv = editor->priv; + + if (GTK_IS_ENTRY (priv->focused_entry)) + gtk_editable_cut_clipboard (GTK_EDITABLE (priv->focused_entry)); + if (GTK_IS_TEXT_VIEW (priv->focused_entry)) + g_signal_emit_by_name (priv->focused_entry, "cut-clipboard"); + } @@ -1356,7 +1393,7 @@ static BonoboUIVerb verbs [] = { BONOBO_UI_VERB ("EditCopy", menu_edit_copy_cb), BONOBO_UI_VERB ("EditPaste", menu_edit_paste_cb), BONOBO_UI_VERB ("EditCut", menu_edit_cut_cb), - + BONOBO_UI_VERB ("EditSelectAll", menu_edit_selectall_cb), BONOBO_UI_VERB ("InsertAttachments", menu_insert_attachment_cb), BONOBO_UI_VERB ("Help", menu_help_cb), @@ -1464,6 +1501,7 @@ comp_editor_init (CompEditor *editor) setup_widgets (editor); + priv->focused_entry = NULL; priv->pages = NULL; priv->changed = FALSE; priv->needs_send = FALSE; @@ -1904,7 +1942,10 @@ comp_editor_append_page (CompEditor *editor, G_CALLBACK (page_summary_changed_cb), editor); g_signal_connect(page, "dates_changed", G_CALLBACK (page_dates_changed_cb), editor); - + g_signal_connect(page, "focus_in", + G_CALLBACK (page_focus_in_widget_cb), editor); + g_signal_connect(page, "focus_out", + G_CALLBACK (page_focus_out_widget_cb), editor); /* Listen for when the page is mapped/unmapped so we can install/uninstall the appropriate GtkAccelGroup. */ g_signal_connect((page_widget), "map", @@ -2734,6 +2775,30 @@ needs_send_cb (GtkObject *obj, gpointer data) comp_editor_set_needs_send (editor, TRUE); } +/* Focus out widget callback */ +static void +page_focus_out_widget_cb (GtkObject *obj, GtkWidget *widget, gpointer data) +{ + CompEditor *editor = COMP_EDITOR (data); + CompEditorPrivate *priv; + + priv = editor->priv; + + priv->focused_entry = NULL; +} + +/* Focus in widget callback*/ +static void +page_focus_in_widget_cb (GtkObject *obj, GtkWidget *widget, gpointer data) +{ + + CompEditor *editor = COMP_EDITOR (data); + CompEditorPrivate *priv; + + priv = editor->priv; + + priv->focused_entry = widget; +} /* Page signal callbacks */ static void page_summary_changed_cb (GtkObject *obj, const char *summary, gpointer data) diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c index f475aae715..550462d154 100644 --- a/calendar/gui/dialogs/event-page.c +++ b/calendar/gui/dialogs/event-page.c @@ -2232,6 +2232,30 @@ get_widgets (EventPage *epage) && priv->description ); } +/* sets the current focused widget */ +static gboolean +widget_focus_in_cb (GtkWidget *widget, GdkEventFocus *event, gpointer data) +{ + EventPage *epage; + epage = EVENT_PAGE (data); + + comp_editor_page_set_focused_widget (COMP_EDITOR_PAGE (epage), widget); + + return FALSE; +} + +/* unset the current focused widget */ +static gboolean +widget_focus_out_cb (GtkWidget *widget, GdkEventFocus *event, gpointer data) +{ + EventPage *epage; + epage = EVENT_PAGE (data); + + comp_editor_page_unset_focused_widget (COMP_EDITOR_PAGE (epage), widget); + + return FALSE; +} + /* Callback used when the summary changes; we emit the notification signal. */ static void summary_changed_cb (GtkEditable *editable, gpointer data) @@ -2742,11 +2766,20 @@ init_widgets (EventPage *epage) /* Summary */ g_signal_connect((priv->summary), "changed", G_CALLBACK (summary_changed_cb), epage); + g_signal_connect(priv->summary, "focus-in-event", + G_CALLBACK (widget_focus_in_cb), epage); + g_signal_connect(priv->summary, "focus-out-event", + G_CALLBACK (widget_focus_out_cb), epage); + /* Description */ text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->description)); gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (priv->description), GTK_WRAP_WORD); + g_signal_connect(priv->description, "focus-in-event", + G_CALLBACK (widget_focus_in_cb), epage); + g_signal_connect(priv->description, "focus-out-event", + G_CALLBACK (widget_focus_out_cb), epage); /* Start and end times */ g_signal_connect((priv->start_time), "changed", @@ -2877,6 +2910,10 @@ init_widgets (EventPage *epage) G_CALLBACK (field_changed_cb), epage); g_signal_connect((priv->location), "changed", G_CALLBACK (field_changed_cb), epage); + g_signal_connect((priv->location), "focus-in-event", + G_CALLBACK (widget_focus_in_cb), epage); + g_signal_connect((priv->location), "focus-out-event", + G_CALLBACK (widget_focus_out_cb), epage); g_signal_connect((priv->start_time), "changed", G_CALLBACK (field_changed_cb), epage); g_signal_connect((priv->end_time), "changed", diff --git a/calendar/gui/dialogs/task-page.c b/calendar/gui/dialogs/task-page.c index 93386e9b6a..c8c21082fe 100644 --- a/calendar/gui/dialogs/task-page.c +++ b/calendar/gui/dialogs/task-page.c @@ -1565,7 +1565,28 @@ categories_clicked_cb (GtkWidget *button, gpointer data) entry = priv->categories; e_categories_config_open_dialog_for_entry (GTK_ENTRY (entry)); } +/* sets the current focused widget */ +static gboolean +widget_focus_in_cb (GtkWidget *widget, GdkEventFocus *event, gpointer data) +{ + TaskPage *tpage; + tpage = TASK_PAGE (data); + + comp_editor_page_set_focused_widget (COMP_EDITOR_PAGE(tpage), widget); + + return FALSE; +} +/* unsets the current focused widget */ +static gboolean +widget_focus_out_cb (GtkWidget *widget, GdkEventFocus *event, gpointer data) +{ + TaskPage *tpage; + tpage = TASK_PAGE (data); + comp_editor_page_unset_focused_widget (COMP_EDITOR_PAGE(tpage), widget); + + return FALSE; +} /* This is called when any field is changed; it notifies upstream. */ static void field_changed_cb (GtkWidget *widget, gpointer data) @@ -1703,6 +1724,18 @@ init_widgets (TaskPage *tpage) /* Connect the default signal handler to use to make sure the "changed" field gets set whenever a field is changed. */ + /* Set the current focus entry */ + g_signal_connect (priv->summary, "focus-in-event", + G_CALLBACK (widget_focus_in_cb), tpage); + g_signal_connect (priv->summary, "focus-out-event", + G_CALLBACK (widget_focus_out_cb), tpage); + + g_signal_connect (priv->description, "focus-in-event", + G_CALLBACK (widget_focus_in_cb), tpage); + g_signal_connect (priv->description, "focus-out-event", + G_CALLBACK (widget_focus_out_cb), tpage); + + /* Belongs to priv->description */ g_signal_connect ((text_buffer), "changed", G_CALLBACK (field_changed_cb), tpage); |