Implemented scrolling

This commit is contained in:
Moritz Lipp 2010-04-12 19:38:07 +02:00
parent 8394bd8dcc
commit f8eb8b7a9f
2 changed files with 28 additions and 1 deletions

View file

@ -103,6 +103,15 @@ InputbarShortcut inputbar_shortcuts[] = {
{GDK_CONTROL_MASK, GDK_w, isc_string_manipulation, { DELETE_LAST_WORD } }, {GDK_CONTROL_MASK, GDK_w, isc_string_manipulation, { DELETE_LAST_WORD } },
}; };
/* mouse settings */
MouseScrollEvent mouse_scroll_events[] = {
/* direction, function, argument */
{GDK_SCROLL_LEFT, sc_scroll, { LEFT } },
{GDK_SCROLL_UP, sc_scroll, { UP } },
{GDK_SCROLL_DOWN, sc_scroll, { DOWN } },
{GDK_SCROLL_RIGHT, sc_scroll, { RIGHT } },
};
/* commands */ /* commands */
Command commands[] = { Command commands[] = {
/* command, abbreviation, function, completion, description */ /* command, abbreviation, function, completion, description */

View file

@ -85,6 +85,13 @@ typedef struct
Argument argument; Argument argument;
} InputbarShortcut; } InputbarShortcut;
typedef struct
{
int direction;
void (*function)(Argument*);
Argument argument;
} MouseScrollEvent;
typedef struct typedef struct
{ {
char* command; char* command;
@ -1255,6 +1262,7 @@ sc_adjust_window(Argument* argument)
Zathura.PDF.scale = (view_size / page_width) * 100; Zathura.PDF.scale = (view_size / page_width) * 100;
draw(Zathura.PDF.page_number); draw(Zathura.PDF.page_number);
update_status();
} }
void void
@ -3074,7 +3082,17 @@ cb_view_button_pressed(GtkWidget* widget, GdkEventButton* event, gpointer data)
gboolean gboolean
cb_view_scrolled(GtkWidget* widget, GdkEventScroll* event, gpointer data) cb_view_scrolled(GtkWidget* widget, GdkEventScroll* event, gpointer data)
{ {
int i;
for(i = 0; i < LENGTH(mouse_scroll_events); i++)
{
if(event->direction == mouse_scroll_events[i].direction)
{
mouse_scroll_events[i].function(&(mouse_scroll_events[i].argument));
return TRUE; return TRUE;
}
}
return FALSE;
} }
/* main function */ /* main function */