[gnome-builder] drawer: stub out drawer code for workbench sidebar
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] drawer: stub out drawer code for workbench sidebar
- Date: Mon, 10 Nov 2014 10:57:31 +0000 (UTC)
commit cbc64b9a33730cc1d6dd7031d4310df1a598a77c
Author: Christian Hergert <christian hergert me>
Date: Mon Nov 10 02:57:25 2014 -0800
drawer: stub out drawer code for workbench sidebar
src/drawer/gb-drawer.c | 147 ++++++++++++++++++++++++++++++++++++++
src/drawer/gb-drawer.h | 59 +++++++++++++++
src/gnome-builder.mk | 3 +
src/resources/ui/gb-workbench.ui | 76 +++++++++++--------
src/workbench/gb-workbench.c | 2 +
5 files changed, 255 insertions(+), 32 deletions(-)
---
diff --git a/src/drawer/gb-drawer.c b/src/drawer/gb-drawer.c
new file mode 100644
index 0000000..83632f1
--- /dev/null
+++ b/src/drawer/gb-drawer.c
@@ -0,0 +1,147 @@
+/* gb-drawer.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 <glib/gi18n.h>
+
+#include "gb-drawer.h"
+
+struct _GbDrawerPrivate
+{
+ GtkStackSwitcher *switcher;
+ GtkStack *stack;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GbDrawer, gb_drawer, GTK_TYPE_BIN)
+
+enum {
+ PROP_0,
+ PROP_CURRENT_PAGE,
+ LAST_PROP
+};
+
+static GParamSpec *gParamSpecs [LAST_PROP];
+
+GtkWidget *
+gb_drawer_new (void)
+{
+ return g_object_new (GB_TYPE_DRAWER, NULL);
+}
+
+GtkWidget *
+gb_drawer_get_current_page (GbDrawer *drawer)
+{
+ g_return_val_if_fail (GB_IS_DRAWER (drawer), NULL);
+
+ return gtk_stack_get_visible_child (drawer->priv->stack);
+}
+
+void
+gb_drawer_set_current_page (GbDrawer *drawer,
+ GtkWidget *widget)
+{
+ g_return_if_fail (GB_IS_DRAWER (drawer));
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ gtk_stack_set_visible_child (drawer->priv->stack, widget);
+
+ g_object_notify_by_pspec (G_OBJECT (drawer),
+ gParamSpecs [PROP_CURRENT_PAGE]);
+}
+
+static void
+gb_drawer_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GbDrawer *self = GB_DRAWER (object);
+
+ switch (prop_id)
+ {
+ case PROP_CURRENT_PAGE:
+ g_value_set_object (value, gb_drawer_get_current_page (self));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gb_drawer_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GbDrawer *self = GB_DRAWER (object);
+
+ switch (prop_id)
+ {
+ case PROP_CURRENT_PAGE:
+ gb_drawer_set_current_page (self, g_value_get_object (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gb_drawer_class_init (GbDrawerClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->get_property = gb_drawer_get_property;
+ object_class->set_property = gb_drawer_set_property;
+
+ gParamSpecs [PROP_CURRENT_PAGE] =
+ g_param_spec_object ("current-page",
+ _("Current Page"),
+ _("The current page of the drawer."),
+ GTK_TYPE_WIDGET,
+ (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class, PROP_CURRENT_PAGE,
+ gParamSpecs [PROP_CURRENT_PAGE]);
+}
+
+static void
+gb_drawer_init (GbDrawer *self)
+{
+ GtkBox *box;
+
+ self->priv = gb_drawer_get_instance_private (self);
+
+ box = g_object_new (GTK_TYPE_BOX,
+ "orientation", GTK_ORIENTATION_VERTICAL,
+ "spacing", 0,
+ "visible", TRUE,
+ NULL);
+ gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (box));
+
+ self->priv->switcher = g_object_new (GTK_TYPE_STACK_SWITCHER,
+ "vexpand", FALSE,
+ "visible", TRUE,
+ NULL);
+ gtk_container_add (GTK_CONTAINER (box), GTK_WIDGET (self->priv->switcher));
+
+ self->priv->stack = g_object_new (GTK_TYPE_STACK,
+ "vexpand", TRUE,
+ "visible", TRUE,
+ NULL);
+ gtk_container_add (GTK_CONTAINER (box), GTK_WIDGET (self->priv->stack));
+}
diff --git a/src/drawer/gb-drawer.h b/src/drawer/gb-drawer.h
new file mode 100644
index 0000000..b09152a
--- /dev/null
+++ b/src/drawer/gb-drawer.h
@@ -0,0 +1,59 @@
+/* gb-drawer.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_DRAWER_H
+#define GB_DRAWER_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_DRAWER (gb_drawer_get_type())
+#define GB_DRAWER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GB_TYPE_DRAWER, GbDrawer))
+#define GB_DRAWER_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GB_TYPE_DRAWER, GbDrawer const))
+#define GB_DRAWER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GB_TYPE_DRAWER, GbDrawerClass))
+#define GB_IS_DRAWER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GB_TYPE_DRAWER))
+#define GB_IS_DRAWER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GB_TYPE_DRAWER))
+#define GB_DRAWER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GB_TYPE_DRAWER, GbDrawerClass))
+
+typedef struct _GbDrawer GbDrawer;
+typedef struct _GbDrawerClass GbDrawerClass;
+typedef struct _GbDrawerPrivate GbDrawerPrivate;
+
+struct _GbDrawer
+{
+ GtkBin parent;
+
+ /*< private >*/
+ GbDrawerPrivate *priv;
+};
+
+struct _GbDrawerClass
+{
+ GtkBinClass parent;
+};
+
+GType gb_drawer_get_type (void);
+GtkWidget *gb_drawer_new (void);
+GtkWidget *gb_drawer_get_current_page (GbDrawer *drawer);
+void gb_drawer_set_current_page (GbDrawer *drawer,
+ GtkWidget *widget);
+
+G_END_DECLS
+
+#endif /* GB_DRAWER_H */
diff --git a/src/gnome-builder.mk b/src/gnome-builder.mk
index eb2b730..8e4c756 100644
--- a/src/gnome-builder.mk
+++ b/src/gnome-builder.mk
@@ -41,6 +41,8 @@ libgnome_builder_la_SOURCES = \
src/devhelp/gb-devhelp-tab.h \
src/devhelp/gb-devhelp-workspace.c \
src/devhelp/gb-devhelp-workspace.h \
+ src/drawer/gb-drawer.c \
+ src/drawer/gb-drawer.h \
src/editor/c-parse-helper.c \
src/editor/c-parse-helper.h \
src/editor/gb-editor-code-assistant.c \
@@ -189,6 +191,7 @@ libgnome_builder_la_CFLAGS = \
-I$(top_srcdir)/src/auto-indent \
-I$(top_srcdir)/src/commands \
-I$(top_srcdir)/src/devhelp \
+ -I$(top_srcdir)/src/drawer \
-I$(top_srcdir)/src/editor \
-I$(top_srcdir)/src/gca \
-I$(top_srcdir)/src/gd \
diff --git a/src/resources/ui/gb-workbench.ui b/src/resources/ui/gb-workbench.ui
index c6e3a1c..a2491c7 100644
--- a/src/resources/ui/gb-workbench.ui
+++ b/src/resources/ui/gb-workbench.ui
@@ -137,52 +137,64 @@
</object>
</child>
<child>
- <object class="GtkBox" id="main_hbox">
+ <object class="GtkPaned" id="main_paned">
<property name="orientation">horizontal</property>
<property name="visible">True</property>
+ <property name="position">250</property>
<child>
- <object class="GtkStackSwitcher" id="switcher">
+ <object class="GbDrawer" id="drawer">
<property name="visible">False</property>
- <property name="stack">stack</property>
- <property name="orientation">vertical</property>
- <property name="border_width">4</property>
- <property name="spacing">4</property>
- <style>
- <class name="gb-workspace-switcher"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkSeparator" id="sidebar_separator">
- <property name="visible">False</property>
- <property name="orientation">vertical</property>
</object>
</child>
<child>
- <object class="GtkStack" id="stack">
+ <object class="GtkBox" id="main_hbox">
+ <property name="orientation">horizontal</property>
<property name="visible">True</property>
- <property name="transition_type">GTK_STACK_TRANSITION_TYPE_SLIDE_UP_DOWN</property>
<child>
- <object class="GbEditorWorkspace" id="editor">
- <property name="name">editor</property>
- <property name="visible">True</property>
+ <object class="GtkStackSwitcher" id="switcher">
+ <property name="visible">False</property>
+ <property name="stack">stack</property>
+ <property name="orientation">vertical</property>
+ <property name="border_width">4</property>
+ <property name="spacing">4</property>
+ <style>
+ <class name="gb-workspace-switcher"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSeparator" id="sidebar_separator">
+ <property name="visible">False</property>
+ <property name="orientation">vertical</property>
</object>
- <packing>
- <property name="icon_name">text-editor-symbolic</property>
- <property name="name">editor</property>
- <property name="title" translatable="yes">Editor</property>
- </packing>
</child>
<child>
- <object class="GbDevhelpWorkspace" id="devhelp">
- <property name="name">devhelp</property>
+ <object class="GtkStack" id="stack">
<property name="visible">True</property>
+ <property name="transition_type">GTK_STACK_TRANSITION_TYPE_SLIDE_UP_DOWN</property>
+ <child>
+ <object class="GbEditorWorkspace" id="editor">
+ <property name="name">editor</property>
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="icon_name">text-editor-symbolic</property>
+ <property name="name">editor</property>
+ <property name="title" translatable="yes">Editor</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GbDevhelpWorkspace" id="devhelp">
+ <property name="name">devhelp</property>
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="name">devhelp</property>
+ <property name="icon_name">help-browser-symbolic</property>
+ <property name="title" translatable="yes">Documentation</property>
+ </packing>
+ </child>
</object>
- <packing>
- <property name="name">devhelp</property>
- <property name="icon_name">help-browser-symbolic</property>
- <property name="title" translatable="yes">Documentation</property>
- </packing>
</child>
</object>
</child>
diff --git a/src/workbench/gb-workbench.c b/src/workbench/gb-workbench.c
index adccc99..8ee00b6 100644
--- a/src/workbench/gb-workbench.c
+++ b/src/workbench/gb-workbench.c
@@ -25,6 +25,7 @@
#include "gb-command-manager.h"
#include "gb-command-vim-provider.h"
#include "gb-devhelp-workspace.h"
+#include "gb-drawer.h"
#include "gb-editor-workspace.h"
#include "gb-log.h"
#include "gb-widget.h"
@@ -542,6 +543,7 @@ gb_workbench_class_init (GbWorkbenchClass *klass)
g_type_ensure (GB_TYPE_COMMAND_BAR);
g_type_ensure (GB_TYPE_DEVHELP_WORKSPACE);
+ g_type_ensure (GB_TYPE_DRAWER);
g_type_ensure (GB_TYPE_EDITOR_WORKSPACE);
g_type_ensure (GEDIT_TYPE_MENU_STACK_SWITCHER);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]