[evolution-patches] Patch to add "Open Web Page" item to tasks right-click menu



Hi,

Tasks support an URL property, but the only way to access it right now
is by opening the task editor and going to the EUrlEntry in the Details
page.  The attached patch adds an "Open Web Page" command to the
right-click menu for tasks.  I find it very useful, especially in the
little tasks table that goes beside calendar views.

I also did a little beautification of the task details page in the task
editor; now all of its entries have mnemonics.  I had to add mnemonic
support to EDateEdit and EUrlEntry.

Is it OK to commit to HEAD?

  Federico
Index: widgets/misc/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/widgets/misc/ChangeLog,v
retrieving revision 1.229
diff -u -r1.229 ChangeLog
--- widgets/misc/ChangeLog	9 Jul 2003 19:47:08 -0000	1.229
+++ widgets/misc/ChangeLog	11 Jul 2003 17:25:58 -0000
@@ -1,3 +1,10 @@
+2003-07-11  Federico Mena Quintero  <federico ximian com>
+
+	* e-dateedit.c (e_date_edit_mnemonic_activate): Added a handler
+	for GtkWidget::mnemonic_activate().
+
+	* e-url-entry.c (mnemonic_activate): Likewise.
+
 2003-07-09  Federico Mena Quintero  <federico ximian com>
 
 	* e-url-entry.c (destroy): Chain to the parent handler.  Fixes #45236.
Index: widgets/misc/e-dateedit.c
===================================================================
RCS file: /cvs/gnome/evolution/widgets/misc/e-dateedit.c,v
retrieving revision 1.34
diff -u -r1.34 e-dateedit.c
--- widgets/misc/e-dateedit.c	30 May 2003 17:32:31 -0000	1.34
+++ widgets/misc/e-dateedit.c	11 Jul 2003 17:25:58 -0000
@@ -138,6 +138,8 @@
 static void e_date_edit_init			(EDateEdit	*dedit);
 static void create_children			(EDateEdit	*dedit);
 static void e_date_edit_dispose			(GObject	*object);
+static gboolean e_date_edit_mnemonic_activate	(GtkWidget	*widget,
+						 gboolean	 group_cycling);
 static void e_date_edit_grab_focus		(GtkWidget	*widget);
 
 static gint on_date_entry_key_press		(GtkWidget	*widget,
@@ -252,6 +254,7 @@
 
 	object_class->dispose = e_date_edit_dispose;
 
+	widget_class->mnemonic_activate = e_date_edit_mnemonic_activate;
 	widget_class->grab_focus = e_date_edit_grab_focus;
 
 	class->changed = NULL;
@@ -469,6 +472,14 @@
 		(* G_OBJECT_CLASS (parent_class)->dispose) (object);
 }
 
+
+/* GtkWidget::mnemonic_activate() handler for the EDateEdit */
+static gboolean
+e_date_edit_mnemonic_activate (GtkWidget *widget, gboolean group_cycling)
+{
+	e_date_edit_grab_focus (widget);
+	return TRUE;
+}
 
 /* Grab_focus handler for the EDateEdit. If the date field is being shown, we
    grab the focus to that, otherwise we grab it to the time field. */
Index: widgets/misc/e-url-entry.c
===================================================================
RCS file: /cvs/gnome/evolution/widgets/misc/e-url-entry.c,v
retrieving revision 1.7
diff -u -r1.7 e-url-entry.c
--- widgets/misc/e-url-entry.c	9 Jul 2003 19:47:09 -0000	1.7
+++ widgets/misc/e-url-entry.c	11 Jul 2003 17:25:58 -0000
@@ -40,6 +40,8 @@
 
 static void button_clicked_cb (GtkWidget *widget, gpointer data);
 
+static gboolean mnemonic_activate (GtkWidget *widget, gboolean group_cycling);
+
 static GtkHBoxClass *parent_class = NULL;
 
 
