[evolution-data-server/wip/mcrha/gtk4] Cover ERemindersWidget
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/wip/mcrha/gtk4] Cover ERemindersWidget
- Date: Fri, 15 Oct 2021 10:09:09 +0000 (UTC)
commit 6ee5e19cd28ca59e4b349a214c7dfc2192b0f164
Author: Milan Crha <mcrha redhat com>
Date: Fri Oct 15 12:08:51 2021 +0200
Cover ERemindersWidget
src/libedataserverui/e-reminders-widget.c | 121 +++++++++++++++++++++++++++---
1 file changed, 111 insertions(+), 10 deletions(-)
---
diff --git a/src/libedataserverui/e-reminders-widget.c b/src/libedataserverui/e-reminders-widget.c
index baa212f16..fd863045a 100644
--- a/src/libedataserverui/e-reminders-widget.c
+++ b/src/libedataserverui/e-reminders-widget.c
@@ -1231,6 +1231,60 @@ reminders_widget_add_snooze_update_sensitize_cb (GtkSpinButton *spin,
gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (reminders->priv->add_snooze_days_spin)) >
0);
}
+#if GTK_CHECK_VERSION(4, 0, 0)
+static void
+gtk_box_pack_start (GtkBox *box,
+ GtkWidget *child,
+ gboolean expand,
+ gboolean fill,
+ guint padding)
+{
+ if (gtk_orientable_get_orientation (GTK_ORIENTABLE (box)) == GTK_ORIENTATION_VERTICAL) {
+ if (expand)
+ gtk_widget_set_hexpand (child, TRUE);
+ if (fill)
+ gtk_widget_set_halign (child, GTK_ALIGN_FILL);
+ if (padding) {
+ gtk_widget_set_margin_start (child, padding + gtk_widget_get_margin_start (child));
+ gtk_widget_set_margin_end (child, padding + gtk_widget_get_margin_end (child));
+ }
+ } else {
+ if (expand)
+ gtk_widget_set_vexpand (child, TRUE);
+ if (fill)
+ gtk_widget_set_valign (child, GTK_ALIGN_FILL);
+ if (padding) {
+ gtk_widget_set_margin_top (child, padding + gtk_widget_get_margin_top (child));
+ gtk_widget_set_margin_bottom (child, padding + gtk_widget_get_margin_bottom (child));
+ }
+ }
+
+ gtk_box_append (box, child);
+}
+
+static void
+gtk_paned_pack1 (GtkPaned *paned,
+ GtkWidget *widget,
+ gboolean resize,
+ gboolean shrink)
+{
+ gtk_paned_set_start_child (paned, widget);
+ gtk_paned_set_resize_start_child (paned, resize);
+ gtk_paned_set_shrink_start_child (paned, shrink);
+}
+
+static void
+gtk_paned_pack2 (GtkPaned *paned,
+ GtkWidget *widget,
+ gboolean resize,
+ gboolean shrink)
+{
+ gtk_paned_set_end_child (paned, widget);
+ gtk_paned_set_resize_end_child (paned, resize);
+ gtk_paned_set_shrink_end_child (paned, shrink);
+}
+#endif /* GTK_CHECK_VERSION(4, 0, 0) */
+
static void
reminders_widget_snooze_add_custom (ERemindersWidget *reminders)
{
@@ -1322,14 +1376,29 @@ reminders_widget_snooze_add_custom (ERemindersWidget *reminders)
"halign", GTK_ALIGN_CENTER,
NULL);
+#if GTK_CHECK_VERSION(4, 0, 0)
+ gtk_box_append (vbox, reminders->priv->add_snooze_add_button);
+#else
gtk_box_pack_start (vbox, reminders->priv->add_snooze_add_button, FALSE, FALSE, 0);
-
gtk_widget_show_all (GTK_WIDGET (vbox));
-
+#endif
+
+#if GTK_CHECK_VERSION(4, 0, 0)
+ reminders->priv->add_snooze_popover = gtk_popover_new ();
+ gtk_widget_set_parent (reminders->priv->add_snooze_popover, GTK_WIDGET (reminders));
+ g_object_set (G_OBJECT (vbox),
+ "margin-start", 6,
+ "margin-end", 6,
+ "margin-top", 6,
+ "margin-bottom", 6,
+ NULL);
+ gtk_popover_set_child (GTK_POPOVER (reminders->priv->add_snooze_popover), GTK_WIDGET (vbox));
+#else
reminders->priv->add_snooze_popover = gtk_popover_new (GTK_WIDGET (reminders));
- gtk_popover_set_position (GTK_POPOVER (reminders->priv->add_snooze_popover), GTK_POS_BOTTOM);
gtk_container_add (GTK_CONTAINER (reminders->priv->add_snooze_popover), GTK_WIDGET (vbox));
gtk_container_set_border_width (GTK_CONTAINER (reminders->priv->add_snooze_popover), 6);
+#endif
+ gtk_popover_set_position (GTK_POPOVER (reminders->priv->add_snooze_popover), GTK_POS_BOTTOM);
g_signal_connect (reminders->priv->add_snooze_add_button, "clicked",
G_CALLBACK (reminders_widget_add_snooze_add_button_clicked_cb), reminders);
@@ -1363,7 +1432,11 @@ reminders_widget_snooze_add_custom (ERemindersWidget *reminders)
}
gtk_widget_hide (reminders->priv->add_snooze_popover);
+#if GTK_CHECK_VERSION(4, 0, 0)
+ gtk_widget_set_parent (GTK_WIDGET (reminders->priv->add_snooze_popover),
reminders->priv->snooze_combo);
+#else
gtk_popover_set_relative_to (GTK_POPOVER (reminders->priv->add_snooze_popover),
reminders->priv->snooze_combo);
+#endif
gtk_widget_show (reminders->priv->add_snooze_popover);
gtk_widget_grab_focus (reminders->priv->add_snooze_days_spin);
@@ -1547,7 +1620,11 @@ reminders_widget_constructed (GObject *object)
gtk_grid_attach (GTK_GRID (reminders), GTK_WIDGET (reminders->priv->paned), 0, 0, 1, 1);
+#if GTK_CHECK_VERSION(4, 0, 0)
+ scrolled_window = gtk_scrolled_window_new ();
+#else
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+#endif
g_object_set (G_OBJECT (scrolled_window),
"halign", GTK_ALIGN_FILL,
"hexpand", TRUE,
@@ -1555,7 +1632,11 @@ reminders_widget_constructed (GObject *object)
"vexpand", TRUE,
"hscrollbar-policy", GTK_POLICY_NEVER,
"vscrollbar-policy", GTK_POLICY_AUTOMATIC,
+#if GTK_CHECK_VERSION(4, 0, 0)
+ "has-frame", TRUE,
+#else
"shadow-type", GTK_SHADOW_IN,
+#endif
NULL);
gtk_paned_pack1 (reminders->priv->paned, scrolled_window, FALSE, FALSE);
@@ -1581,7 +1662,11 @@ reminders_widget_constructed (GObject *object)
"hover-selection", FALSE,
NULL);
+#if GTK_CHECK_VERSION(4, 0, 0)
+ gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolled_window), GTK_WIDGET
(reminders->priv->tree_view));
+#else
gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (reminders->priv->tree_view));
+#endif
e_binding_bind_property (reminders, "empty",
scrolled_window, "sensitive",
@@ -1607,7 +1692,11 @@ reminders_widget_constructed (GObject *object)
column = gtk_tree_view_get_column (reminders->priv->tree_view, 1);
gtk_tree_view_column_set_expand (column, TRUE);
+#if GTK_CHECK_VERSION(4, 0, 0)
+ scrolled_window = gtk_scrolled_window_new ();
+#else
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+#endif
g_object_set (G_OBJECT (scrolled_window),
"halign", GTK_ALIGN_FILL,
"hexpand", TRUE,
@@ -1615,7 +1704,11 @@ reminders_widget_constructed (GObject *object)
"vexpand", TRUE,
"hscrollbar-policy", GTK_POLICY_NEVER,
"vscrollbar-policy", GTK_POLICY_AUTOMATIC,
+#if GTK_CHECK_VERSION(4, 0, 0)
+ "has-frame", TRUE,
+#else
"shadow-type", GTK_SHADOW_IN,
+#endif
NULL);
gtk_paned_pack2 (reminders->priv->paned, scrolled_window, TRUE, FALSE);
@@ -1631,7 +1724,11 @@ reminders_widget_constructed (GObject *object)
"wrap-mode", GTK_WRAP_WORD_CHAR,
NULL);
+#if GTK_CHECK_VERSION(4, 0, 0)
+ gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolled_window), GTK_WIDGET
(reminders->priv->details_text_view));
+#else
gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (reminders->priv->details_text_view));
+#endif
e_buffer_tagger_connect (reminders->priv->details_text_view);
@@ -1643,7 +1740,7 @@ reminders_widget_constructed (GObject *object)
reminders_widget_fill_snooze_combo (reminders,
g_settings_get_int (reminders->priv->settings, "notify-last-snooze-minutes"));
- box = GTK_BOX (gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL));
+ box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4));
g_object_set (G_OBJECT (box),
"halign", GTK_ALIGN_END,
"hexpand", TRUE,
@@ -1660,12 +1757,11 @@ reminders_widget_constructed (GObject *object)
gtk_box_pack_start (box, reminders->priv->dismiss_button, FALSE, FALSE, 0);
gtk_box_pack_start (box, reminders->priv->dismiss_all_button, FALSE, FALSE, 0);
- gtk_button_box_set_child_non_homogeneous (GTK_BUTTON_BOX (box), reminders->priv->snooze_combo, TRUE);
- gtk_button_box_set_child_non_homogeneous (GTK_BUTTON_BOX (box), widget, TRUE);
-
gtk_grid_attach (GTK_GRID (reminders), GTK_WIDGET (box), 0, 1, 1, 1);
+#if !GTK_CHECK_VERSION(4, 0, 0)
gtk_widget_show_all (GTK_WIDGET (reminders));
+#endif
selection = gtk_tree_view_get_selection (reminders->priv->tree_view);
gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
@@ -1967,7 +2063,7 @@ reminders_widget_error_response_cb (GtkInfoBar *info_bar,
g_return_if_fail (E_IS_REMINDERS_WIDGET (reminders));
if (reminders->priv->info_bar == info_bar) {
- gtk_widget_destroy (GTK_WIDGET (reminders->priv->info_bar));
+ g_object_unref (reminders->priv->info_bar);
reminders->priv->info_bar = NULL;
}
}
@@ -2010,7 +2106,7 @@ e_reminders_widget_report_error (ERemindersWidget *reminders,
}
if (reminders->priv->info_bar) {
- gtk_widget_destroy (GTK_WIDGET (reminders->priv->info_bar));
+ g_object_unref (reminders->priv->info_bar);
reminders->priv->info_bar = NULL;
}
@@ -2021,11 +2117,16 @@ e_reminders_widget_report_error (ERemindersWidget *reminders,
label = GTK_LABEL (gtk_label_new (message));
gtk_label_set_width_chars (label, 20);
gtk_label_set_max_width_chars (label, 120);
- gtk_label_set_line_wrap (label, TRUE);
gtk_label_set_selectable (label, TRUE);
+#if GTK_CHECK_VERSION(4, 0, 0)
+ gtk_label_set_wrap (label, TRUE);
+ gtk_info_bar_add_child (GTK_INFO_BAR (reminders->priv->info_bar), GTK_WIDGET (label));
+#else
+ gtk_label_set_line_wrap (label, TRUE);
gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (reminders->priv->info_bar)),
GTK_WIDGET (label));
gtk_widget_show (GTK_WIDGET (label));
gtk_widget_show (GTK_WIDGET (reminders->priv->info_bar));
+#endif
g_signal_connect (reminders->priv->info_bar, "response", G_CALLBACK
(reminders_widget_error_response_cb), reminders);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]