[Xfce4-commits] r26571 - in mousepad/branches/nick_0_3: . icons/16x16 icons/24x24 icons/scalable mousepad

Nick Schermer nick at xfce.org
Mon Jan 14 17:49:57 CET 2008


Author: nick
Date: 2008-01-14 16:49:57 +0000 (Mon, 14 Jan 2008)
New Revision: 26571

Modified:
   mousepad/branches/nick_0_3/Mousepad.desktop.in.in
   mousepad/branches/nick_0_3/Mousepad.spec.in
   mousepad/branches/nick_0_3/configure.in.in
   mousepad/branches/nick_0_3/icons/16x16/Makefile.am
   mousepad/branches/nick_0_3/icons/24x24/Makefile.am
   mousepad/branches/nick_0_3/icons/scalable/Makefile.am
   mousepad/branches/nick_0_3/mousepad/Makefile.am
   mousepad/branches/nick_0_3/mousepad/main.c
   mousepad/branches/nick_0_3/mousepad/mousepad-application.c
   mousepad/branches/nick_0_3/mousepad/mousepad-dialogs.c
   mousepad/branches/nick_0_3/mousepad/mousepad-preferences.c
   mousepad/branches/nick_0_3/mousepad/mousepad-preferences.h
   mousepad/branches/nick_0_3/mousepad/mousepad-print.c
   mousepad/branches/nick_0_3/mousepad/mousepad-private.h
   mousepad/branches/nick_0_3/mousepad/mousepad-util.c
   mousepad/branches/nick_0_3/mousepad/mousepad-util.h
   mousepad/branches/nick_0_3/mousepad/mousepad-window.c
Log:
* Drop libxfce4util as dependency
* Switch to accessories-text-editor as icon name


Modified: mousepad/branches/nick_0_3/Mousepad.desktop.in.in
===================================================================
--- mousepad/branches/nick_0_3/Mousepad.desktop.in.in	2008-01-14 11:33:17 UTC (rev 26570)
+++ mousepad/branches/nick_0_3/Mousepad.desktop.in.in	2008-01-14 16:49:57 UTC (rev 26571)
@@ -5,7 +5,7 @@
 _Comment=Simple Text Editor
 _GenericName=Text Editor
 Exec=mousepad %F
-Icon=mousepad
+Icon=accessories-text-editor
 Terminal=false
 StartupNotify=true
 Type=Application

Modified: mousepad/branches/nick_0_3/Mousepad.spec.in
===================================================================
--- mousepad/branches/nick_0_3/Mousepad.spec.in	2008-01-14 11:33:17 UTC (rev 26570)
+++ mousepad/branches/nick_0_3/Mousepad.spec.in	2008-01-14 16:49:57 UTC (rev 26571)
@@ -8,9 +8,7 @@
 Group:		Applications/X11
 BuildRoot:	%{_tmppath}/%{name}-root
 Requires:	gtk2 >= @GTK_REQUIRED_VERSION@
-Requires:	libxfce4util >= @LIBXFCE4UTIL_REQUIRED_VERSION@
 BuildRequires:	gtk2-devel >= @GTK_REQUIRED_VERSION@
-BuildRequires:	libxfce4util-devel >= @LIBXFCE4UTIL_REQUIRED_VERSION@
 
 %description
 Mousepad is a simple text editor for the Xfce Desktop Environment.

Modified: mousepad/branches/nick_0_3/configure.in.in
===================================================================
--- mousepad/branches/nick_0_3/configure.in.in	2008-01-14 11:33:17 UTC (rev 26570)
+++ mousepad/branches/nick_0_3/configure.in.in	2008-01-14 16:49:57 UTC (rev 26571)
@@ -69,8 +69,8 @@
 dnl **********************************
 dnl *** Check for standard headers ***
 dnl **********************************
-AC_CHECK_HEADERS([errno.h fcntl.h memory.h math.h stdlib.h string.h \
-                  sys/types.h sys/stat.h time.h unistd.h])
+AC_CHECK_HEADERS([errno.h fcntl.h libintl.h memory.h math.h stdlib.h \
+                  string.h sys/types.h sys/stat.h time.h unistd.h])
 
 dnl ******************************
 dnl *** Check for i18n support ***
