[evolution-patches] [Calendar] Edit Menu in CompEditor Implementation



Hi

Patch for the edit menu implementation in comp-editor.
Please review.

Thanks
Johnny
Index: calendar/gui/dialogs/comp-editor.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/dialogs/comp-editor.c,v
retrieving revision 1.155
diff -u -p -r1.155 comp-editor.c
--- calendar/gui/dialogs/comp-editor.c	26 Nov 2005 02:31:51 -0000	1.155
+++ calendar/gui/dialogs/comp-editor.c	13 Dec 2005 15:37:25 -0000
@@ -96,6 +96,9 @@ struct _CompEditorPrivate {
 	/* Notebook to hold the pages */
 	GtkNotebook *notebook;
 
+	/* Focussed Widget*/
+	GtkWidget *focused_entry;	
+
 	/* Attachment handling */
 	GtkWidget *attachment_bar;
 	GtkWidget *attachment_scrolled_window;
@@ -141,6 +144,8 @@ static void page_changed_cb (GtkObject *
 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);
@@ -1235,9 +1240,13 @@ menu_edit_copy_cb (BonoboUIComponent *ui
 		   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
@@ -1245,18 +1254,46 @@ menu_edit_paste_cb (BonoboUIComponent *u
 		    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");
+
 
 }
 
@@ -1301,7 +1338,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),
@@ -1408,6 +1445,7 @@ comp_editor_init (CompEditor *editor)
 
 	setup_widgets (editor);
 
+	priv->focused_entry = NULL;
 	priv->pages = NULL;
 	priv->changed = FALSE;
 	priv->needs_send = FALSE;
@@ -1848,7 +1886,10 @@ comp_editor_append_page (CompEditor *edi
 			    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",
@@ -2689,6 +2730,30 @@ needs_send_cb (GtkObject *obj, gpointer 
 	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)
Index: calendar/gui/dialogs/comp-editor-page.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/dialogs/comp-editor-page.c,v
retrieving revision 1.26
diff -u -p -r1.26 comp-editor-page.c
--- calendar/gui/dialogs/comp-editor-page.c	8 Jun 2004 16:44:46 -0000	1.26
+++ calendar/gui/dialogs/comp-editor-page.c	13 Dec 2005 15:37:36 -0000
@@ -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 (CompEditorP
 			      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;
@@ -332,6 +350,39 @@ comp_editor_page_set_summary (CompEditor
 		(* CLASS (page)->set_summary) (page, 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
Index: calendar/gui/dialogs/comp-editor-page.h
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/dialogs/comp-editor-page.h,v
retrieving revision 1.22
diff -u -p -r1.22 comp-editor-page.h
--- calendar/gui/dialogs/comp-editor-page.h	29 Sep 2005 13:02:56 -0000	1.22
+++ calendar/gui/dialogs/comp-editor-page.h	13 Dec 2005 15:37:46 -0000
@@ -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);
Index: calendar/gui/dialogs/task-page.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/dialogs/task-page.c,v
retrieving revision 1.77
diff -u -p -r1.77 task-page.c
--- calendar/gui/dialogs/task-page.c	26 Nov 2005 02:31:52 -0000	1.77
+++ calendar/gui/dialogs/task-page.c	13 Dec 2005 15:38:01 -0000
@@ -1565,7 +1565,28 @@ categories_clicked_cb (GtkWidget *button
 	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)
@@ -1702,6 +1723,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",
Index: calendar/gui/dialogs/event-page.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/dialogs/event-page.c,v
retrieving revision 1.92
diff -u -p -r1.92 event-page.c
--- calendar/gui/dialogs/event-page.c	26 Nov 2005 02:39:46 -0000	1.92
+++ calendar/gui/dialogs/event-page.c	13 Dec 2005 15:38:16 -0000
@@ -2092,6 +2092,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)
@@ -2579,11 +2603,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",
@@ -2705,6 +2738,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",


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