[gnome-builder/wip/commands2: 4/12] commands: start on gaction command provider.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/commands2: 4/12] commands: start on gaction command provider.
- Date: Fri, 10 Oct 2014 01:05:05 +0000 (UTC)
commit 604ce9d05c72a834c84b9bc24d08795528b12bb2
Author: Christian Hergert <christian hergert me>
Date: Thu Oct 9 02:08:18 2014 -0700
commands: start on gaction command provider.
src/commands/gb-command-gaction-provider.c | 160 ++++++++++++++++++++++++++++
src/commands/gb-command-gaction-provider.h | 57 ++++++++++
src/gnome-builder.mk | 2 +
3 files changed, 219 insertions(+), 0 deletions(-)
---
diff --git a/src/commands/gb-command-gaction-provider.c b/src/commands/gb-command-gaction-provider.c
new file mode 100644
index 0000000..cf93b06
--- /dev/null
+++ b/src/commands/gb-command-gaction-provider.c
@@ -0,0 +1,160 @@
+/* gb-command-gaction-provider.c
+ *
+ * Copyright (C) 2014 Christian Hergert <christian hergert me>
+ *
+ * This program 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, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 "gb-command-gaction-provider.h"
+
+struct _GbCommandGactionProviderPrivate
+{
+ GbWorkbench *workbench;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GbCommandGactionProvider,
+ gb_command_gaction_provider,
+ GB_TYPE_COMMAND_PROVIDER)
+
+enum {
+ PROP_0,
+ PROP_WORKBENCH,
+ LAST_PROP
+};
+
+static GParamSpec *gParamSpecs [LAST_PROP];
+
+GbCommandProvider *
+gb_command_gaction_provider_new (GbWorkbench *workbench)
+{
+ return g_object_new (GB_TYPE_COMMAND_GACTION_PROVIDER,
+ "workbench", workbench,
+ NULL);
+}
+
+GbWorkbench *
+gb_command_gaction_provider_get_workbench (GbCommandGactionProvider *provider)
+{
+ g_return_val_if_fail (GB_IS_COMMAND_GACTION_PROVIDER (provider), NULL);
+
+ return provider->priv->workbench;
+}
+
+void
+gb_command_gaction_provider_set_workbench (GbCommandGactionProvider *provider,
+ GbWorkbench *workbench)
+{
+ GbCommandGactionProviderPrivate *priv;
+
+ g_return_if_fail (GB_IS_COMMAND_GACTION_PROVIDER (provider));
+ g_return_if_fail (!workbench || GB_IS_WORKBENCH (workbench));
+
+ priv = provider->priv;
+
+ if (workbench != priv->workbench)
+ {
+ if (priv->workbench)
+ {
+ g_object_remove_weak_pointer (G_OBJECT (priv->workbench),
+ (gpointer *)&priv->workbench);
+ priv->workbench = NULL;
+ }
+
+ if (workbench)
+ {
+ priv->workbench = workbench;
+ g_object_add_weak_pointer (G_OBJECT (workbench),
+ (gpointer *)&priv->workbench);
+ }
+
+ g_object_notify_by_pspec (G_OBJECT (provider),
+ gParamSpecs [PROP_WORKBENCH]);
+ }
+}
+
+static void
+gb_command_gaction_provider_dispose (GObject *object)
+{
+ GbCommandGactionProvider *provider = (GbCommandGactionProvider *)object;
+
+ gb_command_gaction_provider_set_workbench (provider, NULL);
+
+ G_OBJECT_CLASS (gb_command_gaction_provider_parent_class)->dispose (object);
+}
+
+static void
+gb_command_gaction_provider_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GbCommandGactionProvider *self = GB_COMMAND_GACTION_PROVIDER (object);
+
+ switch (prop_id)
+ {
+ case PROP_WORKBENCH:
+ g_value_set_object (value,
+ gb_command_gaction_provider_get_workbench (self));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gb_command_gaction_provider_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GbCommandGactionProvider *self = GB_COMMAND_GACTION_PROVIDER (object);
+
+ switch (prop_id)
+ {
+ case PROP_WORKBENCH:
+ gb_command_gaction_provider_set_workbench (self,
+ g_value_get_object (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gb_command_gaction_provider_class_init (GbCommandGactionProviderClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = gb_command_gaction_provider_dispose;
+ object_class->get_property = gb_command_gaction_provider_get_property;
+ object_class->set_property = gb_command_gaction_provider_set_property;
+
+ gParamSpecs [PROP_WORKBENCH] =
+ g_param_spec_object ("workbench",
+ _("Workbench"),
+ _("The workbench containing the actions."),
+ GB_TYPE_WORKBENCH,
+ (G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class, PROP_WORKBENCH,
+ gParamSpecs [PROP_WORKBENCH]);
+}
+
+static void
+gb_command_gaction_provider_init (GbCommandGactionProvider *self)
+{
+ self->priv = gb_command_gaction_provider_get_instance_private (self);
+}
diff --git a/src/commands/gb-command-gaction-provider.h b/src/commands/gb-command-gaction-provider.h
new file mode 100644
index 0000000..d7dc040
--- /dev/null
+++ b/src/commands/gb-command-gaction-provider.h
@@ -0,0 +1,57 @@
+/* gb-command-gaction-provider.h
+ *
+ * Copyright (C) 2014 Christian Hergert <christian hergert me>
+ *
+ * This program 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, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 GB_COMMAND_GACTION_PROVIDER_H
+#define GB_COMMAND_GACTION_PROVIDER_H
+
+#include "gb-command-provider.h"
+#include "gb-workbench.h"
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_COMMAND_GACTION_PROVIDER (gb_command_gaction_provider_get_type())
+#define GB_COMMAND_GACTION_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GB_TYPE_COMMAND_GACTION_PROVIDER, GbCommandGactionProvider))
+#define GB_COMMAND_GACTION_PROVIDER_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GB_TYPE_COMMAND_GACTION_PROVIDER, GbCommandGactionProvider const))
+#define GB_COMMAND_GACTION_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GB_TYPE_COMMAND_GACTION_PROVIDER, GbCommandGactionProviderClass))
+#define GB_IS_COMMAND_GACTION_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GB_TYPE_COMMAND_GACTION_PROVIDER))
+#define GB_IS_COMMAND_GACTION_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GB_TYPE_COMMAND_GACTION_PROVIDER))
+#define GB_COMMAND_GACTION_PROVIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GB_TYPE_COMMAND_GACTION_PROVIDER, GbCommandGactionProviderClass))
+
+typedef struct _GbCommandGactionProvider GbCommandGactionProvider;
+typedef struct _GbCommandGactionProviderClass GbCommandGactionProviderClass;
+typedef struct _GbCommandGactionProviderPrivate GbCommandGactionProviderPrivate;
+
+struct _GbCommandGactionProvider
+{
+ GbCommandProvider parent;
+
+ /*< private >*/
+ GbCommandGactionProviderPrivate *priv;
+};
+
+struct _GbCommandGactionProviderClass
+{
+ GbCommandProviderClass parent;
+};
+
+GType gb_command_gaction_provider_get_type (void) G_GNUC_CONST;
+GbCommandProvider *gb_command_gaction_provider_new (GbWorkbench *workbench);
+
+G_END_DECLS
+
+#endif /* GB_COMMAND_GACTION_PROVIDER_H */
diff --git a/src/gnome-builder.mk b/src/gnome-builder.mk
index c29366e..99dc855 100644
--- a/src/gnome-builder.mk
+++ b/src/gnome-builder.mk
@@ -9,6 +9,8 @@ libgnome_builder_la_SOURCES = \
src/animation/gb-frame-source.h \
src/app/gb-application.c \
src/app/gb-application.h \
+ src/commands/gb-command-gaction-provider.c \
+ src/commands/gb-command-gaction-provider.h \
src/commands/gb-command-manager.c \
src/commands/gb-command-manager.h \
src/commands/gb-command-provider.c \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]