[nautilus/wip/antoniof/gnome-42: 23/72] Revert "general: Don't subclass GtkInfoBar"




commit 993bc1718341551d3c274bf5eb8e4c967d31cbcb
Author: António Fernandes <antoniof gnome org>
Date:   Fri Feb 11 19:01:39 2022 +0000

    Revert "general: Don't subclass GtkInfoBar"
    
    This reverts commit e84ce5acb38377ab773ee08d71936cac9942ab5a.

 src/nautilus-special-location-bar.c | 18 +++++++++---------
 src/nautilus-special-location-bar.h |  4 ++--
 src/nautilus-trash-bar.c            | 38 +++++++++++++++++--------------------
 src/nautilus-trash-bar.h            |  4 ++--
 src/nautilus-x-content-bar.c        | 20 +++++++++----------
 src/nautilus-x-content-bar.h        |  4 ++--
 6 files changed, 41 insertions(+), 47 deletions(-)
---
diff --git a/src/nautilus-special-location-bar.c b/src/nautilus-special-location-bar.c
index d2a559726..ce4052122 100644
--- a/src/nautilus-special-location-bar.c
+++ b/src/nautilus-special-location-bar.c
@@ -28,7 +28,7 @@
 
 struct _NautilusSpecialLocationBar
 {
-    GtkBin parent_instance;
+    GtkInfoBar parent_instance;
 
     GtkWidget *label;
     GtkWidget *learn_more_label;
@@ -41,7 +41,7 @@ enum
     PROP_SPECIAL_LOCATION,
 };
 
