Commit 20eda083 authored by Christian Hergert's avatar Christian Hergert
Browse files

more work on ripping up the editor

parent 889f3c95
- Search entry context menu (use a GMenu and merging this time)
Might also require DzlWidgetActionGroup.
- Enter, Up, and Down accelerators for search/replace entries.
- perspective focus_location
- other perspective interface methods
- can we make perspectives the plugin interface?
- Check if buffer is already in visible stack before adding new view
- view-added/removed/etc on IdeLayoutGrid
- Remove get_right_edge() etc, switch with "classification" for panels
- Ability to disable plugin by default
- Plugins to fix for API
- devhelp
- command bar / vim
- project-tree
- terminal
- symbol-tree
- Remove accelerators from perspective, use shortcut engine
- Move panel position settings to org.gnome.builder.editor maybe
......@@ -61,27 +61,6 @@
<attribute name="verb-icon">builder-view-right-pane-symbolic</attribute>
</item>
</section>
<!--
<section>
<attribute name="id">juntion-section</attribute>
<attribute name="display-hint">horizontal-buttons</attribute>
<item>
<attribute name="label" translatable="yes">_Reload</attribute>
<attribute name="action">win.revert</attribute>
<attribute name="verb-icon">view-refresh-symbolic</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Print…</attribute>
<attribute name="action">win.print</attribute>
<attribute name="verb-icon">printer-symbolic</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Fullscreen</attribute>
<attribute name="action">win.fullscreen</attribute>
<attribute name="verb-icon">view-fullscreen-symbolic</attribute>
</item>
</section>
-->
<section id="gear-menu-new-section">
<item>
<attribute name="label" translatable="yes">_New File</attribute>
......@@ -262,61 +241,50 @@
</item>
</section>
</menu>
<menu id="ide-layout-stack-menu">
<section id="ide-layout-stack-menu-splits-section">
<attribute name="display-hint">horizontal-buttons</attribute>
<attribute name="label" translatable="yes">Split</attribute>
<menu id="ide-layout-stack-frame-menu">
<section id="ide-layout-stack-frame-section">
<attribute name="label" translatable="yes">Frame</attribute>
<item>
<attribute name="label" translatable="yes">Split Left</attribute>
<attribute name="action">view-stack.split-left</attribute>
<attribute name="verb-icon">builder-split-tab-left-symbolic</attribute>
<attribute name="label" translatable="yes">Move Left</attribute>
<attribute name="action">layoutstack.move-left</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Split Right</attribute>
<attribute name="action">view-stack.split-right</attribute>
<attribute name="verb-icon">builder-split-tab-right-symbolic</attribute>
<attribute name="label" translatable="yes">Move Right</attribute>
<attribute name="action">layoutstack.move-right</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Split Down</attribute>
<attribute name="action">view-stack.split-down</attribute>
<attribute name="verb-icon">builder-split-tab-symbolic</attribute>
<attribute name="action">layoutstack.split-view</attribute>
<attribute name="label" translatable="yes">Split</attribute>
</item>
</section>
<section id="ide-layout-stack-menu-move-section">
<attribute name="display-hint">horizontal-buttons</attribute>
<attribute name="label" translatable="yes">Move</attribute>
<item>
<attribute name="label" translatable="yes">Move Left</attribute>
<attribute name="action">view-stack.move-left</attribute>
<attribute name="verb-icon">builder-move-left-symbolic</attribute>
<attribute name="action">layoutgrid.close-stack</attribute>
<attribute name="label" translatable="yes">Close</attribute>
</item>
</section>
</menu>
<menu id="ide-editor-view-document-menu">
<section id="editor-document-section">
<attribute name="label" translatable="yes">Document</attribute>
<item>
<attribute name="label" translatable="yes">Move Right</attribute>
<attribute name="action">view-stack.move-right</attribute>
<attribute name="verb-icon">builder-move-right-symbolic</attribute>
<attribute name="label" translatable="yes">Open in New Frame</attribute>
<attribute name="action">layoutstack.open-in-new-frame</attribute>
</item>
</section>
<section id="ide-layout-stack-menu-preview-section"/>
<section id="ide-layout-stack-menu-save-section">
<item>
<attribute name="label" translatable="yes">_Save</attribute>
<attribute name="action">view.save</attribute>
<attribute name="label" translatable="yes">Open Preview</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Save As</attribute>
<attribute name="action">view.save-as</attribute>
<attribute name="label" translatable="yes">Print…</attribute>
</item>
</section>
<section id="ide-layout-stack-menu-print-section">
<section id="editor-document-preferences-section">
<item>
<attribute name="label" translatable="yes">_Print</attribute>
<attribute name="action">view.print</attribute>
<attribute name="label" translatable="yes">Document Preferences</attribute>
</item>
</section>
<section id="ide-layout-stack-menu-close-section">
<section id="editor-document-close-section">
<item>
<attribute name="label" translatable="yes">_Close</attribute>
<attribute name="action">view-stack.close</attribute>
<attribute name="action">layoutstack.close-view</attribute>
<attribute name="label" translatable="yes">Close</attribute>
</item>
</section>
</menu>
......
@import url("resource:///org/gnome/builder/themes/shared.css");
/*
* Layout tab and tab bar tweaks
*
* The following makes the layout stack header look similar to a tab bar.
*/
layouttabbar > box > button {
opacity: 0.5;
}
layouttabbar > box > button:hover {
opacity: 0.75;
}
layouttabbar > box > button:active {
opacity: 1;
}
layouttabbar button {
border: none;
box-shadow: none;
background: transparent;
}
layouttab label {
padding: 5px;
}
layouttab {
background-color: @theme_bg_color;
border-bottom: 3px;
border-bottom-style: solid;
border-right: 1px solid alpha(@borders, 0.75);
border-left: 1px solid alpha(@borders, 0.75);
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
}
layouttab:backdrop {
border-right-color: alpha(@borders, 0.75);
border-left-color: alpha(@borders, 0.75);
box-shadow: none;
}
layouttabbar:backdrop {
box-shadow: none;
}
layouttab separator.vertical {
margin-top: 7px;
margin-bottom: 7px;
opacity: 0.75;
idelayoutstackheader > button:last-child {
margin-right: 3px;
}
layouttab separator.vertical:backdrop {
opacity: 0.3;
}
layouttab button:disabled,
layouttab button {
background: none;
border: none;
box-shadow: none;
padding-left: 4px;
padding-right: 4px;
}
/*
* Close button styling for layouttab.
*/
layouttab > box > button:last-child image {
color: @theme_fg_color;
opacity: 0.3;
margin: 2px;
border: 1px solid transparent;
border-radius: 3px;
}
layouttab > box > button:last-child:hover image {
opacity: .75;
transition-duration: 250ms;
border: 1px solid @borders;
}
layouttab > box > button:last-child:active image {
opacity: .8;
background-image: linear-gradient(shade(@theme_bg_color, 0.9), @theme_bg_color);
}
layouttab > box > button:last-child:backdrop image {
opacity: .1;
}
layout {
border: 1px solid alpha(@borders, 0.75);
-PnlDockBin-handle-size: 1;
}
entry.search-missing {
background-color: #cc0000;
......
@import url("resource:///org/gnome/builder/themes/shared/shared-layout.css");
/* work around some gtk padding issue */
filechooser actionbar button.combo {
padding: 0;
......@@ -9,7 +11,7 @@ filechooser actionbar button.combo {
}
/* styling for editor search */
frame.gb-search-frame {
ideeditorsearchbar {
background-image: linear-gradient(shade(@theme_bg_color,1.05), @theme_bg_color);
padding: 6px;
border-style: solid;
......@@ -20,9 +22,6 @@ frame.gb-search-frame {
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
}
frame.gb-search-frame border {
border: none;
}
/* styling for the search and spellchecker list close button */
frame.gb-search-frame > box > grid:first-child > button.close:disabled,
......
idelayoutstackheader {
min-height: 26px;
}
idelayoutstackheader button {
border: none;
border-radius: 0;
background: transparent;
box-shadow: none;
padding: 0;
margin: 0;
}
idelayoutstackheader button:not(:disabled) image {
opacity: 0.55;
}
idelayoutstackheader button:checked image,
idelayoutstackheader button:not(:disabled):hover image {
opacity: 1;
}
idelayoutstackheader button:checked,
idelayoutstackheader button:hover {
background: shade(@theme_bg_color, 0.9);
}
idelayoutstackheader button:active {
background: shade(@theme_bg_color, 0.85);
}
idelayoutstackheader > button {
padding-left: 12px;
padding-right: 12px;
}
idelayoutstackheader * button:first-child > image,
idelayoutstackheader * button:last-child:dir(rtl) > image {
padding-left: 12px;
padding-right: 10px;
}
idelayoutstackheader * button:first-child:dir(rtl) > image,
idelayoutstackheader * button:last-child > image {
padding-right: 12px;
padding-left: 9px;
}
idelayoutgrid.handle {
border: 1px solid @borders;
}
popover.symbols-button {
padding: 12px;
}
popover.symbols-button treeview {
background: transparent;
color: @theme_text_color;
}
popover.title-popover scrolledwindow {
min-width: 300px;
}
popover.title-popover list {
background: transparent;
}
popover.title-popover list row {
padding: 6px;
}
popover.title-popover list row button {
margin: 0;
padding: 0;
box-shadow: none;
border: none;
background: transparent;
}
......@@ -18,59 +18,30 @@
#define G_LOG_DOMAIN "ide-editor-perspective"
#include "ide-editor-perspective.h"
#include <glib/gi18n.h>
#include "editor/ide-editor-perspective.h"
#include "editor/ide-editor-view.h"
#include "workbench/ide-perspective.h"
struct _IdeEditorPerspective
{
IdeLayout parent_instance;
/* Template widgets */
IdeLayoutGrid *grid;
};
enum {
PROP_0,
N_PROPS
};
G_DEFINE_TYPE (IdeEditorPerspective, ide_editor_perspective, IDE_TYPE_LAYOUT)
static GParamSpec *properties [N_PROPS];
static void
ide_editor_perspective_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
switch (prop_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void perspective_iface_init (IdePerspectiveInterface *iface);
static void
ide_editor_perspective_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
switch (prop_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
G_DEFINE_TYPE_WITH_CODE (IdeEditorPerspective, ide_editor_perspective, IDE_TYPE_LAYOUT,
G_IMPLEMENT_INTERFACE (IDE_TYPE_PERSPECTIVE, perspective_iface_init))
static void
ide_editor_perspective_class_init (IdeEditorPerspectiveClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->get_property = ide_editor_perspective_get_property;
object_class->set_property = ide_editor_perspective_set_property;
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/builder/ui/ide-editor-perspective.ui");
gtk_widget_class_bind_template_child (widget_class, IdeEditorPerspective, grid);
}
......@@ -78,6 +49,7 @@ ide_editor_perspective_class_init (IdeEditorPerspectiveClass *klass)
static void
ide_editor_perspective_init (IdeEditorPerspective *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
}
/**
......@@ -98,3 +70,229 @@ ide_editor_perspective_get_grid (IdeEditorPerspective *self)
return self->grid;
}
void
ide_editor_perspective_focus_location (IdeEditorPerspective *self,
IdeSourceLocation *location)
{
g_return_if_fail (IDE_IS_EDITOR_PERSPECTIVE (self));
g_return_if_fail (location != NULL);
/* TODO: */
}
void
ide_editor_perspective_focus_buffer_in_current_stack (IdeEditorPerspective *self,
IdeBuffer *buffer)
{
IdeLayoutStack *stack;
IdeEditorView *view;
g_return_if_fail (IDE_IS_EDITOR_PERSPECTIVE (self));
g_return_if_fail (IDE_IS_BUFFER (buffer));
stack = ide_layout_grid_get_current_stack (self->grid);
/* TODO: Check if buffer is in stack */
view = g_object_new (IDE_TYPE_EDITOR_VIEW,
"buffer", buffer,
"visible", TRUE,
NULL);
gtk_container_add (GTK_CONTAINER (stack), GTK_WIDGET (view));
}
/**
* ide_editor_perspective_get_active_view:
* @self: a #IdeEditorPerspective
*
* Gets the active view for the perspective, or %NULL if there is not one.
*
* Returns: (nullable) (transfer none): An #IdeLayoutView or %NULL.
*
* Since: 3.26
*/
IdeLayoutView *
ide_editor_perspective_get_active_view (IdeEditorPerspective *self)
{
IdeLayoutStack *stack;
g_return_val_if_fail (IDE_IS_EDITOR_PERSPECTIVE (self), NULL);
stack = ide_layout_grid_get_current_stack (self->grid);
return ide_layout_stack_get_visible_child (stack);
}
/**
* ide_editor_perspective_get_right_edge:
*
* Returns: (transfer none): A #GtkWidget
*/
GtkWidget *
ide_editor_perspective_get_right_edge (IdeEditorPerspective *self)
{
g_return_val_if_fail (IDE_IS_EDITOR_PERSPECTIVE (self), NULL);
return dzl_dock_bin_get_right_edge (DZL_DOCK_BIN (self));
}
/**
* ide_editor_perspective_get_bottom_edge:
*
* Returns: (transfer none): A #GtkWidget
*/
GtkWidget *
ide_editor_perspective_get_bottom_edge (IdeEditorPerspective *self)
{
g_return_val_if_fail (IDE_IS_EDITOR_PERSPECTIVE (self), NULL);
return dzl_dock_bin_get_bottom_edge (DZL_DOCK_BIN (self));
}
static void
set_reveal_child_without_transition (DzlDockRevealer *revealer,
gboolean reveal)
{
DzlDockRevealerTransitionType type;
g_assert (DZL_IS_DOCK_REVEALER (revealer));
type = dzl_dock_revealer_get_transition_type (revealer);
dzl_dock_revealer_set_transition_type (revealer, DZL_DOCK_REVEALER_TRANSITION_TYPE_NONE);
dzl_dock_revealer_set_reveal_child (revealer, reveal);
dzl_dock_revealer_set_transition_type (revealer, type);
}
static void
ide_editor_perspective_restore_panel_state (IdeEditorPerspective *self)
{
g_autoptr(GSettings) settings = NULL;
GtkWidget *pane;
gboolean reveal;
guint position;
g_assert (IDE_IS_EDITOR_PERSPECTIVE (self));
/* TODO: This belongs in editor settings probably */
settings = g_settings_new ("org.gnome.builder.workbench");
pane = dzl_dock_bin_get_left_edge (DZL_DOCK_BIN (self));
reveal = g_settings_get_boolean (settings, "left-visible");
position = g_settings_get_int (settings, "left-position");
dzl_dock_revealer_set_position (DZL_DOCK_REVEALER (pane), position);
set_reveal_child_without_transition (DZL_DOCK_REVEALER (pane), reveal);
pane = dzl_dock_bin_get_right_edge (DZL_DOCK_BIN (self));
reveal = g_settings_get_boolean (settings, "right-visible");
position = g_settings_get_int (settings, "right-position");
dzl_dock_revealer_set_position (DZL_DOCK_REVEALER (pane), position);
set_reveal_child_without_transition (DZL_DOCK_REVEALER (pane), reveal);
pane = dzl_dock_bin_get_bottom_edge (DZL_DOCK_BIN (self));
reveal = g_settings_get_boolean (settings, "bottom-visible");
position = g_settings_get_int (settings, "bottom-position");
dzl_dock_revealer_set_position (DZL_DOCK_REVEALER (pane), position);
set_reveal_child_without_transition (DZL_DOCK_REVEALER (pane), reveal);
}
static void
ide_editor_perspective_save_panel_state (IdeEditorPerspective *self)
{
g_autoptr(GSettings) settings = NULL;
GtkWidget *pane;
gboolean reveal;
guint position;
g_assert (IDE_IS_EDITOR_PERSPECTIVE (self));
/* TODO: possibly belongs in editor settings */
settings = g_settings_new ("org.gnome.builder.workbench");
pane = dzl_dock_bin_get_left_edge (DZL_DOCK_BIN (self));
position = dzl_dock_revealer_get_position (DZL_DOCK_REVEALER (pane));
reveal = dzl_dock_revealer_get_reveal_child (DZL_DOCK_REVEALER (pane));
g_settings_set_boolean (settings, "left-visible", reveal);
g_settings_set_int (settings, "left-position", position);
pane = dzl_dock_bin_get_right_edge (DZL_DOCK_BIN (self));
position = dzl_dock_revealer_get_position (DZL_DOCK_REVEALER (pane));
reveal = dzl_dock_revealer_get_reveal_child (DZL_DOCK_REVEALER (pane));
g_settings_set_boolean (settings, "right-visible", reveal);
g_settings_set_int (settings, "right-position", position);
pane = dzl_dock_bin_get_bottom_edge (DZL_DOCK_BIN (self));
position = dzl_dock_revealer_get_position (DZL_DOCK_REVEALER (pane));
reveal = dzl_dock_revealer_get_reveal_child (DZL_DOCK_REVEALER (pane));
g_settings_set_boolean (settings, "bottom-visible", reveal);
g_settings_set_int (settings, "bottom-position", position);
}
static void
ide_editor_perspective_views_foreach (IdePerspective *perspective,
GtkCallback callback,
gpointer user_data)
{
IdeEditorPerspective *self = (IdeEditorPerspective *)perspective;
g_assert (IDE_IS_EDITOR_PERSPECTIVE (self));
g_assert (callback != NULL);
ide_layout_grid_foreach_view (self->grid, callback, user_data);
}
static gchar *
ide_editor_perspective_get_id (IdePerspective *perspective)
{
return g_strdup ("editor");
}