diff options
author | António Fernandes <antoniof@gnome.org> | 2021-12-19 12:40:34 +0000 |
---|---|---|
committer | António Fernandes <antoniof@gnome.org> | 2022-01-01 22:04:06 +0000 |
commit | 0e8c0ac3a4a80a1ba8b98b4b2ad102f9df489d56 (patch) | |
tree | 0f2710decc488e17ba3e3cd0c9be1fdf53356b65 | |
parent | ee17419fd8aa0c1d3f9ec4acd68e752708a199d5 (diff) | |
download | nautilus-0e8c0ac3a4a80a1ba8b98b4b2ad102f9df489d56.tar.gz |
toolbar: Don't subclass HdyHeaderBar
In GTK4 we are not going to be able to subclass headerbars.
But subclassing GtkWidget directly implies adding a lot of
boilerplate to behave as a container.
The easy way around that is going to be AdwBin. Use GtkBin for the
time being, but introduce a wraper for a missing method.
-rw-r--r-- | src/nautilus-gtk4-helpers.c | 9 | ||||
-rw-r--r-- | src/nautilus-gtk4-helpers.h | 5 | ||||
-rw-r--r-- | src/nautilus-toolbar.c | 4 | ||||
-rw-r--r-- | src/nautilus-toolbar.h | 2 | ||||
-rw-r--r-- | src/resources/ui/nautilus-toolbar.ui | 385 |
5 files changed, 212 insertions, 193 deletions
diff --git a/src/nautilus-gtk4-helpers.c b/src/nautilus-gtk4-helpers.c index e61cf0611..247102e47 100644 --- a/src/nautilus-gtk4-helpers.c +++ b/src/nautilus-gtk4-helpers.c @@ -1,6 +1,15 @@ #include "nautilus-gtk4-helpers.h" void +adw_bin_set_child (AdwBin *bin, + GtkWidget *child) +{ + g_assert (GTK_IS_BIN (bin)); + + gtk_container_add (GTK_CONTAINER (bin), child); +} + +void gtk_button_set_child (GtkButton *button, GtkWidget *child) { diff --git a/src/nautilus-gtk4-helpers.h b/src/nautilus-gtk4-helpers.h index cdcb1068f..24f3a0d5e 100644 --- a/src/nautilus-gtk4-helpers.h +++ b/src/nautilus-gtk4-helpers.h @@ -7,6 +7,11 @@ G_BEGIN_DECLS #if GTK_MAJOR_VERSION < 4 +#define AdwBin GtkBin +#define ADW_BIN GTK_BIN + +void adw_bin_set_child (AdwBin *bin, + GtkWidget *child); void gtk_button_set_child (GtkButton *button, GtkWidget *child); void gtk_menu_button_set_child (GtkMenuButton *menu_button, diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c index b11d62053..7148427ac 100644 --- a/src/nautilus-toolbar.c +++ b/src/nautilus-toolbar.c @@ -54,7 +54,7 @@ typedef enum struct _NautilusToolbar { - GtkHeaderBar parent_instance; + GtkBin parent_instance; NautilusWindow *window; @@ -121,7 +121,7 @@ enum static GParamSpec *properties[NUM_PROPERTIES] = { NULL, }; -G_DEFINE_TYPE (NautilusToolbar, nautilus_toolbar, HDY_TYPE_HEADER_BAR); +G_DEFINE_TYPE (NautilusToolbar, nautilus_toolbar, GTK_TYPE_BIN); static void nautilus_toolbar_set_window_slot_real (NautilusToolbar *self, NautilusWindowSlot *slot); diff --git a/src/nautilus-toolbar.h b/src/nautilus-toolbar.h index 364bc76d8..6f49acee1 100644 --- a/src/nautilus-toolbar.h +++ b/src/nautilus-toolbar.h @@ -32,7 +32,7 @@ G_BEGIN_DECLS #define NAUTILUS_TYPE_TOOLBAR nautilus_toolbar_get_type() -G_DECLARE_FINAL_TYPE (NautilusToolbar, nautilus_toolbar, NAUTILUS, TOOLBAR, HdyHeaderBar) +G_DECLARE_FINAL_TYPE (NautilusToolbar, nautilus_toolbar, NAUTILUS, TOOLBAR, GtkBin) GtkWidget *nautilus_toolbar_new (void); diff --git a/src/resources/ui/nautilus-toolbar.ui b/src/resources/ui/nautilus-toolbar.ui index fe95facfd..8bb25bf2e 100644 --- a/src/resources/ui/nautilus-toolbar.ui +++ b/src/resources/ui/nautilus-toolbar.ui @@ -135,203 +135,105 @@ </object> </child> </object> - <template class="NautilusToolbar" parent="HdyHeaderBar"> + <template class="NautilusToolbar" parent="GtkBin"> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="show_close_button">True</property> - <child type="title"> - <object class="GtkBox" id="header_toolbar"> - <property name="width_request">270</property> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="spacing">6</property> - <child> - <object class="GtkStack" id="toolbar_switcher"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="valign">center</property> - <property name="hexpand">False</property> - <property name="transition_type">crossfade</property> - <child> - <object class="GtkBox" id="path_bar_container"> - <property name="can_focus">False</property> - <property name="valign">center</property> - </object> - <packing> - <property name="name">pathbar</property> - </packing> - </child> - <child> - <object class="GtkBox" id="location_entry_container"> - <property name="can_focus">False</property> - <style> - <class name="linked"/> - </style> - </object> - <packing> - <property name="name">location</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkBox" id="search_container"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="orientation">vertical</property> - </object> - <packing> - <property name="name">search</property> - <property name="position">2</property> - </packing> - </child> - </object> - </child> - <child> - <object class="GtkToggleButton" id="search_button"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="tooltip_text" translatable="yes">Search</property> - <property name="halign">center</property> - <property name="valign">center</property> - <property name="action_name">slot.search-visible</property> - <child> - <object class="GtkImage" id="search_icon"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="icon_name">edit-find-symbolic</property> - <property name="icon_size">1</property> - </object> - </child> - <style> - <class name="image-button"/> - </style> - </object> - <packing> - <property name="position">2</property> - </packing> - </child> - </object> - </child> <child> - <object class="GtkBox" id="navigation_box"> + <object class="HdyHeaderBar"> <property name="visible">True</property> <property name="can_focus">False</property> - <child> - <object class="GtkButton" id="back_button"> + <property name="show_close_button">True</property> + <child type="title"> + <object class="GtkBox" id="header_toolbar"> + <property name="width_request">270</property> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="tooltip_text" translatable="yes">Go back</property> - <property name="halign">center</property> - <property name="valign">center</property> - <property name="action_name">win.back</property> + <property name="can_focus">False</property> + <property name="spacing">6</property> <child> - <object class="GtkImage" id="back_icon"> + <object class="GtkStack" id="toolbar_switcher"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="icon_name">go-previous-symbolic</property> - <property name="icon_size">1</property> + <property name="valign">center</property> + <property name="hexpand">False</property> + <property name="transition_type">crossfade</property> + <child> + <object class="GtkBox" id="path_bar_container"> + <property name="can_focus">False</property> + <property name="valign">center</property> + </object> + <packing> + <property name="name">pathbar</property> + </packing> + </child> + <child> + <object class="GtkBox" id="location_entry_container"> + <property name="can_focus">False</property> + <style> + <class name="linked"/> + </style> + </object> + <packing> + <property name="name">location</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkBox" id="search_container"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + </object> + <packing> + <property name="name">search</property> + <property name="position">2</property> + </packing> + </child> </object> </child> - <style> - <class name="image-button"/> - </style> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkButton" id="forward_button"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="tooltip_text" translatable="yes">Go forward</property> - <property name="halign">center</property> - <property name="valign">center</property> - <property name="action_name">win.forward</property> <child> - <object class="GtkImage" id="forward_icon"> + <object class="GtkToggleButton" id="search_button"> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="icon_name">go-next-symbolic</property> - <property name="icon_size">1</property> - </object> - </child> - <style> - <class name="image-button"/> - </style> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> - <style> - <class name="linked"/> - <class name="raised"/> - </style> - </object> - </child> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="margin_start">72</property> - <child> - <object class="GtkRevealer" id="operations_revealer"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="halign">center</property> - <property name="valign">center</property> - <property name="transition_type">slide-right</property> - <child> - <object class="GtkMenuButton" id="operations_button"> <property name="can_focus">True</property> <property name="receives_default">False</property> - <property name="tooltip_text" translatable="yes">Show operations</property> - <property name="margin_end">6</property> - <property name="popover">operations_popover</property> - <signal name="toggled" handler="on_operations_button_toggled" object="NautilusToolbar" swapped="yes"/> + <property name="tooltip_text" translatable="yes">Search</property> + <property name="halign">center</property> + <property name="valign">center</property> + <property name="action_name">slot.search-visible</property> <child> - <object class="GtkDrawingArea" id="operations_icon"> - <property name="width_request">16</property> - <property name="height_request">16</property> + <object class="GtkImage" id="search_icon"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="halign">center</property> - <property name="valign">center</property> - <signal name="draw" handler="on_operations_icon_draw" object="NautilusToolbar" swapped="no"/> + <property name="icon_name">edit-find-symbolic</property> + <property name="icon_size">1</property> </object> </child> <style> - <class name="button"/> + <class name="image-button"/> </style> </object> + <packing> + <property name="position">2</property> + </packing> </child> </object> - <packing> - <property name="position">0</property> - </packing> </child> <child> - <object class="GtkBox"> + <object class="GtkBox" id="navigation_box"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="halign">center</property> - <property name="valign">center</property> - <property name="margin_end">6</property> <child> - <object class="GtkButton" id="view_toggle_button"> + <object class="GtkButton" id="back_button"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> - <property name="tooltip_text" translatable="yes">Toggle view</property> - <property name="action_name">slot.files-view-mode-toggle</property> + <property name="tooltip_text" translatable="yes">Go back</property> + <property name="halign">center</property> + <property name="valign">center</property> + <property name="action_name">win.back</property> <child> - <object class="GtkImage" id="view_toggle_icon"> + <object class="GtkImage" id="back_icon"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="icon_name">go-previous-symbolic</property> <property name="icon_size">1</property> </object> </child> @@ -344,23 +246,24 @@ </packing> </child> <child> - <object class="GtkMenuButton" id="view_button"> + <object class="GtkButton" id="forward_button"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="tooltip_text" translatable="yes" comments="“View” is a noun">View options</property> - <property name="halign">start</property> - <property name="action_name">win.view-menu</property> - <property name="menu-model">view_menu</property> + <property name="receives_default">False</property> + <property name="tooltip_text" translatable="yes">Go forward</property> + <property name="halign">center</property> + <property name="valign">center</property> + <property name="action_name">win.forward</property> <child> - <object class="GtkImage"> + <object class="GtkImage" id="forward_icon"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="icon_name">pan-down-symbolic</property> + <property name="icon_name">go-next-symbolic</property> + <property name="icon_size">1</property> </object> </child> <style> - <class name="disclosure-button"/> + <class name="image-button"/> </style> </object> <packing> @@ -369,41 +272,143 @@ </child> <style> <class name="linked"/> + <class name="raised"/> </style> </object> - <packing> - <property name="position">2</property> - </packing> </child> <child> - <object class="GtkMenuButton" id="app_button"> + <object class="GtkBox"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="halign">center</property> - <property name="valign">center</property> - <property name="menu-model">app_menu</property> + <property name="can_focus">False</property> + <property name="margin_start">72</property> <child> - <object class="GtkImage"> + <object class="GtkRevealer" id="operations_revealer"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="icon_name">open-menu-symbolic</property> - <property name="icon_size">1</property> + <property name="halign">center</property> + <property name="valign">center</property> + <property name="transition_type">slide-right</property> + <child> + <object class="GtkMenuButton" id="operations_button"> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="tooltip_text" translatable="yes">Show operations</property> + <property name="margin_end">6</property> + <property name="popover">operations_popover</property> + <signal name="toggled" handler="on_operations_button_toggled" object="NautilusToolbar" swapped="yes"/> + <child> + <object class="GtkDrawingArea" id="operations_icon"> + <property name="width_request">16</property> + <property name="height_request">16</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">center</property> + <property name="valign">center</property> + <signal name="draw" handler="on_operations_icon_draw" object="NautilusToolbar" swapped="no"/> + </object> + </child> + <style> + <class name="button"/> + </style> + </object> + </child> </object> + <packing> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">center</property> + <property name="valign">center</property> + <property name="margin_end">6</property> + <child> + <object class="GtkButton" id="view_toggle_button"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="tooltip_text" translatable="yes">Toggle view</property> + <property name="action_name">slot.files-view-mode-toggle</property> + <child> + <object class="GtkImage" id="view_toggle_icon"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_size">1</property> + </object> + </child> + <style> + <class name="image-button"/> + </style> + </object> + <packing> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkMenuButton" id="view_button"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="tooltip_text" translatable="yes" comments="“View” is a noun">View options</property> + <property name="halign">start</property> + <property name="action_name">win.view-menu</property> + <property name="menu-model">view_menu</property> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">pan-down-symbolic</property> + </object> + </child> + <style> + <class name="disclosure-button"/> + </style> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + <style> + <class name="linked"/> + </style> + </object> + <packing> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkMenuButton" id="app_button"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="halign">center</property> + <property name="valign">center</property> + <property name="menu-model">app_menu</property> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">open-menu-symbolic</property> + <property name="icon_size">1</property> + </object> + </child> + <style> + <class name="image-button"/> + </style> + </object> + <packing> + <property name="position">3</property> + </packing> </child> - <style> - <class name="image-button"/> - </style> </object> <packing> + <property name="pack_type">end</property> <property name="position">3</property> </packing> </child> </object> - <packing> - <property name="pack_type">end</property> - <property name="position">3</property> - </packing> </child> </template> </interface> |