Commit e9c4d1f2 authored by Christian Hergert's avatar Christian Hergert
Browse files

panel: rebase IdeLayout and IdeLayoutPane on panel-gtk

Just in time for 3.20, we are landing the panel cleanup. This primarily
allows us to improve things for the dot releases without breaking ABI,
and additionally will fix a bunch of resize warnings introduced by gadgets
in GTK+.

To the user, things should be pretty much the same. However, we've laid
the groundwork to be able to incrementally add panel dragging and
reordering in upcoming releases.

Additionally, we'll be able to add a floating layer to the system in good
time (PnlDockOverlay).
parent 8cdac199
......@@ -51,14 +51,14 @@ layouttab:backdrop {
}
layoutpane > box.vertical:first-child > box.horizontal {
tabstrip {
background-color: #303535;
box-shadow: 0 4px 3px -5px #2c3030 inset,
0 -1px 0 #1c1f1f inset;
}
layoutpane:backdrop > box.vertical:first-child > box.horizontal {
tabstrip:backdrop {
box-shadow: 0 -1px 0 #2c3030 inset;
}
layoutpane stackswitcher button:checked {
tabstrip tab:checked {
box-shadow: 0 -2px 0 #215d9c inset;
}
dockbin {
border: 1px solid alpha(@borders, 0.75);
-PnlDockBin-handle-size: 1;
}
dockpaned {
border: 1px solid @borders;
}
tabstrip {
padding: 0 6px 0 6px;
}
tab {
background-image: none;
background-color: transparent;
border-color: transparent;
border-style: solid;
color: @theme_fg_color;
min-height: 39px;
outline-offset: -6px;
transition-duration: 200ms;
transition-timing-function: ease;
}
tab label {
font-size: 0.7em;
}
tab > * {
padding: 0 6px 0 6px;
}
dockoverlayedge {
background-color: @theme_bg_color;
}
dockoverlayedge tabstrip {
padding: 0;
border: none;
}
dockoverlayedge.left-edge tab:checked {
border-right-color: @theme_selected_bg_color;
border-bottom-color: transparent;
}
dockoverlayedge.right-edge tab:checked {
border-left-color: @theme_selected_bg_color;
border-bottom-color: transparent;
}
@import url("resource:///org/gnome/builder/theme/shared.css");
@import url("resource:///org/gnome/builder/theme/Adwaita-panels.css");
/*
......@@ -109,22 +110,7 @@ layouttab > box > button:last-child:backdrop image {
}
/*
* The following tweaks the layout panel headers
*/
layoutpane {
-IdeLayoutPane-handle-size: 1;
-gtk-icon-source: none;
}
layoutpane stackswitcher button {
min-width: 0;
border: none;
background: transparent;
box-shadow: none;
padding: 0 3px 0 3px;
border-radius: 0;
layout {
border: 1px solid alpha(@borders, 0.75);
-PnlDockBin-handle-size: 1;
}
layoutpane .pane-separator {
background-color: @borders;
}
......@@ -49,14 +49,14 @@ layouttab:backdrop {
}
layoutpane > box.vertical:first-child > box.horizontal {
tabstrip {
background-color: #d6d6d6;
box-shadow: 0 4px 3px -5px #aaa inset,
0 -1px 0 #a1a1a1 inset;
}
layoutpane:backdrop > box.vertical:first-child > box.horizontal {
tabstrip:backdrop {
box-shadow: 0 -1px 0 #a1a1a1 inset;
}
layoutpane stackswitcher button:checked {
tabstrip tab:checked {
box-shadow: 0 -2px 0 #4a90d9 inset;
}
......@@ -2,69 +2,61 @@
<interface>
<!-- interface-requires gtk+ 3.18 -->
<template class="IdeEditorPerspective" parent="IdeLayout">
<child internal-child="content_pane">
<object class="IdeLayoutPane">
<child internal-child="header">
<child type="center">
<object class="GtkStack" id="content_stack">
<property name="visible">true</property>
<child>
<object class="GtkBox">
<property name="visible">false</property>
</object>
</child>
<child internal-child="stack">
<object class="GtkStack" id="content_stack">
<property name="halign">center</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<property name="visible">true</property>
<child>
<object class="GtkImage">
<property name="icon-name">text-editor-symbolic</property>
<property name="pixel-size">128</property>
<property name="visible">true</property>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
<child>
<object class="GtkBox">
<property name="halign">center</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<object class="GtkLabel">
<property name="label" translatable="yes">No open files</property>
<property name="visible">true</property>
<child>
<object class="GtkImage">
<property name="icon-name">text-editor-symbolic</property>
<property name="pixel-size">128</property>
<property name="visible">true</property>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">No open files</property>
<property name="visible">true</property>
<style>
<class name="dim-label"/>
</style>
<attributes>
<attribute name="scale" value="2.0"/>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Try opening a file by typing in the search box at the top</property>
<property name="wrap">true</property>
<property name="visible">true</property>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
<style>
<class name="dim-label"/>
</style>
<attributes>
<attribute name="scale" value="2.0"/>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="name">empty_state</property>
</packing>
</child>
<child>
<object class="IdeLayoutGrid" id="grid">
<object class="GtkLabel">
<property name="label" translatable="yes">Try opening a file by typing in the search box at the top</property>
<property name="wrap">true</property>
<property name="visible">true</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="name">grid</property>
</packing>
</child>
</object>
<packing>
<property name="name">empty_state</property>
</packing>
</child>
<child>
<object class="IdeLayoutGrid" id="grid">
<property name="visible">true</property>
</object>
<packing>
<property name="name">grid</property>
</packing>
</child>
</object>
</child>
......@@ -80,7 +72,7 @@
</style>
<child>
<object class="GtkToggleButton">
<property name="action-name">panels.left</property>
<property name="action-name">dockbin.left-visible</property>
<property name="tooltip-text" translatable="yes">Enable / Disable left panel. Shortcut: F9</property>
<property name="focus-on-click">false</property>
<property name="visible">true</property>
......@@ -97,7 +89,7 @@
</child>
<child>
<object class="GtkToggleButton">
<property name="action-name">panels.bottom</property>
<property name="action-name">dockbin.bottom-visible</property>
<property name="tooltip-text" translatable="yes">Enable / Disable bottom panel. Shortcut: Ctrl + F9</property>
<property name="focus-on-click">false</property>
<property name="visible">true</property>
......@@ -114,7 +106,7 @@
</child>
<child>
<object class="GtkToggleButton">
<property name="action-name">panels.right</property>
<property name="action-name">dockbin.right-visible</property>
<property name="tooltip-text" translatable="yes">Enable / Disable right panel. Shortcut: Shift + F9</property>
<property name="focus-on-click">false</property>
<property name="visible">true</property>
......
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.16 -->
<template class="IdeLayoutPane" parent="GtkBin">
<template class="IdeLayoutPane" parent="PnlDockBinEdge">
<child>
<object class="GtkBox" id="box">
<property name="orientation">vertical</property>
<object class="PnlDockStack" id="dock_stack">
<property name="expand">true</property>
<property name="visible">true</property>
<child>
<object class="GtkBox" id="header">
<property name="visible">true</property>
<property name="vexpand">false</property>
<child type="center">
<object class="GtkStackSwitcher" id="stack_switcher">
<property name="stack">stack</property>
<property name="visible">true</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkStack" id="stack">
<property name="transition-duration">150</property>
<property name="transition-type">crossfade</property>
<property name="expand">true</property>
<property name="homogeneous">false</property>
<property name="visible">true</property>
</object>
</child>
</object>
</child>
</template>
......
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.8 -->
<template class="IdeLayout" parent="GtkOverlay">
<child type="overlay">
<object class="IdeLayoutPane" id="left_pane">
<property name="position">left</property>
<property name="visible">true</property>
</object>
</child>
<child type="overlay">
<object class="IdeLayoutPane" id="right_pane">
<property name="position">right</property>
<property name="visible">true</property>
</object>
</child>
<child type="overlay">
<object class="IdeLayoutPane" id="bottom_pane">
<property name="position">bottom</property>
<property name="visible">true</property>
</object>
</child>
<child type="overlay">
<object class="IdeLayoutPane" id="content_pane">
<property name="position">top</property>
<property name="visible">true</property>
</object>
</child>
</template>
</interface>
......@@ -976,10 +976,6 @@ ide_language_defaults_init_finish
IDE_TYPE_LAYOUT
IdeLayoutClass
ide_layout_new
ide_layout_get_left_pane
ide_layout_get_right_pane
ide_layout_get_bottom_pane
ide_layout_get_content_pane
ide_layout_get_active_view
IdeLayout
</SECTION>
......
......@@ -446,9 +446,11 @@ libide_1_0_la_includes = \
-I$(top_srcdir)/contrib/egg \
-I$(top_srcdir)/contrib/gd \
-I$(top_srcdir)/contrib/nautilus \
-I$(top_srcdir)/contrib/pnl \
-I$(top_srcdir)/contrib/search \
-I$(top_srcdir)/contrib/tmpl \
-I$(top_srcdir)/contrib/xml \
-I$(top_builddir)/contrib/pnl \
-I$(top_builddir)/contrib/tmpl \
-I$(top_builddir)/data/icons/hicolor \
-I$(srcdir) \
......@@ -500,6 +502,7 @@ libide_1_0_la_LIBADD = \
$(top_builddir)/contrib/egg/libegg-private.la \
$(top_builddir)/contrib/gd/libgd.la \
$(top_builddir)/contrib/nautilus/libnautilus.la \
$(top_builddir)/contrib/pnl/libpanel-gtk.la \
$(top_builddir)/contrib/search/libsearch.la \
$(top_builddir)/contrib/tmpl/libtemplate-glib-1.0.la \
$(top_builddir)/contrib/xml/libxml.la \
......@@ -577,6 +580,7 @@ INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) --warn-all
INTROSPECTION_COMPILER_ARGS = \
--includedir=$(srcdir) \
--includedir=$(top_builddir)/contrib/egg \
--includedir=$(top_builddir)/contrib/pnl \
--includedir=$(top_builddir)/contrib/tmpl
introspection_sources = \
......@@ -596,6 +600,7 @@ Ide_1_0_gir_LIBS = \
Ide_1_0_gir_FILES = $(introspection_sources)
Ide_1_0_gir_SCANNERFLAGS = \
--include-uninstalled=$(top_builddir)/contrib/egg/Egg-1.0.gir \
--include-uninstalled=$(top_builddir)/contrib/pnl/Pnl-1.0.gir \
--include-uninstalled=$(top_builddir)/contrib/tmpl/Template-1.0.gir \
--c-include="ide.h" \
-n Ide \
......@@ -624,15 +629,18 @@ libide_1_0_vapi_DEPS = \
gtk+-3.0 \
gtksourceview-3.0 \
libpeas-1.0 \
panel-gtk \
template-glib-1.0 \
egg-private
libide_1_0_vapi_METADATADIRS = $(srcdir)
libide_1_0_vapi_FILES = Ide-1.0.gir
libide_1_0_vapi_VAPIDIRS = \
$(top_builddir)/contrib/egg \
$(top_builddir)/contrib/pnl \
$(top_builddir)/contrib/tmpl
libide_1_0_vapi_GIRDIRS = \
$(top_builddir)/contrib/egg \
$(top_builddir)/contrib/pnl \
$(top_builddir)/contrib/tmpl
libide-1.0.deps: Makefile
......
......@@ -76,29 +76,23 @@ ide_editor_perspective_restore_panel_state (IdeEditorPerspective *self)
settings = g_settings_new ("org.gnome.builder.workbench");
pane = ide_layout_get_left_pane (IDE_LAYOUT (self));
pane = pnl_dock_bin_get_left_edge (PNL_DOCK_BIN (self));
reveal = g_settings_get_boolean (settings, "left-visible");
position = g_settings_get_int (settings, "left-position");
gtk_container_child_set (GTK_CONTAINER (self), pane,
"position", position,
"reveal", reveal,
NULL);
pnl_dock_revealer_set_reveal_child (PNL_DOCK_REVEALER (pane), reveal);
pnl_dock_revealer_set_position (PNL_DOCK_REVEALER (pane), position);
pane = ide_layout_get_right_pane (IDE_LAYOUT (self));
pane = pnl_dock_bin_get_right_edge (PNL_DOCK_BIN (self));
reveal = g_settings_get_boolean (settings, "right-visible");
position = g_settings_get_int (settings, "right-position");
gtk_container_child_set (GTK_CONTAINER (self), pane,
"position", position,
"reveal", reveal,
NULL);
pnl_dock_revealer_set_reveal_child (PNL_DOCK_REVEALER (pane), reveal);
pnl_dock_revealer_set_position (PNL_DOCK_REVEALER (pane), position);
pane = ide_layout_get_bottom_pane (IDE_LAYOUT (self));
pane = pnl_dock_bin_get_bottom_edge (PNL_DOCK_BIN (self));
reveal = g_settings_get_boolean (settings, "bottom-visible");
position = g_settings_get_int (settings, "bottom-position");
gtk_container_child_set (GTK_CONTAINER (self), pane,
"position", position,
"reveal", reveal,
NULL);
pnl_dock_revealer_set_reveal_child (PNL_DOCK_REVEALER (pane), reveal);
pnl_dock_revealer_set_position (PNL_DOCK_REVEALER (pane), position);
}
static void
......@@ -113,27 +107,21 @@ ide_editor_perspective_save_panel_state (IdeEditorPerspective *self)
settings = g_settings_new ("org.gnome.builder.workbench");
pane = ide_layout_get_left_pane (IDE_LAYOUT (self));
gtk_container_child_get (GTK_CONTAINER (IDE_LAYOUT (self)), pane,
"reveal", &reveal,
"position", &position,
NULL);
pane = pnl_dock_bin_get_left_edge (PNL_DOCK_BIN (self));
position = pnl_dock_revealer_get_position (PNL_DOCK_REVEALER (pane));
reveal = pnl_dock_revealer_get_reveal_child (PNL_DOCK_REVEALER (pane));
g_settings_set_boolean (settings, "left-visible", reveal);
g_settings_set_int (settings, "left-position", position);
pane = ide_layout_get_right_pane (IDE_LAYOUT (self));
gtk_container_child_get (GTK_CONTAINER (IDE_LAYOUT (self)), pane,
"reveal", &reveal,
"position", &position,
NULL);
pane = pnl_dock_bin_get_right_edge (PNL_DOCK_BIN (self));
position = pnl_dock_revealer_get_position (PNL_DOCK_REVEALER (pane));
reveal = pnl_dock_revealer_get_reveal_child (PNL_DOCK_REVEALER (pane));
g_settings_set_boolean (settings, "right-visible", reveal);
g_settings_set_int (settings, "right-position", position);
pane = ide_layout_get_bottom_pane (IDE_LAYOUT (self));
gtk_container_child_get (GTK_CONTAINER (IDE_LAYOUT (self)), pane,
"reveal", &reveal,
"position", &position,
NULL);
pane = pnl_dock_bin_get_bottom_edge (PNL_DOCK_BIN (self));
position = pnl_dock_revealer_get_position (PNL_DOCK_REVEALER (pane));
reveal = pnl_dock_revealer_get_reveal_child (PNL_DOCK_REVEALER (pane));
g_settings_set_boolean (settings, "bottom-visible", reveal);
g_settings_set_int (settings, "bottom-position", position);
}
......@@ -441,8 +429,8 @@ ide_editor_perspective_init (IdeEditorPerspective *self)
g_action_map_add_action_entries (G_ACTION_MAP (self->actions), entries,
G_N_ELEMENTS (entries), self);
actions = gtk_widget_get_action_group (GTK_WIDGET (self), "panels");
gtk_widget_insert_action_group (GTK_WIDGET (self->titlebar), "panels", actions);
actions = gtk_widget_get_action_group (GTK_WIDGET (self), "dockbin");
gtk_widget_insert_action_group (GTK_WIDGET (self->titlebar), "dockbin", actions);
ide_editor_perspective_restore_panel_state (self);
......
......@@ -33,6 +33,7 @@
struct _IdeEditorWorkbenchAddin
{
GObject parent_instance;
PnlDockManager *manager;
IdeEditorPerspective *perspective;
IdeWorkbench *workbench;
};
......@@ -65,7 +66,10 @@ ide_editor_workbench_addin_load (IdeWorkbenchAddin *addin,
self->workbench = workbench;
self->manager = pnl_dock_manager_new ();
self->perspective = g_object_new (IDE_TYPE_EDITOR_PERSPECTIVE,
"manager", self->manager,
"visible", TRUE,
NULL);
ide_workbench_add_perspective (workbench, IDE_PERSPECTIVE (self->perspective));
......@@ -90,6 +94,8 @@ ide_editor_workbench_addin_unload (IdeWorkbenchAddin *addin,
self->workbench = NULL;
ide_workbench_remove_perspective (workbench, perspective);
g_clear_object (&self->manager);
}
static gboolean
......
......@@ -309,9 +309,9 @@ ide_application_actions_init (IdeApplication *self)
/*
* FIXME: Once we get a new shortcuts engine, port these to that.
*/
gtk_application_set_accels_for_action (GTK_APPLICATION (self), "panels.left", left);
gtk_application_set_accels_for_action (GTK_APPLICATION (self), "panels.right", right);
gtk_application_set_accels_for_action (GTK_APPLICATION (self), "panels.bottom", bottom);
gtk_application_set_accels_for_action (GTK_APPLICATION (self), "dockbin.left-visible", left);
gtk_application_set_accels_for_action (GTK_APPLICATION (self), "dockbin.right-visible", right);
gtk_application_set_accels_for_action (GTK_APPLICATION (self), "dockbin.bottom-visible", bottom);
gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.preferences", preferences);
gtk_application_set_accels_for_action (GTK_APPLICATION (self), "perspective.global-search", global_search);
gtk_application_set_accels_for_action (GTK_APPLICATION (self), "perspective.new-file", new_file);
......
......@@ -27,154 +27,29 @@
struct _IdeLayoutPane
{
GtkBin parent_instance;
GtkBox *box;
GtkBox *header;
GtkStackSwitcher *stack_switcher;
GtkStack *stack;
PnlDockBinEdge parent_instance;
EggSignalGroup *toplevel_signals;
gulong notify_stack_signal_handler;
GdkRectangle handle_pos;
GtkPositionType position;
PnlDockStack *dock_stack;
};
G_DEFINE_TYPE (IdeLayoutPane, ide_layout_pane, GTK_TYPE_BIN)
enum {
PROP_0,
PROP_POSITION,
LAST_PROP
};
enum {
STYLE_PROP_0,
STYLE_PROP_HANDLE_SIZE,
LAST_STYLE_PROP
};
static GParamSpec *properties [LAST_PROP];
static GParamSpec *styleParamSpecs [LAST_STYLE_PROP];
static gboolean
ide_layout_pane_draw (GtkWidget *widget,
cairo_t *cr)
{
IdeLayoutPane *self = (IdeLayoutPane *)widget;
GtkStyleContext *style_context;
gboolean ret;
g_assert (IDE_IS_LAYOUT_PANE (self));
g_assert (cr != NULL);
ret = GTK_WIDGET_CLASS (ide_layout_pane_parent_class)->draw (widget, cr);
style_context = gtk_widget_get_style_context (widget);
gtk_style_context_save (style_context);
gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_PANE_SEPARATOR);
gtk_render_handle (style_context, cr,
self->handle_pos.x,
self->handle_pos.y,
self->handle_pos.width,
self->handle_pos.height);
gtk_style_context_restore (style_context);
return ret;
}
G_DEFINE_TYPE (IdeLayoutPane, ide_layout_pane, PNL_TYPE_DOCK_BIN_EDGE)
static void
ide_layout_pane_size_allocate (GtkWidget *widget,
GtkAllocation *alloc)
ide_layout_pane_add (GtkContainer *container,
GtkWidget *widget)
{
IdeLayoutPane *self = (IdeLayoutPane *)widget;
GtkWidget *child;
GtkAllocation child_alloc;
gint handle_size;
IdeLayoutPane *self = (IdeLayoutPane *)container;