-G_DEFINE_TYPE (NautilusSpecialLocationBar, nautilus_special_location_bar, GTK_TYPE_BIN)
+G_DEFINE_TYPE (NautilusSpecialLocationBar, nautilus_special_location_bar, GTK_TYPE_INFO_BAR)
 
 static void
 set_special_location (NautilusSpecialLocationBar *bar,
@@ -163,13 +163,12 @@ nautilus_special_location_bar_class_init (NautilusSpecialLocationBarClass *klass
 static void
 nautilus_special_location_bar_init (NautilusSpecialLocationBar *bar)
 {
-    GtkWidget *info_bar;
+    GtkWidget *action_area;
     PangoAttrList *attrs;
 
-    info_bar = gtk_info_bar_new ();
-    gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_QUESTION);
-    gtk_widget_show (info_bar);
-    adw_bin_set_child (ADW_BIN (bar), info_bar);
+    action_area = gtk_info_bar_get_action_area (GTK_INFO_BAR (bar));
+
+    gtk_orientable_set_orientation (GTK_ORIENTABLE (action_area), GTK_ORIENTATION_HORIZONTAL);
 
     attrs = pango_attr_list_new ();
     pango_attr_list_insert (attrs, pango_attr_weight_new (PANGO_WEIGHT_BOLD));
@@ -178,18 +177,19 @@ nautilus_special_location_bar_init (NautilusSpecialLocationBar *bar)
     pango_attr_list_unref (attrs);
 
     gtk_label_set_ellipsize (GTK_LABEL (bar->label), PANGO_ELLIPSIZE_END);
-    gtk_info_bar_add_child (GTK_INFO_BAR (info_bar), bar->label);
+    gtk_info_bar_add_child (GTK_INFO_BAR (bar), bar->label);
 
     bar->learn_more_label = gtk_label_new (NULL);
     gtk_widget_set_hexpand (bar->learn_more_label, TRUE);
     gtk_widget_set_halign (bar->learn_more_label, GTK_ALIGN_END);
-    gtk_info_bar_add_child (GTK_INFO_BAR (info_bar), bar->learn_more_label);
+    gtk_info_bar_add_child (GTK_INFO_BAR (bar), bar->learn_more_label);
 }
 
 GtkWidget *
 nautilus_special_location_bar_new (NautilusSpecialLocation location)
 {
     return g_object_new (NAUTILUS_TYPE_SPECIAL_LOCATION_BAR,
+                         "message-type", GTK_MESSAGE_QUESTION,
                          "special-location", location,
                          NULL);
 }
diff --git a/src/nautilus-special-location-bar.h b/src/nautilus-special-location-bar.h
index 3d07c7171..d5772c103 100644
--- a/src/nautilus-special-location-bar.h
+++ b/src/nautilus-special-location-bar.h
@@ -24,7 +24,7 @@
 G_BEGIN_DECLS
 
 #define NAUTILUS_TYPE_SPECIAL_LOCATION_BAR (nautilus_special_location_bar_get_type ())
-G_DECLARE_FINAL_TYPE (NautilusSpecialLocationBar, nautilus_special_location_bar, NAUTILUS, 
SPECIAL_LOCATION_BAR, GtkBin)
+G_DECLARE_FINAL_TYPE (NautilusSpecialLocationBar, nautilus_special_location_bar, NAUTILUS, 
SPECIAL_LOCATION_BAR, GtkInfoBar)
 
 typedef enum {
        NAUTILUS_SPECIAL_LOCATION_TEMPLATES,
@@ -33,4 +33,4 @@ typedef enum {
 
 GtkWidget      *nautilus_special_location_bar_new (NautilusSpecialLocation location);
 
-G_END_DECLS
+G_END_DECLS
\ No newline at end of file
diff --git a/src/nautilus-trash-bar.c b/src/nautilus-trash-bar.c
index af87dbdf1..4f19bdfaa 100644
--- a/src/nautilus-trash-bar.c
+++ b/src/nautilus-trash-bar.c
@@ -49,27 +49,25 @@ enum
 
 struct _NautilusTrashBar
 {
-    GtkBin parent_instance;
+    GtkInfoBar parent_instance;
 
     NautilusFilesView *view;
     gulong selection_handler_id;
 };
 
-G_DEFINE_TYPE (NautilusTrashBar, nautilus_trash_bar, GTK_TYPE_BIN)
+G_DEFINE_TYPE (NautilusTrashBar, nautilus_trash_bar, GTK_TYPE_INFO_BAR)
 
 static void
 selection_changed_cb (NautilusFilesView *view,
                       NautilusTrashBar  *bar)
 {
     g_autolist (NautilusFile) selection = NULL;
-    GtkWidget *info_bar;
     int count;
 
     selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
     count = g_list_length (selection);
 
-    info_bar = gtk_bin_get_child (GTK_BIN (bar));
-    gtk_info_bar_set_response_sensitive (GTK_INFO_BAR (info_bar),
+    gtk_info_bar_set_response_sensitive (GTK_INFO_BAR (bar),
                                          TRASH_BAR_RESPONSE_RESTORE,
                                          (count > 0));
 }
@@ -126,12 +124,10 @@ nautilus_trash_bar_trash_state_changed (NautilusTrashMonitor *trash_monitor,
                                         gpointer              data)
 {
     NautilusTrashBar *bar;
-    GtkWidget *info_bar;
 
     bar = NAUTILUS_TRASH_BAR (data);
 
-    info_bar = gtk_bin_get_child (GTK_BIN (bar));
-    gtk_info_bar_set_response_sensitive (GTK_INFO_BAR (info_bar),
+    gtk_info_bar_set_response_sensitive (GTK_INFO_BAR (bar),
                                          TRASH_BAR_RESPONSE_EMPTY,
                                          !nautilus_trash_monitor_is_empty ());
 }
@@ -165,7 +161,7 @@ trash_bar_response_cb (GtkInfoBar *infobar,
     NautilusTrashBar *bar;
     GtkWidget *window;
 
-    bar = NAUTILUS_TRASH_BAR (user_data);
+    bar = NAUTILUS_TRASH_BAR (infobar);
     window = gtk_widget_get_toplevel (GTK_WIDGET (bar));
 
     switch (response_id)
@@ -216,17 +212,16 @@ trash_bar_response_cb (GtkInfoBar *infobar,
 static void
 nautilus_trash_bar_init (NautilusTrashBar *bar)
 {
-    GtkWidget *info_bar;
-    GtkWidget *w;
+    GtkWidget *action_area, *w;
     const gchar *subtitle_text;
     GtkWidget *label;
     GtkWidget *subtitle;
     PangoAttrList *attrs;
 
-    info_bar = gtk_info_bar_new ();
-    gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_QUESTION);
-    gtk_widget_show (info_bar);
-    adw_bin_set_child (ADW_BIN (bar), info_bar);
+    action_area = gtk_info_bar_get_action_area (GTK_INFO_BAR (bar));
+
+    gtk_orientable_set_orientation (GTK_ORIENTABLE (action_area),
+                                    GTK_ORIENTATION_HORIZONTAL);
 
     attrs = pango_attr_list_new ();
     pango_attr_list_insert (attrs, pango_attr_weight_new (PANGO_WEIGHT_BOLD));
@@ -246,23 +241,23 @@ nautilus_trash_bar_init (NautilusTrashBar *bar)
                      G_SETTINGS_BIND_GET);
 
     gtk_widget_show (label);
-    gtk_info_bar_add_child (GTK_INFO_BAR (info_bar), label);
+    gtk_info_bar_add_child (GTK_INFO_BAR (bar), label);
 
-    gtk_info_bar_add_child (GTK_INFO_BAR (info_bar), subtitle);
+    gtk_info_bar_add_child (GTK_INFO_BAR (bar), subtitle);
 
-    w = gtk_info_bar_add_button (GTK_INFO_BAR (info_bar),
+    w = gtk_info_bar_add_button (GTK_INFO_BAR (bar),
                                  _("_Settings"),
                                  TRASH_BAR_RESPONSE_AUTODELETE);
     gtk_widget_set_tooltip_text (w,
                                  _("Display system controls for trash content"));
 
-    w = gtk_info_bar_add_button (GTK_INFO_BAR (info_bar),
+    w = gtk_info_bar_add_button (GTK_INFO_BAR (bar),
                                  _("_Restore"),
                                  TRASH_BAR_RESPONSE_RESTORE);
     gtk_widget_set_tooltip_text (w,
                                  _("Restore selected items to their original position"));
 
-    w = gtk_info_bar_add_button (GTK_INFO_BAR (info_bar),
+    w = gtk_info_bar_add_button (GTK_INFO_BAR (bar),
                                  /* Translators: "Empty" is an action (for the trash) , not a state */
                                  _("_Empty…"),
                                  TRASH_BAR_RESPONSE_EMPTY);
@@ -277,7 +272,7 @@ nautilus_trash_bar_init (NautilusTrashBar *bar)
     nautilus_trash_bar_trash_state_changed (nautilus_trash_monitor_get (),
                                             FALSE, bar);
 
-    g_signal_connect (info_bar, "response",
+    g_signal_connect (bar, "response",
                       G_CALLBACK (trash_bar_response_cb), bar);
 }
 
@@ -286,5 +281,6 @@ nautilus_trash_bar_new (NautilusFilesView *view)
 {
     return g_object_new (NAUTILUS_TYPE_TRASH_BAR,
                          "view", view,
+                         "message-type", GTK_MESSAGE_QUESTION,
                          NULL);
 }
diff --git a/src/nautilus-trash-bar.h b/src/nautilus-trash-bar.h
index 9fc4ffa50..f838cbdaf 100644
--- a/src/nautilus-trash-bar.h
+++ b/src/nautilus-trash-bar.h
@@ -28,8 +28,8 @@ G_BEGIN_DECLS
 
 #define NAUTILUS_TYPE_TRASH_BAR (nautilus_trash_bar_get_type ())
 
-G_DECLARE_FINAL_TYPE (NautilusTrashBar, nautilus_trash_bar, NAUTILUS, TRASH_BAR, GtkBin)
+G_DECLARE_FINAL_TYPE (NautilusTrashBar, nautilus_trash_bar, NAUTILUS, TRASH_BAR, GtkInfoBar)
 
 GtkWidget *nautilus_trash_bar_new (NautilusFilesView *view);
 
-G_END_DECLS
+G_END_DECLS
\ No newline at end of file
diff --git a/src/nautilus-x-content-bar.c b/src/nautilus-x-content-bar.c
index 8dec51f41..2613cff46 100644
--- a/src/nautilus-x-content-bar.c
+++ b/src/nautilus-x-content-bar.c
@@ -34,7 +34,7 @@
 
 struct _NautilusXContentBar
 {
-    GtkBin parent_instance;
+    GtkInfoBar parent_instance;
     GtkWidget *label;
 
     char **x_content_types;
@@ -154,7 +154,6 @@ nautilus_x_content_bar_set_x_content_types (NautilusXContentBar *bar,
         const char *name;
         GIcon *icon;
         GtkWidget *image;
-        GtkWidget *info_bar;
         GtkWidget *button;
         GAppInfo *app;
         gboolean has_app;
@@ -190,8 +189,7 @@ nautilus_x_content_bar_set_x_content_types (NautilusXContentBar *bar,
         }
 
         name = g_app_info_get_name (default_app);
-        info_bar = gtk_bin_get_child (GTK_BIN (bar));
-        button = gtk_info_bar_add_button (GTK_INFO_BAR (info_bar), name, n);
+        button = gtk_info_bar_add_button (GTK_INFO_BAR (bar), name, n);
         box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
 
         if (image != NULL)
@@ -325,13 +323,12 @@ nautilus_x_content_bar_class_init (NautilusXContentBarClass *klass)
 static void
 nautilus_x_content_bar_init (NautilusXContentBar *bar)
 {
-    GtkWidget *info_bar;
+    GtkWidget *action_area;
     PangoAttrList *attrs;
 
-    info_bar = gtk_info_bar_new ();
-    gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_QUESTION);
-    gtk_widget_show (info_bar);
-    adw_bin_set_child (ADW_BIN (bar), info_bar);
+    action_area = gtk_info_bar_get_action_area (GTK_INFO_BAR (bar));
+
+    gtk_orientable_set_orientation (GTK_ORIENTABLE (action_area), GTK_ORIENTATION_HORIZONTAL);
 
     attrs = pango_attr_list_new ();
     pango_attr_list_insert (attrs, pango_attr_weight_new (PANGO_WEIGHT_BOLD));
@@ -340,9 +337,9 @@ nautilus_x_content_bar_init (NautilusXContentBar *bar)
     pango_attr_list_unref (attrs);
 
     gtk_label_set_ellipsize (GTK_LABEL (bar->label), PANGO_ELLIPSIZE_END);
-    gtk_info_bar_add_child (GTK_INFO_BAR (info_bar), bar->label);
+    gtk_info_bar_add_child (GTK_INFO_BAR (bar), bar->label);
 
-    g_signal_connect (info_bar, "response",
+    g_signal_connect (bar, "response",
                       G_CALLBACK (content_bar_response_cb),
                       bar);
 }
@@ -352,6 +349,7 @@ nautilus_x_content_bar_new (GMount             *mount,
                             const char * const *x_content_types)
 {
     return g_object_new (NAUTILUS_TYPE_X_CONTENT_BAR,
+                         "message-type", GTK_MESSAGE_QUESTION,
                          "mount", mount,
                          "x-content-types", x_content_types,
                          NULL);
diff --git a/src/nautilus-x-content-bar.h b/src/nautilus-x-content-bar.h
index af7bcaefe..78872c884 100644
--- a/src/nautilus-x-content-bar.h
+++ b/src/nautilus-x-content-bar.h
@@ -29,9 +29,9 @@ G_BEGIN_DECLS
 
 #define NAUTILUS_TYPE_X_CONTENT_BAR (nautilus_x_content_bar_get_type ())
 
-G_DECLARE_FINAL_TYPE (NautilusXContentBar, nautilus_x_content_bar, NAUTILUS, X_CONTENT_BAR, GtkBin)
+G_DECLARE_FINAL_TYPE (NautilusXContentBar, nautilus_x_content_bar, NAUTILUS, X_CONTENT_BAR, GtkInfoBar)
 
 GtkWidget *nautilus_x_content_bar_new (GMount             *mount,
                                        const char * const *x_content_types);
 
-G_END_DECLS
+G_END_DECLS
\ No newline at end of file


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]