[gnome-builder] layout-stack: add ide_layout_stack_add_control()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] layout-stack: add ide_layout_stack_add_control()
- Date: Wed, 20 Jul 2016 02:08:18 +0000 (UTC)
commit 84397191831bf7893d42ecd711184473c15b75b9
Author: Christian Hergert <chergert redhat com>
Date: Tue Jul 19 18:25:50 2016 -0700
layout-stack: add ide_layout_stack_add_control()
This API should be used to add controls to the tab instead of using
IdeLayoutView.get_controls(). See IdeLayoutStackAddin for a convenient
way to add controls to the stack.
libide/workbench/ide-layout-stack.c | 20 ++++++++++
libide/workbench/ide-layout-stack.h | 3 ++
libide/workbench/ide-layout-tab-bar-private.h | 46 ++++++++++++++++++++++++
libide/workbench/ide-layout-tab-bar.c | 17 +--------
libide/workbench/ide-layout-tab-private.h | 47 +++++++++++++++++++++++++
libide/workbench/ide-layout-tab.c | 42 +++-------------------
libide/workbench/ide-layout-tab.ui | 2 +-
7 files changed, 123 insertions(+), 54 deletions(-)
---
diff --git a/libide/workbench/ide-layout-stack.c b/libide/workbench/ide-layout-stack.c
index a94e8fc..1b4ba28 100644
--- a/libide/workbench/ide-layout-stack.c
+++ b/libide/workbench/ide-layout-stack.c
@@ -34,7 +34,10 @@
#include "workbench/ide-layout-stack-addin.h"
#include "workbench/ide-layout-stack-private.h"
#include "workbench/ide-layout-stack-split.h"
+#include "workbench/ide-layout-tab.h"
+#include "workbench/ide-layout-tab-private.h"
#include "workbench/ide-layout-tab-bar.h"
+#include "workbench/ide-layout-tab-bar-private.h"
#include "workbench/ide-layout-view.h"
#include "workbench/ide-workbench.h"
@@ -660,3 +663,20 @@ ide_layout_stack_foreach_view (IdeLayoutStack *self,
gtk_container_foreach (GTK_CONTAINER (self->stack), callback, user_data);
}
+
+void
+ide_layout_stack_add_control (IdeLayoutStack *self,
+ GtkWidget *widget,
+ gint priority)
+{
+ GtkContainer *container;
+
+ g_return_if_fail (IDE_IS_LAYOUT_STACK (self));
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ container = GTK_CONTAINER (self->tab_bar->tab->controls_container);
+
+ gtk_container_add_with_properties (container, widget,
+ "priority", priority,
+ NULL);
+}
diff --git a/libide/workbench/ide-layout-stack.h b/libide/workbench/ide-layout-stack.h
index 7b4a3f9..38bf9f2 100644
--- a/libide/workbench/ide-layout-stack.h
+++ b/libide/workbench/ide-layout-stack.h
@@ -30,6 +30,9 @@ G_DECLARE_FINAL_TYPE (IdeLayoutStack, ide_layout_stack, IDE, LAYOUT_STACK, GtkBi
GtkWidget *ide_layout_stack_new (void);
void ide_layout_stack_remove (IdeLayoutStack *self,
GtkWidget *view);
+void ide_layout_stack_add_control (IdeLayoutStack *self,
+ GtkWidget *control,
+ gint priority);
GtkWidget *ide_layout_stack_get_active_view (IdeLayoutStack *self);
void ide_layout_stack_set_active_view (IdeLayoutStack *self,
GtkWidget *active_view);
diff --git a/libide/workbench/ide-layout-tab-bar-private.h b/libide/workbench/ide-layout-tab-bar-private.h
new file mode 100644
index 0000000..b42333d
--- /dev/null
+++ b/libide/workbench/ide-layout-tab-bar-private.h
@@ -0,0 +1,46 @@
+/* ide-layout-tab-bar-private.h
+ *
+ * Copyright (C) 2016 Christian Hergert <chergert redhat com>
+ *
+ * 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 IDE_LAYOUT_TAB_BAR_PRIVATE_H
+#define IDE_LAYOUT_TAB_BAR_PRIVATE_H
+
+#include <gtk/gtk.h>
+
+#include "ide-layout-tab.h"
+
+G_BEGIN_DECLS
+
+struct _IdeLayoutTabBar
+{
+ GtkEventBox parent_instance;
+
+ gulong set_focus_handler;
+
+ guint child_count;
+
+ IdeLayoutTab *tab;
+ GtkWidget *tab_expander;
+ GtkMenuButton *views_list_button;
+ GtkStack *stack;
+ GtkListBox *views_list_box;
+ GtkPopover *views_list_popover;
+};
+
+G_END_DECLS
+
+#endif /* IDE_LAYOUT_TAB_BAR_PRIVATE_H */
diff --git a/libide/workbench/ide-layout-tab-bar.c b/libide/workbench/ide-layout-tab-bar.c
index 89071b6..68c71b6 100644
--- a/libide/workbench/ide-layout-tab-bar.c
+++ b/libide/workbench/ide-layout-tab-bar.c
@@ -21,27 +21,12 @@
#include "util/ide-gtk.h"
#include "workbench/ide-layout-stack.h"
#include "workbench/ide-layout-tab-bar.h"
+#include "workbench/ide-layout-tab-bar-private.h"
#include "workbench/ide-layout-tab.h"
#include "workbench/ide-layout-view.h"
#include "workbench/ide-workbench-private.h"
#include "workbench/ide-workbench.h"
-struct _IdeLayoutTabBar
-{
- GtkEventBox parent_instance;
-
- gulong set_focus_handler;
-
- guint child_count;
-
- IdeLayoutTab *tab;
- GtkWidget *tab_expander;
- GtkMenuButton *views_list_button;
- GtkStack *stack;
- GtkListBox *views_list_box;
- GtkPopover *views_list_popover;
-};
-
G_DEFINE_TYPE (IdeLayoutTabBar, ide_tab_layout_bar, GTK_TYPE_EVENT_BOX)
enum {
diff --git a/libide/workbench/ide-layout-tab-private.h b/libide/workbench/ide-layout-tab-private.h
new file mode 100644
index 0000000..2a511dc
--- /dev/null
+++ b/libide/workbench/ide-layout-tab-private.h
@@ -0,0 +1,47 @@
+/* ide-layout-tab-private.h
+ *
+ * Copyright (C) 2016 Christian Hergert <chergert redhat com>
+ *
+ * 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 IDE_LAYOUT_TAB_PRIVATE_H
+#define IDE_LAYOUT_TAB_PRIVATE_H
+
+#include <gtk/gtk.h>
+
+#include "ide-layout-view.h"
+
+G_BEGIN_DECLS
+
+struct _IdeLayoutTab
+{
+ GtkEventBox parent_instance;
+
+ IdeLayoutView *view;
+ GBinding *modified_binding;
+ GBinding *title_binding;
+
+ GtkWidget *backward_button;
+ GtkWidget *controls_container;
+ GtkWidget *close_button;
+ GtkWidget *forward_button;
+ GtkWidget *modified_label;
+ GtkWidget *title_menu_button;
+ GtkWidget *title_label;
+};
+
+G_END_DECLS
+
+#endif /* IDE_LAYOUT_TAB_PRIVATE_H */
diff --git a/libide/workbench/ide-layout-tab.c b/libide/workbench/ide-layout-tab.c
index 9eb39db..110cfe4 100644
--- a/libide/workbench/ide-layout-tab.c
+++ b/libide/workbench/ide-layout-tab.c
@@ -18,28 +18,14 @@
#define G_LOG_DOMAIN "ide-layout-tab"
+#include <egg-priority-box.h>
+
#include "ide-macros.h"
#include "application/ide-application.h"
#include "workbench/ide-layout-view.h"
#include "workbench/ide-layout-tab.h"
-
-struct _IdeLayoutTab
-{
- GtkEventBox parent_instance;
-
- IdeLayoutView *view;
- GBinding *modified_binding;
- GBinding *title_binding;
-
- GtkWidget *backward_button;
- GtkWidget *controls_container;
- GtkWidget *close_button;
- GtkWidget *forward_button;
- GtkWidget *modified_label;
- GtkWidget *title_menu_button;
- GtkWidget *title_label;
-};
+#include "workbench/ide-layout-tab-private.h"
G_DEFINE_TYPE (IdeLayoutTab, ide_layout_tab, GTK_TYPE_EVENT_BOX)
@@ -54,7 +40,6 @@ static GParamSpec *properties [LAST_PROP];
static void
ide_layout_tab_connect (IdeLayoutTab *self)
{
- GtkWidget *controls;
GBinding *binding;
g_assert (IDE_IS_LAYOUT_TAB (self));
@@ -69,10 +54,6 @@ ide_layout_tab_connect (IdeLayoutTab *self)
G_BINDING_SYNC_CREATE);
ide_set_weak_pointer (&self->modified_binding, binding);
- controls = ide_layout_view_get_controls (self->view);
- if (controls != NULL)
- gtk_container_add (GTK_CONTAINER (self->controls_container), controls);
-
g_signal_connect (self->view,
"destroy",
G_CALLBACK (gtk_widget_destroyed),
@@ -82,17 +63,6 @@ ide_layout_tab_connect (IdeLayoutTab *self)
}
static void
-ide_layout_tab_remove_control (GtkWidget *widget,
- gpointer user_data)
-{
- IdeLayoutTab *self = user_data;
-
- g_assert (IDE_IS_LAYOUT_TAB (self));
-
- gtk_container_remove (GTK_CONTAINER (self->controls_container), widget);
-}
-
-static void
ide_layout_tab_disconnect (IdeLayoutTab *self)
{
g_assert (IDE_IS_LAYOUT_TAB (self));
@@ -101,10 +71,6 @@ ide_layout_tab_disconnect (IdeLayoutTab *self)
G_CALLBACK (gtk_widget_destroyed),
&self->view);
- gtk_container_foreach (GTK_CONTAINER (self->controls_container),
- ide_layout_tab_remove_control,
- self);
-
if (self->title_binding)
{
g_binding_unbind (self->title_binding);
@@ -263,6 +229,8 @@ ide_layout_tab_class_init (IdeLayoutTabClass *klass)
gtk_widget_class_bind_template_child (widget_class, IdeLayoutTab, modified_label);
gtk_widget_class_bind_template_child (widget_class, IdeLayoutTab, title_label);
gtk_widget_class_bind_template_child (widget_class, IdeLayoutTab, title_menu_button);
+
+ g_type_ensure (EGG_TYPE_PRIORITY_BOX);
}
static void
diff --git a/libide/workbench/ide-layout-tab.ui b/libide/workbench/ide-layout-tab.ui
index 0560c98..4d7a473 100644
--- a/libide/workbench/ide-layout-tab.ui
+++ b/libide/workbench/ide-layout-tab.ui
@@ -103,7 +103,7 @@
</object>
</child>
<child>
- <object class="GtkBox" id="controls_container">
+ <object class="EggPriorityBox" id="controls_container">
<property name="hexpand">false</property>
<property name="visible">true</property>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]