From 83865d89983d769177d47d147ae036aecba43cab Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Sun, 5 Aug 2012 02:30:03 +0200 Subject: [PATCH] Use GtkGrid instead of GtkTable --- config.c | 5 +++++ shortcuts.c | 3 +-- zathura.c | 20 ++++++++++++++++++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/config.c b/config.c index 191dc00..99443b3 100644 --- a/config.c +++ b/config.c @@ -53,8 +53,13 @@ cb_page_padding_changed(girara_session_t* session, const char* UNUSED(name), int val = *(int*) value; if (GTK_IS_TABLE(zathura->ui.page_widget) == TRUE) { +#if (GTK_MAJOR_VERSION == 3) + gtk_grid_set_row_spacing(GTK_GRID(zathura->ui.page_widget), val); + gtk_grid_set_column_spacing(GTK_GRID(zathura->ui.page_widget), val); +#else gtk_table_set_row_spacings(GTK_TABLE(zathura->ui.page_widget), val); gtk_table_set_col_spacings(GTK_TABLE(zathura->ui.page_widget), val); +#endif } } diff --git a/shortcuts.c b/shortcuts.c index 0782083..0e32481 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -343,7 +343,7 @@ sc_mouse_scroll(girara_session_t* session, girara_argument_t* argument, girara_e break; case GIRARA_EVENT_MOTION_NOTIFY: x_adj = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(session->gtk.view)); - y_adj =gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(session->gtk.view)); + y_adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(session->gtk.view)); if (x_adj == NULL || y_adj == NULL) { return false; @@ -543,7 +543,6 @@ sc_scroll(girara_session_t* session, girara_argument_t* argument, adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(session->gtk.view)); } - gdouble view_size = gtk_adjustment_get_page_size(adjustment); gdouble value = gtk_adjustment_get_value(adjustment); gdouble max = gtk_adjustment_get_upper(adjustment) - view_size; diff --git a/zathura.c b/zathura.c index 6cf4860..afe9307 100644 --- a/zathura.c +++ b/zathura.c @@ -227,7 +227,11 @@ zathura_init(int argc, char* argv[]) zathura->ui.session->events.unknown_command = cb_unknown_command; /* page view */ +#if (GTK_MAJOR_VERSION == 3) + zathura->ui.page_widget = gtk_grid_new(); +#else zathura->ui.page_widget = gtk_table_new(0, 0, TRUE); +#endif if (zathura->ui.page_widget == NULL) { goto error_free; } @@ -274,8 +278,13 @@ zathura_init(int argc, char* argv[]) int page_padding = 1; girara_setting_get(zathura->ui.session, "page-padding", &page_padding); +#if (GTK_MAJOR_VERSION == 3) + gtk_grid_set_row_spacing(GTK_GRID(zathura->ui.page_widget), page_padding); + gtk_grid_set_column_spacing(GTK_GRID(zathura->ui.page_widget), page_padding); +#else gtk_table_set_row_spacings(GTK_TABLE(zathura->ui.page_widget), page_padding); gtk_table_set_col_spacings(GTK_TABLE(zathura->ui.page_widget), page_padding); +#endif /* database */ char* database = NULL; @@ -937,15 +946,22 @@ page_widget_set_mode(zathura_t* zathura, unsigned int pages_per_row, unsigned in gtk_container_foreach(GTK_CONTAINER(zathura->ui.page_widget), remove_page_from_table, (gpointer)0); unsigned int number_of_pages = zathura_document_get_number_of_pages(zathura->document); +#if (GTK_MAJOR_VERSION == 3) +#else gtk_table_resize(GTK_TABLE(zathura->ui.page_widget), ceil((number_of_pages + first_page_column - 1) / pages_per_row), pages_per_row); - for (unsigned int i = 0; i < number_of_pages; i++) - { +#endif + + for (unsigned int i = 0; i < number_of_pages; i++) { int x = (i + first_page_column - 1) % pages_per_row; int y = (i + first_page_column - 1) / pages_per_row; zathura_page_t* page = zathura_document_get_page(zathura->document, i); GtkWidget* page_widget = zathura_page_get_widget(zathura, page); +#if (GTK_MAJOR_VERSION == 3) + gtk_grid_attach(GTK_GRID(zathura->ui.page_widget), page_widget, x, y, 1, 1); +#else gtk_table_attach(GTK_TABLE(zathura->ui.page_widget), page_widget, x, x + 1, y, y + 1, GTK_SHRINK, GTK_SHRINK, 0, 0); +#endif } gtk_widget_show_all(zathura->ui.page_widget);