[gnome-builder] navigation: place devhelp navigation items into global navigation list.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] navigation: place devhelp navigation items into global navigation list.
- Date: Thu, 25 Sep 2014 02:49:23 +0000 (UTC)
commit a8072cd9c327bb353634e2526598908fc933cbb3
Author: Christian Hergert <christian hergert me>
Date: Wed Sep 24 19:48:57 2014 -0700
navigation: place devhelp navigation items into global navigation list.
src/devhelp/gb-devhelp-navigation-item.c | 158 ++++++++++++++++++++++++++++++
src/devhelp/gb-devhelp-navigation-item.h | 55 ++++++++++
src/devhelp/gb-devhelp-workspace.c | 40 ++++++++
src/devhelp/gb-devhelp-workspace.h | 2 +
src/gnome-builder.mk | 6 +-
5 files changed, 259 insertions(+), 2 deletions(-)
---
diff --git a/src/devhelp/gb-devhelp-navigation-item.c b/src/devhelp/gb-devhelp-navigation-item.c
new file mode 100644
index 0000000..54bf0b2
--- /dev/null
+++ b/src/devhelp/gb-devhelp-navigation-item.c
@@ -0,0 +1,158 @@
+/* gb-devhelp-navigation-item.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/>.
+ */
+
+#define G_LOG_DOMAIN "devhelp-navigation"
+
+#include <glib/gi18n.h>
+
+#include "gb-devhelp-navigation-item.h"
+#include "gb-devhelp-workspace.h"
+#include "gb-log.h"
+
+struct _GbDevhelpNavigationItemPrivate
+{
+ gchar *uri;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GbDevhelpNavigationItem,
+ gb_devhelp_navigation_item,
+ GB_TYPE_NAVIGATION_ITEM)
+
+enum {
+ PROP_0,
+ PROP_URI,
+ LAST_PROP
+};
+
+static GParamSpec *gParamSpecs [LAST_PROP];
+
+const gchar *
+gb_devhelp_navigation_item_get_uri (GbDevhelpNavigationItem *item)
+{
+ g_return_val_if_fail (GB_IS_DEVHELP_NAVIGATION_ITEM (item), NULL);
+
+ return item->priv->uri;
+}
+
+static void
+gb_devhelp_navigation_item_activate (GbNavigationItem *item)
+{
+ GbDevhelpNavigationItem *nav = (GbDevhelpNavigationItem *)item;
+ GbWorkspace *workspace;
+
+ ENTRY;
+
+ g_return_if_fail (GB_IS_DEVHELP_NAVIGATION_ITEM (nav));
+
+ workspace = gb_navigation_item_get_workspace (item);
+
+ if (GB_IS_DEVHELP_WORKSPACE (workspace))
+ gb_devhelp_workspace_open_uri (GB_DEVHELP_WORKSPACE (workspace),
+ nav->priv->uri);
+
+ EXIT;
+}
+
+void
+gb_devhelp_navigation_item_set_uri (GbDevhelpNavigationItem *item,
+ const gchar *uri)
+{
+ g_return_if_fail (GB_IS_DEVHELP_NAVIGATION_ITEM (item));
+
+ g_free (item->priv->uri);
+ item->priv->uri = g_strdup (uri);
+ g_object_notify_by_pspec (G_OBJECT (item), gParamSpecs [PROP_URI]);
+}
+
+static void
+gb_devhelp_navigation_item_finalize (GObject *object)
+{
+ GbDevhelpNavigationItemPrivate *priv = GB_DEVHELP_NAVIGATION_ITEM (object)->priv;
+
+ g_clear_pointer (&priv->uri, g_free);
+
+ G_OBJECT_CLASS (gb_devhelp_navigation_item_parent_class)->finalize (object);
+}
+
+static void
+gb_devhelp_navigation_item_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GbDevhelpNavigationItem *self = GB_DEVHELP_NAVIGATION_ITEM (object);
+
+ switch (prop_id)
+ {
+ case PROP_URI:
+ g_value_set_string (value, gb_devhelp_navigation_item_get_uri (self));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gb_devhelp_navigation_item_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GbDevhelpNavigationItem *self = GB_DEVHELP_NAVIGATION_ITEM (object);
+
+ switch (prop_id)
+ {
+ case PROP_URI:
+ gb_devhelp_navigation_item_set_uri (self, g_value_get_string (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gb_devhelp_navigation_item_class_init (GbDevhelpNavigationItemClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GbNavigationItemClass *item_class = GB_NAVIGATION_ITEM_CLASS (klass);
+
+ object_class->finalize = gb_devhelp_navigation_item_finalize;
+ object_class->get_property = gb_devhelp_navigation_item_get_property;
+ object_class->set_property = gb_devhelp_navigation_item_set_property;
+
+ item_class->activate = gb_devhelp_navigation_item_activate;
+
+ gParamSpecs [PROP_URI] =
+ g_param_spec_string ("uri",
+ _("URI"),
+ _("The uri of the devhelp link."),
+ NULL,
+ (G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class, PROP_URI,
+ gParamSpecs [PROP_URI]);
+}
+
+static void
+gb_devhelp_navigation_item_init (GbDevhelpNavigationItem *self)
+{
+ self->priv = gb_devhelp_navigation_item_get_instance_private (self);
+}
diff --git a/src/devhelp/gb-devhelp-navigation-item.h b/src/devhelp/gb-devhelp-navigation-item.h
new file mode 100644
index 0000000..102ecce
--- /dev/null
+++ b/src/devhelp/gb-devhelp-navigation-item.h
@@ -0,0 +1,55 @@
+/* gb-devhelp-navigation-item.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_DEVHELP_NAVIGATION_ITEM_H
+#define GB_DEVHELP_NAVIGATION_ITEM_H
+
+#include "gb-navigation-item.h"
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_DEVHELP_NAVIGATION_ITEM (gb_devhelp_navigation_item_get_type())
+#define GB_DEVHELP_NAVIGATION_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GB_TYPE_DEVHELP_NAVIGATION_ITEM, GbDevhelpNavigationItem))
+#define GB_DEVHELP_NAVIGATION_ITEM_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GB_TYPE_DEVHELP_NAVIGATION_ITEM, GbDevhelpNavigationItem const))
+#define GB_DEVHELP_NAVIGATION_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GB_TYPE_DEVHELP_NAVIGATION_ITEM, GbDevhelpNavigationItemClass))
+#define GB_IS_DEVHELP_NAVIGATION_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GB_TYPE_DEVHELP_NAVIGATION_ITEM))
+#define GB_IS_DEVHELP_NAVIGATION_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GB_TYPE_DEVHELP_NAVIGATION_ITEM))
+#define GB_DEVHELP_NAVIGATION_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GB_TYPE_DEVHELP_NAVIGATION_ITEM, GbDevhelpNavigationItemClass))
+
+typedef struct _GbDevhelpNavigationItem GbDevhelpNavigationItem;
+typedef struct _GbDevhelpNavigationItemClass GbDevhelpNavigationItemClass;
+typedef struct _GbDevhelpNavigationItemPrivate GbDevhelpNavigationItemPrivate;
+
+struct _GbDevhelpNavigationItem
+{
+ GbNavigationItem parent;
+
+ /*< private >*/
+ GbDevhelpNavigationItemPrivate *priv;
+};
+
+struct _GbDevhelpNavigationItemClass
+{
+ GbNavigationItemClass parent;
+};
+
+GType gb_devhelp_navigation_item_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* GB_DEVHELP_NAVIGATION_ITEM_H */
diff --git a/src/devhelp/gb-devhelp-workspace.c b/src/devhelp/gb-devhelp-workspace.c
index 5d6c893..8f8f6a8 100644
--- a/src/devhelp/gb-devhelp-workspace.c
+++ b/src/devhelp/gb-devhelp-workspace.c
@@ -16,13 +16,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#define G_LOG_DOMAIN "devhelp-workspace"
+
#include <devhelp/devhelp.h>
#include <glib/gi18n.h>
+#include "gb-devhelp-navigation-item.h"
#include "gb-devhelp-tab.h"
#include "gb-devhelp-workspace.h"
+#include "gb-log.h"
#include "gb-multi-notebook.h"
+#include "gb-navigation-list.h"
#include "gb-notebook.h"
+#include "gb-workbench.h"
struct _GbDevhelpWorkspacePrivate
{
@@ -110,10 +116,15 @@ gb_devhelp_workspace_link_selected (GbDevhelpWorkspace *workspace,
DhSidebar *sidebar)
{
GbDevhelpWorkspacePrivate *priv;
+ GbNavigationList *list;
+ GbNavigationItem *item;
+ GbWorkbench *workbench;
const gchar *uri;
GbNotebook *notebook;
GbTab *tab;
+ ENTRY;
+
g_return_if_fail (GB_IS_DEVHELP_WORKSPACE (workspace));
g_return_if_fail (link_);
g_return_if_fail (DH_IS_SIDEBAR (sidebar));
@@ -133,6 +144,17 @@ gb_devhelp_workspace_link_selected (GbDevhelpWorkspace *workspace,
}
gb_devhelp_tab_set_uri (GB_DEVHELP_TAB (tab), uri);
+
+ workbench = GB_WORKBENCH (gtk_widget_get_toplevel (GTK_WIDGET (workspace)));
+ list = gb_workbench_get_navigation_list (workbench);
+ item = g_object_new (GB_TYPE_DEVHELP_NAVIGATION_ITEM,
+ "label", "",
+ "workspace", workspace,
+ "uri", uri,
+ NULL);
+ gb_navigation_list_append (list, item);
+
+ EXIT;
}
static void
@@ -146,6 +168,24 @@ on_n_notebooks_changed (GbMultiNotebook *mnb,
update_show_tabs (workspace);
}
+void
+gb_devhelp_workspace_open_uri (GbDevhelpWorkspace *workspace,
+ const gchar *uri)
+{
+ GbDevhelpWorkspacePrivate *priv;
+ GbTab *tab;
+
+ g_return_if_fail (GB_IS_DEVHELP_WORKSPACE (workspace));
+ g_return_if_fail (uri);
+
+ priv = workspace->priv;
+
+ tab = gb_multi_notebook_get_active_tab (priv->multi_notebook);
+
+ if (GB_IS_DEVHELP_TAB (tab))
+ gb_devhelp_tab_set_uri (GB_DEVHELP_TAB (tab), uri);
+}
+
static void
gb_devhelp_workspace_constructed (GObject *object)
{
diff --git a/src/devhelp/gb-devhelp-workspace.h b/src/devhelp/gb-devhelp-workspace.h
index 4b5e98b..f12957e 100644
--- a/src/devhelp/gb-devhelp-workspace.h
+++ b/src/devhelp/gb-devhelp-workspace.h
@@ -49,6 +49,8 @@ struct _GbDevhelpWorkspaceClass
};
GType gb_devhelp_workspace_get_type (void) G_GNUC_CONST;
+void gb_devhelp_workspace_open_uri (GbDevhelpWorkspace *workspace,
+ const gchar *uri);
G_END_DECLS
diff --git a/src/gnome-builder.mk b/src/gnome-builder.mk
index cdb3bb1..36e8d7a 100644
--- a/src/gnome-builder.mk
+++ b/src/gnome-builder.mk
@@ -9,10 +9,12 @@ libgnome_builder_la_SOURCES = \
src/animation/gb-frame-source.h \
src/app/gb-application.c \
src/app/gb-application.h \
- src/devhelp/gb-devhelp-workspace.c \
- src/devhelp/gb-devhelp-workspace.h \
+ src/devhelp/gb-devhelp-navigation-item.c \
+ src/devhelp/gb-devhelp-navigation-item.h \
src/devhelp/gb-devhelp-tab.c \
src/devhelp/gb-devhelp-tab.h \
+ src/devhelp/gb-devhelp-workspace.c \
+ src/devhelp/gb-devhelp-workspace.h \
src/editor/c-parse-helper.c \
src/editor/c-parse-helper.h \
src/editor/gb-editor-commands.c \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]