Renaming maemo-tweaks to tweakr.
authorSalvatore Iovene <salvatore@iovene.com>
Fri, 11 Dec 2009 06:46:38 +0000 (08:46 +0200)
committerSalvatore Iovene <salvatore@iovene.com>
Fri, 11 Dec 2009 06:46:38 +0000 (08:46 +0200)
42 files changed:
Makefile.am
configure.ac
debian/changelog
debian/control
debian/libmaemo-tweaks-section-dev.install [deleted file]
debian/libtweakr-section-dev.install [new file with mode: 0644]
debian/maemo-tweaks-modules.install [deleted file]
debian/maemo-tweaks.install [deleted file]
debian/rules
debian/tweakr-modules.install [new file with mode: 0644]
debian/tweakr.install [new file with mode: 0644]
libmaemo-tweaks-section/Makefile.am [deleted file]
libmaemo-tweaks-section/maemo-tweaks-module.c [deleted file]
libmaemo-tweaks-section/maemo-tweaks-module.h [deleted file]
libmaemo-tweaks-section/maemo-tweaks-section.c [deleted file]
libmaemo-tweaks-section/maemo-tweaks-section.h [deleted file]
libmaemo-tweaks-section/maemo-tweaks-section.pc.in [deleted file]
libtweakr-section/Makefile.am [new file with mode: 0644]
libtweakr-section/tweakr-module.c [new file with mode: 0644]
libtweakr-section/tweakr-module.h [new file with mode: 0644]
libtweakr-section/tweakr-section.c [new file with mode: 0644]
libtweakr-section/tweakr-section.h [new file with mode: 0644]
libtweakr-section/tweakr-section.pc.in [new file with mode: 0644]
maemo-tweaks-module-manager.c [deleted file]
maemo-tweaks-module-manager.h [deleted file]
maemo-tweaks-types.h [deleted file]
maemo-tweaks.c [deleted file]
maemo-tweaks.desktop [deleted file]
modules/Makefile.am
modules/maemo-tweaks-desktop-save.c [deleted file]
modules/maemo-tweaks-desktop.c [deleted file]
modules/maemo-tweaks-mce-save.c [deleted file]
modules/maemo-tweaks-mce.c [deleted file]
modules/tweakr-desktop-save.c [new file with mode: 0644]
modules/tweakr-desktop.c [new file with mode: 0644]
modules/tweakr-mce-save.c [new file with mode: 0644]
modules/tweakr-mce.c [new file with mode: 0644]
tweakr-module-manager.c [new file with mode: 0644]
tweakr-module-manager.h [new file with mode: 0644]
tweakr-types.h [new file with mode: 0644]
tweakr.c [new file with mode: 0644]
tweakr.desktop [new file with mode: 0644]

index 8b1f884..3454fff 100644 (file)
@@ -1,34 +1,36 @@
-SUBDIRS = libmaemo-tweaks-section modules
+SUBDIRS = libtweakr-section modules
 
-libmaemo_tweaks_section = \
-       $(top_builddir)/libmaemo-tweaks-section/libmaemo-tweaks-section.la
+libtweakr_section = \
+       $(top_builddir)/libtweakr-section/libtweakr-section.la
 
-libmaemo_tweaks_LTLIBRARIES = libmaemo-tweaks.la
-libmaemo_tweaksdir = $(libdir)/hildon-control-panel
+libtweakr_LTLIBRARIES = libtweakr.la
+libtweakrdir = $(libdir)/hildon-control-panel
 
-libmaemo_tweaks_la_LDFLAGS = -version-info "1":"0":"1"
-libmaemo_tweaks_la_LIBADD = \
+libtweakr_la_LDFLAGS = -version-info "1":"0":"1"
+libtweakr_la_LIBADD = \
        $(GTK_LIBS) \
        $(HILDON_LIBS) \
        $(OSSO_LIBS) \
-       $(libmaemo_tweaks_section)
+       $(CPA_LIBS) \
+       $(libtweakr_section)
 
 AM_CFLAGS = \
        $(GTK_CFLAGS) \
        $(HILDON_CFLAGS) \
        $(OSSO_CFLAGS) \
+       $(CPA_LIBS) \
        -I$(top_srcdir) \
        -DMODULES_DIR=\"$(modulesdir)\" \
-       -DG_LOG_DOMAIN=\"maemo-tweaks\"
+       -DG_LOG_DOMAIN=\"tweakr\"
 
-libmaemo_tweaks_la_SOURCES = \
-       maemo-tweaks.c  \
-       maemo-tweaks-types.h    \
-       maemo-tweaks-module-manager.c   \
-       maemo-tweaks-module-manager.h
+libtweakr_la_SOURCES = \
+       tweakr.c        \
+       tweakr-types.h  \
+       tweakr-module-manager.c \
+       tweakr-module-manager.h
 
 desktopentrydir = $(prefix)/share/applications/hildon-control-panel
-desktopentry_DATA = maemo-tweaks.desktop
+desktopentry_DATA = tweakr.desktop
 
 EXTRA_DIST = $(desktopentry_DATA)
 
index 8f058e6..6210cc6 100644 (file)
@@ -1,4 +1,4 @@
-AC_INIT(maemo-tweaks, 0.0.1)
+AC_INIT(tweakr, 0.0.1)
 
 AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
 AM_CONFIG_HEADER(config.h)
@@ -25,6 +25,12 @@ PKG_CHECK_MODULES(OSSO, libosso)
 AC_SUBST(OSSO_LIBS)
 AC_SUBST(OSSO_CFLAGS)
 
+PKG_CHECK_MODULES(OSSO, hildon-control-panel)
+AC_SUBST(CPA_LIBS)
+AC_SUBST(CPA_CFLAGS)
+
+CFLAGS="-g -O0"
+
 AC_ARG_ENABLE(cast-checks,  [  --disable-cast-checks   compile with GLIB cast checks disabled],[cchecks=${enableval}],cchecks=yes)
 if test "x$cchecks" = "xno"; then
     CFLAGS="$CFLAGS -DG_DISABLE_CAST_CHECKS"
@@ -50,9 +56,9 @@ if test "x$coverage" = "xyes"; then
     CFLAGS="$CFLAGS -g -fprofile-arcs -ftest-coverage"
 fi
 
-AC_ARG_WITH(modules_dir, AS_HELP_STRING([--with-modules-dir=<path>],[Directory for storing maemo-tweaks modules]))
+AC_ARG_WITH(modules_dir, AS_HELP_STRING([--with-modules-dir=<path>],[Directory for storing tweakr modules]))
 if test -z "$with_modules_dir" ; then
-    modulesdir=$libdir/maemo-tweaks/modules
+    modulesdir=$libdir/tweakr/modules
 else
     modulesdir=$with_modules_dir
 fi
@@ -60,8 +66,8 @@ AC_SUBST(modulesdir)
 
 AC_OUTPUT([
            Makefile
-           libmaemo-tweaks-section/Makefile
-           libmaemo-tweaks-section/maemo-tweaks-section.pc
+           libtweakr-section/Makefile
+           libtweakr-section/tweakr-section.pc
            modules/Makefile
            ])
 
index 324fd19..9afe1cf 100644 (file)
@@ -1,4 +1,4 @@
-maemo-tweaks (0.0.1-1) UNRELEASED; urgency=low
+tweakr (0.0.1-1) UNRELEASED; urgency=low
 
   * Initial release.
 
index 35c2c57..6dcadcd 100644 (file)
@@ -1,27 +1,27 @@
-Source: maemo-tweaks
+Source: tweakr
 Priority: optional
 Maintainer: Salvatore Iovene <salvatore@iovene.com>
-Build-Depends: debhelper (>= 4.1.0), cdbs, libgtk2.0-dev, libhildon1-dev, libosso-dev, libglib2.0-dev
+Build-Depends: debhelper (>= 4.1.0), cdbs, libgtk2.0-dev, libhildon1-dev, libosso-dev, libglib2.0-dev, hildon-control-panel-dev
 Standards-Version: 3.6.0
 
-Package: maemo-tweaks
+Package: tweakr
 Architecture: any
 Section: libs
 Depends: ${shlibs:Depends}, ${misc:depends}
 Description: Control panel applet for tweaking various settings
  An applet that tweaks various settings otherwise hardly accessible.
 
-Package: libmaemo-tweaks-section-dev
+Package: libtweakr-section-dev
 Architecture: any
 Section: devel
 Depends: ${shlibs:Depends}, ${misc:depends}
-Description: Library needed to write maemo-tweaks modules
- Development symbols for maemo-tweaks
+Description: Library needed to write tweakr modules
+ Development symbols for tweakr
 
-Package: maemo-tweaks-modules
+Package: tweakr-modules
 Architecture: any
 Section: libs
 Depends: ${shlibs:Depends}, ${misc:depends}
-Description: maemo-tweaks core modules
- Contains all the core modules for maemo-tweaks
+Description: tweakr core modules
+ Contains all the core modules for tweakr
 
