[anjuta] libanjuta/app: Add interface to maximize/unmaximize widgets
- From: Johannes Schmid <jhs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] libanjuta/app: Add interface to maximize/unmaximize widgets
- Date: Mon, 19 Apr 2010 17:11:23 +0000 (UTC)
commit 1770384026ce81e575ffbd3e05ef88da29b337e3
Author: Dragos Dena <dragos dena gmail com>
Date: Mon Apr 19 19:07:02 2010 +0200
libanjuta/app: Add interface to maximize/unmaximize widgets
libanjuta/anjuta-shell.c | 74 +++++++++++++++++++++++
libanjuta/anjuta-shell.h | 29 +++++++++
src/anjuta-app.c | 147 +++++++++++++++++++++++++++++++++++++++++++++-
src/anjuta-app.h | 1 +
src/shell.c | 49 +++++++++++++++
5 files changed, 299 insertions(+), 1 deletions(-)
---
diff --git a/libanjuta/anjuta-shell.c b/libanjuta/anjuta-shell.c
index df85d44..6c1cb9e 100644
--- a/libanjuta/anjuta-shell.c
+++ b/libanjuta/anjuta-shell.c
@@ -416,6 +416,80 @@ anjuta_shell_present_widget (AnjutaShell *shell,
}
/**
+ * anjuta_shell_iconify_dockable_widget:
+ * @shell: A #AnjutaShell interface.
+ * @widget: a #GtkWidget to iconify.
+ * @error: Error propagation object.
+ *
+ * If the widget is dockable, it iconifies it.
+ */
+void anjuta_shell_iconify_dockable_widget (AnjutaShell *shell,
+ GtkWidget *widget,
+ GError **error)
+{
+ ANJUTA_SHELL_GET_IFACE (shell)->iconify_dockable_widget (shell, widget, error);
+}
+
+/**
+ * anjuta_shell_hide_dockable_widget:
+ * @shell: A #AnjutaShell interface.
+ * @widget: a #GtkWidget to hide.
+ * @error: Error propagation object.
+ *
+ * If the widget is dockable, it hides it.
+ */
+void anjuta_shell_hide_dockable_widget (AnjutaShell *shell,
+ GtkWidget *widget,
+ GError **error)
+{
+ ANJUTA_SHELL_GET_IFACE (shell)->hide_dockable_widget (shell, widget, error);
+}
+
+/**
+ * anjuta_shell_show_dockable_widget:
+ * @shell: A #AnjutaShell interface.
+ * @widget: a #GtkWidget to show.
+ * @error: Error propagation object.
+ *
+ * If the widget was hidden or iconified, it will make it visible.
+ */
+void anjuta_shell_show_dockable_widget (AnjutaShell *shell,
+ GtkWidget *widget,
+ GError **error)
+{
+ ANJUTA_SHELL_GET_IFACE (shell)->show_dockable_widget (shell, widget, error);
+}
+
+/**
+ * anjuta_shell_maximize_widget:
+ * @shell: A #AnjutaShell interface.
+ * @widget_name: Name of the widget to be maximized.
+ * @error: Error propagation object.
+ *
+ * Maximizes a widget so it will occupy all the possible space.
+ */
+void anjuta_shell_maximize_widget (AnjutaShell *shell,
+ const char *widget_name,
+ GError **error)
+{
+ ANJUTA_SHELL_GET_IFACE (shell)->maximize_widget (shell, widget_name, error);
+}
+
+/**
+ * anjuta_shell_unmaximize:
+ * @shell: A #AnjutaShell interface.
+ * @error: Error propagation object.
+ *
+ * Unmaximizes the UI which was previously maximized by
+ * #anjuta_shell_maximize_widget
+ */
+void anjuta_shell_unmaximize (AnjutaShell *shell,
+ GError **error)
+{
+ ANJUTA_SHELL_GET_IFACE (shell)->unmaximize (shell, error);
+}
+
+/**
* anjuta_shell_add_value:
* @shell: A #AnjutaShell interface
* @name: Name of the value
diff --git a/libanjuta/anjuta-shell.h b/libanjuta/anjuta-shell.h
index 7cc5d76..bed4d8f 100644
--- a/libanjuta/anjuta-shell.h
+++ b/libanjuta/anjuta-shell.h
@@ -105,6 +105,21 @@ struct _AnjutaShellIface {
void (*present_widget) (AnjutaShell *shell,
GtkWidget *widget,
GError **error);
+
+ void (*iconify_dockable_widget) (AnjutaShell *shell,
+ GtkWidget *widget,
+ GError **error);
+ void (*hide_dockable_widget) (AnjutaShell *shell,
+ GtkWidget *widget,
+ GError **error);
+ void (*show_dockable_widget) (AnjutaShell *shell,
+ GtkWidget *widget,
+ GError **error);
+ void (*maximize_widget) (AnjutaShell *shell,
+ const char *widget_name,
+ GError **error);
+ void (*unmaximize) (AnjutaShell *shell,
+ GError **error);
void (*add_value) (AnjutaShell *shell,
const char *name,
const GValue *value,
@@ -174,6 +189,20 @@ void anjuta_shell_remove_widget (AnjutaShell *shell,
void anjuta_shell_present_widget (AnjutaShell *shell,
GtkWidget *widget,
GError **error);
+void anjuta_shell_iconify_dockable_widget (AnjutaShell *shell,
+ GtkWidget *widget,
+ GError **error);
+void anjuta_shell_hide_dockable_widget (AnjutaShell *shell,
+ GtkWidget *widget,
+ GError **error);
+void anjuta_shell_show_dockable_widget (AnjutaShell *shell,
+ GtkWidget *widget,
+ GError **error);
+void anjuta_shell_maximize_widget (AnjutaShell *shell,
+ const char *widget_name,
+ GError **error);
+void anjuta_shell_unmaximize (AnjutaShell *shell,
+ GError **error);
void anjuta_shell_add_value (AnjutaShell *shell,
const char *name,
const GValue *value,
diff --git a/src/anjuta-app.c b/src/anjuta-app.c
index 60540c3..9bce842 100644
--- a/src/anjuta-app.c
+++ b/src/anjuta-app.c
@@ -112,6 +112,141 @@ disconnect_proxy_cb (GtkUIManager *manager,
}
}
+static void
+anjuta_app_iconify_dockable_widget (AnjutaShell *shell, GtkWidget *widget,
+ GError **error)
+{
+ AnjutaApp *app = NULL;
+ GtkWidget *dock_item = NULL;
+
+ /* Argumments assertions */
+ g_return_if_fail (ANJUTA_IS_APP (shell));
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ app = ANJUTA_APP (shell);
+ g_return_if_fail (app->widgets != NULL);
+
+ dock_item = g_object_get_data (G_OBJECT (widget), "dockitem");
+ g_return_if_fail (dock_item != NULL);
+
+ /* Iconify the dockable item */
+ gdl_dock_item_iconify_item (GDL_DOCK_ITEM (dock_item));
+}
+
+static void
+anjuta_app_hide_dockable_widget (AnjutaShell *shell, GtkWidget *widget,
+ GError **error)
+{
+ AnjutaApp *app = NULL;
+ GtkWidget *dock_item = NULL;
+
+ /* Argumments assertions */
+ g_return_if_fail (ANJUTA_IS_APP (shell));
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ app = ANJUTA_APP (shell);
+ g_return_if_fail (app->widgets != NULL);
+
+ dock_item = g_object_get_data (G_OBJECT (widget), "dockitem");
+ g_return_if_fail (dock_item != NULL);
+
+ /* Hide the dockable item */
+ gdl_dock_item_iconify_item (GDL_DOCK_ITEM (dock_item));
+}
+
+static void
+anjuta_app_show_dockable_widget (AnjutaShell *shell, GtkWidget* widget,
+ GError **error)
+{
+ AnjutaApp *app = NULL;
+ GtkWidget *dock_item = NULL;
+
+ /* Argumments assertions */
+ g_return_if_fail (ANJUTA_IS_APP (shell));
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ app = ANJUTA_APP (shell);
+ g_return_if_fail (app->widgets != NULL);
+
+ dock_item = g_object_get_data (G_OBJECT (widget), "dockitem");
+ g_return_if_fail (dock_item != NULL);
+
+ /* Show the dockable item */
+ gdl_dock_item_show_item(GDL_DOCK_ITEM (dock_item));
+}
+
+static void
+anjuta_app_maximize_widget (AnjutaShell *shell,
+ const char *widget_name,
+ GError **error)
+{
+ AnjutaApp *app = NULL;
+ GtkWidget *dock_item = NULL;
+ gpointer value, key;
+ GtkWidget *widget = NULL;
+ GHashTableIter iter;
+
+ /* AnjutaApp assertions */
+ g_return_if_fail (ANJUTA_IS_APP (shell));
+ app = ANJUTA_APP (shell);
+
+ /* If app->maximized is TRUE then another widget is already maximized.
+ Restoring the UI for a new maximization. */
+ if(app->maximized)
+ gdl_dock_layout_load_layout (app->layout_manager, "back-up");
+
+ /* Back-up the layout so it can be restored */
+ gdl_dock_layout_save_layout(app->layout_manager, "back-up");
+
+ /* Mark the app as maximized (the other widgets except center are hidden) */
+ app->maximized = TRUE;
+
+ /* Hide all DockItem's except the ones positioned in the center */
+ g_hash_table_iter_init (&iter, app->widgets);
+ while (g_hash_table_iter_next (&iter, &key, &value))
+ {
+ if (value == NULL)
+ continue;
+
+ /* If it's the widget requesting maximization then continue */
+ if(!g_strcmp0((gchar*)key, widget_name))
+ continue;
+
+ /* Widget assertions */
+ widget = GTK_WIDGET (value);
+ if(!GTK_IS_WIDGET (widget))
+ continue;
+
+ /* DockItem assertions */
+ dock_item = g_object_get_data (G_OBJECT (widget), "dockitem");
+ if(dock_item == NULL || !GDL_IS_DOCK_ITEM (dock_item))
+ continue;
+
+ /* Hide the item */
+ gdl_dock_item_hide_item (GDL_DOCK_ITEM (dock_item));
+ }
+}
+
+static void
+anjuta_app_unmaximize (AnjutaShell *shell,
+ GError **error)
+{
+ AnjutaApp *app = NULL;
+
+ /* AnjutaApp assertions */
+ g_return_if_fail (ANJUTA_IS_APP (shell));
+ app = ANJUTA_APP (shell);
+
+ /* If not maximized then the operation doesn't make sence. */
+ g_return_if_fail (app->maximized);
+
+ /* Load the backed-up layout */
+ gdl_dock_layout_load_layout (app->layout_manager, "back-up");
+ gdl_dock_layout_delete_layout (app->layout_manager, "back-up");
+
+ /* Un-mark maximized */
+ app->maximized = FALSE;
+}
static void
on_toolbar_style_changed (AnjutaPreferences* prefs,
@@ -420,6 +555,7 @@ anjuta_app_instance_init (AnjutaApp *app)
app->values = NULL;
app->widgets = NULL;
+ app->maximized = FALSE;
/* Status bar */
app->status = ANJUTA_STATUS (anjuta_status_new ());
@@ -702,6 +838,11 @@ anjuta_app_layout_save (AnjutaApp *app, const gchar *filename,
g_return_if_fail (ANJUTA_IS_APP (app));
g_return_if_fail (filename != NULL);
+ /* If maximized, the layout should be loaded from the back-up first */
+ if(app->maximized)
+ gdl_dock_layout_load_layout (app->layout_manager, "back-up");
+
+ /* Continue with the saving */
gdl_dock_layout_save_layout (app->layout_manager, name);
if (!gdl_dock_layout_save_to_file (app->layout_manager, filename))
g_warning ("Saving dock layout to '%s' failed!", filename);
@@ -969,7 +1110,6 @@ anjuta_app_setup_widget (AnjutaApp* app,
{
GtkCheckMenuItem* menuitem;
-
/* Add the widget to hash */
if (app->widgets == NULL)
{
@@ -1210,6 +1350,11 @@ anjuta_shell_iface_init (AnjutaShellIface *iface)
iface->add_widget_custom = anjuta_app_add_widget_custom;
iface->remove_widget = anjuta_app_remove_widget;
iface->present_widget = anjuta_app_present_widget;
+ iface->iconify_dockable_widget = anjuta_app_iconify_dockable_widget;
+ iface->hide_dockable_widget = anjuta_app_hide_dockable_widget;
+ iface->show_dockable_widget = anjuta_app_show_dockable_widget;
+ iface->maximize_widget = anjuta_app_maximize_widget;
+ iface->unmaximize = anjuta_app_unmaximize;
iface->add_value = anjuta_app_add_value;
iface->get_value = anjuta_app_get_value;
iface->remove_value = anjuta_app_remove_value;
diff --git a/src/anjuta-app.h b/src/anjuta-app.h
index 183e0ec..b9fced6 100644
--- a/src/anjuta-app.h
+++ b/src/anjuta-app.h
@@ -50,6 +50,7 @@ struct _AnjutaApp
GHashTable *values;
GHashTable *widgets;
+ gboolean maximized;
GtkAccelGroup *accel_group;
diff --git a/src/shell.c b/src/shell.c
index 89cb644..bc8a8be 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -233,6 +233,50 @@ anjuta_test_shell_get_value (AnjutaShell *shell,
}
}
+static void
+anjuta_test_shell_iconify_dockable_widget (AnjutaShell *shell,
+ GtkWidget *widget,
+ GError **error)
+{
+ /* Not implemented. */
+ return;
+}
+
+static void
+anjuta_test_shell_hide_dockable_widget (AnjutaShell *shell,
+ GtkWidget *widget,
+ GError **error)
+{
+ /* Not implemented. */
+ return;
+}
+
+static void
+anjuta_test_shell_show_dockable_widget (AnjutaShell *shell,
+ GtkWidget *widget,
+ GError **error)
+{
+ /* Not implemented. */
+ return;
+}
+
+static void
+anjuta_test_shell_maximize_widget (AnjutaShell *shell,
+ const char *widget_name,
+ GError **error)
+{
+ /* Not implemented. */
+ return;
+}
+
+static void
+anjuta_test_shell_unmaximize (AnjutaShell *shell,
+ GError **error)
+{
+ /* Not implemented. */
+ return;
+}
+
static void
anjuta_test_shell_add_widget (AnjutaShell *shell,
GtkWidget *w,
@@ -402,6 +446,11 @@ anjuta_shell_iface_init (AnjutaShellIface *iface)
iface->add_widget_full = anjuta_test_shell_add_widget;
iface->remove_widget = anjuta_test_shell_remove_widget;
iface->present_widget = anjuta_test_shell_present_widget;
+ iface->iconify_dockable_widget = anjuta_test_shell_iconify_dockable_widget;
+ iface->hide_dockable_widget = anjuta_test_shell_hide_dockable_widget;
+ iface->show_dockable_widget = anjuta_test_shell_show_dockable_widget;
+ iface->maximize_widget = anjuta_test_shell_maximize_widget;
+ iface->unmaximize = anjuta_test_shell_unmaximize;
iface->add_value = anjuta_test_shell_add_value;
iface->get_value = anjuta_test_shell_get_value;
iface->remove_value = anjuta_test_shell_remove_value;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]