@@ -72,12 +74,16 @@
 class_init (EUrlEntryClass *klass)
 {
 	GtkObjectClass *object_class;
+	GtkWidgetClass *widget_class;
 
 	object_class = GTK_OBJECT_CLASS (klass);
+	widget_class = GTK_WIDGET_CLASS (klass);
 
 	parent_class = g_type_class_ref(gtk_hbox_get_type ());
 	
 	object_class->destroy = destroy;
+
+	widget_class->mnemonic_activate = mnemonic_activate;
 }
 
 
@@ -117,6 +123,19 @@
 	}
 
 	GTK_OBJECT_CLASS (parent_class)->destroy (obj);
+}
+
+/* GtkWidget::mnemonic_activate() handler for the EUrlEntry */
+static gboolean
+mnemonic_activate (GtkWidget *widget, gboolean group_cycling)
+{
+	EUrlEntry *url_entry;
+	EUrlEntryPrivate *priv;
+
+	url_entry = E_URL_ENTRY (widget);
+	priv = url_entry->priv;
+
+	return gtk_widget_mnemonic_activate (priv->entry, group_cycling);
 }
 
 
? calendar/gui/dialogs/task-details-page.gladep
Index: calendar/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.1817
diff -u -r1.1817 ChangeLog
--- calendar/ChangeLog	1 Jan 1997 09:59:13 -0000	1.1817
+++ calendar/ChangeLog	11 Jul 2003 18:18:14 -0000
@@ -1,3 +1,26 @@
+2003-07-11  Federico Mena Quintero  <federico ximian com>
+
+	* gui/dialogs/task-details-page.glade: Changed the "URL:" label to
+	"_Web Page:".  Added a widget name to the URL label so that we can
+	hook up its mnemonic by hand.  Added underlines to the "%
+	Complete:" and "Date Completed:" labels.  Added a widget name to
+	the date completed label, also so that we can hook up its mnemonic.
+
+	* gui/dialogs/task-details-page.c (get_widgets): Get the url_label
+	and date_completed_label as well.
+	(init_widgets): Set the mnemonic widgets of the url_label and the
+	date_completed_label by hand, as their respective widgets are
+	not created by libglade.
+
+	* gui/e-calendar-table.c (tasks_popup_menu): Added an item for
+	"Open Web Page".
+	(e_calendar_table_show_popup_menu): Disable the aforementioned
+	menu item if the selected task doesn't have the URL property set.
+	(open_url_cb): New callback.
+
+	* gui/e-tasks.c (write_html): Make the HTML say "Web Page:"
+	instead of "URL:".
+
 2003-07-10  Harry Lu <harry lu sun com>
 
 	Fixes #46075.
Index: calendar/gui/e-calendar-table.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-calendar-table.c,v
retrieving revision 1.92
diff -u -r1.92 e-calendar-table.c
--- calendar/gui/e-calendar-table.c	2 Jul 2003 01:59:48 -0000	1.92
+++ calendar/gui/e-calendar-table.c	11 Jul 2003 18:18:14 -0000
@@ -935,6 +935,27 @@
 	e_table_selected_row_foreach (etable, mark_row_complete_cb, cal_table);
 }
 
+/* Opens the URL of the task */
+static void
+open_url_cb (GtkWidget *menuitem, gpointer data)
+{
+	ECalendarTable *cal_table;
+	CalComponent *comp;
+	const char *url;
+
+	cal_table = E_CALENDAR_TABLE (data);
+
+	comp = get_selected_comp (cal_table);
+	if (!comp)
+		return;
+
+	cal_component_get_url (comp, &url);
+	if (!url)
+		return;
+
+	gnome_url_show (url, NULL);
+}
+
 /* Callback for the "delete tasks" menu item */
 static void
 delete_cb (GtkWidget *menuitem, gpointer data)
