summaryrefslogtreecommitdiff
path: root/capplets
diff options
context:
space:
mode:
authorLaurent Napias <[email protected]>2019-06-26 22:51:52 +0200
committerraveit65 <[email protected]>2019-07-02 11:07:04 +0200
commitb931a8f99fc07cf860819507e18546bb9583a2f1 (patch)
tree3e0dfaa5be7b0e9f63f34bc147df4a688493f3c6 /capplets
parent566addef611bfab08379e29a16379e6a12642db7 (diff)
downloadmate-control-center-b931a8f99fc07cf860819507e18546bb9583a2f1.tar.bz2
mate-control-center-b931a8f99fc07cf860819507e18546bb9583a2f1.tar.xz
Add scroll tabs with mouse wheel in severals capplets
Diffstat (limited to 'capplets')
-rw-r--r--capplets/appearance/appearance-main.c8
-rw-r--r--capplets/common/capplet-util.c60
-rw-r--r--capplets/common/capplet-util.h1
-rw-r--r--capplets/default-applications/mate-da-capplet.c8
-rw-r--r--capplets/keyboard/mate-keyboard-properties.c17
-rw-r--r--capplets/mouse/mate-mouse-properties.c9
-rw-r--r--capplets/network/mate-network-properties.c7
-rw-r--r--capplets/windows/mate-window-properties.c11
8 files changed, 107 insertions, 14 deletions
diff --git a/capplets/appearance/appearance-main.c b/capplets/appearance/appearance-main.c
index bd6fc87f..3d401d4b 100644
--- a/capplets/appearance/appearance-main.c
+++ b/capplets/appearance/appearance-main.c
@@ -204,6 +204,12 @@ main (int argc, char **argv)
if (wallpaper_files && !install_filename && !start_page)
start_page = g_strdup ("background");
+ GtkNotebook* nb = GTK_NOTEBOOK(appearance_capplet_get_widget (data, "main_notebook"));
+ gtk_widget_add_events (GTK_WIDGET (nb), GDK_SCROLL_MASK);
+ g_signal_connect (GTK_WIDGET (nb), "scroll-event",
+ G_CALLBACK (capplet_dialog_page_scroll_event_cb),
+ GTK_WINDOW (w));
+
if (start_page != NULL) {
gchar *page_name;
@@ -212,10 +218,8 @@ main (int argc, char **argv)
w = appearance_capplet_get_widget (data, page_name);
if (w != NULL) {
- GtkNotebook *nb;
gint pindex;
- nb = GTK_NOTEBOOK (appearance_capplet_get_widget (data, "main_notebook"));
pindex = gtk_notebook_page_num (nb, w);
if (pindex != -1)
gtk_notebook_set_current_page (nb, pindex);
diff --git a/capplets/common/capplet-util.c b/capplets/common/capplet-util.c
index d2458d9b..b9fde6bb 100644
--- a/capplets/common/capplet-util.c
+++ b/capplets/common/capplet-util.c
@@ -170,6 +170,66 @@ capplet_file_delete_recursive (GFile *file, GError **error)
return g_file_delete (file, NULL, error);
}
+gboolean
+capplet_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;
+}
+
void
capplet_init (GOptionContext *context,
int *argc,
diff --git a/capplets/common/capplet-util.h b/capplets/common/capplet-util.h
index df79c20f..78fcfe13 100644
--- a/capplets/common/capplet-util.h
+++ b/capplets/common/capplet-util.h
@@ -39,6 +39,7 @@
void capplet_help (GtkWindow *parent, char const *section);
void capplet_set_icon (GtkWidget *window, char const *icon_file_name);
gboolean capplet_file_delete_recursive (GFile *directory, GError **error);
+gboolean capplet_dialog_page_scroll_event_cb (GtkWidget *widget, GdkEventScroll *event, GtkWindow *window);
void capplet_init (GOptionContext *context, int *argc, char ***argv);
#endif /* __CAPPLET_UTIL_H */
diff --git a/capplets/default-applications/mate-da-capplet.c b/capplets/default-applications/mate-da-capplet.c
index 11a57809..1ef41412 100644
--- a/capplets/default-applications/mate-da-capplet.c
+++ b/capplets/default-applications/mate-da-capplet.c
@@ -770,6 +770,12 @@ show_dialog(MateDACapplet* capplet, const gchar* start_page)
gtk_window_set_icon_name(GTK_WINDOW (capplet->window), "preferences-desktop-default-applications");
+ GtkNotebook* nb = GTK_NOTEBOOK(get_widget("preferred_apps_notebook"));
+ gtk_widget_add_events (GTK_WIDGET (nb), GDK_SCROLL_MASK);
+ g_signal_connect (GTK_WIDGET (nb), "scroll-event",
+ G_CALLBACK (capplet_dialog_page_scroll_event_cb),
+ GTK_WINDOW (capplet->window));
+
if (start_page != NULL)
{
gchar* page_name;
@@ -781,10 +787,8 @@ show_dialog(MateDACapplet* capplet, const gchar* start_page)
if (w != NULL)
{
- GtkNotebook* nb;
gint pindex;
- nb = GTK_NOTEBOOK(get_widget("preferred_apps_notebook"));
pindex = gtk_notebook_page_num(nb, w);
if (pindex != -1)
diff --git a/capplets/keyboard/mate-keyboard-properties.c b/capplets/keyboard/mate-keyboard-properties.c
index b9bd4d45..bc02a3bc 100644
--- a/capplets/keyboard/mate-keyboard-properties.c
+++ b/capplets/keyboard/mate-keyboard-properties.c
@@ -242,17 +242,18 @@ main (int argc, char **argv)
exit (EXIT_FAILURE);
setup_dialog (dialog);
+
+ GtkNotebook* nb = GTK_NOTEBOOK (WID ("keyboard_notebook"));
+ gtk_widget_add_events (GTK_WIDGET (nb), GDK_SCROLL_MASK);
+ g_signal_connect (GTK_WIDGET (nb), "scroll-event",
+ G_CALLBACK (capplet_dialog_page_scroll_event_cb),
+ GTK_WINDOW (WID ("keyboard_dialog")));
+
if (switch_to_typing_break_page) {
- gtk_notebook_set_current_page (GTK_NOTEBOOK
- (WID
- ("keyboard_notebook")),
- 4);
+ gtk_notebook_set_current_page (nb, 4);
}
else if (switch_to_a11y_page) {
- gtk_notebook_set_current_page (GTK_NOTEBOOK
- (WID
- ("keyboard_notebook")),
- 2);
+ gtk_notebook_set_current_page (nb, 2);
}
diff --git a/capplets/mouse/mate-mouse-properties.c b/capplets/mouse/mate-mouse-properties.c
index 194d4609..2c2292a4 100644
--- a/capplets/mouse/mate-mouse-properties.c
+++ b/capplets/mouse/mate-mouse-properties.c
@@ -445,6 +445,13 @@ main (int argc, char **argv)
g_signal_connect (dialog_win, "response",
G_CALLBACK (dialog_response_cb), NULL);
+ GtkNotebook* nb = GTK_NOTEBOOK (WID ("prefs_widget"));
+ gtk_widget_add_events (GTK_WIDGET (nb), GDK_SCROLL_MASK);
+ g_signal_connect (GTK_WIDGET (nb), "scroll-event",
+ G_CALLBACK (capplet_dialog_page_scroll_event_cb),
+ GTK_WINDOW (dialog_win));
+
+
if (start_page != NULL) {
gchar *page_name;
@@ -453,10 +460,8 @@ main (int argc, char **argv)
w = WID (page_name);
if (w != NULL) {
- GtkNotebook *nb;
gint pindex;
- nb = GTK_NOTEBOOK (WID ("prefs_widget"));
pindex = gtk_notebook_page_num (nb, w);
if (pindex != -1)
gtk_notebook_set_current_page (nb, pindex);
diff --git a/capplets/network/mate-network-properties.c b/capplets/network/mate-network-properties.c
index af17495b..8400e822 100644
--- a/capplets/network/mate-network-properties.c
+++ b/capplets/network/mate-network-properties.c
@@ -479,6 +479,13 @@ main (int argc, char **argv)
setup_dialog (builder);
widget = _gtk_builder_get_widget (builder, "network_dialog");
+
+ GtkNotebook* nb = GTK_NOTEBOOK (_gtk_builder_get_widget (builder, "notebook1"));
+ gtk_widget_add_events (GTK_WIDGET (nb), GDK_SCROLL_MASK);
+ g_signal_connect (GTK_WIDGET (nb), "scroll-event",
+ G_CALLBACK (capplet_dialog_page_scroll_event_cb),
+ GTK_WINDOW (widget));
+
capplet_set_icon (widget, "network-server");
gtk_widget_show_all (widget);
gtk_main ();
diff --git a/capplets/windows/mate-window-properties.c b/capplets/windows/mate-window-properties.c
index 3d27b35e..70cd671c 100644
--- a/capplets/windows/mate-window-properties.c
+++ b/capplets/windows/mate-window-properties.c
@@ -355,12 +355,23 @@ main (int argc, char **argv)
"gtk-close",
GTK_RESPONSE_CLOSE,
NULL);
+
//gtk_window_set_resizable (GTK_WINDOW (dialog_win), FALSE);
gtk_window_set_icon_name (GTK_WINDOW (dialog_win), "preferences-system-windows");
gtk_container_set_border_width (GTK_CONTAINER (dialog_win), 10);
nb = gtk_notebook_new ();
+ gtk_widget_add_events (GTK_WIDGET (nb), GDK_SCROLL_MASK);
+ g_signal_connect (GTK_WIDGET (nb), "scroll-event",
+ G_CALLBACK (capplet_dialog_page_scroll_event_cb),
+ GTK_WINDOW (widget));
+
+ gtk_widget_add_events (GTK_WIDGET (nb), GDK_SCROLL_MASK);
+ g_signal_connect (GTK_WIDGET (nb), "scroll-event",
+ G_CALLBACK (capplet_dialog_page_scroll_event_cb),
+ GTK_WINDOW (dialog_win));
+
general_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
behaviour_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
placement_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);