From d67dc36bbec949e4cfe5cc0d6a837e6576b85080 Mon Sep 17 00:00:00 2001 From: TingPing Date: Sun, 18 Nov 2012 15:45:31 -0500 Subject: allow only one menu --- src/fe-gtk/plugin-tray.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/fe-gtk/plugin-tray.c b/src/fe-gtk/plugin-tray.c index 136e9b8e..4380b450 100644 --- a/src/fe-gtk/plugin-tray.c +++ b/src/fe-gtk/plugin-tray.c @@ -499,7 +499,7 @@ tray_menu_destroy (GtkWidget *menu, gpointer userdata) static void tray_menu_cb (GtkWidget *widget, guint button, guint time, gpointer userdata) { - GtkWidget *menu; + static GtkWidget *menu; #ifndef WIN32 GtkWidget *submenu; GtkWidget *item; @@ -509,6 +509,9 @@ tray_menu_cb (GtkWidget *widget, guint button, guint time, gpointer userdata) /* ph may have an invalid context now */ hexchat_set_context (ph, hexchat_find_context (ph, NULL, NULL)); + /* close any old menu */ + tray_menu_destroy (menu, NULL); + menu = gtk_menu_new (); /*gtk_menu_set_screen (GTK_MENU (menu), gtk_widget_get_screen (widget));*/ -- cgit 1.4.1 From a7631810bdd00232b6039cb94ed9079b46eba144 Mon Sep 17 00:00:00 2001 From: TingPing Date: Sun, 18 Nov 2012 16:35:18 -0500 Subject: auto close menu on windows --- src/fe-gtk/plugin-tray.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src') diff --git a/src/fe-gtk/plugin-tray.c b/src/fe-gtk/plugin-tray.c index 4380b450..a5623b3f 100644 --- a/src/fe-gtk/plugin-tray.c +++ b/src/fe-gtk/plugin-tray.c @@ -60,6 +60,8 @@ typedef GdkPixbuf* TrayIcon; static GtkStatusIcon *sticon; static gint flash_tag; static TrayStatus tray_status; +static guint tray_menu_timer; +static gint64 tray_menu_inactivetime; static hexchat_plugin *ph; static TrayIcon custom_icon1; @@ -494,8 +496,34 @@ tray_menu_destroy (GtkWidget *menu, gpointer userdata) { gtk_widget_destroy (menu); g_object_unref (menu); +#ifdef WIN32 + g_source_remove (tray_menu_timer); +#endif +} + +#ifdef WIN32 +static void +tray_menu_enter_cb (GtkWidget *menu) +{ + tray_menu_inactivetime = 0; +} + +static void +tray_menu_left_cb (GtkWidget *menu) +{ + tray_menu_inactivetime = g_get_real_time (); } +static void +tray_check_hide (GtkWidget *menu) +{ + if (tray_menu_inactivetime && g_get_real_time () - tray_menu_inactivetime >= 2000000) + { + tray_menu_destroy (menu, NULL); + } +} +#endif + static void tray_menu_cb (GtkWidget *widget, guint button, guint time, gpointer userdata) { @@ -549,6 +577,16 @@ tray_menu_cb (GtkWidget *widget, guint button, guint time, gpointer userdata) g_object_unref (menu); g_signal_connect (G_OBJECT (menu), "selection-done", G_CALLBACK (tray_menu_destroy), NULL); +#ifdef WIN32 + g_signal_connect (G_OBJECT (menu), "leave-notify-event", + G_CALLBACK (tray_menu_left_cb), NULL); + g_signal_connect (G_OBJECT (menu), "enter-notify-event", + G_CALLBACK (tray_menu_enter_cb), NULL); + + tray_menu_timer = g_timeout_add(500, (GSourceFunc) tray_check_hide, menu); +#endif + + gtk_menu_popup (GTK_MENU (menu), NULL, NULL, gtk_status_icon_position_menu, userdata, button, time); -- cgit 1.4.1 From ecde599fd456adc83f42cc842ac87cbec94b7610 Mon Sep 17 00:00:00 2001 From: TingPing Date: Mon, 19 Nov 2012 23:02:53 -0500 Subject: add missing ifdef --- src/fe-gtk/plugin-tray.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/fe-gtk/plugin-tray.c b/src/fe-gtk/plugin-tray.c index a5623b3f..94510e4d 100644 --- a/src/fe-gtk/plugin-tray.c +++ b/src/fe-gtk/plugin-tray.c @@ -60,8 +60,10 @@ typedef GdkPixbuf* TrayIcon; static GtkStatusIcon *sticon; static gint flash_tag; static TrayStatus tray_status; +#ifdef WIN32 static guint tray_menu_timer; static gint64 tray_menu_inactivetime; +#endif static hexchat_plugin *ph; static TrayIcon custom_icon1; @@ -586,8 +588,6 @@ tray_menu_cb (GtkWidget *widget, guint button, guint time, gpointer userdata) tray_menu_timer = g_timeout_add(500, (GSourceFunc) tray_check_hide, menu); #endif - - gtk_menu_popup (GTK_MENU (menu), NULL, NULL, gtk_status_icon_position_menu, userdata, button, time); } -- cgit 1.4.1 From a1c8fd998cca80423b0a365e3dff134b21fa2cb8 Mon Sep 17 00:00:00 2001 From: TingPing Date: Tue, 20 Nov 2012 15:25:38 -0500 Subject: ensure menu exists --- src/fe-gtk/plugin-tray.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/fe-gtk/plugin-tray.c b/src/fe-gtk/plugin-tray.c index 94510e4d..5c0d02ce 100644 --- a/src/fe-gtk/plugin-tray.c +++ b/src/fe-gtk/plugin-tray.c @@ -540,7 +540,10 @@ tray_menu_cb (GtkWidget *widget, guint button, guint time, gpointer userdata) hexchat_set_context (ph, hexchat_find_context (ph, NULL, NULL)); /* close any old menu */ - tray_menu_destroy (menu, NULL); + if (G_IS_OBJECT (menu)) + { + tray_menu_destroy (menu, NULL); + } menu = gtk_menu_new (); /*gtk_menu_set_screen (GTK_MENU (menu), gtk_widget_get_screen (widget));*/ -- cgit 1.4.1