From 2f361187de89fe177b8021bbb1616dbf22bc4726 Mon Sep 17 00:00:00 2001 From: Salvatore Iovene Date: Sun, 6 Dec 2009 14:01:35 +0200 Subject: [PATCH] Load sections and add their widget to the dialog. --- Makefile.am | 7 ++++++- configure.ac | 8 ++++++++ maemo-tweaks.c | 40 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index b7b9cd8..8b1f884 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,8 @@ SUBDIRS = libmaemo-tweaks-section modules +libmaemo_tweaks_section = \ + $(top_builddir)/libmaemo-tweaks-section/libmaemo-tweaks-section.la + libmaemo_tweaks_LTLIBRARIES = libmaemo-tweaks.la libmaemo_tweaksdir = $(libdir)/hildon-control-panel @@ -7,13 +10,15 @@ libmaemo_tweaks_la_LDFLAGS = -version-info "1":"0":"1" libmaemo_tweaks_la_LIBADD = \ $(GTK_LIBS) \ $(HILDON_LIBS) \ - $(OSSO_LIBS) + $(OSSO_LIBS) \ + $(libmaemo_tweaks_section) AM_CFLAGS = \ $(GTK_CFLAGS) \ $(HILDON_CFLAGS) \ $(OSSO_CFLAGS) \ -I$(top_srcdir) \ + -DMODULES_DIR=\"$(modulesdir)\" \ -DG_LOG_DOMAIN=\"maemo-tweaks\" libmaemo_tweaks_la_SOURCES = \ diff --git a/configure.ac b/configure.ac index 4d54615..24e263f 100644 --- a/configure.ac +++ b/configure.ac @@ -46,6 +46,14 @@ 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=],[Directory for storing maemo-tweaks modules])) +if test -z "$with_modules_dir" ; then + modulesdir=$libdir/maemo-tweaks/modules +else + modulesdir=$with_modules_dir +fi +AC_SUBST(modulesdir) + AC_OUTPUT([ Makefile libmaemo-tweaks-section/Makefile diff --git a/maemo-tweaks.c b/maemo-tweaks.c index ca3f125..67f9a27 100644 --- a/maemo-tweaks.c +++ b/maemo-tweaks.c @@ -5,6 +5,10 @@ #include #include +#include "maemo-tweaks-types.h" +#include "libmaemo-tweaks-section/maemo-tweaks-section.h" +#include "maemo-tweaks-module-manager.h" + GtkWidget *create_dialog (GtkWindow *parent) { GtkWidget *dialog; @@ -22,20 +26,54 @@ GtkWidget *create_dialog (GtkWindow *parent) return dialog; } - osso_return_t execute (osso_context_t *osso, gpointer data, gboolean user_activated) { GtkWidget *dialog; gint response; + MaemoTweaksModuleManager *manager; + GType *section_types; + guint n_sections; + GList *sections = NULL; + gint i; + + 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)); + + for (i = 0; i < n_sections; i++) + { + MaemoTweaksSection *section; + MaemoTweaksSectionClass *klass; + + klass = g_type_class_ref (section_types[i]); + section = maemo_tweaks_section_new (section_types[i]); + + sections = g_list_prepend (sections, section); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), + maemo_tweaks_section_get_widget (section), + FALSE, FALSE, 0); + + g_type_class_unref (klass); + } + response = gtk_dialog_run (GTK_DIALOG (dialog)); if (response == GTK_RESPONSE_OK) { } + gtk_widget_destroy (GTK_WIDGET (dialog)); + g_object_unref (manager); + g_list_foreach (sections, (GFunc) g_object_unref, NULL); + if (sections) + g_list_free (sections); + return OSSO_OK; } -- 1.7.9.5