[poppler] configure.ac glib/demo test/gtk-test.cc
Carlos Garcia Campos
carlosgc at kemper.freedesktop.org
Sat May 19 03:13:14 PDT 2012
configure.ac | 4
glib/demo/annots.c | 74 ++++++-------
glib/demo/attachments.c | 4
glib/demo/find.c | 4
glib/demo/fonts.c | 4
glib/demo/forms.c | 64 +++++------
glib/demo/images.c | 21 +--
glib/demo/info.cc | 67 +++++-------
glib/demo/layers.c | 22 +---
glib/demo/links.c | 6 -
glib/demo/main.c | 31 +----
glib/demo/outline.c | 2
glib/demo/page.c | 23 ++--
glib/demo/print.c | 14 --
glib/demo/render.c | 263 +++++++++++++-----------------------------------
glib/demo/selections.c | 77 +++++---------
glib/demo/text.c | 22 ++--
glib/demo/transitions.c | 4
glib/demo/utils.c | 101 +++++++++---------
glib/demo/utils.h | 6 -
test/gtk-test.cc | 48 +++++---
21 files changed, 350 insertions(+), 511 deletions(-)
New commits:
commit a24e326425e198eeb70c4d9205bb7a0a3a9db297
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date: Sat May 19 12:09:45 2012 +0200
gtk-tests: Port to GTK+ 3.0
diff --git a/configure.ac b/configure.ac
index abd6e5f..f9919d9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -644,9 +644,9 @@ AC_ARG_ENABLE(gtk-test,
enable_gtk_test=$enableval,
enable_gtk_test="try")
if test x$enable_gtk_test = xyes; then
- PKG_CHECK_MODULES(GTK_TEST, gtk+-2.0 >= 2.14 gdk-pixbuf-2.0 gthread-2.0)
+ PKG_CHECK_MODULES(GTK_TEST, gtk+-3.0 >= 3.0 gdk-pixbuf-2.0)
elif test x$enable_gtk_test = xtry; then
- PKG_CHECK_MODULES(GTK_TEST, gtk+-2.0 >= 2.14 gdk-pixbuf-2.0 gthread-2.0,
+ PKG_CHECK_MODULES(GTK_TEST, gtk+-3.0 >= 3.0 gdk-pixbuf-2.0,
[enable_gtk_test="yes"],
[enable_gtk_test="no"])
fi
diff --git a/glib/demo/annots.c b/glib/demo/annots.c
index 7075028..290847a 100644
--- a/glib/demo/annots.c
+++ b/glib/demo/annots.c
@@ -289,35 +289,35 @@ pgd_annot_view_set_annot_markup (GtkWidget *table,
PopplerRectangle rect;
text = poppler_annot_markup_get_label (markup);
- pgd_table_add_property (GTK_TABLE (table), "<b>Label:</b>", text, row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Label:</b>", text, row);
g_free (text);
if (poppler_annot_markup_has_popup (markup)) {
- pgd_table_add_property (GTK_TABLE (table), "<b>Popup is open:</b>",
+ pgd_table_add_property (GTK_GRID (table), "<b>Popup is open:</b>",
poppler_annot_markup_get_popup_is_open (markup) ? "Yes" : "No", row);
poppler_annot_markup_get_popup_rectangle (markup, &rect);
text = g_strdup_printf ("X1: %.2f, Y1: %.2f, X2: %.2f, Y2: %.2f",
rect.x1, rect.y1, rect.x2, rect.y2);
- pgd_table_add_property (GTK_TABLE (table), "<b>Popup Rectangle:</b>", text, row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Popup Rectangle:</b>", text, row);
g_free (text);
}
text = g_strdup_printf ("%f", poppler_annot_markup_get_opacity (markup));
- pgd_table_add_property (GTK_TABLE (table), "<b>Opacity:</b>", text, row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Opacity:</b>", text, row);
g_free (text);
text = get_markup_date (markup);
- pgd_table_add_property (GTK_TABLE (table), "<b>Date:</b>", text, row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Date:</b>", text, row);
g_free (text);
text = poppler_annot_markup_get_subject (markup);
- pgd_table_add_property (GTK_TABLE (table), "<b>Subject:</b>", text, row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Subject:</b>", text, row);
g_free (text);
- pgd_table_add_property (GTK_TABLE (table), "<b>Reply To:</b>", get_markup_reply_to (markup), row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Reply To:</b>", get_markup_reply_to (markup), row);
- pgd_table_add_property (GTK_TABLE (table), "<b>External Data:</b>", get_markup_external_data (markup), row);
+ pgd_table_add_property (GTK_GRID (table), "<b>External Data:</b>", get_markup_external_data (markup), row);
}
static void
@@ -327,14 +327,14 @@ pgd_annot_view_set_annot_text (GtkWidget *table,
{
gchar *text;
- pgd_table_add_property (GTK_TABLE (table), "<b>Is open:</b>",
+ pgd_table_add_property (GTK_GRID (table), "<b>Is open:</b>",
poppler_annot_text_get_is_open (annot) ? "Yes" : "No", row);
text = poppler_annot_text_get_icon (annot);
- pgd_table_add_property (GTK_TABLE (table), "<b>Icon:</b>", text, row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Icon:</b>", text, row);
g_free (text);
- pgd_table_add_property (GTK_TABLE (table), "<b>State:</b>", get_text_state (annot), row);
+ pgd_table_add_property (GTK_GRID (table), "<b>State:</b>", get_text_state (annot), row);
}
static void
@@ -344,10 +344,10 @@ pgd_annot_view_set_annot_free_text (GtkWidget *table,
{
gchar *text;
- pgd_table_add_property (GTK_TABLE (table), "<b>Quadding:</b>", get_free_text_quadding (annot), row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Quadding:</b>", get_free_text_quadding (annot), row);
text = get_free_text_callout_line (annot);
- pgd_table_add_property (GTK_TABLE (table), "<b>Callout:</b>", text, row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Callout:</b>", text, row);
g_free (text);
}
@@ -408,14 +408,14 @@ pgd_annot_view_set_annot_file_attachment (GtkWidget *table,
gchar *text;
text = poppler_annot_file_attachment_get_name (annot);
- pgd_table_add_property (GTK_TABLE (table), "<b>Attachment Name:</b>", text, row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Attachment Name:</b>", text, row);
g_free (text);
button = gtk_button_new_with_label ("Save Attachment");
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (pgd_annot_save_file_attachment_button_clicked),
(gpointer)annot);
- pgd_table_add_property_with_custom_widget (GTK_TABLE (table), "<b>File Attachment:</b>", button, row);
+ pgd_table_add_property_with_custom_widget (GTK_GRID (table), "<b>File Attachment:</b>", button, row);
gtk_widget_show (button);
}
@@ -429,12 +429,12 @@ pgd_annot_view_set_annot_movie (GtkWidget *table,
gchar *text;
text = poppler_annot_movie_get_title (annot);
- pgd_table_add_property (GTK_TABLE (table), "<b>Movie Title:</b>", text, row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Movie Title:</b>", text, row);
g_free (text);
movie_view = pgd_movie_view_new ();
pgd_movie_view_set_movie (movie_view, poppler_annot_movie_get_movie (annot));
- pgd_table_add_property_with_custom_widget (GTK_TABLE (table), "<b>Movie:</b>", movie_view, row);
+ pgd_table_add_property_with_custom_widget (GTK_GRID (table), "<b>Movie:</b>", movie_view, row);
gtk_widget_show (movie_view);
}
@@ -447,7 +447,7 @@ pgd_annot_view_set_annot_screen (GtkWidget *table,
action_view = pgd_action_view_new (NULL);
pgd_action_view_set_action (action_view, poppler_annot_screen_get_action (annot));
- pgd_table_add_property_with_custom_widget (GTK_TABLE (table), "<b>Action:</b>", action_view, row);
+ pgd_table_add_property_with_custom_widget (GTK_GRID (table), "<b>Action:</b>", action_view, row);
gtk_widget_show (action_view);
}
@@ -475,16 +475,16 @@ pgd_annot_view_set_annot (GtkWidget *annot_view,
if (!annot)
return;
- table = gtk_table_new (10, 2, FALSE);
- gtk_table_set_col_spacings (GTK_TABLE (table), 6);
- gtk_table_set_row_spacings (GTK_TABLE (table), 6);
+ table = gtk_grid_new ();
+ gtk_grid_set_column_spacing (GTK_GRID (table), 6);
+ gtk_grid_set_row_spacing (GTK_GRID (table), 6);
text = poppler_annot_get_contents (annot);
- pgd_table_add_property (GTK_TABLE (table), "<b>Contents:</b>", text, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Contents:</b>", text, &row);
g_free (text);
text = poppler_annot_get_name (annot);
- pgd_table_add_property (GTK_TABLE (table), "<b>Name:</b>", text, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Name:</b>", text, &row);
g_free (text);
text = poppler_annot_get_modified (annot);
@@ -492,15 +492,15 @@ pgd_annot_view_set_annot (GtkWidget *annot_view,
g_free (text);
text = pgd_format_date (timet);
}
- pgd_table_add_property (GTK_TABLE (table), "<b>Modified:</b>", text, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Modified:</b>", text, &row);
g_free (text);
text = g_strdup_printf ("%d", poppler_annot_get_flags (annot));
- pgd_table_add_property (GTK_TABLE (table), "<b>Flags:</b>", text, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Flags:</b>", text, &row);
g_free (text);
text = g_strdup_printf ("%d", poppler_annot_get_page_index (annot));
- pgd_table_add_property (GTK_TABLE (table), "<b>Page:</b>", text, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Page:</b>", text, &row);
g_free (text);
if (POPPLER_IS_ANNOT_MARKUP (annot))
@@ -666,22 +666,16 @@ pgd_annots_add_annot (GtkWidget *button,
vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
-#if GTK_CHECK_VERSION (2, 24, 0)
type_selector = gtk_combo_box_text_new ();
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (type_selector), "POPPLER_ANNOT_UNKNOWN");
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (type_selector), "POPPLER_ANNOT_TEXT");
-#else
- type_selector = gtk_combo_box_new_text ();
- gtk_combo_box_append_text (GTK_COMBO_BOX (type_selector), "POPPLER_ANNOT_UNKNOWN");
- gtk_combo_box_append_text (GTK_COMBO_BOX (type_selector), "POPPLER_ANNOT_TEXT");
-#endif
gtk_combo_box_set_active (GTK_COMBO_BOX (type_selector), 1);
gtk_box_pack_start (GTK_BOX (vbox), type_selector, TRUE, TRUE, 0);
gtk_widget_show (type_selector);
- hbox = gtk_hbox_new (FALSE, 6);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
- rect_hbox = gtk_hbox_new (FALSE, 6);
+ rect_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
label = gtk_label_new ("x1:");
gtk_box_pack_start (GTK_BOX (rect_hbox), label, TRUE, TRUE, 0);
@@ -694,7 +688,7 @@ pgd_annots_add_annot (GtkWidget *button,
gtk_box_pack_start (GTK_BOX (hbox), rect_hbox, FALSE, TRUE, 0);
gtk_widget_show (rect_hbox);
- rect_hbox = gtk_hbox_new (FALSE, 6);
+ rect_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
label = gtk_label_new ("x2:");
gtk_box_pack_start (GTK_BOX (rect_hbox), label, TRUE, TRUE, 0);
@@ -707,7 +701,7 @@ pgd_annots_add_annot (GtkWidget *button,
gtk_box_pack_start (GTK_BOX (hbox), rect_hbox, FALSE, TRUE, 0);
gtk_widget_show (rect_hbox);
- rect_hbox = gtk_hbox_new (FALSE, 6);
+ rect_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
label = gtk_label_new ("y1:");
gtk_box_pack_start (GTK_BOX (rect_hbox), label, TRUE, TRUE, 0);
@@ -720,7 +714,7 @@ pgd_annots_add_annot (GtkWidget *button,
gtk_box_pack_start (GTK_BOX (hbox), rect_hbox, FALSE, TRUE, 0);
gtk_widget_show (rect_hbox);
- rect_hbox = gtk_hbox_new (FALSE, 6);
+ rect_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
label = gtk_label_new ("y2:");
gtk_box_pack_start (GTK_BOX (rect_hbox), label, TRUE, TRUE, 0);
@@ -771,9 +765,9 @@ pgd_annots_create_widget (PopplerDocument *document)
n_pages = poppler_document_get_n_pages (document);
- vbox = gtk_vbox_new (FALSE, 12);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
- hbox = gtk_hbox_new (FALSE, 6);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
label = gtk_label_new ("Page:");
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
@@ -815,7 +809,7 @@ pgd_annots_create_widget (PopplerDocument *document)
gtk_box_pack_start (GTK_BOX (vbox), demo->timer_label, FALSE, TRUE, 0);
gtk_widget_show (demo->timer_label);
- hpaned = gtk_hpaned_new ();
+ hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
demo->annot_view = pgd_annot_view_new ();
diff --git a/glib/demo/attachments.c b/glib/demo/attachments.c
index 63565dd..1b74274 100644
--- a/glib/demo/attachments.c
+++ b/glib/demo/attachments.c
@@ -280,7 +280,7 @@ pgd_attachments_create_widget (PopplerDocument *document)
GtkWidget *hbox, *button;
gboolean has_attachments;
- vbox = gtk_vbox_new (FALSE, 12);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
swindow = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
@@ -327,7 +327,7 @@ pgd_attachments_create_widget (PopplerDocument *document)
if (!has_attachments)
return vbox;
- hbox = gtk_hbutton_box_new ();
+ hbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_SPREAD);
button = gtk_button_new_with_label ("Save");
diff --git a/glib/demo/find.c b/glib/demo/find.c
index 632e610..0fdce85 100644
--- a/glib/demo/find.c
+++ b/glib/demo/find.c
@@ -190,9 +190,9 @@ pgd_find_create_widget (PopplerDocument *document)
demo->n_pages = poppler_document_get_n_pages (document);
- vbox = gtk_vbox_new (FALSE, 12);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
- hbox = gtk_hbox_new (FALSE, 6);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
demo->entry = gtk_entry_new ();
gtk_box_pack_start (GTK_BOX (hbox), demo->entry, FALSE, TRUE, 0);
diff --git a/glib/demo/fonts.c b/glib/demo/fonts.c
index 24eb87c..d0ffa3d 100644
--- a/glib/demo/fonts.c
+++ b/glib/demo/fonts.c
@@ -228,9 +228,9 @@ pgd_fonts_create_widget (PopplerDocument *document)
demo->doc = g_object_ref (document);
- vbox = gtk_vbox_new (FALSE, 12);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
- hbox = gtk_hbox_new (FALSE, 6);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
demo->progress = gtk_progress_bar_new ();
gtk_progress_bar_set_ellipsize (GTK_PROGRESS_BAR (demo->progress),
diff --git a/glib/demo/forms.c b/glib/demo/forms.c
index 3a74ef5..9dfe3cd 100644
--- a/glib/demo/forms.c
+++ b/glib/demo/forms.c
@@ -79,7 +79,7 @@ pgd_form_field_view_new (void)
}
static void
-pgd_form_field_view_add_choice_items (GtkTable *table,
+pgd_form_field_view_add_choice_items (GtkGrid *table,
PopplerFormField *field,
gint *selected,
gint *row)
@@ -92,8 +92,7 @@ pgd_form_field_view_add_choice_items (GtkTable *table,
label = gtk_label_new (NULL);
g_object_set (G_OBJECT (label), "xalign", 0.0, NULL);
gtk_label_set_markup (GTK_LABEL (label), "<b>Items:</b>");
- gtk_table_attach (GTK_TABLE (table), label, 0, 1, *row, *row + 1,
- GTK_FILL, GTK_FILL, 0, 0);
+ gtk_grid_attach (GTK_GRID (table), label, 0, *row, 1, 1);
gtk_widget_show (label);
swindow = gtk_scrolled_window_new (NULL, NULL);
@@ -120,8 +119,7 @@ pgd_form_field_view_add_choice_items (GtkTable *table,
gtk_container_add (GTK_CONTAINER (swindow), textview);
gtk_widget_show (textview);
- gtk_table_attach (GTK_TABLE (table), swindow, 1, 2, *row, *row + 1,
- GTK_FILL, GTK_FILL, 0, 0);
+ gtk_grid_attach (GTK_GRID (table), swindow, 1, *row, 1, 1);
gtk_widget_show (swindow);
*row += 1;
@@ -151,23 +149,23 @@ pgd_form_field_view_set_field (GtkWidget *field_view,
if (!field)
return;
- table = gtk_table_new (13, 2, FALSE);
- gtk_table_set_col_spacings (GTK_TABLE (table), 6);
- gtk_table_set_row_spacings (GTK_TABLE (table), 6);
+ table = gtk_grid_new ();
+ gtk_grid_set_column_spacing (GTK_GRID (table), 6);
+ gtk_grid_set_row_spacing (GTK_GRID (table), 6);
text = poppler_form_field_get_name (field);
if (text) {
- pgd_table_add_property (GTK_TABLE (table), "<b>Name:</b>", text, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Name:</b>", text, &row);
g_free (text);
}
text = poppler_form_field_get_partial_name (field);
if (text) {
- pgd_table_add_property (GTK_TABLE (table), "<b>Partial Name:</b>", text, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Partial Name:</b>", text, &row);
g_free (text);
}
text = poppler_form_field_get_mapping_name (field);
if (text) {
- pgd_table_add_property (GTK_TABLE (table), "<b>Mapping Name:</b>", text, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Mapping Name:</b>", text, &row);
g_free (text);
}
@@ -177,7 +175,7 @@ pgd_form_field_view_set_field (GtkWidget *field_view,
action_view = pgd_action_view_new (NULL);
pgd_action_view_set_action (action_view, action);
- pgd_table_add_property_with_custom_widget (GTK_TABLE (table), "<b>Action:</b>", action_view, &row);
+ pgd_table_add_property_with_custom_widget (GTK_GRID (table), "<b>Action:</b>", action_view, &row);
gtk_widget_show (action_view);
}
@@ -185,30 +183,30 @@ pgd_form_field_view_set_field (GtkWidget *field_view,
case POPPLER_FORM_FIELD_BUTTON:
enum_value = g_enum_get_value ((GEnumClass *) g_type_class_ref (POPPLER_TYPE_FORM_BUTTON_TYPE),
poppler_form_field_button_get_button_type (field));
- pgd_table_add_property (GTK_TABLE (table), "<b>Button Type:</b>", enum_value->value_name, &row);
- pgd_table_add_property (GTK_TABLE (table), "<b>Button State:</b>",
+ pgd_table_add_property (GTK_GRID (table), "<b>Button Type:</b>", enum_value->value_name, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Button State:</b>",
poppler_form_field_button_get_state (field) ? "Active" : "Inactive", &row);
break;
case POPPLER_FORM_FIELD_TEXT:
enum_value = g_enum_get_value ((GEnumClass *) g_type_class_ref (POPPLER_TYPE_FORM_TEXT_TYPE),
poppler_form_field_text_get_text_type (field));
- pgd_table_add_property (GTK_TABLE (table), "<b>Text Type:</b>", enum_value->value_name, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Text Type:</b>", enum_value->value_name, &row);
text = poppler_form_field_text_get_text (field);
- pgd_table_add_property (GTK_TABLE (table), "<b>Contents:</b>", text, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Contents:</b>", text, &row);
g_free (text);
text = g_strdup_printf ("%d", poppler_form_field_text_get_max_len (field));
- pgd_table_add_property (GTK_TABLE (table), "<b>Max Length:</b>", text, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Max Length:</b>", text, &row);
g_free (text);
- pgd_table_add_property (GTK_TABLE (table), "<b>Do spellcheck:</b>",
+ pgd_table_add_property (GTK_GRID (table), "<b>Do spellcheck:</b>",
poppler_form_field_text_do_spell_check (field) ? "Yes" : "No", &row);
- pgd_table_add_property (GTK_TABLE (table), "<b>Do scroll:</b>",
+ pgd_table_add_property (GTK_GRID (table), "<b>Do scroll:</b>",
poppler_form_field_text_do_scroll (field) ? "Yes" : "No", &row);
- pgd_table_add_property (GTK_TABLE (table), "<b>Rich Text:</b>",
+ pgd_table_add_property (GTK_GRID (table), "<b>Rich Text:</b>",
poppler_form_field_text_is_rich_text (field) ? "Yes" : "No", &row);
- pgd_table_add_property (GTK_TABLE (table), "<b>Pasword type:</b>",
+ pgd_table_add_property (GTK_GRID (table), "<b>Pasword type:</b>",
poppler_form_field_text_is_password (field) ? "Yes" : "No", &row);
break;
case POPPLER_FORM_FIELD_CHOICE: {
@@ -217,32 +215,32 @@ pgd_form_field_view_set_field (GtkWidget *field_view,
enum_value = g_enum_get_value ((GEnumClass *) g_type_class_ref (POPPLER_TYPE_FORM_CHOICE_TYPE),
poppler_form_field_choice_get_choice_type (field));
- pgd_table_add_property (GTK_TABLE (table), "<b>Choice Type:</b>", enum_value->value_name, &row);
- pgd_table_add_property (GTK_TABLE (table), "<b>Editable:</b>",
+ pgd_table_add_property (GTK_GRID (table), "<b>Choice Type:</b>", enum_value->value_name, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Editable:</b>",
poppler_form_field_choice_is_editable (field) ? "Yes" : "No", &row);
- pgd_table_add_property (GTK_TABLE (table), "<b>Multiple Selection:</b>",
+ pgd_table_add_property (GTK_GRID (table), "<b>Multiple Selection:</b>",
poppler_form_field_choice_can_select_multiple (field) ? "Yes" : "No", &row);
- pgd_table_add_property (GTK_TABLE (table), "<b>Do spellcheck:</b>",
+ pgd_table_add_property (GTK_GRID (table), "<b>Do spellcheck:</b>",
poppler_form_field_choice_do_spell_check (field) ? "Yes" : "No", &row);
- pgd_table_add_property (GTK_TABLE (table), "<b>Commit on Change:</b>",
+ pgd_table_add_property (GTK_GRID (table), "<b>Commit on Change:</b>",
poppler_form_field_choice_commit_on_change (field) ? "Yes" : "No", &row);
text = g_strdup_printf ("%d", poppler_form_field_choice_get_n_items (field));
- pgd_table_add_property (GTK_TABLE (table), "<b>Number of items:</b>", text, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Number of items:</b>", text, &row);
g_free (text);
- pgd_form_field_view_add_choice_items (GTK_TABLE (table), field, &selected, &row);
+ pgd_form_field_view_add_choice_items (GTK_GRID (table), field, &selected, &row);
if (selected >= 0 && poppler_form_field_choice_get_n_items (field) > selected) {
item = poppler_form_field_choice_get_item (field, selected);
text = g_strdup_printf ("%d (%s)", selected, item);
g_free (item);
- pgd_table_add_property (GTK_TABLE (table), "<b>Selected item:</b>", text, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Selected item:</b>", text, &row);
g_free (text);
}
text = poppler_form_field_choice_get_text (field);
- pgd_table_add_property (GTK_TABLE (table), "<b>Contents:</b>", text, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Contents:</b>", text, &row);
g_free (text);
}
break;
@@ -390,9 +388,9 @@ pgd_forms_create_widget (PopplerDocument *document)
n_pages = poppler_document_get_n_pages (document);
- vbox = gtk_vbox_new (FALSE, 12);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
- hbox = gtk_hbox_new (FALSE, 6);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
label = gtk_label_new ("Page:");
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
@@ -427,7 +425,7 @@ pgd_forms_create_widget (PopplerDocument *document)
gtk_box_pack_start (GTK_BOX (vbox), demo->timer_label, FALSE, TRUE, 0);
gtk_widget_show (demo->timer_label);
- hpaned = gtk_hpaned_new ();
+ hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
demo->field_view = pgd_form_field_view_new ();
diff --git a/glib/demo/images.c b/glib/demo/images.c
index 6e987d2..3623fd7 100644
--- a/glib/demo/images.c
+++ b/glib/demo/images.c
@@ -61,11 +61,10 @@ pgd_images_free (PgdImagesDemo *demo)
}
static gboolean
-pgd_image_view_drawing_area_expose (GtkWidget *area,
- GdkEventExpose *event,
- GtkWidget *image_view)
+pgd_image_view_drawing_area_draw (GtkWidget *area,
+ cairo_t *cr,
+ GtkWidget *image_view)
{
- cairo_t *cr;
cairo_surface_t *image;
image = g_object_get_data (G_OBJECT (image_view), "image-surface");
@@ -75,11 +74,9 @@ pgd_image_view_drawing_area_expose (GtkWidget *area,
gtk_widget_set_size_request (area,
cairo_image_surface_get_width (image),
cairo_image_surface_get_height (image));
-
- cr = gdk_cairo_create (gtk_widget_get_window (area));
+
cairo_set_source_surface (cr, image, 0, 0);
cairo_paint (cr);
- cairo_destroy (cr);
return TRUE;
}
@@ -93,8 +90,8 @@ pgd_image_view_new ()
swindow = gtk_scrolled_window_new (NULL, NULL);
darea = gtk_drawing_area_new ();
- g_signal_connect (G_OBJECT (darea), "expose_event",
- G_CALLBACK (pgd_image_view_drawing_area_expose),
+ g_signal_connect (G_OBJECT (darea), "draw",
+ G_CALLBACK (pgd_image_view_drawing_area_draw),
(gpointer)swindow);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
@@ -229,9 +226,9 @@ pgd_images_create_widget (PopplerDocument *document)
n_pages = poppler_document_get_n_pages (document);
- vbox = gtk_vbox_new (FALSE, 12);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
- hbox = gtk_hbox_new (FALSE, 6);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
label = gtk_label_new ("Page:");
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
@@ -266,7 +263,7 @@ pgd_images_create_widget (PopplerDocument *document)
gtk_box_pack_start (GTK_BOX (vbox), demo->timer_label, FALSE, TRUE, 0);
gtk_widget_show (demo->timer_label);
- hpaned = gtk_hpaned_new ();
+ hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
demo->image_view = pgd_image_view_new ();
diff --git a/glib/demo/info.cc b/glib/demo/info.cc
index e05cc15..590ddc7 100644
--- a/glib/demo/info.cc
+++ b/glib/demo/info.cc
@@ -23,7 +23,7 @@
#include "utils.h"
static void
-pgd_info_add_permissions (GtkTable *table,
+pgd_info_add_permissions (GtkGrid *table,
PopplerPermissions permissions,
gint *row)
{
@@ -33,12 +33,11 @@ pgd_info_add_permissions (GtkTable *table,
label = gtk_label_new (NULL);
g_object_set (G_OBJECT (label), "xalign", 0.0, NULL);
gtk_label_set_markup (GTK_LABEL (label), "<b>Permissions:</b>");
- gtk_table_attach (GTK_TABLE (table), label, 0, 1, *row, *row + 1,
- GTK_FILL, GTK_FILL, 0, 0);
+ gtk_grid_attach (GTK_GRID (table), label, 0, *row, 1, 1);
gtk_widget_show (label);
- vbox = gtk_vbox_new (FALSE, 0);
- hbox = gtk_hbox_new (FALSE, 6);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
checkbox = gtk_check_button_new_with_label ("Print");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox),
@@ -73,7 +72,7 @@ pgd_info_add_permissions (GtkTable *table,
gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
gtk_widget_show (hbox);
- hbox = gtk_hbox_new (FALSE, 6);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
checkbox = gtk_check_button_new_with_label ("Extract contents");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox),
@@ -96,15 +95,14 @@ pgd_info_add_permissions (GtkTable *table,
gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
gtk_widget_show (hbox);
- gtk_table_attach (GTK_TABLE (table), vbox, 1, 2, *row, *row + 1,
- GTK_FILL, GTK_FILL, 0, 0);
+ gtk_grid_attach (GTK_GRID (table), vbox, 1, *row, 1, 1);
gtk_widget_show (vbox);
*row += 1;
}
static void
-pgd_info_add_metadata (GtkTable *table,
+pgd_info_add_metadata (GtkGrid *table,
const gchar *metadata,
gint *row)
{
@@ -115,8 +113,7 @@ pgd_info_add_metadata (GtkTable *table,
label = gtk_label_new (NULL);
g_object_set (G_OBJECT (label), "xalign", 0.0, NULL);
gtk_label_set_markup (GTK_LABEL (label), "<b>Metadata:</b>");
- gtk_table_attach (GTK_TABLE (table), label, 0, 1, *row, *row + 1,
- GTK_FILL, GTK_FILL, 0, 0);
+ gtk_grid_attach (GTK_GRID (table), label, 0, *row, 1, 1);
gtk_widget_show (label);
swindow = gtk_scrolled_window_new (NULL, NULL);
@@ -132,10 +129,10 @@ pgd_info_add_metadata (GtkTable *table,
gtk_container_add (GTK_CONTAINER (swindow), textview);
gtk_widget_show (textview);
-
- gtk_table_attach (GTK_TABLE (table), swindow, 1, 2, *row, *row + 1,
- (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
- (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0);
+
+ gtk_grid_attach (GTK_GRID (table), swindow, 1, *row, 1, 1);
+ gtk_widget_set_hexpand (swindow, TRUE);
+ gtk_widget_set_vexpand (swindow, TRUE);
gtk_widget_show (swindow);
*row += 1;
@@ -181,7 +178,7 @@ pgd_info_create_widget (PopplerDocument *document)
"metadata", &metadata,
NULL);
- vbox = gtk_vbox_new (FALSE, 12);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
backend = poppler_get_backend ();
enum_value = g_enum_get_value ((GEnumClass *) g_type_class_ref (POPPLER_TYPE_BACKEND), backend);
@@ -205,61 +202,61 @@ pgd_info_create_widget (PopplerDocument *document)
gtk_container_add (GTK_CONTAINER (frame), alignment);
gtk_widget_show (alignment);
- table = gtk_table_new (14, 2, FALSE);
- gtk_table_set_col_spacings (GTK_TABLE (table), 6);
- gtk_table_set_row_spacings (GTK_TABLE (table), 6);
+ table = gtk_grid_new ();
+ gtk_grid_set_column_spacing (GTK_GRID (table), 6);
+ gtk_grid_set_row_spacing (GTK_GRID (table), 6);
- pgd_table_add_property (GTK_TABLE (table), "<b>Format:</b>", format, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Format:</b>", format, &row);
g_free (format);
- pgd_table_add_property (GTK_TABLE (table), "<b>Title:</b>", title, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Title:</b>", title, &row);
g_free (title);
- pgd_table_add_property (GTK_TABLE (table), "<b>Author:</b>", author, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Author:</b>", author, &row);
g_free (author);
- pgd_table_add_property (GTK_TABLE (table), "<b>Subject:</b>", subject, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Subject:</b>", subject, &row);
g_free (subject);
- pgd_table_add_property (GTK_TABLE (table), "<b>Keywords:</b>", keywords, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Keywords:</b>", keywords, &row);
g_free (keywords);
- pgd_table_add_property (GTK_TABLE (table), "<b>Creator:</b>", creator, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Creator:</b>", creator, &row);
g_free (creator);
- pgd_table_add_property (GTK_TABLE (table), "<b>Producer:</b>", producer, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Producer:</b>", producer, &row);
g_free (producer);
- pgd_table_add_property (GTK_TABLE (table), "<b>Linearized:</b>", linearized ? "Yes" : "No", &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Linearized:</b>", linearized ? "Yes" : "No", &row);
str = pgd_format_date (creation_date);
- pgd_table_add_property (GTK_TABLE (table), "<b>Creation Date:</b>", str, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Creation Date:</b>", str, &row);
g_free (str);
str = pgd_format_date (mod_date);
- pgd_table_add_property (GTK_TABLE (table), "<b>Modification Date:</b>", str, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Modification Date:</b>", str, &row);
g_free (str);
enum_value = g_enum_get_value ((GEnumClass *) g_type_class_peek (POPPLER_TYPE_PAGE_MODE), mode);
- pgd_table_add_property (GTK_TABLE (table), "<b>Page Mode:</b>", enum_value->value_name, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Page Mode:</b>", enum_value->value_name, &row);
enum_value = g_enum_get_value ((GEnumClass *) g_type_class_peek (POPPLER_TYPE_PAGE_LAYOUT), layout);
- pgd_table_add_property (GTK_TABLE (table), "<b>Page Layout:</b>", enum_value->value_name, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Page Layout:</b>", enum_value->value_name, &row);
if (poppler_document_get_id (document, &perm_id, &up_id)) {
str = g_strndup (perm_id, 32);
g_free (perm_id);
- pgd_table_add_property (GTK_TABLE (table), "<b>Permanent ID:</b>", str, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Permanent ID:</b>", str, &row);
g_free (str);
str = g_strndup (up_id, 32);
g_free (up_id);
- pgd_table_add_property (GTK_TABLE (table), "<b>Update ID:</b>", str, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Update ID:</b>", str, &row);
g_free (str);
}
- pgd_info_add_permissions (GTK_TABLE (table), permissions, &row);
+ pgd_info_add_permissions (GTK_GRID (table), permissions, &row);
- pgd_info_add_metadata (GTK_TABLE (table), metadata, &row);
+ pgd_info_add_metadata (GTK_GRID (table), metadata, &row);
g_free (metadata);
/* TODO: view_prefs */
diff --git a/glib/demo/layers.c b/glib/demo/layers.c
index fc0ba35..c55de42 100644
--- a/glib/demo/layers.c
+++ b/glib/demo/layers.c
@@ -181,24 +181,18 @@ pgd_layers_render_page (PgdLayersDemo *demo)
}
static gboolean
-pgd_layers_viewer_drawing_area_expose (GtkWidget *area,
- GdkEventExpose *event,
- PgdLayersDemo *demo)
+pgd_layers_viewer_drawing_area_draw (GtkWidget *area,
+ cairo_t *cr,
+ PgdLayersDemo *demo)
{
- cairo_t *cr;
-
if (!demo->surface) {
demo->surface = pgd_layers_render_page (demo);
if (!demo->surface)
return FALSE;
}
- gdk_window_clear (gtk_widget_get_window (area));
-
- cr = gdk_cairo_create (gtk_widget_get_window (area));
cairo_set_source_surface (cr, demo->surface, 0, 0);
cairo_paint (cr);
- cairo_destroy (cr);
return TRUE;
}
@@ -238,9 +232,9 @@ pgd_layers_create_viewer (PgdLayersDemo *demo)
guint n_pages;
gchar *str;
- vbox = gtk_vbox_new (FALSE, 6);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- hbox = gtk_hbox_new (FALSE, 6);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
label = gtk_label_new ("Page:");
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
@@ -264,8 +258,8 @@ pgd_layers_create_viewer (PgdLayersDemo *demo)
gtk_widget_show (hbox);
demo->darea = gtk_drawing_area_new ();
- g_signal_connect (G_OBJECT (demo->darea), "expose_event",
- G_CALLBACK (pgd_layers_viewer_drawing_area_expose),
+ g_signal_connect (G_OBJECT (demo->darea), "draw",
+ G_CALLBACK (pgd_layers_viewer_drawing_area_draw),
(gpointer)demo);
swindow = gtk_scrolled_window_new (NULL, NULL);
@@ -385,7 +379,7 @@ pgd_layers_create_widget (PopplerDocument *document)
demo = g_new0 (PgdLayersDemo, 1);
demo->doc = g_object_ref (document);
- hpaned = gtk_hpaned_new ();
+ hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
viewer = pgd_layers_create_viewer (demo);
diff --git a/glib/demo/links.c b/glib/demo/links.c
index 6cb4a5d..3670436 100644
--- a/glib/demo/links.c
+++ b/glib/demo/links.c
@@ -178,9 +178,9 @@ pgd_links_create_widget (PopplerDocument *document)
n_pages = poppler_document_get_n_pages (document);
- vbox = gtk_vbox_new (FALSE, 12);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
- hbox = gtk_hbox_new (FALSE, 6);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
label = gtk_label_new ("Page:");
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
@@ -215,7 +215,7 @@ pgd_links_create_widget (PopplerDocument *document)
gtk_box_pack_start (GTK_BOX (vbox), demo->timer_label, FALSE, TRUE, 0);
gtk_widget_show (demo->timer_label);
- hpaned = gtk_hpaned_new ();
+ hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
demo->action_view = pgd_action_view_new (document);
diff --git a/glib/demo/main.c b/glib/demo/main.c
index d8ed142..2523800 100644
--- a/glib/demo/main.c
+++ b/glib/demo/main.c
@@ -180,9 +180,6 @@ pgd_demo_get_auth_dialog (GFile *uri_file)
action_area = gtk_dialog_get_action_area (dialog);
/* Set the dialog up with HIG properties */
-#if !GTK_CHECK_VERSION (2, 22, 0)
- gtk_dialog_set_has_separator (dialog, FALSE);
-#endif
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
@@ -206,7 +203,7 @@ pgd_demo_get_auth_dialog (GFile *uri_file)
-1);
/* Build contents */
- hbox = gtk_hbox_new (FALSE, 12);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 0);
gtk_widget_show (hbox);
@@ -218,7 +215,7 @@ pgd_demo_get_auth_dialog (GFile *uri_file)
gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
gtk_widget_show (icon);
- main_vbox = gtk_vbox_new (FALSE, 18);
+ main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
gtk_box_pack_start (GTK_BOX (hbox), main_vbox, TRUE, TRUE, 0);
gtk_widget_show (main_vbox);
@@ -238,7 +235,7 @@ pgd_demo_get_auth_dialog (GFile *uri_file)
FALSE, FALSE, 0);
gtk_widget_show (label);
- vbox = gtk_vbox_new (FALSE, 6);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0);
gtk_widget_show (vbox);
@@ -252,9 +249,9 @@ pgd_demo_get_auth_dialog (GFile *uri_file)
FALSE, FALSE, 0);
gtk_widget_show (entry_container);
- table = gtk_table_new (1, 2, FALSE);
- gtk_table_set_col_spacings (GTK_TABLE (table), 12);
- gtk_table_set_row_spacings (GTK_TABLE (table), 6);
+ table = gtk_grid_new ();
+ gtk_grid_set_column_spacing (GTK_GRID (table), 12);
+ gtk_grid_set_row_spacing (GTK_GRID (table), 6);
gtk_container_add (GTK_CONTAINER (entry_container), table);
gtk_widget_show (table);
@@ -270,13 +267,11 @@ pgd_demo_get_auth_dialog (GFile *uri_file)
G_CALLBACK (pgd_demo_auth_dialog_entry_activated),
dialog);
- gtk_table_attach (GTK_TABLE (table), label,
- 0, 1, 0, 1,
- GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
+ gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1);
gtk_widget_show (label);
- gtk_table_attach_defaults (GTK_TABLE (table), password_entry,
- 1, 2, 0, 1);
+ gtk_grid_attach (GTK_GRID (table), password_entry, 1, 0, 1, 1);
+ gtk_widget_set_hexpand (password_entry, TRUE);
gtk_widget_show (password_entry);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), password_entry);
@@ -303,12 +298,6 @@ gint main (gint argc, gchar **argv)
return 1;
}
-/* Threading is always enabled starting from GLib 2.24.0 */
-#if !GLIB_CHECK_VERSION (2, 24, 0)
- if (!g_thread_supported ())
- g_thread_init (NULL);
-#endif
-
gtk_init (&argc, &argv);
file = g_file_new_for_commandline_arg (argv[1]);
@@ -368,7 +357,7 @@ gint main (gint argc, gchar **argv)
g_closure_unref (closure);
gtk_window_add_accel_group (GTK_WINDOW(win), gtk_accel);
- hbox = gtk_hbox_new (FALSE, 6);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
treeview = pgd_demo_list_create ();
gtk_box_pack_start (GTK_BOX (hbox), treeview, FALSE, TRUE, 0);
diff --git a/glib/demo/outline.c b/glib/demo/outline.c
index 5dc7189..55874cc 100644
--- a/glib/demo/outline.c
+++ b/glib/demo/outline.c
@@ -161,7 +161,7 @@ pgd_outline_create_widget (PopplerDocument *document)
GtkTreeSelection *selection;
GtkWidget *hpaned, *action;
- hpaned = gtk_hpaned_new ();
+ hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
action = pgd_action_view_new (document);
diff --git a/glib/demo/page.c b/glib/demo/page.c
index 7ab008c..ddf7789 100644
--- a/glib/demo/page.c
+++ b/glib/demo/page.c
@@ -229,9 +229,9 @@ pgd_page_create_widget (PopplerDocument *document)
n_pages = poppler_document_get_n_pages (document);
- vbox = gtk_vbox_new (FALSE, 12);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
- hbox = gtk_hbox_new (FALSE, 6);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
label = gtk_label_new ("Page:");
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
@@ -260,7 +260,7 @@ pgd_page_create_widget (PopplerDocument *document)
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
gtk_widget_show (hbox);
- hbox = gtk_hbox_new (FALSE, 6);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
@@ -274,18 +274,17 @@ pgd_page_create_widget (PopplerDocument *document)
gtk_container_add (GTK_CONTAINER (frame), alignment);
gtk_widget_show (alignment);
- table = gtk_table_new (3, 2, FALSE);
+ table = gtk_grid_new ();
+ gtk_grid_set_column_spacing (GTK_GRID (table), 6);
+ gtk_grid_set_row_spacing (GTK_GRID (table), 6);
- gtk_table_set_col_spacings (GTK_TABLE (table), 6);
- gtk_table_set_row_spacings (GTK_TABLE (table), 6);
-
- pgd_table_add_property_with_value_widget (GTK_TABLE (table), "<b>Page Index:</b>",
+ pgd_table_add_property_with_value_widget (GTK_GRID (table), "<b>Page Index:</b>",
&(demo->index), NULL, &row);
- pgd_table_add_property_with_value_widget (GTK_TABLE (table), "<b>Page Label:</b>",
+ pgd_table_add_property_with_value_widget (GTK_GRID (table), "<b>Page Label:</b>",
&(demo->label), NULL, &row);
- pgd_table_add_property_with_value_widget (GTK_TABLE (table), "<b>Page Size:</b>",
+ pgd_table_add_property_with_value_widget (GTK_GRID (table), "<b>Page Size:</b>",
&(demo->size), NULL, &row);
- pgd_table_add_property_with_value_widget (GTK_TABLE (table), "<b>Page Duration:</b>",
+ pgd_table_add_property_with_value_widget (GTK_GRID (table), "<b>Page Duration:</b>",
&(demo->duration), NULL, &row);
gtk_container_add (GTK_CONTAINER (alignment), table);
@@ -307,7 +306,7 @@ pgd_page_create_widget (PopplerDocument *document)
gtk_container_add (GTK_CONTAINER (frame), alignment);
gtk_widget_show (alignment);
- thumnail_box = gtk_vbox_new (FALSE, 6);
+ thumnail_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
demo->thumbnail = gtk_image_new ();
gtk_box_pack_start (GTK_BOX (thumnail_box), demo->thumbnail, TRUE, TRUE, 0);
diff --git a/glib/demo/print.c b/glib/demo/print.c
index 17bbe0e..8147036 100644
--- a/glib/demo/print.c
+++ b/glib/demo/print.c
@@ -114,24 +114,18 @@ pgd_print_create_custom_widget (GtkPrintOperation *op,
PGD_PRINT_OPTIONS,
PRINT_DOCUMENT_MARKUPS);
- hbox = gtk_hbox_new (FALSE, 0);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 12);
label = gtk_label_new ("Print: ");
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
-#if GTK_CHECK_VERSION (2, 24, 0)
combo = gtk_combo_box_text_new ();
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "Document");
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "Document and markup");
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "Document and stamps");
-#else
- combo = gtk_combo_box_new_text ();
- gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "Document");
- gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "Document and markup");
- gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "Document and stamps");
-#endif
+
demo->options_combo = combo;
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), options);
gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);
@@ -210,9 +204,9 @@ pgd_print_create_widget (PopplerDocument *document)
demo->doc = g_object_ref (document);
- vbox = gtk_vbox_new (FALSE, 12);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
- hbox = gtk_hbox_new (FALSE, 6);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
button = gtk_button_new_with_label ("Print...");
g_signal_connect (G_OBJECT (button), "clicked",
diff --git a/glib/demo/render.c b/glib/demo/render.c
index bb7afbd..48e9210 100644
--- a/glib/demo/render.c
+++ b/glib/demo/render.c
@@ -23,16 +23,10 @@
#include "render.h"
-typedef enum {
- PGD_RENDER_CAIRO,
- PGD_RENDER_PIXBUF
-} PgdRenderMode;
-
typedef struct {
PopplerDocument *doc;
/* Properties */
- PgdRenderMode mode;
gint page;
gdouble scale;
gint rotate;
@@ -48,7 +42,6 @@ typedef struct {
GtkWidget *timer_label;
cairo_surface_t *surface;
- GdkPixbuf *pixbuf;
} PgdRenderDemo;
static void
@@ -61,53 +54,25 @@ pgd_render_free (PgdRenderDemo *demo)
g_object_unref (demo->doc);
demo->doc = NULL;
}
-
+
if (demo->surface) {
cairo_surface_destroy (demo->surface);
demo->surface = NULL;
}
- if (demo->pixbuf) {
- g_object_unref (demo->pixbuf);
- demo->pixbuf = NULL;
- }
-
g_free (demo);
}
static gboolean
-pgd_render_drawing_area_expose (GtkWidget *area,
- GdkEventExpose *event,
- PgdRenderDemo *demo)
+pgd_render_drawing_area_draw (GtkWidget *area,
+ cairo_t *cr,
+ PgdRenderDemo *demo)
{
- if (demo->mode == PGD_RENDER_CAIRO && !demo->surface)
+ if (!demo->surface)
return FALSE;
- if (demo->mode == PGD_RENDER_PIXBUF && !demo->pixbuf)
- return FALSE;
-
- gdk_window_clear (gtk_widget_get_window (area));
-
- if (demo->mode == PGD_RENDER_CAIRO) {
- cairo_t *cr;
-
- cr = gdk_cairo_create (gtk_widget_get_window (area));
- cairo_set_source_surface (cr, demo->surface, 0, 0);
- cairo_paint (cr);
- cairo_destroy (cr);
- } else if (demo->mode == PGD_RENDER_PIXBUF) {
- gdk_draw_pixbuf (gtk_widget_get_window (area),
- gtk_widget_get_style(area)->fg_gc[GTK_STATE_NORMAL],
- demo->pixbuf,
- 0, 0,
- 0, 0,
- gdk_pixbuf_get_width (demo->pixbuf),
- gdk_pixbuf_get_height (demo->pixbuf),
- GDK_RGB_DITHER_NORMAL,
- 0, 0);
- } else {
- g_assert_not_reached ();
- }
+ cairo_set_source_surface (cr, demo->surface, 0, 0);
+ cairo_paint (cr);
return TRUE;
}
@@ -122,6 +87,7 @@ pgd_render_start (GtkButton *button,
gint x, y;
gchar *str;
GTimer *timer;
+ cairo_t *cr;
page = poppler_document_get_page (demo->doc, demo->page);
if (!page)
@@ -131,10 +97,6 @@ pgd_render_start (GtkButton *button,
cairo_surface_destroy (demo->surface);
demo->surface = NULL;
- if (demo->pixbuf)
- g_object_unref (demo->pixbuf);
- demo->pixbuf = NULL;
-
poppler_page_get_size (page, &page_width, &page_height);
if (demo->rotate == 0 || demo->rotate == 180) {
@@ -149,90 +111,58 @@ pgd_render_start (GtkButton *button,
y = demo->slice.x * demo->scale;
}
- if (demo->mode == PGD_RENDER_CAIRO) {
- cairo_t *cr;
-
- timer = g_timer_new ();
- demo->surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
- width, height);
- cr = cairo_create (demo->surface);
-
- cairo_save (cr);
- switch (demo->rotate) {
- case 90:
- cairo_translate (cr, x + width, -y);
- break;
- case 180:
- cairo_translate (cr, x + width, y + height);
- break;
- case 270:
- cairo_translate (cr, -x, y + height);
- break;
- default:
- cairo_translate (cr, -x, -y);
- }
-
- if (demo->scale != 1.0)
- cairo_scale (cr, demo->scale, demo->scale);
-
- if (demo->rotate != 0)
- cairo_rotate (cr, demo->rotate * G_PI / 180.0);
-
- if (demo->printing)
- poppler_page_render_for_printing (page, cr);
- else
- poppler_page_render (page, cr);
- cairo_restore (cr);
-
- cairo_set_operator (cr, CAIRO_OPERATOR_DEST_OVER);
- cairo_set_source_rgb (cr, 1., 1., 1.);
- cairo_paint (cr);
-
- g_timer_stop (timer);
-
- cairo_destroy (cr);
- } else if (demo->mode == PGD_RENDER_PIXBUF) {
-#ifdef POPPLER_WITH_GDK
- timer = g_timer_new ();
- demo->pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
- FALSE, 8, width, height);
- gdk_pixbuf_fill (demo->pixbuf, 0xffffff);
- if (demo->printing) {
- poppler_page_render_to_pixbuf_for_printing (page,
- x, y,
- width,
- height,
- demo->scale,
- demo->rotate,
- demo->pixbuf);
- } else {
- poppler_page_render_to_pixbuf (page,
- x, y,
- width,
- height,
- demo->scale,
- demo->rotate,
- demo->pixbuf);
- }
- g_timer_stop (timer);
-#endif /* POPPLER_WITH_GDK */
- } else {
- g_assert_not_reached ();
- }
-
+ timer = g_timer_new ();
+ demo->surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+ width, height);
+ cr = cairo_create (demo->surface);
+
+ cairo_save (cr);
+ switch (demo->rotate) {
+ case 90:
+ cairo_translate (cr, x + width, -y);
+ break;
+ case 180:
+ cairo_translate (cr, x + width, y + height);
+ break;
+ case 270:
+ cairo_translate (cr, -x, y + height);
+ break;
+ default:
+ cairo_translate (cr, -x, -y);
+ }
+
+ if (demo->scale != 1.0)
+ cairo_scale (cr, demo->scale, demo->scale);
+
+ if (demo->rotate != 0)
+ cairo_rotate (cr, demo->rotate * G_PI / 180.0);
+
+ if (demo->printing)
+ poppler_page_render_for_printing (page, cr);
+ else
+ poppler_page_render (page, cr);
+ cairo_restore (cr);
+
+ cairo_set_operator (cr, CAIRO_OPERATOR_DEST_OVER);
+ cairo_set_source_rgb (cr, 1., 1., 1.);
+ cairo_paint (cr);
+
+ g_timer_stop (timer);
+
+ cairo_destroy (cr);
g_object_unref (page);
-
+
str = g_strdup_printf ("<i>Page rendered in %.4f seconds</i>",
g_timer_elapsed (timer, NULL));
gtk_label_set_markup (GTK_LABEL (demo->timer_label), str);
g_free (str);
-
+
g_timer_destroy (timer);
-
+
gtk_widget_set_size_request (demo->darea, width, height);
gtk_widget_queue_draw (demo->darea);
}
-
+
static void
pgd_render_slice_selector_setup (PgdRenderDemo *demo)
{
@@ -288,13 +218,6 @@ pgd_render_printing_selector_changed (GtkToggleButton *tooglebutton,
}
static void
-pgd_render_mode_selector_changed (GtkComboBox *combobox,
- PgdRenderDemo *demo)
-{
- demo->mode = gtk_combo_box_get_active (combobox);
-}
-
-static void
pgd_render_slice_selector_value_changed (GtkSpinButton *spinbutton,
PgdRenderDemo *demo)
{
@@ -312,7 +235,6 @@ pgd_render_properties_selector_create (PgdRenderDemo *demo)
GtkWidget *page_hbox, *page_selector;
GtkWidget *scale_hbox, *scale_selector;
GtkWidget *rotate_hbox, *rotate_selector;
- GtkWidget *mode_hbox, *mode_selector;
GtkWidget *printing_selector;
GtkWidget *slice_hbox, *slice_selector;
GtkWidget *button;
@@ -321,18 +243,18 @@ pgd_render_properties_selector_create (PgdRenderDemo *demo)
n_pages = poppler_document_get_n_pages (demo->doc);
- vbox = gtk_vbox_new (FALSE, 6);
-
- hbox = gtk_hbox_new (FALSE, 12);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
gtk_widget_show (hbox);
- page_hbox = gtk_hbox_new (FALSE, 6);
+ page_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
label = gtk_label_new ("Page:");
gtk_box_pack_start (GTK_BOX (page_hbox), label, TRUE, TRUE, 0);
gtk_widget_show (label);
-
+
page_selector = gtk_spin_button_new_with_range (1, n_pages, 1);
g_signal_connect (G_OBJECT (page_selector), "value-changed",
G_CALLBACK (pgd_render_page_selector_value_changed),
@@ -349,12 +271,12 @@ pgd_render_properties_selector_create (PgdRenderDemo *demo)
gtk_box_pack_start (GTK_BOX (hbox), page_hbox, FALSE, TRUE, 0);
gtk_widget_show (page_hbox);
- scale_hbox = gtk_hbox_new (FALSE, 6);
-
+ scale_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+
label = gtk_label_new ("Scale:");
gtk_box_pack_start (GTK_BOX (scale_hbox), label, TRUE, TRUE, 0);
gtk_widget_show (label);
-
+
scale_selector = gtk_spin_button_new_with_range (0, 10.0, 0.1);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (scale_selector), 1.0);
g_signal_connect (G_OBJECT (scale_selector), "value-changed",
@@ -366,25 +288,17 @@ pgd_render_properties_selector_create (PgdRenderDemo *demo)
gtk_box_pack_start (GTK_BOX (hbox), scale_hbox, FALSE, TRUE, 0);
gtk_widget_show (scale_hbox);
- rotate_hbox = gtk_hbox_new (FALSE, 6);
+ rotate_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
label = gtk_label_new ("Rotate:");
gtk_box_pack_start (GTK_BOX (rotate_hbox), label, TRUE, TRUE, 0);
gtk_widget_show (label);
-#if GTK_CHECK_VERSION (2, 24, 0)
rotate_selector = gtk_combo_box_text_new ();
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (rotate_selector), "0");
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (rotate_selector), "90");
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (rotate_selector), "180");
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (rotate_selector), "270");
-#else
- rotate_selector = gtk_combo_box_new_text ();
- gtk_combo_box_append_text (GTK_COMBO_BOX (rotate_selector), "0");
- gtk_combo_box_append_text (GTK_COMBO_BOX (rotate_selector), "90");
- gtk_combo_box_append_text (GTK_COMBO_BOX (rotate_selector), "180");
- gtk_combo_box_append_text (GTK_COMBO_BOX (rotate_selector), "270");
-#endif
gtk_combo_box_set_active (GTK_COMBO_BOX (rotate_selector), 0);
g_signal_connect (G_OBJECT (rotate_selector), "changed",
G_CALLBACK (pgd_render_rotate_selector_changed),
@@ -395,35 +309,6 @@ pgd_render_properties_selector_create (PgdRenderDemo *demo)
gtk_box_pack_start (GTK_BOX (hbox), rotate_hbox, FALSE, TRUE, 0);
gtk_widget_show (rotate_hbox);
- mode_hbox = gtk_hbox_new (FALSE, 6);
-
- label = gtk_label_new ("Mode:");
- gtk_box_pack_start (GTK_BOX (mode_hbox), label, TRUE, TRUE, 0);
- gtk_widget_show (label);
-
-#if GTK_CHECK_VERSION (2, 24, 0)
- mode_selector = gtk_combo_box_text_new ();
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (mode_selector), "cairo");
-#ifdef POPPLER_WITH_GDK
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (mode_selector), "pixbuf");
-#endif
-#else // ! GTK_CHECK_VERSION (2, 24, 0)
- mode_selector = gtk_combo_box_new_text ();
- gtk_combo_box_append_text (GTK_COMBO_BOX (mode_selector), "cairo");
-#ifdef POPPLER_WITH_GDK
- gtk_combo_box_append_text (GTK_COMBO_BOX (mode_selector), "pixbuf");
-#endif
-#endif // GTK_CHECK_VERSION (2, 24, 0)
- gtk_combo_box_set_active (GTK_COMBO_BOX (mode_selector), 0);
- g_signal_connect (G_OBJECT (mode_selector), "changed",
- G_CALLBACK (pgd_render_mode_selector_changed),
- (gpointer)demo);
- gtk_box_pack_start (GTK_BOX (mode_hbox), mode_selector, TRUE, TRUE, 0);
- gtk_widget_show (mode_selector);
-
- gtk_box_pack_start (GTK_BOX (hbox), mode_hbox, FALSE, TRUE, 0);
- gtk_widget_show (mode_hbox);
-
printing_selector = gtk_check_button_new_with_label ("Printing");
g_signal_connect (printing_selector, "toggled",
G_CALLBACK (pgd_render_printing_selector_changed),
@@ -431,11 +316,11 @@ pgd_render_properties_selector_create (PgdRenderDemo *demo)
gtk_box_pack_start (GTK_BOX (hbox), printing_selector, FALSE, TRUE, 0);
gtk_widget_show (printing_selector);
- hbox = gtk_hbox_new (FALSE, 12);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
gtk_widget_show (hbox);
- slice_hbox = gtk_hbox_new (FALSE, 6);
+ slice_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
label = gtk_label_new ("x:");
gtk_box_pack_start (GTK_BOX (slice_hbox), label, TRUE, TRUE, 0);
@@ -451,8 +336,8 @@ pgd_render_properties_selector_create (PgdRenderDemo *demo)
gtk_box_pack_start (GTK_BOX (hbox), slice_hbox, FALSE, TRUE, 0);
gtk_widget_show (slice_hbox);
- slice_hbox = gtk_hbox_new (FALSE, 6);
-
+ slice_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+
label = gtk_label_new ("y:");
gtk_box_pack_start (GTK_BOX (slice_hbox), label, TRUE, TRUE, 0);
gtk_widget_show (label);
@@ -466,9 +351,9 @@ pgd_render_properties_selector_create (PgdRenderDemo *demo)
gtk_box_pack_start (GTK_BOX (hbox), slice_hbox, FALSE, TRUE, 0);
gtk_widget_show (slice_hbox);
-
- slice_hbox = gtk_hbox_new (FALSE, 6);
-
+
+ slice_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+
label = gtk_label_new ("width:");
gtk_box_pack_start (GTK_BOX (slice_hbox), label, TRUE, TRUE, 0);
gtk_widget_show (label);
@@ -482,9 +367,9 @@ pgd_render_properties_selector_create (PgdRenderDemo *demo)
gtk_box_pack_start (GTK_BOX (hbox), slice_hbox, FALSE, TRUE, 0);
gtk_widget_show (slice_hbox);
-
- slice_hbox = gtk_hbox_new (FALSE, 6);
-
+
+ slice_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+
label = gtk_label_new ("height:");
gtk_box_pack_start (GTK_BOX (slice_hbox), label, TRUE, TRUE, 0);
gtk_widget_show (label);
@@ -528,17 +413,17 @@ pgd_render_create_widget (PopplerDocument *document)
demo->doc = g_object_ref (document);
demo->scale = 1.0;
- vbox = gtk_vbox_new (FALSE, 6);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
hbox = pgd_render_properties_selector_create (demo);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 6);
gtk_widget_show (hbox);
demo->darea = gtk_drawing_area_new ();
- g_signal_connect (G_OBJECT (demo->darea), "expose_event",
- G_CALLBACK (pgd_render_drawing_area_expose),
+ g_signal_connect (G_OBJECT (demo->darea), "draw",
+ G_CALLBACK (pgd_render_drawing_area_draw),
(gpointer)demo);
-
+
demo->swindow = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (demo->swindow),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
diff --git a/glib/demo/selections.c b/glib/demo/selections.c
index bfd9070..b3095fe 100644
--- a/glib/demo/selections.c
+++ b/glib/demo/selections.c
@@ -172,7 +172,7 @@ pgd_selections_update_cursor (PgdSelectionsDemo *demo,
gdk_window_set_cursor (window, cursor);
gdk_flush ();
if (cursor)
- gdk_cursor_unref (cursor);
+ g_object_unref (cursor);
}
static gboolean
@@ -220,19 +220,13 @@ pgd_selections_render_selections (PgdSelectionsDemo *demo)
}
static gboolean
-pgd_selections_drawing_area_expose (GtkWidget *area,
- GdkEventExpose *event,
- PgdSelectionsDemo *demo)
+pgd_selections_drawing_area_draw (GtkWidget *area,
+ cairo_t *cr,
+ PgdSelectionsDemo *demo)
{
- cairo_t *cr;
-
if (!demo->surface)
return FALSE;
- gdk_window_clear (gtk_widget_get_window (area));
-
- cr = gdk_cairo_create (gtk_widget_get_window (area));
-
cairo_save (cr);
cairo_set_source_surface (cr, demo->surface, 0, 0);
cairo_paint (cr);
@@ -243,8 +237,6 @@ pgd_selections_drawing_area_expose (GtkWidget *area,
cairo_paint (cr);
}
- cairo_destroy (cr);
-
return TRUE;
}
@@ -335,7 +327,8 @@ static void
pgd_selections_drawing_area_realize (GtkWidget *area,
PgdSelectionsDemo *demo)
{
- GtkStyle *style = gtk_widget_get_style (area);
+ GtkStyleContext *style_context = gtk_widget_get_style_context (area);
+ GdkRGBA rgba;
gtk_widget_add_events (area,
GDK_POINTER_MOTION_HINT_MASK |
@@ -344,10 +337,10 @@ pgd_selections_drawing_area_realize (GtkWidget *area,
GDK_BUTTON_RELEASE_MASK);
g_object_set (area, "has-tooltip", TRUE, NULL);
- gtk_color_button_set_color (GTK_COLOR_BUTTON (demo->fg_color_button),
- &style->text[GTK_STATE_SELECTED]);
- gtk_color_button_set_color (GTK_COLOR_BUTTON (demo->bg_color_button),
- &style->base[GTK_STATE_SELECTED]);
+ gtk_style_context_get_color (style_context, GTK_STATE_FLAG_SELECTED, &rgba);
+ gtk_color_button_set_rgba (GTK_COLOR_BUTTON (demo->fg_color_button), &rgba);
+ gtk_style_context_get_background_color (style_context, GTK_STATE_FLAG_SELECTED, &rgba);
+ gtk_color_button_set_rgba (GTK_COLOR_BUTTON (demo->bg_color_button), &rgba);
}
static gboolean
@@ -463,12 +456,12 @@ pgd_selections_fg_color_changed (GtkColorButton *button,
GParamSpec *pspec,
PgdSelectionsDemo *demo)
{
- GdkColor color;
+ GdkRGBA color;
- gtk_color_button_get_color (GTK_COLOR_BUTTON (button), &color);
- demo->glyph_color.red = color.red;
- demo->glyph_color.green = color.green;
- demo->glyph_color.blue = color.blue;
+ gtk_color_button_get_rgba (GTK_COLOR_BUTTON (button), &color);
+ demo->glyph_color.red = CLAMP ((guint) (color.red * 65535), 0, 65535);
+ demo->glyph_color.green = CLAMP ((guint) (color.green * 65535), 0, 65535);
+ demo->glyph_color.blue = CLAMP ((guint) (color.blue * 65535), 0, 65535);
}
static void
@@ -476,12 +469,12 @@ pgd_selections_bg_color_changed (GtkColorButton *button,
GParamSpec *pspec,
PgdSelectionsDemo *demo)
{
- GdkColor color;
+ GdkRGBA color;
- gtk_color_button_get_color (GTK_COLOR_BUTTON (button), &color);
- demo->background_color.red = color.red;
- demo->background_color.green = color.green;
- demo->background_color.blue = color.blue;
+ gtk_color_button_get_rgba (GTK_COLOR_BUTTON (button), &color);
+ demo->background_color.red = CLAMP ((guint) (color.red * 65535), 0, 65535);
+ demo->background_color.green = CLAMP ((guint) (color.green * 65535), 0, 65535);
+ demo->background_color.blue = CLAMP ((guint) (color.blue * 65535), 0, 65535);
}
GtkWidget *
@@ -499,13 +492,13 @@ pgd_selections_properties_selector_create (PgdSelectionsDemo *demo)
n_pages = poppler_document_get_n_pages (demo->doc);
- vbox = gtk_vbox_new (FALSE, 6);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- hbox = gtk_hbox_new (FALSE, 12);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
gtk_widget_show (hbox);
- page_hbox = gtk_hbox_new (FALSE, 6);
+ page_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
label = gtk_label_new ("Page:");
gtk_box_pack_start (GTK_BOX (page_hbox), label, TRUE, TRUE, 0);
@@ -527,7 +520,7 @@ pgd_selections_properties_selector_create (PgdSelectionsDemo *demo)
gtk_box_pack_start (GTK_BOX (hbox), page_hbox, FALSE, TRUE, 0);
gtk_widget_show (page_hbox);
- scale_hbox = gtk_hbox_new (FALSE, 6);
+ scale_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
label = gtk_label_new ("Scale:");
gtk_box_pack_start (GTK_BOX (scale_hbox), label, TRUE, TRUE, 0);
@@ -544,25 +537,17 @@ pgd_selections_properties_selector_create (PgdSelectionsDemo *demo)
gtk_box_pack_start (GTK_BOX (hbox), scale_hbox, FALSE, TRUE, 0);
gtk_widget_show (scale_hbox);
- rotate_hbox = gtk_hbox_new (FALSE, 6);
+ rotate_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
label = gtk_label_new ("Rotate:");
gtk_box_pack_start (GTK_BOX (rotate_hbox), label, TRUE, TRUE, 0);
gtk_widget_show (label);
-#if GTK_CHECK_VERSION (2, 24, 0)
rotate_selector = gtk_combo_box_text_new ();
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (rotate_selector), "0");
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (rotate_selector), "90");
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (rotate_selector), "180");
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (rotate_selector), "270");
-#else
- rotate_selector = gtk_combo_box_new_text ();
- gtk_combo_box_append_text (GTK_COMBO_BOX (rotate_selector), "0");
- gtk_combo_box_append_text (GTK_COMBO_BOX (rotate_selector), "90");
- gtk_combo_box_append_text (GTK_COMBO_BOX (rotate_selector), "180");
- gtk_combo_box_append_text (GTK_COMBO_BOX (rotate_selector), "270");
-#endif
gtk_combo_box_set_active (GTK_COMBO_BOX (rotate_selector), 0);
#if 0
g_signal_connect (G_OBJECT (rotate_selector), "changed",
@@ -575,11 +560,11 @@ pgd_selections_properties_selector_create (PgdSelectionsDemo *demo)
gtk_box_pack_start (GTK_BOX (hbox), rotate_hbox, FALSE, TRUE, 0);
gtk_widget_show (rotate_hbox);
- hbox = gtk_hbox_new (FALSE, 12);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
gtk_widget_show (hbox);
- color_hbox = gtk_hbox_new (FALSE, 6);
+ color_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
label = gtk_label_new ("Foreground Color:");
gtk_box_pack_start (GTK_BOX (color_hbox), label, TRUE, TRUE, 0);
@@ -595,7 +580,7 @@ pgd_selections_properties_selector_create (PgdSelectionsDemo *demo)
gtk_box_pack_start (GTK_BOX (hbox), color_hbox, FALSE, TRUE, 0);
gtk_widget_show (color_hbox);
- color_hbox = gtk_hbox_new (FALSE, 6);
+ color_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
label = gtk_label_new ("Background Color:");
gtk_box_pack_start (GTK_BOX (color_hbox), label, TRUE, TRUE, 0);
@@ -643,7 +628,7 @@ pgd_selections_create_widget (PopplerDocument *document)
pgd_selections_clear_selections (demo);
- vbox = gtk_vbox_new (FALSE, 6);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
hbox = pgd_selections_properties_selector_create (demo);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 6);
@@ -653,8 +638,8 @@ pgd_selections_create_widget (PopplerDocument *document)
g_signal_connect (demo->darea, "realize",
G_CALLBACK (pgd_selections_drawing_area_realize),
(gpointer)demo);
- g_signal_connect (demo->darea, "expose_event",
- G_CALLBACK (pgd_selections_drawing_area_expose),
+ g_signal_connect (demo->darea, "draw",
+ G_CALLBACK (pgd_selections_drawing_area_draw),
(gpointer)demo);
g_signal_connect (demo->darea, "button_press_event",
G_CALLBACK (pgd_selections_drawing_area_button_press),
diff --git a/glib/demo/text.c b/glib/demo/text.c
index 3a7b2cd..0d3781e 100644
--- a/glib/demo/text.c
+++ b/glib/demo/text.c
@@ -303,11 +303,11 @@ pgd_text_create_widget (PopplerDocument *document)
n_pages = poppler_document_get_n_pages (document);
- vbox = gtk_vbox_new (FALSE, 12);
- vbox2 = gtk_vbox_new (FALSE, 12);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
+ vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
textinfo = gtk_label_new ("TextInfo");
- hbox = gtk_hbox_new (FALSE, 6);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
label = gtk_label_new ("Page:");
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
@@ -342,7 +342,7 @@ pgd_text_create_widget (PopplerDocument *document)
gtk_box_pack_start (GTK_BOX (vbox), demo->timer_label, FALSE, TRUE, 0);
gtk_widget_show (demo->timer_label);
- hpaned = gtk_hpaned_new ();
+ hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
gtk_paned_set_position (GTK_PANED (hpaned), 300);
swindow = gtk_scrolled_window_new (NULL, NULL);
@@ -414,18 +414,18 @@ pgd_text_create_widget (PopplerDocument *document)
gtk_container_add (GTK_CONTAINER (frame), alignment);
gtk_widget_show (alignment);
- table = gtk_table_new (4, 2, FALSE);
- gtk_table_set_col_spacings (GTK_TABLE (table), 6);
- gtk_table_set_row_spacings (GTK_TABLE (table), 6);
+ table = gtk_grid_new ();
+ gtk_grid_set_column_spacing (GTK_GRID (table), 6);
+ gtk_grid_set_row_spacing (GTK_GRID (table), 6);
demo->font_name = gtk_label_new (NULL);
- pgd_table_add_property_with_custom_widget (GTK_TABLE (table), "<b>Font Name:</b>", demo->font_name, &row);
+ pgd_table_add_property_with_custom_widget (GTK_GRID (table), "<b>Font Name:</b>", demo->font_name, &row);
demo->font_size = gtk_label_new (NULL);
- pgd_table_add_property_with_custom_widget (GTK_TABLE (table), "<b>Font Size:</b>", demo->font_size, &row);
+ pgd_table_add_property_with_custom_widget (GTK_GRID (table), "<b>Font Size:</b>", demo->font_size, &row);
demo->is_underlined = gtk_label_new (NULL);
- pgd_table_add_property_with_custom_widget (GTK_TABLE (table), "<b>Underlined:</b>", demo->is_underlined, &row);
+ pgd_table_add_property_with_custom_widget (GTK_GRID (table), "<b>Underlined:</b>", demo->is_underlined, &row);
demo->text_color = gtk_image_new ();
- pgd_table_add_property_with_custom_widget (GTK_TABLE (table), "<b>Color:</b>", demo->text_color, &row);
+ pgd_table_add_property_with_custom_widget (GTK_GRID (table), "<b>Color:</b>", demo->text_color, &row);
gtk_container_add (GTK_CONTAINER (alignment), table);
gtk_widget_show (table);
diff --git a/glib/demo/transitions.c b/glib/demo/transitions.c
index b6188b5..e6e2ab4 100644
--- a/glib/demo/transitions.c
+++ b/glib/demo/transitions.c
@@ -275,9 +275,9 @@ pgd_transitions_create_widget (PopplerDocument *document)
demo->doc = g_object_ref (document);
- vbox = gtk_vbox_new (FALSE, 12);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
- hbox = gtk_hbox_new (FALSE, 6);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
demo->progress = gtk_progress_bar_new ();
gtk_progress_bar_set_ellipsize (GTK_PROGRESS_BAR (demo->progress),
diff --git a/glib/demo/utils.c b/glib/demo/utils.c
index 625596c..f1d47c8 100644
--- a/glib/demo/utils.c
+++ b/glib/demo/utils.c
@@ -24,7 +24,7 @@
#include "utils.h"
void
-pgd_table_add_property_with_custom_widget (GtkTable *table,
+pgd_table_add_property_with_custom_widget (GtkGrid *table,
const gchar *markup,
GtkWidget *widget,
gint *row)
@@ -34,19 +34,18 @@ pgd_table_add_property_with_custom_widget (GtkTable *table,
label = gtk_label_new (NULL);
g_object_set (G_OBJECT (label), "xalign", 0.0, NULL);
gtk_label_set_markup (GTK_LABEL (label), markup);
- gtk_table_attach (GTK_TABLE (table), label, 0, 1, *row, *row + 1,
- GTK_FILL, GTK_FILL, 0, 0);
+ gtk_grid_attach (GTK_GRID (table), label, 0, *row, 1, 1);
gtk_widget_show (label);
- gtk_table_attach (GTK_TABLE (table), widget, 1, 2, *row, *row + 1,
- GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
+ gtk_grid_attach (GTK_GRID (table), widget, 1, *row, 1, 1);
+ gtk_widget_set_hexpand (widget, TRUE);
gtk_widget_show (widget);
*row += 1;
}
void
-pgd_table_add_property_with_value_widget (GtkTable *table,
+pgd_table_add_property_with_value_widget (GtkGrid *table,
const gchar *markup,
GtkWidget **value_widget,
const gchar *value,
@@ -64,7 +63,7 @@ pgd_table_add_property_with_value_widget (GtkTable *table,
}
void
-pgd_table_add_property (GtkTable *table,
+pgd_table_add_property (GtkGrid *table,
const gchar *markup,
const gchar *value,
gint *row)
@@ -93,7 +92,7 @@ pgd_action_view_new (PopplerDocument *document)
static void
pgd_action_view_add_destination (GtkWidget *action_view,
- GtkTable *table,
+ GtkGrid *table,
PopplerDest *dest,
gboolean remote,
gint *row)
@@ -165,13 +164,13 @@ pgd_action_view_add_destination (GtkWidget *action_view,
alignment = gtk_alignment_new (0.5, 0.5, 1, 1);
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 5, 5, 12, 5);
- new_table = gtk_table_new (8, 2, FALSE);
- gtk_table_set_col_spacings (GTK_TABLE (new_table), 6);
- gtk_table_set_row_spacings (GTK_TABLE (new_table), 6);
- gtk_table_attach_defaults (table, alignment, 0, 2, *row, *row + 1);
+ new_table = gtk_grid_new ();
+ gtk_grid_set_column_spacing (GTK_GRID (new_table), 6);
+ gtk_grid_set_row_spacing (GTK_GRID (new_table), 6);
+ gtk_grid_attach (GTK_GRID(table), alignment, 0, *row, 1, 1);
gtk_widget_show (alignment);
- pgd_action_view_add_destination (action_view, GTK_TABLE (new_table),
+ pgd_action_view_add_destination (action_view, GTK_GRID (new_table),
new_dest, FALSE, &new_row);
poppler_dest_free (new_dest);
@@ -329,68 +328,68 @@ pgd_action_view_set_action (GtkWidget *action_view,
if (!action)
return;
- table = gtk_table_new (10, 2, FALSE);
- gtk_table_set_col_spacings (GTK_TABLE (table), 6);
- gtk_table_set_row_spacings (GTK_TABLE (table), 6);
+ table = gtk_grid_new ();
+ gtk_grid_set_column_spacing (GTK_GRID (table), 6);
+ gtk_grid_set_row_spacing (GTK_GRID (table), 6);
- pgd_table_add_property (GTK_TABLE (table), "<b>Title:</b>", action->any.title, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Title:</b>", action->any.title, &row);
switch (action->type) {
case POPPLER_ACTION_UNKNOWN:
- pgd_table_add_property (GTK_TABLE (table), "<b>Type:</b>", "Unknown", &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Type:</b>", "Unknown", &row);
break;
case POPPLER_ACTION_NONE:
- pgd_table_add_property (GTK_TABLE (table), "<b>Type:</b>", "None", &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Type:</b>", "None", &row);
break;
case POPPLER_ACTION_GOTO_DEST:
- pgd_action_view_add_destination (action_view, GTK_TABLE (table), action->goto_dest.dest, FALSE, &row);
+ pgd_action_view_add_destination (action_view, GTK_GRID (table), action->goto_dest.dest, FALSE, &row);
break;
case POPPLER_ACTION_GOTO_REMOTE:
- pgd_table_add_property (GTK_TABLE (table), "<b>Type:</b>", "Remote Destination", &row);
- pgd_table_add_property (GTK_TABLE (table), "<b>Filename:</b>", action->goto_remote.file_name, &row);
- pgd_action_view_add_destination (action_view, GTK_TABLE (table), action->goto_remote.dest, TRUE, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Type:</b>", "Remote Destination", &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Filename:</b>", action->goto_remote.file_name, &row);
+ pgd_action_view_add_destination (action_view, GTK_GRID (table), action->goto_remote.dest, TRUE, &row);
break;
case POPPLER_ACTION_LAUNCH:
- pgd_table_add_property (GTK_TABLE (table), "<b>Type:</b>", "Launch", &row);
- pgd_table_add_property (GTK_TABLE (table), "<b>Filename:</b>", action->launch.file_name, &row);
- pgd_table_add_property (GTK_TABLE (table), "<b>Params:</b>", action->launch.params, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Type:</b>", "Launch", &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Filename:</b>", action->launch.file_name, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Params:</b>", action->launch.params, &row);
break;
case POPPLER_ACTION_URI:
- pgd_table_add_property (GTK_TABLE (table), "<b>Type:</b>", "External URI", &row);
- pgd_table_add_property (GTK_TABLE (table), "<b>URI</b>", action->uri.uri, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Type:</b>", "External URI", &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>URI</b>", action->uri.uri, &row);
break;
case POPPLER_ACTION_NAMED:
- pgd_table_add_property (GTK_TABLE (table), "<b>Type:</b>", "Named Action", &row);
- pgd_table_add_property (GTK_TABLE (table), "<b>Name:</b>", action->named.named_dest, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Type:</b>", "Named Action", &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Name:</b>", action->named.named_dest, &row);
break;
case POPPLER_ACTION_MOVIE: {
GtkWidget *movie_view = pgd_movie_view_new ();
- pgd_table_add_property (GTK_TABLE (table), "<b>Type:</b>", "Movie", &row);
- pgd_table_add_property (GTK_TABLE (table), "<b>Operation:</b>", get_movie_op (action->movie.operation), &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Type:</b>", "Movie", &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Operation:</b>", get_movie_op (action->movie.operation), &row);
pgd_movie_view_set_movie (movie_view, action->movie.movie);
- pgd_table_add_property_with_custom_widget (GTK_TABLE (table), "<b>Movie:</b>", movie_view, &row);
+ pgd_table_add_property_with_custom_widget (GTK_GRID (table), "<b>Movie:</b>", movie_view, &row);
}
break;
case POPPLER_ACTION_RENDITION: {
gchar *text;
- pgd_table_add_property (GTK_TABLE (table), "<b>Type:</b>", "Rendition", &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Type:</b>", "Rendition", &row);
text = g_strdup_printf ("%d", action->rendition.op);
- pgd_table_add_property (GTK_TABLE (table), "<b>Operation:</b>", text, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Operation:</b>", text, &row);
g_free (text);
if (action->rendition.media) {
gboolean embedded = poppler_media_is_embedded (action->rendition.media);
GtkWidget *button;
- pgd_table_add_property (GTK_TABLE (table), "<b>Embedded:</b>", embedded ? "Yes": "No", &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Embedded:</b>", embedded ? "Yes": "No", &row);
if (embedded) {
const gchar *mime_type = poppler_media_get_mime_type (action->rendition.media);
- pgd_table_add_property (GTK_TABLE (table), "<b>Mime type:</b>",
+ pgd_table_add_property (GTK_GRID (table), "<b>Mime type:</b>",
mime_type ? mime_type : "",
&row);
} else {
- pgd_table_add_property (GTK_TABLE (table), "<b>Filename:</b>",
+ pgd_table_add_property (GTK_GRID (table), "<b>Filename:</b>",
poppler_media_get_filename (action->rendition.media),
&row);
}
@@ -399,7 +398,7 @@ pgd_action_view_set_action (GtkWidget *action_view,
g_signal_connect (button, "clicked",
G_CALLBACK (pgd_action_view_play_rendition),
action->rendition.media);
- pgd_table_add_property_with_custom_widget (GTK_TABLE (table), NULL, button, &row);
+ pgd_table_add_property_with_custom_widget (GTK_GRID (table), NULL, button, &row);
gtk_widget_show (button);
}
}
@@ -408,7 +407,7 @@ pgd_action_view_set_action (GtkWidget *action_view,
GList *l;
GtkWidget *button;
- pgd_table_add_property (GTK_TABLE (table), "<b>Type:</b>", "OCGState", &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Type:</b>", "OCGState", &row);
for (l = action->ocg_state.state_list; l; l = g_list_next (l)) {
PopplerActionLayer *action_layer = (PopplerActionLayer *)l->data;
@@ -426,7 +425,7 @@ pgd_action_view_set_action (GtkWidget *action_view,
text = g_strdup_printf ("%d layers Toggle", n_layers);
break;
}
- pgd_table_add_property (GTK_TABLE (table), "<b>Action:</b>", text, &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Action:</b>", text, &row);
g_free (text);
}
@@ -434,7 +433,7 @@ pgd_action_view_set_action (GtkWidget *action_view,
g_signal_connect (button, "clicked",
G_CALLBACK (pgd_action_view_do_action_layer),
action->ocg_state.state_list);
- pgd_table_add_property_with_custom_widget (GTK_TABLE (table), NULL, button, &row);
+ pgd_table_add_property_with_custom_widget (GTK_GRID (table), NULL, button, &row);
gtk_widget_show (button);
}
break;
@@ -443,7 +442,7 @@ pgd_action_view_set_action (GtkWidget *action_view,
GtkWidget *textview;
GtkWidget *swindow;
- pgd_table_add_property (GTK_TABLE (table), "<b>Type:</b>", "JavaScript", &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Type:</b>", "JavaScript", &row);
buffer = gtk_text_buffer_new (NULL);
if (action->javascript.script)
@@ -459,7 +458,7 @@ pgd_action_view_set_action (GtkWidget *action_view,
gtk_container_add (GTK_CONTAINER (swindow), textview);
gtk_widget_show (textview);
- pgd_table_add_property_with_custom_widget (GTK_TABLE (table), NULL, swindow, &row);
+ pgd_table_add_property_with_custom_widget (GTK_GRID (table), NULL, swindow, &row);
gtk_widget_show (swindow);
}
break;
@@ -565,19 +564,19 @@ pgd_movie_view_set_movie (GtkWidget *movie_view,
if (!movie)
return;
- table = gtk_table_new (10, 2, FALSE);
- gtk_table_set_col_spacings (GTK_TABLE (table), 6);
- gtk_table_set_row_spacings (GTK_TABLE (table), 6);
+ table = gtk_grid_new ();
+ gtk_grid_set_column_spacing (GTK_GRID (table), 6);
+ gtk_grid_set_row_spacing (GTK_GRID (table), 6);
- pgd_table_add_property (GTK_TABLE (table), "<b>Filename:</b>", poppler_movie_get_filename (movie), &row);
- pgd_table_add_property (GTK_TABLE (table), "<b>Need Poster:</b>", poppler_movie_need_poster (movie) ? "Yes" : "No", &row);
- pgd_table_add_property (GTK_TABLE (table), "<b>Show Controls:</b>", poppler_movie_show_controls (movie) ? "Yes" : "No", &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Filename:</b>", poppler_movie_get_filename (movie), &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Need Poster:</b>", poppler_movie_need_poster (movie) ? "Yes" : "No", &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Show Controls:</b>", poppler_movie_show_controls (movie) ? "Yes" : "No", &row);
button = gtk_button_new_from_stock (GTK_STOCK_MEDIA_PLAY);
g_signal_connect (button, "clicked",
G_CALLBACK (pgd_movie_view_play_movie),
movie);
- pgd_table_add_property_with_custom_widget (GTK_TABLE (table), NULL, button, &row);
+ pgd_table_add_property_with_custom_widget (GTK_GRID (table), NULL, button, &row);
gtk_widget_show (button);
gtk_container_add (GTK_CONTAINER (alignment), table);
diff --git a/glib/demo/utils.h b/glib/demo/utils.h
index 452f3fa..026cfb4 100644
--- a/glib/demo/utils.h
+++ b/glib/demo/utils.h
@@ -24,16 +24,16 @@
G_BEGIN_DECLS
-void pgd_table_add_property (GtkTable *table,
+void pgd_table_add_property (GtkGrid *table,
const gchar *markup,
const gchar *value,
gint *row);
-void pgd_table_add_property_with_value_widget (GtkTable *table,
+void pgd_table_add_property_with_value_widget (GtkGrid *table,
const gchar *markup,
GtkWidget **value_widget,
const gchar *value,
gint *row);
-void pgd_table_add_property_with_custom_widget (GtkTable *table,
+void pgd_table_add_property_with_custom_widget (GtkGrid *table,
const gchar *markup,
GtkWidget *widget,
gint *row);
diff --git a/test/gtk-test.cc b/test/gtk-test.cc
index dd339fb..a5759d7 100644
--- a/test/gtk-test.cc
+++ b/test/gtk-test.cc
@@ -156,16 +156,14 @@ void GDKSplashOutputDev::redraw(int srcX, int srcY,
}
static gboolean
-drawing_area_expose (GtkWidget *drawing_area,
- GdkEventExpose *event,
- View *view)
+drawing_area_draw (GtkWidget *drawing_area,
+ cairo_t *cr,
+ View *view)
{
- cairo_t *cr;
GdkRectangle document;
+ GdkRectangle clip;
GdkRectangle draw;
- gdk_window_clear (drawing_area->window);
-
document.x = 0;
document.y = 0;
if (cairo_output) {
@@ -176,8 +174,10 @@ drawing_area_expose (GtkWidget *drawing_area,
document.height = view->out->getBitmapHeight();
}
- cr = gdk_cairo_create (drawing_area->window);
- if (!gdk_rectangle_intersect (&document, &event->area, &draw))
+ if (!gdk_cairo_get_clip_rectangle (cr, &clip))
+ return FALSE;
+
+ if (!gdk_rectangle_intersect (&document, &clip, &draw))
return FALSE;
if (cairo_output) {
@@ -190,8 +190,6 @@ drawing_area_expose (GtkWidget *drawing_area,
draw.width, draw.height);
}
- cairo_destroy (cr);
-
return TRUE;
}
@@ -281,6 +279,7 @@ view_new (PopplerDocument *doc)
GtkWidget *sw;
GtkWidget *vbox, *hbox;
guint n_pages;
+ PopplerPage *page;
view = g_slice_new0 (View);
@@ -291,7 +290,16 @@ view_new (PopplerDocument *doc)
G_CALLBACK (destroy_window_callback),
view);
- vbox = gtk_vbox_new (FALSE, 5);
+ page = poppler_document_get_page (doc, 0);
+ if (page) {
+ double width, height;
+
+ poppler_page_get_size (page, &width, &height);
+ gtk_window_set_default_size (GTK_WINDOW (window), (gint)width, (gint)height);
+ g_object_unref (page);
+ }
+
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
view->drawing_area = gtk_drawing_area_new ();
sw = gtk_scrolled_window_new (NULL, NULL);
@@ -305,7 +313,7 @@ view_new (PopplerDocument *doc)
gtk_box_pack_end (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
gtk_widget_show (sw);
- hbox = gtk_hbox_new (FALSE, 5);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
n_pages = poppler_document_get_n_pages (doc);
view->spin_button = gtk_spin_button_new_with_range (0, n_pages - 1, 1);
@@ -333,8 +341,8 @@ view_new (PopplerDocument *doc)
}
g_signal_connect (view->drawing_area,
- "expose_event",
- G_CALLBACK (drawing_area_expose),
+ "draw",
+ G_CALLBACK (drawing_area_draw),
view);
return view;
@@ -366,27 +374,27 @@ main (int argc, char *argv [])
for (int i = 0; file_arguments[i]; i++) {
View *view;
GFile *file;
- gchar *uri;
PopplerDocument *doc;
GError *error = NULL;
file = g_file_new_for_commandline_arg (file_arguments[i]);
- uri = g_file_get_uri (file);
- g_object_unref (file);
-
- doc = poppler_document_new_from_file (uri, NULL, &error);
+ doc = poppler_document_new_from_gfile (file, NULL, NULL, &error);
if (!doc) {
+ gchar *uri;
+
+ uri = g_file_get_uri (file);
g_printerr ("Error opening document %s: %s\n", uri, error->message);
g_error_free (error);
g_free (uri);
+ g_object_unref (file);
continue;
}
+ g_object_unref (file);
view = view_new (doc);
view_list = g_list_prepend (view_list, view);
view_set_page (view, CLAMP (page, 0, poppler_document_get_n_pages (doc) - 1));
- g_free (uri);
}
gtk_main ();
More information about the poppler
mailing list