[gtksourceview/wip/minimap] some cleanups
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/minimap] some cleanups
- Date: Mon, 4 May 2015 06:53:41 +0000 (UTC)
commit b31aca37a1ff97d5cf18cbc7a054db669a022f1e
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Mon May 4 08:53:27 2015 +0200
some cleanups
gtksourceview/gtksourcemap.c | 59 +++++++++++++++++++++++++-----------------
1 files changed, 35 insertions(+), 24 deletions(-)
---
diff --git a/gtksourceview/gtksourcemap.c b/gtksourceview/gtksourcemap.c
index afba570..b9c03cc 100644
--- a/gtksourceview/gtksourcemap.c
+++ b/gtksourceview/gtksourcemap.c
@@ -244,8 +244,10 @@ update_scrubber_height (GtkSourceMap *map)
priv = gtk_source_map_get_instance_private (map);
gtk_widget_get_allocation (GTK_WIDGET (priv->view), &alloc);
- gtk_widget_get_preferred_height (GTK_WIDGET (priv->view), NULL, &view_height);
- gtk_widget_get_preferred_height (GTK_WIDGET (priv->child_view), NULL, &child_height);
+ gtk_widget_get_preferred_height (GTK_WIDGET (priv->view),
+ NULL, &view_height);
+ gtk_widget_get_preferred_height (GTK_WIDGET (priv->child_view),
+ NULL, &child_height);
ratio = alloc.height / (gdouble)view_height;
child_height *= ratio;
@@ -415,7 +417,7 @@ gtk_source_map_get_preferred_width (GtkWidget *widget,
layout = gtk_widget_create_pango_layout (GTK_WIDGET (priv->child_view), "X");
pango_layout_get_pixel_size (layout, &width, &height);
- g_clear_object (&layout);
+ g_object_unref (layout);
right_margin_position = gtk_source_view_get_right_margin_position (priv->view);
width *= right_margin_position;
@@ -451,19 +453,22 @@ gtk_source_map__child_view_button_press_event (GtkSourceMap *map,
GtkSourceView *child_view)
{
GtkSourceMapPrivate *priv;
- GtkTextIter iter;
priv = gtk_source_map_get_instance_private (map);
if (priv->view != NULL)
{
+ GtkTextIter iter;
gint x;
gint y;
- gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (child_view), GTK_TEXT_WINDOW_WIDGET,
+ gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (child_view),
+ GTK_TEXT_WINDOW_WIDGET,
event->x, event->y, &x, &y);
- gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (child_view), &iter, x, y);
- gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (priv->view), &iter, 0.0, TRUE, 1.0, 0.5);
+ gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (child_view),
+ &iter, x, y);
+ gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (priv->view), &iter,
+ 0.0, TRUE, 1.0, 0.5);
}
return GDK_EVENT_STOP;
@@ -476,7 +481,8 @@ gtk_source_map__child_view_state_flags_changed (GtkWidget *widget,
{
GdkWindow *window;
- window = gtk_text_view_get_window (GTK_TEXT_VIEW (child_view), GTK_TEXT_WINDOW_TEXT);
+ window = gtk_text_view_get_window (GTK_TEXT_VIEW (child_view),
+ GTK_TEXT_WINDOW_TEXT);
if (window != NULL)
{
gdk_window_set_cursor (window, NULL);
@@ -552,7 +558,8 @@ gtk_source_map__overlay_box_motion_notify_event (GtkSourceMap *map,
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->child_view));
gtk_text_buffer_get_end_iter (buffer, &iter);
- gtk_text_view_get_iter_location (GTK_TEXT_VIEW (priv->child_view), &iter, &rect);
+ gtk_text_view_get_iter_location (GTK_TEXT_VIEW (priv->child_view),
+ &iter, &rect);
child_height = MIN (child_alloc.height, (rect.y + rect.height));
@@ -560,9 +567,11 @@ gtk_source_map__overlay_box_motion_notify_event (GtkSourceMap *map,
ratio = (gdouble)y / (gdouble)child_height;
y = (rect.y + rect.height) * ratio;
- gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (priv->child_view), &iter, x, y);
+ gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (priv->child_view),
+ &iter, x, y);
- gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (priv->view), &iter, 0.0, TRUE, 1.0, 0.5);
+ gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (priv->view), &iter,
+ 0.0, TRUE, 1.0, 0.5);
}
return GDK_EVENT_PROPAGATE;
@@ -585,11 +594,10 @@ gtk_source_map_do_scroll_event (GtkSourceMap *map,
GtkWidget *widget)
{
GtkSourceMapPrivate *priv;
+ static const gint scroll_acceleration = 4;
priv = gtk_source_map_get_instance_private (map);
-#define SCROLL_ACCELERATION 4
-
/*
* TODO: This doesn't propagate kinetic scrolling or anything.
* We should probably make something that does that.
@@ -602,11 +610,11 @@ gtk_source_map_do_scroll_event (GtkSourceMap *map,
if (event->direction == GDK_SCROLL_UP)
{
- count = -SCROLL_ACCELERATION;
+ count = -scroll_acceleration;
}
else if (event->direction == GDK_SCROLL_DOWN)
{
- count = SCROLL_ACCELERATION;
+ count = scroll_acceleration;
}
else
{
@@ -614,11 +622,11 @@ gtk_source_map_do_scroll_event (GtkSourceMap *map,
if (y > 0)
{
- count = SCROLL_ACCELERATION;
+ count = scroll_acceleration;
}
else if (y < 0)
{
- count = -SCROLL_ACCELERATION;
+ count = -scroll_acceleration;
}
}
@@ -629,8 +637,6 @@ gtk_source_map_do_scroll_event (GtkSourceMap *map,
}
}
-#undef SCROLL_ACCELERATION
-
return GDK_EVENT_PROPAGATE;
}
@@ -775,10 +781,13 @@ gtk_source_map_get_child_position (GtkOverlay *overlay,
gtk_widget_get_preferred_height (child, NULL, &alloc->height);
- gtk_text_view_get_visible_rect (GTK_TEXT_VIEW (priv->view), &visible_area);
- gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (priv->view), &iter, visible_area.x,
+ gtk_text_view_get_visible_rect (GTK_TEXT_VIEW (priv->view),
+ &visible_area);
+ gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (priv->view),
+ &iter, visible_area.x,
visible_area.y);
- gtk_text_view_get_iter_location (GTK_TEXT_VIEW (priv->child_view), &iter, &loc);
+ gtk_text_view_get_iter_location (GTK_TEXT_VIEW (priv->child_view),
+ &iter, &loc);
gtk_text_view_buffer_to_window_coords (GTK_TEXT_VIEW (priv->child_view),
GTK_TEXT_WINDOW_WIDGET,
loc.x, loc.y,
@@ -1017,12 +1026,14 @@ gtk_source_map_set_view (GtkSourceMap *map,
if ((gtk_widget_get_events (GTK_WIDGET (priv->view)) & GDK_ENTER_NOTIFY_MASK) == 0)
{
- gtk_widget_add_events (GTK_WIDGET (priv->view), GDK_ENTER_NOTIFY_MASK);
+ gtk_widget_add_events (GTK_WIDGET (priv->view),
+ GDK_ENTER_NOTIFY_MASK);
}
if ((gtk_widget_get_events (GTK_WIDGET (priv->view)) & GDK_LEAVE_NOTIFY_MASK) == 0)
{
- gtk_widget_add_events (GTK_WIDGET (priv->view), GDK_LEAVE_NOTIFY_MASK);
+ gtk_widget_add_events (GTK_WIDGET (priv->view),
+ GDK_LEAVE_NOTIFY_MASK);
}
gtk_source_map_rebuild_css (map);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]