From f320383369c4105e8076a0a5248a728fac76a0c0 Mon Sep 17 00:00:00 2001 From: raveit65 Date: Thu, 23 Jun 2016 00:22:11 +0200 Subject: GTK+-3: Use GtkGrid instead of GtkTable taken from: https://git.gnome.org/browse/evince/commit/?id=da8f31e --- libview/ev-print-operation.c | 29 ++++++++++ properties/ev-properties-view.c | 94 ++++++++++++++++++++++++++++++++ shell/ev-annotation-properties-dialog.c | 95 +++++++++++++++++++++++++++++++++ shell/ev-password-view.c | 20 +++++++ 4 files changed, 238 insertions(+) diff --git a/libview/ev-print-operation.c b/libview/ev-print-operation.c index 6b972f4e..bd6ef328 100644 --- a/libview/ev-print-operation.c +++ b/libview/ev-print-operation.c @@ -1872,7 +1872,11 @@ ev_print_operation_print_create_custom_widget (EvPrintOperationPrint *print, { GtkPrintSettings *settings; GtkWidget *label; +#if GTK_CHECK_VERSION (3, 0, 0) + GtkWidget *grid; +#else GtkWidget *table; +#endif EvPrintScale page_scale; gboolean autorotate; gboolean use_source_size; @@ -1884,6 +1888,15 @@ ev_print_operation_print_create_custom_widget (EvPrintOperationPrint *print, TRUE; use_source_size = gtk_print_settings_get_bool (settings, EV_PRINT_SETTING_PAGE_SIZE); +#if GTK_CHECK_VERSION (3, 0, 0) + grid = gtk_grid_new (); + gtk_grid_set_row_spacing (GTK_GRID (grid), 6); + gtk_grid_set_column_spacing (GTK_GRID (grid), 12); + gtk_container_set_border_width (GTK_CONTAINER (grid), 12); + + label = gtk_label_new (_("Page Scaling:")); + gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1); +#else table = gtk_table_new (3, 2, FALSE); gtk_table_set_row_spacings (GTK_TABLE (table), 6); gtk_table_set_col_spacings (GTK_TABLE (table), 12); @@ -1891,6 +1904,7 @@ ev_print_operation_print_create_custom_widget (EvPrintOperationPrint *print, label = gtk_label_new (_("Page Scaling:")); gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); +#endif gtk_widget_show (label); print->scale_combo = gtk_combo_box_text_new (); @@ -1908,7 +1922,11 @@ ev_print_operation_print_create_custom_widget (EvPrintOperationPrint *print, "\n" "• \"Fit to Printable Area\": Document pages are enlarged or reduced as" " required to fit the printable area of the printer page.\n")); +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_grid_attach (GTK_GRID (grid), print->scale_combo, 1, 0, 1, 1); +#else gtk_table_attach (GTK_TABLE (table), print->scale_combo, 1, 2, 0, 1, GTK_FILL, 0, 0, 0); +#endif gtk_widget_show (print->scale_combo); print->autorotate_button = gtk_check_button_new_with_label (_("Auto Rotate and Center")); @@ -1916,17 +1934,28 @@ ev_print_operation_print_create_custom_widget (EvPrintOperationPrint *print, gtk_widget_set_tooltip_text (print->autorotate_button, _("Rotate printer page orientation of each page to match orientation of each document page. " "Document pages will be centered within the printer page.")); +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_grid_attach (GTK_GRID (grid), print->autorotate_button, 0, 1, 2, 1); +#else gtk_table_attach (GTK_TABLE (table), print->autorotate_button, 0, 2, 1, 2, GTK_FILL, 0, 0, 0); +#endif gtk_widget_show (print->autorotate_button); print->source_button = gtk_check_button_new_with_label (_("Select page size using document page size")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (print->source_button), use_source_size); gtk_widget_set_tooltip_text (print->source_button, _("When enabled, each page will be printed on " "the same size paper as the document page.")); +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_grid_attach (GTK_GRID (grid), print->source_button, 0, 2, 2, 1); + gtk_widget_show (print->source_button); + + return G_OBJECT (grid); +#else gtk_table_attach (GTK_TABLE (table), print->source_button, 0, 2, 2, 3, GTK_FILL, 0, 0, 0); gtk_widget_show (print->source_button); return G_OBJECT (table); +#endif } static void diff --git a/properties/ev-properties-view.c b/properties/ev-properties-view.c index 8555c627..a38846eb 100644 --- a/properties/ev-properties-view.c +++ b/properties/ev-properties-view.c @@ -76,7 +76,11 @@ static const PropertyInfo properties_info[] = { struct _EvPropertiesView { GtkBox base_instance; +#if GTK_CHECK_VERSION (3, 0, 0) + GtkWidget *grid; +#else GtkWidget *table; +#endif GtkWidget *labels[N_PROPERTIES]; gchar *uri; }; @@ -150,7 +154,11 @@ make_valid_utf8 (const gchar *name) static void set_property (EvPropertiesView *properties, +#if GTK_CHECK_VERSION (3, 0, 0) + GtkGrid *grid, +#else GtkTable *table, +#endif Property property, const gchar *text, gint *row) @@ -166,8 +174,12 @@ set_property (EvPropertiesView *properties, gtk_label_set_markup (GTK_LABEL (label), markup); g_free (markup); +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_grid_attach (grid, label, 0, *row, 1, 1); +#else gtk_table_attach (table, label, 0, 1, *row, *row + 1, GTK_FILL, GTK_FILL, 0, 0); +#endif gtk_widget_show (label); } @@ -195,8 +207,12 @@ set_property (EvPropertiesView *properties, } if (!properties->labels[property]) { +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_grid_attach (grid, label, 1, *row, 1, 1); +#else gtk_table_attach (table, label, 1, 2, *row, *row + 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); +#endif properties->labels[property] = label; } @@ -313,6 +329,74 @@ ev_regular_paper_size (const EvDocumentInfo *info) void ev_properties_view_set_info (EvPropertiesView *properties, const EvDocumentInfo *info) { +#if GTK_CHECK_VERSION (3, 0, 0) + GtkWidget *grid; + gchar *text; + gint row = 0; + + grid = properties->grid; + + if (info->fields_mask & EV_DOCUMENT_INFO_TITLE) { + set_property (properties, GTK_GRID (grid), TITLE_PROPERTY, info->title, &row); + } + set_property (properties, GTK_GRID (grid), URI_PROPERTY, properties->uri, &row); + if (info->fields_mask & EV_DOCUMENT_INFO_SUBJECT) { + set_property (properties, GTK_GRID (grid), SUBJECT_PROPERTY, info->subject, &row); + } + if (info->fields_mask & EV_DOCUMENT_INFO_AUTHOR) { + set_property (properties, GTK_GRID (grid), AUTHOR_PROPERTY, info->author, &row); + } + if (info->fields_mask & EV_DOCUMENT_INFO_KEYWORDS) { + set_property (properties, GTK_GRID (grid), KEYWORDS_PROPERTY, info->keywords, &row); + } + if (info->fields_mask & EV_DOCUMENT_INFO_PRODUCER) { + set_property (properties, GTK_GRID (grid), PRODUCER_PROPERTY, info->producer, &row); + } + if (info->fields_mask & EV_DOCUMENT_INFO_CREATOR) { + set_property (properties, GTK_GRID (grid), CREATOR_PROPERTY, info->creator, &row); + } + if (info->fields_mask & EV_DOCUMENT_INFO_CREATION_DATE) { + text = ev_document_misc_format_date (info->creation_date); + set_property (properties, GTK_GRID (grid), CREATION_DATE_PROPERTY, text, &row); + g_free (text); + } + if (info->fields_mask & EV_DOCUMENT_INFO_MOD_DATE) { + text = ev_document_misc_format_date (info->modified_date); + set_property (properties, GTK_GRID (grid), MOD_DATE_PROPERTY, text, &row); + g_free (text); + } + if (info->fields_mask & EV_DOCUMENT_INFO_FORMAT) { + set_property (properties, GTK_GRID (grid), FORMAT_PROPERTY, info->format, &row); + } + if (info->fields_mask & EV_DOCUMENT_INFO_N_PAGES) { + text = g_strdup_printf ("%d", info->n_pages); + set_property (properties, GTK_GRID (grid), N_PAGES_PROPERTY, text, &row); + g_free (text); + } + if (info->fields_mask & EV_DOCUMENT_INFO_LINEARIZED) + { + /* nice hack bro */ + if (info->linearized == 1) + { + set_property (properties, GTK_GRID (grid), LINEARIZED_PROPERTY, _("Yes"), &row); + } + else if (info->linearized == 0) + { + set_property (properties, GTK_GRID (grid), LINEARIZED_PROPERTY, _("No"), &row); + } + else + { + set_property (properties, GTK_GRID (grid), LINEARIZED_PROPERTY, info->linearized, &row); + } + } + if (info->fields_mask & EV_DOCUMENT_INFO_SECURITY) { + set_property (properties, GTK_GRID (grid), SECURITY_PROPERTY, info->security, &row); + } + if (info->fields_mask & EV_DOCUMENT_INFO_PAPER_SIZE) { + text = ev_regular_paper_size (info); + set_property (properties, GTK_GRID (grid), PAPER_SIZE_PROPERTY, text, &row); + g_free (text); +#else GtkWidget *table; gchar *text; gint row = 0; @@ -379,6 +463,7 @@ ev_properties_view_set_info (EvPropertiesView *properties, const EvDocumentInfo text = ev_regular_paper_size (info); set_property (properties, GTK_TABLE (table), PAPER_SIZE_PROPERTY, text, &row); g_free (text); +#endif } } @@ -386,6 +471,14 @@ static void ev_properties_view_init (EvPropertiesView *properties) { gtk_orientable_set_orientation (GTK_ORIENTABLE (properties), GTK_ORIENTATION_VERTICAL); +#if GTK_CHECK_VERSION (3, 0, 0) + properties->grid = gtk_grid_new (); + gtk_grid_set_column_spacing (GTK_GRID (properties->grid), 12); + gtk_grid_set_row_spacing (GTK_GRID (properties->grid), 6); + gtk_container_set_border_width (GTK_CONTAINER (properties->grid), 12); + gtk_box_pack_start (GTK_BOX (properties), properties->grid, TRUE, TRUE, 0); + gtk_widget_show (properties->grid); +#else properties->table = gtk_table_new (13, 2, FALSE); gtk_table_set_col_spacings (GTK_TABLE (properties->table), 12); gtk_table_set_row_spacings (GTK_TABLE (properties->table), 6); @@ -393,6 +486,7 @@ ev_properties_view_init (EvPropertiesView *properties) gtk_box_pack_start (GTK_BOX (properties), properties->table, TRUE, TRUE, 0); gtk_widget_show (properties->table); +#endif } void diff --git a/shell/ev-annotation-properties-dialog.c b/shell/ev-annotation-properties-dialog.c index 3d413096..eb736c5d 100644 --- a/shell/ev-annotation-properties-dialog.c +++ b/shell/ev-annotation-properties-dialog.c @@ -39,7 +39,11 @@ struct _EvAnnotationPropertiesDialog { EvAnnotationType annot_type; EvAnnotation *annot; +#if GTK_CHECK_VERSION (3, 0, 0) + GtkWidget *grid; +#else GtkWidget *table; +#endif GtkWidget *author; GtkWidget *color; @@ -90,15 +94,23 @@ static void ev_annotation_properties_dialog_constructed (GObject *object) { EvAnnotationPropertiesDialog *dialog = EV_ANNOTATION_PROPERTIES_DIALOG (object); +#if GTK_CHECK_VERSION (3, 0, 0) + GtkWidget *grid = dialog->grid; +#else GtkWidget *table = dialog->table; +#endif GtkWidget *label; switch (dialog->annot_type) { case EV_ANNOTATION_TYPE_TEXT: label = gtk_label_new (_("Icon:")); gtk_misc_set_alignment (GTK_MISC (label), 0., 0.5); +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_grid_attach (GTK_GRID (grid), label, 0, 5, 1, 1); +#else gtk_table_attach (GTK_TABLE (table), label, 0, 1, 5, 6, GTK_FILL, GTK_FILL, 0, 0); +#endif gtk_widget_show (label); dialog->icon = gtk_combo_box_text_new (); @@ -113,9 +125,14 @@ ev_annotation_properties_dialog_constructed (GObject *object) gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (dialog->icon), _("Circle")); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (dialog->icon), _("Unknown")); gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->icon), 0); +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_grid_attach (GTK_GRID (grid), dialog->icon, 1, 5, 1, 1); + gtk_widget_set_hexpand (dialog->icon, TRUE); +#else gtk_table_attach (GTK_TABLE (table), dialog->icon, 1, 2, 5, 6, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); +#endif gtk_widget_show (dialog->icon); break; @@ -132,7 +149,11 @@ ev_annotation_properties_dialog_init (EvAnnotationPropertiesDialog *annot_dialog GtkDialog *dialog = GTK_DIALOG (annot_dialog); GtkWidget *content_area; GtkWidget *label; +#if GTK_CHECK_VERSION (3, 0, 0) + GtkWidget *grid; +#else GtkWidget *table; +#endif GtkWidget *hbox; gchar *markup; GdkColor color = { 0, 65535, 65535, 0 }; @@ -149,6 +170,79 @@ ev_annotation_properties_dialog_init (EvAnnotationPropertiesDialog *annot_dialog content_area = gtk_dialog_get_content_area (dialog); gtk_box_set_spacing (GTK_BOX (content_area), 2); +#if GTK_CHECK_VERSION (3, 0, 0) + grid = gtk_grid_new (); + annot_dialog->grid = grid; + gtk_grid_set_column_spacing (GTK_GRID (grid), 12); + gtk_grid_set_row_spacing (GTK_GRID (grid), 6); + gtk_container_set_border_width (GTK_CONTAINER (grid), 12); + gtk_box_pack_start (GTK_BOX (content_area), grid, FALSE, FALSE, 0); + gtk_widget_show (grid); + + label = gtk_label_new (_("Author:")); + gtk_misc_set_alignment (GTK_MISC (label), 0., 0.5); + gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1); + gtk_widget_show (label); + + annot_dialog->author = gtk_entry_new (); + gtk_entry_set_text (GTK_ENTRY (annot_dialog->author), g_get_real_name ()); + gtk_grid_attach (GTK_GRID (grid), annot_dialog->author, 1, 0, 1, 1); + gtk_widget_set_hexpand (annot_dialog->author, TRUE); + gtk_widget_show (annot_dialog->author); + + label = gtk_label_new (_("Color:")); + gtk_misc_set_alignment (GTK_MISC (label), 0., 0.5); + gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1); + gtk_widget_show (label); + + annot_dialog->color = gtk_color_button_new_with_color (&color); + gtk_grid_attach (GTK_GRID (grid), annot_dialog->color, 1, 1, 1, 1); + gtk_widget_set_hexpand (annot_dialog->color, TRUE); + gtk_widget_show (annot_dialog->color); + + label = gtk_label_new (_("Style:")); + gtk_misc_set_alignment (GTK_MISC (label), 0., 0.5); + gtk_grid_attach (GTK_GRID (grid), label, 0, 2, 1, 1); + gtk_widget_show (label); + + annot_dialog->opacity = gtk_hscale_new_with_range (0, 100, 5); + gtk_range_set_value (GTK_RANGE (annot_dialog->opacity), 100); + gtk_grid_attach (GTK_GRID (grid), annot_dialog->opacity, 1, 2, 1, 1); + gtk_widget_set_hexpand (annot_dialog->opacity, TRUE); + gtk_widget_show (annot_dialog->opacity); + + hbox = gtk_hbox_new (FALSE, 6); + + label = gtk_label_new (NULL); + markup = g_strdup_printf ("%s", _("Transparent")); + gtk_label_set_markup (GTK_LABEL (label), markup); + g_free (markup); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_widget_show (label); + + label = gtk_label_new (NULL); + markup = g_strdup_printf ("%s", _("Opaque")); + gtk_label_set_markup (GTK_LABEL (label), markup); + g_free (markup); + gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_widget_show (label); + + gtk_grid_attach (GTK_GRID (grid), hbox, 1, 3, 1, 1); + gtk_widget_set_hexpand (hbox, TRUE); + gtk_widget_show (hbox); + + label = gtk_label_new (_("Initial window state:")); + gtk_misc_set_alignment (GTK_MISC (label), 0., 0.5); + gtk_grid_attach (GTK_GRID (grid), label, 0, 4, 1, 1); + gtk_widget_show (label); + + annot_dialog->popup_state = gtk_combo_box_text_new (); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (annot_dialog->popup_state), _("Open")); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (annot_dialog->popup_state), _("Close")); + gtk_combo_box_set_active (GTK_COMBO_BOX (annot_dialog->popup_state), 1); + gtk_grid_attach (GTK_GRID (grid), annot_dialog->popup_state, 1, 4, 1, 1); + gtk_widget_set_hexpand (annot_dialog->popup_state, TRUE); +#else table = gtk_table_new (5, 2, FALSE); annot_dialog->table = table; gtk_table_set_col_spacings (GTK_TABLE (table), 12); @@ -229,6 +323,7 @@ ev_annotation_properties_dialog_init (EvAnnotationPropertiesDialog *annot_dialog gtk_table_attach (GTK_TABLE (table), annot_dialog->popup_state, 1, 2, 4, 5, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); +#endif gtk_widget_show (annot_dialog->popup_state); } diff --git a/shell/ev-password-view.c b/shell/ev-password-view.c index 5e5a5559..545c064c 100644 --- a/shell/ev-password-view.c +++ b/shell/ev-password-view.c @@ -251,7 +251,11 @@ ev_password_view_ask_password (EvPasswordView *password_view) GtkWidget *content_area, *action_area; GtkWidget *entry_container; GtkWidget *hbox, *main_vbox, *vbox, *icon; +#if GTK_CHECK_VERSION (3, 0, 0) + GtkWidget *grid; +#else GtkWidget *table; +#endif GtkWidget *label; gchar *format, *markup, *file_name; @@ -332,11 +336,19 @@ ev_password_view_ask_password (EvPasswordView *password_view) FALSE, FALSE, 0); gtk_widget_show (entry_container); +#if GTK_CHECK_VERSION (3, 0, 0) + grid = gtk_grid_new (); + gtk_grid_set_column_spacing (GTK_GRID (grid), 12); + gtk_grid_set_row_spacing (GTK_GRID (grid), 6); + gtk_container_add (GTK_CONTAINER (entry_container), grid); + gtk_widget_show (grid); +#else 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); gtk_container_add (GTK_CONTAINER (entry_container), table); gtk_widget_show (table); +#endif label = gtk_label_new_with_mnemonic (_("_Password:")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); @@ -349,6 +361,13 @@ ev_password_view_ask_password (EvPasswordView *password_view) g_signal_connect (password_view->priv->password_entry, "activate", G_CALLBACK (ev_password_dialog_entry_activated_cb), dialog); +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1); + gtk_widget_show (label); + + gtk_grid_attach (GTK_GRID (grid), password_view->priv->password_entry, 1, 0, 1, 1); + gtk_widget_set_hexpand (password_view->priv->password_entry, TRUE); +#else gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); @@ -356,6 +375,7 @@ ev_password_view_ask_password (EvPasswordView *password_view) gtk_table_attach_defaults (GTK_TABLE (table), password_view->priv->password_entry, 1, 2, 0, 1); +#endif gtk_widget_show (password_view->priv->password_entry); gtk_label_set_mnemonic_widget (GTK_LABEL (label), -- cgit v1.2.1