diff --git a/debian/libmaemo-tweaks-section-dev.install b/debian/libmaemo-tweaks-section-dev.install
deleted file mode 100644 (file)
index 74142fe..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-usr/lib/libmaemo-tweaks-section.so*
-usr/lib/libmaemo-tweaks-section.a
-usr/lib/pkgconfig/maemo-tweaks-section.pc
-usr/include/maemo-tweaks/*
diff --git a/debian/libtweakr-section-dev.install b/debian/libtweakr-section-dev.install
new file mode 100644 (file)
index 0000000..372ba11
--- /dev/null
@@ -0,0 +1,4 @@
+usr/lib/libtweakr-section.so*
+usr/lib/libtweakr-section.a
+usr/lib/pkgconfig/tweakr-section.pc
+usr/include/tweakr/*
diff --git a/debian/maemo-tweaks-modules.install b/debian/maemo-tweaks-modules.install
deleted file mode 100644 (file)
index 8cff40f..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-usr/lib/maemo-tweaks/modules/*.so*
-usr/bin/*
diff --git a/debian/maemo-tweaks.install b/debian/maemo-tweaks.install
deleted file mode 100644 (file)
index fb11dc0..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-usr/lib/hildon-control-panel/*so*
-usr/share/applications/hildon-control-panel/*.desktop
index aed6576..df05924 100755 (executable)
@@ -40,10 +40,10 @@ debian/stamp-autotools-files:
        autoreconf -v --install
        touch debian/stamp-autotools-files
 
-binary-predeb/maemo-tweaks::
+binary-predeb/tweakr::
        dh_maemolauncher
 
-binary-predeb/maemo-tweaks-modules::
+binary-predeb/tweakr-modules::
        # set the Setuid bit
-       chmod 4755 $(CURDIR)/debian/maemo-tweaks-modules/usr/bin/maemo-tweaks-desktop-save
-       chmod 4755 $(CURDIR)/debian/maemo-tweaks-modules/usr/bin/maemo-tweaks-mce-save
+       chmod 4755 $(CURDIR)/debian/tweakr-modules/usr/bin/tweakr-desktop-save
+       chmod 4755 $(CURDIR)/debian/tweakr-modules/usr/bin/tweakr-mce-save
diff --git a/debian/tweakr-modules.install b/debian/tweakr-modules.install
new file mode 100644 (file)
index 0000000..56bb54f
--- /dev/null
@@ -0,0 +1,2 @@
+usr/lib/tweakr/modules/*.so*
+usr/bin/*
diff --git a/debian/tweakr.install b/debian/tweakr.install
new file mode 100644 (file)
index 0000000..fb11dc0
--- /dev/null
@@ -0,0 +1,2 @@
+usr/lib/hildon-control-panel/*so*
+usr/share/applications/hildon-control-panel/*.desktop
diff --git a/libmaemo-tweaks-section/Makefile.am b/libmaemo-tweaks-section/Makefile.am
deleted file mode 100644 (file)
index 9fd3096..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-AM_CPPFLAGS = \
-       -I$(top_srcdir) \
-       $(GTK_CFLAGS)
-
-lib_LTLIBRARIES = libmaemo-tweaks-section.la
-
-libmaemo_tweaks_section_la_SOURCES = \
-       maemo-tweaks-section.c  \
-       maemo-tweaks-section.h  \
-       maemo-tweaks-module.c   \
-       maemo-tweaks-module.h
-
-libmaemo_tweaks_section_la_LIBADD = \
-       $(GTK_LIBS)
-
-libmaemo_tweaks_section_la_include_HEADERS = \
-       maemo-tweaks-section.h  \
-       maemo-tweaks-module.h
-
-libmaemo_tweaks_section_la_includedir = $(includedir)/maemo-tweaks
-
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = maemo-tweaks-section.pc
-
diff --git a/libmaemo-tweaks-section/maemo-tweaks-module.c b/libmaemo-tweaks-section/maemo-tweaks-module.c
deleted file mode 100644 (file)
index b934ba6..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * vim:ts=4:sw=4:et:cindent:cino=(0
- */ 
-
-#include <config.h>
-#include <gmodule.h>
-
-#include "maemo-tweaks-module.h"
-
-
-enum
-{
-    PROP_0,
-    PROP_FILENAME
-};
-
-
-static void      maemo_tweaks_module_finalize      (GObject      *object);
-static void      maemo_tweaks_module_get_property  (GObject      *object,
-                                                    guint         param_id,
-                                                    GValue       *value,
-                                                    GParamSpec   *pspec);
-static void      maemo_tweaks_module_set_property  (GObject      *object,
-                                                    guint         param_id,
-                                                    const GValue *value,
-                                                    GParamSpec   *pspec);
-static gboolean  maemo_tweaks_module_load_module   (GTypeModule  *gmodule);
-static void      maemo_tweaks_module_unload_module (GTypeModule  *gmodule);
-
-
-G_DEFINE_TYPE (MaemoTweaksModule, maemo_tweaks_module, G_TYPE_TYPE_MODULE);
-
-
-static void
-maemo_tweaks_module_class_init (MaemoTweaksModuleClass *class)
-{
-    GObjectClass     *object_class      = G_OBJECT_CLASS (class);
-    GTypeModuleClass *type_module_class = G_TYPE_MODULE_CLASS (class);
-
-    object_class->finalize     = maemo_tweaks_module_finalize;
-    object_class->get_property = maemo_tweaks_module_get_property;
-    object_class->set_property = maemo_tweaks_module_set_property;
-
-    type_module_class->load    = maemo_tweaks_module_load_module;
-    type_module_class->unload  = maemo_tweaks_module_unload_module;
-
-    g_object_class_install_property
-        (object_class, PROP_FILENAME,
-         g_param_spec_string ("filename",
-                              "Filename",
-                              "The filaname of the module",
-                              NULL,
-                              G_PARAM_READWRITE |
-                              G_PARAM_CONSTRUCT_ONLY));
-}
-
-static void
-maemo_tweaks_module_init (MaemoTweaksModule *module)
-{
-    module->filename = NULL;
-    module->library  = NULL;
-    module->load     = NULL;
-    module->unload   = NULL;
-}
-
-static void
-maemo_tweaks_module_finalize (GObject *object)
-{
-    MaemoTweaksModule *module = MAEMO_TWEAKS_MODULE (object);
-
-    g_free (module->filename);
-
-    G_OBJECT_CLASS (maemo_tweaks_module_parent_class)->finalize (object);
-}
-
-static void
-maemo_tweaks_module_get_property (GObject    *object,
-                                  guint       param_id,
-                                  GValue     *value,
-                                  GParamSpec *pspec)
-{
-    MaemoTweaksModule *module = MAEMO_TWEAKS_MODULE (object);
-
-    switch (param_id)
-    {
-        case PROP_FILENAME:
-            g_value_set_string (value, module->filename);
-            break;
-        default:
-            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
-            break;
-    }
-}
-
-static void
-maemo_tweaks_module_set_property (GObject      *object,
-                                  guint         param_id,
-                                  const GValue *value,
-                                  GParamSpec   *pspec)
-{
-    MaemoTweaksModule *module = MAEMO_TWEAKS_MODULE (object);
-
-    switch (param_id)
-    {
-        case PROP_FILENAME:
-            g_free (module->filename);
-            module->filename = g_value_dup_string (value);
-            break;
-        default:
-            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
-            break;
-    }
-}
-
-static gboolean
-maemo_tweaks_module_load_module (GTypeModule *gmodule)
-{
-    MaemoTweaksModule *module = MAEMO_TWEAKS_MODULE (gmodule);
-
-    if (!module->filename)
-    {
-        g_warning ("Module path not set");
-        return FALSE;
-    }
-
-    module->library = g_module_open (module->filename, 0);
-
-    if (!module->library)
-    {
-        g_printerr ("%s\n", g_module_error ());
-        return FALSE;
-    }
-
-    /* Make sure that the loaded library contains the required methods */
-    if (! g_module_symbol (module->library,
-                           "maemo_tweaks_module_load",
-                           (gpointer) &module->load) ||
-        ! g_module_symbol (module->library,
-                           "maemo_tweaks_module_unload",
-                           (gpointer) &module->unload))
-    {
-        g_printerr ("%s\n", g_module_error ());
-        g_module_close (module->library);
-
-        return FALSE;
-    }
-
-    /* Initialize the loaded module */
-    module->load (module);
-
-    return TRUE;
-}
-
-static void
-maemo_tweaks_module_unload_module (GTypeModule *gmodule)
-{
-    MaemoTweaksModule *module = MAEMO_TWEAKS_MODULE (gmodule);
-
-    module->unload (module);
-
-    g_module_close (module->library);
-    module->library = NULL;
-
-    module->load   = NULL;
-    module->unload = NULL;
-}
-
-MaemoTweaksModule *
-maemo_tweaks_module_new (const gchar *filename)
-{
-    MaemoTweaksModule *module;
-
-    g_return_val_if_fail (filename != NULL, NULL);
-
-    module = g_object_new (MAEMO_TWEAKS_TYPE_MODULE,
-                           "filename", filename,
-                           NULL);
-
-    return module;
-}
-
diff --git a/libmaemo-tweaks-section/maemo-tweaks-module.h b/libmaemo-tweaks-section/maemo-tweaks-module.h
deleted file mode 100644 (file)
index bd5e631..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * vim:ts=4:sw=4:et:cindent:cino=(0
- */ 
-
-#ifndef __MAEMO_TWEAKS_MODULE_H__
-#define __MAEMO_TWEAKS_MODULE_H__
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-
-#define MAEMO_TWEAKS_TYPE_MODULE \
-        (maemo_tweaks_module_get_type ())
-#define MAEMO_TWEAKS_MODULE(o) \
-        (G_TYPE_CHECK_INSTANCE_CAST ((o), MAEMO_TWEAKS_TYPE_MODULE, \
-        MaemoTweaksModule))
-#define MAEMO_TWEAKS_MODULE_CLASS(k) \
-        (G_TYPE_CHECK_CLASS_CAST((k), MAEMO_TWEAKS_TYPE_MODULE, \
-        MaemoTweaksModuleClass))
-#define MAEMO_TWEAKS_IS_MODULE(o) \
-        (G_TYPE_CHECK_INSTANCE_TYPE ((o), MAEMO_TWEAKS_TYPE_MODULE))
-#define MAEMO_TWEAKS_IS_MODULE_CLASS(k) \
-        (G_TYPE_CHECK_CLASS_TYPE ((k), MAEMO_TWEAKS_TYPE_MODULE))
-#define MAEMO_TWEAKS_MODULE_GET_CLASS(o) \
-        (G_TYPE_INSTANCE_GET_CLASS ((o), MAEMO_TWEAKS_TYPE_MODULE, \
-        MaemoTweaksModuleClass))
-
-typedef struct _MaemoTweaksModule      MaemoTweaksModule;
-typedef struct _MaemoTweaksModuleClass MaemoTweaksModuleClass;
-
-struct _MaemoTweaksModule
-{
-    GTypeModule  parent_instance;
-
-    gchar       *filename;
-    GModule     *library;
-
-    /*  module symbols  */
-    void (* load)   (MaemoTweaksModule *module);
-    void (* unload) (MaemoTweaksModule *module);
-};
-
-struct _MaemoTweaksModuleClass
-{
-    GTypeModuleClass  parent_class;
-};
-
-GType maemo_tweaks_module_get_type (void) G_GNUC_CONST;
-
-MaemoTweaksModule * maemo_tweaks_module_new      (const gchar *filename);
-
-
-/* API for the modules to implement */
-
-void        maemo_tweaks_module_load     (MaemoTweaksModule   *module);
-void        maemo_tweaks_module_unload   (MaemoTweaksModule   *module);
-
-
-G_END_DECLS
-
-#endif /* __MAEMO_TWEAKS_MODULE_H_ */
diff --git a/libmaemo-tweaks-section/maemo-tweaks-section.c b/libmaemo-tweaks-section/maemo-tweaks-section.c
deleted file mode 100644 (file)
index ef730b1..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * vim:ts=4:sw=4:et:cindent:cino=(0
- */ 
-
-#include <config.h>
-#include <gtk/gtk.h>
-
-#include "maemo-tweaks-section.h"
-
-
-G_DEFINE_TYPE (MaemoTweaksSection, maemo_tweaks_section, G_TYPE_OBJECT);
-
-
-static void
-maemo_tweaks_section_class_init (MaemoTweaksSectionClass *class)
-{
-}
-
-static void
-maemo_tweaks_section_init (MaemoTweaksSection *section)
-{
-}
-
-MaemoTweaksSection *
-maemo_tweaks_section_new (GType type)
-{
-    g_return_val_if_fail (g_type_is_a (type, MAEMO_TWEAKS_TYPE_SECTION),
-                          NULL);
-
-    return g_object_new (type, NULL);
-}
-
-GtkWidget *
-maemo_tweaks_section_get_widget (MaemoTweaksSection *section)
-{
-    g_return_val_if_fail (MAEMO_TWEAKS_IS_SECTION (section), NULL);
-
-    return section->widget;
-}
-
-gboolean
-maemo_tweaks_section_save (MaemoTweaksSection *section,
-                           gboolean *requires_restart)
-{
-    g_return_val_if_fail (MAEMO_TWEAKS_IS_SECTION (section), TRUE);
-
-    if (MAEMO_TWEAKS_SECTION_GET_CLASS (section)->save)
-        return MAEMO_TWEAKS_SECTION_GET_CLASS (section)->save
-            (section, requires_restart);
-    else
-        g_warning ("%s: section class %s doesn't implement "
-                   "MaemoTweaksSection::filter ()\n",
-                   G_STRFUNC, g_type_name (G_TYPE_FROM_INSTANCE (section)));
-
-    return TRUE;
-}
-
diff --git a/libmaemo-tweaks-section/maemo-tweaks-section.h b/libmaemo-tweaks-section/maemo-tweaks-section.h
deleted file mode 100644 (file)
index 1fe1509..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * vim:ts=4:sw=4:et:cindent:cino=(0
- */ 
-
-#ifndef __MAEMO_TWEAKS_SECTION_H__
-#define __MAEMO_TWEAKS_SECTION_H__
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-
-#define MAEMO_TWEAKS_TYPE_SECTION \
-        (maemo_tweaks_section_get_type ())
-#define MAEMO_TWEAKS_SECTION(o) \
-        (G_TYPE_CHECK_INSTANCE_CAST ((o), MAEMO_TWEAKS_TYPE_SECTION, \
-        MaemoTweaksSection))
-#define MAEMO_TWEAKS_SECTION_CLASS(k) \
-        (G_TYPE_CHECK_CLASS_CAST((k), MAEMO_TWEAKS_TYPE_SECTION, \
-        MaemoTweaksSectionClass))
-#define MAEMO_TWEAKS_IS_SECTION(o) \
-        (G_TYPE_CHECK_INSTANCE_TYPE ((o), MAEMO_TWEAKS_TYPE_SECTION))
-#define MAEMO_TWEAKS_IS_SECTION_CLASS(k) \
-        (G_TYPE_CHECK_CLASS_TYPE ((k), MAEMO_TWEAKS_TYPE_SECTION))
-#define MAEMO_TWEAKS_SECTION_GET_CLASS(o) \
-        (G_TYPE_INSTANCE_GET_CLASS ((o), MAEMO_TWEAKS_TYPE_SECTION, \
-        MaemoTweaksSectionClass))
-
-
-typedef struct _MaemoTweaksSection      MaemoTweaksSection;
-typedef struct _MaemoTweaksSectionClass MaemoTweaksSectionClass;
-
-struct _MaemoTweaksSection
-{
-    GObject  parent_instance;
-
-    /* The widget that the section populates (usually a vbox */
-    GtkWidget *widget;
-    const gchar *name;
-};
-
-struct _MaemoTweaksSectionClass
-{
-    GObjectClass  parent_class;
-
-    const gchar *name;
-
-    gboolean (*save) (MaemoTweaksSection *section,
-                      gboolean *requires_restart);
-};
-
-
-GType maemo_tweaks_section_get_type (void) G_GNUC_CONST;
-
-MaemoTweaksSection * maemo_tweaks_section_new (GType type);
-
-GtkWidget * maemo_tweaks_section_get_widget (MaemoTweaksSection *section);
-gboolean maemo_tweaks_section_save (MaemoTweaksSection *section,
-                                    gboolean *requires_restart);
-
-G_END_DECLS
-
-#endif /* __MAEMO_TWEAKS_SECTION_H_ */
-
diff --git a/libmaemo-tweaks-section/maemo-tweaks-section.pc.in b/libmaemo-tweaks-section/maemo-tweaks-section.pc.in
deleted file mode 100644 (file)
index ca57275..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: maemo-tweaks-section
-Description: A section in the maemo-tweaks applet.
-Requires: gtk+-2.0
-Version: @VERSION@
-Libs: -L${libdir} -lmaemo-tweaks-section
-Cflags: -I${includedir}
-
diff --git a/libtweakr-section/Makefile.am b/libtweakr-section/Makefile.am
new file mode 100644 (file)
index 0000000..18a1b92
--- /dev/null
@@ -0,0 +1,24 @@
+AM_CPPFLAGS = \
+       -I$(top_srcdir) \
+       $(GTK_CFLAGS)
+
+lib_LTLIBRARIES = libtweakr-section.la
+
+libtweakr_section_la_SOURCES = \
+       tweakr-section.c        \
+       tweakr-section.h        \
+       tweakr-module.c \
+       tweakr-module.h
+
+libtweakr_section_la_LIBADD = \
+       $(GTK_LIBS)
+
+libtweakr_section_la_include_HEADERS = \
+       tweakr-section.h        \
+       tweakr-module.h
+
+libtweakr_section_la_includedir = $(includedir)/tweakr
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = tweakr-section.pc
+
diff --git a/libtweakr-section/tweakr-module.c b/libtweakr-section/tweakr-module.c
new file mode 100644 (file)
index 0000000..dd19afe
--- /dev/null
@@ -0,0 +1,181 @@
+/*
+ * vim:ts=4:sw=4:et:cindent:cino=(0
+ */ 
+
+#include <config.h>
+#include <gmodule.h>
+
+#include "tweakr-module.h"
+
+
+enum
+{
+    PROP_0,
+    PROP_FILENAME
+};
+
+
+static void      tweakr_module_finalize      (GObject      *object);
+static void      tweakr_module_get_property  (GObject      *object,
+                                                    guint         param_id,
+                                                    GValue       *value,
+                                                    GParamSpec   *pspec);
+static void      tweakr_module_set_property  (GObject      *object,
+                                                    guint         param_id,
+                                                    const GValue *value,
+                                                    GParamSpec   *pspec);
+static gboolean  tweakr_module_load_module   (GTypeModule  *gmodule);
+static void      tweakr_module_unload_module (GTypeModule  *gmodule);
+
+
+G_DEFINE_TYPE (TweakrModule, tweakr_module, G_TYPE_TYPE_MODULE);
+
+
+static void
+tweakr_module_class_init (TweakrModuleClass *class)
+{
+    GObjectClass     *object_class      = G_OBJECT_CLASS (class);
+    GTypeModuleClass *type_module_class = G_TYPE_MODULE_CLASS (class);
+
+    object_class->finalize     = tweakr_module_finalize;
+    object_class->get_property = tweakr_module_get_property;
+    object_class->set_property = tweakr_module_set_property;
+
+    type_module_class->load    = tweakr_module_load_module;
+    type_module_class->unload  = tweakr_module_unload_module;
+
+    g_object_class_install_property
+        (object_class, PROP_FILENAME,
+         g_param_spec_string ("filename",
+                              "Filename",
+                              "The filaname of the module",
+                              NULL,
+                              G_PARAM_READWRITE |
+                              G_PARAM_CONSTRUCT_ONLY));
+}
+
+static void
+tweakr_module_init (TweakrModule *module)
+{
+    module->filename = NULL;
+    module->library  = NULL;
+    module->load     = NULL;
+    module->unload   = NULL;
+}
+
+static void
+tweakr_module_finalize (GObject *object)
+{
+    TweakrModule *module = TWEAKR_MODULE (object);
+
+    g_free (module->filename);
+
+    G_OBJECT_CLASS (tweakr_module_parent_class)->finalize (object);
+}
+
+static void
+tweakr_module_get_property (GObject    *object,
+                                  guint       param_id,
+                                  GValue     *value,
+                                  GParamSpec *pspec)
+{
+    TweakrModule *module = TWEAKR_MODULE (object);
+
+    switch (param_id)
+    {
+        case PROP_FILENAME:
+            g_value_set_string (value, module->filename);
+            break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+            break;
+    }
+}
+
+static void
+tweakr_module_set_property (GObject      *object,
+                                  guint         param_id,
+                                  const GValue *value,
+                                  GParamSpec   *pspec)
+{
+    TweakrModule *module = TWEAKR_MODULE (object);
+
+    switch (param_id)
+    {
+        case PROP_FILENAME:
+            g_free (module->filename);
+            module->filename = g_value_dup_string (value);
+            break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+            break;
+    }
+}
+
+static gboolean
+tweakr_module_load_module (GTypeModule *gmodule)
+{
+    TweakrModule *module = TWEAKR_MODULE (gmodule);
+
+    if (!module->filename)
+    {
+        g_warning ("Module path not set");
+        return FALSE;
+    }
+
+    module->library = g_module_open (module->filename, 0);
+
+    if (!module->library)
+    {
+        g_printerr ("%s\n", g_module_error ());
+        return FALSE;
+    }
+
+    /* Make sure that the loaded library contains the required methods */
+    if (! g_module_symbol (module->library,
+                           "tweakr_module_load",
+                           (gpointer) &module->load) ||
+        ! g_module_symbol (module->library,
+                           "tweakr_module_unload",
+                           (gpointer) &module->unload))
+    {
+        g_printerr ("%s\n", g_module_error ());
+        g_module_close (module->library);
+
+        return FALSE;
+    }
+
+    /* Initialize the loaded module */
+    module->load (module);
+
+    return TRUE;
+}
+
+static void
+tweakr_module_unload_module (GTypeModule *gmodule)
+{
+    TweakrModule *module = TWEAKR_MODULE (gmodule);
+
+    module->unload (module);
+
+    g_module_close (module->library);
+    module->library = NULL;
+
+    module->load   = NULL;
+    module->unload = NULL;
+}
+
+TweakrModule *
+tweakr_module_new (const gchar *filename)
+{
+    TweakrModule *module;
+
+    g_return_val_if_fail (filename != NULL, NULL);
+
+    module = g_object_new (TWEAKR_TYPE_MODULE,
+                           "filename", filename,
+                           NULL);
+
+    return module;
+}
+
diff --git a/libtweakr-section/tweakr-module.h b/libtweakr-section/tweakr-module.h
new file mode 100644 (file)
index 0000000..677452b
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * vim:ts=4:sw=4:et:cindent:cino=(0
+ */ 
+
+#ifndef __TWEAKR_MODULE_H__
+#define __TWEAKR_MODULE_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+
+#define TWEAKR_TYPE_MODULE \
+        (tweakr_module_get_type ())
+#define TWEAKR_MODULE(o) \
+        (G_TYPE_CHECK_INSTANCE_CAST ((o), TWEAKR_TYPE_MODULE, \
+        TweakrModule))
+#define TWEAKR_MODULE_CLASS(k) \
+        (G_TYPE_CHECK_CLASS_CAST((k), TWEAKR_TYPE_MODULE, \
+        TweakrModuleClass))
+#define TWEAKR_IS_MODULE(o) \
+        (G_TYPE_CHECK_INSTANCE_TYPE ((o), TWEAKR_TYPE_MODULE))
+#define TWEAKR_IS_MODULE_CLASS(k) \
+        (G_TYPE_CHECK_CLASS_TYPE ((k), TWEAKR_TYPE_MODULE))
+#define TWEAKR_MODULE_GET_CLASS(o) \
+        (G_TYPE_INSTANCE_GET_CLASS ((o), TWEAKR_TYPE_MODULE, \
+        TweakrModuleClass))
+
+typedef struct _TweakrModule      TweakrModule;
+typedef struct _TweakrModuleClass TweakrModuleClass;
+
+struct _TweakrModule
+{
+    GTypeModule  parent_instance;
+
+    gchar       *filename;
+    GModule     *library;
+
+    /*  module symbols  */
+    void (* load)   (TweakrModule *module);
+    void (* unload) (TweakrModule *module);
+};
+
+struct _TweakrModuleClass
+{
+    GTypeModuleClass  parent_class;
+};
+
+GType tweakr_module_get_type (void) G_GNUC_CONST;
+
+TweakrModule * tweakr_module_new      (const gchar *filename);
+
+
+/* API for the modules to implement */
+
+void        tweakr_module_load     (TweakrModule   *module);
+void        tweakr_module_unload   (TweakrModule   *module);
+
+
+G_END_DECLS
+
+#endif /* __TWEAKR_MODULE_H_ */
diff --git a/libtweakr-section/tweakr-section.c b/libtweakr-section/tweakr-section.c
new file mode 100644 (file)
index 0000000..744aae3
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * vim:ts=4:sw=4:et:cindent:cino=(0
+ */ 
+
+#include <config.h>
+#include <gtk/gtk.h>
+
+#include "tweakr-section.h"
+
+
+G_DEFINE_TYPE (TweakrSection, tweakr_section, G_TYPE_OBJECT);
+
+
+static void
+tweakr_section_class_init (TweakrSectionClass *class)
+{
+}
+
+static void
+tweakr_section_init (TweakrSection *section)
+{
+}
+
+TweakrSection *
+tweakr_section_new (GType type)
+{
+    g_return_val_if_fail (g_type_is_a (type, TWEAKR_TYPE_SECTION),
+                          NULL);
+
+    return g_object_new (type, NULL);
+}
+
+GtkWidget *
+tweakr_section_get_widget (TweakrSection *section)
+{
+    g_return_val_if_fail (TWEAKR_IS_SECTION (section), NULL);
+
+    return section->widget;
+}
+
+gboolean
+tweakr_section_save (TweakrSection *section,
+                           gboolean *requires_restart)
+{
+    g_return_val_if_fail (TWEAKR_IS_SECTION (section), TRUE);
+
+    if (TWEAKR_SECTION_GET_CLASS (section)->save)
+        return TWEAKR_SECTION_GET_CLASS (section)->save
+            (section, requires_restart);
+    else
+        g_warning ("%s: section class %s doesn't implement "
+                   "TweakrSection::filter ()\n",
+                   G_STRFUNC, g_type_name (G_TYPE_FROM_INSTANCE (section)));
+
+    return TRUE;
+}
+
diff --git a/libtweakr-section/tweakr-section.h b/libtweakr-section/tweakr-section.h
new file mode 100644 (file)
index 0000000..9715a0a
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * vim:ts=4:sw=4:et:cindent:cino=(0
+ */ 
+
+#ifndef __TWEAKR_SECTION_H__
+#define __TWEAKR_SECTION_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+
+#define TWEAKR_TYPE_SECTION \
+        (tweakr_section_get_type ())
+#define TWEAKR_SECTION(o) \
+        (G_TYPE_CHECK_INSTANCE_CAST ((o), TWEAKR_TYPE_SECTION, \
+        TweakrSection))
+#define TWEAKR_SECTION_CLASS(k) \
+        (G_TYPE_CHECK_CLASS_CAST((k), TWEAKR_TYPE_SECTION, \
+        TweakrSectionClass))
+#define TWEAKR_IS_SECTION(o) \
+        (G_TYPE_CHECK_INSTANCE_TYPE ((o), TWEAKR_TYPE_SECTION))
+#define TWEAKR_IS_SECTION_CLASS(k) \
+        (G_TYPE_CHECK_CLASS_TYPE ((k), TWEAKR_TYPE_SECTION))
+#define TWEAKR_SECTION_GET_CLASS(o) \
+        (G_TYPE_INSTANCE_GET_CLASS ((o), TWEAKR_TYPE_SECTION, \
+        TweakrSectionClass))
+
+
+typedef struct _TweakrSection      TweakrSection;
+typedef struct _TweakrSectionClass TweakrSectionClass;
+
+struct _TweakrSection
+{
+    GObject  parent_instance;
+
+    /* The widget that the section populates (usually a vbox */
+    GtkWidget *widget;
+    const gchar *name;
+};
+
+struct _TweakrSectionClass
+{
+    GObjectClass  parent_class;
+
+    const gchar *name;
+
+    gboolean (*save) (TweakrSection *section,
+                      gboolean *requires_restart);
+};
+
+
+GType tweakr_section_get_type (void) G_GNUC_CONST;
+
+TweakrSection * tweakr_section_new (GType type);
+
+GtkWidget * tweakr_section_get_widget (TweakrSection *section);
+gboolean tweakr_section_save (TweakrSection *section,
+                                    gboolean *requires_restart);
+
+G_END_DECLS
+
+#endif /* __TWEAKR_SECTION_H_ */
+
diff --git a/libtweakr-section/tweakr-section.pc.in b/libtweakr-section/tweakr-section.pc.in
new file mode 100644 (file)
index 0000000..f1edf73
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: tweakr-section
+Description: A section in the tweakr applet.
+Requires: gtk+-2.0
+Version: @VERSION@
+Libs: -L${libdir} -ltweakr-section
+Cflags: -I${includedir}
+
diff --git a/maemo-tweaks-module-manager.c b/maemo-tweaks-module-manager.c
deleted file mode 100644 (file)
index 90a7f50..0000000
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * vim:ts=4:sw=4:et:cindent:cino=(0
- */ 
-
-#include <config.h>
-
-#include <string.h>
-#include <unistd.h>
-
-#include <gmodule.h>
-
-#include "maemo-tweaks-types.h"
-#include "libmaemo-tweaks-section/maemo-tweaks-module.h"
-#include "maemo-tweaks-module-manager.h"
-
-
-enum
-{
-    PROP_0,
-    PROP_MODULE_PATH
-};
-
-
-static GObject *
-maemo_tweaks_module_manager_constructor (GType type,
-                                         guint n_params,
-                                         GObjectConstructParam *params);
-static void
-maemo_tweaks_module_manager_finalize (GObject *object);
-
-static void
-maemo_tweaks_module_manager_get_property (GObject *object,
-                                          guint param_id,
-                                          GValue *value,
-                                          GParamSpec *pspec);
-
-static void
-maemo_tweaks_module_manager_set_property (GObject *object,
-                                          guint param_id,
-                                          const GValue *value,
-                                          GParamSpec *pspec);
-
-static gboolean
-maemo_tweaks_module_manager_query_modules
-    (MaemoTweaksModuleManager *manager);
-
-
-G_DEFINE_TYPE (MaemoTweaksModuleManager, maemo_tweaks_module_manager,
-               G_TYPE_OBJECT);
-
-
-static void
-maemo_tweaks_module_manager_class_init (MaemoTweaksModuleManagerClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-    object_class->constructor  = maemo_tweaks_module_manager_constructor;
-    object_class->finalize     = maemo_tweaks_module_manager_finalize;
-    object_class->get_property = maemo_tweaks_module_manager_get_property;
-    object_class->set_property = maemo_tweaks_module_manager_set_property;
-
-    g_object_class_install_property
-        (object_class, PROP_MODULE_PATH,
-         g_param_spec_string ("module-path",
-                              "Module Path",
-                              "The path where to look for modules",
-                              NULL,
-                              G_PARAM_READWRITE |
-                              G_PARAM_CONSTRUCT_ONLY));
-}
-
-static void
-maemo_tweaks_module_manager_init (MaemoTweaksModuleManager *manager)
-{
-    manager->module_path = NULL;
-    manager->modules     = NULL;
-}
-
-static GObject *
-maemo_tweaks_module_manager_constructor (GType type,
-                                         guint n_params,
-                                         GObjectConstructParam *params)
-{
-    GObject *object;
-    MaemoTweaksModuleManager *manager;
-
-    object = G_OBJECT_CLASS
-        (maemo_tweaks_module_manager_parent_class)->constructor (type,
-                                                                 n_params,
-                                                                 params);
-
-    manager = MAEMO_TWEAKS_MODULE_MANAGER (object);
-
-    if (manager->module_path)
-        maemo_tweaks_module_manager_query_modules (manager);
-
-    return object;
-}
-
-static void
-maemo_tweaks_module_manager_finalize (GObject *object)
-{
-    MaemoTweaksModuleManager *manager = MAEMO_TWEAKS_MODULE_MANAGER (object);
-
-    g_free (manager->module_path);
-
-    /* GTypeModules most not be finalized, don't unref them */
-    g_list_free (manager->modules);
-
-    G_OBJECT_CLASS (maemo_tweaks_module_manager_parent_class)->
-        finalize (object);
-}
-
-static void
-maemo_tweaks_module_manager_get_property (GObject *object,
-                                          guint param_id,
-                                          GValue *value,
-                                          GParamSpec *pspec)
-{
-    MaemoTweaksModuleManager *manager = MAEMO_TWEAKS_MODULE_MANAGER (object);
-
-    switch (param_id)
-    {
-        case PROP_MODULE_PATH:
-            g_value_set_string (value, manager->module_path);
-            break;
-        default:
-            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
-            break;
-    }
-}
-
-static void
-maemo_tweaks_module_manager_set_property (GObject *object,
-                                          guint param_id,
-                                          const GValue *value,
-                                          GParamSpec *pspec)
-{
-    MaemoTweaksModuleManager *manager = MAEMO_TWEAKS_MODULE_MANAGER (object);
-
-    switch (param_id)
-    {
-        case PROP_MODULE_PATH:
-            manager->module_path = g_value_dup_string (value);
-            break;
-        default:
-            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
-            break;
-    }
-}
-
-static gboolean
-maemo_tweaks_module_manager_is_valid_module_name (const gchar *name)
-{
-    return g_str_has_suffix (name, ".so");
-}
-
-static gboolean
-maemo_tweaks_module_manager_query_modules (MaemoTweaksModuleManager *manager)
-{
-    const gchar *name;
-    GDir        *dir;
-    GError      *error = NULL;
-
-    dir = g_dir_open (manager->module_path, 0, &error);
-
-    if (!dir)
-    {
-        g_printerr ("Error while opening module dir: %s\n", error->message);
-        g_clear_error (&error);
-        return FALSE;
-    }
-
-    while ((name = g_dir_read_name (dir)))
-    {
-        if (maemo_tweaks_module_manager_is_valid_module_name (name))
-        {
-            MaemoTweaksModule *module;
-            gchar     *path;
-
-            path = g_build_filename (manager->module_path, name, NULL);
-            module = maemo_tweaks_module_new (path);
-
-            if (! g_type_module_use (G_TYPE_MODULE (module)))
-            {
-                g_printerr ("Failed to load module: %s\n", path);
-                g_object_unref (module);
-                g_free (path);
-                continue;
-            }
-
-            g_free (path);
-
-            g_type_module_unuse (G_TYPE_MODULE (module));
-
-            manager->modules = g_list_prepend (manager->modules, module);
-        }
-    }
-
-    g_dir_close (dir);
-
-    return TRUE;
-}
-
diff --git a/maemo-tweaks-module-manager.h b/maemo-tweaks-module-manager.h
deleted file mode 100644 (file)
index 3dbafef..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * vim:ts=4:sw=4:et:cindent:cino=(0
- */ 
-
-#ifndef __MAEMO_TWEAKS_MODULE_MANAGER_H__
-#define __MAEMO_TWEAKS_MODULE_MANAGER_H__
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define MAEMO_TWEAKS_TYPE_MODULE_MANAGER \
-        (maemo_tweaks_module_manager_get_type ())
-#define MAEMO_TWEAKS_MODULE_MANAGER(obj) \
-        (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
-        MAEMO_TWEAKS_TYPE_MODULE_MANAGER, \
-        MaemoTweaksModuleManager))
-#define MAEMO_TWEAKS_MODULE_MANAGER_CLASS(k) \
-        (G_TYPE_CHECK_CLASS_CAST((k), \
-        MAEMO_TWEAKS_TYPE_MODULE_MANAGER, \
-        MaemoTweaksModuleManagerClass))
-#define MAEMO_TWEAKS_IS_MODULE_MANAGER(obj) \
-        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
-        MAEMO_TWEAKS_TYPE_MODULE_MANAGER))
-#define MAEMO_TWEAKS_IS_MODULE_MANAGER_CLASS(k) \
-        (G_TYPE_CHECK_CLASS_TYPE((k), \
-        MAEMO_TWEAKS_TYPE_MODULE_MANAGER))
-#define MAEMO_TWEAKS_MODULE_MANAGER_GET_CLASS(o) \
-        (G_TYPE_INSTANCE_GET_CLASS ((o), \
-        MAEMO_TWEAKS_TYPE_MODULE_MANAGER, \
-        MaemoTweaksModuleManagerClass))
-
-
-typedef struct _MaemoTweaksModuleManagerClass MaemoTweaksModuleManagerClass;
-
-struct _MaemoTweaksModuleManager
-{
-    GObject  parent_instance;
-
-    gchar   *module_path;
-    GList   *modules;
-};
-
-struct _MaemoTweaksModuleManagerClass
-{
-    GObjectClass  parent_class;
-};
-
-
-GType maemo_tweaks_module_manager_get_type (void) G_GNUC_CONST;
-
-
-G_END_DECLS
-
-#endif /* __MAEMO_TWEAKS_MODULE_MANAGER_H__ */
-
diff --git a/maemo-tweaks-types.h b/maemo-tweaks-types.h
deleted file mode 100644 (file)
index 7548de1..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * vim:ts=4:sw=4:et:cindent:cino=(0
- */ 
-
-#ifndef __MAEMO_TWEAKS_TYPES_H__
-#define __MAEMO_TWEAKS_TYPES_H__
-
-typedef struct _MaemoTweaksModuleManager MaemoTweaksModuleManager;
-
-#endif /* __MAEMO_TWEAKS_TYPES_H__ */
-
diff --git a/maemo-tweaks.c b/maemo-tweaks.c
deleted file mode 100644 (file)
index 4253087..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * vim:ts=4:sw=4:et:cindent:cino=(0
- */ 
-
-#include <hildon-cp-plugin/hildon-cp-plugin-interface.h>
-#include <gtk/gtk.h>
-#include <hildon/hildon-note.h>
-#include <hildon/hildon-pannable-area.h>
-#include <hildon/hildon-defines.h>
-
-#include "maemo-tweaks-types.h"
-#include "libmaemo-tweaks-section/maemo-tweaks-section.h"
-#include "maemo-tweaks-module-manager.h"
-
-static gboolean save_ret;
-
-GtkWidget *create_dialog (GtkWindow *parent)
-{
-    GtkWidget *dialog;
-
-    dialog = gtk_dialog_new_with_buttons
-        ("Maemo Tweaks",
-         parent,
-         GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR,
-         GTK_STOCK_SAVE,
-         GTK_RESPONSE_OK,
-         GTK_STOCK_CANCEL,
-         GTK_RESPONSE_CANCEL,
-         NULL);
-
-    return dialog;
-}
-
-void _save (MaemoTweaksSection *section, gboolean *requires_restart)
-{
-    save_ret &= maemo_tweaks_section_save (section, requires_restart);
-}
-
-osso_return_t execute (osso_context_t *osso, gpointer data,
-                       gboolean user_activated)
-{
-    GtkWidget *dialog;
-    GtkWidget *panarea;
-    GtkWidget *box;
-    gint response;
-
-    MaemoTweaksModuleManager *manager;
-    GType *section_types;
-    guint n_sections;
-    GList *sections = NULL;
-    gint i;
-    gboolean requires_restart = FALSE;
-
-    manager = g_object_new (MAEMO_TWEAKS_TYPE_MODULE_MANAGER,
-                            "module-path", MODULES_DIR,
-                            NULL);
-
-    section_types = g_type_children (MAEMO_TWEAKS_TYPE_SECTION, &n_sections);
-
-    dialog = create_dialog (GTK_WINDOW (data));
-    panarea = hildon_pannable_area_new ();
-    box = gtk_vbox_new (FALSE, HILDON_MARGIN_DOUBLE);
-
-    hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA (panarea),
-                                            box);
-    g_object_set (G_OBJECT (panarea), "height-request", 350, NULL);
-
-    for (i = 0; i < n_sections; i++)
-    {
-        MaemoTweaksSection *section;
-        MaemoTweaksSectionClass *klass;
-        GtkWidget *frame;
-
-        klass = g_type_class_ref (section_types[i]);
-        section = maemo_tweaks_section_new (section_types[i]);
-
-        sections = g_list_prepend (sections, section);
-        frame = gtk_frame_new (section->name);
-
-        gtk_box_pack_start (GTK_BOX (box),
-                            frame,
-                            FALSE, FALSE, 0);
-        gtk_container_add (GTK_CONTAINER (frame),
-                           maemo_tweaks_section_get_widget (section));
-
-        g_type_class_unref (klass);
-    }
-
-    gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), panarea,
-                        FALSE, FALSE, 0);
-    gtk_widget_show_all (GTK_DIALOG (dialog)->vbox);
-
-    for (;;)
-    {
-        save_ret = TRUE;
-        response = gtk_dialog_run (GTK_DIALOG (dialog));
-        if (response == GTK_RESPONSE_OK)
-        {
-            /* Save all settings */
-            g_list_foreach (sections, (GFunc) _save, &requires_restart);
-        }
-        if (save_ret)
-            break;
-    }
-
-    gtk_widget_destroy (GTK_WIDGET (dialog));
-    g_object_unref (manager);
-    if (sections)
-    {
-        g_list_foreach (sections, (GFunc) g_object_unref, NULL);
-        g_list_free (sections);
-    }
-
-    if (requires_restart)
-    {
-        GtkWidget *note;
-
-        note = hildon_note_new_information
-            (GTK_WINDOW (data), "Some of the settings you have changed"
-             " will take effect only after you restart your device.");
-        gtk_dialog_run (GTK_DIALOG (note));
-        gtk_widget_destroy (note);
-    }
-
-    return OSSO_OK;
-}
-
diff --git a/maemo-tweaks.desktop b/maemo-tweaks.desktop
deleted file mode 100644 (file)
index 2eac2ba..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-[Desktop Entry] 
-Encoding=UTF-8
-Version=0.1
-Name=Maemo Tweaks
-Comment=Tweaks for Maemo 5
-Type=HildonControlPanelPlugin
-Icon=qgn_list_cp_isetup
-X-control-panel-plugin=libmaemo-tweaks.so
-Categories=personalization
index 216dc90..ecdb0af 100644 (file)
@@ -1,5 +1,5 @@
-libmaemo_tweaks_section = \
-       $(top_builddir)/libmaemo-tweaks-section/libmaemo-tweaks-section.la
+libtweakr_section = \
+       $(top_builddir)/libtweakr-section/libtweakr-section.la
 
 AM_CPPFLAGS = \
        -I$(top_srcdir) \
@@ -8,35 +8,35 @@ AM_CPPFLAGS = \
        -DTRANSITIONS=\"/usr/share/hildon-desktop/transitions.ini\"     \
        -DMCE=\"/etc/mce/mce.ini\"
 
-modulesdir = $(libdir)/maemo-tweaks/modules
+modulesdir = $(libdir)/tweakr/modules
 
 modules_LTLIBRARIES = \
-       libmaemo-tweaks-desktop.la \
-       libmaemo-tweaks-mce.la
+       libtweakr-desktop.la \
+       libtweakr-mce.la
 
-libmaemo_tweaks_desktop_la_SOURCES = maemo-tweaks-desktop.c
-libmaemo_tweaks_desktop_la_LDFLAGS = -avoid-version -module
-libmaemo_tweaks_desktop_la_LIBADD = \
-       $(libmaemo_tweaks_section)      \
+libtweakr_desktop_la_SOURCES = tweakr-desktop.c
+libtweakr_desktop_la_LDFLAGS = -avoid-version -module
+libtweakr_desktop_la_LIBADD = \
+       $(libtweakr_section)    \
        $(GTK_LIBS)     \
        $(HILDON_LIBS)
 
-libmaemo_tweaks_mce_la_SOURCES = maemo-tweaks-mce.c
-libmaemo_tweaks_mce_la_LDFLAGS = -avoid-version -module
-libmaemo_tweaks_mce_la_LIBADD = \
-       $(libmaemo_tweaks_section)      \
+libtweakr_mce_la_SOURCES = tweakr-mce.c
+libtweakr_mce_la_LDFLAGS = -avoid-version -module
+libtweakr_mce_la_LIBADD = \
+       $(libtweakr_section)    \
        $(GTK_LIBS)     \
        $(HILDON_LIBS)
 
 bin_PROGRAMS = \
-       maemo-tweaks-desktop-save       \
-       maemo-tweaks-mce-save
+       tweakr-desktop-save     \
+       tweakr-mce-save
 
-maemo_tweaks_desktop_save_SOURCES = maemo-tweaks-desktop-save.c
-maemo_tweaks_desktop_save_LDADD = \
+tweakr_desktop_save_SOURCES = tweakr-desktop-save.c
+tweakr_desktop_save_LDADD = \
        $(GLIB_LIBS)
 
-maemo_tweaks_mce_save_SOURCES = maemo-tweaks-mce-save.c
-maemo_tweaks_mce_save_LDADD = \
+tweakr_mce_save_SOURCES = tweakr-mce-save.c
+tweakr_mce_save_LDADD = \
        $(GLIB_LIBS)
 
diff --git a/modules/maemo-tweaks-desktop-save.c b/modules/maemo-tweaks-desktop-save.c
deleted file mode 100644 (file)
index 3b56065..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * vim:ts=4:sw=4:et:cindent:cino=(0
- */ 
-
-#include <stdlib.h>
-#include <glib.h>
-
-static gchar *groups[] =
-{
-    "edit_mode",
-    NULL
-};
-static gchar *keys[] =
-{
-    "snap_grid_size",
-    NULL
-};
-
-int main (int argc, char *argv[])
-{
-    GKeyFile *kf;
-    gint i;
-    GError *error = NULL;
-    gchar *data;
-    gsize size;
-
-    if (argc < 2)
-    {
-        exit (EXIT_FAILURE);;
-    }
-
-    kf = g_key_file_new ();
-    if (!g_key_file_load_from_file (kf, TRANSITIONS,
-                                    G_KEY_FILE_KEEP_COMMENTS |
-                                    G_KEY_FILE_KEEP_TRANSLATIONS,
-                                    &error))
-    {
-        g_warning ("Error while reading %s: %s", TRANSITIONS, error->message);
-        g_error_free (error);
-        exit (EXIT_FAILURE);
-    }
-
-    for (i = 0; i < argc - 1; i++)
-    {
-        g_key_file_set_string (kf, groups[i], keys[i], argv[i+1]);
-    }
-
-    data = g_key_file_to_data (kf, &size, &error);
-    if (data == NULL)
-    {
-        g_warning ("Error while writing keyfile data.");
-        g_error_free (error);
-        exit (EXIT_FAILURE);
-    }
-    
-    if (!g_file_set_contents (TRANSITIONS, data, size, &error))
-    {
-        g_warning ("Error writing %s", TRANSITIONS);
-        g_free (data);
-        g_error_free (error);
-        exit (EXIT_FAILURE);
-    }
-
-    g_free (data);
-    g_key_file_free (kf);
-
-    return 0;
-}
-
diff --git a/modules/maemo-tweaks-desktop.c b/modules/maemo-tweaks-desktop.c
deleted file mode 100644 (file)
index 7a39a01..0000000
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * vim:ts=4:sw=4:et:cindent:cino=(0
- */ 
-
-#include <config.h>
-
-#include <gtk/gtk.h>
-#include <hildon/hildon-picker-button.h>
-#include <hildon/hildon-touch-selector.h>
-
-#include "libmaemo-tweaks-section/maemo-tweaks-section.h"
-#include "libmaemo-tweaks-section/maemo-tweaks-module.h"
-
-
-#define MAEMO_TWEAKS_TYPE_DESKTOP_SECTION \
-        (maemo_tweaks_desktop_section_type)
-#define MAEMO_TWEAKS_DESKTOP_SECTION(obj) \
-        (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
-        MAEMO_TWEAKS_TYPE_DESKTOP_SECTION, \
-        MaemoTweaksDesktopSection))
-#define MAEMO_TWEAKS_DESKTOP_SECTION_CLASS(k) \
-        (G_TYPE_CHECK_CLASS_CAST((k), \
-        MAEMO_TWEAKS_TYPE_DESKTOP_SECTION, \
-        MaemoTweaksDesktopSectionClass))
-#define MAEMO_TWEAKS_IS_DESKTOP_SECTION(obj) \
-        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
-        MAEMO_TWEAKS_TYPE_DESKTOP_SECTION))
-
-
-enum
-{
-    SNAP_NONE,
-    SNAP_SMALL,
-    SNAP_LARGE,
-    SNAP_HUGE
-};
-
-enum
-{
-    SNAP_NONE_VALUE,
-    SNAP_SMALL_VALUE = 8,
-    SNAP_LARGE_VALUE = 16,
-    SNAP_HUGE_VALUE = 32
-};
-
-static gint snap_values [] = {
-    SNAP_NONE_VALUE,
-    SNAP_SMALL_VALUE,
-    SNAP_LARGE_VALUE,
-    SNAP_HUGE_VALUE
-};
-
-typedef struct _MaemoTweaksDesktopSection MaemoTweaksDesktopSection;
-typedef struct _MaemoTweaksDesktopSectionClass
-               MaemoTweaksDesktopSectionClass;
-
-struct _MaemoTweaksDesktopSection
-{
-    MaemoTweaksSection parent_instance;
-
-    GKeyFile *ini;
-    GtkWidget *snap_button;
-};
-
-struct _MaemoTweaksDesktopSectionClass
-{
-    MaemoTweaksSectionClass parent_class;
-};
-
-
-static GType maemo_tweaks_desktop_section_get_type (GTypeModule *module);
-static void maemo_tweaks_desktop_section_class_init
-    (MaemoTweaksDesktopSectionClass *class);
-static void maemo_tweaks_desktop_section_init
-    (MaemoTweaksDesktopSection *section);
-static void maemo_tweaks_desktop_section_dispose (GObject *obj);
-
-static gboolean _save (MaemoTweaksSection *section,
-                       gboolean *requires_restart);
-
-static GType maemo_tweaks_desktop_section_type = 0;
-static MaemoTweaksSectionClass *
-    maemo_tweaks_desktop_section_parent_class = NULL;
-
-
-G_MODULE_EXPORT void
-maemo_tweaks_module_load (MaemoTweaksModule *module)
-{
-    maemo_tweaks_desktop_section_get_type (G_TYPE_MODULE (module));
-}
-
-G_MODULE_EXPORT void
-maemo_tweaks_module_unload (MaemoTweaksModule *module)
-{
-}
-
-static GType
-maemo_tweaks_desktop_section_get_type (GTypeModule *module)
-{
-    if (!maemo_tweaks_desktop_section_type)
-    {
-        static const GTypeInfo section_info =
-        {
-            sizeof (MaemoTweaksDesktopSectionClass),
-            (GBaseInitFunc) NULL,
-            (GBaseFinalizeFunc) NULL,
-            (GClassInitFunc) maemo_tweaks_desktop_section_class_init,
-            NULL,           /* class_finalize */
-            NULL,           /* class_data     */
-            sizeof (MaemoTweaksDesktopSection),
-            0,              /* n_preallocs    */
-            (GInstanceInitFunc) maemo_tweaks_desktop_section_init
-        };
-
-        maemo_tweaks_desktop_section_type =
-            g_type_module_register_type (module, MAEMO_TWEAKS_TYPE_SECTION,
-                                         "MaemoTweaksDesktopSection",
-                                         &section_info, 0);
-    }
-
-    return maemo_tweaks_desktop_section_type;
-}
-
-static void
-maemo_tweaks_desktop_section_class_init
-    (MaemoTweaksDesktopSectionClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS (klass);
-    MaemoTweaksSectionClass *section_class =
-        MAEMO_TWEAKS_SECTION_CLASS (klass);
-
-    maemo_tweaks_desktop_section_parent_class =
-        g_type_class_peek_parent (klass);
-
-    section_class->name   = "_Desktop";
-    section_class->save = _save;
-
-    object_class->dispose = maemo_tweaks_desktop_section_dispose;
-}
-
-GtkWidget * _build_snap_to_grid (void)
-{
-    const gchar *options[] = {"No", "Small", "Large", "Huge", NULL};
-    gint i = 0;
-    GtkWidget *button, *selector;
-
-    selector = hildon_touch_selector_new_text ();
-    while (options[i] && options[i] != '\0')
-    {
-        hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector),
-                                           options [i++]);
-    }
-
-    button = hildon_picker_button_new (HILDON_SIZE_AUTO,
-                                       HILDON_BUTTON_ARRANGEMENT_VERTICAL);
-    hildon_gtk_widget_set_theme_size (button, HILDON_SIZE_FINGER_HEIGHT);
-
-    hildon_button_set_title (HILDON_BUTTON (button),
-                             "Snap icons to grid");
-    gtk_button_set_alignment (GTK_BUTTON (button), 0.0f, 0.5f);
-    hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
-                                       HILDON_TOUCH_SELECTOR (selector));
-
-    gtk_widget_show (button);
-    return button;
-}
-
-static void
-maemo_tweaks_desktop_section_init (MaemoTweaksDesktopSection *section)
-{
-    MaemoTweaksSection *iface;
-
-    gint snap_value = SNAP_NONE_VALUE;
-
-    section->snap_button = _build_snap_to_grid ();
-
-    section->ini = g_key_file_new ();
-
-    if (!g_key_file_load_from_file (section->ini, TRANSITIONS,
-                                    G_KEY_FILE_NONE, NULL))
-    {
-        g_warning ("%s: failed to load %s", G_STRFUNC, TRANSITIONS);
-        return;
-    }
-
-    snap_value = g_key_file_get_integer (section->ini, "edit_mode",
-                                         "snap_grid_size", NULL);
-
-    if (snap_value < SNAP_SMALL_VALUE)
-    {
-        hildon_picker_button_set_active
-            (HILDON_PICKER_BUTTON (section->snap_button), SNAP_NONE);
-    }
-    else if (snap_value < SNAP_LARGE_VALUE)
-    {
-        hildon_picker_button_set_active
-            (HILDON_PICKER_BUTTON (section->snap_button), SNAP_SMALL);
-    }
-    else if (snap_value < SNAP_HUGE_VALUE)
-    {
-        hildon_picker_button_set_active
-            (HILDON_PICKER_BUTTON (section->snap_button), SNAP_LARGE);
-    }
-    else
-    {
-        hildon_picker_button_set_active
-            (HILDON_PICKER_BUTTON (section->snap_button), SNAP_HUGE);
-    }
-
-
-
-    iface = MAEMO_TWEAKS_SECTION (section);
-    iface->name = "Desktop";
-    iface->widget = gtk_vbox_new (FALSE, 0);
-    gtk_box_pack_start (GTK_BOX (iface->widget), section->snap_button,
-                        FALSE, FALSE, 0);
-}
-
-static void
-maemo_tweaks_desktop_section_dispose (GObject *obj)
-{
-    MaemoTweaksDesktopSection *section = MAEMO_TWEAKS_DESKTOP_SECTION (obj);
-    if (section->ini)
-    {
-        g_key_file_free (section->ini);
-        section->ini = NULL;
-    }
-
-    G_OBJECT_CLASS (maemo_tweaks_desktop_section_parent_class)->dispose
-        (obj);
-}
-
-
-static gboolean  _save (MaemoTweaksSection *section,
-                        gboolean *requires_restart)
-{
-    gchar *argv[3];
-    gint active;
-
-    active = hildon_picker_button_get_active
-        (HILDON_PICKER_BUTTON (MAEMO_TWEAKS_DESKTOP_SECTION
-                               (section)->snap_button));
-
-    argv[0] = g_strdup ("/usr/bin/maemo-tweaks-desktop-save");
-    argv[1] = g_strdup_printf ("%d", snap_values[active]);
-    argv[2] = NULL;
-
-    g_spawn_sync ("/home/user", argv, NULL,
-                  G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
-                  NULL, NULL, NULL, NULL, NULL, NULL);
-
-    g_free (argv[0]);
-    g_free (argv[1]);
-
-    return TRUE;
-}
-
diff --git a/modules/maemo-tweaks-mce-save.c b/modules/maemo-tweaks-mce-save.c
deleted file mode 100644 (file)
index 608c2d8..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * vim:ts=4:sw=4:et:cindent:cino=(0
- */ 
-
-#include <stdlib.h>
-#include <glib.h>
-
-#define FILENAME MCE
-
-typedef struct _value_t
-{
-    const gchar *group;
-    const gchar *name;
-    const gchar *value;
-} value_t;
-
-int main (int argc, char *argv[])
-{
-    GKeyFile *kf;
-    value_t v[3];
-    gint i;
-    GError *error = NULL;
-    gchar *data;
-    gsize size;
-
-    if (argc < (sizeof (v) / sizeof (value_t)) + 1)
-    {
-        exit (EXIT_FAILURE);
-    }
-
-    v[0].group = "PowerKey";
-    v[0].name = "PowerKeyShortAction";
-    v[0].value = argv[1];
-
-    v[1].group = "PowerKey";
-    v[1].name = "PowerKeyLongAction";
-    v[1].value = argv[2];
-
-    v[2].group = "PowerKey";
-    v[2].name = "PowerKeyDoubleAction";
-    v[2].value = argv[3];
-
-    kf = g_key_file_new ();
-    if (!g_key_file_load_from_file (kf, FILENAME,
-                                    G_KEY_FILE_KEEP_COMMENTS |
-                                    G_KEY_FILE_KEEP_TRANSLATIONS,
-                                    &error))
-    {
-        g_warning ("Error while reading %s: %s", FILENAME, error->message);
-        g_error_free (error);
-        exit (EXIT_FAILURE);
-    }
-
-    for (i = 0; i < argc - 1; i++)
-    {
-        g_key_file_set_string (kf, v[i].group, v[i].name, v[i].value);
-    }
-
-    data = g_key_file_to_data (kf, &size, &error);
-    if (data == NULL)
-    {
-        g_warning ("Error while writing keyfile data.");
-        g_error_free (error);
-        exit (EXIT_FAILURE);
-    }
-    
-    if (!g_file_set_contents (FILENAME, data, size, &error))
-    {
-        g_warning ("Error writing %s", FILENAME);
-        g_free (data);
-        g_error_free (error);
-        exit (EXIT_FAILURE);
-    }
-
-    g_free (data);
-    g_key_file_free (kf);
-
-    exit (EXIT_SUCCESS);
-}
-
diff --git a/modules/maemo-tweaks-mce.c b/modules/maemo-tweaks-mce.c
deleted file mode 100644 (file)
index 4a83f86..0000000
+++ /dev/null
@@ -1,415 +0,0 @@
-/*
- * vim:ts=4:sw=4:et:cindent:cino=(0
- */ 
-
-#include <config.h>
-
-#include <gtk/gtk.h>
-#include <hildon/hildon-picker-button.h>
-#include <hildon/hildon-touch-selector.h>
-#include <hildon/hildon-note.h>
-
-#include "libmaemo-tweaks-section/maemo-tweaks-section.h"
-#include "libmaemo-tweaks-section/maemo-tweaks-module.h"
-
-
-#define MAEMO_TWEAKS_TYPE_MCE_SECTION \
-        (maemo_tweaks_mce_section_type)
-#define MAEMO_TWEAKS_MCE_SECTION(obj) \
-        (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
-        MAEMO_TWEAKS_TYPE_MCE_SECTION, \
-        MaemoTweaksMceSection))
-#define MAEMO_TWEAKS_MCE_SECTION_CLASS(k) \
-        (G_TYPE_CHECK_CLASS_CAST((k), \
-        MAEMO_TWEAKS_TYPE_MCE_SECTION, \
-        MaemoTweaksMceSectionClass))
-#define MAEMO_TWEAKS_IS_MCE_SECTION(obj) \
-        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
-        MAEMO_TWEAKS_TYPE_MCE_SECTION))
-
-#define DISABLE_LABEL "Disable"
-#define SHOW_MENU_LABEL "Show menu"
-#define POWER_OFF_LABEL "Power off"
-#define LOCK_LABEL "Lock"
-
-enum {
-    SHORT_POWER_KEY_DISABLED,
-    SHORT_POWER_KEY_MENU,
-    SHORT_POWER_KEY_OFF,
-    SHORT_POWER_KEY_N
-};
-
-enum {
-    LONG_POWER_KEY_DISABLED,
-    LONG_POWER_KEY_MENU,
-    LONG_POWER_KEY_OFF,
-    LONG_POWER_KEY_N
-};
-
-enum {
-    DOUBLE_POWER_KEY_DISABLED,
-    DOUBLE_POWER_KEY_MENU,
-    DOUBLE_POWER_KEY_OFF,
-    DOUBLE_POWER_KEY_LOCK,
-    DOUBLE_POWER_KEY_N
-};
-
-
-typedef struct _picker_t
-{
-    guint index;
-    const gchar *value;
-    const gchar *label;
-} picker_t;
-
-static picker_t spk [] = {
-    {SHORT_POWER_KEY_DISABLED, "disabled", DISABLE_LABEL},
-    {SHORT_POWER_KEY_MENU, "menu", SHOW_MENU_LABEL},
-    {SHORT_POWER_KEY_OFF, "poweroff", POWER_OFF_LABEL}
-};
-
-static picker_t lpk [] = {
-    {LONG_POWER_KEY_DISABLED, "disabled", DISABLE_LABEL},
-    {LONG_POWER_KEY_MENU, "menu", SHOW_MENU_LABEL},
-    {LONG_POWER_KEY_OFF, "poweroff", POWER_OFF_LABEL}
-};
-
-static picker_t dpk [] = {
-    {DOUBLE_POWER_KEY_DISABLED, "disabled", DISABLE_LABEL},
-    {DOUBLE_POWER_KEY_MENU, "menu", SHOW_MENU_LABEL},
-    {DOUBLE_POWER_KEY_OFF, "poweroff", POWER_OFF_LABEL},
-    {DOUBLE_POWER_KEY_LOCK, "tklock", LOCK_LABEL}
-};
-
-
-typedef struct _MaemoTweaksMceSection MaemoTweaksMceSection;
-typedef struct _MaemoTweaksMceSectionClass
-               MaemoTweaksMceSectionClass;
-
-struct _MaemoTweaksMceSection
-{
-    MaemoTweaksSection parent_instance;
-
-    GKeyFile *ini;
-    GtkWidget *short_power_key;
-    GtkWidget *long_power_key;
-    GtkWidget *double_power_key;
-
-    guint value_changed : 1;
-};
-
-struct _MaemoTweaksMceSectionClass
-{
-    MaemoTweaksSectionClass parent_class;
-};
-
-
-static GType maemo_tweaks_mce_section_get_type (GTypeModule *module);
-static void maemo_tweaks_mce_section_class_init
-    (MaemoTweaksMceSectionClass *class);
-static void maemo_tweaks_mce_section_init
-    (MaemoTweaksMceSection *section);
-static void maemo_tweaks_mce_section_dispose (GObject *obj);
-
-static gboolean _save (MaemoTweaksSection *section,
-                       gboolean *requires_restart);
-
-static GType maemo_tweaks_mce_section_type = 0;
-static MaemoTweaksSectionClass *
-    maemo_tweaks_mce_section_parent_class = NULL;
-
-
-G_MODULE_EXPORT void
-maemo_tweaks_module_load (MaemoTweaksModule *module)
-{
-    maemo_tweaks_mce_section_get_type (G_TYPE_MODULE (module));
-}
-
-G_MODULE_EXPORT void
-maemo_tweaks_module_unload (MaemoTweaksModule *module)
-{
-}
-
-static GType
-maemo_tweaks_mce_section_get_type (GTypeModule *module)
-{
-    if (!maemo_tweaks_mce_section_type)
-    {
-        static const GTypeInfo section_info =
-        {
-            sizeof (MaemoTweaksMceSectionClass),
-            (GBaseInitFunc) NULL,
-            (GBaseFinalizeFunc) NULL,
-            (GClassInitFunc) maemo_tweaks_mce_section_class_init,
-            NULL,           /* class_finalize */
-            NULL,           /* class_data     */
-            sizeof (MaemoTweaksMceSection),
-            0,              /* n_preallocs    */
-            (GInstanceInitFunc) maemo_tweaks_mce_section_init
-        };
-
-        maemo_tweaks_mce_section_type =
-            g_type_module_register_type (module, MAEMO_TWEAKS_TYPE_SECTION,
-                                         "MaemoTweaksMceSection",
-                                         &section_info, 0);
-    }
-
-    return maemo_tweaks_mce_section_type;
-}
-
-static void
-maemo_tweaks_mce_section_class_init
-    (MaemoTweaksMceSectionClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS (klass);
-    MaemoTweaksSectionClass *section_class =
-        MAEMO_TWEAKS_SECTION_CLASS (klass);
-
-    maemo_tweaks_mce_section_parent_class =
-        g_type_class_peek_parent (klass);
-
-    section_class->name   = "_Mce";
-    section_class->save = _save;
-
-    object_class->dispose = maemo_tweaks_mce_section_dispose;
-}
-
-static void _value_changed (HildonPickerButton *b, gpointer user_data)
-{
-    MaemoTweaksMceSection *section = MAEMO_TWEAKS_MCE_SECTION (user_data);
-
-    section->value_changed = TRUE;
-}
-
-GtkWidget * _build_short_power_key (MaemoTweaksMceSection *section)
-{
-    gint i;
-    GtkWidget *button, *selector;
-
-    selector = hildon_touch_selector_new_text ();
-    for (i = 0; i < SHORT_POWER_KEY_N; i++)
-    {
-        hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector),
-                                           spk[i].label);
-    }
-
-    button = hildon_picker_button_new (HILDON_SIZE_AUTO,
-                                       HILDON_BUTTON_ARRANGEMENT_VERTICAL);
-    hildon_gtk_widget_set_theme_size (button, HILDON_SIZE_FINGER_HEIGHT);
-
-    hildon_button_set_title (HILDON_BUTTON (button),
-                             "Power key: short press");
-    gtk_button_set_alignment (GTK_BUTTON (button), 0.0f, 0.5f);
-    hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
-                                       HILDON_TOUCH_SELECTOR (selector));
-
-    g_signal_connect (G_OBJECT (button), "value-changed",
-                      G_CALLBACK (_value_changed), section);
-
-    gtk_widget_show (button);
-    return button;
-}
-
-GtkWidget * _build_long_power_key (MaemoTweaksMceSection *section)
-{
-    gint i;
-    GtkWidget *button, *selector;
-
-    selector = hildon_touch_selector_new_text ();
-    for (i = 0; i < LONG_POWER_KEY_N; i++)
-    {
-        hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector),
-                                           lpk[i].label);
-    }
-
-    button = hildon_picker_button_new (HILDON_SIZE_AUTO,
-                                       HILDON_BUTTON_ARRANGEMENT_VERTICAL);
-    hildon_gtk_widget_set_theme_size (button, HILDON_SIZE_FINGER_HEIGHT);
-
-    hildon_button_set_title (HILDON_BUTTON (button),
-                             "Power key: long press");
-    gtk_button_set_alignment (GTK_BUTTON (button), 0.0f, 0.5f);
-    hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
-                                       HILDON_TOUCH_SELECTOR (selector));
-
-    g_signal_connect (G_OBJECT (button), "value-changed",
-                      G_CALLBACK (_value_changed), section);
-
-    gtk_widget_show (button);
-    return button;
-}
-
-GtkWidget * _build_double_power_key (MaemoTweaksMceSection *section)
-{
-    gint i;
-    GtkWidget *button, *selector;
-
-    selector = hildon_touch_selector_new_text ();
-    for (i = 0; i < DOUBLE_POWER_KEY_N; i++)
-    {
-        hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector),
-                                           dpk[i].label);
-    }
-
-    button = hildon_picker_button_new (HILDON_SIZE_AUTO,
-                                       HILDON_BUTTON_ARRANGEMENT_VERTICAL);
-    hildon_gtk_widget_set_theme_size (button, HILDON_SIZE_FINGER_HEIGHT);
-
-    hildon_button_set_title (HILDON_BUTTON (button),
-                             "Power key: double press");
-    gtk_button_set_alignment (GTK_BUTTON (button), 0.0f, 0.5f);
-    hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
-                                       HILDON_TOUCH_SELECTOR (selector));
-
-    g_signal_connect (G_OBJECT (button), "value-changed",
-                      G_CALLBACK (_value_changed), section);
-
-    gtk_widget_show (button);
-    return button;
-}
-
-
-static void
-maemo_tweaks_mce_section_init (MaemoTweaksMceSection *section)
-{
-    MaemoTweaksSection *iface;
-    gchar *short_power_key_value;
-    gchar *long_power_key_value;
-    gchar *double_power_key_value;
-    gint i;
-
-    section->short_power_key = _build_short_power_key (section);
-    section->long_power_key = _build_long_power_key (section);
-    section->double_power_key = _build_double_power_key (section);
-
-    section->ini = g_key_file_new ();
-
-    if (!g_key_file_load_from_file (section->ini, MCE,
-                                    G_KEY_FILE_NONE, NULL))
-    {
-        g_warning ("%s: failed to load %s", G_STRFUNC, MCE);
-        return;
-    }
-
-    short_power_key_value = g_key_file_get_string (section->ini, "PowerKey",
-                                                   "PowerKeyShortAction",
-                                                   NULL);
-    long_power_key_value = g_key_file_get_string (section->ini, "PowerKey",
-                                                  "PowerKeyLongAction",
-                                                  NULL);
-    double_power_key_value = g_key_file_get_string (section->ini, "PowerKey",
-                                                    "PowerKeyDoubleAction",
-                                                    NULL);
-
-    for (i = 0; i < SHORT_POWER_KEY_N; i++)
-    {
-        if (g_strcmp0 (short_power_key_value, spk[i].value) == 0)
-        {
-            hildon_picker_button_set_active
-                (HILDON_PICKER_BUTTON (section->short_power_key), i);
-        }
-    }
-
-    for (i = 0; i < LONG_POWER_KEY_N; i++)
-    {
-        if (g_strcmp0 (long_power_key_value, lpk[i].value) == 0)
-        {
-            hildon_picker_button_set_active
-                (HILDON_PICKER_BUTTON (section->long_power_key), i);
-        }
-    }
-
-    for (i = 0; i < DOUBLE_POWER_KEY_N; i++)
-    {
-        if (g_strcmp0 (double_power_key_value, dpk[i].value) == 0)
-        {
-            hildon_picker_button_set_active
-                (HILDON_PICKER_BUTTON (section->double_power_key), i);
-        }
-    }
-
-    section->value_changed = FALSE;
-
-    iface = MAEMO_TWEAKS_SECTION (section);
-    iface->name = "Mce";
-    iface->widget = gtk_vbox_new (FALSE, 0);
-    gtk_box_pack_start (GTK_BOX (iface->widget), section->short_power_key,
-                        FALSE, FALSE, 0);
-    gtk_box_pack_start (GTK_BOX (iface->widget), section->long_power_key,
-                        FALSE, FALSE, 0);
-    gtk_box_pack_start (GTK_BOX (iface->widget), section->double_power_key,
-                        FALSE, FALSE, 0);
-}
-
-static void
-maemo_tweaks_mce_section_dispose (GObject *obj)
-{
-    MaemoTweaksMceSection *section = MAEMO_TWEAKS_MCE_SECTION (obj);
-    if (section->ini)
-    {
-        g_key_file_free (section->ini);
-        section->ini = NULL;
-    }
-
-    G_OBJECT_CLASS (maemo_tweaks_mce_section_parent_class)->dispose
-        (obj);
-}
-
-static gboolean _save (MaemoTweaksSection *section,
-                       gboolean *requires_restart)
-{
-    gchar *argv[5];
-    gint short_active, long_active, double_active;
-    gint i;
-
-    if (!MAEMO_TWEAKS_MCE_SECTION (section)->value_changed)
-        return TRUE;
-
-    short_active = hildon_picker_button_get_active
-        (HILDON_PICKER_BUTTON (MAEMO_TWEAKS_MCE_SECTION
-                               (section)->short_power_key));
-
-    long_active = hildon_picker_button_get_active
-        (HILDON_PICKER_BUTTON (MAEMO_TWEAKS_MCE_SECTION
-                               (section)->long_power_key));
-
-    double_active = hildon_picker_button_get_active
-        (HILDON_PICKER_BUTTON (MAEMO_TWEAKS_MCE_SECTION
-                               (section)->double_power_key));
-
-    if (short_active  == SHORT_POWER_KEY_DISABLED &&
-        long_active   == LONG_POWER_KEY_DISABLED  &&
-        double_active == DOUBLE_POWER_KEY_DISABLED)
-    {
-        GtkWidget *note;
-        gint retcode;
-
-        note = hildon_note_new_confirmation
-            (NULL, "Setting all Power Key options to \"Disabled\" means "
-             "that the only way to turn the device off is the removal of "
-             "the battery. Do you want to continue?");
-        retcode = gtk_dialog_run (GTK_DIALOG (note));
-        gtk_widget_destroy (note);
-
-        if (retcode == GTK_RESPONSE_CANCEL)
-            return FALSE;
-    }
-
-    *requires_restart = TRUE;
-
-    argv[0] = g_strdup ("/usr/bin/maemo-tweaks-mce-save");
-    argv[1] = g_strdup_printf ("%s", spk[short_active].value);
-    argv[2] = g_strdup_printf ("%s", lpk[long_active].value);
-    argv[3] = g_strdup_printf ("%s", dpk[double_active].value);
-    argv[4] = NULL;
-
-    g_spawn_sync ("/home/user", argv, NULL,
-                  G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
-                  NULL, NULL, NULL, NULL, NULL, NULL);
-
-    for (i = 0; i < (sizeof (argv) / sizeof (gchar *)) - 1; i++)
-        g_free (argv[i]);
-
-    return TRUE;
-}
-
diff --git a/modules/tweakr-desktop-save.c b/modules/tweakr-desktop-save.c
new file mode 100644 (file)
index 0000000..3b56065
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * vim:ts=4:sw=4:et:cindent:cino=(0
+ */ 
+
+#include <stdlib.h>
+#include <glib.h>
+
+static gchar *groups[] =
+{
+    "edit_mode",
+    NULL
+};
+static gchar *keys[] =
+{
+    "snap_grid_size",
+    NULL
+};
+
+int main (int argc, char *argv[])
+{
+    GKeyFile *kf;
+    gint i;
+    GError *error = NULL;
+    gchar *data;
+    gsize size;
+
+    if (argc < 2)
+    {
+        exit (EXIT_FAILURE);;
+    }
+
+    kf = g_key_file_new ();
+    if (!g_key_file_load_from_file (kf, TRANSITIONS,
+                                    G_KEY_FILE_KEEP_COMMENTS |
+                                    G_KEY_FILE_KEEP_TRANSLATIONS,
+                                    &error))
+    {
+        g_warning ("Error while reading %s: %s", TRANSITIONS, error->message);
+        g_error_free (error);
+        exit (EXIT_FAILURE);
+    }
+
+    for (i = 0; i < argc - 1; i++)
+    {
+        g_key_file_set_string (kf, groups[i], keys[i], argv[i+1]);
+    }
+
+    data = g_key_file_to_data (kf, &size, &error);
+    if (data == NULL)
+    {
+        g_warning ("Error while writing keyfile data.");
+        g_error_free (error);
+        exit (EXIT_FAILURE);
+    }
+    
+    if (!g_file_set_contents (TRANSITIONS, data, size, &error))
+    {
+        g_warning ("Error writing %s", TRANSITIONS);
+        g_free (data);
+        g_error_free (error);
+        exit (EXIT_FAILURE);
+    }
+
+    g_free (data);
+    g_key_file_free (kf);
+
+    return 0;
+}
+
diff --git a/modules/tweakr-desktop.c b/modules/tweakr-desktop.c
new file mode 100644 (file)
index 0000000..0aa8a6e
--- /dev/null
@@ -0,0 +1,257 @@
+/*
+ * vim:ts=4:sw=4:et:cindent:cino=(0
+ */ 
+
+#include <config.h>
+
+#include <gtk/gtk.h>
+#include <hildon/hildon-picker-button.h>
+#include <hildon/hildon-touch-selector.h>
+
+#include "libtweakr-section/tweakr-section.h"
+#include "libtweakr-section/tweakr-module.h"
+
+
+#define TWEAKR_TYPE_DESKTOP_SECTION \
+        (tweakr_desktop_section_type)
+#define TWEAKR_DESKTOP_SECTION(obj) \
+        (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+        TWEAKR_TYPE_DESKTOP_SECTION, \
+        TweakrDesktopSection))
+#define TWEAKR_DESKTOP_SECTION_CLASS(k) \
+        (G_TYPE_CHECK_CLASS_CAST((k), \
+        TWEAKR_TYPE_DESKTOP_SECTION, \
+        TweakrDesktopSectionClass))
+#define TWEAKR_IS_DESKTOP_SECTION(obj) \
+        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+        TWEAKR_TYPE_DESKTOP_SECTION))
+
+
+enum
+{
+    SNAP_NONE,
+    SNAP_SMALL,
+    SNAP_LARGE,
+    SNAP_HUGE
+};
+
+enum
+{
+    SNAP_NONE_VALUE,
+    SNAP_SMALL_VALUE = 8,
+    SNAP_LARGE_VALUE = 16,
+    SNAP_HUGE_VALUE = 32
+};
+
+static gint snap_values [] = {
+    SNAP_NONE_VALUE,
+    SNAP_SMALL_VALUE,
+    SNAP_LARGE_VALUE,
+    SNAP_HUGE_VALUE
+};
+
+typedef struct _TweakrDesktopSection TweakrDesktopSection;
+typedef struct _TweakrDesktopSectionClass
+               TweakrDesktopSectionClass;
+
+struct _TweakrDesktopSection
+{
+    TweakrSection parent_instance;
+
+    GKeyFile *ini;
+    GtkWidget *snap_button;
+};
+
+struct _TweakrDesktopSectionClass
+{
+    TweakrSectionClass parent_class;
+};
+
+
+static GType tweakr_desktop_section_get_type (GTypeModule *module);
+static void tweakr_desktop_section_class_init
+    (TweakrDesktopSectionClass *class);
+static void tweakr_desktop_section_init
+    (TweakrDesktopSection *section);
+static void tweakr_desktop_section_dispose (GObject *obj);
+
+static gboolean _save (TweakrSection *section,
+                       gboolean *requires_restart);
+
+static GType tweakr_desktop_section_type = 0;
+static TweakrSectionClass *
+    tweakr_desktop_section_parent_class = NULL;
+
+
+G_MODULE_EXPORT void
+tweakr_module_load (TweakrModule *module)
+{
+    tweakr_desktop_section_get_type (G_TYPE_MODULE (module));
+}
+
+G_MODULE_EXPORT void
+tweakr_module_unload (TweakrModule *module)
+{
+}
+
+static GType
+tweakr_desktop_section_get_type (GTypeModule *module)
+{
+    if (!tweakr_desktop_section_type)
+    {
+        static const GTypeInfo section_info =
+        {
+            sizeof (TweakrDesktopSectionClass),
+            (GBaseInitFunc) NULL,
+            (GBaseFinalizeFunc) NULL,
+            (GClassInitFunc) tweakr_desktop_section_class_init,
+            NULL,           /* class_finalize */
+            NULL,           /* class_data     */
+            sizeof (TweakrDesktopSection),
+            0,              /* n_preallocs    */
+            (GInstanceInitFunc) tweakr_desktop_section_init
+        };
+
+        tweakr_desktop_section_type =
+            g_type_module_register_type (module, TWEAKR_TYPE_SECTION,
+                                         "TweakrDesktopSection",
+                                         &section_info, 0);
+    }
+
+    return tweakr_desktop_section_type;
+}
+
+static void
+tweakr_desktop_section_class_init
+    (TweakrDesktopSectionClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+    TweakrSectionClass *section_class =
+        TWEAKR_SECTION_CLASS (klass);
+
+    tweakr_desktop_section_parent_class =
+        g_type_class_peek_parent (klass);
+
+    section_class->name   = "_Desktop";
+    section_class->save = _save;
+
+    object_class->dispose = tweakr_desktop_section_dispose;
+}
+
+GtkWidget * _build_snap_to_grid (void)
+{
+    const gchar *options[] = {"No", "Small", "Large", "Huge", NULL};
+    gint i = 0;
+    GtkWidget *button, *selector;
+
+    selector = hildon_touch_selector_new_text ();
+    while (options[i] && options[i] != '\0')
+    {
+        hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector),
+                                           options [i++]);
+    }
+
+    button = hildon_picker_button_new (HILDON_SIZE_AUTO,
+                                       HILDON_BUTTON_ARRANGEMENT_VERTICAL);
+    hildon_gtk_widget_set_theme_size (button, HILDON_SIZE_FINGER_HEIGHT);
+
+    hildon_button_set_title (HILDON_BUTTON (button),
+                             "Snap icons to grid");
+    gtk_button_set_alignment (GTK_BUTTON (button), 0.0f, 0.5f);
+    hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
+                                       HILDON_TOUCH_SELECTOR (selector));
+
+    gtk_widget_show (button);
+    return button;
+}
+
+static void
+tweakr_desktop_section_init (TweakrDesktopSection *section)
+{
+    TweakrSection *iface;
+
+    gint snap_value = SNAP_NONE_VALUE;
+
+    section->snap_button = _build_snap_to_grid ();
+
+    section->ini = g_key_file_new ();
+
+    if (!g_key_file_load_from_file (section->ini, TRANSITIONS,
+                                    G_KEY_FILE_NONE, NULL))
+    {
+        g_warning ("%s: failed to load %s", G_STRFUNC, TRANSITIONS);
+        return;
+    }
+
+    snap_value = g_key_file_get_integer (section->ini, "edit_mode",
+                                         "snap_grid_size", NULL);
+
+    if (snap_value < SNAP_SMALL_VALUE)
+    {
+        hildon_picker_button_set_active
+            (HILDON_PICKER_BUTTON (section->snap_button), SNAP_NONE);
+    }
+    else if (snap_value < SNAP_LARGE_VALUE)
+    {
+        hildon_picker_button_set_active
+            (HILDON_PICKER_BUTTON (section->snap_button), SNAP_SMALL);
+    }
+    else if (snap_value < SNAP_HUGE_VALUE)
+    {
+        hildon_picker_button_set_active
+            (HILDON_PICKER_BUTTON (section->snap_button), SNAP_LARGE);
+    }
+    else
+    {
+        hildon_picker_button_set_active
+            (HILDON_PICKER_BUTTON (section->snap_button), SNAP_HUGE);
+    }
+
+
+
+    iface = TWEAKR_SECTION (section);
+    iface->name = "Desktop";
+    iface->widget = gtk_vbox_new (FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (iface->widget), section->snap_button,
+                        FALSE, FALSE, 0);
+}
+
+static void
+tweakr_desktop_section_dispose (GObject *obj)
+{
+    TweakrDesktopSection *section = TWEAKR_DESKTOP_SECTION (obj);
+    if (section->ini)
+    {
+        g_key_file_free (section->ini);
+        section->ini = NULL;
+    }
+
+    G_OBJECT_CLASS (tweakr_desktop_section_parent_class)->dispose
+        (obj);
+}
+
+
+static gboolean  _save (TweakrSection *section,
+                        gboolean *requires_restart)
+{
+    gchar *argv[3];
+    gint active;
+
+    active = hildon_picker_button_get_active
+        (HILDON_PICKER_BUTTON (TWEAKR_DESKTOP_SECTION
+                               (section)->snap_button));
+
+    argv[0] = g_strdup ("/usr/bin/tweakr-desktop-save");
+    argv[1] = g_strdup_printf ("%d", snap_values[active]);
+    argv[2] = NULL;
+
+    g_spawn_sync ("/home/user", argv, NULL,
+                  G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
+                  NULL, NULL, NULL, NULL, NULL, NULL);
+
+    g_free (argv[0]);
+    g_free (argv[1]);
+
+    return TRUE;
+}
+
diff --git a/modules/tweakr-mce-save.c b/modules/tweakr-mce-save.c
new file mode 100644 (file)
index 0000000..608c2d8
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * vim:ts=4:sw=4:et:cindent:cino=(0
+ */ 
+
+#include <stdlib.h>
+#include <glib.h>
+
+#define FILENAME MCE
+
+typedef struct _value_t
+{
+    const gchar *group;
+    const gchar *name;
+    const gchar *value;
+} value_t;
+
+int main (int argc, char *argv[])
+{
+    GKeyFile *kf;
+    value_t v[3];
+    gint i;
+    GError *error = NULL;
+    gchar *data;
+    gsize size;
+
+    if (argc < (sizeof (v) / sizeof (value_t)) + 1)
+    {
+        exit (EXIT_FAILURE);
+    }
+
+    v[0].group = "PowerKey";
+    v[0].name = "PowerKeyShortAction";
+    v[0].value = argv[1];
+
+    v[1].group = "PowerKey";
+    v[1].name = "PowerKeyLongAction";
+    v[1].value = argv[2];
+
+    v[2].group = "PowerKey";
+    v[2].name = "PowerKeyDoubleAction";
+    v[2].value = argv[3];
+
+    kf = g_key_file_new ();
+    if (!g_key_file_load_from_file (kf, FILENAME,
+                                    G_KEY_FILE_KEEP_COMMENTS |
+                                    G_KEY_FILE_KEEP_TRANSLATIONS,
+                                    &error))
+    {
+        g_warning ("Error while reading %s: %s", FILENAME, error->message);
+        g_error_free (error);
+        exit (EXIT_FAILURE);
+    }
+
+    for (i = 0; i < argc - 1; i++)
+    {
+        g_key_file_set_string (kf, v[i].group, v[i].name, v[i].value);
+    }
+
+    data = g_key_file_to_data (kf, &size, &error);
+    if (data == NULL)
+    {
+        g_warning ("Error while writing keyfile data.");
+        g_error_free (error);
+        exit (EXIT_FAILURE);
+    }
+    
+    if (!g_file_set_contents (FILENAME, data, size, &error))
+    {
+        g_warning ("Error writing %s", FILENAME);
+        g_free (data);
+        g_error_free (error);
+        exit (EXIT_FAILURE);
+    }
+
+    g_free (data);
+    g_key_file_free (kf);
+
+    exit (EXIT_SUCCESS);
+}
+
diff --git a/modules/tweakr-mce.c b/modules/tweakr-mce.c
new file mode 100644 (file)
index 0000000..34ce1a6
--- /dev/null
@@ -0,0 +1,415 @@
+/*
+ * vim:ts=4:sw=4:et:cindent:cino=(0
+ */ 
+
+#include <config.h>
+
+#include <gtk/gtk.h>
+#include <hildon/hildon-picker-button.h>
+#include <hildon/hildon-touch-selector.h>
+#include <hildon/hildon-note.h>
+
+#include "libtweakr-section/tweakr-section.h"
+#include "libtweakr-section/tweakr-module.h"
+
+
+#define TWEAKR_TYPE_MCE_SECTION \
+        (tweakr_mce_section_type)
+#define TWEAKR_MCE_SECTION(obj) \
+        (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+        TWEAKR_TYPE_MCE_SECTION, \
+        TweakrMceSection))
+#define TWEAKR_MCE_SECTION_CLASS(k) \
+        (G_TYPE_CHECK_CLASS_CAST((k), \
+        TWEAKR_TYPE_MCE_SECTION, \
+        TweakrMceSectionClass))
+#define TWEAKR_IS_MCE_SECTION(obj) \
+        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+        TWEAKR_TYPE_MCE_SECTION))
+
+#define DISABLE_LABEL "Disable"
+#define SHOW_MENU_LABEL "Show menu"
+#define POWER_OFF_LABEL "Power off"
+#define LOCK_LABEL "Lock"
+
+enum {
+    SHORT_POWER_KEY_DISABLED,
+    SHORT_POWER_KEY_MENU,
+    SHORT_POWER_KEY_OFF,
+    SHORT_POWER_KEY_N
+};
+
+enum {
+    LONG_POWER_KEY_DISABLED,
+    LONG_POWER_KEY_MENU,
+    LONG_POWER_KEY_OFF,
+    LONG_POWER_KEY_N
+};
+
+enum {
+    DOUBLE_POWER_KEY_DISABLED,
+    DOUBLE_POWER_KEY_MENU,
+    DOUBLE_POWER_KEY_OFF,
+    DOUBLE_POWER_KEY_LOCK,
+    DOUBLE_POWER_KEY_N
+};
+
+
+typedef struct _picker_t
+{
+    guint index;
+    const gchar *value;
+    const gchar *label;
+} picker_t;
+
+static picker_t spk [] = {
+    {SHORT_POWER_KEY_DISABLED, "disabled", DISABLE_LABEL},
+    {SHORT_POWER_KEY_MENU, "menu", SHOW_MENU_LABEL},
+    {SHORT_POWER_KEY_OFF, "poweroff", POWER_OFF_LABEL}
+};
+
+static picker_t lpk [] = {
+    {LONG_POWER_KEY_DISABLED, "disabled", DISABLE_LABEL},
+    {LONG_POWER_KEY_MENU, "menu", SHOW_MENU_LABEL},
+    {LONG_POWER_KEY_OFF, "poweroff", POWER_OFF_LABEL}
+};
+
+static picker_t dpk [] = {
+    {DOUBLE_POWER_KEY_DISABLED, "disabled", DISABLE_LABEL},
+    {DOUBLE_POWER_KEY_MENU, "menu", SHOW_MENU_LABEL},
+    {DOUBLE_POWER_KEY_OFF, "poweroff", POWER_OFF_LABEL},
+    {DOUBLE_POWER_KEY_LOCK, "tklock", LOCK_LABEL}
+};
+
+
+typedef struct _TweakrMceSection TweakrMceSection;
+typedef struct _TweakrMceSectionClass
+               TweakrMceSectionClass;
+
+struct _TweakrMceSection
+{
+    TweakrSection parent_instance;
+
+    GKeyFile *ini;
+    GtkWidget *short_power_key;
+    GtkWidget *long_power_key;
+    GtkWidget *double_power_key;
+
+    guint value_changed : 1;
+};
+
+struct _TweakrMceSectionClass
+{
+    TweakrSectionClass parent_class;
+};
+
+
+static GType tweakr_mce_section_get_type (GTypeModule *module);
+static void tweakr_mce_section_class_init
+    (TweakrMceSectionClass *class);
+static void tweakr_mce_section_init
+    (TweakrMceSection *section);
+static void tweakr_mce_section_dispose (GObject *obj);
+
+static gboolean _save (TweakrSection *section,
+                       gboolean *requires_restart);
+
+static GType tweakr_mce_section_type = 0;
+static TweakrSectionClass *
+    tweakr_mce_section_parent_class = NULL;
+
+
+G_MODULE_EXPORT void
+tweakr_module_load (TweakrModule *module)
+{
+    tweakr_mce_section_get_type (G_TYPE_MODULE (module));
+}
+
+G_MODULE_EXPORT void
+tweakr_module_unload (TweakrModule *module)
+{
+}
+
+static GType
+tweakr_mce_section_get_type (GTypeModule *module)
+{
+    if (!tweakr_mce_section_type)
+    {
+        static const GTypeInfo section_info =
+        {
+            sizeof (TweakrMceSectionClass),
+            (GBaseInitFunc) NULL,
+            (GBaseFinalizeFunc) NULL,
+            (GClassInitFunc) tweakr_mce_section_class_init,
+            NULL,           /* class_finalize */
+            NULL,           /* class_data     */
+            sizeof (TweakrMceSection),
+            0,              /* n_preallocs    */
+            (GInstanceInitFunc) tweakr_mce_section_init
+        };
+
+        tweakr_mce_section_type =
+            g_type_module_register_type (module, TWEAKR_TYPE_SECTION,
+                                         "TweakrMceSection",
+                                         &section_info, 0);
+    }
+
+    return tweakr_mce_section_type;
+}
+
+static void
+tweakr_mce_section_class_init
+    (TweakrMceSectionClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+    TweakrSectionClass *section_class =
+        TWEAKR_SECTION_CLASS (klass);
+
+    tweakr_mce_section_parent_class =
+        g_type_class_peek_parent (klass);
+
+    section_class->name   = "_Mce";
+    section_class->save = _save;
+
+    object_class->dispose = tweakr_mce_section_dispose;
+}
+
+static void _value_changed (HildonPickerButton *b, gpointer user_data)
+{
+    TweakrMceSection *section = TWEAKR_MCE_SECTION (user_data);
+
+    section->value_changed = TRUE;
+}
+
+GtkWidget * _build_short_power_key (TweakrMceSection *section)
+{
+    gint i;
+    GtkWidget *button, *selector;
+
+    selector = hildon_touch_selector_new_text ();
+    for (i = 0; i < SHORT_POWER_KEY_N; i++)
+    {
+        hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector),
+                                           spk[i].label);
+    }
+
+    button = hildon_picker_button_new (HILDON_SIZE_AUTO,
+                                       HILDON_BUTTON_ARRANGEMENT_VERTICAL);
+    hildon_gtk_widget_set_theme_size (button, HILDON_SIZE_FINGER_HEIGHT);
+
+    hildon_button_set_title (HILDON_BUTTON (button),
+                             "Power key: short press");
+    gtk_button_set_alignment (GTK_BUTTON (button), 0.0f, 0.5f);
+    hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
+                                       HILDON_TOUCH_SELECTOR (selector));
+
+    g_signal_connect (G_OBJECT (button), "value-changed",
+                      G_CALLBACK (_value_changed), section);
+
+    gtk_widget_show (button);
+    return button;
+}
+
+GtkWidget * _build_long_power_key (TweakrMceSection *section)
+{
+    gint i;
+    GtkWidget *button, *selector;
+
+    selector = hildon_touch_selector_new_text ();
+    for (i = 0; i < LONG_POWER_KEY_N; i++)
+    {
+        hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector),
+                                           lpk[i].label);
+    }
+
+    button = hildon_picker_button_new (HILDON_SIZE_AUTO,
+                                       HILDON_BUTTON_ARRANGEMENT_VERTICAL);
+    hildon_gtk_widget_set_theme_size (button, HILDON_SIZE_FINGER_HEIGHT);
+
+    hildon_button_set_title (HILDON_BUTTON (button),
+                             "Power key: long press");
+    gtk_button_set_alignment (GTK_BUTTON (button), 0.0f, 0.5f);
+    hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
+                                       HILDON_TOUCH_SELECTOR (selector));
+
+    g_signal_connect (G_OBJECT (button), "value-changed",
+                      G_CALLBACK (_value_changed), section);
+
+    gtk_widget_show (button);
+    return button;
+}
+
+GtkWidget * _build_double_power_key (TweakrMceSection *section)
+{
+    gint i;
+    GtkWidget *button, *selector;
+
+    selector = hildon_touch_selector_new_text ();
+    for (i = 0; i < DOUBLE_POWER_KEY_N; i++)
+    {
+        hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector),
+                                           dpk[i].label);
+    }
+
+    button = hildon_picker_button_new (HILDON_SIZE_AUTO,
+                                       HILDON_BUTTON_ARRANGEMENT_VERTICAL);
+    hildon_gtk_widget_set_theme_size (button, HILDON_SIZE_FINGER_HEIGHT);
+
+    hildon_button_set_title (HILDON_BUTTON (button),
+                             "Power key: double press");
+    gtk_button_set_alignment (GTK_BUTTON (button), 0.0f, 0.5f);
+    hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
+                                       HILDON_TOUCH_SELECTOR (selector));
+
+    g_signal_connect (G_OBJECT (button), "value-changed",
+                      G_CALLBACK (_value_changed), section);
+
+    gtk_widget_show (button);
+    return button;
+}
+
+
+static void
+tweakr_mce_section_init (TweakrMceSection *section)
+{
+    TweakrSection *iface;
+    gchar *short_power_key_value;
+    gchar *long_power_key_value;
+    gchar *double_power_key_value;
+    gint i;
+
+    section->short_power_key = _build_short_power_key (section);
+    section->long_power_key = _build_long_power_key (section);
+    section->double_power_key = _build_double_power_key (section);
+
+    section->ini = g_key_file_new ();
+
+    if (!g_key_file_load_from_file (section->ini, MCE,
+                                    G_KEY_FILE_NONE, NULL))
+    {
+        g_warning ("%s: failed to load %s", G_STRFUNC, MCE);
+        return;
+    }
+
+    short_power_key_value = g_key_file_get_string (section->ini, "PowerKey",
+                                                   "PowerKeyShortAction",
+                                                   NULL);
+    long_power_key_value = g_key_file_get_string (section->ini, "PowerKey",
+                                                  "PowerKeyLongAction",
+                                                  NULL);
+    double_power_key_value = g_key_file_get_string (section->ini, "PowerKey",
+                                                    "PowerKeyDoubleAction",
+                                                    NULL);
+
+    for (i = 0; i < SHORT_POWER_KEY_N; i++)
+    {
+        if (g_strcmp0 (short_power_key_value, spk[i].value) == 0)
+        {
+            hildon_picker_button_set_active
+                (HILDON_PICKER_BUTTON (section->short_power_key), i);
+        }
+    }
+
+    for (i = 0; i < LONG_POWER_KEY_N; i++)
+    {
+        if (g_strcmp0 (long_power_key_value, lpk[i].value) == 0)
+        {
+            hildon_picker_button_set_active
+                (HILDON_PICKER_BUTTON (section->long_power_key), i);
+        }
+    }
+
+    for (i = 0; i < DOUBLE_POWER_KEY_N; i++)
+    {
+        if (g_strcmp0 (double_power_key_value, dpk[i].value) == 0)
+        {
+            hildon_picker_button_set_active
+                (HILDON_PICKER_BUTTON (section->double_power_key), i);
+        }
+    }
+
+    section->value_changed = FALSE;
+
+    iface = TWEAKR_SECTION (section);
+    iface->name = "Mce";
+    iface->widget = gtk_vbox_new (FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (iface->widget), section->short_power_key,
+                        FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (iface->widget), section->long_power_key,
+                        FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (iface->widget), section->double_power_key,
+                        FALSE, FALSE, 0);
+}
+
+static void
+tweakr_mce_section_dispose (GObject *obj)
+{
+    TweakrMceSection *section = TWEAKR_MCE_SECTION (obj);
+    if (section->ini)
+    {
+        g_key_file_free (section->ini);
+        section->ini = NULL;
+    }
+
+    G_OBJECT_CLASS (tweakr_mce_section_parent_class)->dispose
+        (obj);
+}
+
+static gboolean _save (TweakrSection *section,
+                       gboolean *requires_restart)
+{
+    gchar *argv[5];
+    gint short_active, long_active, double_active;
+    gint i;
+
+    if (!TWEAKR_MCE_SECTION (section)->value_changed)
+        return TRUE;
+
+    short_active = hildon_picker_button_get_active
+        (HILDON_PICKER_BUTTON (TWEAKR_MCE_SECTION
+                               (section)->short_power_key));
+
+    long_active = hildon_picker_button_get_active
+        (HILDON_PICKER_BUTTON (TWEAKR_MCE_SECTION
+                               (section)->long_power_key));
+
+    double_active = hildon_picker_button_get_active
+        (HILDON_PICKER_BUTTON (TWEAKR_MCE_SECTION
+                               (section)->double_power_key));
+
+    if (short_active  == SHORT_POWER_KEY_DISABLED &&
+        long_active   == LONG_POWER_KEY_DISABLED  &&
+        double_active == DOUBLE_POWER_KEY_DISABLED)
+    {
+        GtkWidget *note;
+        gint retcode;
+
+        note = hildon_note_new_confirmation
+            (NULL, "Setting all Power Key options to \"Disabled\" means "
+             "that the only way to turn the device off is the removal of "
+             "the battery. Do you want to continue?");
+        retcode = gtk_dialog_run (GTK_DIALOG (note));
+        gtk_widget_destroy (note);
+
+        if (retcode == GTK_RESPONSE_CANCEL)
+            return FALSE;
+    }
+
+    *requires_restart = TRUE;
+
+    argv[0] = g_strdup ("/usr/bin/tweakr-mce-save");
+    argv[1] = g_strdup_printf ("%s", spk[short_active].value);
+    argv[2] = g_strdup_printf ("%s", lpk[long_active].value);
+    argv[3] = g_strdup_printf ("%s", dpk[double_active].value);
+    argv[4] = NULL;
+
+    g_spawn_sync ("/home/user", argv, NULL,
+                  G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
+                  NULL, NULL, NULL, NULL, NULL, NULL);
+
+    for (i = 0; i < (sizeof (argv) / sizeof (gchar *)) - 1; i++)
+        g_free (argv[i]);
+
+    return TRUE;
+}
+
diff --git a/tweakr-module-manager.c b/tweakr-module-manager.c
new file mode 100644 (file)
index 0000000..db4c2e5
--- /dev/null
@@ -0,0 +1,204 @@
+/*
+ * vim:ts=4:sw=4:et:cindent:cino=(0
+ */ 
+
+#include <config.h>
+
+#include <string.h>
+#include <unistd.h>
+
+#include <gmodule.h>
+
+#include "tweakr-types.h"
+#include "libtweakr-section/tweakr-module.h"
+#include "tweakr-module-manager.h"
+
+
+enum
+{
+    PROP_0,
+    PROP_MODULE_PATH
+};
+
+
+static GObject *
+tweakr_module_manager_constructor (GType type,
+                                         guint n_params,
+                                         GObjectConstructParam *params);
+static void
+tweakr_module_manager_finalize (GObject *object);
+
+static void
+tweakr_module_manager_get_property (GObject *object,
+                                          guint param_id,
+                                          GValue *value,
+                                          GParamSpec *pspec);
+
+static void
+tweakr_module_manager_set_property (GObject *object,
+                                          guint param_id,
+                                          const GValue *value,
+                                          GParamSpec *pspec);
+
+static gboolean
+tweakr_module_manager_query_modules
+    (TweakrModuleManager *manager);
+
+
+G_DEFINE_TYPE (TweakrModuleManager, tweakr_module_manager,
+               G_TYPE_OBJECT);
+
+
+static void
+tweakr_module_manager_class_init (TweakrModuleManagerClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+    object_class->constructor  = tweakr_module_manager_constructor;
+    object_class->finalize     = tweakr_module_manager_finalize;
+    object_class->get_property = tweakr_module_manager_get_property;
+    object_class->set_property = tweakr_module_manager_set_property;
+
+    g_object_class_install_property
+        (object_class, PROP_MODULE_PATH,
+         g_param_spec_string ("module-path",
+                              "Module Path",
+                              "The path where to look for modules",
+                              NULL,
+                              G_PARAM_READWRITE |
+                              G_PARAM_CONSTRUCT_ONLY));
+}
+
+static void
+tweakr_module_manager_init (TweakrModuleManager *manager)
+{
+    manager->module_path = NULL;
+    manager->modules     = NULL;
+}
+
+static GObject *
+tweakr_module_manager_constructor (GType type,
+                                         guint n_params,
+                                         GObjectConstructParam *params)
+{
+    GObject *object;
+    TweakrModuleManager *manager;
+
+    object = G_OBJECT_CLASS
+        (tweakr_module_manager_parent_class)->constructor (type,
+                                                                 n_params,
+                                                                 params);
+
+    manager = TWEAKR_MODULE_MANAGER (object);
+
+    if (manager->module_path)
+        tweakr_module_manager_query_modules (manager);
+
+    return object;
+}
+
+static void
+tweakr_module_manager_finalize (GObject *object)
+{
+    TweakrModuleManager *manager = TWEAKR_MODULE_MANAGER (object);
+
+    g_free (manager->module_path);
+
+    /* GTypeModules most not be finalized, don't unref them */
+    g_list_free (manager->modules);
+
+    G_OBJECT_CLASS (tweakr_module_manager_parent_class)->
+        finalize (object);
+}
+
+static void
+tweakr_module_manager_get_property (GObject *object,
+                                          guint param_id,
+                                          GValue *value,
+                                          GParamSpec *pspec)
+{
+    TweakrModuleManager *manager = TWEAKR_MODULE_MANAGER (object);
+
+    switch (param_id)
+    {
+        case PROP_MODULE_PATH:
+            g_value_set_string (value, manager->module_path);
+            break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+            break;
+    }
+}
+
+static void
+tweakr_module_manager_set_property (GObject *object,
+                                          guint param_id,
+                                          const GValue *value,
+                                          GParamSpec *pspec)
+{
+    TweakrModuleManager *manager = TWEAKR_MODULE_MANAGER (object);
+
+    switch (param_id)
+    {
+        case PROP_MODULE_PATH:
+            manager->module_path = g_value_dup_string (value);
+            break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+            break;
+    }
+}
+
+static gboolean
+tweakr_module_manager_is_valid_module_name (const gchar *name)
+{
+    return g_str_has_suffix (name, ".so");
+}
+
+static gboolean
+tweakr_module_manager_query_modules (TweakrModuleManager *manager)
+{
+    const gchar *name;
+    GDir        *dir;
+    GError      *error = NULL;
+
+    dir = g_dir_open (manager->module_path, 0, &error);
+
+    if (!dir)
+    {
+        g_printerr ("Error while opening module dir: %s\n", error->message);
+        g_clear_error (&error);
+        return FALSE;
+    }
+
+    while ((name = g_dir_read_name (dir)))
+    {
+        if (tweakr_module_manager_is_valid_module_name (name))
+        {
+            TweakrModule *module;
+            gchar     *path;
+
+            path = g_build_filename (manager->module_path, name, NULL);
+            module = tweakr_module_new (path);
+
+            if (! g_type_module_use (G_TYPE_MODULE (module)))
+            {
+                g_printerr ("Failed to load module: %s\n", path);
+                g_object_unref (module);
+                g_free (path);
+                continue;
+            }
+
+            g_free (path);
+
+            g_type_module_unuse (G_TYPE_MODULE (module));
+
+            manager->modules = g_list_prepend (manager->modules, module);
+        }
+    }
+
+    g_dir_close (dir);
+
+    return TRUE;
+}
+
diff --git a/tweakr-module-manager.h b/tweakr-module-manager.h
new file mode 100644 (file)
index 0000000..28b56b8
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * vim:ts=4:sw=4:et:cindent:cino=(0
+ */ 
+
+#ifndef __TWEAKR_MODULE_MANAGER_H__
+#define __TWEAKR_MODULE_MANAGER_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define TWEAKR_TYPE_MODULE_MANAGER \
+        (tweakr_module_manager_get_type ())
+#define TWEAKR_MODULE_MANAGER(obj) \
+        (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+        TWEAKR_TYPE_MODULE_MANAGER, \
+        TweakrModuleManager))
+#define TWEAKR_MODULE_MANAGER_CLASS(k) \
+        (G_TYPE_CHECK_CLASS_CAST((k), \
+        TWEAKR_TYPE_MODULE_MANAGER, \
+        TweakrModuleManagerClass))
+#define TWEAKR_IS_MODULE_MANAGER(obj) \
+        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+        TWEAKR_TYPE_MODULE_MANAGER))
+#define TWEAKR_IS_MODULE_MANAGER_CLASS(k) \
+        (G_TYPE_CHECK_CLASS_TYPE((k), \
+        TWEAKR_TYPE_MODULE_MANAGER))
+#define TWEAKR_MODULE_MANAGER_GET_CLASS(o) \
+        (G_TYPE_INSTANCE_GET_CLASS ((o), \
+        TWEAKR_TYPE_MODULE_MANAGER, \
+        TweakrModuleManagerClass))
+
+
+typedef struct _TweakrModuleManagerClass TweakrModuleManagerClass;
+
+struct _TweakrModuleManager
+{
+    GObject  parent_instance;
+
+    gchar   *module_path;
+    GList   *modules;
+};
+
+struct _TweakrModuleManagerClass
+{
+    GObjectClass  parent_class;
+};
+
+
+GType tweakr_module_manager_get_type (void) G_GNUC_CONST;
+
+
+G_END_DECLS
+
+#endif /* __TWEAKR_MODULE_MANAGER_H__ */
+
diff --git a/tweakr-types.h b/tweakr-types.h
new file mode 100644 (file)
index 0000000..efc3ef5
--- /dev/null
@@ -0,0 +1,11 @@
+/*
+ * vim:ts=4:sw=4:et:cindent:cino=(0
+ */ 
+
+#ifndef __TWEAKR_TYPES_H__
+#define __TWEAKR_TYPES_H__
+
+typedef struct _TweakrModuleManager TweakrModuleManager;
+
+#endif /* __TWEAKR_TYPES_H__ */
+
diff --git a/tweakr.c b/tweakr.c
new file mode 100644 (file)
index 0000000..9ddd1cc
--- /dev/null
+++ b/tweakr.c
@@ -0,0 +1,127 @@
+/*
+ * vim:ts=4:sw=4:et:cindent:cino=(0
+ */ 
+
+#include <hildon-cp-plugin/hildon-cp-plugin-interface.h>
+#include <gtk/gtk.h>
+#include <hildon/hildon-note.h>
+#include <hildon/hildon-pannable-area.h>
+#include <hildon/hildon-defines.h>
+
+#include "tweakr-types.h"
+#include "libtweakr-section/tweakr-section.h"
+#include "tweakr-module-manager.h"
+
+static gboolean save_ret;
+
+GtkWidget *create_dialog (GtkWindow *parent)
+{
+    GtkWidget *dialog;
+
+    dialog = gtk_dialog_new_with_buttons
+        ("Tweakr",
+         parent,
+         GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR,
+         GTK_STOCK_SAVE,
+         GTK_RESPONSE_OK,
+         GTK_STOCK_CANCEL,
+         GTK_RESPONSE_CANCEL,
+         NULL);
+
+    return dialog;
+}
+
+void _save (TweakrSection *section, gboolean *requires_restart)
+{
+    save_ret &= tweakr_section_save (section, requires_restart);
+}
+
+osso_return_t execute (osso_context_t *osso, gpointer data,
+                       gboolean user_activated)
+{
+    GtkWidget *dialog;
+    GtkWidget *panarea;
+    GtkWidget *box;
+    gint response;
+
+    TweakrModuleManager *manager;
+    GType *section_types;
+    guint n_sections;
+    GList *sections = NULL;
+    gint i;
+    gboolean requires_restart = FALSE;
+
+    manager = g_object_new (TWEAKR_TYPE_MODULE_MANAGER,
+                            "module-path", MODULES_DIR,
+                            NULL);
+
+    section_types = g_type_children (TWEAKR_TYPE_SECTION, &n_sections);
+
+    dialog = create_dialog (GTK_WINDOW (data));
+    panarea = hildon_pannable_area_new ();
+    box = gtk_vbox_new (FALSE, HILDON_MARGIN_DOUBLE);
+
+    hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA (panarea),
+                                            box);
+    g_object_set (G_OBJECT (panarea), "height-request", 350, NULL);
+
+    for (i = 0; i < n_sections; i++)
+    {
+        TweakrSection *section;
+        TweakrSectionClass *klass;
+        GtkWidget *frame;
+
+        klass = g_type_class_ref (section_types[i]);
+        section = tweakr_section_new (section_types[i]);
+
+        sections = g_list_prepend (sections, section);
+        frame = gtk_frame_new (section->name);
+
+        gtk_box_pack_start (GTK_BOX (box),
+                            frame,
+                            FALSE, FALSE, 0);
+        gtk_container_add (GTK_CONTAINER (frame),
+                           tweakr_section_get_widget (section));
+
+        g_type_class_unref (klass);
+    }
+
+    gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), panarea,
+                        FALSE, FALSE, 0);
+    gtk_widget_show_all (GTK_DIALOG (dialog)->vbox);
+
+    for (;;)
+    {
+        save_ret = TRUE;
+        response = gtk_dialog_run (GTK_DIALOG (dialog));
+        if (response == GTK_RESPONSE_OK)
+        {
+            /* Save all settings */
+            g_list_foreach (sections, (GFunc) _save, &requires_restart);
+        }
+        if (save_ret)
+            break;
+    }
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+    g_object_unref (manager);
+    if (sections)
+    {
+        g_list_foreach (sections, (GFunc) g_object_unref, NULL);
+        g_list_free (sections);
+    }
+
+    if (requires_restart)
+    {
+        GtkWidget *note;
+
+        note = hildon_note_new_information
+            (GTK_WINDOW (data), "Some of the settings you have changed"
+             " will take effect only after you restart your device.");
+        gtk_dialog_run (GTK_DIALOG (note));
+        gtk_widget_destroy (note);
+    }
+
+    return OSSO_OK;
+}
+
diff --git a/tweakr.desktop b/tweakr.desktop
new file mode 100644 (file)
index 0000000..2aa3335
--- /dev/null
@@ -0,0 +1,9 @@
+[Desktop Entry] 
+Encoding=UTF-8
+Version=0.1
+Name=Tweakr
+Comment=Tweaks for Maemo 5
+Type=HildonControlPanelPlugin
+Icon=qgn_list_cp_isetup
+X-control-panel-plugin=libtweakr.so
+Categories=personalization