@@ -84,7 +84,6 @@
 XDT_CHECK_PACKAGE([GMODULE], [gmodule-2.0], [2.12.0])
 XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.12.0])
 XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.10.0])
-XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.4.0])
 
 dnl **********************************
 dnl *** Optional support for D-BUS ***

Modified: mousepad/branches/nick_0_3/icons/16x16/Makefile.am
===================================================================
--- mousepad/branches/nick_0_3/icons/16x16/Makefile.am	2008-01-14 11:33:17 UTC (rev 26570)
+++ mousepad/branches/nick_0_3/icons/16x16/Makefile.am	2008-01-14 16:49:57 UTC (rev 26571)
@@ -1,10 +1,15 @@
 # $Id$
 
-appsdir = $(datadir)/icons/hicolor/16x16/apps
-apps_DATA =								\
+iconsdir = $(datadir)/icons/hicolor/16x16/apps
+icons_DATA =								\
 	Mousepad.png
 
+# install symlink
+install-data-local:
+	$(mkinstalldirs) $(DESTDIR)$(iconsdir)
+	-( cd $(DESTDIR)$(iconsdir) ; ln -sf Mousepad.png accessories-text-editor.png )
+
 EXTRA_DIST =								\
-	$(apps_DATA)
+	$(icons_DATA)
 
 # vi:set ts=8 sw=8 noet ai nocindent syntax=automake:

Modified: mousepad/branches/nick_0_3/icons/24x24/Makefile.am
===================================================================
--- mousepad/branches/nick_0_3/icons/24x24/Makefile.am	2008-01-14 11:33:17 UTC (rev 26570)
+++ mousepad/branches/nick_0_3/icons/24x24/Makefile.am	2008-01-14 16:49:57 UTC (rev 26571)
@@ -4,6 +4,11 @@
 icons_DATA =								\
 	Mousepad.png
 
+# install symlink
+install-data-local:
+	$(mkinstalldirs) $(DESTDIR)$(iconsdir)
+	-( cd $(DESTDIR)$(iconsdir) ; ln -sf Mousepad.png accessories-text-editor.png )
+
 EXTRA_DIST =								\
 	$(icons_DATA)
 

Modified: mousepad/branches/nick_0_3/icons/scalable/Makefile.am
===================================================================
--- mousepad/branches/nick_0_3/icons/scalable/Makefile.am	2008-01-14 11:33:17 UTC (rev 26570)
+++ mousepad/branches/nick_0_3/icons/scalable/Makefile.am	2008-01-14 16:49:57 UTC (rev 26571)
@@ -4,6 +4,11 @@
 icons_DATA =								\
 	Mousepad.svg
 
+# install symlink
+install-data-local:
+	$(mkinstalldirs) $(DESTDIR)$(iconsdir)
+	-( cd $(DESTDIR)$(iconsdir) ; ln -sf Mousepad.svg accessories-text-editor.svg )
+
 EXTRA_DIST =								\
 	$(icons_DATA)
 

Modified: mousepad/branches/nick_0_3/mousepad/Makefile.am
===================================================================
--- mousepad/branches/nick_0_3/mousepad/Makefile.am	2008-01-14 11:33:17 UTC (rev 26570)
+++ mousepad/branches/nick_0_3/mousepad/Makefile.am	2008-01-14 16:49:57 UTC (rev 26571)
@@ -59,7 +59,6 @@
 
 mousepad_CFLAGS =								\
 	$(GTK_CFLAGS)								\
-	$(LIBXFCE4UTIL_CFLAGS)							\
 	$(GMODULE_CFLAGS)							\
 	$(GTHREAD_CFLAGS)							\
 	$(PLATFORM_CFLAGS)
@@ -70,7 +69,6 @@
 
 mousepad_LDADD =								\
 	$(GTK_LIBS)								\
-	$(LIBXFCE4UTIL_LIBS)							\
 	$(GMODULE_LIBS)								\
 	$(GTHREAD_LIBS)
 

Modified: mousepad/branches/nick_0_3/mousepad/main.c
===================================================================
--- mousepad/branches/nick_0_3/mousepad/main.c	2008-01-14 11:33:17 UTC (rev 26570)
+++ mousepad/branches/nick_0_3/mousepad/main.c	2008-01-14 16:49:57 UTC (rev 26571)
@@ -25,6 +25,9 @@
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
+#ifdef HAVE_LIBINTL_H
+#include <libintl.h>
+#endif
 
 #include <mousepad/mousepad-private.h>
 #include <mousepad/mousepad-application.h>
