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 #172

Closed
wants to merge 1 commit 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
60 changes: 60 additions & 0 deletions src/callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,3 +506,63 @@ cb_radio_processes(GtkAction *action, GtkRadioAction *current, gpointer data)
g_settings_set_int (procdata->settings, "view-as",
procdata->config.whose_process);
}

gboolean
cb_dialog_page_scroll_event(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;
}
4 changes: 4 additions & 0 deletions src/callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,8 @@ void cb_kill_sigstop(GtkAction *action,
void cb_kill_sigcont(GtkAction *action,
gpointer data);

gboolean cb_dialog_page_scroll_event(GtkWidget *widget,
GdkEventScroll *event,
GtkWindow *window);

#endif /* _PROCMAN_CALLBACKS_H_ */
5 changes: 5 additions & 0 deletions src/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,11 @@ create_main_window (ProcData *procdata)

/* create the main notebook */
procdata->notebook = notebook = gtk_notebook_new ();

gtk_widget_add_events (procdata->notebook, GDK_SCROLL_MASK);
g_signal_connect (procdata->notebook, "scroll-event",
G_CALLBACK (cb_dialog_page_scroll_event), GTK_WINDOW (app));

gtk_box_pack_start (GTK_BOX (main_box), notebook, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (notebook), 12);

Expand Down
5 changes: 5 additions & 0 deletions src/procdialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,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 (cb_dialog_page_scroll_event), 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