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
(MaemoTweaksDesktopSectionClass *class);
static void maemo_tweaks_desktop_section_init
(MaemoTweaksDesktopSection *section);
+static void maemo_tweaks_desktop_section_dispose (GObject *obj);
-static void _save (MaemoTweaksSection *section);
+static gboolean _save (MaemoTweaksSection *section,
+ gboolean *requires_restart);
static GType maemo_tweaks_desktop_section_type = 0;
static MaemoTweaksSectionClass *
maemo_tweaks_desktop_section_class_init
(MaemoTweaksDesktopSectionClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
MaemoTweaksSectionClass *section_class =
MAEMO_TWEAKS_SECTION_CLASS (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[] = {"Default", "Small grid", "Large grid", NULL};
+ const gchar *options[] = {"No", "Small", "Large", "Huge", NULL};
gint i = 0;
GtkWidget *button, *selector;
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 desktop icons to grid");
-
+ "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));
static void
maemo_tweaks_desktop_section_init (MaemoTweaksDesktopSection *section)
{
- GtkWidget * snap_button;
MaemoTweaksSection *iface;
- snap_button = _build_snap_to_grid ();
- iface = MAEMO_TWEAKS_SECTION (section);
+ 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), snap_button,
- TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (iface->widget), section->snap_button,
+ FALSE, FALSE, 0);
}
-static void _save (MaemoTweaksSection *section)
+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;
}