[Goodies-commits] r7333 - in xfce4-clipman-plugin/trunk: . panel-plugin

Mike Massonnet mmassonnet at xfce.org
Thu May 14 06:31:11 CEST 2009


Author: mmassonnet
Date: 2009-05-14 04:31:11 +0000 (Thu, 14 May 2009)
New Revision: 7333

Modified:
   xfce4-clipman-plugin/trunk/ChangeLog
   xfce4-clipman-plugin/trunk/panel-plugin/main.c
Log:
Ask the user if the clipboard manager should be restarted

Modified: xfce4-clipman-plugin/trunk/ChangeLog
===================================================================
--- xfce4-clipman-plugin/trunk/ChangeLog	2009-05-12 21:14:23 UTC (rev 7332)
+++ xfce4-clipman-plugin/trunk/ChangeLog	2009-05-14 04:31:11 UTC (rev 7333)
@@ -1,3 +1,11 @@
+2009-05-14	Mike Massonnet
+Ask the user if the clipboard manager should be restarted
+
+	- panel-plugin/main.c(update_autostart_file):
+		New function to set the Hidden key to true or false.
+	- panel-plugin/main.c(cb_status_icon_quit):
+		Ask the user if the manager should be restarted.
+
 2009-04-26	Mike Massonnet
 Rename "Add selections" to "Sync selections"
 
@@ -2,3 +10,3 @@
 	- panel-plugin/settings-dialog.glade:
-		Rename the option Add selections
+		Rename the option Add selections.
 

Modified: xfce4-clipman-plugin/trunk/panel-plugin/main.c
===================================================================
--- xfce4-clipman-plugin/trunk/panel-plugin/main.c	2009-05-12 21:14:23 UTC (rev 7332)
+++ xfce4-clipman-plugin/trunk/panel-plugin/main.c	2009-05-14 04:31:11 UTC (rev 7333)
@@ -80,6 +80,7 @@
                                                          gint size);
 static void             cb_status_icon_finalize         (MyPlugin *plugin);
 static void             install_autostart_file          ();
+static void             update_autostart_file           ();
 
 /*
  * Panel Plugin
@@ -360,6 +361,11 @@
 static void
 cb_status_icon_quit (MyPlugin *plugin)
 {
+  res = xfce_message_dialog (NULL, _("Autostart Clipman"), GTK_STOCK_DIALOG_QUESTION,
+                             _("Autostart Clipman"), _("Do you want to restart the clipboard manager the next time you login?"),
+                             GTK_STOCK_YES, GTK_RESPONSE_YES, GTK_STOCK_NO, GTK_RESPONSE_NO, NULL);
+  update_autostart_file (res == GTK_RESPONSE_YES);
+
   gtk_status_icon_set_visible (plugin->status_icon, FALSE);
   gtk_main_quit ();
 }
@@ -429,6 +435,35 @@
   g_free (userfile);
 }
 
+static void
+update_autostart_file (gboolean autostart)
+{
+  gchar *userfile;
+  gint res;
+  GKeyFile *keyfile;
+  gchar *data;
+
+  userfile = g_strdup_printf ("%s/autostart/"PACKAGE"-autostart.desktop", g_get_user_config_dir ());
+
+  /* Check if the user autostart file exists */
+  if (!g_file_test (userfile, G_FILE_TEST_EXISTS))
+    {
+      g_warning ("The autostart file (%s) is not installed, what did you do?", userfile);
+      g_free (userfile);
+      return;
+    }
+
+  /* Update the file */
+  keyfile = g_key_file_new ();
+  g_key_file_load_from_file (keyfile, userfile, G_KEY_FILE_KEEP_TRANSLATIONS, NULL);
+  g_key_file_set_boolean (keyfile, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_HIDDEN, !autostart);
+  data = g_key_file_to_data (keyfile, NULL, NULL);
+  g_file_set_contents (userfile, data, -1, NULL);
+  g_free (data);
+  g_key_file_free (keyfile);
+  g_free (userfile);
+}
+
 /*
  * Panel Plugin
  */




More information about the Goodies-commits mailing list