@@ -68,9 +71,12 @@
   MousepadDBusService *dbus_service;
 #endif
 
-  /* translation domain */
-  xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
+  /* bind the text domain to the locale directory */
+  bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
 
+  /* set the package textdomain */
+  textdomain (GETTEXT_PACKAGE);
+
   /* default application name */
   g_set_application_name (_("Mousepad"));
 
@@ -105,7 +111,7 @@
   /* check if we should print version information */
   if (G_UNLIKELY (opt_version))
     {
-      g_print ("%s %s (Xfce %s)\n\n", PACKAGE_NAME, PACKAGE_VERSION, xfce_version_string ());
+      g_print ("%s %s\n\n", PACKAGE_NAME, PACKAGE_VERSION);
       g_print ("%s\n", "Copyright (c) 2007");
       g_print ("\t%s\n\n", _("The Xfce development team. All rights reserved."));
       g_print (_("Please report bugs to <%s>."), PACKAGE_BUGREPORT);

Modified: mousepad/branches/nick_0_3/mousepad/mousepad-application.c
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-application.c	2008-01-14 11:33:17 UTC (rev 26570)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-application.c	2008-01-14 16:49:57 UTC (rev 26571)
@@ -76,17 +76,17 @@
 static void
 mousepad_application_init (MousepadApplication *application)
 {
-  gchar *path;
+  gchar *filename;
 
   /* check if we have a saved accel map */
-  path = xfce_resource_lookup (XFCE_RESOURCE_CONFIG, PACKAGE_NAME G_DIR_SEPARATOR_S "accels.scm");
-  if (G_LIKELY (path != NULL))
+  filename = mousepad_util_get_save_location (MOUSEPAD_ACCELS_RELPATH, FALSE);
+  if (G_LIKELY (filename != NULL))
     {
       /* load the accel map */
-      gtk_accel_map_load (path);
+      gtk_accel_map_load (filename);
 
       /* cleanup */
-      g_free (path);
+      g_free (filename);
     }
 }
 
@@ -97,7 +97,7 @@
 {
   MousepadApplication *application = MOUSEPAD_APPLICATION (object);
   GSList              *li;
-  gchar               *path;
+  gchar               *filename;
 
   /* flush the history items of the replace dialog
    * this is a bit of an ugly place, but cleaning on a window close
@@ -105,14 +105,14 @@
   mousepad_replace_dialog_history_clean ();
 
   /* save the current accel map */
-  path = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, PACKAGE_NAME G_DIR_SEPARATOR_S "accels.scm", TRUE);
-  if (G_LIKELY (path != NULL))
+  filename = mousepad_util_get_save_location (MOUSEPAD_ACCELS_RELPATH, TRUE);
+  if (G_LIKELY (filename != NULL))
     {
       /* save the accel map */
-      gtk_accel_map_save (path);
+      gtk_accel_map_save (filename);
 
       /* cleanup */
-      g_free (path);
+      g_free (filename);
     }
 
   /* destroy the windows if they are still opened */

Modified: mousepad/branches/nick_0_3/mousepad/mousepad-dialogs.c
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-dialogs.c	2008-01-14 11:33:17 UTC (rev 26570)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-dialogs.c	2008-01-14 16:49:57 UTC (rev 26571)
@@ -40,8 +40,7 @@
                          "authors", authors,
                          "comments", _("Mousepad is a fast text editor for the Xfce Desktop Environment."),
                          "destroy-with-parent", TRUE,
-                         "license", XFCE_LICENSE_GPL,
-                         "logo-icon-name", PACKAGE_NAME,
+                         "logo-icon-name", "accessories-text-editor",
 #if GTK_CHECK_VERSION (2,12,0)
                          "program-name", PACKAGE_NAME,
 #else

Modified: mousepad/branches/nick_0_3/mousepad/mousepad-preferences.c
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-preferences.c	2008-01-14 11:33:17 UTC (rev 26570)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-preferences.c	2008-01-14 16:49:57 UTC (rev 26571)
@@ -122,8 +122,7 @@
  * @const GValue : String #GValue.
  * @GValue       : Return location for a #GValue boolean.
  *
- * Converts a string into a boolean. This is used when
- * converting the XfceRc values.
+ * Converts a string into a boolean.
  **/
 static void
 transform_string_to_boolean (const GValue *src,
@@ -357,8 +356,8 @@
   /* flush preferences */
   if (G_UNLIKELY (preferences->store_idle_id != 0))
     {
+      g_source_remove (preferences->store_idle_id);
       mousepad_preferences_store (preferences);
-      g_source_remove (preferences->store_idle_id);
     }
   /* release the property values */
   for (n = 1; n < N_PROPERTIES; ++n)
@@ -451,82 +450,88 @@
 static void
 mousepad_preferences_load (MousepadPreferences *preferences)
 {
-  const gchar  *string;
-  GParamSpec  **specs;
-  GParamSpec   *spec;
-  XfceRc       *rc;
-  GValue        dst = { 0, };
-  GValue        src = { 0, };
-  guint         nspecs;
-  guint         n;
+  gchar       *string;
+  GParamSpec **pspecs;
+  GParamSpec  *pspec;
+  GKeyFile    *keyfile;
+  gchar       *filename;
+  GValue       dst = { 0, };
+  GValue       src = { 0, };
+  guint        nspecs;
+  guint        n;
 
-  /* try to open the config file */
-  rc = xfce_rc_config_open (XFCE_RESOURCE_CONFIG, MOUSEPAD_PREFERENCES_REL_PATH, TRUE);
-  if (G_UNLIKELY (rc == NULL))
-    {
-      g_warning (_("Failed to load the preferences."));
+  /* get the save location */
+  filename = mousepad_util_get_save_location (MOUSEPAD_RC_RELPATH, FALSE);
 
-      return;
-    }
+  /* leave when there if no file found */
+  if (G_UNLIKELY (filename == NULL))
+    return;
 
-  /* freeze notification signals */
-  g_object_freeze_notify (G_OBJECT (preferences));
+  /* create a new key file */
+  keyfile = g_key_file_new ();
 
-  /* set group */
-  xfce_rc_set_group (rc, "Configuration");
+  /* open the config file */
+  if (G_LIKELY (g_key_file_load_from_file (keyfile, filename, G_KEY_FILE_NONE, NULL)))
+    {
+      /* freeze notification signals */
+      g_object_freeze_notify (G_OBJECT (preferences));
 
-  /* get all the properties in the class */
-  specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (preferences), &nspecs);
+      /* get all the properties in the class */
+      pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (preferences), &nspecs);
 
-  for (n = 0; n < nspecs; ++n)
-    {
-      spec = specs[n];
+      for (n = 0; n < nspecs; n++)
+        {
+          pspec = pspecs[n];
 
 #ifndef NDEBUG
-      /* check nick name with generated option name */
-      mousepad_preferences_check_option_name (spec);
+          /* check nick name with generated option name */
+          mousepad_preferences_check_option_name (pspec);
 #endif
 
-      /* read the entry */
-      string = xfce_rc_read_entry (rc, spec->_nick, NULL);
+          /* read the propert value */
+          string = g_key_file_get_string (keyfile, "Configuration", pspec->_nick, NULL);
 
-      if (G_UNLIKELY (string == NULL))
-        continue;
+          if (G_UNLIKELY (string == NULL))
+            continue;
 
-      /* create gvalue with the string as value */
-      g_value_init (&src, G_TYPE_STRING);
-      g_value_set_static_string (&src, string);
+          /* create gvalue with the string as value */
+          g_value_init (&src, G_TYPE_STRING);
+          g_value_take_string (&src, string);
 
-      if (spec->value_type == G_TYPE_STRING)
-        {
-          /* they have the same type, so set the property */
-          g_object_set_property (G_OBJECT (preferences), spec->name, &src);
+          if (pspec->value_type == G_TYPE_STRING)
+            {
+              /* they have the same type, so set the property */
+              g_object_set_property (G_OBJECT (preferences), pspec->name, &src);
+            }
+          else if (g_value_type_transformable (G_TYPE_STRING, pspec->value_type))
+            {
+              /* transform the type */
+              g_value_init (&dst, pspec->value_type);
+              if (g_value_transform (&src, &dst))
+                g_object_set_property (G_OBJECT (preferences), pspec->name, &dst);
+              g_value_unset (&dst);
+            }
+          else
+            {
+              g_warning ("Failed to load property \"%s\"", pspec->name);
+            }
+
+          /* cleanup */
+          g_value_unset (&src);
         }
-      else if (g_value_type_transformable (G_TYPE_STRING, spec->value_type))
-        {
-          /* transform the type */
-          g_value_init (&dst, spec->value_type);
-          if (g_value_transform (&src, &dst))
-            g_object_set_property (G_OBJECT (preferences), spec->name, &dst);
-          g_value_unset (&dst);
-        }
-      else
-        {
-          g_warning ("Failed to load property \"%s\"", spec->name);
-        }
 
-      /* cleanup */
-      g_value_unset (&src);
+      /* cleanup the specs */
+      g_free (pspecs);
+
+      /* allow notifications again */
+      g_object_thaw_notify (G_OBJECT (preferences));
     }
 
-  /* cleanup the specs */
-  g_free (specs);
+  /* free the key file */
+  g_key_file_free (keyfile);
 
-  /* close the rc file */
-  xfce_rc_close (rc);
-
-  /* allow notifications again */
-  g_object_thaw_notify (G_OBJECT (preferences));
+  /* cleanup filename */
+  g_free (filename);
 }
 
 
@@ -546,63 +551,76 @@
 static gboolean
 mousepad_preferences_store_idle (gpointer user_data)
 {
-  MousepadPreferences *preferences = MOUSEPAD_PREFERENCES (user_data);
-  const gchar         *string;
-  GParamSpec         **specs;
-  GParamSpec          *spec;
-  XfceRc              *rc;
-  GValue               dst = { 0, };
-  GValue               src = { 0, };
-  guint                nspecs;
-  guint                n;
+  MousepadPreferences  *preferences = MOUSEPAD_PREFERENCES (user_data);
+  const gchar          *string;
+  GParamSpec          **pspecs;
+  GParamSpec           *pspec;
+  GKeyFile             *keyfile;
+  gchar                *filename;
+  GValue                dst = { 0, };
+  GValue                src = { 0, };
+  guint                 nspecs;
+  guint                 n;
 
-  /* open the config file */
-  rc = xfce_rc_config_open (XFCE_RESOURCE_CONFIG, MOUSEPAD_PREFERENCES_REL_PATH, FALSE);
-  if (G_UNLIKELY (rc == NULL))
-    {
-      g_warning (_("Failed to store the preferences."));
-      return FALSE;
-    }
+  /* get the config filename */
+  filename = mousepad_util_get_save_location (MOUSEPAD_RC_RELPATH, TRUE);
 
-  /* set the group */
-  xfce_rc_set_group (rc, "Configuration");
+  /* leave when no filename is returned */
+  if (G_UNLIKELY (filename == NULL))
+    return FALSE;
 
+  /* create an empty key file */
+  keyfile = g_key_file_new ();
+
+  /* try to load the file contents, no worries if this fails */
+  g_key_file_load_from_file (keyfile, filename, G_KEY_FILE_NONE, NULL);
+
   /* get the list of properties in the class */
-  specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (preferences), &nspecs);
+  pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (preferences), &nspecs);
 
   for (n = 0; n < nspecs; ++n)
     {
-      spec = specs[n];
+      pspec = pspecs[n];
 
       /* init a string value */
       g_value_init (&dst, G_TYPE_STRING);
 
-      if (spec->value_type == G_TYPE_STRING)
+      if (pspec->value_type == G_TYPE_STRING)
         {
           /* set the string value */
-          g_object_get_property (G_OBJECT (preferences), spec->name, &dst);
+          g_object_get_property (G_OBJECT (preferences), pspec->name, &dst);
         }
       else
         {
           /* property contains another type, transform it first */
-          g_value_init (&src, spec->value_type);
-          g_object_get_property (G_OBJECT (preferences), spec->name, &src);
+          g_value_init (&src, pspec->value_type);
+          g_object_get_property (G_OBJECT (preferences), pspec->name, &src);
           g_value_transform (&src, &dst);
           g_value_unset (&src);
         }
 
-      /* store the setting */
+      /* get the string from the value */
       string = g_value_get_string (&dst);
+
+      /* store the value */
       if (G_LIKELY (string != NULL))
-        xfce_rc_write_entry (rc, spec->_nick, string);
+        g_key_file_set_string (keyfile, "Configuration", pspec->_nick, string);
 
       /* cleanup */
       g_value_unset (&dst);
     }
 
+  /* cleanup the specs */
+  g_free (pspecs);
+
+  /* save the keyfile */
+  mousepad_util_save_key_file (keyfile, filename);
+
+  /* close the key file */
+  g_key_file_free (keyfile);
+
   /* cleanup */
-  g_free (specs);
-  xfce_rc_close (rc);
+  g_free (filename);
 
   return FALSE;
 }