@@ -950,12 +971,14 @@
 	MASK_SINGLE	= 1 << 0,	/* For commands that work on 1 task. */
 	MASK_MULTIPLE	= 1 << 1,	/* For commands for multiple tasks. */
 	MASK_EDITABLE   = 1 << 2,       /* For commands disabled in read-only folders */
-	MASK_ASSIGNABLE = 1 << 3        /* For non-task assignable backends */
+	MASK_ASSIGNABLE = 1 << 3,       /* For non-task assignable backends */
+	MASK_LACKS_URL  = 1 << 5        /* For tasks that don't have the URL property set */
 };
 
 
 static EPopupMenu tasks_popup_menu [] = {
 	E_POPUP_ITEM (N_("_Open"), GTK_SIGNAL_FUNC (e_calendar_table_on_open_task), MASK_SINGLE),
+	E_POPUP_ITEM (N_("Open _Web Page"), GTK_SIGNAL_FUNC (open_url_cb), MASK_SINGLE | MASK_LACKS_URL),
 	E_POPUP_ITEM (N_("_Save as..."), GTK_SIGNAL_FUNC (e_calendar_table_on_save_as), MASK_SINGLE),
 	E_POPUP_ITEM (N_("_Print..."), GTK_SIGNAL_FUNC (e_calendar_table_on_print_task), MASK_SINGLE),
 
@@ -994,9 +1017,21 @@
 	if (n_selected <= 0)
 		return TRUE;
 
-	if (n_selected == 1)
+	if (n_selected == 1) {
+		CalComponent *comp;
+		const char *url;
+
 		hide_mask = MASK_MULTIPLE;
-	else
+
+		/* See if the task has the URL property set */
+
+		comp = get_selected_comp (cal_table);
+		g_assert (comp != NULL);
+
+		cal_component_get_url (comp, &url);
+		if (!url)
+			disable_mask |= MASK_LACKS_URL;
+	} else
 		hide_mask = MASK_SINGLE;
 
 	if (cal_client_is_read_only (calendar_model_get_cal_client (e_calendar_table_get_model (cal_table))))
Index: calendar/gui/e-tasks.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-tasks.c,v
retrieving revision 1.51
diff -u -r1.51 e-tasks.c
--- calendar/gui/e-tasks.c	4 Jul 2003 10:36:25 -0000	1.51
+++ calendar/gui/e-tasks.c	11 Jul 2003 18:18:14 -0000
@@ -318,7 +318,7 @@
 		gtk_html_stream_printf (stream, "<TD></TD></TR>");
 
 	/* URL */
-	gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD>", _("URL:"));
+	gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD>", _("Web Page:"));
 	cal_component_get_url (comp, (const char **) &str);
 	if (str)
 		gtk_html_stream_printf (stream, "<TD><A HREF=\"%s\">%s</A></TD></TR>", str, str);
Index: calendar/gui/dialogs/task-details-page.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/dialogs/task-details-page.c,v
retrieving revision 1.32
diff -u -r1.32 task-details-page.c
--- calendar/gui/dialogs/task-details-page.c	8 May 2003 14:02:35 -0000	1.32
+++ calendar/gui/dialogs/task-details-page.c	11 Jul 2003 18:18:15 -0000
@@ -52,8 +52,10 @@
 	GtkWidget *priority;
 	GtkWidget *percent_complete;
 
+	GtkWidget *date_completed_label;
 	GtkWidget *completed_date;
 
+	GtkWidget *url_label;
 	GtkWidget *url_entry;
 	GtkWidget *url;
 
@@ -148,8 +150,10 @@
 	priv->priority = NULL;
 	priv->percent_complete = NULL;
 	
+	priv->date_completed_label = NULL;
 	priv->completed_date = NULL;
 
+	priv->url_label = NULL;
 	priv->url_entry = NULL;
 	priv->url = NULL;
 
@@ -469,9 +473,13 @@
 	priv->priority = GW ("priority");
 	priv->percent_complete = GW ("percent-complete");
 
+	priv->date_completed_label = GW ("date_completed_label");
+
 	priv->completed_date = GW ("completed-date");
 	gtk_widget_show (priv->completed_date);
 
+	priv->url_label = GW ("url_label");
+
 	priv->url_entry = GW ("url_entry");
 	gtk_widget_show (priv->url_entry);
 	priv->url = e_url_entry_get_entry (E_URL_ENTRY (priv->url_entry));
@@ -481,7 +489,9 @@
 	return (priv->status
 		&& priv->priority
 		&& priv->percent_complete
+		&& priv->date_completed_label
 		&& priv->completed_date
+		&& priv->url_label
 		&& priv->url);
 }
 
