[gnome-builder] prefs: inherit from DzlPreferencesView
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] prefs: inherit from DzlPreferencesView
- Date: Tue, 6 Jun 2017 09:51:41 +0000 (UTC)
commit a613e605c7119ab0ddf3704e4df8c0062d66af12
Author: Christian Hergert <chergert redhat com>
Date: Tue Jun 6 02:51:31 2017 -0700
prefs: inherit from DzlPreferencesView
libdazzle has DzlPreferencesView now which contains most of this class.
We can simplify things now by subclassing and just focusing on the
extension (plugin) hooks.
libide/preferences/ide-preferences-perspective.c | 851 +--------------------
libide/preferences/ide-preferences-perspective.h | 4 +-
libide/preferences/ide-preferences-perspective.ui | 75 --
libide/resources/libide.gresource.xml | 1 -
4 files changed, 11 insertions(+), 920 deletions(-)
---
diff --git a/libide/preferences/ide-preferences-perspective.c
b/libide/preferences/ide-preferences-perspective.c
index 488c913..7d62710 100644
--- a/libide/preferences/ide-preferences-perspective.c
+++ b/libide/preferences/ide-preferences-perspective.c
@@ -20,97 +20,30 @@
#include <glib/gi18n.h>
#include <libpeas/peas.h>
-#include <dazzle.h>
-#include "ide-macros.h"
-
-#include "search/ide-pattern-spec.h"
-#include "workbench/ide-perspective.h"
#include "preferences/ide-preferences-addin.h"
#include "preferences/ide-preferences-builtin.h"
#include "preferences/ide-preferences-perspective.h"
-#include "workbench/ide-workbench-header-bar.h"
+#include "workbench/ide-perspective.h"
struct _IdePreferencesPerspective
{
- GtkBin parent_instance;
-
- guint last_widget_id;
-
- GActionGroup *actions;
- PeasExtensionSet *extensions;
- GSequence *pages;
- GHashTable *widgets;
-
- GtkScrolledWindow *scroller;
- GtkStack *page_stack;
- GtkStackSwitcher *page_stack_sidebar;
- GtkSearchEntry *search_entry;
- GtkStack *subpage_stack;
+ DzlPreferencesView parent_instance;
+ PeasExtensionSet *extensions;
};
-static void dzl_preferences_iface_init (DzlPreferencesInterface *iface);
static void ide_perspective_iface_init (IdePerspectiveInterface *iface);
-G_DEFINE_TYPE_EXTENDED (IdePreferencesPerspective, ide_preferences_perspective, GTK_TYPE_BIN, 0,
- G_IMPLEMENT_INTERFACE (DZL_TYPE_PREFERENCES, dzl_preferences_iface_init)
+G_DEFINE_TYPE_EXTENDED (IdePreferencesPerspective, ide_preferences_perspective, DZL_TYPE_PREFERENCES_VIEW, 0,
G_IMPLEMENT_INTERFACE (IDE_TYPE_PERSPECTIVE, ide_perspective_iface_init))
static void
-ide_preferences_perspective_refilter_cb (GtkWidget *widget,
- gpointer user_data)
-{
- DzlPreferencesPage *page = (DzlPreferencesPage *)widget;
- DzlPatternSpec *spec = user_data;
-
- g_assert (DZL_IS_PREFERENCES_PAGE (page));
-
- dzl_preferences_page_refilter (page, spec);
-}
-
-static void
-ide_preferences_perspective_refilter (IdePreferencesPerspective *self,
- const gchar *search_text)
-{
- DzlPatternSpec *spec = NULL;
-
- g_assert (IDE_IS_PREFERENCES_PERSPECTIVE (self));
-
- if (!ide_str_empty0 (search_text))
- spec = dzl_pattern_spec_new (search_text);
-
- gtk_container_foreach (GTK_CONTAINER (self->page_stack),
- ide_preferences_perspective_refilter_cb,
- spec);
- gtk_container_foreach (GTK_CONTAINER (self->subpage_stack),
- ide_preferences_perspective_refilter_cb,
- spec);
-
- g_clear_pointer (&spec, dzl_pattern_spec_unref);
-}
-
-static gint
-sort_by_priority (gconstpointer a,
- gconstpointer b,
- gpointer user_data)
-{
- gint prioritya = 0;
- gint priorityb = 0;
-
- g_object_get ((gpointer)a, "priority", &prioritya, NULL);
- g_object_get ((gpointer)b, "priority", &priorityb, NULL);
-
- return prioritya - priorityb;
-}
-
-static void
ide_preferences_perspective_extension_added (PeasExtensionSet *set,
PeasPluginInfo *plugin_info,
PeasExtension *extension,
gpointer user_data)
{
IdePreferencesPerspective *self = user_data;
- const gchar *text;
g_assert (PEAS_IS_EXTENSION_SET (set));
g_assert (plugin_info != NULL);
@@ -118,9 +51,7 @@ ide_preferences_perspective_extension_added (PeasExtensionSet *set,
g_assert (IDE_IS_PREFERENCES_PERSPECTIVE (self));
ide_preferences_addin_load (IDE_PREFERENCES_ADDIN (extension), DZL_PREFERENCES (self));
-
- text = gtk_entry_get_text (GTK_ENTRY (self->search_entry));
- ide_preferences_perspective_refilter (self, text);
+ dzl_preferences_view_reapply_filter (DZL_PREFERENCES_VIEW (self));
}
static void
@@ -130,7 +61,6 @@ ide_preferences_perspective_extension_removed (PeasExtensionSet *set,
gpointer user_data)
{
IdePreferencesPerspective *self = user_data;
- const gchar *text;
g_assert (PEAS_IS_EXTENSION_SET (set));
g_assert (plugin_info != NULL);
@@ -138,64 +68,7 @@ ide_preferences_perspective_extension_removed (PeasExtensionSet *set,
g_assert (IDE_IS_PREFERENCES_PERSPECTIVE (self));
ide_preferences_addin_unload (IDE_PREFERENCES_ADDIN (extension), DZL_PREFERENCES (self));
-
- text = gtk_entry_get_text (GTK_ENTRY (self->search_entry));
- ide_preferences_perspective_refilter (self, text);
-}
-
-static void
-ide_preferences_perspective_notify_visible_child (IdePreferencesPerspective *self,
- GParamSpec *pspec,
- GtkStack *stack)
-{
-#if 0
- DzlPreferencesPage *page;
- GHashTableIter iter;
- gpointer value;
-
- g_assert (IDE_IS_PREFERENCES_PERSPECTIVE (self));
-
- /* Short circuit if we are destroying everything */
- if (gtk_widget_in_destruction (GTK_WIDGET (self)))
- return;
-
- gtk_widget_hide (GTK_WIDGET (self->subpage_stack));
-
- /*
- * If there are any selections in list groups, re-select it to cause
- * the subpage to potentially reappear.
- */
-
- if (NULL == (page = DZL_PREFERENCES_PAGE (gtk_stack_get_visible_child (stack))))
- return;
-
- g_hash_table_iter_init (&iter, page->groups_by_name);
-
- while (g_hash_table_iter_next (&iter, NULL, &value))
- {
- DzlPreferencesGroup *group = value;
- GtkSelectionMode mode = GTK_SELECTION_NONE;
-
- g_assert (DZL_IS_PREFERENCES_GROUP (group));
-
- if (!group->is_list)
- continue;
-
- g_object_get (group, "mode", &mode, NULL);
-
- if (mode == GTK_SELECTION_SINGLE)
- {
- GtkListBoxRow *selected;
-
- selected = gtk_list_box_get_selected_row (group->list_box);
-
- g_assert (!selected || GTK_IS_LIST_BOX_ROW (selected));
-
- if (selected != NULL && gtk_widget_activate (GTK_WIDGET (selected)))
- break;
- }
- }
-#endif
+ dzl_preferences_view_reapply_filter (DZL_PREFERENCES_VIEW (self));
}
static void
@@ -227,724 +100,16 @@ ide_preferences_perspective_constructed (GObject *object)
}
static void
-ide_preferences_perspective_finalize (GObject *object)
-{
- IdePreferencesPerspective *self = (IdePreferencesPerspective *)object;
-
- g_clear_pointer (&self->pages, g_sequence_free);
- g_clear_pointer (&self->widgets, g_hash_table_unref);
- g_clear_object (&self->actions);
-
- G_OBJECT_CLASS (ide_preferences_perspective_parent_class)->finalize (object);
-}
-
-static void
ide_preferences_perspective_class_init (IdePreferencesPerspectiveClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->constructed = ide_preferences_perspective_constructed;
- object_class->finalize = ide_preferences_perspective_finalize;
-
- gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/builder/ui/ide-preferences-perspective.ui");
- gtk_widget_class_set_css_name (widget_class, "preferences");
- gtk_widget_class_bind_template_child (widget_class, IdePreferencesPerspective, page_stack);
- gtk_widget_class_bind_template_child (widget_class, IdePreferencesPerspective, page_stack_sidebar);
- gtk_widget_class_bind_template_child (widget_class, IdePreferencesPerspective, scroller);
- gtk_widget_class_bind_template_child (widget_class, IdePreferencesPerspective, search_entry);
- gtk_widget_class_bind_template_child (widget_class, IdePreferencesPerspective, subpage_stack);
-}
-
-static void
-go_back_activate (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
-{
- IdePreferencesPerspective *self = user_data;
-
- g_assert (IDE_IS_PREFERENCES_PERSPECTIVE (self));
-
- gtk_widget_hide (GTK_WIDGET (self->subpage_stack));
-}
-
-static void
-ide_preferences_perspective_search_entry_changed (IdePreferencesPerspective *self,
- GtkSearchEntry *search_entry)
-{
- const gchar *text;
-
- g_assert (IDE_IS_PREFERENCES_PERSPECTIVE (self));
- g_assert (GTK_IS_SEARCH_ENTRY (search_entry));
-
- text = gtk_entry_get_text (GTK_ENTRY (search_entry));
- ide_preferences_perspective_refilter (self, text);
-}
-
-static void
-ide_preferences_perspective_notify_subpage_stack_visible (IdePreferencesPerspective *self,
- GParamSpec *pspec,
- GtkStack *subpage_stack)
-{
- g_assert (IDE_IS_PREFERENCES_PERSPECTIVE (self));
- g_assert (GTK_IS_STACK (subpage_stack));
-
- /*
- * Because the subpage stack can cause us to have a wider display than
- * the screen has, we need to allow scrolling. This can happen because
- * side-by-side we could be just a bit bigger than 1280px which is a
- * fairly common laptop screen size (especially under HiDPI).
- *
- * https://bugzilla.gnome.org/show_bug.cgi?id=772700
- */
-
- if (gtk_widget_get_visible (GTK_WIDGET (subpage_stack)))
- g_object_set (self->scroller, "hscrollbar-policy", GTK_POLICY_AUTOMATIC, NULL);
- else
- g_object_set (self->scroller, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
}
static void
ide_preferences_perspective_init (IdePreferencesPerspective *self)
{
- static const GActionEntry entries[] = {
- { "go-back", go_back_activate },
- };
-
- gtk_widget_init_template (GTK_WIDGET (self));
-
- g_signal_connect_object (self->search_entry,
- "changed",
- G_CALLBACK (ide_preferences_perspective_search_entry_changed),
- self,
- G_CONNECT_SWAPPED);
-
- g_signal_connect_object (self->page_stack,
- "notify::visible-child",
- G_CALLBACK (ide_preferences_perspective_notify_visible_child),
- self,
- G_CONNECT_SWAPPED);
-
- g_signal_connect_object (self->subpage_stack,
- "notify::visible",
- G_CALLBACK (ide_preferences_perspective_notify_subpage_stack_visible),
- self,
- G_CONNECT_SWAPPED);
-
- self->pages = g_sequence_new (NULL);
- self->widgets = g_hash_table_new (g_direct_hash, g_direct_equal);
-
- self->actions = G_ACTION_GROUP (g_simple_action_group_new ());
- g_action_map_add_action_entries (G_ACTION_MAP (self->actions),
- entries, G_N_ELEMENTS (entries), self);
-}
-
-static GtkWidget *
-ide_preferences_perspective_get_page (IdePreferencesPerspective *self,
- const gchar *page_name)
-{
- g_assert (IDE_IS_PREFERENCES_PERSPECTIVE (self));
- g_assert (page_name != NULL);
-
- if (strchr (page_name, '.') != NULL)
- return gtk_stack_get_child_by_name (self->subpage_stack, page_name);
- else
- return gtk_stack_get_child_by_name (self->page_stack, page_name);
-}
-
-static void
-ide_preferences_perspective_add_page (DzlPreferences *preferences,
- const gchar *page_name,
- const gchar *title,
- gint priority)
-{
- IdePreferencesPerspective *self = (IdePreferencesPerspective *)preferences;
- DzlPreferencesPage *page;
- GSequenceIter *iter;
- GtkStack *stack;
- gint position = -1;
-
- g_assert (DZL_IS_PREFERENCES (preferences));
- g_assert (IDE_IS_PREFERENCES_PERSPECTIVE (self));
- g_assert (page_name != NULL);
- g_assert (title != NULL || strchr (page_name, '.'));
-
- if (strchr (page_name, '.') != NULL)
- stack = self->subpage_stack;
- else
- stack = self->page_stack;
-
- if (gtk_stack_get_child_by_name (stack, page_name))
- return;
-
- page = g_object_new (DZL_TYPE_PREFERENCES_PAGE,
- "priority", priority,
- "visible", TRUE,
- NULL);
-
- if (stack == self->page_stack)
- {
- iter = g_sequence_insert_sorted (self->pages, page, sort_by_priority, NULL);
- position = g_sequence_iter_get_position (iter);
- }
-
- gtk_container_add_with_properties (GTK_CONTAINER (stack), GTK_WIDGET (page),
- "position", position,
- "name", page_name,
- "title", title,
- NULL);
-}
-
-static void
-ide_preferences_perspective_add_group (DzlPreferences *preferences,
- const gchar *page_name,
- const gchar *group_name,
- const gchar *title,
- gint priority)
-{
- IdePreferencesPerspective *self = (IdePreferencesPerspective *)preferences;
- DzlPreferencesGroup *group;
- GtkWidget *page;
-
- g_assert (IDE_IS_PREFERENCES_PERSPECTIVE (self));
- g_assert (page_name != NULL);
- g_assert (group_name != NULL);
-
- page = ide_preferences_perspective_get_page (self, page_name);
-
- if (page == NULL)
- {
- g_warning ("No page named \"%s\" could be found.", page_name);
- return;
- }
-
- group = g_object_new (DZL_TYPE_PREFERENCES_GROUP,
- "name", group_name,
- "priority", priority,
- "title", title,
- "visible", TRUE,
- NULL);
- dzl_preferences_page_add_group (DZL_PREFERENCES_PAGE (page), group);
-}
-
-static void
-ide_preferences_perspective_add_list_group (DzlPreferences *preferences,
- const gchar *page_name,
- const gchar *group_name,
- const gchar *title,
- GtkSelectionMode mode,
- gint priority)
-{
- IdePreferencesPerspective *self = (IdePreferencesPerspective *)preferences;
- DzlPreferencesGroup *group;
- GtkWidget *page;
-
- g_assert (IDE_IS_PREFERENCES_PERSPECTIVE (self));
- g_assert (page_name != NULL);
- g_assert (group_name != NULL);
-
- page = ide_preferences_perspective_get_page (self, page_name);
-
- if (page == NULL)
- {
- g_warning ("No page named \"%s\" could be found.", page_name);
- return;
- }
-
- group = g_object_new (DZL_TYPE_PREFERENCES_GROUP,
- "is-list", TRUE,
- "mode", mode,
- "name", group_name,
- "priority", priority,
- "title", title,
- "visible", TRUE,
- NULL);
- dzl_preferences_page_add_group (DZL_PREFERENCES_PAGE (page), group);
-}
-
-static guint
-ide_preferences_perspective_add_radio (DzlPreferences *preferences,
- const gchar *page_name,
- const gchar *group_name,
- const gchar *schema_id,
- const gchar *key,
- const gchar *path,
- const gchar *variant_string,
- const gchar *title,
- const gchar *subtitle,
- const gchar *keywords,
- gint priority)
-{
- IdePreferencesPerspective *self = (IdePreferencesPerspective *)preferences;
- DzlPreferencesSwitch *widget;
- DzlPreferencesGroup *group;
- g_autoptr(GVariant) variant = NULL;
- GtkWidget *page;
- guint widget_id;
-
- g_assert (IDE_IS_PREFERENCES_PERSPECTIVE (self));
- g_assert (page_name != NULL);
- g_assert (group_name != NULL);
- g_assert (schema_id != NULL);
- g_assert (key != NULL);
- g_assert (title != NULL);
-
- page = ide_preferences_perspective_get_page (self, page_name);
-
- if (page == NULL)
- {
- g_warning ("No page named \"%s\" could be found.", page_name);
- return 0;
- }
-
- group = dzl_preferences_page_get_group (DZL_PREFERENCES_PAGE (page), group_name);
-
- if (group == NULL)
- {
- g_warning ("No such preferences group \"%s\" in page \"%s\"",
- group_name, page_name);
- return 0;
- }
-
- if (variant_string != NULL)
- {
- g_autoptr(GError) error = NULL;
-
- variant = g_variant_parse (NULL, variant_string, NULL, NULL, &error);
-
- if (variant == NULL)
- g_warning ("%s", error->message);
- else
- g_variant_ref_sink (variant);
- }
-
- widget = g_object_new (DZL_TYPE_PREFERENCES_SWITCH,
- "is-radio", TRUE,
- "key", key,
- "keywords", keywords,
- "path", path,
- "priority", priority,
- "schema-id", schema_id,
- "subtitle", subtitle,
- "target", variant,
- "title", title,
- "visible", TRUE,
- NULL);
-
- dzl_preferences_group_add (group, GTK_WIDGET (widget));
-
- widget_id = ++self->last_widget_id;
- g_hash_table_insert (self->widgets, GINT_TO_POINTER (widget_id), widget);
-
- return widget_id;
-}
-
-static guint
-ide_preferences_perspective_add_switch (DzlPreferences *preferences,
- const gchar *page_name,
- const gchar *group_name,
- const gchar *schema_id,
- const gchar *key,
- const gchar *path,
- const gchar *variant_string,
- const gchar *title,
- const gchar *subtitle,
- const gchar *keywords,
- gint priority)
-{
- IdePreferencesPerspective *self = (IdePreferencesPerspective *)preferences;
- DzlPreferencesSwitch *widget;
- DzlPreferencesGroup *group;
- g_autoptr(GVariant) variant = NULL;
- GtkWidget *page;
- guint widget_id;
-
- g_assert (IDE_IS_PREFERENCES_PERSPECTIVE (self));
- g_assert (page_name != NULL);
- g_assert (group_name != NULL);
- g_assert (schema_id != NULL);
- g_assert (key != NULL);
- g_assert (title != NULL);
-
- page = ide_preferences_perspective_get_page (self, page_name);
-
- if (page == NULL)
- {
- g_warning ("No page named \"%s\" could be found.", page_name);
- return 0;
- }
-
- group = dzl_preferences_page_get_group (DZL_PREFERENCES_PAGE (page), group_name);
-
- if (group == NULL)
- {
- g_warning ("No such preferences group \"%s\" in page \"%s\"",
- group_name, page_name);
- return 0;
- }
-
- if (variant_string != NULL)
- {
- g_autoptr(GError) error = NULL;
-
- variant = g_variant_parse (NULL, variant_string, NULL, NULL, &error);
-
- if (variant == NULL)
- g_warning ("%s", error->message);
- else
- g_variant_ref_sink (variant);
- }
-
- widget = g_object_new (DZL_TYPE_PREFERENCES_SWITCH,
- "key", key,
- "keywords", keywords,
- "path", path,
- "priority", priority,
- "schema-id", schema_id,
- "subtitle", subtitle,
- "target", variant,
- "title", title,
- "visible", TRUE,
- NULL);
-
- dzl_preferences_group_add (group, GTK_WIDGET (widget));
-
- widget_id = ++self->last_widget_id;
- g_hash_table_insert (self->widgets, GINT_TO_POINTER (widget_id), widget);
-
- return widget_id;
-}
-
-static guint
-ide_preferences_perspective_add_spin_button (DzlPreferences *preferences,
- const gchar *page_name,
- const gchar *group_name,
- const gchar *schema_id,
- const gchar *key,
- const gchar *path,
- const gchar *title,
- const gchar *subtitle,
- const gchar *keywords,
- gint priority)
-{
- IdePreferencesPerspective *self = (IdePreferencesPerspective *)preferences;
- DzlPreferencesSpinButton *widget;
- DzlPreferencesGroup *group;
- GtkWidget *page;
- guint widget_id;
-
- g_assert (IDE_IS_PREFERENCES_PERSPECTIVE (self));
- g_assert (page_name != NULL);
- g_assert (group_name != NULL);
- g_assert (schema_id != NULL);
- g_assert (key != NULL);
- g_assert (title != NULL);
-
- page = ide_preferences_perspective_get_page (self, page_name);
-
- if (page == NULL)
- {
- g_warning ("No page named \"%s\" could be found.", page_name);
- return 0;
- }
-
- group = dzl_preferences_page_get_group (DZL_PREFERENCES_PAGE (page), group_name);
-
-
- if (group == NULL)
- {
- g_warning ("No such preferences group \"%s\" in page \"%s\"",
- group_name, page_name);
- return 0;
- }
-
- widget = g_object_new (DZL_TYPE_PREFERENCES_SPIN_BUTTON,
- "key", key,
- "keywords", keywords,
- "path", path,
- "priority", priority,
- "schema-id", schema_id,
- "subtitle", subtitle,
- "title", title,
- "visible", TRUE,
- NULL);
-
- dzl_preferences_group_add (group, GTK_WIDGET (widget));
-
- widget_id = ++self->last_widget_id;
- g_hash_table_insert (self->widgets, GINT_TO_POINTER (widget_id), widget);
-
- return widget_id;
-}
-
-static guint
-ide_preferences_perspective_add_font_button (DzlPreferences *preferences,
- const gchar *page_name,
- const gchar *group_name,
- const gchar *schema_id,
- const gchar *key,
- const gchar *title,
- const gchar *keywords,
- gint priority)
-{
- IdePreferencesPerspective *self = (IdePreferencesPerspective *)preferences;
- DzlPreferencesSwitch *widget;
- DzlPreferencesGroup *group;
- GtkWidget *page;
- guint widget_id;
-
- g_assert (IDE_IS_PREFERENCES_PERSPECTIVE (self));
- g_assert (page_name != NULL);
- g_assert (group_name != NULL);
- g_assert (schema_id != NULL);
- g_assert (key != NULL);
- g_assert (title != NULL);
-
- page = ide_preferences_perspective_get_page (self, page_name);
-
- if (page == NULL)
- {
- g_warning ("No page named \"%s\" could be found.", page_name);
- return 0;
- }
-
- group = dzl_preferences_page_get_group (DZL_PREFERENCES_PAGE (page), group_name);
-
- if (group == NULL)
- {
- g_warning ("No such preferences group \"%s\" in page \"%s\"",
- group_name, page_name);
- return 0;
- }
-
- widget = g_object_new (DZL_TYPE_PREFERENCES_FONT_BUTTON,
- "key", key,
- "keywords", keywords,
- "priority", priority,
- "schema-id", schema_id,
- "title", title,
- "visible", TRUE,
- NULL);
-
- dzl_preferences_group_add (group, GTK_WIDGET (widget));
-
- widget_id = ++self->last_widget_id;
- g_hash_table_insert (self->widgets, GINT_TO_POINTER (widget_id), widget);
-
- return widget_id;
-}
-
-static guint
-ide_preferences_perspective_add_file_chooser (DzlPreferences *preferences,
- const gchar *page_name,
- const gchar *group_name,
- const gchar *schema_id,
- const gchar *key,
- const gchar *path,
- const gchar *title,
- const gchar *subtitle,
- GtkFileChooserAction action,
- const gchar *keywords,
- gint priority)
-{
- IdePreferencesPerspective *self = (IdePreferencesPerspective *)preferences;
- DzlPreferencesFileChooserButton *widget;
- DzlPreferencesGroup *group;
- GtkWidget *page;
- guint widget_id;
-
- g_assert (IDE_IS_PREFERENCES_PERSPECTIVE (self));
- g_assert (page_name != NULL);
- g_assert (group_name != NULL);
- g_assert (schema_id != NULL);
- g_assert (key != NULL);
- g_assert (title != NULL);
-
- page = ide_preferences_perspective_get_page (self, page_name);
-
- if (page == NULL)
- {
- g_warning ("No page named \"%s\" could be found.", page_name);
- return 0;
- }
-
- group = dzl_preferences_page_get_group (DZL_PREFERENCES_PAGE (page), group_name);
-
- if (group == NULL)
- {
- g_warning ("No such preferences group \"%s\" in page \"%s\"",
- group_name, page_name);
- return 0;
- }
-
- widget = g_object_new (DZL_TYPE_PREFERENCES_FILE_CHOOSER_BUTTON,
- "action", action,
- "key", key,
- "priority", priority,
- "schema-id", schema_id,
- "path", path,
- "subtitle", subtitle,
- "title", title,
- "keywords", keywords,
- "visible", TRUE,
- NULL);
-
- dzl_preferences_group_add (group, GTK_WIDGET (widget));
-
- widget_id = ++self->last_widget_id;
- g_hash_table_insert (self->widgets, GINT_TO_POINTER (widget_id), widget);
-
- return widget_id;
-}
-
-static guint
-ide_preferences_perspective_add_custom (DzlPreferences *preferences,
- const gchar *page_name,
- const gchar *group_name,
- GtkWidget *widget,
- const gchar *keywords,
- gint priority)
-{
- IdePreferencesPerspective *self = (IdePreferencesPerspective *)preferences;
- DzlPreferencesBin *container;
- DzlPreferencesGroup *group;
- GtkWidget *page;
- guint widget_id;
-
- g_assert (IDE_IS_PREFERENCES_PERSPECTIVE (self));
- g_assert (page_name != NULL);
- g_assert (group_name != NULL);
- g_assert (GTK_IS_WIDGET (widget));
-
- page = ide_preferences_perspective_get_page (self, page_name);
-
- if (page == NULL)
- {
- g_warning ("No page named \"%s\" could be found.", page_name);
- return 0;
- }
-
- group = dzl_preferences_page_get_group (DZL_PREFERENCES_PAGE (page), group_name);
-
- if (group == NULL)
- {
- g_warning ("No such preferences group \"%s\" in page \"%s\"",
- group_name, page_name);
- return 0;
- }
-
- widget_id = ++self->last_widget_id;
-
- gtk_widget_show (widget);
- gtk_widget_show (GTK_WIDGET (group));
-
- if (DZL_IS_PREFERENCES_BIN (widget))
- container = DZL_PREFERENCES_BIN (widget);
- else
- container = g_object_new (DZL_TYPE_PREFERENCES_BIN,
- "child", widget,
- "keywords", keywords,
- "priority", priority,
- "visible", TRUE,
- NULL);
-
- dzl_preferences_group_add (group, GTK_WIDGET (container));
-
- g_hash_table_insert (self->widgets, GINT_TO_POINTER (widget_id), widget);
-
- return widget_id;
-}
-
-static gboolean
-ide_preferences_perspective_remove_id (DzlPreferences *preferences,
- guint widget_id)
-{
- IdePreferencesPerspective *self = (IdePreferencesPerspective *)preferences;
- GtkWidget *widget;
-
- g_assert (IDE_IS_PREFERENCES_PERSPECTIVE (self));
- g_assert (widget_id);
-
- widget = g_hash_table_lookup (self->widgets, GINT_TO_POINTER (widget_id));
- if (widget != NULL)
- {
- if (g_hash_table_remove (self->widgets, GINT_TO_POINTER (widget_id)))
- {
- GtkWidget *parent = gtk_widget_get_ancestor (widget, GTK_TYPE_LIST_BOX_ROW);
-
- /* in case we added our own row ancestor, destroy it */
- if (parent != NULL)
- gtk_widget_destroy (parent);
- else
- gtk_widget_destroy (widget);
-
- return TRUE;
- }
- }
-
- g_warning ("No Preferences widget with number %i could be found and thus removed.", widget_id);
-
- return FALSE;
-}
-
-static void
-ide_preferences_perspective_set_page (DzlPreferences *preferences,
- const gchar *page_name,
- GHashTable *map)
-{
- IdePreferencesPerspective *self = (IdePreferencesPerspective *)preferences;
- GtkWidget *page;
-
- g_assert (IDE_IS_PREFERENCES_PERSPECTIVE (self));
- g_assert (page_name != NULL);
-
- page = ide_preferences_perspective_get_page (self, page_name);
-
- if (page == NULL)
- {
- g_warning ("No such page \"%s\"", page_name);
- return;
- }
-
- if (strchr (page_name, '.') != NULL)
- {
- dzl_preferences_page_set_map (DZL_PREFERENCES_PAGE (page), map);
- gtk_stack_set_visible_child (self->subpage_stack, page);
- gtk_widget_show (GTK_WIDGET (self->subpage_stack));
- }
- else
- {
- gtk_stack_set_visible_child (self->page_stack, page);
- gtk_widget_hide (GTK_WIDGET (self->subpage_stack));
- }
-}
-
-static GtkWidget *
-ide_preferences_perspective_get_widget (DzlPreferences *preferences,
- guint widget_id)
-{
- IdePreferencesPerspective *self = (IdePreferencesPerspective *)preferences;
-
- g_assert (IDE_IS_PREFERENCES_PERSPECTIVE (self));
-
- return g_hash_table_lookup (self->widgets, GINT_TO_POINTER (widget_id));
-}
-
-static void
-dzl_preferences_iface_init (DzlPreferencesInterface *iface)
-{
- iface->add_page = ide_preferences_perspective_add_page;
- iface->add_group = ide_preferences_perspective_add_group;
- iface->add_list_group = ide_preferences_perspective_add_list_group;
- iface->add_radio = ide_preferences_perspective_add_radio;
- iface->add_font_button = ide_preferences_perspective_add_font_button;
- iface->add_switch = ide_preferences_perspective_add_switch;
- iface->add_spin_button = ide_preferences_perspective_add_spin_button;
- iface->add_file_chooser = ide_preferences_perspective_add_file_chooser;
- iface->add_custom = ide_preferences_perspective_add_custom;
- iface->set_page = ide_preferences_perspective_set_page;
- iface->remove_id = ide_preferences_perspective_remove_id;
- iface->get_widget = ide_preferences_perspective_get_widget;
}
static gchar *
@@ -972,7 +137,9 @@ ide_preferences_perspective_get_actions (IdePerspective *perspective)
g_assert (IDE_IS_PREFERENCES_PERSPECTIVE (self));
- return g_object_ref (self->actions);
+ /* TODO: Get the action group for the back button */
+
+ return NULL;
}
static gint
diff --git a/libide/preferences/ide-preferences-perspective.h
b/libide/preferences/ide-preferences-perspective.h
index c91e013..17ce0ea 100644
--- a/libide/preferences/ide-preferences-perspective.h
+++ b/libide/preferences/ide-preferences-perspective.h
@@ -19,14 +19,14 @@
#ifndef IDE_PREFERENCES_PERSPECTIVE_H
#define IDE_PREFERENCES_PERSPECTIVE_H
-#include <gtk/gtk.h>
+#include <dazzle.h>
G_BEGIN_DECLS
#define IDE_TYPE_PREFERENCES_PERSPECTIVE (ide_preferences_perspective_get_type())
#define IDE_PREFERENCES_PERSPECTIVE_PRIORITY 1000000
-G_DECLARE_FINAL_TYPE (IdePreferencesPerspective, ide_preferences_perspective, IDE, PREFERENCES_PERSPECTIVE,
GtkBin)
+G_DECLARE_FINAL_TYPE (IdePreferencesPerspective, ide_preferences_perspective, IDE, PREFERENCES_PERSPECTIVE,
DzlPreferencesView)
G_END_DECLS
diff --git a/libide/resources/libide.gresource.xml b/libide/resources/libide.gresource.xml
index 8cb55fb..2615924 100644
--- a/libide/resources/libide.gresource.xml
+++ b/libide/resources/libide.gresource.xml
@@ -69,7 +69,6 @@
<file compressed="true" alias="ide-omni-search-row.ui">../search/ide-omni-search-row.ui</file>
<file compressed="true"
alias="ide-perspective-menu-button.ui">../workbench/ide-perspective-menu-button.ui</file>
<file compressed="true"
alias="ide-preferences-language-row.ui">../preferences/ide-preferences-language-row.ui</file>
- <file compressed="true"
alias="ide-preferences-perspective.ui">../preferences/ide-preferences-perspective.ui</file>
<file compressed="true" alias="ide-run-button.ui">../runner/ide-run-button.ui</file>
<file compressed="true" alias="ide-transfer-row.ui">../transfers/ide-transfer-row.ui</file>
<file compressed="true" alias="ide-transfers-button.ui">../transfers/ide-transfers-button.ui</file>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]