Modified: mousepad/branches/nick_0_3/mousepad/mousepad-preferences.h
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-preferences.h	2008-01-14 11:33:17 UTC (rev 26570)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-preferences.h	2008-01-14 16:49:57 UTC (rev 26571)
@@ -27,8 +27,6 @@
 #define MOUSEPAD_IS_PREFERENCES_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), MOUSEPAD_TYPE_PREFERENCES))
 #define MOUSEPAD_PREFERENCES_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), MOUSEPAD_TYPE_PREFERENCES, MousepadPreferencesClass))
 
-#define MOUSEPAD_PREFERENCES_REL_PATH         ("Mousepad" G_DIR_SEPARATOR_S "mousepadrc")
-
 typedef struct _MousepadPreferencesClass MousepadPreferencesClass;
 typedef struct _MousepadPreferences      MousepadPreferences;
 

Modified: mousepad/branches/nick_0_3/mousepad/mousepad-print.c
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-print.c	2008-01-14 11:33:17 UTC (rev 26570)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-print.c	2008-01-14 16:49:57 UTC (rev 26571)
@@ -159,12 +159,13 @@
 mousepad_print_settings_load (GtkPrintOperation *operation)
 {
   MousepadPrint         *print = MOUSEPAD_PRINT (operation);
-  XfceRc                *rc;
+  GKeyFile              *keyfile;
+  gchar                 *filename;
   GtkPrintSettings      *settings = NULL;
   gchar                **keys;
   gint                   i;
   gchar                 *key;
-  const gchar           *value;
+  gchar                 *value;
   GtkPageSetup          *page_setup;
   GtkPaperSize          *paper_size;
   PangoContext          *context;
@@ -173,13 +174,18 @@
   _mousepad_return_if_fail (MOUSEPAD_IS_DOCUMENT (print->document));
   _mousepad_return_if_fail (GTK_IS_WIDGET (print->document->textview));
 
-  /* open the config file */
-  rc = xfce_rc_config_open (XFCE_RESOURCE_CONFIG, MOUSEPAD_PREFERENCES_REL_PATH, TRUE);
+  /* get the config file filename */
+  filename = mousepad_util_get_save_location (MOUSEPAD_RC_RELPATH, FALSE);
+  if (G_UNLIKELY (filename == NULL))
+    return;
 
-  if (G_LIKELY (rc != NULL))
+  /* create a new keyfile */
+  keyfile = g_key_file_new ();
+
+  if (G_LIKELY (g_key_file_load_from_file (keyfile, filename, G_KEY_FILE_NONE, NULL)))
     {
       /* get all the keys from the config file */
-      keys = xfce_rc_get_entries (rc, "Print Settings");
+      keys = g_key_file_get_keys (keyfile, "Print Settings", NULL, NULL);
 
       if (G_LIKELY (keys))
         {
@@ -190,7 +196,7 @@
           for (i = 0; keys[i] != NULL; i++)
             {
               /* read the value from the config file */
-              value = xfce_rc_read_entry (rc, keys[i], NULL);
+              value = g_key_file_get_string (keyfile, "Print Settings", keys[i], NULL);
 
               /* set the value */
               if (G_LIKELY (value))
@@ -198,17 +204,21 @@
                   key = mousepad_util_key_name (keys[i]);
                   gtk_print_settings_set (settings, key, value);
                   g_free (key);
+                  g_free (value);
                 }
             }
 
           /* cleanup */
           g_strfreev (keys);
         }
-
-      /* close */
-      xfce_rc_close (rc);
     }
 