@@ -665,6 +675,10 @@
 	e_date_edit_set_get_time_callback (E_DATE_EDIT (priv->completed_date),
 					   (EDateEditGetTimeCallback) comp_editor_get_current_time,
 					   tdpage, NULL);
+
+	/* These are created by hand, so hook the mnemonics manually */
+	gtk_label_set_mnemonic_widget (GTK_LABEL (priv->date_completed_label), priv->completed_date);
+	gtk_label_set_mnemonic_widget (GTK_LABEL (priv->url_label), priv->url_entry);
 
 	/* Connect signals. The Status, Percent Complete & Date Completed
 	   properties are closely related so whenever one changes we may need
Index: calendar/gui/dialogs/task-details-page.glade
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/dialogs/task-details-page.glade,v
retrieving revision 1.14
diff -u -r1.14 task-details-page.glade
--- calendar/gui/dialogs/task-details-page.glade	28 Apr 2003 19:03:21 -0000	1.14
+++ calendar/gui/dialogs/task-details-page.glade	11 Jul 2003 18:18:15 -0000
@@ -188,8 +188,8 @@
 		  <child>
 		    <widget class="GtkLabel" id="label19">
 		      <property name="visible">True</property>
-		      <property name="label" translatable="yes">% Complete</property>
-		      <property name="use_underline">False</property>
+		      <property name="label" translatable="yes">% _Complete</property>
+		      <property name="use_underline">True</property>
 		      <property name="use_markup">False</property>
 		      <property name="justify">GTK_JUSTIFY_CENTER</property>
 		      <property name="wrap">False</property>
@@ -198,6 +198,7 @@
 		      <property name="yalign">0.5</property>
 		      <property name="xpad">0</property>
 		      <property name="ypad">0</property>
+		      <property name="mnemonic_widget">percent-complete</property>
 		    </widget>
 		    <packing>
 		      <property name="padding">0</property>
@@ -243,10 +244,10 @@
 		  <property name="column_spacing">4</property>
 
 		  <child>
-		    <widget class="GtkLabel" id="label12">
+		    <widget class="GtkLabel" id="date_completed_label">
 		      <property name="visible">True</property>
-		      <property name="label" translatable="yes">Date Completed:</property>
-		      <property name="use_underline">False</property>
+		      <property name="label" translatable="yes">_Date Completed:</property>
+		      <property name="use_underline">True</property>
 		      <property name="use_markup">False</property>
 		      <property name="justify">GTK_JUSTIFY_CENTER</property>
 		      <property name="wrap">False</property>
@@ -330,10 +331,10 @@
 	  <property name="column_spacing">6</property>
 
 	  <child>
-	    <widget class="GtkLabel" id="label14">
+	    <widget class="GtkLabel" id="url_label">
 	      <property name="visible">True</property>
-	      <property name="label" translatable="yes">URL:</property>
-	      <property name="use_underline">False</property>
+	      <property name="label" translatable="yes">_Web Page:</property>
+	      <property name="use_underline">True</property>
 	      <property name="use_markup">False</property>
 	      <property name="justify">GTK_JUSTIFY_CENTER</property>
 	      <property name="wrap">False</property>


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