summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Napias <[email protected]>2019-06-29 22:28:21 +0200
committerraveit65 <[email protected]>2019-07-10 21:09:34 +0200
commit67b0883a92607d52ece6ab7e8f8869e7f55bab29 (patch)
treebcccbc8319590fa23563c2d2f5156b0c99b03b92 /src
parentef6434d21bd88d18d48f01113bc44e1611acc918 (diff)
downloadmate-power-manager-67b0883a92607d52ece6ab7e8f8869e7f55bab29.tar.bz2
mate-power-manager-67b0883a92607d52ece6ab7e8f8869e7f55bab29.tar.xz
Add scroll interface tabs with mouse wheel
in preferences and gpm-statistics (mouse-battery)
Diffstat (limited to 'src')
-rw-r--r--src/gpm-common.c59
-rw-r--r--src/gpm-common.h18
-rw-r--r--src/gpm-prefs-core.c25
-rw-r--r--src/gpm-statistics.c18
4 files changed, 98 insertions, 22 deletions
diff --git a/src/gpm-common.c b/src/gpm-common.c
index 6556d85..754ac9e 100644
--- a/src/gpm-common.c
+++ b/src/gpm-common.c
@@ -158,6 +158,65 @@ gpm_help_display (const gchar *link_id)
g_free (uri);
}
+/**
+ * gpm_dialog_page_scroll_event_cb:
+ **/
+gboolean
+gpm_dialog_page_scroll_event_cb (GtkWidget *widget, GdkEventScroll *event, GtkWindow *window)
+{
+ GtkNotebook *notebook = GTK_NOTEBOOK (widget);
+ GtkWidget *child, *event_widget, *action_widget;
+
+ child = gtk_notebook_get_nth_page (notebook, gtk_notebook_get_current_page (notebook));
+ if (child == NULL)
+ return FALSE;
+
+ event_widget = gtk_get_event_widget ((GdkEvent *) event);
+
+ /* Ignore scroll events from the content of the page */
+ if (event_widget == NULL || event_widget == child || gtk_widget_is_ancestor (event_widget, child))
+ return FALSE;
+
+ /* And also from the action widgets */
+ action_widget = gtk_notebook_get_action_widget (notebook, GTK_PACK_START);
+ if (event_widget == action_widget || (action_widget != NULL && gtk_widget_is_ancestor (event_widget, action_widget)))
+ return FALSE;
+ action_widget = gtk_notebook_get_action_widget (notebook, GTK_PACK_END);
+ if (event_widget == action_widget || (action_widget != NULL && gtk_widget_is_ancestor (event_widget, action_widget)))
+ return FALSE;
+
+ switch (event->direction) {
+ case GDK_SCROLL_RIGHT:
+ case GDK_SCROLL_DOWN:
+ gtk_notebook_next_page (notebook);
+ break;
+ case GDK_SCROLL_LEFT:
+ case GDK_SCROLL_UP:
+ gtk_notebook_prev_page (notebook);
+ break;
+ case GDK_SCROLL_SMOOTH:
+ switch (gtk_notebook_get_tab_pos (notebook)) {
+ case GTK_POS_LEFT:
+ case GTK_POS_RIGHT:
+ if (event->delta_y > 0)
+ gtk_notebook_next_page (notebook);
+ else if (event->delta_y < 0)
+ gtk_notebook_prev_page (notebook);
+ break;
+ case GTK_POS_TOP:
+ case GTK_POS_BOTTOM:
+ if (event->delta_x > 0)
+ gtk_notebook_next_page (notebook);
+ else if (event->delta_x < 0)
+ gtk_notebook_prev_page (notebook);
+ break;
+ }
+ break;
+ }
+
+ return TRUE;
+}
+
/***************************************************************************
*** MAKE CHECK TESTS ***
***************************************************************************/
diff --git a/src/gpm-common.h b/src/gpm-common.h
index e9f0ac9..8aeedbc 100644
--- a/src/gpm-common.h
+++ b/src/gpm-common.h
@@ -23,6 +23,7 @@
#define __GPMCOMMON_H
#include <glib.h>
+#include <gtk/gtk.h>
#include <unistd.h>
@@ -154,14 +155,17 @@ typedef enum {
GPM_ACTION_POLICY_NOTHING
} GpmActionPolicy;
-gchar *gpm_get_timestring (guint time);
-guint gpm_discrete_from_percent (guint percentage,
- guint levels);
-guint gpm_discrete_to_percent (guint discrete,
- guint levels);
-void gpm_help_display (const gchar *link_id);
+gchar *gpm_get_timestring (guint time);
+guint gpm_discrete_from_percent (guint percentage,
+ guint levels);
+guint gpm_discrete_to_percent (guint discrete,
+ guint levels);
+void gpm_help_display (const gchar *link_id);
+gboolean gpm_dialog_page_scroll_event_cb (GtkWidget *widget,
+ GdkEventScroll *event,
+ GtkWindow *window);
#ifdef EGG_TEST
-void gpm_common_test (gpointer data);
+void gpm_common_test (gpointer data);
#endif
G_END_DECLS
diff --git a/src/gpm-prefs-core.c b/src/gpm-prefs-core.c
index 5346ab9..4d62794 100644
--- a/src/gpm-prefs-core.c
+++ b/src/gpm-prefs-core.c
@@ -484,7 +484,7 @@ prefs_setup_ac (GpmPrefs *prefs)
widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "hbox_ac_brightness"));
gtk_widget_hide(widget);
-
+
widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "checkbutton_ac_display_dim"));
gtk_widget_hide(widget);
@@ -575,7 +575,8 @@ static void
prefs_setup_ups (GpmPrefs *prefs)
{
GtkWidget *widget;
- GtkNotebook *notebook;
+ GtkWidget *notebook;
+ GtkWidget *window;
gint page;
const GpmActionPolicy ups_low_actions[] =
@@ -607,11 +608,17 @@ prefs_setup_ups (GpmPrefs *prefs)
GPM_SETTINGS_SLEEP_DISPLAY_UPS,
display_times);
+ window = gpm_window (prefs);
+ notebook = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "notebook_preferences"));
+ gtk_widget_add_events (notebook, GDK_SCROLL_MASK);
+ g_signal_connect (GTK_NOTEBOOK (notebook), "scroll-event",
+ G_CALLBACK (gpm_dialog_page_scroll_event_cb),
+ window);
+
if (prefs->priv->has_ups == FALSE) {
- notebook = GTK_NOTEBOOK (gtk_builder_get_object (prefs->priv->builder, "notebook_preferences"));
widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "vbox_ups"));
- page = gtk_notebook_page_num (notebook, GTK_WIDGET (widget));
- gtk_notebook_remove_page (notebook, page);
+ page = gtk_notebook_page_num (GTK_NOTEBOOK (notebook), GTK_WIDGET (widget));
+ gtk_notebook_remove_page (GTK_NOTEBOOK (notebook), page);
return;
}
@@ -721,7 +728,7 @@ gpm_prefs_init (GpmPrefs *prefs)
g_error_free (error);
}
- res = g_dbus_proxy_call_sync (proxy, "CanSuspend",
+ res = g_dbus_proxy_call_sync (proxy, "CanSuspend",
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
@@ -737,7 +744,7 @@ gpm_prefs_init (GpmPrefs *prefs)
g_error_free (error);
}
- res = g_dbus_proxy_call_sync (proxy, "CanHibernate",
+ res = g_dbus_proxy_call_sync (proxy, "CanHibernate",
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
@@ -776,8 +783,8 @@ gpm_prefs_init (GpmPrefs *prefs)
return;
}
- res = g_dbus_proxy_call_sync (proxy, "Get",
- g_variant_new( "(ss)",
+ res = g_dbus_proxy_call_sync (proxy, "Get",
+ g_variant_new( "(ss)",
"org.freedesktop.UPower",
"LidIsPresent"),
G_DBUS_CALL_FLAGS_NONE,
diff --git a/src/gpm-statistics.c b/src/gpm-statistics.c
index d6bcaf1..cbbd564 100644
--- a/src/gpm-statistics.c
+++ b/src/gpm-statistics.c
@@ -1342,9 +1342,9 @@ gpm_stats_history_type_combo_changed_cb (GtkWidget *widget, gpointer data)
guint active;
const gchar *axis_x = NULL;
const gchar *axis_y = NULL;
-
+
active = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
-
+
if (active == 0) {
history_type = GPM_HISTORY_RATE_VALUE;
/* TRANSLATORS: this is the X axis on the graph */
@@ -1394,9 +1394,9 @@ gpm_stats_type_combo_changed_cb (GtkWidget *widget, gpointer data)
guint active;
const gchar *axis_x = NULL;
const gchar *axis_y = NULL;
-
+
active = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
-
+
if (active == 0) {
stats_type = GPM_STATS_CHARGE_DATA_VALUE;
/* TRANSLATORS: this is the X axis on the graph for the whole battery device */
@@ -1444,9 +1444,9 @@ static void
gpm_stats_range_combo_changed (GtkWidget *widget, gpointer data)
{
guint active;
-
+
active = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
-
+
if (active == 0)
history_time = GPM_HISTORY_MINUTE_VALUE;
else if (active == 1)
@@ -1681,6 +1681,12 @@ main (int argc, char *argv[])
G_CALLBACK (gpm_stats_points_checkbox_stats_cb), NULL);
widget = GTK_WIDGET (gtk_builder_get_object (builder, "notebook1"));
+
+ gtk_widget_add_events (widget, GDK_SCROLL_MASK);
+ g_signal_connect (widget, "scroll-event",
+ G_CALLBACK (gpm_dialog_page_scroll_event_cb),
+ window);
+
page = g_settings_get_int (settings, GPM_SETTINGS_INFO_PAGE_NUMBER);
gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), page);
g_signal_connect (widget, "switch-page",