aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@ximian.com>2003-11-19 00:30:14 +0800
committerRodrigo Moya <rodrigo@src.gnome.org>2003-11-19 00:30:14 +0800
commitb47685534d7e5738d712962334537bb329831b9e (patch)
tree89715be728f4c19046dc0fd638cdaf84a195f27a
parent9163c12f19f54c0a6a24afd8b46e30112809567d (diff)
downloadgsoc2013-evolution-b47685534d7e5738d712962334537bb329831b9e.tar.gz
gsoc2013-evolution-b47685534d7e5738d712962334537bb329831b9e.tar.zst
gsoc2013-evolution-b47685534d7e5738d712962334537bb329831b9e.zip
added 'sensitive' argument. (fill_popup_menu_cb): disable/enable menu
2003-11-18 Rodrigo Moya <rodrigo@ximian.com> * gui/calendar-component.c (add_popup_menu_item): added 'sensitive' argument. (fill_popup_menu_cb): disable/enable menu items depending on whether there is a selection or not. * gui/tasks-component.c (add_popup_menu_item, fill_popup_menu_cb): ditto. svn path=/trunk/; revision=23416
-rw-r--r--calendar/ChangeLog10
-rw-r--r--calendar/gui/calendar-component.c20
-rw-r--r--calendar/gui/tasks-component.c23
3 files changed, 43 insertions, 10 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 30927820b1..cf41b539b6 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,13 @@
+2003-11-18 Rodrigo Moya <rodrigo@ximian.com>
+
+ * gui/calendar-component.c (add_popup_menu_item): added 'sensitive'
+ argument.
+ (fill_popup_menu_cb): disable/enable menu items depending on whether
+ there is a selection or not.
+
+ * gui/tasks-component.c (add_popup_menu_item, fill_popup_menu_cb):
+ ditto.
+
2003-11-17 JP Rosevear <jpr@ximian.com>
* Cleanup some ref/unref calls
diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c
index 1b0f3b479e..394aff4d36 100644
--- a/calendar/gui/calendar-component.c
+++ b/calendar/gui/calendar-component.c
@@ -229,7 +229,7 @@ get_default_event (ECal *client, gboolean all_day)
/* Callbacks. */
static void
add_popup_menu_item (GtkMenu *menu, const char *label, const char *pixmap,
- GCallback callback, gpointer user_data)
+ GCallback callback, gpointer user_data, gboolean sensitive)
{
GtkWidget *item, *image;
@@ -241,8 +241,10 @@ add_popup_menu_item (GtkMenu *menu, const char *label, const char *pixmap,
if (!image)
image = gtk_image_new_from_file (pixmap);
- if (image)
+ if (image) {
+ gtk_widget_show (image);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+ }
} else {
item = gtk_menu_item_new_with_label (label);
}
@@ -250,6 +252,9 @@ add_popup_menu_item (GtkMenu *menu, const char *label, const char *pixmap,
if (callback)
g_signal_connect (G_OBJECT (item), "activate", callback, user_data);
+ if (!sensitive)
+ gtk_widget_set_sensitive (item, FALSE);
+
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
}
@@ -328,9 +333,14 @@ rename_calendar_cb (GtkWidget *widget, CalendarComponent *comp)
static void
fill_popup_menu_cb (ESourceSelector *selector, GtkMenu *menu, CalendarComponent *comp)
{
- add_popup_menu_item (menu, _("New Calendar"), NULL, G_CALLBACK (new_calendar_cb), comp);
- add_popup_menu_item (menu, _("Delete"), GTK_STOCK_DELETE, G_CALLBACK (delete_calendar_cb), comp);
- add_popup_menu_item (menu, _("Rename"), NULL, G_CALLBACK (rename_calendar_cb), comp);
+ gboolean sensitive;
+
+ sensitive = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (priv->source_selector)) ?
+ TRUE : FALSE;
+
+ add_popup_menu_item (menu, _("New Calendar"), NULL, G_CALLBACK (new_calendar_cb), comp, TRUE);
+ add_popup_menu_item (menu, _("Delete"), GTK_STOCK_DELETE, G_CALLBACK (delete_calendar_cb), comp, sensitive);
+ add_popup_menu_item (menu, _("Rename"), NULL, G_CALLBACK (rename_calendar_cb), comp, sensitive);
}
static void
diff --git a/calendar/gui/tasks-component.c b/calendar/gui/tasks-component.c
index e1603893e2..f23d4bf732 100644
--- a/calendar/gui/tasks-component.c
+++ b/calendar/gui/tasks-component.c
@@ -200,7 +200,7 @@ get_default_task (ECal *ecal)
/* Callbacks. */
static void
add_popup_menu_item (GtkMenu *menu, const char *label, const char *pixmap,
- GCallback callback, gpointer user_data)
+ GCallback callback, gpointer user_data, gboolean sensitive)
{
GtkWidget *item, *image;
@@ -212,8 +212,10 @@ add_popup_menu_item (GtkMenu *menu, const char *label, const char *pixmap,
if (!image)
image = gtk_image_new_from_file (pixmap);
- if (image)
+ if (image) {
+ gtk_widget_show (image);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+ }
} else {
item = gtk_menu_item_new_with_label (label);
}
@@ -221,6 +223,9 @@ add_popup_menu_item (GtkMenu *menu, const char *label, const char *pixmap,
if (callback)
g_signal_connect (G_OBJECT (item), "activate", callback, user_data);
+ if (!sensitive)
+ gtk_widget_set_sensitive (item, FALSE);
+
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
}
@@ -298,9 +303,17 @@ rename_task_list_cb (GtkWidget *widget, TasksComponent *comp)
static void
fill_popup_menu_cb (ESourceSelector *selector, GtkMenu *menu, TasksComponent *component)
{
- add_popup_menu_item (menu, _("New Task List"), GTK_STOCK_NEW, G_CALLBACK (new_task_list_cb), component);
- add_popup_menu_item (menu, _("Delete"), GTK_STOCK_DELETE, G_CALLBACK (delete_task_list_cb), component);
- add_popup_menu_item (menu, _("Rename"), NULL, G_CALLBACK (rename_task_list_cb), component);
+ gboolean sensitive;
+
+ sensitive = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (priv->source_selector)) ?
+ TRUE : FALSE;
+
+ add_popup_menu_item (menu, _("New Task List"), GTK_STOCK_NEW, G_CALLBACK (new_task_list_cb),
+ component, TRUE);
+ add_popup_menu_item (menu, _("Delete"), GTK_STOCK_DELETE, G_CALLBACK (delete_task_list_cb),
+ component, sensitive);
+ add_popup_menu_item (menu, _("Rename"), NULL, G_CALLBACK (rename_task_list_cb),
+ component, sensitive);
}
static void