changeset 17707:3c3fc1432a01

Let windows know when the workspace they are in is being hidden/shown
author Richard Nelson <wabz@pidgin.im>
date Sat, 12 May 2007 23:58:11 +0000
parents 8eed567eee39
children 4d4a396a478c
files finch/gntblist.c finch/libgnt/gntmenu.c finch/libgnt/gnttree.c finch/libgnt/gntwindow.c finch/libgnt/gntwindow.h finch/libgnt/gntws.c
diffstat 6 files changed, 52 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/finch/gntblist.c	Mon Apr 30 12:02:15 2007 +0000
+++ b/finch/gntblist.c	Sat May 12 23:58:11 2007 +0000
@@ -2274,6 +2274,8 @@
 				ggblist, 0, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
 	g_signal_connect_data(G_OBJECT(ggblist->tree), "lost-focus", G_CALLBACK(remove_peripherals),
 				ggblist, 0, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
+	g_signal_connect_data(G_OBJECT(ggblist->window), "workspace-hidden", G_CALLBACK(remove_peripherals),
+				ggblist, 0, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
 	g_signal_connect(G_OBJECT(ggblist->tree), "size_changed", G_CALLBACK(size_changed_cb), NULL);
 	g_signal_connect(G_OBJECT(ggblist->window), "position_set", G_CALLBACK(save_position_cb), NULL);
 	g_signal_connect(G_OBJECT(ggblist->window), "destroy", G_CALLBACK(reset_blist_window), NULL);
--- a/finch/libgnt/gntmenu.c	Mon Apr 30 12:02:15 2007 +0000
+++ b/finch/libgnt/gntmenu.c	Sat May 12 23:58:11 2007 +0000
@@ -220,7 +220,10 @@
 static void
 gnt_menu_hide(GntWidget *widget)
 {
-	GntMenu *menu = GNT_MENU(widget);
+	GntMenu *sub, *menu = GNT_MENU(widget);
+
+	while ((sub = menu->submenu))
+		gnt_widget_hide(GNT_WIDGET(sub));
 	if (menu->parentmenu)
 		menu->parentmenu->submenu = NULL;
 }
--- a/finch/libgnt/gnttree.c	Mon Apr 30 12:02:15 2007 +0000
+++ b/finch/libgnt/gnttree.c	Sat May 12 23:58:11 2007 +0000
@@ -281,7 +281,7 @@
 
 		notfirst = TRUE;
 
-		if (len > width) {
+		if (len > width - 2) {
 			len = width - 1;
 			cut = TRUE;
 		}
--- a/finch/libgnt/gntwindow.c	Mon Apr 30 12:02:15 2007 +0000
+++ b/finch/libgnt/gntwindow.c	Sat May 12 23:58:11 2007 +0000
@@ -5,9 +5,13 @@
 
 enum
 {
-	SIGS = 1,
+	SIG_WORKSPACE_HIDE,
+	SIG_WORKSPACE_SHOW,
+	SIGS,
 };
 
+static guint signals[SIGS] = { 0 };
+
 static GntBoxClass *parent_class = NULL;
 
 static void (*org_destroy)(GntWidget *widget);
@@ -42,6 +46,24 @@
 	org_destroy = wid_class->destroy;
 	wid_class->destroy = gnt_window_destroy;
 
+	signals[SIG_WORKSPACE_HIDE] =
+		g_signal_new("workspace-hidden",
+					 G_TYPE_FROM_CLASS(klass),
+					 G_SIGNAL_RUN_LAST,
+					 0,
+					 NULL, NULL,
+					 g_cclosure_marshal_VOID__VOID,
+					 G_TYPE_NONE, 0);
+
+	signals[SIG_WORKSPACE_SHOW] =
+		g_signal_new("workspace-shown",
+					 G_TYPE_FROM_CLASS(klass),
+					 G_SIGNAL_RUN_LAST,
+					 0,
+					 NULL, NULL,
+					 g_cclosure_marshal_VOID__VOID,
+					 G_TYPE_NONE, 0);
+
 	gnt_bindable_class_register_action(bindable, "show-menu", show_menu,
 				GNT_KEY_CTRL_O, NULL);
 	gnt_bindable_register_binding(bindable, "show-menu", GNT_KEY_F10, NULL);
@@ -109,6 +131,20 @@
 	return wid;
 }
 
+void
+gnt_window_workspace_hiding(GntWindow *window)
+{
+	if (window->menu)
+		gnt_widget_hide(GNT_WIDGET(window->menu));
+	g_signal_emit(window, signals[SIG_WORKSPACE_HIDE], 0);
+}
+
+void
+gnt_window_workspace_showing(GntWindow *window)
+{
+	g_signal_emit(window, signals[SIG_WORKSPACE_SHOW], 0);
+}
+
 void gnt_window_set_menu(GntWindow *window, GntMenu *menu)
 {
 	/* If a menu already existed, then destroy that first. */
--- a/finch/libgnt/gntwindow.h	Mon Apr 30 12:02:15 2007 +0000
+++ b/finch/libgnt/gntwindow.h	Sat May 12 23:58:11 2007 +0000
@@ -51,6 +51,9 @@
 
 void gnt_window_set_menu(GntWindow *window, GntMenu *menu);
 
+void gnt_window_workspace_hiding(GntWindow *);
+void gnt_window_workspace_showing(GntWindow *);
+
 G_END_DECLS
 
 #endif /* GNT_WINDOW_H */
--- a/finch/libgnt/gntws.c	Mon Apr 30 12:02:15 2007 +0000
+++ b/finch/libgnt/gntws.c	Sat May 12 23:58:11 2007 +0000
@@ -1,15 +1,18 @@
 #include <gmodule.h>
 
 #include "gntbox.h"
-#include "gntws.h"
+#include "gntwidget.h"
+#include "gntwindow.h"
 #include "gntwm.h"
-#include "gntwidget.h"
+#include "gntws.h"
 
 static void
 widget_hide(gpointer data, gpointer nodes)
 {
 	GntWidget *widget = GNT_WIDGET(data);
 	GntNode *node = g_hash_table_lookup(nodes, widget);
+	if (GNT_IS_WINDOW(widget))
+		gnt_window_workspace_hiding(GNT_WINDOW(widget));
 	hide_panel(node->panel);
 }