+  /* free the key file */
+  g_key_file_free (keyfile);
+
+  /* cleanup */
+  g_free (filename);
+
   if (G_LIKELY (settings))
     {
       /* apply the settings */
@@ -267,14 +277,14 @@
                                       const gchar *value,
                                       gpointer     user_data)
 {
-  XfceRc *rc = (XfceRc *) user_data;
-  gchar  *config;
+  GKeyFile *keyfile = user_data;
+  gchar    *config;
 
   /* save the setting */
   if (G_LIKELY (key && value))
     {
       config = mousepad_util_config_name (key);
-      xfce_rc_write_entry (rc, config, value);
+      g_key_file_set_string (keyfile, "Print Settings", config, value);
       g_free (config);
     }
 }
@@ -285,19 +295,21 @@
 mousepad_print_settings_save (GtkPrintOperation *operation)
 {
   MousepadPrint    *print = MOUSEPAD_PRINT (operation);
-  XfceRc           *rc;
+  GKeyFile         *keyfile;
+  gchar            *filename;
   GtkPrintSettings *settings;
   GtkPageSetup     *page_setup;
   GtkPaperSize     *paper_size;
 
-  /* open the config file */
-  rc = xfce_rc_config_open (XFCE_RESOURCE_CONFIG, MOUSEPAD_PREFERENCES_REL_PATH, FALSE);
+  /* get the save location */
+  filename = mousepad_util_get_save_location (MOUSEPAD_RC_RELPATH, TRUE);
 
-  if (G_LIKELY (rc != NULL))
+  /* create a new keyfile */
+  keyfile = g_key_file_new ();
+
+  /* load the existing settings */
+  if (G_LIKELY (g_key_file_load_from_file (keyfile, filename, G_KEY_FILE_NONE, NULL)))
     {
-      /* set print settings group */
-      xfce_rc_set_group (rc, "Print Settings");
-
       /* get the print settings */
       settings = gtk_print_operation_get_print_settings (operation);
 
@@ -336,12 +348,16 @@
           gtk_print_settings_set (settings, "font-name", print->font_name);
 
           /* store all the print settings */
-          gtk_print_settings_foreach (settings, mousepad_print_settings_save_foreach, rc);
+          gtk_print_settings_foreach (settings, mousepad_print_settings_save_foreach, keyfile);
+
+          /* save the contents */
+          mousepad_util_save_key_file (keyfile, filename);
         }
+    }
 
