[gnome-builder/wip/commands2] commands: add commandmanager to GbWorkbench.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/commands2] commands: add commandmanager to GbWorkbench.
- Date: Thu, 9 Oct 2014 23:47:37 +0000 (UTC)
commit fcb1a3ea52fcdebf15bcf59b3e363a6ae8b48b96
Author: Christian Hergert <christian hergert me>
Date: Thu Oct 9 16:47:27 2014 -0700
commands: add commandmanager to GbWorkbench.
src/commands/gb-command-manager.h | 14 ++++-----
src/gnome-builder.mk | 1 +
src/util/gb-widget.c | 22 +++++++++++++-
src/util/gb-widget.h | 1 +
src/workbench/gb-workbench.c | 57 +++++++++++++++++++++++++++++++++++++
src/workbench/gb-workbench.h | 1 +
6 files changed, 87 insertions(+), 9 deletions(-)
---
diff --git a/src/commands/gb-command-manager.h b/src/commands/gb-command-manager.h
index baf8136..6add7cd 100644
--- a/src/commands/gb-command-manager.h
+++ b/src/commands/gb-command-manager.h
@@ -50,14 +50,12 @@ struct _GbCommandManagerClass
GObjectClass parent;
};
-GType gb_command_manager_get_type (void) G_GNUC_CONST;
-GbCommandManager *gb_command_manager_new (void);
-GbCommandManager *gb_command_manager_get_default (void);
-GAction *gb_command_manager_lookup (GbCommandManager *manager,
- const gchar *command_text,
- GVariant **parameters);
-void gb_command_manager_add_provider (GbCommandManager *manager,
- GbCommandProvider *provider);
+GType gb_command_manager_get_type (void) G_GNUC_CONST;
+GAction *gb_command_manager_lookup (GbCommandManager *manager,
+ const gchar *command_text,
+ GVariant **parameters);
+void gb_command_manager_add_provider (GbCommandManager *manager,
+ GbCommandProvider *provider);
G_END_DECLS
diff --git a/src/gnome-builder.mk b/src/gnome-builder.mk
index 1b10dd1..1cffb66 100644
--- a/src/gnome-builder.mk
+++ b/src/gnome-builder.mk
@@ -152,6 +152,7 @@ libgnome_builder_la_CFLAGS = \
$(WEBKIT_CFLAGS) \
-I$(top_srcdir)/src/animation \
-I$(top_srcdir)/src/app \
+ -I$(top_srcdir)/src/commands \
-I$(top_srcdir)/src/devhelp \
-I$(top_srcdir)/src/editor \
-I$(top_srcdir)/src/gd \
diff --git a/src/util/gb-widget.c b/src/util/gb-widget.c
index 5d97390..2b61366 100644
--- a/src/util/gb-widget.c
+++ b/src/util/gb-widget.c
@@ -21,6 +21,27 @@
#include "gb-cairo.h"
#include "gb-rgba.h"
#include "gb-widget.h"
+#include "gb-workbench.h"
+
+/**
+ * gb_widget_get_workbench:
+ *
+ * Returns: (transfer none) (type GbWorkbench*): A #GbWorkbench or %NULL.
+ */
+gpointer
+gb_widget_get_workbench (GtkWidget *widget)
+{
+ GtkWidget *toplevel;
+
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+
+ toplevel = gtk_widget_get_toplevel (widget);
+
+ if (GB_IS_WORKBENCH (toplevel))
+ return GB_WORKBENCH (toplevel);
+
+ return NULL;
+}
void
gb_widget_add_style_class (gpointer widget,
@@ -119,7 +140,6 @@ gb_widget_snapshot (GtkWidget *widget,
gb_cairo_rounded_rectangle (cr, &rect, 1, 1);
-
gdk_rgba_parse (&rgba, "#729fcf");
gb_rgba_shade (&rgba, &rgba, 1.2);
gdk_cairo_set_source_rgba (cr, &rgba);
diff --git a/src/util/gb-widget.h b/src/util/gb-widget.h
index f5d845d..fabd945 100644
--- a/src/util/gb-widget.h
+++ b/src/util/gb-widget.h
@@ -31,6 +31,7 @@ cairo_surface_t *gb_widget_snapshot (GtkWidget *widget,
gint height,
gdouble alpha,
gboolean draw_border);
+gpointer gb_widget_get_workbench (GtkWidget *widget);
G_END_DECLS
diff --git a/src/workbench/gb-workbench.c b/src/workbench/gb-workbench.c
index 7fc06ec..46db7c0 100644
--- a/src/workbench/gb-workbench.c
+++ b/src/workbench/gb-workbench.c
@@ -20,6 +20,9 @@
#include <glib/gi18n.h>
+#include "gb-command-gaction-provider.h"
+#include "gb-command-manager.h"
+#include "gb-command-vim-provider.h"
#include "gb-devhelp-workspace.h"
#include "gb-editor-workspace.h"
#include "gb-log.h"
@@ -33,6 +36,7 @@
struct _GbWorkbenchPrivate
{
GbWorkbenchActions *actions;
+ GbCommandManager *command_manager;
GbNavigationList *navigation_list;
GbWorkspace *active_workspace;
@@ -51,6 +55,7 @@ struct _GbWorkbenchPrivate
enum {
PROP_0,
+ PROP_COMMAND_MANAGER,
PROP_NAVIGATION_LIST,
LAST_PROP
};
@@ -68,6 +73,21 @@ static GParamSpec *gParamSpecs [LAST_PROP];
static guint gSignals [LAST_SIGNAL];
/**
+ * gb_workbench_get_command_manager:
+ *
+ * Retrieves the command manager for the workspace.
+ *
+ * Returns: (transfer none) (type GbCommandManager*): A #GbCommandManager.
+ */
+gpointer
+gb_workbench_get_command_manager (GbWorkbench *workbench)
+{
+ g_return_val_if_fail (GB_IS_WORKBENCH (workbench), NULL);
+
+ return workbench->priv->command_manager;
+}
+
+/**
* gb_workbench_get_navigation_list:
*
* Fetches the navigation list for the workbench. This can be used to move
@@ -337,6 +357,7 @@ gb_workbench_dispose (GObject *object)
priv = GB_WORKBENCH (object)->priv;
g_clear_object (&priv->actions);
+ g_clear_object (&priv->command_manager);
g_clear_object (&priv->navigation_list);
G_OBJECT_CLASS (gb_workbench_parent_class)->dispose (object);
@@ -350,8 +371,18 @@ gb_workbench_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
+ GbWorkbench *self = (GbWorkbench *)object;
+
switch (prop_id)
{
+ case PROP_COMMAND_MANAGER:
+ g_value_set_object (value, gb_workbench_get_command_manager (self));
+ break;
+
+ case PROP_NAVIGATION_LIST:
+ g_value_set_object (value, gb_workbench_get_navigation_list (self));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -385,6 +416,16 @@ gb_workbench_class_init (GbWorkbenchClass *klass)
klass->workspace_changed = gb_workbench_workspace_changed;
+ gParamSpecs [PROP_COMMAND_MANAGER] =
+ g_param_spec_object ("command-manager",
+ _("Command Manager"),
+ _("The command manager for the workspace."),
+ GB_TYPE_COMMAND_MANAGER,
+ (G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class, PROP_COMMAND_MANAGER,
+ gParamSpecs [PROP_COMMAND_MANAGER]);
+
gParamSpecs [PROP_NAVIGATION_LIST] =
g_param_spec_object ("navigation-list",
_("Navigation List"),
@@ -439,10 +480,26 @@ gb_workbench_class_init (GbWorkbenchClass *klass)
static void
gb_workbench_init (GbWorkbench *workbench)
{
+ GbCommandProvider *provider;
+
workbench->priv = gb_workbench_get_instance_private (workbench);
gtk_widget_init_template (GTK_WIDGET (workbench));
+ workbench->priv->command_manager =
+ g_object_new (GB_TYPE_COMMAND_MANAGER,
+ NULL);
+
+ provider = g_object_new (GB_TYPE_COMMAND_GACTION_PROVIDER,
+ "workbench", workbench,
+ NULL);
+ gb_command_manager_add_provider (workbench->priv->command_manager, provider);
+
+ provider = g_object_new (GB_TYPE_COMMAND_VIM_PROVIDER,
+ "workbench", workbench,
+ NULL);
+ gb_command_manager_add_provider (workbench->priv->command_manager, provider);
+
workbench->priv->navigation_list = g_object_new (GB_TYPE_NAVIGATION_LIST,
"workbench", workbench,
NULL);
diff --git a/src/workbench/gb-workbench.h b/src/workbench/gb-workbench.h
index 2d58810..ad4682e 100644
--- a/src/workbench/gb-workbench.h
+++ b/src/workbench/gb-workbench.h
@@ -59,6 +59,7 @@ GbNavigationList *gb_workbench_get_navigation_list (GbWorkbench *workbench);
GbWorkspace *gb_workbench_get_active_workspace (GbWorkbench *workbench);
GbWorkspace *gb_workbench_get_workspace (GbWorkbench *workbench,
GType type);
+gpointer gb_workbench_get_command_manager (GbWorkbench *workbench);
GbWorkbench *gb_navigation_list_get_workbench (GbNavigationList *list);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]