[nautilus/wip/antoniof/gtk4-preparation-discontinued-api: 15/19] general: Don't subclass GtkInfoBar
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/gtk4-preparation-discontinued-api: 15/19] general: Don't subclass GtkInfoBar
- Date: Sun, 26 Dec 2021 23:58:48 +0000 (UTC)
commit 8208d193416d02578399f9095cce51d3a77b2363
Author: António Fernandes <antoniof gnome org>
Date: Sun Dec 19 12:51:53 2021 +0000
general: Don't subclass GtkInfoBar
It's going to be a final class one we switch to GTK 4.
In preparation, become bins containing an info bar.
Also, stop using gtk_info_bar_get_action_area(), which is gone in GTK 4
and we are using it only to set the box to horizontal orientation,
which is the default anyway.
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, 47 insertions(+), 41 deletions(-)
---
diff --git a/src/nautilus-special-location-bar.c b/src/nautilus-special-location-bar.c
index ce4052122..d2a559726 100644
--- a/src/nautilus-special-location-bar.c
+++ b/src/nautilus-special-location-bar.c
@@ -28,7 +28,7 @@
struct _NautilusSpecialLocationBar
{
- GtkInfoBar parent_instance;
+ GtkBin 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_INFO_BAR)
+G_DEFINE_TYPE (NautilusSpecialLocationBar, nautilus_special_location_bar, GTK_TYPE_BIN)
static void
set_special_location (NautilusSpecialLocationBar *bar,
@@ -163,12 +163,13 @@ nautilus_special_location_bar_class_init (NautilusSpecialLocationBarClass *klass
static void
nautilus_special_location_bar_init (NautilusSpecialLocationBar *bar)
{
- GtkWidget *action_area;
+ GtkWidget *info_bar;
PangoAttrList *attrs;
- action_area = gtk_info_bar_get_action_area (GTK_INFO_BAR (bar));
-
- gtk_orientable_set_orientation (GTK_ORIENTABLE (action_area), GTK_ORIENTATION_HORIZONTAL);
+ 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);
attrs = pango_attr_list_new ();
pango_attr_list_insert (attrs, pango_attr_weight_new (PANGO_WEIGHT_BOLD));
@@ -177,19 +178,18 @@ 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 (bar), bar->label);
+ gtk_info_bar_add_child (GTK_INFO_BAR (info_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 (bar), bar->learn_more_label);
+ gtk_info_bar_add_child (GTK_INFO_BAR (info_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 d5772c103..3d07c7171 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, GtkInfoBar)
+G_DECLARE_FINAL_TYPE (NautilusSpecialLocationBar, nautilus_special_location_bar, NAUTILUS,
SPECIAL_LOCATION_BAR, GtkBin)
typedef enum {
NAUTILUS_SPECIAL_LOCATION_TEMPLATES,
@@ -33,4 +33,4 @@ typedef enum {
GtkWidget *nautilus_special_location_bar_new (NautilusSpecialLocation location);
-G_END_DECLS
\ No newline at end of file
+G_END_DECLS
diff --git a/src/nautilus-trash-bar.c b/src/nautilus-trash-bar.c
index 4f19bdfaa..af87dbdf1 100644
--- a/src/nautilus-trash-bar.c
+++ b/src/nautilus-trash-bar.c
@@ -49,25 +49,27 @@ enum
struct _NautilusTrashBar
{
- GtkInfoBar parent_instance;
+ GtkBin parent_instance;
NautilusFilesView *view;
gulong selection_handler_id;
};
-G_DEFINE_TYPE (NautilusTrashBar, nautilus_trash_bar, GTK_TYPE_INFO_BAR)
+G_DEFINE_TYPE (NautilusTrashBar, nautilus_trash_bar, GTK_TYPE_BIN)
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);
- gtk_info_bar_set_response_sensitive (GTK_INFO_BAR (bar),
+ info_bar = gtk_bin_get_child (GTK_BIN (bar));
+ gtk_info_bar_set_response_sensitive (GTK_INFO_BAR (info_bar),
TRASH_BAR_RESPONSE_RESTORE,
(count > 0));
}
@@ -124,10 +126,12 @@ nautilus_trash_bar_trash_state_changed (NautilusTrashMonitor *trash_monitor,
gpointer data)
{
NautilusTrashBar *bar;
+ GtkWidget *info_bar;
bar = NAUTILUS_TRASH_BAR (data);
- gtk_info_bar_set_response_sensitive (GTK_INFO_BAR (bar),
+ info_bar = gtk_bin_get_child (GTK_BIN (bar));
+ gtk_info_bar_set_response_sensitive (GTK_INFO_BAR (info_bar),
TRASH_BAR_RESPONSE_EMPTY,
!nautilus_trash_monitor_is_empty ());
}
@@ -161,7 +165,7 @@ trash_bar_response_cb (GtkInfoBar *infobar,
NautilusTrashBar *bar;
GtkWidget *window;
- bar = NAUTILUS_TRASH_BAR (infobar);
+ bar = NAUTILUS_TRASH_BAR (user_data);
window = gtk_widget_get_toplevel (GTK_WIDGET (bar));
switch (response_id)
@@ -212,16 +216,17 @@ trash_bar_response_cb (GtkInfoBar *infobar,
static void
nautilus_trash_bar_init (NautilusTrashBar *bar)
{
- GtkWidget *action_area, *w;
+ GtkWidget *info_bar;
+ GtkWidget *w;
const gchar *subtitle_text;
GtkWidget *label;
GtkWidget *subtitle;
PangoAttrList *attrs;
- action_area = gtk_info_bar_get_action_area (GTK_INFO_BAR (bar));
-
- gtk_orientable_set_orientation (GTK_ORIENTABLE (action_area),
- GTK_ORIENTATION_HORIZONTAL);
+ 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);
attrs = pango_attr_list_new ();
pango_attr_list_insert (attrs, pango_attr_weight_new (PANGO_WEIGHT_BOLD));
@@ -241,23 +246,23 @@ nautilus_trash_bar_init (NautilusTrashBar *bar)
G_SETTINGS_BIND_GET);
gtk_widget_show (label);
- gtk_info_bar_add_child (GTK_INFO_BAR (bar), label);
+ gtk_info_bar_add_child (GTK_INFO_BAR (info_bar), label);
- gtk_info_bar_add_child (GTK_INFO_BAR (bar), subtitle);
+ gtk_info_bar_add_child (GTK_INFO_BAR (info_bar), subtitle);
- w = gtk_info_bar_add_button (GTK_INFO_BAR (bar),
+ w = gtk_info_bar_add_button (GTK_INFO_BAR (info_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 (bar),
+ w = gtk_info_bar_add_button (GTK_INFO_BAR (info_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 (bar),
+ w = gtk_info_bar_add_button (GTK_INFO_BAR (info_bar),
/* Translators: "Empty" is an action (for the trash) , not a state */
_("_Empty…"),
TRASH_BAR_RESPONSE_EMPTY);
@@ -272,7 +277,7 @@ nautilus_trash_bar_init (NautilusTrashBar *bar)
nautilus_trash_bar_trash_state_changed (nautilus_trash_monitor_get (),
FALSE, bar);
- g_signal_connect (bar, "response",
+ g_signal_connect (info_bar, "response",
G_CALLBACK (trash_bar_response_cb), bar);
}
@@ -281,6 +286,5 @@ 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 f838cbdaf..9fc4ffa50 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, GtkInfoBar)
+G_DECLARE_FINAL_TYPE (NautilusTrashBar, nautilus_trash_bar, NAUTILUS, TRASH_BAR, GtkBin)
GtkWidget *nautilus_trash_bar_new (NautilusFilesView *view);
-G_END_DECLS
\ No newline at end of file
+G_END_DECLS
diff --git a/src/nautilus-x-content-bar.c b/src/nautilus-x-content-bar.c
index 2613cff46..8dec51f41 100644
--- a/src/nautilus-x-content-bar.c
+++ b/src/nautilus-x-content-bar.c
@@ -34,7 +34,7 @@
struct _NautilusXContentBar
{
- GtkInfoBar parent_instance;
+ GtkBin parent_instance;
GtkWidget *label;
char **x_content_types;
@@ -154,6 +154,7 @@ 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;
@@ -189,7 +190,8 @@ nautilus_x_content_bar_set_x_content_types (NautilusXContentBar *bar,
}
name = g_app_info_get_name (default_app);
- button = gtk_info_bar_add_button (GTK_INFO_BAR (bar), name, n);
+ info_bar = gtk_bin_get_child (GTK_BIN (bar));
+ button = gtk_info_bar_add_button (GTK_INFO_BAR (info_bar), name, n);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
if (image != NULL)
@@ -323,12 +325,13 @@ nautilus_x_content_bar_class_init (NautilusXContentBarClass *klass)
static void
nautilus_x_content_bar_init (NautilusXContentBar *bar)
{
- GtkWidget *action_area;
+ GtkWidget *info_bar;
PangoAttrList *attrs;
- action_area = gtk_info_bar_get_action_area (GTK_INFO_BAR (bar));
-
- gtk_orientable_set_orientation (GTK_ORIENTABLE (action_area), GTK_ORIENTATION_HORIZONTAL);
+ 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);
attrs = pango_attr_list_new ();
pango_attr_list_insert (attrs, pango_attr_weight_new (PANGO_WEIGHT_BOLD));
@@ -337,9 +340,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 (bar), bar->label);
+ gtk_info_bar_add_child (GTK_INFO_BAR (info_bar), bar->label);
- g_signal_connect (bar, "response",
+ g_signal_connect (info_bar, "response",
G_CALLBACK (content_bar_response_cb),
bar);
}
@@ -349,7 +352,6 @@ 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 78872c884..af7bcaefe 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, GtkInfoBar)
+G_DECLARE_FINAL_TYPE (NautilusXContentBar, nautilus_x_content_bar, NAUTILUS, X_CONTENT_BAR, GtkBin)
GtkWidget *nautilus_x_content_bar_new (GMount *mount,
const char * const *x_content_types);
-G_END_DECLS
\ No newline at end of file
+G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]