-      /* close */
-      xfce_rc_close (rc);
-    }
+  /* cleanup */
+  g_key_file_free (keyfile);
+  g_free (filename);
 }
 
 

Modified: mousepad/branches/nick_0_3/mousepad/mousepad-private.h
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-private.h	2008-01-14 11:33:17 UTC (rev 26570)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-private.h	2008-01-14 16:49:57 UTC (rev 26571)
@@ -21,10 +21,14 @@
 #include <glib.h>
 #include <glib-object.h>
 #include <gtk/gtk.h>
-#include <libxfce4util/libxfce4util.h>
+#include <glib/gi18n.h>
 
 G_BEGIN_DECLS
 
+/* config file locations */
+#define MOUSEPAD_RC_RELPATH     ("Mousepad" G_DIR_SEPARATOR_S "mousepadrc")
+#define MOUSEPAD_ACCELS_RELPATH ("Mousepad" G_DIR_SEPARATOR_S "accels.scm")
+
 /* handling flags */
 #define MOUSEPAD_SET_FLAG(flags,flag)   G_STMT_START{ ((flags) |= (flag)); }G_STMT_END
 #define MOUSEPAD_UNSET_FLAG(flags,flag) G_STMT_START{ ((flags) &= ~(flag)); }G_STMT_END

