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

wip on layout

parent 8f74bcfd
......@@ -33,7 +33,6 @@
#include "history/ide-back-forward-list.h"
#include "util/ide-dnd.h"
#include "util/ide-gtk.h"
#include "workbench/ide-layout-stack.h"
#include "workbench/ide-workbench.h"
#define MINIMAP_HIDE_DURATION 1000
......
......@@ -21,7 +21,7 @@
#include <gtk/gtk.h>
#include "workbench/ide-layout-stack-addin.h"
#include "layout/ide-layout-stack-addin.h"
G_BEGIN_DECLS
......
......@@ -29,9 +29,9 @@
#include "editor/ide-editor-perspective.h"
#include "editor/ide-editor-spell-widget.h"
#include "editor/ide-editor-view.h"
#include "layout/ide-layout-grid.h"
#include "layout/ide-layout-pane.h"
#include "util/ide-gtk.h"
#include "workbench/ide-layout-grid.h"
#include "workbench/ide-layout-pane.h"
#include "workbench/ide-workbench.h"
#include "workbench/ide-workbench-header-bar.h"
......@@ -357,10 +357,7 @@ ide_editor_perspective_add (GtkContainer *container,
if (IDE_IS_LAYOUT_VIEW (widget))
{
GtkWidget *last_focus;
last_focus = ide_layout_grid_get_last_focus (self->grid);
gtk_container_add (GTK_CONTAINER (last_focus), widget);
gtk_container_add (GTK_CONTAINER (self->grid), widget);
g_signal_connect_object (widget,
"destroy",
G_CALLBACK (ide_editor_perspective_view_destroyed),
......@@ -373,21 +370,6 @@ ide_editor_perspective_add (GtkContainer *container,
GTK_CONTAINER_CLASS (ide_editor_perspective_parent_class)->add (container, widget);
}
static void
ide_editor_perspective_grid_empty (IdeEditorPerspective *self,
IdeLayoutGrid *grid)
{
GtkWidget *stack;
g_assert (IDE_IS_EDITOR_PERSPECTIVE (self));
g_assert (IDE_IS_LAYOUT_GRID (grid));
stack = gtk_widget_get_ancestor (GTK_WIDGET (grid), GTK_TYPE_STACK);
if (stack != NULL)
gtk_stack_set_visible_child_name (GTK_STACK (stack), "empty_state");
}
static void
ide_editor_perspective_grab_focus (GtkWidget *widget)
{
......@@ -510,12 +492,6 @@ ide_editor_perspective_init (IdeEditorPerspective *self)
gtk_widget_init_template (GTK_WIDGET (self));
g_signal_connect_object (self->grid,
"empty",
G_CALLBACK (ide_editor_perspective_grid_empty),
self,
G_CONNECT_SWAPPED);
g_action_map_add_action_entries (G_ACTION_MAP (self->actions), entries,
G_N_ELEMENTS (entries), self);
......
......@@ -23,8 +23,8 @@
#include <gtk/gtk.h>
#include "diagnostics/ide-source-location.h"
#include "layout/ide-layout.h"
#include "sourceview/ide-source-view.h"
#include "workbench/ide-layout.h"
#include "workbench/ide-perspective.h"
G_BEGIN_DECLS
......
......@@ -26,7 +26,7 @@
#include "buffers/ide-buffer.h"
#include "editor/ide-editor-frame.h"
#include "editor/ide-editor-tweak-widget.h"
#include "workbench/ide-layout-view.h"
#include "layout/ide-layout-view.h"
G_BEGIN_DECLS
......
......@@ -26,6 +26,7 @@
#include "ide-macros.h"
#include "buffers/ide-buffer-manager.h"
#include "diagnostics/ide-source-location.h"
#include "editor/ide-editor-frame-private.h"
#include "editor/ide-editor-view-actions.h"
#include "editor/ide-editor-view-addin.h"
......
......@@ -20,8 +20,8 @@
#define IDE_EDITOR_VIEW_H
#include "buffers/ide-buffer.h"
#include "layout/ide-layout-view.h"
#include "sourceview/ide-source-view.h"
#include "workbench/ide-layout-view.h"
G_BEGIN_DECLS
......
/* ide-back-forward-controls.c
*
* Copyright (C) 2017 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/>.
*/
#define G_LOG_DOMAIN "ide-back-forward-controls"
#include <dazzle.h>
#include "ide-back-forward-controls.h"
struct _IdeBackForwardControls
{
GtkBox parent_instance;
GtkButton *previous_button;
GtkButton *next_button;
};
G_DEFINE_TYPE (IdeBackForwardControls, ide_back_forward_controls, GTK_TYPE_BOX)
static void
ide_back_forward_controls_class_init (IdeBackForwardControlsClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
gtk_widget_class_set_css_name (widget_class, "idebackforwardcontrols");
}
static void
ide_back_forward_controls_init (IdeBackForwardControls *self)
{
dzl_gtk_widget_add_style_class (GTK_WIDGET (self), "linked");
gtk_widget_set_sensitive (GTK_WIDGET (self), FALSE);
self->previous_button = g_object_new (GTK_TYPE_BUTTON,
"child", g_object_new (GTK_TYPE_IMAGE,
"icon-name", "pan-start-symbolic",
"visible", TRUE,
NULL),
"visible", TRUE,
NULL);
g_signal_connect (self->previous_button,
"destroy",
G_CALLBACK (gtk_widget_destroyed),
&self->previous_button);
gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (self->previous_button));
self->next_button = g_object_new (GTK_TYPE_BUTTON,
"child", g_object_new (GTK_TYPE_IMAGE,
"icon-name", "pan-end-symbolic",
"visible", TRUE,
NULL),
"visible", TRUE,
NULL);
g_signal_connect (self->next_button,
"destroy",
G_CALLBACK (gtk_widget_destroyed),
&self->next_button);
gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (self->next_button));
}
GtkWidget *
ide_back_forward_controls_new (void)
{
return g_object_new (IDE_TYPE_BACK_FORWARD_CONTROLS, NULL);
}
/* ide-layout-tab.h
/* ide-back-forward-controls.h
*
* Copyright (C) 2015 Christian Hergert <chergert@redhat.com>
* Copyright (C) 2017 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
......@@ -16,20 +16,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef IDE_LAYOUT_TAB_H
#define IDE_LAYOUT_TAB_H
#pragma once
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define IDE_TYPE_LAYOUT_TAB (ide_layout_tab_get_type())
#define IDE_TYPE_BACK_FORWARD_CONTROLS (ide_back_forward_controls_get_type())
G_DECLARE_FINAL_TYPE (IdeLayoutTab, ide_layout_tab, IDE, LAYOUT_TAB, GtkEventBox)
G_DECLARE_FINAL_TYPE (IdeBackForwardControls, ide_back_forward_controls, IDE, BACK_FORWARD_CONTROLS, GtkBox)
void ide_layout_tab_set_view (IdeLayoutTab *self,
GtkWidget *view);
GtkWidget *ide_back_forward_controls_new (void);
G_END_DECLS
#endif /* IDE_LAYOUT_TAB_H */
......@@ -19,7 +19,6 @@
#include "threading/ide-thread-pool.h"
#include "transfers/ide-transfer.h"
#include "vcs/ide-vcs-config.h"
#include "workbench/ide-layout-stack-split.h"
/*** END file-header ***/
......
......@@ -81,6 +81,7 @@ G_BEGIN_DECLS
#include "highlighting/ide-highlight-engine.h"
#include "highlighting/ide-highlight-index.h"
#include "highlighting/ide-highlighter.h"
#include "history/ide-back-forward-controls.h"
#include "history/ide-back-forward-item.h"
#include "history/ide-back-forward-list.h"
#include "langserv/ide-langserv-client.h"
......@@ -89,6 +90,14 @@ G_BEGIN_DECLS
#include "langserv/ide-langserv-rename-provider.h"
#include "langserv/ide-langserv-symbol-resolver.h"
#include "langserv/ide-langserv-util.h"
#include "layout/ide-layout-grid.h"
#include "layout/ide-layout-grid-column.h"
#include "layout/ide-layout-pane.h"
#include "layout/ide-layout-stack-addin.h"
#include "layout/ide-layout-stack-header.h"
#include "layout/ide-layout-stack.h"
#include "layout/ide-layout-view.h"
#include "layout/ide-layout.h"
#include "local/ide-local-device.h"
#include "logging/ide-log.h"
#include "preferences/ide-preferences-addin.h"
......@@ -150,11 +159,6 @@ G_BEGIN_DECLS
#include "vcs/ide-vcs-initializer.h"
#include "vcs/ide-vcs-uri.h"
#include "vcs/ide-vcs.h"
#include "workbench/ide-layout-grid.h"
#include "workbench/ide-layout-pane.h"
#include "workbench/ide-layout-stack.h"
#include "workbench/ide-layout-view.h"
#include "workbench/ide-layout.h"
#include "workbench/ide-perspective.h"
#include "workbench/ide-workbench-addin.h"
#include "workbench/ide-workbench-message.h"
......
/* ide-layout-grid-actions.c
*
* Copyright (C) 2017 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/>.
*/
#define G_LOG_DOMAIN "ide-layout-grid-actions"
#include "ide-layout-private.h"
static void
ide_layout_grid_action_close_stack (GSimpleAction *action,
GVariant *variant,
gpointer user_data)
{
IdeLayoutGrid *self = user_data;
g_assert (G_IS_SIMPLE_ACTION (action));
g_assert (IDE_IS_LAYOUT_GRID (self));
/*
* Clicking the close button should have caused the stack to become the
* current stack, so we can rely on that.
*/
_ide_layout_grid_close_current_stack (self);
}
static const GActionEntry grid_actions[] = {
{ "close-stack", ide_layout_grid_action_close_stack },
};
void
_ide_layout_grid_init_actions (IdeLayoutGrid *self)
{
g_autoptr(GSimpleActionGroup) group = NULL;
g_assert (IDE_IS_LAYOUT_GRID (self));
group = g_simple_action_group_new ();
g_action_map_add_action_entries (G_ACTION_MAP (group),
grid_actions,
G_N_ELEMENTS (grid_actions),
self);
gtk_widget_insert_action_group (GTK_WIDGET (self), "layoutgrid", G_ACTION_GROUP (group));
}
void
_ide_layout_grid_update_actions (IdeLayoutGrid *self)
{
gboolean enabled;
g_assert (IDE_IS_LAYOUT_GRID (self));
enabled = dzl_multi_paned_get_n_children (DZL_MULTI_PANED (self)) > 1;
dzl_gtk_widget_action_set (GTK_WIDGET (self), "layoutgrid", "close-stack",
"enabled", enabled,
NULL);
}
/* ide-layout-grid-column-actions.c
*
* Copyright (C) 2017 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/>.
*/
#define G_LOG_DOMAIN "ide-layout-grid-column-actions"
#include "ide-layout-private.h"
static void
ide_layout_grid_column_actions_close (GSimpleAction *action,
GVariant *variant,
gpointer user_data)
{
IdeLayoutGridColumn *self = user_data;
g_assert (G_IS_SIMPLE_ACTION (action));
g_assert (IDE_IS_LAYOUT_GRID_COLUMN (self));
_ide_layout_grid_column_try_close (self);
}
static const GActionEntry grid_column_actions[] = {
{ "close", ide_layout_grid_column_actions_close },
};
void
_ide_layout_grid_column_update_actions (IdeLayoutGridColumn *self)
{
GtkWidget *grid;
gboolean can_close;
g_assert (IDE_IS_LAYOUT_GRID_COLUMN (self));
grid = gtk_widget_get_parent (GTK_WIDGET (self));
if (grid == NULL || !IDE_IS_LAYOUT_GRID (grid))
{
g_warning ("Attempt to update actions in unowned grid column");
return;
}
can_close = (dzl_multi_paned_get_n_children (DZL_MULTI_PANED (grid)) > 1);
dzl_gtk_widget_action_set (GTK_WIDGET (self), "layoutgridcolumn", "close",
"enabled", can_close,
NULL);
}
void
_ide_layout_grid_column_init_actions (IdeLayoutGridColumn *self)
{
g_autoptr(GSimpleActionGroup) group = NULL;
g_assert (IDE_IS_LAYOUT_GRID_COLUMN (self));
group = g_simple_action_group_new ();
g_action_map_add_action_entries (G_ACTION_MAP (group),
grid_column_actions,
G_N_ELEMENTS (grid_column_actions),
self);
gtk_widget_insert_action_group (GTK_WIDGET (self),
"layoutgridcolumn",
G_ACTION_GROUP (group));
}
/* ide-layout-grid-column.c
*
* Copyright (C) 2017 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/>.
*/
#define G_LOG_DOMAIN "ide-layout-grid-column"
#include "ide-layout-grid-column.h"
#include "ide-layout-private.h"
#include "ide-layout-view.h"
struct _IdeLayoutGridColumn
{
DzlMultiPaned parent_instance;
GQueue focus_stack;
};
typedef struct
{
GList *stacks;
GTask *backpointer;
} TryCloseState;
G_DEFINE_TYPE (IdeLayoutGridColumn, ide_layout_grid_column, DZL_TYPE_MULTI_PANED)
static void ide_layout_grid_column_try_close_pump (GTask *task);
enum {
PROP_0,
PROP_CURRENT_STACK,
N_PROPS
};
static GParamSpec *properties [N_PROPS];
static void
try_close_state_free (gpointer data)
{
TryCloseState *state = data;
g_assert (state != NULL);
g_list_free_full (state->stacks, g_object_unref);
state->stacks = NULL;
state->backpointer = NULL;
g_slice_free (TryCloseState, state);
}
static void
ide_layout_grid_column_add (GtkContainer *container,
GtkWidget *widget)
{
IdeLayoutGridColumn *self = (IdeLayoutGridColumn *)container;
g_assert (IDE_IS_LAYOUT_GRID_COLUMN (self));
if (IDE_IS_LAYOUT_VIEW (widget))
{
GtkWidget *child;
g_assert (dzl_multi_paned_get_n_children (DZL_MULTI_PANED (container)) > 0);
child = dzl_multi_paned_get_nth_child (DZL_MULTI_PANED (container), 0);
gtk_container_add (GTK_CONTAINER (child), widget);
}
else if (IDE_IS_LAYOUT_STACK (widget))
{
g_queue_push_head (&self->focus_stack, widget);
GTK_CONTAINER_CLASS (ide_layout_grid_column_parent_class)->add (container, widget);
}
else
{
g_warning ("%s only supports adding IdeLayoutView or IdeLayoutStack",
G_OBJECT_TYPE_NAME (self));
return;
}
}
static void
ide_layout_grid_column_remove (GtkContainer *container,
GtkWidget *widget)
{
IdeLayoutGridColumn *self = (IdeLayoutGridColumn *)container;
g_assert (IDE_IS_LAYOUT_GRID_COLUMN (self));
g_assert (IDE_IS_LAYOUT_STACK (widget));
g_queue_remove (&self->focus_stack, widget);
GTK_CONTAINER_CLASS (ide_layout_grid_column_parent_class)->remove (container, widget);
}
static void
ide_layout_grid_column_finalize (GObject *object)
{
IdeLayoutGridColumn *self = (IdeLayoutGridColumn *)object;
g_assert (self->focus_stack.head == NULL);
g_assert (self->focus_stack.tail == NULL);
g_assert (self->focus_stack.length == 0);
G_OBJECT_CLASS (ide_layout_grid_column_parent_class)->finalize (object);
}
static void
ide_layout_grid_column_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
IdeLayoutGridColumn *self = IDE_LAYOUT_GRID_COLUMN (object);
switch (prop_id)
{
case PROP_CURRENT_STACK:
g_value_set_object (value, ide_layout_grid_column_get_current_stack (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
ide_layout_grid_column_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
IdeLayoutGridColumn *self = IDE_LAYOUT_GRID_COLUMN (object);
switch (prop_id)
{
case PROP_CURRENT_STACK:
ide_layout_grid_column_set_current_stack (self, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
ide_layout_grid_column_class_init (IdeLayoutGridColumnClass *klass)
{
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = ide_layout_grid_column_finalize;
object_class->get_property = ide_layout_grid_column_get_property;
object_class->set_property = ide_layout_grid_column_set_property;
container_class->add = ide_layout_grid_column_add;
container_class->remove = ide_layout_grid_column_remove;
properties [PROP_CURRENT_STACK] =
g_param_spec_object ("current-stack",
"Current Stack",
"The most recently focused stack within the column",
IDE_TYPE_LAYOUT_STACK,
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (object_class, N_PROPS, properties);
}
static void
ide_layout_grid_column_init (IdeLayoutGridColumn *self)