[RESEND][PATCH] Gnome-CD: "Iconify to tray" option



Hello.

The patch add an option "iconify to tray", which simply hide the window
when the user click the iconify button.

The email I sent before have attached the wrong patch file. This is the right one.
-- 
Ramón Rey Vicente	<ramon dot rey at hispalinux dot es>
jabber ID		<rreylinux at jabber dot org>
GPG public key ID	0xBEBD71D5 -> http://pgp.escomposlinux.org/
Index: gnome-cd.c
===================================================================
RCS file: /cvs/gnome/gnome-media/gnome-cd/gnome-cd.c,v
retrieving revision 1.77
diff -u -r1.77 gnome-cd.c
--- gnome-cd.c	9 Mar 2004 07:51:27 -0000	1.77
+++ gnome-cd.c	9 Apr 2004 21:20:51 -0000
@@ -777,6 +777,13 @@
 	g_object_unref (G_OBJECT (factory));
 }
 
+static void
+iconify_to_tray_cb  (GtkWidget *widget, GdkEventButton *event, GnomeCD *gcd)
+{
+	if (gcd->preferences->iconify_to_tray)
+		gtk_widget_hide (gcd->window);
+}
+
 int 
 main (int argc, char *argv[])
 {
@@ -823,7 +830,10 @@
 	gtk_widget_show_all (gcd->window);
 	g_signal_connect (client, "die",
 			  G_CALLBACK (client_die), gcd);
-
+	
+	g_signal_connect (gcd->window, "unmap_event", 
+			G_CALLBACK (iconify_to_tray_cb), gcd);
+	
 	if (cd_option_play || gcd->preferences->start_play) {
 		/* Just fake a click on the button */
 		play_cb (NULL, gcd);
Index: gnome-cd.schemas.in.in
===================================================================
RCS file: /cvs/gnome/gnome-media/gnome-cd/gnome-cd.schemas.in.in,v
retrieving revision 1.5
diff -u -r1.5 gnome-cd.schemas.in.in
--- gnome-cd.schemas.in.in	3 Jul 2003 07:25:03 -0000	1.5
+++ gnome-cd.schemas.in.in	9 Apr 2004 21:20:51 -0000
@@ -49,5 +49,16 @@
       </locale>
     </schema>
 
+    <schema>
+      <key>/schemas/apps/gnome-cd/iconify-to-tray</key>
+      <applyto>/apps/gnome-cd/iconify-to-tray</applyto>
+      <owner>Gnome-CD</owner>
+      <type>bool</type>
+      <default>FALSE</default>
+      <locale name="C">
+      <short>Iconify the Gnome-CD window to the notification area.</short>
+      <long>Iconify the Gnome-CD window to the notification area.</long>
+      </locale>
+    </schema>
   </schemalist>
 </gconfschemafile>
Index: preferences.c
===================================================================
RCS file: /cvs/gnome/gnome-media/gnome-cd/preferences.c,v
retrieving revision 1.29
diff -u -r1.29 preferences.c
--- preferences.c	23 Feb 2004 08:43:57 -0000	1.29
+++ preferences.c	9 Apr 2004 21:20:52 -0000
@@ -169,6 +169,19 @@
 }
 
 static void
+on_iconify_changed (GConfClient *_client,
+		     guint cnxn_id,
+	             GConfEntry *entry,
+	             gpointer user_data)
+{
+	GnomeCDPreferences *prefs = user_data;
+	GConfValue *value = gconf_entry_get_value (entry);
+
+	prefs->iconify_to_tray = gconf_value_get_bool (value);
+}
+
+
+static void
 restore_preferences (GnomeCDPreferences *prefs)
 {
 	GError *error = NULL;
@@ -211,6 +224,14 @@
 						  on_stop_changed, prefs,
 						  NULL, NULL);
 
+	prefs->iconify_to_tray = gconf_client_get_bool (client,
+					     "/apps/gnome-cd/on-iconify-to-tray",
+					      NULL);
+	prefs->iconify_id = gconf_client_notify_add (client,
+						"/apps/gnome-cd/on-iconify-to-tray",
+						on_iconify_changed, prefs,
+					      	NULL, NULL);
+
 	prefs->theme_name = gconf_client_get_string (client,
 						     "/apps/gnome-cd/theme-name", NULL);
 	if (prefs->theme_name == NULL) {
@@ -235,6 +256,7 @@
 	gconf_client_notify_remove (client, prefs->start_id);
 	gconf_client_notify_remove (client, prefs->stop_id);
 	gconf_client_notify_remove (client, prefs->theme_id);
+	gconf_client_notify_remove (client, prefs->iconify_id);
 
 	g_free (prefs);
 }
@@ -267,12 +289,16 @@
 	GtkWidget *stop_open;
 	
 	GtkWidget *theme_list;
+
+	GtkWidget *iconify_to_tray;
 	
 	guint start_id;
 	guint device_id;
 	
 	guint stop_id;
 	guint theme_id;
+
+	guint iconify_id;
 } PropertyDialog;
 
 static void
