[Rhythmbox-devel] [patch] Show window when not visible
- From: Rached Ben Mustapha <rached benmur net>
- To: rhythmbox-devel gnome org
- Subject: [Rhythmbox-devel] [patch] Show window when not visible
- Date: Wed, 13 Aug 2003 17:22:03 +0200
Hi,
The attached patch changes the click-on-tray-icon behaviour a bit. It
makes the main window be brought to front when it is not visible (for
example, on another desktop, or under another window), and hide it when
it is visible.
It is possible to tweak it so that it hides the window when it is not
fully obscured, much like to gaim docklet plugin. This way it would be
less intrusive and closer to the old behaviour.
This is something that I find excessively useful, but I am aware that
the patch is a bit kludgy, and that this behaviour may be disturbing for
some people, and not to mention the feature-freeze for 0.5.0.
It would be nice if it went in, though :)
Cheers,
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 14:23:21 -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_UNOBSCURED) {
+ shell->priv->window_obscured = FALSE;
+ } else {
+ shell->priv->window_obscured = TRUE;
+ }
+
+ 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]