summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Barciela <[email protected]>2017-11-20 11:53:37 +0100
committermonsta <[email protected]>2017-11-30 16:46:35 +0300
commita778374f183e424f18b337fa32462e1e6f152421 (patch)
treea29f84751b8dfdb9a5f4bb7183a9f50d459199b6
parent35c76d40df1c292feff0f1b35275402dcd7304f7 (diff)
downloadpluma-a778374f183e424f18b337fa32462e1e6f152421.tar.bz2
pluma-a778374f183e424f18b337fa32462e1e6f152421.tar.xz
pluma-view.c: use one static variable instead two to do the same job
This is the improvement of the commits: https://github.com/mate-desktop/pluma/commit/4df44887f4b7547fc9b31d1cb3f61688579fe39b https://github.com/mate-desktop/pluma/commit/ec438f3d262ef178a898612211335d3c9fa2f4ee
-rw-r--r--pluma/pluma-view.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/pluma/pluma-view.c b/pluma/pluma-view.c
index 9bf60985..4ebc0936 100644
--- a/pluma/pluma-view.c
+++ b/pluma/pluma-view.c
@@ -57,8 +57,7 @@
#define PLUMA_VIEW_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), PLUMA_TYPE_VIEW, PlumaViewPrivate))
/* Local variables */
-static gboolean middledown = FALSE;
-static gboolean rightdown = FALSE;
+static gboolean middle_or_right_down = FALSE;
typedef enum
{
@@ -130,6 +129,8 @@ static gboolean pluma_view_button_press_event (GtkWidget *widget,
GdkEventButton *event);
static gboolean pluma_view_button_release_event (GtkWidget *widget,
GdkEventButton *event);
+static void pluma_view_populate_popup (GtkTextView *text_view,
+ GtkWidget *widget);
static gboolean start_interactive_search (PlumaView *view);
static gboolean start_interactive_goto_line (PlumaView *view);
@@ -214,6 +215,7 @@ pluma_view_class_init (PlumaViewClass *klass)
widget_class->drag_drop = pluma_view_drag_drop;
widget_class->button_press_event = pluma_view_button_press_event;
widget_class->button_release_event = pluma_view_button_release_event;
+ text_view_class->populate_popup = pluma_view_populate_popup;
klass->start_interactive_search = start_interactive_search;
klass->start_interactive_goto_line = start_interactive_goto_line;
klass->reset_searched_text = reset_searched_text;
@@ -1995,19 +1997,15 @@ show_line_numbers_menu (GtkWidget *view,
static gboolean
pluma_view_button_press_event (GtkWidget *widget, GdkEventButton *event)
{
- if (((event->button == 3) && (middledown)) || ((event->button == 2) && (rightdown)))
+ if ((event->button == 2) || (event->button == 3))
{
- middledown = FALSE;
- rightdown = FALSE;
- return TRUE;
- }
- else if (event->button == 2)
- {
- middledown = TRUE;
- }
- else if (event->button == 3)
- {
- rightdown = TRUE;
+ if (middle_or_right_down)
+ {
+ middle_or_right_down = FALSE;
+ return TRUE;
+ }
+ else
+ middle_or_right_down = TRUE;
}
if ((event->type == GDK_BUTTON_PRESS) &&
@@ -2034,13 +2032,17 @@ static gboolean
pluma_view_button_release_event (GtkWidget *widget, GdkEventButton *event)
{
if (event->button == 2)
- middledown = FALSE;
- else if (event->button == 3)
- rightdown = FALSE;
+ middle_or_right_down = FALSE;
return GTK_WIDGET_CLASS (pluma_view_parent_class)->button_release_event (widget, event);
}
+static void
+pluma_view_populate_popup (GtkTextView *text_view, GtkWidget *widget)
+{
+ middle_or_right_down = FALSE;
+}
+
static void
search_highlight_updated_cb (PlumaDocument *doc,
GtkTextIter *start,