[gedit] fullscreen mode : center the view on screen
- From: Sebastien Lafargue <slafargue src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] fullscreen mode : center the view on screen
- Date: Mon, 4 Aug 2014 22:53:11 +0000 (UTC)
commit ff71b845e4c17c4afce5a58e95b9dd8f15c52456
Author: Sebastien Lafargue <slafargue gnome org>
Date: Mon Aug 4 20:35:22 2014 +0200
fullscreen mode : center the view on screen
The purpose is to have a distraction free mode.
The GeditViewFrame take account of the right margin visibility to activate
the centering and the right margin position to calculate it, then call
GeditViewHolder to update the spacer
GeditViewHolder is based on Christian Hergert's prototype.
gedit/Makefile.am | 2 +
gedit/gedit-view-frame.c | 72 +++++-
gedit/gedit-view-holder.c | 491 ++++++++++++++++++++++++++++++++
gedit/gedit-view-holder.h | 66 +++++
gedit/resources/ui/gedit-view-frame.ui | 6 +-
5 files changed, 630 insertions(+), 7 deletions(-)
---
diff --git a/gedit/Makefile.am b/gedit/Makefile.am
index 4c8a998..48d40ff 100644
--- a/gedit/Makefile.am
+++ b/gedit/Makefile.am
@@ -123,6 +123,7 @@ gedit_NOINST_H_FILES = \
gedit/gedit-status-menu-button.h \
gedit/gedit-tab-label.h \
gedit/gedit-view-frame.h \
+ gedit/gedit-view-holder.h \
gedit/gedit-window-private.h
gedit_INST_H_FILES = \
@@ -201,6 +202,7 @@ gedit_libgedit_c_files = \
gedit/gedit-utils.c \
gedit/gedit-view.c \
gedit/gedit-view-frame.c \
+ gedit/gedit-view-holder.c \
gedit/gedit-window.c
gedit_libgedit_la_SOURCES = \
diff --git a/gedit/gedit-view-frame.c b/gedit/gedit-view-frame.c
index fb2eeab..a5810f7 100644
--- a/gedit/gedit-view-frame.c
+++ b/gedit/gedit-view-frame.c
@@ -26,6 +26,8 @@
#endif
#include "gedit-view-frame.h"
+#include "gedit-window.h"
+#include "gedit-view-holder.h"
#include "gedit-debug.h"
#include "gedit-utils.h"
#include "libgd/gd.h"
@@ -54,6 +56,9 @@ typedef enum
struct _GeditViewFramePrivate
{
GeditView *view;
+ GeditViewHolder *view_holder;
+ GtkWidget *window;
+
SearchMode search_mode;
/* Where the search has started. When the user presses escape in the
@@ -88,6 +93,8 @@ struct _GeditViewFramePrivate
*/
gchar *search_text;
gchar *old_search_text;
+
+ gint window_state_changed_handler_id;
};
enum
@@ -151,9 +158,17 @@ static void
gedit_view_frame_finalize (GObject *object)
{
GeditViewFrame *frame = GEDIT_VIEW_FRAME (object);
+ GeditViewFramePrivate *priv = frame->priv;
- g_free (frame->priv->search_text);
- g_free (frame->priv->old_search_text);
+ g_free (priv->search_text);
+ g_free (priv->old_search_text);
+
+ if (priv->window_state_changed_handler_id != 0)
+ {
+ g_signal_handler_disconnect (priv->window,
+ priv->window_state_changed_handler_id);
+ priv->window_state_changed_handler_id = 0;
+ }
G_OBJECT_CLASS (gedit_view_frame_parent_class)->finalize (object);
}
@@ -1452,6 +1467,7 @@ gedit_view_frame_class_init (GeditViewFrameClass *klass)
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/gedit/ui/gedit-view-frame.ui");
gtk_widget_class_bind_template_child_private (widget_class, GeditViewFrame, view);
+ gtk_widget_class_bind_template_child_private (widget_class, GeditViewFrame, view_holder);
gtk_widget_class_bind_template_child_private (widget_class, GeditViewFrame, revealer);
gtk_widget_class_bind_template_child_private (widget_class, GeditViewFrame, search_entry);
gtk_widget_class_bind_template_child_private (widget_class, GeditViewFrame, go_up_button);
@@ -1468,6 +1484,49 @@ view_frame_mount_operation_factory (GtkSourceFile *file,
return gtk_mount_operation_new (GTK_WINDOW (window));
}
+static gboolean
+on_window_state_changed (GtkWidget *widget,
+ GdkEventWindowState *event,
+ GeditViewFrame *frame)
+{
+ GeditViewFramePrivate *priv = frame->priv;
+ gboolean fullscreen_state;
+
+ fullscreen_state = event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN;
+
+ gedit_view_holder_set_centering (priv->view_holder, fullscreen_state);
+
+ return FALSE;
+}
+
+static void
+on_toplevel_window_changed (GtkWidget *widget,
+ GtkWidget *previous_toplevel,
+ GeditViewFrame *frame)
+{
+ GeditViewFramePrivate *priv = frame->priv;
+ GeditWindow *gedit_window;
+
+ if (priv->window_state_changed_handler_id != 0)
+ {
+ g_signal_handler_disconnect (priv->window,
+ priv->window_state_changed_handler_id);
+ priv->window_state_changed_handler_id = 0;
+ }
+
+ gedit_window = GEDIT_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (frame), GEDIT_TYPE_WINDOW));
+
+ if (gedit_window)
+ {
+ priv->window = GTK_WIDGET (&gedit_window->window);
+
+ priv->window_state_changed_handler_id = g_signal_connect (priv->window,
+ "window-state-event",
+ G_CALLBACK
(on_window_state_changed),
+ frame);
+ }
+}
+
static void
gedit_view_frame_init (GeditViewFrame *frame)
{
@@ -1475,6 +1534,8 @@ gedit_view_frame_init (GeditViewFrame *frame)
GtkSourceFile *file;
GdkRGBA transparent = {0, 0, 0, 0};
+ gedit_debug (DEBUG_WINDOW);
+
frame->priv = gedit_view_frame_get_instance_private (frame);
gtk_widget_init_template (GTK_WIDGET (frame));
@@ -1484,6 +1545,8 @@ gedit_view_frame_init (GeditViewFrame *frame)
doc = gedit_view_frame_get_document (frame);
file = gedit_document_get_file (doc);
+ frame->priv->window_state_changed_handler_id = 0;
+
gtk_source_file_set_mount_operation_factory (file,
view_frame_mount_operation_factory,
frame,
@@ -1555,6 +1618,11 @@ gedit_view_frame_init (GeditViewFrame *frame)
"clicked",
G_CALLBACK (forward_search),
frame);
+
+ g_signal_connect (frame,
+ "hierarchy-changed",
+ G_CALLBACK (on_toplevel_window_changed),
+ frame);
}
GeditViewFrame *
diff --git a/gedit/gedit-view-holder.c b/gedit/gedit-view-holder.c
new file mode 100644
index 0000000..b21391f
--- /dev/null
+++ b/gedit/gedit-view-holder.c
@@ -0,0 +1,491 @@
+/*
+ * gedit-view-holder.c
+ * This file is part of gedit
+ *
+ * Copyright (C) 2014 - Sébastien Lafargue
+ *
+ * Gedit is free software; you can redistribute this file and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Gedit 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Based on Christian Hergert's prototype.
+ */
+
+#include "gedit-view-holder.h"
+
+#include <gtksourceview/gtksource.h>
+
+#include "gedit-view.h"
+#include "gedit-debug.h"
+
+struct _GeditViewHolderPrivate
+{
+ GtkWidget *box;
+ GtkWidget *scrolled_window;
+ GtkWidget *sourceview;
+ GtkWidget *spacer;
+
+ GtkStyleContext *view_context;
+ GdkRGBA view_background;
+ GdkRGBA view_line_margin_fg;
+ GdkRGBA view_margin_background;
+ guint view_text_width;
+ gboolean centering;
+
+ guint view_background_set : 1;
+ guint view_line_margin_fg_set : 1;
+ guint view_margin_background_set : 1;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GeditViewHolder, gedit_view_holder, GTK_TYPE_BIN)
+
+#define STYLE_TEXT "text"
+#define STYLE_RIGHT_MARGIN "right-margin"
+
+#define RIGHT_MARGIN_LINE_ALPHA 40
+#define RIGHT_MARGIN_OVERLAY_ALPHA 15
+
+static gboolean
+get_style (GtkSourceStyleScheme *scheme,
+ const gchar *style_id,
+ const gchar *attribute,
+ GdkRGBA *color)
+{
+ GtkSourceStyle *style;
+ gchar *style_string;
+
+ style = gtk_source_style_scheme_get_style (scheme, style_id);
+ if (!style)
+ {
+ return FALSE;
+ }
+
+ g_object_get (style, attribute, &style_string, NULL);
+ if (style_string)
+ {
+ gdk_rgba_parse (color, style_string);
+ g_free (style_string);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void
+get_spacer_colors (GeditViewHolder *container,
+ GtkSourceStyleScheme *scheme)
+{
+ GeditViewHolderPrivate *priv = container->priv;
+
+ if (scheme)
+ {
+ priv->view_background_set = get_style (scheme,
+ STYLE_TEXT, "background",
+ &priv->view_background);
+
+ priv->view_line_margin_fg_set = get_style (scheme,
+ STYLE_RIGHT_MARGIN, "foreground",
+ &priv->view_line_margin_fg);
+ priv->view_line_margin_fg.alpha = RIGHT_MARGIN_LINE_ALPHA / 255.0;
+
+ priv->view_margin_background_set = get_style (scheme,
+ STYLE_RIGHT_MARGIN, "background",
+ &priv->view_margin_background);
+ priv->view_margin_background.alpha = RIGHT_MARGIN_OVERLAY_ALPHA / 255.0;
+ }
+}
+
+/* FIXME: when GeditViewHolder will be transfered to GtkSourceViewHolder,
+ * this method will be replaced by a call to a new method called
+ * gtk_source_view_get_right_margin_pixel_position ()
+ */
+static guint
+_gedit_view_holder_get_right_margin_pixel_position (GeditViewHolder *container)
+{
+ GeditViewHolderPrivate *priv;
+ gchar *str;
+ PangoFontDescription *font_desc;
+ PangoLayout *layout;
+ guint right_margin_position;
+ gint width = 0;
+
+ g_return_val_if_fail (GEDIT_IS_VIEW_HOLDER (container), 0);
+
+ priv = container->priv;
+
+ right_margin_position = gtk_source_view_get_right_margin_position (GTK_SOURCE_VIEW
(priv->sourceview));
+
+ gtk_style_context_get(priv->view_context, GTK_STATE_FLAG_NORMAL,
+ GTK_STYLE_PROPERTY_FONT, &font_desc,
+ NULL);
+
+ str = g_strnfill (right_margin_position, '_');
+ layout = gtk_widget_create_pango_layout (GTK_WIDGET (priv->sourceview), str);
+ g_free (str);
+
+ pango_layout_set_font_description (layout, font_desc);
+ pango_font_description_free(font_desc);
+ pango_layout_get_pixel_size (layout, &width, NULL);
+
+ g_object_unref (G_OBJECT (layout));
+
+ return width;
+}
+
+static void
+on_view_right_margin_visibility_changed (GeditView *view,
+ GParamSpec *pspec,
+ GeditViewHolder *container)
+{
+ GeditViewHolderPrivate *priv = container->priv;
+ gboolean visibility;
+
+ visibility = gtk_source_view_get_show_right_margin (GTK_SOURCE_VIEW (priv->sourceview));
+
+ gtk_widget_set_visible (GTK_WIDGET (container->priv->spacer), visibility && priv->centering);
+}
+
+static void
+on_view_right_margin_position_changed (GeditView *view,
+ GParamSpec *pspec,
+ GeditViewHolder *container)
+{
+ GeditViewHolderPrivate *priv = container->priv;
+ gboolean visibility;
+
+ priv->view_text_width = _gedit_view_holder_get_right_margin_pixel_position (container);
+
+ visibility = gtk_source_view_get_show_right_margin (GTK_SOURCE_VIEW (priv->sourceview));
+
+ if (visibility)
+ {
+ gtk_widget_queue_resize (priv->spacer);
+ }
+}
+
+static void
+on_view_context_changed (GtkStyleContext *stylecontext,
+ GeditViewHolder *container)
+{
+ GeditViewHolderPrivate *priv = container->priv;
+ GtkTextBuffer *buffer;
+ GtkSourceStyleScheme *scheme;
+ gboolean visibility;
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->sourceview));
+ scheme = gtk_source_buffer_get_style_scheme (GTK_SOURCE_BUFFER (buffer));
+ get_spacer_colors (container, scheme);
+
+ priv->view_text_width = _gedit_view_holder_get_right_margin_pixel_position (container);
+
+ visibility = gtk_source_view_get_show_right_margin (GTK_SOURCE_VIEW (priv->sourceview));
+
+ if (visibility)
+ {
+ gtk_widget_queue_resize (priv->spacer);
+ }
+}
+
+static gboolean
+on_spacer_draw (GeditViewHolder *container,
+ cairo_t *cr,
+ GtkDrawingArea *spacer)
+{
+ GeditViewHolderPrivate *priv = container->priv;
+ GtkStyleContext *context;
+ guint width, height;
+
+ if (!container->priv->sourceview)
+ {
+ return FALSE;
+ }
+
+ width = gtk_widget_get_allocated_width (GTK_WIDGET (spacer));
+ height = gtk_widget_get_allocated_height (GTK_WIDGET (spacer));
+
+ context = gtk_widget_get_style_context (GTK_WIDGET (spacer));
+ gtk_style_context_save (context);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_VIEW);
+ gtk_render_background (context, cr, 0, 0, width, height);
+ gtk_style_context_restore (context);
+
+ cairo_set_line_width (cr, 1.0);
+
+ if (priv->view_background_set)
+ {
+ gdk_cairo_set_source_rgba (cr, &container->priv->view_background);
+ cairo_rectangle (cr, 0, 0, width, height);
+ cairo_fill (cr);
+ }
+
+ if (priv->view_margin_background_set)
+ {
+ gdk_cairo_set_source_rgba (cr, &container->priv->view_margin_background);
+ cairo_rectangle (cr, 0, 0, width, height);
+ cairo_fill (cr);
+ }
+
+ if (priv->view_line_margin_fg_set)
+ {
+ gdk_cairo_set_source_rgba (cr, &container->priv->view_line_margin_fg);
+ cairo_move_to (cr, width - 0.5, 0);
+ cairo_line_to (cr, width - 0.5, height);
+ cairo_stroke (cr);
+ }
+
+ return FALSE;
+}
+
+static void
+gedit_view_holder_remove (GtkContainer *container,
+ GtkWidget *child)
+{
+ GeditViewHolderPrivate *priv;
+
+ g_assert (GEDIT_IS_VIEW_HOLDER (container));
+
+ priv = GEDIT_VIEW_HOLDER (container)->priv;
+
+ if (priv->sourceview == child)
+ {
+ gtk_container_remove (GTK_CONTAINER (priv->scrolled_window), priv->sourceview);
+ g_object_remove_weak_pointer (G_OBJECT (priv->sourceview), (gpointer *)&priv->sourceview);
+ priv->sourceview = NULL;
+ priv->view_context = NULL;
+ }
+ else
+ {
+ GTK_CONTAINER_CLASS (gedit_view_holder_parent_class)->remove (container, child);
+ }
+}
+
+static void
+gedit_view_holder_add (GtkContainer *container,
+ GtkWidget *child)
+{
+ GeditViewHolderPrivate *priv;
+ GtkTextBuffer *buffer;
+ GtkSourceStyleScheme *scheme;
+
+ g_assert (GEDIT_IS_VIEW_HOLDER (container));
+
+ priv = GEDIT_VIEW_HOLDER (container)->priv;
+
+ if (GEDIT_IS_VIEW (child))
+ {
+ if (priv->sourceview)
+ {
+ gedit_view_holder_remove (container, priv->sourceview);
+ }
+
+ priv->sourceview = child;
+ g_object_add_weak_pointer (G_OBJECT (child), (gpointer *)&priv->sourceview);
+ gtk_container_add (GTK_CONTAINER (priv->scrolled_window), child);
+
+ priv->view_context = gtk_widget_get_style_context (child);
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->sourceview));
+ scheme = gtk_source_buffer_get_style_scheme (GTK_SOURCE_BUFFER (buffer));
+ get_spacer_colors (GEDIT_VIEW_HOLDER (container), scheme);
+
+ g_signal_connect (priv->sourceview,
+ "notify::right-margin-position",
+ G_CALLBACK (on_view_right_margin_position_changed),
+ container);
+
+ g_signal_connect (priv->sourceview,
+ "notify::show-right-margin",
+ G_CALLBACK (on_view_right_margin_visibility_changed),
+ container);
+
+ g_signal_connect (priv->view_context,
+ "changed",
+ G_CALLBACK (on_view_context_changed),
+ container);
+
+ gtk_widget_queue_resize (GTK_WIDGET (container));
+ }
+ else
+ {
+ GTK_CONTAINER_CLASS (gedit_view_holder_parent_class)->add (container, child);
+ }
+}
+
+static gboolean
+on_spacer_scroll_event (GtkWidget *widget,
+ GdkEvent *event,
+ GeditViewHolder *container)
+{
+ GdkEventScroll *new_scroll_event;
+
+ new_scroll_event = (GdkEventScroll *)gdk_event_copy (event);
+ g_object_unref (new_scroll_event->window);
+
+ new_scroll_event->window = g_object_ref (gtk_widget_get_window (container->priv->sourceview));
+ new_scroll_event->send_event = TRUE;
+
+ new_scroll_event->x = 0;
+ new_scroll_event->y = 0;
+ new_scroll_event->x_root = 0;
+ new_scroll_event->y_root = 0;
+
+ gtk_main_do_event ((GdkEvent *)new_scroll_event);
+ gdk_event_free ((GdkEvent *)new_scroll_event);
+
+ return TRUE;
+}
+
+static void
+gedit_view_holder_size_allocate (GtkWidget *widget,
+ GtkAllocation *alloc)
+{
+ GeditViewHolderPrivate *priv;
+ GtkTextView *view;
+ gint container_width;
+ gint gutter_width;
+ gint text_width;
+ gint spacer_width;
+ gint current_spacer_width;
+ GdkWindow *gutter_window;
+
+ g_assert (GEDIT_IS_VIEW_HOLDER (widget));
+
+ priv = GEDIT_VIEW_HOLDER (widget)->priv;
+
+ view = GTK_TEXT_VIEW (priv->sourceview);
+
+ if (view)
+ {
+ container_width = alloc->width;
+
+ gutter_window = gtk_text_view_get_window (view, GTK_TEXT_WINDOW_LEFT);
+ gutter_width = (gutter_window) ? gdk_window_get_width (gutter_window) : 0;
+
+ text_width = priv->view_text_width;
+ spacer_width = MAX (0, container_width - text_width - gutter_width) / 2;
+
+ g_object_get(priv->spacer, "width-request", ¤t_spacer_width, NULL);
+
+ if (current_spacer_width != spacer_width)
+ {
+ g_object_set(priv->spacer, "width-request", spacer_width, NULL);
+ }
+ }
+
+ GTK_WIDGET_CLASS (gedit_view_holder_parent_class)->size_allocate (widget, alloc);
+}
+
+static void
+gedit_view_holder_finalize (GObject *object)
+{
+ GeditViewHolder *container = GEDIT_VIEW_HOLDER (object);
+ GeditViewHolderPrivate *priv = container->priv;
+
+ if (priv->sourceview)
+ {
+ gedit_view_holder_remove (GTK_CONTAINER (container), priv->sourceview);
+ }
+
+ G_OBJECT_CLASS (gedit_view_holder_parent_class)->finalize (object);
+}
+
+static void
+gedit_view_holder_class_init (GeditViewHolderClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
+
+ gobject_class->finalize = gedit_view_holder_finalize;
+
+ widget_class->size_allocate = gedit_view_holder_size_allocate;
+
+ container_class->add = gedit_view_holder_add;
+ container_class->remove = gedit_view_holder_remove;
+}
+
+static void
+gedit_view_holder_init (GeditViewHolder *container)
+{
+ GeditViewHolderPrivate *priv;
+
+ container->priv = gedit_view_holder_get_instance_private (container);
+ priv = container->priv;
+ priv->view_text_width = 0;
+
+ priv->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ priv->spacer = gtk_drawing_area_new ();
+ priv->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+
+ gtk_container_add (GTK_CONTAINER (container), priv->box);
+ gtk_box_pack_start (GTK_BOX (priv->box), priv->spacer, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (priv->box), priv->scrolled_window, TRUE, TRUE, 0);
+
+ gtk_widget_set_no_show_all (GTK_WIDGET (priv->spacer), TRUE);
+ gtk_widget_show_all (GTK_WIDGET (priv->box));
+
+ g_signal_connect_swapped (priv->spacer, "draw",
+ G_CALLBACK (on_spacer_draw),
+ container);
+
+ gtk_widget_add_events(GTK_WIDGET(priv->spacer), GDK_SCROLL_MASK);
+ g_signal_connect (priv->spacer, "scroll-event",
+ G_CALLBACK (on_spacer_scroll_event),
+ container);
+}
+
+/**
+ * gedit_view_holder_set_centering:
+ * @container: a #GeditViewHolder.
+ * @centering : whether to center the sourceview child or not.
+ *
+ * if @centering is %TRUE, the sourceview child is centered
+ * horizontally on the #GeditViewHolder container.
+ **/
+void
+gedit_view_holder_set_centering (GeditViewHolder *container,
+ gboolean centering)
+{
+ g_return_if_fail (GEDIT_IS_VIEW_HOLDER (container));
+
+ container->priv->centering = centering;
+
+ on_view_right_margin_visibility_changed (GEDIT_VIEW (container->priv->sourceview), NULL, container);
+}
+
+/**
+ * gedit_view_holder_get_centering:
+ * @container: a #GeditViewHolder.
+ *
+ * Return whether the #GtkSourceView child is centered or not.
+ *
+ * Return value: %TRUE if the #GtkSourceView child is centered
+ * horizontally on the #GeditViewHolder container.
+ **/
+gboolean
+gedit_view_holder_get_centering (GeditViewHolder *container)
+{
+ g_return_val_if_fail (GEDIT_IS_VIEW_HOLDER (container), FALSE);
+
+ return container->priv->centering;
+}
+
+GeditViewHolder *
+gedit_view_holder_new (void)
+{
+ return g_object_new (GEDIT_TYPE_VIEW_HOLDER,
+ NULL);
+}
+
+/* ex:set ts=8 noet: */
diff --git a/gedit/gedit-view-holder.h b/gedit/gedit-view-holder.h
new file mode 100644
index 0000000..0a256b4
--- /dev/null
+++ b/gedit/gedit-view-holder.h
@@ -0,0 +1,66 @@
+/*
+ * gedit-view-holder.h
+ * This file is part of gedit
+ *
+ * Copyright (C) 2014 - Sébastien Lafargue
+ *
+ * Gedit is free software; you can redistribute this file and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Gedit 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GEDIT_VIEW_HOLDER_H__
+#define __GEDIT_VIEW_HOLDER_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GEDIT_TYPE_VIEW_HOLDER (gedit_view_holder_get_type())
+#define GEDIT_VIEW_HOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_VIEW_HOLDER,
GeditViewHolder))
+#define GEDIT_VIEW_HOLDER_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_VIEW_HOLDER,
GeditViewHolder const))
+#define GEDIT_VIEW_HOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_VIEW_HOLDER,
GeditViewHolderClass))
+#define GEDIT_IS_VIEW_HOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_VIEW_HOLDER))
+#define GEDIT_IS_VIEW_HOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_VIEW_HOLDER))
+#define GEDIT_VIEW_HOLDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_TYPE_VIEW_HOLDER,
GeditViewHolderClass))
+
+typedef struct _GeditViewHolder GeditViewHolder;
+typedef struct _GeditViewHolderClass GeditViewHolderClass;
+typedef struct _GeditViewHolderPrivate GeditViewHolderPrivate;
+
+struct _GeditViewHolder
+{
+ GtkBin parent;
+
+ GeditViewHolderPrivate *priv;
+};
+
+struct _GeditViewHolderClass
+{
+ GtkBinClass parent_class;
+};
+
+GType gedit_view_holder_get_type (void) G_GNUC_CONST;
+
+void gedit_view_holder_set_centering (GeditViewHolder *container,
+ gboolean centering);
+
+gboolean gedit_view_holder_get_centering (GeditViewHolder *container);
+
+GeditViewHolder *gedit_view_holder_new (void);
+
+G_END_DECLS
+
+#endif /* __GEDIT_VIEW_HOLDER_H__ */
+
+/* ex:set ts=8 noet: */
diff --git a/gedit/resources/ui/gedit-view-frame.ui b/gedit/resources/ui/gedit-view-frame.ui
index 1c35c0d..2dd1395 100644
--- a/gedit/resources/ui/gedit-view-frame.ui
+++ b/gedit/resources/ui/gedit-view-frame.ui
@@ -7,12 +7,8 @@
<property name="has_focus">False</property>
<property name="is_focus">False</property>
<child>
- <object class="GtkScrolledWindow" id="scrolledwindow">
+ <object class="GeditViewHolder" id="view_holder">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="has_focus">False</property>
- <property name="is_focus">False</property>
- <property name="shadow_type">none</property>
<child>
<object class="GeditView" id="view">
<property name="visible">True</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]