[gnome-builder] editor-map: add border to editor map
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] editor-map: add border to editor map
- Date: Sat, 2 May 2015 23:04:43 +0000 (UTC)
commit 3099bafbf52d3a3576b8961e5a25011f93fc2a84
Author: Christian Hergert <christian hergert me>
Date: Sat May 2 16:01:32 2015 -0700
editor-map: add border to editor map
This adds a slight border as recommended to us by the design team. We are
simply using GtkSeparator for the line since CSS borders do not seem to
get drawn here.
We might be able to simplify this once we move to GtkSource for the minimap
implementation.
It was recommended that we use slightly lighter color than @borders for
this, which seems to be what is getting drawn. We can adjust with CSS
if necessary.
src/editor/gb-editor-map-bin.c | 43 ++++++++++++++++++++++++++++++++++++++-
src/editor/gb-editor-map-bin.h | 2 +-
2 files changed, 42 insertions(+), 3 deletions(-)
---
diff --git a/src/editor/gb-editor-map-bin.c b/src/editor/gb-editor-map-bin.c
index b6215f2..6d6c043 100644
--- a/src/editor/gb-editor-map-bin.c
+++ b/src/editor/gb-editor-map-bin.c
@@ -23,13 +23,14 @@
struct _GbEditorMapBin
{
- GtkBin parent_instance;
+ GtkBox parent_instance;
gint cached_height;
gulong size_allocate_handler;
GtkWidget *floating_bar;
+ GtkWidget *separator;
};
-G_DEFINE_TYPE (GbEditorMapBin, gb_editor_map_bin, GTK_TYPE_BIN)
+G_DEFINE_TYPE (GbEditorMapBin, gb_editor_map_bin, GTK_TYPE_BOX)
enum {
PROP_0,
@@ -98,10 +99,36 @@ gb_editor_map_bin_size_allocate (GtkWidget *widget,
}
static void
+gb_editor_map_bin_add (GtkContainer *container,
+ GtkWidget *child)
+{
+ GbEditorMapBin *self = (GbEditorMapBin *)container;
+
+ if (IDE_IS_SOURCE_MAP (child) && (self->separator != NULL))
+ gtk_widget_show (GTK_WIDGET (self->separator));
+
+ GTK_CONTAINER_CLASS (gb_editor_map_bin_parent_class)->add (container, child);
+}
+
+static void
+gb_editor_map_bin_remove (GtkContainer *container,
+ GtkWidget *child)
+{
+ GbEditorMapBin *self = (GbEditorMapBin *)container;
+
+ if (IDE_IS_SOURCE_MAP (child) && (self->separator != NULL))
+ gtk_widget_hide (GTK_WIDGET (self->separator));
+
+ GTK_CONTAINER_CLASS (gb_editor_map_bin_parent_class)->remove (container, child);
+}
+
+static void
gb_editor_map_bin_finalize (GObject *object)
{
GbEditorMapBin *self = (GbEditorMapBin *)object;
+ if (self->separator != NULL)
+ g_object_remove_weak_pointer (G_OBJECT (self->separator), (gpointer *)&self->separator);
ide_clear_signal_handler (self->floating_bar, &self->size_allocate_handler);
ide_clear_weak_pointer (&self->floating_bar);
@@ -132,12 +159,17 @@ gb_editor_map_bin_class_init (GbEditorMapBinClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GtkContainerClass *container_class = GTK_CONTAINER_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;
+ container_class = GTK_CONTAINER_CLASS (klass);
+ container_class->add = gb_editor_map_bin_add;
+ container_class->remove = gb_editor_map_bin_remove;
+
gParamSpecs [PROP_FLOATING_BAR] =
g_param_spec_object ("floating-bar",
"Floating Bar",
@@ -151,4 +183,11 @@ gb_editor_map_bin_class_init (GbEditorMapBinClass *klass)
static void
gb_editor_map_bin_init (GbEditorMapBin *self)
{
+ self->separator = g_object_new (GTK_TYPE_SEPARATOR,
+ "orientation", GTK_ORIENTATION_VERTICAL,
+ "hexpand", FALSE,
+ "visible", FALSE,
+ NULL);
+ g_object_add_weak_pointer (G_OBJECT (self->separator), (gpointer *)&self->separator);
+ gtk_container_add (GTK_CONTAINER (self), self->separator);
}
diff --git a/src/editor/gb-editor-map-bin.h b/src/editor/gb-editor-map-bin.h
index c4f1306..5faf40e 100644
--- a/src/editor/gb-editor-map-bin.h
+++ b/src/editor/gb-editor-map-bin.h
@@ -25,7 +25,7 @@ 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_DECLARE_FINAL_TYPE (GbEditorMapBin, gb_editor_map_bin, GB, EDITOR_MAP_BIN, GtkBox)
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]