Re: [Rhythmbox-devel] [patch] Show window when not visible



On Wed, 2003-08-13 at 16:15, Douglas McMorris wrote:

[...]

> Yay!! another person who thinks like me... well... at least on this.

I'm pleased to see that I'm not the only lazy slacker wanting not to
click twice to bring the window in front of me :)

Here's attached a slightly different version of the patch that does
exactly like gaim : it hides the window if at least some part of it is
visible, shows it otherwise. This one may confuse people a bit less :)

Rached

Index: shell/rb-shell.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/shell/rb-shell.c,v
retrieving revision 1.154
diff -u -r1.154 rb-shell.c
--- shell/rb-shell.c	13 Aug 2003 02:19:14 -0000	1.154
+++ shell/rb-shell.c	13 Aug 2003 17:40:26 -0000
@@ -106,6 +106,9 @@
 static gboolean rb_shell_window_delete_cb (GtkWidget *win,
 			                   GdkEventAny *event,
 			                   RBShell *shell);
+static gboolean rb_shell_window_visibility_cb (GtkWidget *win,
+			                   GdkEventVisibility *event,
+			                   RBShell *shell);
 static void rb_shell_sync_window_state (RBShell *shell);
 static void rb_shell_sync_paned (RBShell *shell);
 static void paned_size_allocate_cb (GtkWidget *widget,
@@ -258,6 +261,7 @@
 struct RBShellPrivate
 {
 	GtkWidget *window;
+	gboolean window_obscured;
 
 	BonoboUIComponent *ui_component;
 	BonoboUIContainer *container;
@@ -616,7 +620,11 @@
 	g_signal_connect (G_OBJECT (win), "delete_event",
 			  G_CALLBACK (rb_shell_window_delete_cb),
 			  shell);
-
+	g_signal_connect (G_OBJECT (win), "visibility-notify-event",
+			  G_CALLBACK (rb_shell_window_visibility_cb),
+			  shell);
+	gtk_widget_add_events (GTK_WIDGET (win), GDK_VISIBILITY_NOTIFY_MASK);
+  
 	rb_debug ("shell: creating container area");
 	shell->priv->container = bonobo_window_get_ui_container (win);
 
@@ -915,6 +923,22 @@
 	return TRUE;
 };
 
+static gboolean
+rb_shell_window_visibility_cb (GtkWidget *win,
+			       GdkEventVisibility *event,
+			       RBShell *shell)
+{
+	rb_debug ("window visibility changed");
+
+	if (event->state == GDK_VISIBILITY_FULLY_OBSCURED) {
+		shell->priv->window_obscured = TRUE;
+	} else {
+		shell->priv->window_obscured = FALSE;
+	}
+    
+	return FALSE;
+}
+
 static void
 source_selected_cb (RBSourceList *sourcelist,
 		    RBSource *source,
@@ -1953,13 +1977,21 @@
 			    GdkEventButton *event,
 			    RBShell *shell)
 {
+	gboolean window_hidden;
+  
 	switch (event->button)
 	{
 	case 1:
 		/* toggle mainwindow visibility */
-		eel_gconf_set_boolean (CONF_STATE_WINDOW_HIDDEN,
-				       !eel_gconf_get_boolean (CONF_STATE_WINDOW_HIDDEN));
+		window_hidden = eel_gconf_get_boolean (CONF_STATE_WINDOW_HIDDEN);
+
+		if (window_hidden || !shell->priv->window_obscured) {
+			eel_gconf_set_boolean (CONF_STATE_WINDOW_HIDDEN, !window_hidden);
+		} else {
+			gtk_window_present (GTK_WINDOW(shell->priv->window));
+		}
 		break;
+    
 	case 3:
 		/* contextmenu */
 		sync_tray_menu (shell);


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