[Goodies-commits] r7209 - in xfce4-clipman-plugin/trunk: . panel-plugin
Mike Massonnet
mmassonnet at xfce.org
Wed Apr 15 21:45:54 CEST 2009
Author: mmassonnet
Date: 2009-04-15 19:45:53 +0000 (Wed, 15 Apr 2009)
New Revision: 7209
Added:
xfce4-clipman-plugin/trunk/panel-plugin/xfce4-clipman-plugin-autostart.desktop.in
Modified:
xfce4-clipman-plugin/trunk/ChangeLog
xfce4-clipman-plugin/trunk/panel-plugin/Makefile.am
xfce4-clipman-plugin/trunk/panel-plugin/main.c
Log:
Install autostart file automagically
Modified: xfce4-clipman-plugin/trunk/ChangeLog
===================================================================
--- xfce4-clipman-plugin/trunk/ChangeLog 2009-04-15 18:57:46 UTC (rev 7208)
+++ xfce4-clipman-plugin/trunk/ChangeLog 2009-04-15 19:45:53 UTC (rev 7209)
@@ -1,4 +1,17 @@
2009-04-15 Mike Massonnet
+Install autostart file automagically
+
+ - panel-plugin/xfce4-clipman-plugin-autostart.desktop.in,
+ panel-plugin/Makefile.am:
+ Install a system wide autostart file with Hidden set to true
+ by default.
+ - panel-plugin/main.c:
+ New function install_autostart_file() called after creating
+ the status icon to install the autostart file to the user
+ config directory (thus at the first run) with the key Hidden
+ set automatically to either false or left to true.
+
+2009-04-15 Mike Massonnet
Replace g_idle against g_timeout
- panel-plugin/main.c(status_icon_register):
Modified: xfce4-clipman-plugin/trunk/panel-plugin/Makefile.am
===================================================================
--- xfce4-clipman-plugin/trunk/panel-plugin/Makefile.am 2009-04-15 18:57:46 UTC (rev 7208)
+++ xfce4-clipman-plugin/trunk/panel-plugin/Makefile.am 2009-04-15 19:45:53 UTC (rev 7209)
@@ -106,3 +106,12 @@
sed -e "s^@EXTERNAL_PLUGIN_PATH@^$(bindir)^" \
$< > $@
+#
+# Autostart File
+#
+
+autostartdir = $(sysconfdir)/xdg/autostart
+autostart_in_files = xfce4-clipman-plugin-autostart.desktop.in
+autostart_DATA = $(autostart_in_files:.desktop.in=.desktop)
+ at INTLTOOL_DESKTOP_RULE@
+
Modified: xfce4-clipman-plugin/trunk/panel-plugin/main.c
===================================================================
--- xfce4-clipman-plugin/trunk/panel-plugin/main.c 2009-04-15 18:57:46 UTC (rev 7208)
+++ xfce4-clipman-plugin/trunk/panel-plugin/main.c 2009-04-15 19:45:53 UTC (rev 7209)
@@ -72,6 +72,7 @@
guint activate_time);
static gboolean cb_status_icon_set_size (MyPlugin *plugin,
gint size);
+static void install_autostart_file ();
/*
* Panel Plugin
@@ -188,6 +189,7 @@
g_set_application_name (_("Clipman"));
plugin = status_icon_register ();
+ install_autostart_file ();
gtk_main ();
@@ -346,6 +348,52 @@
return TRUE;
}
+static void
+install_autostart_file ()
+{
+ gchar *sysfile;
+ gchar *userfile;
+ gint res;
+ GKeyFile *keyfile;
+ gchar *data;
+
+ sysfile = g_strdup (SYSCONFDIR"/xdg/autostart/"PACKAGE"-autostart.desktop");
+ userfile = g_strdup_printf ("%s/autostart/"PACKAGE"-autostart.desktop", g_get_user_config_dir ());
+
+ if (!g_file_test (sysfile, G_FILE_TEST_EXISTS))
+ {
+ g_warning ("The autostart file (%s) is missing in the system installation", sysfile);
+ goto out;
+ }
+
+ /* Check if the user autostart file exists */
+ if (g_file_test (userfile, G_FILE_TEST_EXISTS))
+ {
+ goto out;
+ }
+
+ /* Ask the user */
+ res = xfce_message_dialog (NULL, _("Autostart Clipman"), GTK_STOCK_DIALOG_QUESTION,
+ _("Autostart Clipman"), _("Do you want to autostart the clipboard manager?"),
+ GTK_STOCK_YES, GTK_RESPONSE_YES, GTK_STOCK_NO, GTK_RESPONSE_NO, NULL);
+
+ /* Copy the file */
+ keyfile = g_key_file_new ();
+ g_key_file_load_from_file (keyfile, sysfile, G_KEY_FILE_KEEP_TRANSLATIONS, NULL);
+ if (res == GTK_RESPONSE_YES)
+ {
+ g_key_file_set_boolean (keyfile, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_HIDDEN, FALSE);
+ }
+ 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);
+
+out:
+ g_free (sysfile);
+ g_free (userfile);
+}
+
/*
* Panel Plugin
*/
Added: xfce4-clipman-plugin/trunk/panel-plugin/xfce4-clipman-plugin-autostart.desktop.in
===================================================================
--- xfce4-clipman-plugin/trunk/panel-plugin/xfce4-clipman-plugin-autostart.desktop.in (rev 0)
+++ xfce4-clipman-plugin/trunk/panel-plugin/xfce4-clipman-plugin-autostart.desktop.in 2009-04-15 19:45:53 UTC (rev 7209)
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Type=Application
+_Name=Clipman
+_Comment=Clipboards manager
+TryExec=xfce4-clipman-plugin
+Exec=xfce4-clipman-plugin
+Icon=xfce4-clipman-plugin
+OnlyShowIn=XFCE;
+Terminal=false
+Hidden=true
More information about the Goodies-commits
mailing list