Modified: mousepad/branches/nick_0_3/mousepad/mousepad-util.c
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-util.c	2008-01-14 11:33:17 UTC (rev 26570)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-util.c	2008-01-14 16:49:57 UTC (rev 26571)
@@ -547,6 +547,87 @@
 
 
 
+gchar *
+mousepad_util_get_save_location (const gchar *relpath,
+                                 gboolean     create_parents)
+{
+  gchar *filename, *dirname;
+
+  _mousepad_return_val_if_fail (g_get_user_config_dir () != NULL, NULL);
+
+  /* create the full filename */
+  filename = g_build_filename (g_get_user_config_dir (), relpath, NULL);
+
+  /* test if the file exists */
+  if (G_UNLIKELY (g_file_test (filename, G_FILE_TEST_IS_REGULAR) == FALSE))
+    {
+      if (create_parents)
+        {
+          /* get the directory name */
+          dirname = g_path_get_dirname (filename);
+
+          /* make the directory with parents */
+          if (g_mkdir_with_parents (dirname, 0700) == -1)
+            {
+              /* show warning to the user */
+              g_critical (_("Unable to create base directory \"%s\". "
+                            "Saving to file \"%s\" will be aborted."), dirname, filename);
+
+              /* don't return a filename, to avoid problems */
+              g_free (filename);
+              filename = NULL;
+            }
+
+          /* cleanup */
+          g_free (dirname);
+        }
+      else
+        {
+          /* cleanup */
+          g_free (filename);
+          filename = NULL;
+        }
+    }
+
+  return filename;
+}
+
+
+
+void
+mousepad_util_save_key_file (GKeyFile    *keyfile,
+                             const gchar *filename)
+{
+  gchar  *contents;
+  gsize   length;
+  GError *error = NULL;
+
+  /* get the contents of the key file */
+  contents = g_key_file_to_data (keyfile, &length, &error);
+
+  if (G_LIKELY (error == NULL))
+    {
+      /* write the contents to the file */
+      if (G_UNLIKELY (g_file_set_contents (filename, contents, length, &error) == FALSE))
+        goto print_error;
+    }
+  else
+    {
+      print_error:
+
+      /* print error */
+      g_critical (_("Failed to store the preferences to \"%s\": %s"), filename, error->message);
+
+      /* cleanup */
+      g_error_free (error);
+    }
+
+  /* cleanup */
+  g_free (contents);
+}
+
+
+
 GType
 mousepad_util_search_flags_get_type (void)
 {

Modified: mousepad/branches/nick_0_3/mousepad/mousepad-util.h
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-util.h	2008-01-14 11:33:17 UTC (rev 26570)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-util.h	2008-01-14 16:49:57 UTC (rev 26571)
@@ -102,6 +102,12 @@
 gboolean   mousepad_util_forward_iter_to_text     (GtkTextIter         *iter,
                                                    const GtkTextIter   *limit);
 
+gchar     *mousepad_util_get_save_location        (const gchar         *relpath,
+                                                   gboolean             create_parents);
+
+void       mousepad_util_save_key_file            (GKeyFile            *keyfile,
+                                                   const gchar         *filename);
+
 GType      mousepad_util_search_flags_get_type    (void) G_GNUC_CONST;
 
 gint       mousepad_util_highlight                (GtkTextBuffer       *buffer,

Modified: mousepad/branches/nick_0_3/mousepad/mousepad-window.c
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-window.c	2008-01-14 11:33:17 UTC (rev 26570)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-window.c	2008-01-14 16:49:57 UTC (rev 26571)
@@ -550,20 +550,23 @@
   window->active = NULL;
   window->recent_manager = NULL;
 
+  /* setup window */
+  gtk_window_set_icon_name (GTK_WINDOW (window), "accessories-text-editor");
+
   /* increase clipboard history ref count */
   clipboard_history_ref_count++;
 
   /* add the preferences to the window */
   window->preferences = mousepad_preferences_get ();
 
+  /* signal for handling the window delete event */
+  g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (mousepad_window_delete_event), NULL);
+
   /* allocate a closure for the menu_item_selected() callback */
   window->menu_item_selected_closure = g_cclosure_new_object (G_CALLBACK (mousepad_window_menu_item_selected), G_OBJECT (window));
   g_closure_ref (window->menu_item_selected_closure);
   g_closure_sink (window->menu_item_selected_closure);
 
-  /* signal for handling the window delete event */
-  g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (mousepad_window_delete_event), NULL);
-
   /* allocate a closure for the menu_item_deselected() callback */
   window->menu_item_deselected_closure = g_cclosure_new_object (G_CALLBACK (mousepad_window_menu_item_deselected), G_OBJECT (window));
   g_closure_ref (window->menu_item_deselected_closure);
@@ -1818,7 +1821,7 @@
   mousepad_window_recent_menu (window);
 
   /* get the templates path */
-  templates_path = xfce_get_homefile ("Templates", NULL);
+  templates_path = g_build_filename (g_get_home_dir (), "Templates", NULL);
 
   /* check if the directory exists */
   if (g_file_test (templates_path, G_FILE_TEST_IS_DIR))



More information about the Xfce4-commits mailing list