Commit 4867d554 authored by Christian Hergert's avatar Christian Hergert
Browse files

editor: place minimap above floating bar

This adds a new container to help us manage the layout. The minimap will
be displayed above the floating bar, but not cover the source view.
parent 0018fed8
......@@ -3,104 +3,110 @@
<!-- interface-requires gtk+ 3.15 -->
<template class="GbEditorFrame" parent="GtkBin">
<child>
<object class="GtkBox">
<property name="orientation">horizontal</property>
<object class="GtkOverlay">
<property name="expand">true</property>
<property name="visible">true</property>
<child>
<object class="GtkOverlay">
<property name="expand">true</property>
<child type="overlay">
<object class="NautilusFloatingBar" id="floating_bar">
<property name="halign">end</property>
<property name="primary_label"></property>
<property name="valign">end</property>
<property name="visible">true</property>
<child type="overlay">
<object class="NautilusFloatingBar" id="floating_bar">
<property name="halign">end</property>
<property name="primary_label"></property>
<property name="valign">end</property>
<child>
<object class="GtkLabel" id="overwrite_label">
<!-- translators: OVR indicates we are in overwite mode -->
<property name="label" translatable="yes">OVR</property>
<property name="margin-start">12</property>
<property name="visible">false</property>
</object>
<packing>
<property name="pack-type">start</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="mode_name_label">
<property name="margin-start">12</property>
<property name="margin-end">3</property>
<property name="visible">true</property>
<child>
<object class="GtkLabel" id="overwrite_label">
<!-- translators: OVR indicates we are in overwite mode -->
<property name="label" translatable="yes">OVR</property>
<property name="margin-start">12</property>
<property name="visible">false</property>
</object>
<packing>
<property name="pack-type">start</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="mode_name_label">
<property name="margin-start">12</property>
<property name="margin-end">3</property>
<property name="visible">true</property>
</object>
<packing>
<property name="pack-type">start</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="pack-type">start</property>
<property name="position">2</property>
</packing>
</child>
<child type="overlay">
<object class="GtkRevealer" id="search_revealer">
<property name="halign">end</property>
<property name="valign">start</property>
</object>
</child>
<child>
<object class="GtkBox">
<property name="orientation">horizontal</property>
<property name="visible">true</property>
<child>
<object class="GtkOverlay">
<property name="expand">true</property>
<property name="visible">true</property>
<property name="width-request">300</property>
<child>
<object class="GtkFrame">
<child type="overlay">
<object class="GtkRevealer" id="search_revealer">
<property name="halign">end</property>
<property name="valign">start</property>
<property name="visible">true</property>
<property name="margin-end">12</property>
<style>
<class name="gb-search-slider"/>
</style>
<property name="width-request">300</property>
<child>
<object class="GtkBox">
<property name="orientation">horizontal</property>
<object class="GtkFrame">
<property name="visible">true</property>
<property name="margin-end">12</property>
<style>
<class name="linked"/>
<class name="gb-search-slider"/>
</style>
<child>
<object class="GdTaggedEntry" id="search_entry">
<property name="visible">true</property>
<property name="tag-close-visible">false</property>
<property name="can-focus">true</property>
<property name="width-request">260</property>
<property name="primary-icon-activatable">true</property>
<property name="primary-icon-sensitive">true</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="action-name">frame.previous-search-result</property>
<property name="can-focus">false</property>
<object class="GtkBox">
<property name="orientation">horizontal</property>
<property name="visible">true</property>
<style>
<class name="image-button"/>
<class name="linked"/>
</style>
<child>
<object class="GtkImage">
<property name="icon-name">go-up-symbolic</property>
<property name="icon-size">1</property>
<object class="GdTaggedEntry" id="search_entry">
<property name="visible">true</property>
<property name="tag-close-visible">false</property>
<property name="can-focus">true</property>
<property name="width-request">260</property>
<property name="primary-icon-activatable">true</property>
<property name="primary-icon-sensitive">true</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton">
<property name="action-name">frame.next-search-result</property>
<property name="can-focus">false</property>
<property name="visible">true</property>
<style>
<class name="image-button"/>
</style>
<child>
<object class="GtkImage">
<property name="icon-name">go-down-symbolic</property>
<property name="icon-size">1</property>
<object class="GtkButton">
<property name="action-name">frame.previous-search-result</property>
<property name="can-focus">false</property>
<property name="visible">true</property>
<style>
<class name="image-button"/>
</style>
<child>
<object class="GtkImage">
<property name="icon-name">go-up-symbolic</property>
<property name="icon-size">1</property>
<property name="visible">true</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton">
<property name="action-name">frame.next-search-result</property>
<property name="can-focus">false</property>
<property name="visible">true</property>
<style>
<class name="image-button"/>
</style>
<child>
<object class="GtkImage">
<property name="icon-name">go-down-symbolic</property>
<property name="icon-size">1</property>
<property name="visible">true</property>
</object>
</child>
</object>
</child>
</object>
......@@ -109,42 +115,43 @@
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolled_window">
<property name="expand">true</property>
<property name="visible">true</property>
<child>
<object class="IdeSourceView" id="source_view">
<property name="auto-indent">true</property>
<property name="enable-word-completion">true</property>
<property name="highlight-current-line">true</property>
<property name="insert-matching-brace">true</property>
<property name="overwrite-braces">true</property>
<property name="scroll-offset">0</property>
<property name="show-grid-lines">true</property>
<property name="show-line-changes">true</property>
<property name="show-line-numbers">true</property>
<property name="show-right-margin">true</property>
<property name="show-search-bubbles">true</property>
<property name="smart-backspace">true</property>
<property name="snippet-completion">true</property>
<object class="GtkScrolledWindow" id="scrolled_window">
<property name="expand">true</property>
<property name="visible">true</property>
<child internal-child="completion">
<object class="GtkSourceCompletion">
<property name="show-headers">false</property>
<child>
<object class="IdeSourceView" id="source_view">
<property name="auto-indent">true</property>
<property name="enable-word-completion">true</property>
<property name="highlight-current-line">true</property>
<property name="insert-matching-brace">true</property>
<property name="overwrite-braces">true</property>
<property name="scroll-offset">0</property>
<property name="show-grid-lines">true</property>
<property name="show-line-changes">true</property>
<property name="show-line-numbers">true</property>
<property name="show-right-margin">true</property>
<property name="show-search-bubbles">true</property>
<property name="smart-backspace">true</property>
<property name="snippet-completion">true</property>
<property name="visible">true</property>
<child internal-child="completion">
<object class="GtkSourceCompletion">
<property name="show-headers">false</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox" id="source_map_container">
<property name="visible">true</property>
<child>
<object class="GbEditorMapBin" id="source_map_container">
<property name="floating-bar">floating_bar</property>
<property name="visible">true</property>
</object>
</child>
</object>
</child>
</object>
......
......@@ -24,6 +24,7 @@
#include "gb-editor-frame.h"
#include "gb-editor-frame-actions.h"
#include "gb-editor-frame-private.h"
#include "gb-editor-map-bin.h"
#include "gb-string.h"
#include "gb-view-stack.h"
#include "gb-widget.h"
......@@ -684,6 +685,7 @@ gb_editor_frame_class_init (GbEditorFrameClass *klass)
GB_WIDGET_CLASS_BIND (klass, GbEditorFrame, source_view);
g_type_ensure (NAUTILUS_TYPE_FLOATING_BAR);
g_type_ensure (GB_TYPE_EDITOR_MAP_BIN);
g_type_ensure (GD_TYPE_TAGGED_ENTRY);
}
......
/* gb-editor-map-bin.c
*
* Copyright (C) 2015 Christian Hergert <christian@hergert.me>
*
* 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/>.
*/
#include <glib/gi18n.h>
#include <ide.h>
#include "gb-editor-map-bin.h"
struct _GbEditorMapBin
{
GtkBin parent_instance;
gint cached_height;
gulong size_allocate_handler;
GtkWidget *floating_bar;
};
G_DEFINE_TYPE (GbEditorMapBin, gb_editor_map_bin, GTK_TYPE_BIN)
enum {
PROP_0,
PROP_FLOATING_BAR,
LAST_PROP
};
static GParamSpec *gParamSpecs [LAST_PROP];
static void
gb_editor_map_bin__floating_bar_size_allocate (GbEditorMapBin *self,
GtkAllocation *alloc,
GtkWidget *floating_bar)
{
g_assert (GB_IS_EDITOR_MAP_BIN (self));
g_assert (alloc != NULL);
g_assert (GTK_IS_WIDGET (floating_bar));
if (self->cached_height != alloc->height)
{
self->cached_height = alloc->height;
gtk_widget_queue_resize (GTK_WIDGET (self));
}
}
static void
gb_editor_map_bin_set_floating_bar (GbEditorMapBin *self,
GtkWidget *floating_bar)
{
g_return_if_fail (GB_IS_EDITOR_MAP_BIN (self));
if (floating_bar != self->floating_bar)
{
if (self->floating_bar)
{
ide_clear_signal_handler (self->floating_bar, &self->size_allocate_handler);
ide_clear_weak_pointer (&self->floating_bar);
}
if (floating_bar)
{
ide_set_weak_pointer (&self->floating_bar, floating_bar);
g_signal_connect_object (self->floating_bar,
"size-allocate",
G_CALLBACK (gb_editor_map_bin__floating_bar_size_allocate),
self,
G_CONNECT_SWAPPED);
}
gtk_widget_queue_resize (GTK_WIDGET (self));
}
if (ide_set_weak_pointer (&self->floating_bar, floating_bar))
gtk_widget_queue_resize (GTK_WIDGET (self));
}
static void
gb_editor_map_bin_size_allocate (GtkWidget *widget,
GtkAllocation *alloc)
{
GbEditorMapBin *self = (GbEditorMapBin *)widget;
alloc->height -= self->cached_height;
GTK_WIDGET_CLASS (gb_editor_map_bin_parent_class)->size_allocate (widget, alloc);
}
static void
gb_editor_map_bin_finalize (GObject *object)
{
GbEditorMapBin *self = (GbEditorMapBin *)object;
ide_clear_signal_handler (self->floating_bar, &self->size_allocate_handler);
ide_clear_weak_pointer (&self->floating_bar);
G_OBJECT_CLASS (gb_editor_map_bin_parent_class)->finalize (object);
}
static void
gb_editor_map_bin_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GbEditorMapBin *self = GB_EDITOR_MAP_BIN (object);
switch (prop_id)
{
case PROP_FLOATING_BAR:
gb_editor_map_bin_set_floating_bar (self, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
gb_editor_map_bin_class_init (GbEditorMapBinClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->finalize = gb_editor_map_bin_finalize;
object_class->set_property = gb_editor_map_bin_set_property;
widget_class->size_allocate = gb_editor_map_bin_size_allocate;
gParamSpecs [PROP_FLOATING_BAR] =
g_param_spec_object ("floating-bar",
"Floating Bar",
"The floating bar to use for relative allocation size.",
GTK_TYPE_WIDGET,
(G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_FLOATING_BAR,
gParamSpecs [PROP_FLOATING_BAR]);
}
static void
gb_editor_map_bin_init (GbEditorMapBin *self)
{
}
/* gb-editor-map-bin.h
*
* Copyright (C) 2015 Christian Hergert <christian@hergert.me>
*
* 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 GB_EDITOR_MAP_BIN_H
#define GB_EDITOR_MAP_BIN_H
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define GB_TYPE_EDITOR_MAP_BIN (gb_editor_map_bin_get_type())
G_DECLARE_FINAL_TYPE (GbEditorMapBin, gb_editor_map_bin, GB, EDITOR_MAP_BIN, GtkBin)
G_END_DECLS
#endif /* GB_EDITOR_MAP_BIN_H */
......@@ -52,6 +52,8 @@ libgnome_builder_la_SOURCES = \
src/editor/gb-editor-frame-actions.c \
src/editor/gb-editor-frame-actions.h \
src/editor/gb-editor-frame-private.h \
src/editor/gb-editor-map-bin.c \
src/editor/gb-editor-map-bin.h \
src/editor/gb-editor-settings-widget.c \
src/editor/gb-editor-settings-widget.h \
src/editor/gb-editor-tweak-widget.c \
......
......@@ -151,6 +151,7 @@ overlay_enter_notify_cb (GtkWidget *parent,
GdkEventCrossing *event,
gpointer user_data)
{
#if 0
GtkWidget *widget = user_data;
if (event->window != gtk_widget_get_window (widget)) {
......@@ -168,6 +169,7 @@ overlay_enter_notify_cb (GtkWidget *parent,
}
gtk_widget_queue_resize (widget);
#endif
return FALSE;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment