gossip r2826 - in trunk: . data/glade src
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: gossip r2826 - in trunk: . data/glade src
- Date: Tue, 8 Jul 2008 10:04:49 +0000 (UTC)
Author: mr
Date: Tue Jul 8 10:04:48 2008
New Revision: 2826
URL: http://svn.gnome.org/viewvc/gossip?rev=2826&view=rev
Log:
Fixes bug 435273, Usability issue: merge status submenu into task icon menu
Modified:
trunk/ChangeLog
trunk/data/glade/main.glade
trunk/src/gossip-app.c
trunk/src/gossip-presence-chooser.c
trunk/src/gossip-presence-chooser.h
Modified: trunk/data/glade/main.glade
==============================================================================
--- trunk/data/glade/main.glade (original)
+++ trunk/data/glade/main.glade Tue Jul 8 10:04:48 2008
@@ -2230,15 +2230,13 @@
</child>
<child>
- <widget class="GtkMenuItem" id="tray_status">
+ <widget class="GtkSeparatorMenuItem" id="tray_separator1">
<property name="visible">True</property>
- <property name="label" translatable="yes">Status</property>
- <property name="use_underline">True</property>
</widget>
</child>
<child>
- <widget class="GtkSeparatorMenuItem" id="avskiljare6">
+ <widget class="GtkSeparatorMenuItem" id="tray_separator2">
<property name="visible">True</property>
</widget>
</child>
Modified: trunk/src/gossip-app.c
==============================================================================
--- trunk/src/gossip-app.c (original)
+++ trunk/src/gossip-app.c Tue Jul 8 10:04:48 2008
@@ -296,7 +296,8 @@
guint button,
guint activate_time,
GossipApp *app);
-static void app_status_icon_create_menu (void);
+static GtkWidget *
+ app_status_icon_create_menu (GossipApp *app);
static void app_status_icon_create (void);
static void app_setup_dock (void);
static gboolean
@@ -903,7 +904,6 @@
/* Set up notification area / tray. */
gossip_debug (DEBUG_DOMAIN_SETUP, "Configuring notification area widgets");
- app_status_icon_create_menu ();
app_status_icon_create ();
app_setup_presences ();
@@ -2108,37 +2108,24 @@
}
static void
-app_status_icon_popup_menu_cb (GtkStatusIcon *status_icon,
+app_status_icon_popup_menu_cb (GtkStatusIcon *status_icon,
guint button,
guint activate_time,
- GossipApp *app)
+ GossipApp *app)
{
GossipAppPriv *priv;
- GtkWidget *submenu;
- gboolean show;
+ GtkWidget *menu;
priv = GET_PRIV (app);
- if (!priv->popup_menu) {
+ menu = app_status_icon_create_menu (app);
+
+ if (!menu) {
/* On Mac, there is no menu (at least for now). */
return;
}
- show = gossip_window_get_is_visible (GTK_WINDOW (priv->window));
-
- g_signal_handlers_block_by_func (priv->popup_menu_show_list_item,
- app_show_hide_list_cb, app);
- gtk_check_menu_item_set_active
- (GTK_CHECK_MENU_ITEM (priv->popup_menu_show_list_item), show);
- g_signal_handlers_unblock_by_func (priv->popup_menu_show_list_item,
- app_show_hide_list_cb, app);
-
- submenu = gossip_presence_chooser_create_menu (
- GOSSIP_PRESENCE_CHOOSER (priv->presence_chooser));
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (priv->popup_menu_status_item),
- submenu);
-
- gtk_menu_popup (GTK_MENU (priv->popup_menu),
+ gtk_menu_popup (GTK_MENU (menu),
NULL, NULL,
gtk_status_icon_position_menu,
priv->status_icon,
@@ -2146,16 +2133,21 @@
activate_time);
}
-static void
-app_status_icon_create_menu (void)
+static GtkWidget *
+app_status_icon_create_menu (GossipApp *app)
{
GossipAppPriv *priv;
GladeXML *glade;
+ GtkWidget *menu;
+ GtkWidget *separator_item;
GtkWidget *message_item;
+ GtkWidget *show_list_item;
+ gint connected;
+ gboolean show;
#ifdef GDK_WINDOWING_QUARTZ
/* Unused for now. */
- return;
+ return NULL;
#endif
priv = GET_PRIV (app);
@@ -2163,10 +2155,10 @@
glade = gossip_glade_get_file ("main.glade",
"tray_menu",
NULL,
- "tray_menu", &priv->popup_menu,
- "tray_show_list", &priv->popup_menu_show_list_item,
+ "tray_menu", &menu,
+ "tray_show_list", &show_list_item,
"tray_new_message", &message_item,
- "tray_status", &priv->popup_menu_status_item,
+ "tray_separator1", &separator_item,
NULL);
gossip_glade_connect (glade,
@@ -2175,16 +2167,33 @@
"tray_quit", "activate", app_chat_quit_cb,
NULL);
- g_signal_connect (priv->popup_menu_show_list_item, "toggled",
- G_CALLBACK (app_show_hide_list_cb), app);
+ /* Status menu items */
+ gossip_session_count_accounts (priv->session,
+ &connected,
+ NULL,
+ NULL);
- priv->widgets_connected = g_list_prepend (priv->widgets_connected,
- priv->popup_menu_status_item);
+ gossip_presence_chooser_insert_menu (
+ GOSSIP_PRESENCE_CHOOSER (priv->presence_chooser),
+ menu,
+ 4,
+ connected > 0,
+ FALSE);
+ gtk_widget_show_all (menu);
+
+ /* New message item */
+ gtk_widget_set_sensitive (message_item, connected > 0);
- priv->widgets_connected = g_list_prepend (priv->widgets_connected,
- message_item);
+ /* Show/hide check menu item */
+ show = gossip_window_get_is_visible (GTK_WINDOW (priv->window));
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (show_list_item), show);
+ g_signal_connect (show_list_item, "toggled",
+ G_CALLBACK (app_show_hide_list_cb), app);
+
g_object_unref (glade);
+
+ return menu;
}
static void
Modified: trunk/src/gossip-presence-chooser.c
==============================================================================
--- trunk/src/gossip-presence-chooser.c (original)
+++ trunk/src/gossip-presence-chooser.c Tue Jul 8 10:04:48 2008
@@ -79,10 +79,12 @@
gpointer user_data);
static void presence_chooser_clear_activate_cb (GtkWidget *item,
GossipPresenceChooser *chooser);
-static void presence_chooser_menu_add_item (GossipPresenceChooser *chooser,
+static GtkWidget *
+ presence_chooser_menu_add_item (GossipPresenceChooser *chooser,
GtkWidget *menu,
const gchar *str,
GossipPresenceState state,
+ gint position,
gboolean custom);
static void presence_chooser_menu_align_func (GtkMenu *menu,
gint *x,
@@ -520,11 +522,12 @@
gtk_widget_show (dialog);
}
-static void
+static GtkWidget *
presence_chooser_menu_add_item (GossipPresenceChooser *chooser,
GtkWidget *menu,
const gchar *str,
GossipPresenceState state,
+ gint position,
gboolean custom)
{
GtkWidget *item;
@@ -578,7 +581,13 @@
g_object_set_data (G_OBJECT (item), "state", GINT_TO_POINTER (state));
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ if (position == -1) {
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ } else {
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menu), item, position);
+ }
+
+ return item;
}
static void
@@ -665,7 +674,7 @@
return;
}
- menu = gossip_presence_chooser_create_menu (chooser);
+ menu = gossip_presence_chooser_create_menu (chooser, TRUE, TRUE, -1);
g_signal_connect_after (menu, "selection-done",
G_CALLBACK (presence_chooser_menu_selection_done_cb),
@@ -995,108 +1004,201 @@
}
GtkWidget *
-gossip_presence_chooser_create_menu (GossipPresenceChooser *chooser)
+gossip_presence_chooser_create_menu (GossipPresenceChooser *chooser,
+ gint position,
+ gboolean sensitive,
+ gboolean include_clear)
{
GtkWidget *menu;
+
+ g_return_val_if_fail (GOSSIP_IS_PRESENCE_CHOOSER (chooser), NULL);
+
+ menu = gtk_menu_new ();
+
+ gossip_presence_chooser_insert_menu (chooser,
+ menu,
+ position,
+ sensitive,
+ include_clear);
+
+ return menu;
+}
+
+void
+gossip_presence_chooser_insert_menu (GossipPresenceChooser *chooser,
+ GtkWidget *menu,
+ gint position,
+ gboolean sensitive,
+ gboolean include_clear)
+{
GtkWidget *item;
GList *list, *l;
+ gint i;
- menu = gtk_menu_new ();
+ g_return_if_fail (GOSSIP_IS_PRESENCE_CHOOSER (chooser));
+ g_return_if_fail (GTK_IS_MENU (menu));
+
+ i = position;
- presence_chooser_menu_add_item (chooser,
- menu,
- _("Available"),
- GOSSIP_PRESENCE_STATE_AVAILABLE,
- FALSE);
+ item = presence_chooser_menu_add_item (chooser,
+ menu,
+ _("Available"),
+ GOSSIP_PRESENCE_STATE_AVAILABLE,
+ i++,
+ FALSE);
+ if (!sensitive) {
+ gtk_widget_set_sensitive (item, FALSE);
+ }
list = gossip_status_presets_get (GOSSIP_PRESENCE_STATE_AVAILABLE, 5);
for (l = list; l; l = l->next) {
- presence_chooser_menu_add_item (chooser,
- menu,
- l->data,
- GOSSIP_PRESENCE_STATE_AVAILABLE,
- FALSE);
+ item = presence_chooser_menu_add_item (chooser,
+ menu,
+ l->data,
+ GOSSIP_PRESENCE_STATE_AVAILABLE,
+ i++,
+ FALSE);
+ if (!sensitive) {
+ gtk_widget_set_sensitive (item, FALSE);
+ }
}
g_list_free (list);
- presence_chooser_menu_add_item (chooser,
- menu,
- _("Custom message..."),
- GOSSIP_PRESENCE_STATE_AVAILABLE,
- TRUE);
+ item = presence_chooser_menu_add_item (chooser,
+ menu,
+ _("Custom message..."),
+ GOSSIP_PRESENCE_STATE_AVAILABLE,
+ i++,
+ TRUE);
+ if (!sensitive) {
+ gtk_widget_set_sensitive (item, FALSE);
+ }
+
/* Separator. */
item = gtk_menu_item_new ();
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
- presence_chooser_menu_add_item (chooser,
- menu,
- _("Busy"),
- GOSSIP_PRESENCE_STATE_BUSY,
- FALSE);
+ if (position == -1) {
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ } else {
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menu), item, i++);
+ }
+ gtk_widget_show (item);
+
+ item = presence_chooser_menu_add_item (chooser,
+ menu,
+ _("Busy"),
+ GOSSIP_PRESENCE_STATE_BUSY,
+ i++,
+ FALSE);
+ if (!sensitive) {
+ gtk_widget_set_sensitive (item, FALSE);
+ }
+
list = gossip_status_presets_get (GOSSIP_PRESENCE_STATE_BUSY, 5);
for (l = list; l; l = l->next) {
- presence_chooser_menu_add_item (chooser,
- menu,
- l->data,
- GOSSIP_PRESENCE_STATE_BUSY,
- FALSE);
+ item = presence_chooser_menu_add_item (chooser,
+ menu,
+ l->data,
+ GOSSIP_PRESENCE_STATE_BUSY,
+ i++,
+ FALSE);
+ if (!sensitive) {
+ gtk_widget_set_sensitive (item, FALSE);
+ }
}
g_list_free (list);
- presence_chooser_menu_add_item (chooser,
- menu,
- _("Custom message..."),
- GOSSIP_PRESENCE_STATE_BUSY,
- TRUE);
+ item = presence_chooser_menu_add_item (chooser,
+ menu,
+ _("Custom message..."),
+ GOSSIP_PRESENCE_STATE_BUSY,
+ i++,
+ TRUE);
+ if (!sensitive) {
+ gtk_widget_set_sensitive (item, FALSE);
+ }
/* Separator. */
item = gtk_menu_item_new ();
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+ if (position == -1) {
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ } else {
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menu), item, i++);
+ }
+
gtk_widget_show (item);
- presence_chooser_menu_add_item (chooser,
- menu,
- _("Away"),
- GOSSIP_PRESENCE_STATE_AWAY,
- FALSE);
+ item = presence_chooser_menu_add_item (chooser,
+ menu,
+ _("Away"),
+ GOSSIP_PRESENCE_STATE_AWAY,
+ i++,
+ FALSE);
+ if (!sensitive) {
+ gtk_widget_set_sensitive (item, FALSE);
+ }
list = gossip_status_presets_get (GOSSIP_PRESENCE_STATE_AWAY, 5);
for (l = list; l; l = l->next) {
- presence_chooser_menu_add_item (chooser,
- menu,
- l->data,
- GOSSIP_PRESENCE_STATE_AWAY,
- FALSE);
+ item = presence_chooser_menu_add_item (chooser,
+ menu,
+ l->data,
+ GOSSIP_PRESENCE_STATE_AWAY,
+ i++,
+ FALSE);
+ if (!sensitive) {
+ gtk_widget_set_sensitive (item, FALSE);
+ }
}
g_list_free (list);
- presence_chooser_menu_add_item (chooser,
- menu,
- _("Custom message..."),
- GOSSIP_PRESENCE_STATE_AWAY,
- TRUE);
-
- /* Separator. */
- item = gtk_menu_item_new ();
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
+ item = presence_chooser_menu_add_item (chooser,
+ menu,
+ _("Custom message..."),
+ GOSSIP_PRESENCE_STATE_AWAY,
+ i++,
+ TRUE);
+ if (!sensitive) {
+ gtk_widget_set_sensitive (item, FALSE);
+ }
+
+ if (include_clear) {
+ /* Separator. */
+ item = gtk_menu_item_new ();
+
+ if (position == -1) {
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ } else {
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menu), item, i++);
+ }
- item = gtk_menu_item_new_with_label (_("Clear List..."));
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
+ gtk_widget_show (item);
+
+ item = gtk_menu_item_new_with_label (_("Clear List..."));
+
+ if (position == -1) {
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ } else {
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menu), item, i++);
+ }
- g_signal_connect (item,
- "activate",
- G_CALLBACK (presence_chooser_clear_activate_cb),
- chooser);
+ if (!sensitive) {
+ gtk_widget_set_sensitive (item, FALSE);
+ }
- return menu;
+ gtk_widget_show (item);
+
+ g_signal_connect (item,
+ "activate",
+ G_CALLBACK (presence_chooser_clear_activate_cb),
+ chooser);
+ }
}
void
Modified: trunk/src/gossip-presence-chooser.h
==============================================================================
--- trunk/src/gossip-presence-chooser.h (original)
+++ trunk/src/gossip-presence-chooser.h Tue Jul 8 10:04:48 2008
@@ -43,14 +43,21 @@
GtkToggleButtonClass parent_class;
};
-GType gossip_presence_chooser_get_type (void) G_GNUC_CONST;
-GtkWidget *gossip_presence_chooser_new (void);
-GtkWidget *gossip_presence_chooser_create_menu (GossipPresenceChooser *chooser);
-
-void gossip_presence_chooser_set_state (GossipPresenceChooser *chooser,
- GossipPresenceState state);
-void gossip_presence_chooser_set_status (GossipPresenceChooser *chooser,
- const gchar *status);
+GType gossip_presence_chooser_get_type (void) G_GNUC_CONST;
+GtkWidget *gossip_presence_chooser_new (void);
+GtkWidget *gossip_presence_chooser_create_menu (GossipPresenceChooser *chooser,
+ gint position,
+ gboolean sensitive,
+ gboolean include_clear);
+void gossip_presence_chooser_insert_menu (GossipPresenceChooser *chooser,
+ GtkWidget *menu,
+ gint position,
+ gboolean sensitive,
+ gboolean include_clear);
+void gossip_presence_chooser_set_state (GossipPresenceChooser *chooser,
+ GossipPresenceState state);
+void gossip_presence_chooser_set_status (GossipPresenceChooser *chooser,
+ const gchar *status);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]