@@ -324,6 +350,7 @@
 	gconf_client_notify_remove (client, pd->start_id);
 	gconf_client_notify_remove (client, pd->stop_id); 
 	gconf_client_notify_remove (client, pd->theme_id);
+	gconf_client_notify_remove (client, pd->iconify_id);
 	
 	g_free (pd);
 }
@@ -408,6 +435,16 @@
 }
 
 static void
+iconify_to_tray_toggled_cb (GtkToggleButton *tb,
+			PropertyDialog *pd)
+{
+	gconf_client_set_bool (client, "/apps/gnome-cd/on-iconify-to-tray",
+			       gtk_toggle_button_get_active (tb), NULL);
+	
+}
+
+
+static void
 change_play_widget (GConfClient *_client,
 		    guint cnxn,
 		    GConfEntry *entry,
@@ -756,6 +793,22 @@
 	gtk_widget_show (label);
 	gtk_box_pack_start (GTK_BOX (inner_vbox), label, FALSE, FALSE, 0);
 
+
+	/* iconify the window to tray */
+        gtk_box_pack_start (GTK_BOX (action_vbox), label, FALSE, FALSE, 0);
+
+	pd->iconify_to_tray = gtk_check_button_new_with_mnemonic (_("_Iconify the window to the notification area"));
+	add_description (pd->iconify_to_tray, _("Iconify the window to the notification area"));
+
+	if (gcd->preferences->iconify_to_tray) {
+		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pd->iconify_to_tray), TRUE);
+	}
+	
+	g_signal_connect (G_OBJECT (pd->iconify_to_tray), "toggled",
+			  G_CALLBACK (iconify_to_tray_toggled_cb), pd);
+
+	gtk_box_pack_start (GTK_BOX (action_vbox), pd->iconify_to_tray, FALSE, FALSE, 0);
+	
 	/* Theme */
 	hbox = gtk_hbox_new (FALSE, 0);
 	gtk_box_pack_start (GTK_BOX (inner_vbox), hbox, TRUE, TRUE, 0);
Index: preferences.h
===================================================================
RCS file: /cvs/gnome/gnome-media/gnome-cd/preferences.h,v
retrieving revision 1.5
diff -u -r1.5 preferences.h
--- preferences.h	14 Mar 2003 01:52:19 -0000	1.5
+++ preferences.h	9 Apr 2004 21:20:52 -0000
@@ -32,12 +32,15 @@
 	
 	gboolean start_play;
 	gboolean stop_eject;
+
+	gboolean iconify_to_tray;
 	
 	/* GConf IDs */
 	guint device_id;
 	guint start_id;
 	guint stop_id;
 	guint theme_id;
+	guint iconify_id;
 } GnomeCDPreferences;
 
 GnomeCDPreferences *preferences_new         (GnomeCD *gcd);

Attachment: signature.asc
Description: Esta parte del mensaje =?ISO-8859-1?Q?est=E1?= firmada digitalmente



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