Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scroll interface tabs with mouse wheel #171

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ AC_PREREQ([2.63])

AC_INIT([mate-system-monitor],
[1.23.0],
[http://www.mate-desktop.org/])
[https://mate-desktop.org/])
AC_CONFIG_SRCDIR(configure.ac)
AC_CONFIG_HEADERS(config.h)
AC_CONFIG_MACRO_DIR([m4])
Expand Down
2 changes: 1 addition & 1 deletion mate-system-monitor.appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</image>
</screenshot>
</screenshots>
<url type="homepage">http://www.mate-desktop.org</url>
<url type="homepage">https://mate-desktop.org</url>
<updatecontact>[email protected]</updatecontact>
<project_group>MATE</project_group>
</component>
2 changes: 1 addition & 1 deletion org.mate.mate-system-monitor.policy.in.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
<policyconfig>
<vendor>MATE Desktop</vendor>
<vendor_url>http://www.mate-desktop.org/</vendor_url>
<vendor_url>https://mate-desktop.org/</vendor_url>
<icon_name>utilities-system-monitor</icon_name>

<action id="org.mate.mate-system-monitor.kill">
Expand Down
2 changes: 1 addition & 1 deletion src/callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ cb_about (GtkAction *action, gpointer data)
"translator-credits", _("translator-credits"),
"license", license_trans,
"wrap-license", TRUE,
"website", "http://www.mate-desktop.org",
"website", "https://mate-desktop.org",
NULL
);

Expand Down
64 changes: 64 additions & 0 deletions src/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,66 @@ static const char ui_info[] =
" </popup>";


static gboolean
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;
}

static GtkWidget *
create_proc_view (ProcData *procdata)
{
Expand Down Expand Up @@ -701,6 +761,10 @@ create_main_window (ProcData *procdata)
gtk_box_pack_start (GTK_BOX (main_box), notebook, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (notebook), 12);

gtk_widget_add_events (notebook, GDK_SCROLL_MASK);
g_signal_connect (notebook, "scroll-event",
G_CALLBACK (dialog_page_scroll_event_cb), GTK_WINDOW (app));

sysinfo_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); // procman_create_sysinfo_view();
sysinfo_label = gtk_label_new(_("System"));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), sysinfo_box, sysinfo_label);
Expand Down
65 changes: 65 additions & 0 deletions src/procdialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,66 @@ static GtkWidget *prefs_dialog = NULL;
static gint new_nice_value = 0;


static gboolean
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;
}

static void
kill_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
{
Expand Down Expand Up @@ -546,6 +606,11 @@ procdialog_create_preferences_dialog (ProcData *procdata)
gtk_box_set_spacing (GTK_BOX (main_vbox), 2);

notebook = gtk_notebook_new ();

gtk_widget_add_events (notebook, GDK_SCROLL_MASK);
g_signal_connect (notebook, "scroll-event",
G_CALLBACK (dialog_page_scroll_event_cb), GTK_WINDOW (dialog));

gtk_container_set_border_width (GTK_CONTAINER (notebook), 5);
gtk_box_pack_start (GTK_BOX (main_vbox), notebook, TRUE, TRUE, 0);

Expand Down