aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Bradford <rob@o-hand.com>2008-03-18 14:55:37 +0000
committerrob <rob@aea7fca7-3721-49c4-ace3-ac8c44b998bb>2008-03-18 14:55:37 +0000
commit9a18bd368e2ef060b68e9997b25839833548f847 (patch)
tree8d1dc22726983b738cdd880b8558e1d060828202
parent0ec4af86a8d136cfbd9827221d6fc99ff720d863 (diff)
downloadanjuta-poky-9a18bd368e2ef060b68e9997b25839833548f847.tar.gz
anjuta-poky-9a18bd368e2ef060b68e9997b25839833548f847.tar.bz2
anjuta-poky-9a18bd368e2ef060b68e9997b25839833548f847.zip
2008-03-18 Rob Bradford <rob@openedhand.com>
* src/Makefile.am: * src/beaver-settings-page.c: (beaver_settings_page_get_property), (beaver_settings_page_set_property), (beaver_settings_page_dispose), (beaver_settings_page_finalize), (beaver_settings_page_constructed), (beaver_settings_page_class_init), (beaver_settings_page_init), (beaver_settings_page_new), (preferences_timeout_cb), (full_radio_toggled_cb), (toolchain_radio_toggled_cb), (create_ui): * src/beaver-settings-page.h: * src/beaver.h: * src/plugin.c: (ipreferences_merge): * src/plugin.h: Separate the preferences UI into it's own component.
-rw-r--r--ChangeLog16
-rw-r--r--src/Makefile.am4
-rw-r--r--src/beaver-settings-page.c425
-rw-r--r--src/beaver-settings-page.h63
-rw-r--r--src/beaver.h32
-rw-r--r--src/plugin.c310
-rw-r--r--src/plugin.h9
7 files changed, 543 insertions, 316 deletions
diff --git a/ChangeLog b/ChangeLog
index 8fea91d..cd513c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
2008-03-18 Rob Bradford <rob@openedhand.com>
+ * src/Makefile.am:
+ * src/beaver-settings-page.c: (beaver_settings_page_get_property),
+ (beaver_settings_page_set_property),
+ (beaver_settings_page_dispose), (beaver_settings_page_finalize),
+ (beaver_settings_page_constructed),
+ (beaver_settings_page_class_init), (beaver_settings_page_init),
+ (beaver_settings_page_new), (preferences_timeout_cb),
+ (full_radio_toggled_cb), (toolchain_radio_toggled_cb), (create_ui):
+ * src/beaver-settings-page.h:
+ * src/beaver.h:
+ * src/plugin.c: (ipreferences_merge):
+ * src/plugin.h:
+ Separate the preferences UI into it's own component.
+
+2008-03-18 Rob Bradford <rob@openedhand.com>
+
* src/beaver-util.h:
Add header guards.
diff --git a/src/Makefile.am b/src/Makefile.am
index 662e736..c17f3e1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -45,7 +45,9 @@ plugin_LTLIBRARIES = libanjuta-plugin-sdk.la
libanjuta_plugin_sdk_la_SOURCES = plugin.c plugin.h \
beaver-target.c beaver-target.h \
beaver-target-qemu.c beaver-target-qemu.h \
- beaver-util.c beaver-util.h
+ beaver-util.c beaver-util.h \
+ beaver-settings-page.c beaver-settings-page.h \
+ beaver.h
# Plugin dependencies
libanjuta_plugin_sdk_la_LIBADD = \
diff --git a/src/beaver-settings-page.c b/src/beaver-settings-page.c
new file mode 100644
index 0000000..ea9537a
--- /dev/null
+++ b/src/beaver-settings-page.c
@@ -0,0 +1,425 @@
+/*
+ * Copyright (C) 2007, 2008 OpenedHand Ltd.
+ * Authored by: Rob Bradford <rob@o-hand.com>
+ *
+ * This is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, version 2 of the License.
+ *
+ * This software is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "beaver-settings-page.h"
+#include "beaver.h"
+
+G_DEFINE_TYPE (BeaverSettingsPage, beaver_settings_page, GTK_TYPE_VBOX)
+
+#define SETTINGS_PAGE_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), BEAVER_TYPE_SETTINGS_PAGE, BeaverSettingsPagePrivate))
+
+typedef struct _BeaverSettingsPagePrivate BeaverSettingsPagePrivate;
+
+struct _BeaverSettingsPagePrivate
+{
+ AnjutaShell *shell;
+ AnjutaPreferences *prefs;
+
+ GtkWidget *kernel_chooser;
+ GtkWidget *rootfs_chooser;
+};
+
+enum
+{
+ PROP_0,
+ PROP_SHELL
+};
+
+static void create_ui (BeaverSettingsPage *page);
+
+static void
+beaver_settings_page_get_property (GObject *object, guint property_id,
+ GValue *value, GParamSpec *pspec)
+{
+ switch (property_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+beaver_settings_page_set_property (GObject *object, guint property_id,
+ const GValue *value, GParamSpec *pspec)
+{
+ BeaverSettingsPagePrivate *priv = SETTINGS_PAGE_PRIVATE (object);
+
+ switch (property_id) {
+ case PROP_SHELL:
+ priv->shell = g_value_get_object (value);
+ priv->prefs = anjuta_shell_get_preferences (priv->shell, NULL);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+beaver_settings_page_dispose (GObject *object)
+{
+ if (G_OBJECT_CLASS (beaver_settings_page_parent_class)->dispose)
+ G_OBJECT_CLASS (beaver_settings_page_parent_class)->dispose (object);
+}
+
+static void
+beaver_settings_page_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (beaver_settings_page_parent_class)->finalize (object);
+}
+
+static void
+beaver_settings_page_constructed (GObject *object)
+{
+ if (G_OBJECT_CLASS (beaver_settings_page_parent_class)->constructed)
+ G_OBJECT_CLASS (beaver_settings_page_parent_class)->constructed (object);
+
+ create_ui (BEAVER_SETTINGS_PAGE (object));
+}
+
+static void
+beaver_settings_page_class_init (BeaverSettingsPageClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GParamSpec *pspec = NULL;
+
+ g_type_class_add_private (klass, sizeof (BeaverSettingsPagePrivate));
+
+ object_class->get_property = beaver_settings_page_get_property;
+ object_class->set_property = beaver_settings_page_set_property;
+ object_class->dispose = beaver_settings_page_dispose;
+ object_class->finalize = beaver_settings_page_finalize;
+ object_class->constructed = beaver_settings_page_constructed;
+
+ pspec = g_param_spec_object ("shell", "shell", "shell",
+ ANJUTA_TYPE_SHELL,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE);
+ g_object_class_install_property (object_class, PROP_SHELL, pspec);
+}
+
+static void
+beaver_settings_page_init (BeaverSettingsPage *self)
+{
+}
+
+GtkWidget *
+beaver_settings_page_new (AnjutaShell *shell)
+{
+ return g_object_new (BEAVER_TYPE_SETTINGS_PAGE,
+ "shell", shell,
+ NULL);
+}
+
+static gboolean
+preferences_timeout_cb (gpointer userdata)
+{
+ BeaverSettingsPage *page = BEAVER_SETTINGS_PAGE (userdata);
+ BeaverSettingsPagePrivate *priv = SETTINGS_PAGE_PRIVATE (page);
+ gchar *filename;
+
+ filename = anjuta_preferences_get (priv->prefs,
+ PREFS_PROP_KERNEL);
+ gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (priv->kernel_chooser),
+ filename);
+ g_free (filename);
+
+ filename = anjuta_preferences_get (priv->prefs,
+ PREFS_PROP_ROOTFS);
+ gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (priv->rootfs_chooser),
+ filename);
+ g_free (filename);
+
+ return FALSE;
+}
+
+static void
+full_radio_toggled_cb (GtkToggleButton *toggle, gpointer userdata)
+{
+ gtk_widget_set_sensitive (GTK_WIDGET (userdata),
+ gtk_toggle_button_get_active (toggle));
+}
+
+static void
+toolchain_radio_toggled_cb (GtkToggleButton *toggle, gpointer userdata)
+{
+ gtk_widget_set_sensitive (GTK_WIDGET (userdata),
+ gtk_toggle_button_get_active (toggle));
+}
+
+static void
+create_ui (BeaverSettingsPage *page)
+{
+ BeaverSettingsPagePrivate *priv = SETTINGS_PAGE_PRIVATE (page);
+
+ GtkSizeGroup *opts_labels_group;
+ GtkSizeGroup *opts_fields_group;
+ GtkSizeGroup *qemu_labels_group;
+ GtkSizeGroup *qemu_fields_group;
+
+ GtkWidget *frame;
+ GtkWidget *inner_vbox;
+ GtkWidget *hbox;
+ GtkWidget *label;
+ GtkWidget *chooser;
+ GtkWidget *entry;
+ GtkWidget *inner_alignment;
+ GtkWidget *qemu_vbox;
+
+ GtkWidget *toolchain_radio;
+ GtkWidget *full_radio;
+
+ gboolean res;
+ gchar *filename = NULL;
+
+ gtk_box_set_spacing (GTK_BOX (page), 6);
+ gtk_box_set_homogeneous (GTK_BOX (page), FALSE);
+ gtk_container_set_border_width (GTK_CONTAINER (page), 6);
+
+ /* Frame for options */
+ frame = gtk_frame_new (_("<b>Cross-compiler Options</b>"));
+ gtk_box_pack_start (GTK_BOX (page), frame, FALSE, FALSE, 2);
+ label = gtk_frame_get_label_widget (GTK_FRAME (frame));
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+
+ /* size groups for files */
+ opts_labels_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+ opts_fields_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+
+ /* Pack inner vbox */
+ inner_vbox = gtk_vbox_new (FALSE, 6);
+ inner_alignment = gtk_alignment_new (0, 0.5, 1, 1);
+ g_object_set (inner_alignment, "left-padding", 12, "top-padding", 6, NULL);
+ gtk_container_add (GTK_CONTAINER (inner_alignment), inner_vbox);
+ gtk_container_add (GTK_CONTAINER (frame), inner_alignment);
+
+ /* Radio for external toolchain */
+ toolchain_radio = gtk_radio_button_new_with_label (NULL,
+ _("Use an external toolchain"));
+ gtk_box_pack_start (GTK_BOX (inner_vbox), toolchain_radio, TRUE, FALSE, 0);
+
+ /* Widgets for sdk root */
+ inner_alignment = gtk_alignment_new (0, 0.5, 1, 1);
+ g_object_set (inner_alignment, "left-padding", 24, NULL);
+ gtk_box_pack_start (GTK_BOX (inner_vbox), inner_alignment, TRUE, FALSE, 0);
+
+ hbox = gtk_hbox_new (FALSE, 6);
+ gtk_container_add (GTK_CONTAINER (inner_alignment), hbox);
+ g_signal_connect (toolchain_radio, "toggled", (GCallback)toolchain_radio_toggled_cb,
+ hbox);
+
+ /* label */
+ label = gtk_label_new (_("SDK root: "));
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ gtk_size_group_add_widget (opts_labels_group, label);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+
+ /* chooser */
+ chooser = gtk_file_chooser_button_new (_("Select SDK root"),
+ GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
+ gtk_size_group_add_widget (opts_fields_group, label);
+ gtk_box_pack_start (GTK_BOX (hbox), chooser, TRUE, TRUE, 0);
+
+ res = anjuta_preferences_register_property_raw (
+ priv->prefs,
+ chooser,
+ PREFS_PROP_SDK_ROOT,
+ NULL,
+ 0,
+ ANJUTA_PROPERTY_OBJECT_TYPE_FOLDER,
+ ANJUTA_PROPERTY_DATA_TYPE_TEXT);
+
+ if (!res)
+ g_warning ("Error adding preference for SDK root");
+
+ /* Radio for poky tree */
+ full_radio = gtk_radio_button_new_with_label_from_widget (
+ GTK_RADIO_BUTTON (toolchain_radio),
+ _("Use a full Poky tree"));
+ gtk_box_pack_start (GTK_BOX (inner_vbox), full_radio, TRUE, FALSE, 0);
+
+ /* Widgets for full tree */
+ inner_alignment = gtk_alignment_new (0, 0.5, 1, 1);
+ g_object_set (inner_alignment, "left-padding", 24, NULL);
+ gtk_box_pack_start (GTK_BOX (inner_vbox), inner_alignment, TRUE, FALSE, 0);
+
+ hbox = gtk_hbox_new (FALSE, 6);
+ gtk_container_add (GTK_CONTAINER (inner_alignment), hbox);
+ g_signal_connect (full_radio, "toggled", (GCallback)full_radio_toggled_cb,
+ hbox);
+
+ /* Make the full options insensitive since by default we used external
+ * toolchain mode */
+ gtk_widget_set_sensitive (hbox, FALSE);
+
+ /* label */
+ label = gtk_label_new (_("Poky root: "));
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ gtk_size_group_add_widget (opts_labels_group, label);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+
+ /* chooser */
+ chooser = gtk_file_chooser_button_new (_("Select Poky root"),
+ GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
+
+ gtk_size_group_add_widget (opts_fields_group, label);
+ gtk_box_pack_start (GTK_BOX (hbox), chooser, TRUE, TRUE, 0);
+
+ res = anjuta_preferences_register_property_raw (
+ priv->prefs,
+ chooser,
+ PREFS_PROP_POKY_ROOT,
+ NULL,
+ 0,
+ ANJUTA_PROPERTY_OBJECT_TYPE_FOLDER,
+ ANJUTA_PROPERTY_DATA_TYPE_TEXT);
+
+ if (!res)
+ g_warning ("Error adding preference for Poky root");
+
+ /* Register a preference for the toggle */
+
+ /* This is all a bit of a hack, we register the property on the second one
+ * in the group. If the mode is 1 then this gets selected and the world is a
+ * happy place. But if this is 0, then the group is in an inconsistent
+ * state...Ah, but actually when the widgets are created the first is
+ * toggled on by default.
+ */
+ res = anjuta_preferences_register_property_raw (
+ priv->prefs,
+ full_radio,
+ PREFS_PROP_POKY_MODE,
+ NULL,
+ 0,
+ ANJUTA_PROPERTY_OBJECT_TYPE_TOGGLE,
+ ANJUTA_PROPERTY_DATA_TYPE_INT);
+
+ if (!res)
+ g_warning ("Error adding preference for mode of operation");
+
+ /* Widgets for toolchain triplet */
+ hbox = gtk_hbox_new (FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (inner_vbox), hbox, TRUE, FALSE, 0);
+
+ /* label */
+ label = gtk_label_new (_("Toolchain triplet: "));
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ gtk_size_group_add_widget (opts_labels_group, label);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+
+ /* entry */
+ entry = gtk_entry_new ();
+ gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
+ gtk_size_group_add_widget (opts_fields_group, label);
+
+ /* register prop */
+ res = anjuta_preferences_register_property_raw (priv->prefs,
+ entry,
+ PREFS_PROP_TRIPLET,
+ NULL,
+ 0,
+ ANJUTA_PROPERTY_OBJECT_TYPE_ENTRY,
+ ANJUTA_PROPERTY_DATA_TYPE_TEXT);
+
+ if (!res)
+ g_warning ("Error adding preference for triplet");
+
+ /* Frame for qemu */
+ frame = gtk_frame_new ("<b>QEMU Options</b>");
+ gtk_box_pack_start (GTK_BOX (page), frame, FALSE, FALSE, 2);
+ gtk_label_set_use_markup (GTK_LABEL (gtk_frame_get_label_widget (GTK_FRAME (frame))),
+ TRUE);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+
+ /* size groups for files */
+ qemu_labels_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+ qemu_fields_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+
+ /* Pack inner vbox */
+ inner_vbox = gtk_vbox_new (FALSE, 6);
+ inner_alignment = gtk_alignment_new (0, 0.5, 1, 1);
+ g_object_set (inner_alignment, "left-padding", 12, "top-padding", 6, NULL);
+ gtk_container_add (GTK_CONTAINER (inner_alignment), inner_vbox);
+ gtk_container_add (GTK_CONTAINER (frame), inner_alignment);
+
+ /* Widgets for kernel */
+ hbox = gtk_hbox_new (FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (inner_vbox), hbox, TRUE, FALSE, 0);
+
+ /* label */
+ label = gtk_label_new ("Kernel: ");
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ gtk_size_group_add_widget (qemu_labels_group, label);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+
+ /* chooser */
+ chooser = gtk_file_chooser_button_new (_("Select kernel file"), GTK_FILE_CHOOSER_ACTION_OPEN);
+ gtk_box_pack_start (GTK_BOX (hbox), chooser, TRUE, TRUE, 0);
+ gtk_size_group_add_widget (qemu_fields_group, chooser);
+
+ anjuta_preferences_register_property_raw (
+ priv->prefs,
+ chooser,
+ PREFS_PROP_KERNEL,
+ NULL,
+ 0,
+ ANJUTA_PROPERTY_OBJECT_TYPE_FILE,
+ ANJUTA_PROPERTY_DATA_TYPE_TEXT);
+
+ priv->kernel_chooser = chooser;
+
+ /* Widgets for rootfs */
+ hbox = gtk_hbox_new (FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (inner_vbox), hbox, TRUE, FALSE, 0);
+
+ /* label */
+ label = gtk_label_new ("Root filesystem: ");
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ gtk_size_group_add_widget (qemu_labels_group, label);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+
+ /* chooser */
+ chooser = gtk_file_chooser_button_new (_("Select root filesystem file"),
+ GTK_FILE_CHOOSER_ACTION_OPEN);
+ gtk_box_pack_start (GTK_BOX (hbox), chooser, TRUE, TRUE, 0);
+ gtk_size_group_add_widget (qemu_fields_group, chooser);
+ priv->rootfs_chooser = chooser;
+
+ anjuta_preferences_register_property_raw (
+ priv->prefs,
+ chooser,
+ PREFS_PROP_ROOTFS,
+ NULL,
+ 0,
+ ANJUTA_PROPERTY_OBJECT_TYPE_FILE,
+ ANJUTA_PROPERTY_DATA_TYPE_TEXT);
+
+ /* add page */
+ gtk_widget_show_all (GTK_WIDGET (page));
+
+ /*
+ * This is a horrible hack around some kind of race condition that seems to
+ * mean that the GtkFileChooserButton doesn't reflect the filename it is
+ * given by the prefences code in Anjuta. Even if it just gets set here it
+ * isn't guaranteed to work. This is the best option i've come up with.
+ *
+ * After 800ms fire a timeout that reads the values for the preferences and
+ * then sets the widgets. It only needs to be done for those that are of
+ * ANJUTA_PROPERTY_OBJECT_TYPE_FILE type.
+ */
+ g_timeout_add (800, preferences_timeout_cb, page);
+}
+
diff --git a/src/beaver-settings-page.h b/src/beaver-settings-page.h
new file mode 100644
index 0000000..3cced69
--- /dev/null
+++ b/src/beaver-settings-page.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2007, 2008 OpenedHand Ltd.
+ * Authored by: Rob Bradford <rob@o-hand.com>
+ *
+ * This is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, version 2 of the License.
+ *
+ * This software is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _BEAVER_SETTINGS_PAGE
+#define _BEAVER_SETTINGS_PAGE
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+#include <libanjuta/anjuta-shell.h>
+
+G_BEGIN_DECLS
+
+#define BEAVER_TYPE_SETTINGS_PAGE beaver_settings_page_get_type()
+
+#define BEAVER_SETTINGS_PAGE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ BEAVER_TYPE_SETTINGS_PAGE, BeaverSettingsPage))
+
+#define BEAVER_SETTINGS_PAGE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ BEAVER_TYPE_SETTINGS_PAGE, BeaverSettingsPageClass))
+
+#define BEAVER_IS_SETTINGS_PAGE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ BEAVER_TYPE_SETTINGS_PAGE))
+
+#define BEAVER_IS_SETTINGS_PAGE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ BEAVER_TYPE_SETTINGS_PAGE))
+
+#define BEAVER_SETTINGS_PAGE_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ BEAVER_TYPE_SETTINGS_PAGE, BeaverSettingsPageClass))
+
+typedef struct {
+ GtkVBox parent;
+} BeaverSettingsPage;
+
+typedef struct {
+ GtkVBoxClass parent_class;
+} BeaverSettingsPageClass;
+
+GType beaver_settings_page_get_type (void);
+
+GtkWidget *beaver_settings_page_new (AnjutaShell *shell);
+
+G_END_DECLS
+
+#endif /* _BEAVER_SETTINGS_PAGE */
diff --git a/src/beaver.h b/src/beaver.h
new file mode 100644
index 0000000..c440901
--- /dev/null
+++ b/src/beaver.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2007, 2008 OpenedHand Ltd.
+ * Authored by: Rob Bradford <rob@o-hand.com>
+ *
+ * This is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, version 2 of the License.
+ *
+ * This software is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _BEAVER
+#define _BEAVER
+
+#include "beaver-target.h"
+#include "beaver-target-qemu.h"
+#include "beaver-settings-page.h"
+
+#define PREFS_PROP_SDK_ROOT "sdk.root"
+#define PREFS_PROP_TRIPLET "sdk.triplet"
+#define PREFS_PROP_POKY_ROOT "sdk.poky_root"
+#define PREFS_PROP_POKY_MODE "sdk.poky_mode"
+#define PREFS_PROP_KERNEL "sdk.kernel"
+#define PREFS_PROP_ROOTFS "sdk.rootfs"
+
+#endif /* _BEAVER */
diff --git a/src/plugin.c b/src/plugin.c
index 92488fa..0ea32c6 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -35,15 +35,6 @@
#define g_timeout_add_seconds(interval, function, data) g_timeout_add ((interval) * 1000, function, data)
#endif
-#define PREFS_PROP_SDK_ROOT "sdk.root"
-#define PREFS_PROP_TRIPLET "sdk.triplet"
-#define PREFS_PROP_POKY_ROOT "sdk.poky_root"
-
-#define PREFS_PROP_POKY_MODE "sdk.poky_mode"
-
-#define PREFS_PROP_KERNEL "sdk.kernel"
-#define PREFS_PROP_ROOTFS "sdk.rootfs"
-
#define UI_FILE ANJUTA_DATA_DIR"/ui/anjuta-plugin-sdk.ui"
#define ICON_FILE "anjuta-plugin-sdk.png"
@@ -1716,315 +1707,20 @@ anjuta_plugin_sdk_class_init (GObjectClass *klass)
klass->dispose = anjuta_plugin_sdk_dispose;
}
-static gboolean
-preferences_timeout_cb (gpointer userdata)
-{
- AnjutaPluginSdk *sp = (AnjutaPluginSdk *)userdata;
- gchar *filename;
-
- filename = anjuta_preferences_get (ANJUTA_PREFERENCES (sp->prefs),
- PREFS_PROP_KERNEL);
- gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (sp->kernel_chooser),
- filename);
- g_free (filename);
-
- filename = anjuta_preferences_get (ANJUTA_PREFERENCES (sp->prefs),
- PREFS_PROP_ROOTFS);
- gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (sp->rootfs_chooser),
- filename);
- g_free (filename);
-
- return FALSE;
-}
-
-static void
-full_radio_toggled_cb (GtkToggleButton *toggle, gpointer userdata)
-{
- gtk_widget_set_sensitive (GTK_WIDGET (userdata),
- gtk_toggle_button_get_active (toggle));
-}
-
-static void
-toolchain_radio_toggled_cb (GtkToggleButton *toggle, gpointer userdata)
-{
- gtk_widget_set_sensitive (GTK_WIDGET (userdata),
- gtk_toggle_button_get_active (toggle));
-}
-
static void
ipreferences_merge (IAnjutaPreferences *ipref, AnjutaPreferences *prefs,
GError **error)
{
AnjutaPluginSdk *sp = (AnjutaPluginSdk *)ipref;
-
- GtkWidget *vbox;
- GtkSizeGroup *opts_labels_group;
- GtkSizeGroup *opts_fields_group;
- GtkSizeGroup *qemu_labels_group;
- GtkSizeGroup *qemu_fields_group;
-
- GtkWidget *frame;
- GtkWidget *inner_vbox;
- GtkWidget *hbox;
- GtkWidget *label;
- GtkWidget *chooser;
- GtkWidget *entry;
- GtkWidget *inner_alignment;
- GtkWidget *qemu_vbox;
-
- GtkWidget *toolchain_radio;
- GtkWidget *full_radio;
-
- gboolean res;
- gchar *filename = NULL;
-
GtkWidget *dialog = NULL;
+ GtkWidget *page = NULL;
dialog = anjuta_preferences_get_dialog (prefs);
-
- /* Create main vbox */
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
-
- /* Frame for options */
- frame = gtk_frame_new (_("<b>Cross-compiler Options</b>"));
- gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 2);
- label = gtk_frame_get_label_widget (GTK_FRAME (frame));
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
-
- /* size groups for files */
- opts_labels_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
- opts_fields_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-
- /* Pack inner vbox */
- inner_vbox = gtk_vbox_new (FALSE, 6);
- inner_alignment = gtk_alignment_new (0, 0.5, 1, 1);
- g_object_set (inner_alignment, "left-padding", 12, "top-padding", 6, NULL);
- gtk_container_add (GTK_CONTAINER (inner_alignment), inner_vbox);
- gtk_container_add (GTK_CONTAINER (frame), inner_alignment);
-
- /* Radio for external toolchain */
- toolchain_radio = gtk_radio_button_new_with_label (NULL,
- _("Use an external toolchain"));
- gtk_box_pack_start (GTK_BOX (inner_vbox), toolchain_radio, TRUE, FALSE, 0);
-
- /* Widgets for sdk root */
- inner_alignment = gtk_alignment_new (0, 0.5, 1, 1);
- g_object_set (inner_alignment, "left-padding", 24, NULL);
- gtk_box_pack_start (GTK_BOX (inner_vbox), inner_alignment, TRUE, FALSE, 0);
-
- hbox = gtk_hbox_new (FALSE, 6);
- gtk_container_add (GTK_CONTAINER (inner_alignment), hbox);
- g_signal_connect (toolchain_radio, "toggled", (GCallback)toolchain_radio_toggled_cb,
- hbox);
-
- /* label */
- label = gtk_label_new (_("SDK root: "));
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- gtk_size_group_add_widget (opts_labels_group, label);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
-
- /* chooser */
- chooser = gtk_file_chooser_button_new (_("Select SDK root"),
- GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
- gtk_size_group_add_widget (opts_fields_group, label);
- gtk_box_pack_start (GTK_BOX (hbox), chooser, TRUE, TRUE, 0);
-
- res = anjuta_preferences_register_property_raw (
- ANJUTA_PREFERENCES (prefs),
- chooser,
- PREFS_PROP_SDK_ROOT,
- NULL,
- 0,
- ANJUTA_PROPERTY_OBJECT_TYPE_FOLDER,
- ANJUTA_PROPERTY_DATA_TYPE_TEXT);
-
- if (!res)
- g_warning ("Error adding preference for SDK root");
-
- /* Radio for poky tree */
- full_radio = gtk_radio_button_new_with_label_from_widget (
- GTK_RADIO_BUTTON (toolchain_radio),
- _("Use a full Poky tree"));
- gtk_box_pack_start (GTK_BOX (inner_vbox), full_radio, TRUE, FALSE, 0);
-
- /* Widgets for full tree */
- inner_alignment = gtk_alignment_new (0, 0.5, 1, 1);
- g_object_set (inner_alignment, "left-padding", 24, NULL);
- gtk_box_pack_start (GTK_BOX (inner_vbox), inner_alignment, TRUE, FALSE, 0);
-
- hbox = gtk_hbox_new (FALSE, 6);
- gtk_container_add (GTK_CONTAINER (inner_alignment), hbox);
- g_signal_connect (full_radio, "toggled", (GCallback)full_radio_toggled_cb,
- hbox);
-
- /* Make the full options insensitive since by default we used external
- * toolchain mode */
- gtk_widget_set_sensitive (hbox, FALSE);
-
- /* label */
- label = gtk_label_new (_("Poky root: "));
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- gtk_size_group_add_widget (opts_labels_group, label);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
-
- /* chooser */
- chooser = gtk_file_chooser_button_new (_("Select Poky root"),
- GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
- sp->poky_root_chooser = chooser;
-
- gtk_size_group_add_widget (opts_fields_group, label);
- gtk_box_pack_start (GTK_BOX (hbox), chooser, TRUE, TRUE, 0);
-
- res = anjuta_preferences_register_property_raw (
- ANJUTA_PREFERENCES (prefs),
- chooser,
- PREFS_PROP_POKY_ROOT,
- NULL,
- 0,
- ANJUTA_PROPERTY_OBJECT_TYPE_FOLDER,
- ANJUTA_PROPERTY_DATA_TYPE_TEXT);
-
- if (!res)
- g_warning ("Error adding preference for Poky root");
-
- /* Register a preference for the toggle */
-
- /* This is all a bit of a hack, we register the property on the second one
- * in the group. If the mode is 1 then this gets selected and the world is a
- * happy place. But if this is 0, then the group is in an inconsistent
- * state...Ah, but actually when the widgets are created the first is
- * toggled on by default.
- */
- res = anjuta_preferences_register_property_raw (
- ANJUTA_PREFERENCES (prefs),
- full_radio,
- PREFS_PROP_POKY_MODE,
- NULL,
- 0,
- ANJUTA_PROPERTY_OBJECT_TYPE_TOGGLE,
- ANJUTA_PROPERTY_DATA_TYPE_INT);
-
- if (!res)
- g_warning ("Error adding preference for mode of operation");
-
- /* Widgets for toolchain triplet */
- hbox = gtk_hbox_new (FALSE, 6);
- gtk_box_pack_start (GTK_BOX (inner_vbox), hbox, TRUE, FALSE, 0);
-
- /* label */
- label = gtk_label_new (_("Toolchain triplet: "));
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- gtk_size_group_add_widget (opts_labels_group, label);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
-
- /* entry */
- entry = gtk_entry_new ();
- gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
- gtk_size_group_add_widget (opts_fields_group, label);
-
- /* register prop */
- res = anjuta_preferences_register_property_raw (ANJUTA_PREFERENCES (prefs),
- entry,
- PREFS_PROP_TRIPLET,
- NULL,
- 0,
- ANJUTA_PROPERTY_OBJECT_TYPE_ENTRY,
- ANJUTA_PROPERTY_DATA_TYPE_TEXT);
-
- if (!res)
- g_warning ("Error adding preference for triplet");
-
- /* Frame for qemu */
- frame = gtk_frame_new ("<b>QEMU Options</b>");
- gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 2);
- gtk_label_set_use_markup (GTK_LABEL (gtk_frame_get_label_widget (GTK_FRAME (frame))),
- TRUE);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
-
- /* size groups for files */
- qemu_labels_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
- qemu_fields_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-
- /* Pack inner vbox */
- inner_vbox = gtk_vbox_new (FALSE, 6);
- inner_alignment = gtk_alignment_new (0, 0.5, 1, 1);
- g_object_set (inner_alignment, "left-padding", 12, "top-padding", 6, NULL);
- gtk_container_add (GTK_CONTAINER (inner_alignment), inner_vbox);
- gtk_container_add (GTK_CONTAINER (frame), inner_alignment);
-
- /* Widgets for kernel */
- hbox = gtk_hbox_new (FALSE, 6);
- gtk_box_pack_start (GTK_BOX (inner_vbox), hbox, TRUE, FALSE, 0);
-
- /* label */
- label = gtk_label_new ("Kernel: ");
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- gtk_size_group_add_widget (qemu_labels_group, label);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
-
- /* chooser */
- chooser = gtk_file_chooser_button_new (_("Select kernel file"), GTK_FILE_CHOOSER_ACTION_OPEN);
- gtk_box_pack_start (GTK_BOX (hbox), chooser, TRUE, TRUE, 0);
- gtk_size_group_add_widget (qemu_fields_group, chooser);
-
- anjuta_preferences_register_property_raw (
- ANJUTA_PREFERENCES (prefs),
- chooser,
- PREFS_PROP_KERNEL,
- NULL,
- 0,
- ANJUTA_PROPERTY_OBJECT_TYPE_FILE,
- ANJUTA_PROPERTY_DATA_TYPE_TEXT);
-
- sp->kernel_chooser = chooser;
-
- /* Widgets for rootfs */
- hbox = gtk_hbox_new (FALSE, 6);
- gtk_box_pack_start (GTK_BOX (inner_vbox), hbox, TRUE, FALSE, 0);
-
- /* label */
- label = gtk_label_new ("Root filesystem: ");
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- gtk_size_group_add_widget (qemu_labels_group, label);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
-
- /* chooser */
- chooser = gtk_file_chooser_button_new (_("Select root filesystem file"),
- GTK_FILE_CHOOSER_ACTION_OPEN);
- gtk_box_pack_start (GTK_BOX (hbox), chooser, TRUE, TRUE, 0);
- gtk_size_group_add_widget (qemu_fields_group, chooser);
- sp->rootfs_chooser = chooser;
-
- anjuta_preferences_register_property_raw (
- ANJUTA_PREFERENCES (prefs),
- chooser,
- PREFS_PROP_ROOTFS,
- NULL,
- 0,
- ANJUTA_PROPERTY_OBJECT_TYPE_FILE,
- ANJUTA_PROPERTY_DATA_TYPE_TEXT);
-
- /* add page */
- gtk_widget_show_all (vbox);
-
+ page = beaver_settings_page_new (ANJUTA_PLUGIN (sp)->shell);
anjuta_preferences_dialog_add_page (ANJUTA_PREFERENCES_DIALOG (dialog),
_("Poky SDK"), _("Poky SDK"),
sp->prefs_icon,
- vbox);
-
- /*
- * This is a horrible hack around some kind of race condition that seems to
- * mean that the GtkFileChooserButton doesn't reflect the filename it is
- * given by the prefences code in Anjuta. Even if it just gets set here it
- * isn't guaranteed to work. This is the best option i've come up with.
- *
- * After 800ms fire a timeout that reads the values for the preferences and
- * then sets the widgets. It only needs to be done for those that are of
- * ANJUTA_PROPERTY_OBJECT_TYPE_FILE type.
- */
- g_timeout_add (800, preferences_timeout_cb, sp);
+ page);
}
static void
diff --git a/src/plugin.h b/src/plugin.h
index fd0d0b2..404a866 100644
--- a/src/plugin.h
+++ b/src/plugin.h
@@ -23,8 +23,7 @@
#include <libanjuta/interfaces/ianjuta-buildable.h>
#include <libanjuta/anjuta-launcher.h>
-#include "beaver-target.h"
-#include "beaver-target-qemu.h"
+#include "beaver.h"
typedef struct _AnjutaPluginSdk AnjutaPluginSdk;
typedef struct _AnjutaPluginSdkClass AnjutaPluginSdkClass;
@@ -54,12 +53,6 @@ struct _AnjutaPluginSdk
AnjutaPreferences *prefs;
- GtkWidget *sdk_root_chooser;
- GtkWidget *triplet_entry;
- GtkWidget *rootfs_chooser;
- GtkWidget *kernel_chooser;
- GtkWidget *poky_root_chooser;
-
GtkActionGroup *action_group;
guint sdk_root_notifyid;