[anjuta/git-shell] git: Add the AnjutaDock and AnjutaCommandBar files to version control



commit 90bc41cb08333bbf5e82e3dcd270e4c33b1b938a
Author: James Liggett <jrliggett cox net>
Date:   Wed May 19 23:44:18 2010 -0700

    git: Add the AnjutaDock and AnjutaCommandBar files to version control

 libanjuta/anjuta-command-bar.c |  298 +++++++++++++++++++++++++++++++++++++++
 libanjuta/anjuta-command-bar.h |  111 +++++++++++++++
 libanjuta/anjuta-dock-pane.c   |  167 ++++++++++++++++++++++
 libanjuta/anjuta-dock-pane.h   |   63 +++++++++
 libanjuta/anjuta-dock.c        |  300 ++++++++++++++++++++++++++++++++++++++++
 libanjuta/anjuta-dock.h        |   76 ++++++++++
 6 files changed, 1015 insertions(+), 0 deletions(-)
---
diff --git a/libanjuta/anjuta-command-bar.c b/libanjuta/anjuta-command-bar.c
new file mode 100644
index 0000000..065fc7e
--- /dev/null
+++ b/libanjuta/anjuta-command-bar.c
@@ -0,0 +1,298 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * git-shell-test
+ * Copyright (C) James Liggett 2009 <jrliggett cox net>
+ * 
+ * git-shell-test 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.
+ * 
+ * git-shell-test 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 "anjuta-command-bar.h"
+
+/**
+ * SECTION: anjuta-command-bar
+ * @short_description: Widget that lays out commands in a vertical row of 
+ *					   buttons and frames.
+ * @see_also: #AnjutaDock, #GtkAction
+ * @include: libanjuta/anjuta-command-bar.h
+ *
+ * AnjutaCommandBar provides a convenient way to arrange several sets of 
+ * commands into one widget. It separates commands into different groups of 
+ * actions, with only one group visible at a time. 
+ */
+
+G_DEFINE_TYPE (AnjutaCommandBar, anjuta_command_bar, GTK_TYPE_NOTEBOOK);
+
+struct _AnjutaCommandBarPriv
+{
+	GHashTable *action_groups;
+	GHashTable *widgets;
+};
+
+static void
+anjuta_command_bar_init (AnjutaCommandBar *self)
+{
+	self->priv = g_new0 (AnjutaCommandBarPriv, 1);
+
+	gtk_notebook_set_show_border (GTK_NOTEBOOK (self), FALSE);
+	gtk_notebook_set_show_tabs (GTK_NOTEBOOK (self), FALSE);
+	
+	/* The action groups table contains the GtkActionGroup objects that 
+	 * correspond to each page of the action bar. The widgets table contain's
+	 * each group's set of buttons and frames. */
+	self->priv->action_groups = g_hash_table_new_full (g_str_hash, g_str_equal,
+	                                                   NULL, g_object_unref);
+	self->priv->widgets = g_hash_table_new (g_str_hash, g_str_equal);
+}
+
+static void
+anjuta_command_bar_finalize (GObject *object)
+{
+	AnjutaCommandBar *self;
+
+	self = ANJUTA_COMMAND_BAR (object);
+
+	g_hash_table_destroy (self->priv->action_groups);
+	g_hash_table_destroy (self->priv->widgets);
+
+	G_OBJECT_CLASS (anjuta_command_bar_parent_class)->finalize (object);
+}
+
+static void
+anjuta_command_bar_class_init (AnjutaCommandBarClass *klass)
+{
+	GObjectClass* object_class = G_OBJECT_CLASS (klass);
+
+	object_class->finalize = anjuta_command_bar_finalize;
+}
+
+/**
+ * anjuta_command_bar_new:
+ *
+ * Creates a new AnjutaCommandBar.
+ * Returns: A new AnjutaCommandBar
+ */
+GtkWidget *
+anjuta_command_bar_new (void)
+{
+	return g_object_new (ANJUTA_TYPE_COMMAND_BAR, NULL);
+}
+
+/**
+ * anjuta_command_bar_add_action_group:
+ * @self: An AnjutaCommandBar
+ * @group_name: A unique name for this group of entries
+ * @entries: A list of entries to add
+ * @num_entries: The number of items pointed to by entries
+ * @user_data: User data to pass to the entry callback
+ * 
+ * Adds a group of entries to an AnjutaCommandBar.
+ */
+void 
+anjuta_command_bar_add_action_group (AnjutaCommandBar *self, 
+                                     const gchar *group_name, 
+                                     const AnjutaCommandBarEntry *entries,
+                                     int num_entries, gpointer user_data)
+{
+	GtkWidget *vbox;
+	GtkWidget *current_vbox;
+	GtkActionGroup *action_group;
+	int i;
+	GtkAction *action;
+	GtkWidget *button;
+	GtkWidget *button_image;
+	gchar *frame_label_text;
+	GtkWidget *frame_label;
+	GtkWidget *frame;
+	GtkWidget *frame_vbox;
+
+	vbox = gtk_vbox_new (FALSE, 2);
+
+	g_hash_table_insert (self->priv->widgets, (gchar *) group_name, 
+	                     vbox);
+
+	action_group = gtk_action_group_new (group_name);
+
+	g_hash_table_insert (self->priv->action_groups, (gchar *) group_name,
+	                     action_group);
+
+	/* The current_vbox is the vbox we're currently adding buttons to. As 
+	 * frame entries are encountered, the current box changes to the newly 
+	 * created frame vbox. But start by adding any other buttons to the top
+	 * level vbox. */
+	current_vbox = vbox;
+
+	for (i = 0; i < num_entries; i++)
+	{
+		if (entries[i].type == ANJUTA_COMMAND_BAR_ENTRY_BUTTON)
+		{
+			action = gtk_action_new (entries[i].action_name, entries[i].label, 
+			                         entries[i].tooltip, entries[i].stock_icon);
+			button = gtk_button_new();
+
+			gtk_action_group_add_action (action_group, action);
+			
+			gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+
+			if (entries[i].stock_icon)
+			{
+				button_image = gtk_action_create_icon (action, 
+				                                       GTK_ICON_SIZE_BUTTON);
+				gtk_button_set_image (GTK_BUTTON (button), button_image);
+			}
+
+			gtk_activatable_set_related_action (GTK_ACTIVATABLE (button), 
+			                                    action);
+			gtk_activatable_set_use_action_appearance (GTK_ACTIVATABLE (button),
+			                                           TRUE);
+
+			g_signal_connect (G_OBJECT (action), "activate",
+			                  entries[i].callback,
+			                  user_data);
+
+			/* Left-align button contents */
+			g_object_set (G_OBJECT (button), "xalign", 0.0, NULL);
+
+			gtk_box_pack_start (GTK_BOX (current_vbox), button, FALSE, FALSE, 
+			                    2);
+		}
+		else
+		{
+			frame_label_text = g_strdup_printf ("<b>%s</b>", entries[i].label);
+			frame_label = gtk_label_new (NULL);
+			frame = gtk_frame_new (NULL);
+			
+			gtk_label_set_markup(GTK_LABEL (frame_label), frame_label_text);
+			gtk_frame_set_label_widget (GTK_FRAME (frame), frame_label);
+
+			g_free (frame_label_text);
+			
+			frame_vbox = gtk_vbox_new (TRUE, 2);
+
+			g_object_set (G_OBJECT (frame), "shadow-type", GTK_SHADOW_NONE, 
+			              NULL);
+
+			gtk_container_add (GTK_CONTAINER (frame), frame_vbox);
+			gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 2);
+
+			current_vbox = frame_vbox;
+		}
+	}
+
+	gtk_widget_show_all (vbox);
+	gtk_notebook_append_page (GTK_NOTEBOOK (self), vbox, NULL);
+}
+
+/**
+ * anjuta_command_bar_remove_action_group:
+ * @self: An AnjutaCommandBar
+ * @group_name: Name of the action group to remove
+ *
+ * Removes an action group from an AnjutaCommandBar.
+ */
+void 
+anjuta_command_bar_remove_action_group (AnjutaCommandBar *self,
+                                        const gchar *group_name)
+{
+	GtkWidget *page_widget;
+	int page_num;
+
+	page_widget = g_hash_table_lookup (self->priv->action_groups, group_name);
+
+	if (page_widget)
+	{
+		page_num = gtk_notebook_page_num (GTK_NOTEBOOK (self), page_widget);
+
+		gtk_notebook_remove_page (GTK_NOTEBOOK (self), page_num);
+
+		g_hash_table_remove (self->priv->action_groups, group_name);
+		g_hash_table_remove (self->priv->widgets, group_name);
+	}
+	else
+		g_warning ("Action group %s not found.", group_name);
+	
+}
+
+/**
+ * anjuta_command_bar_show_action_group:
+ * @self: An AnjutaCommandBar
+ * @group_name: The name of the action group to show
+ * 
+ * Causes the actions in the given group to become visible, replacing the 
+ * previously visible group.
+ */
+void
+anjuta_command_bar_show_action_group (AnjutaCommandBar *self,
+                                      const gchar *group_name)
+{
+	GtkWidget *page_widget;
+	int page_num;
+
+	page_widget = g_hash_table_lookup (self->priv->widgets, group_name);
+
+	if (page_widget)
+	{
+		page_num = gtk_notebook_page_num (GTK_NOTEBOOK (self), page_widget);
+
+		gtk_notebook_set_current_page (GTK_NOTEBOOK (self), page_num);
+	}
+	else
+		g_warning ("Action group %s not found.", group_name);
+	
+}
+
+/**
+ * anjuta_command_bar_get_action_group:
+ * @self An AnjutaCommandBar
+ * @group_name: The name of the action group
+ *
+ * Returns the #GtkActionGroup with the given @group_name
+ */
+GtkActionGroup *
+anjuta_command_bar_get_action_group (AnjutaCommandBar *self,
+                                     const gchar *group_name)
+{
+	GtkActionGroup *action_group;
+
+	action_group = g_hash_table_lookup (self->priv->action_groups, group_name);
+
+	if (!action_group)
+		g_warning ("Action group %s not found.", group_name);
+
+	return action_group;
+}
+
+/**
+ * anjuta_command_bar_get_action:
+ * @self: An AnjutaCommandBar
+ * @group_name: The name of the #GtkActionGroup to look for the action in
+ * @action: The name of the action
+ *
+ * Retrieves a #GtkAction object in the given group with the given name
+ */
+GtkAction *
+anjuta_command_bar_get_action (AnjutaCommandBar *self, const gchar *group_name, 
+                               const gchar *action_name)
+{
+	GtkActionGroup *action_group;
+	GtkAction *action;
+
+	action = NULL;
+
+	action_group = anjuta_command_bar_get_action_group (self, group_name);
+
+	if (action_group)
+		action = gtk_action_group_get_action (action_group, action_name);
+
+	return action;
+}
diff --git a/libanjuta/anjuta-command-bar.h b/libanjuta/anjuta-command-bar.h
new file mode 100644
index 0000000..014130c
--- /dev/null
+++ b/libanjuta/anjuta-command-bar.h
@@ -0,0 +1,111 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * git-shell-test
+ * Copyright (C) James Liggett 2009 <jrliggett cox net>
+ * 
+ * git-shell-test 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.
+ * 
+ * git-shell-test 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 _ANJUTA_COMMAND_BAR_H_
+#define _ANJUTA_COMMAND_BAR_H_
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define ANJUTA_TYPE_COMMAND_BAR             (anjuta_command_bar_get_type ())
+#define ANJUTA_COMMAND_BAR(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_COMMAND_BAR, AnjutaCommandBar))
+#define ANJUTA_COMMAND_BAR_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), ANJUTA_TYPE_COMMAND_BAR, AnjutaCommandBarClass))
+#define ANJUTA_IS_COMMAND_BAR(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ANJUTA_TYPE_COMMAND_BAR))
+#define ANJUTA_IS_COMMAND_BAR_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), ANJUTA_TYPE_COMMAND_BAR))
+#define ANJUTA_COMMAND_BAR_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), ANJUTA_TYPE_COMMAND_BAR, AnjutaCommandBarClass))
+
+typedef struct _AnjutaCommandBarClass AnjutaCommandBarClass;
+typedef struct _AnjutaCommandBar AnjutaCommandBar;
+typedef struct _AnjutaCommandBarPriv AnjutaCommandBarPriv;
+
+/**
+ * AnjutaCommandBarEntryType:
+ * @ANJUTA_COMMAND_BAR_ENTRY_FRAME: This entry should create a frame in the 
+ *									action bar. The entry's action name and 
+ *									callback are ignored.
+ * @ANJUTA_COMMAND_BAR_ENTRY_BUTTON: This entry adds a button to the action bar,
+ *									 either to the last frame to appear in the 
+ *									 entry list before this entry, or to the top
+ *									 of the bar if no frames were previously 
+ *									 added.
+ *
+ * Specifies if the entry corresponds to a frame or a button.
+ * Buttons are added to the last frame that appears before the button entry
+ */
+typedef enum
+{
+	ANJUTA_COMMAND_BAR_ENTRY_FRAME,
+	ANJUTA_COMMAND_BAR_ENTRY_BUTTON
+} AnjutaCommandBarEntryType;
+
+/**
+ * AnjutaCommandBarEntry:
+ * @type: The type of action
+ * @action_name: The name of the action for this entry
+ * @label: The display label for this entry
+ * @stock_icon: The stock icon to display for this entry
+ * @callback: Function to call when this entry's action is activated
+ *
+ * AnjutaCommandBarEntry is used to add a set of frames and actions to a command
+ * bar.
+ */
+typedef struct
+{
+	AnjutaCommandBarEntryType type;
+	const gchar *action_name;
+	const gchar *label;
+	const gchar *tooltip;
+	const gchar *stock_icon;
+	GCallback callback;
+} AnjutaCommandBarEntry;
+
+struct _AnjutaCommandBarClass
+{
+	GtkNotebookClass parent_class;
+};
+
+struct _AnjutaCommandBar
+{
+	GtkNotebook parent_instance;
+
+	AnjutaCommandBarPriv *priv;
+};
+
+GType anjuta_command_bar_get_type (void) G_GNUC_CONST;
+GtkWidget *anjuta_command_bar_new (void);
+void anjuta_command_bar_add_action_group (AnjutaCommandBar *self, 
+                                          const gchar *group_name, 
+                                          const AnjutaCommandBarEntry *entries,
+                                          int num_entries,
+                                          gpointer user_data);
+void anjuta_command_bar_remove_action_group (AnjutaCommandBar *self,
+                                             const gchar *group_name);
+void anjuta_command_bar_show_action_group (AnjutaCommandBar *self,
+                                           const gchar *group_name);
+GtkActionGroup *anjuta_command_bar_get_action_group (AnjutaCommandBar *self,
+                                                     const gchar *group_name);
+GtkAction *anjuta_command_bar_get_action (AnjutaCommandBar *self,
+                                          const gchar *group_name, 
+                                          const gchar *action_name);
+
+G_END_DECLS
+
+#endif /* _ANJUTA_COMMAND_BAR_H_ */
diff --git a/libanjuta/anjuta-dock-pane.c b/libanjuta/anjuta-dock-pane.c
new file mode 100644
index 0000000..0f98901
--- /dev/null
+++ b/libanjuta/anjuta-dock-pane.c
@@ -0,0 +1,167 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * git-shell-test
+ * Copyright (C) James Liggett 2010 <jrliggett cox net>
+ * 
+ * git-shell-test 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.
+ * 
+ * git-shell-test 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 "anjuta-dock-pane.h"
+
+/**
+ * SECTION: anjuta-dock-pane
+ * @short_description: Wrapper class for #AnjutaDock panes
+ * @see_also: #AnjutaDock
+ * @include: libanjuta/anjuta-dock-pane.h
+ *
+ * AnjutaDockPane is an abstract wrapper class for panes in an 
+ * #AnjutaDock.
+ *
+ * Using AnjutaDockPane is especially helpful for those panes that show data
+ * from extenal sources that must be refreshed frequently, or panes that are
+ * exceptionally complex. 
+ */
+
+enum
+{
+	ANJUTA_DOCK_PANE_PLUGIN = 1
+};
+
+struct _AnjutaDockPanePriv
+{
+	AnjutaPlugin *plugin;
+};
+
+G_DEFINE_ABSTRACT_TYPE (AnjutaDockPane, anjuta_dock_pane, G_TYPE_OBJECT);
+
+static void
+anjuta_dock_pane_init (AnjutaDockPane *self)
+{
+	self->priv = g_new0 (AnjutaDockPanePriv, 1);
+}
+
+static void
+anjuta_dock_pane_finalize (GObject *object)
+{
+	AnjutaDockPane *self;
+
+	self = ANJUTA_DOCK_PANE (object);
+
+	g_free (self->priv);
+
+	G_OBJECT_CLASS (anjuta_dock_pane_parent_class)->finalize (object);
+}
+
+static void
+anjuta_dock_pane_set_property (GObject *object, guint property_id, 
+                               const GValue *value, GParamSpec *param_spec)
+{
+	AnjutaDockPane *self;
+
+	self = ANJUTA_DOCK_PANE (object);
+
+	switch (property_id)
+	{
+		case ANJUTA_DOCK_PANE_PLUGIN:
+			self->priv->plugin = ANJUTA_PLUGIN (g_value_get_object (value));
+			break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, param_spec);
+			break;
+	}
+}
+
+static void
+anjuta_dock_pane_get_property (GObject *object, guint property_id,
+                               GValue *value, GParamSpec *param_spec)
+{
+	AnjutaDockPane *self;
+
+	self = ANJUTA_DOCK_PANE (object);
+
+	switch (property_id)
+	{
+		case ANJUTA_DOCK_PANE_PLUGIN:
+			g_value_set_object (value, self->priv->plugin);
+			break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, param_spec);
+			break;
+	}
+}
+
+static void
+anjuta_dock_pane_class_init (AnjutaDockPaneClass *klass)
+{
+	GObjectClass* object_class = G_OBJECT_CLASS (klass);
+	GParamSpec *param_spec;
+
+	object_class->finalize = anjuta_dock_pane_finalize;
+	object_class->set_property = anjuta_dock_pane_set_property;
+	object_class->get_property = anjuta_dock_pane_get_property;
+	klass->refresh = NULL;
+	klass->get_widget = NULL;
+
+	param_spec = g_param_spec_object ("plugin", "Plugin", 
+	                                  "Plugin object associated with this pane.",
+	                                  ANJUTA_TYPE_PLUGIN,
+	                                  G_PARAM_READWRITE);
+	g_object_class_install_property (object_class, ANJUTA_DOCK_PANE_PLUGIN, 
+	                                 param_spec);
+}
+
+/**
+ * anjuta_dock_pane_refresh:
+ * @self: An AnjutaDockPane
+ *
+ * Refreshes the given pane. Subclasses only need to override this method if 
+ * needed. 
+ */
+void
+anjuta_dock_pane_refresh (AnjutaDockPane *self)
+{
+	AnjutaDockPaneClass *klass;
+
+	klass = ANJUTA_DOCK_PANE_GET_CLASS (self);
+	
+	if (klass->refresh)
+		klass->refresh (self);
+}
+
+/**
+ * anjuta_dock_pane_get_widget:
+ * @self: An AnjutaDockPane
+ *
+ * Returns the widget assocatioed with the given pane. The returned widget is 
+ * owned by the pane and should not be destroyed or modified.
+ */
+GtkWidget *
+anjuta_dock_pane_get_widget (AnjutaDockPane *self)
+{
+	return ANJUTA_DOCK_PANE_GET_CLASS (self)->get_widget (self);
+}
+
+
+/**
+ * anjuta_dock_pane_get_plugin:
+ * @self: An AnjutaDockPane
+ *
+ * Returns the plugin object associated with this pane. 
+ */
+AnjutaPlugin *
+anjuta_dock_pane_get_plugin (AnjutaDockPane *self)
+{
+	return self->priv->plugin;
+}
+
diff --git a/libanjuta/anjuta-dock-pane.h b/libanjuta/anjuta-dock-pane.h
new file mode 100644
index 0000000..9b78416
--- /dev/null
+++ b/libanjuta/anjuta-dock-pane.h
@@ -0,0 +1,63 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * git-shell-test
+ * Copyright (C) James Liggett 2010 <jrliggett cox net>
+ * 
+ * git-shell-test 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.
+ * 
+ * git-shell-test 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 _ANJUTA_DOCK_PANE_H_
+#define _ANJUTA_DOCK_PANE_H_
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+#include <libanjuta/anjuta-plugin.h>
+
+G_BEGIN_DECLS
+
+#define ANJUTA_TYPE_DOCK_PANE             (anjuta_dock_pane_get_type ())
+#define ANJUTA_DOCK_PANE(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_DOCK_PANE, AnjutaDockPane))
+#define ANJUTA_DOCK_PANE_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), ANJUTA_TYPE_DOCK_PANE, AnjutaDockPaneClass))
+#define ANJUTA_IS_DOCK_PANE(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ANJUTA_TYPE_DOCK_PANE))
+#define ANJUTA_IS_DOCK_PANE_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), ANJUTA_TYPE_DOCK_PANE))
+#define ANJUTA_DOCK_PANE_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), ANJUTA_TYPE_DOCK_PANE, AnjutaDockPaneClass))
+
+typedef struct _AnjutaDockPaneClass AnjutaDockPaneClass;
+typedef struct _AnjutaDockPane AnjutaDockPane;
+typedef struct _AnjutaDockPanePriv AnjutaDockPanePriv;
+
+struct _AnjutaDockPaneClass
+{
+	GObjectClass parent_class;
+
+	/* Virtual methods */
+	void (*refresh) (AnjutaDockPane *self);
+	GtkWidget * (*get_widget) (AnjutaDockPane *self);
+};
+
+struct _AnjutaDockPane
+{
+	GObject parent_instance;
+
+	AnjutaDockPanePriv *priv;
+};
+
+GType anjuta_dock_pane_get_type (void) G_GNUC_CONST;
+void anjuta_dock_pane_refresh (AnjutaDockPane *self);
+GtkWidget *anjuta_dock_pane_get_widget (AnjutaDockPane *self);
+AnjutaPlugin *anjuta_dock_pane_get_plugin (AnjutaDockPane *self);
+
+G_END_DECLS
+
+#endif /* _ANJUTA_DOCK_PANE_H_ */
diff --git a/libanjuta/anjuta-dock.c b/libanjuta/anjuta-dock.c
new file mode 100644
index 0000000..9722a8f
--- /dev/null
+++ b/libanjuta/anjuta-dock.c
@@ -0,0 +1,300 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * git-shell-test
+ * Copyright (C) James Liggett 2009 <jrliggett cox net>
+ * 
+ * git-shell-test 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.
+ * 
+ * git-shell-test 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 "anjuta-dock.h"
+
+/**
+ * SECTION: AnjutaDock
+ * @short_description: Docking system for context-driven user interfaces.
+ * @see_also: #AnjutaCommandBar
+ * @include; libanjuta/anjuta-dock.h
+ *
+ * AnjutaDock provides an alternative to the traditional menu and toolbar based
+ * methodologies used by most GNOME programs. Instead, it focuses on tasks, or 
+ * related sets of tasks. Each pane in the dock corresponds to a different set
+ * of related tasks. 
+ * 
+ * Optionally, you can also associate an #AnjutaCommandBar with an AnjutaDock to
+ * provide contextually appropriate sets of commands depending on the currently
+ * visible pane
+ */
+
+struct _AnjutaDockPriv
+{
+	GHashTable *panes;
+	GtkWidget *command_bar;
+};
+
+G_DEFINE_TYPE (AnjutaDock, anjuta_dock, GDL_TYPE_DOCK);
+
+static void
+anjuta_dock_init (AnjutaDock *self)
+{
+	self->priv = g_new0 (AnjutaDockPriv, 1);
+	self->priv->panes = g_hash_table_new_full (g_str_hash, g_str_equal, 
+	                                           NULL, g_object_unref);
+}
+
+static void
+anjuta_dock_finalize (GObject *object)
+{
+	AnjutaDock *self;
+
+	self = ANJUTA_DOCK (object);
+
+	g_free (self->priv);
+
+	G_OBJECT_CLASS (anjuta_dock_parent_class)->finalize (object);
+}
+
+static void
+anjuta_dock_dispose (GObject *object)
+{
+	AnjutaDock *self;
+
+	self = ANJUTA_DOCK (object);
+
+	if (self->priv->command_bar)
+	{
+		g_object_unref (self->priv->command_bar);
+		self->priv->command_bar = NULL;
+	}
+
+	G_OBJECT_CLASS (anjuta_dock_parent_class)->dispose (object);
+}
+
+static void
+anjuta_dock_class_init (AnjutaDockClass *klass)
+{
+	GObjectClass* object_class = G_OBJECT_CLASS (klass);
+
+	object_class->finalize = anjuta_dock_finalize;
+	object_class->dispose = anjuta_dock_dispose;
+}
+
+/**
+ * anjuta_dock_new:
+ * 
+ * Creates a new AnjutaDock.
+ */
+GtkWidget *
+anjuta_dock_new (void)
+{
+	return g_object_new (ANJUTA_TYPE_DOCK, NULL);
+}
+
+/**
+ * anjuta_dock_add_pane:
+ * @self: An AnjutaDock
+ * @pane_name: A unique name for this pane
+ * @pane_label: Label to display in this pane's grip 
+ * @pane: The #AnjutaDockPane to add to the dock. The dock takes ownership of
+ *		  the pane object.
+ * @stock_id: Stock icon to display in this pane's grip
+ * @placement: A #GdlDockPlacement value indicating where the pane should be
+ *			   placed
+ * @entries: #AnjutaCommandBar entries for this pane. Can be %NULL
+ * @num_entries: The number of entries pointed to by entries, or 0.
+ * @user_data: User data to pass to the entry callback
+ *
+ * Adds a pane, with optional #AnjutaCommandBar entries, to an AnjutaDock. This
+ * method adds a pane with no grip that cannot be closed, floating or iconified.
+ */
+void 
+anjuta_dock_add_pane (AnjutaDock *self, const gchar *pane_name,
+                      const gchar *pane_label, const gchar *stock_icon,
+                      AnjutaDockPane *pane, GdlDockPlacement placement, 
+                      AnjutaCommandBarEntry *entries, int num_entries,
+                      gpointer user_data)
+{
+	int behavior;
+
+	behavior = 0;
+	behavior |= GDL_DOCK_ITEM_BEH_NO_GRIP;
+	behavior |= GDL_DOCK_ITEM_BEH_CANT_CLOSE;
+	behavior |= GDL_DOCK_ITEM_BEH_CANT_ICONIFY;
+	behavior |= GDL_DOCK_ITEM_BEH_NEVER_FLOATING;
+	
+	anjuta_dock_add_pane_full (self, pane_name, pane_label, stock_icon,
+	                           pane, placement, entries, num_entries, 
+	                           user_data, behavior);
+}
+
+static void
+on_pane_selected (GdlDockItem *item, AnjutaCommandBar *command_bar)
+{
+	const gchar *pane_name;
+
+	pane_name = (const gchar *) g_object_get_data (G_OBJECT (item), 
+	                                               "pane-name");
+	anjuta_command_bar_show_action_group (command_bar, pane_name);
+}
+
+/**
+ * anjuta_dock_add_pane_full:
+ * @self: An AnjutaDock
+ * @pane_name: A unique name for this pane
+ * @pane_label: Label to display in this pane's grip 
+ * @stock_id: Stock icon to display in this pane's grip
+ * @pane: The #AnjutaDockPane to add to the dock. The dock takes ownership of
+ *		  the pane object.
+ * @placement: A #GdlDockPlacement value indicating where the pane should be
+ *			   placed
+ * @entries: #AnjutaCommandBar entries for this pane. Can be %NULL
+ * @num_entries: The number of entries pointed to by entries, or 0.
+ * @user_data: User data to pass to the entry callback
+ * @behavior: Any combination of #GdlDockItemBehavior flags
+ *
+ * Does the same thing as anjuta_dock_add_pane, but allows GDL dock behavior 
+ * flags to be specified.
+ */
+void 
+anjuta_dock_add_pane_full (AnjutaDock *self, const gchar *pane_name,
+                           const gchar *pane_label, const gchar *stock_icon,   
+                           AnjutaDockPane *pane,
+                           GdlDockPlacement placement,
+                           AnjutaCommandBarEntry *entries, int num_entries,
+                           gpointer user_data,
+                           GdlDockItemBehavior behavior)
+{
+	GtkWidget *dock_item;
+	GtkWidget *child;
+
+	dock_item = gdl_dock_item_new (pane_name, pane_label, behavior);
+	child = anjuta_dock_pane_get_widget (pane);
+	g_object_set_data (G_OBJECT (child), "dock-item", dock_item);
+
+	/* Make sure there isn't another dock with the same name */
+	if (!g_hash_table_lookup_extended (self->priv->panes, pane_name, NULL, 
+	                                   NULL))
+	{
+		/* Take ownership of the pane object */
+		g_hash_table_insert (self->priv->panes, (gchar *) pane_name, pane);
+
+		gtk_container_add (GTK_CONTAINER (dock_item), child);
+		gdl_dock_add_item (GDL_DOCK (self), GDL_DOCK_ITEM (dock_item), placement);
+
+		g_object_set_data (G_OBJECT (dock_item), "pane-name", (gchar *) pane_name);
+
+		/* Don't add anything to the action bar if there are no entries */
+		if (self->priv->command_bar && entries)
+		{
+			anjuta_command_bar_add_action_group (ANJUTA_COMMAND_BAR (self->priv->command_bar),
+			                                     pane_name, entries, num_entries, 
+			                                     user_data);
+
+			g_signal_connect (G_OBJECT (dock_item), "selected",
+			                  G_CALLBACK (on_pane_selected),
+			                  self->priv->command_bar);
+
+			/* Show the new pane's commands in the command bar */
+			anjuta_command_bar_show_action_group (ANJUTA_COMMAND_BAR (self->priv->command_bar),
+			                                      pane_name);
+		}
+	}
+}
+
+/**
+ * anjuta_dock_remove_pane:
+ * @self An AnjutaDock
+ * @pane_name: Name of the pane to remove
+ *
+ * Removes a pane from a dock
+ */
+void
+anjuta_dock_remove_pane (AnjutaDock *self, AnjutaDockPane *pane)
+{
+	GtkWidget *child;
+	GtkContainer *dock_item;
+
+	child = anjuta_dock_pane_get_widget (pane);
+
+	if (child)
+	{
+		/* Remove the child from its dock item and destroy it */
+		dock_item = g_object_get_data (G_OBJECT (child), "dock-item");
+		g_hash_table_remove (self->priv->panes, 
+		                     g_object_get_data (G_OBJECT (dock_item), 
+		                                        "pane-name"));
+		gtk_container_remove (dock_item, child);
+
+		gdl_dock_item_unbind (GDL_DOCK_ITEM (dock_item));
+	}
+}
+
+/**
+ * anjuta_dock_show_pane:
+ * @self: An AnjutaDock
+ * @pane_name: Name of the pane to show
+ *
+ * Makes the given pane visible
+ */
+void
+anjuta_dock_show_pane (AnjutaDock *self, AnjutaDockPane *pane)
+{
+	GtkWidget *child;
+	GdlDockItem *dock_item;
+
+	child = anjuta_dock_pane_get_widget (pane);
+
+	if (child)
+	{
+		dock_item = g_object_get_data (G_OBJECT (child), "dock-item");
+		gdl_dock_item_show_item (dock_item);
+	}
+}
+
+/**
+ * anjuta_dock_hide_pane:
+ * @self: An AnjutaDock
+ * @pane_name: Name of the pane to hide
+ *
+ * Makes the given pane invisible
+ */
+void
+anjuta_dock_hide_pane (AnjutaDock *self, AnjutaDockPane *pane)
+{
+	GtkWidget *child;
+	GdlDockItem *dock_item;
+
+	child = anjuta_dock_pane_get_widget (pane);
+
+	if (child)
+	{
+		dock_item = g_object_get_data (G_OBJECT (child), "dock-item");
+		gdl_dock_item_hide_item (dock_item);
+	}
+}
+
+/**
+ * anjuta_dock_set_command_bar:
+ * @self: An AnjutaDock
+ * @command_bar: An #AnjutaCommandBar to associate with this dock
+ *
+ * Associates an #AnjutaCommandBar with this dock. Command bars can be used to 
+ * provide different sets of commands based on the currently visible pane.
+ */
+void
+anjuta_dock_set_command_bar (AnjutaDock *self, AnjutaCommandBar *command_bar)
+{
+	if (self->priv->command_bar)
+		g_object_unref (self->priv->command_bar);
+
+	self->priv->command_bar = g_object_ref (command_bar);
+}
diff --git a/libanjuta/anjuta-dock.h b/libanjuta/anjuta-dock.h
new file mode 100644
index 0000000..7706c5c
--- /dev/null
+++ b/libanjuta/anjuta-dock.h
@@ -0,0 +1,76 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * git-shell-test
+ * Copyright (C) James Liggett 2009 <jrliggett cox net>
+ * 
+ * git-shell-test 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.
+ * 
+ * git-shell-test 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 _ANJUTA_DOCK_H_
+#define _ANJUTA_DOCK_H_
+
+#include <glib-object.h>
+#include <gdl/gdl-dock.h>
+#include <gdl/gdl-dock-object.h>
+#include "anjuta-dock-pane.h"
+#include "anjuta-command-bar.h"
+
+G_BEGIN_DECLS
+
+#define ANJUTA_TYPE_DOCK             (anjuta_dock_get_type ())
+#define ANJUTA_DOCK(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_DOCK, AnjutaDock))
+#define ANJUTA_DOCK_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), ANJUTA_TYPE_DOCK, AnjutaDockClass))
+#define ANJUTA_IS_DOCK(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ANJUTA_TYPE_DOCK))
+#define ANJUTA_IS_DOCK_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), ANJUTA_TYPE_DOCK))
+#define ANJUTA_DOCK_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), ANJUTA_TYPE_DOCK, AnjutaDockClass))
+
+typedef struct _AnjutaDockClass AnjutaDockClass;
+typedef struct _AnjutaDock AnjutaDock;
+typedef struct _AnjutaDockPriv AnjutaDockPriv;
+
+struct _AnjutaDockClass
+{
+	GdlDockClass parent_class;
+};
+
+struct _AnjutaDock
+{
+	GdlDock parent_instance;
+
+	AnjutaDockPriv *priv;
+};
+
+GType anjuta_dock_get_type (void) G_GNUC_CONST;
+GtkWidget *anjuta_dock_new (void);
+void anjuta_dock_add_pane (AnjutaDock *self, const gchar *pane_name,
+                           const gchar *pane_label, const gchar *stock_icon,
+                           AnjutaDockPane *pane, GdlDockPlacement placement, 
+                           AnjutaCommandBarEntry *entries, int num_entries,
+                           gpointer user_data);
+void anjuta_dock_add_pane_full (AnjutaDock *self, const gchar *pane_name,
+                                const gchar *pane_label, 
+                                const gchar *stock_icon,  AnjutaDockPane *pane, 
+                                GdlDockPlacement placement,
+                                AnjutaCommandBarEntry *entries, int num_entries,
+                                gpointer user_data, 
+                                GdlDockItemBehavior behavior);
+void anjuta_dock_remove_pane (AnjutaDock *self, AnjutaDockPane *pane);
+void anjuta_dock_show_pane (AnjutaDock *self, AnjutaDockPane *pane);
+void anjuta_dock_hide_pane (AnjutaDock *self, AnjutaDockPane *pane);
+void anjuta_dock_set_command_bar (AnjutaDock *self, 
+                                  AnjutaCommandBar *command_bar);
+
+G_END_DECLS
+
+#endif /* _ANJUTA_DOCK_H_ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]