[libwnck] Add an option to disable the tasklist scroll event
- From: Marco Trevisan <marcotrevi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libwnck] Add an option to disable the tasklist scroll event
- Date: Wed, 26 Apr 2017 07:25:01 +0000 (UTC)
commit 3526d6df9cceac4d313372754054d0492f103032
Author: Moritz Bruder <muesli4 gmail com>
Date: Mon Apr 24 19:36:37 2017 +0200
Add an option to disable the tasklist scroll event
This commit is a minor and optional enhancement of the WnckTasklist
widget.
It allows to disable scrolling of the tasklist.
By default scrolling on the tasklist is enabled. The behavior might
be configured by calling wnck_tasklist_set_scroll_enabled.
https://bugzilla.gnome.org/show_bug.cgi?id=402528
libwnck/tasklist.c | 41 +++++++++++++++++++++++++++++++++++++++++
libwnck/tasklist.h | 3 +++
libwnck/test-tasklist.c | 4 ++++
3 files changed, 48 insertions(+), 0 deletions(-)
---
diff --git a/libwnck/tasklist.c b/libwnck/tasklist.c
index c464a0d..55f0a4b 100644
--- a/libwnck/tasklist.c
+++ b/libwnck/tasklist.c
@@ -230,6 +230,8 @@ struct _WnckTasklistPrivate
GtkOrientation orientation;
guint drag_start_time;
+
+ gboolean scroll_enabled;
};
static GType wnck_task_get_type (void);
@@ -596,6 +598,7 @@ wnck_tasklist_init (WnckTasklist *tasklist)
tasklist->priv->monitor_geometry.width = -1; /* invalid value */
tasklist->priv->relief = GTK_RELIEF_NORMAL;
tasklist->priv->orientation = GTK_ORIENTATION_HORIZONTAL;
+ tasklist->priv->scroll_enabled = TRUE;
atk_obj = gtk_widget_get_accessible (widget);
atk_object_set_name (atk_obj, _("Window List"));
@@ -869,6 +872,41 @@ void wnck_tasklist_set_orientation (WnckTasklist *tasklist,
}
/**
+ * wnck_tasklist_set_scroll_enabled:
+ * @tasklist: a #WnckTasklist.
+ * @scroll_enabled: a boolean.
+ *
+ * Sets the scroll behavior of the @tasklist. When set to %TRUE, a scroll
+ * event over the tasklist will change the current window accordingly.
+ *
+ * Since: 3.20.2
+ */
+void
+wnck_tasklist_set_scroll_enabled (WnckTasklist *tasklist,
+ gboolean scroll_enabled)
+{
+ g_return_if_fail (WNCK_IS_TASKLIST (tasklist));
+
+ tasklist->priv->scroll_enabled = scroll_enabled;
+}
+
+/**
+ * wnck_tasklist_get_scroll_enabled:
+ * @tasklist: a #WnckTasklist.
+ *
+ * Gets the scroll behavior of the @tasklist.
+ *
+ * Since: 3.20.2
+ */
+gboolean
+wnck_tasklist_get_scroll_enabled (WnckTasklist *tasklist)
+{
+ g_return_val_if_fail (WNCK_IS_TASKLIST (tasklist), TRUE);
+
+ return tasklist->priv->scroll_enabled;
+}
+
+/**
* wnck_tasklist_set_switch_workspace_on_unminimize:
* @tasklist: a #WnckTasklist.
* @switch_workspace_on_unminimize: whether to activate the #WnckWorkspace a
@@ -1937,6 +1975,9 @@ wnck_tasklist_scroll_event (GtkWidget *widget,
tasklist = WNCK_TASKLIST (widget);
+ if (!tasklist->priv->scroll_enabled)
+ return FALSE;
+
window = g_list_find (tasklist->priv->windows,
tasklist->priv->active_task);
if (window)
diff --git a/libwnck/tasklist.h b/libwnck/tasklist.h
index 37ee385..d2952f8 100644
--- a/libwnck/tasklist.h
+++ b/libwnck/tasklist.h
@@ -105,6 +105,9 @@ void wnck_tasklist_set_button_relief (WnckTasklist *tasklist,
GtkReliefStyle relief);
void wnck_tasklist_set_orientation (WnckTasklist *tasklist,
GtkOrientation orient);
+void wnck_tasklist_set_scroll_enabled (WnckTasklist *tasklist,
+ gboolean scroll_enabled);
+gboolean wnck_tasklist_get_scroll_enabled (WnckTasklist *tasklist);
/**
* WnckLoadIconFunction:
diff --git a/libwnck/test-tasklist.c b/libwnck/test-tasklist.c
index 0912cc8..6b27f5a 100644
--- a/libwnck/test-tasklist.c
+++ b/libwnck/test-tasklist.c
@@ -11,6 +11,7 @@ static gboolean skip_tasklist = FALSE;
static gboolean transparent = FALSE;
static gboolean vertical = FALSE;
static gint icon_size = WNCK_DEFAULT_MINI_ICON_SIZE;
+static gboolean enable_scroll = TRUE;
static GOptionEntry entries[] = {
{"always-group", 'g', 0, G_OPTION_ARG_NONE, &always_group, "Always group windows", NULL},
@@ -21,6 +22,7 @@ static GOptionEntry entries[] = {
{"skip-tasklist", 's', 0, G_OPTION_ARG_NONE, &skip_tasklist, "Don't show window in tasklist", NULL},
{"vertical", 'v', 0, G_OPTION_ARG_NONE, &vertical, "Show in vertical mode", NULL},
{"transparent", 't', 0, G_OPTION_ARG_NONE, &transparent, "Enable Transparency", NULL},
+ {"disable-scroll", 'd', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &enable_scroll, "Disable
scrolling", NULL},
{NULL }
};
@@ -102,6 +104,8 @@ main (int argc, char **argv)
wnck_tasklist_set_grouping (WNCK_TASKLIST (tasklist),
WNCK_TASKLIST_AUTO_GROUP);
+ wnck_tasklist_set_scroll_enabled (WNCK_TASKLIST (tasklist), enable_scroll);
+
wnck_tasklist_set_middle_click_close (WNCK_TASKLIST (tasklist), TRUE);
wnck_tasklist_set_orientation (WNCK_TASKLIST (tasklist),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]