diff options
author | Carlos Soriano <csoriano@gnome.org> | 2018-04-06 09:43:07 +0200 |
---|---|---|
committer | Carlos Soriano <csoriano@gnome.org> | 2018-04-09 11:56:20 +0200 |
commit | 540a29ba7fc9bc8acf0442863f87512dde31d454 (patch) | |
tree | 3fb963649208c0f1c8af0e3c34408bd8a156aa9d /src | |
parent | 657dc8c234234df3d83c1a335909da2be93896a8 (diff) | |
download | nautilus-540a29ba7fc9bc8acf0442863f87512dde31d454.tar.gz |
action-bar: Take full width window
Diffstat (limited to 'src')
-rw-r--r-- | src/nautilus-action-bar.c | 117 | ||||
-rw-r--r-- | src/nautilus-action-bar.h | 9 | ||||
-rw-r--r-- | src/nautilus-window.c | 9 | ||||
-rw-r--r-- | src/resources/ui/nautilus-action-bar.ui | 229 | ||||
-rw-r--r-- | src/resources/ui/nautilus-window.ui | 9 |
5 files changed, 216 insertions, 157 deletions
diff --git a/src/nautilus-action-bar.c b/src/nautilus-action-bar.c index e50d2fe5c..206132838 100644 --- a/src/nautilus-action-bar.c +++ b/src/nautilus-action-bar.c @@ -25,31 +25,31 @@ #include <glib/gi18n.h> -#define UPDATE_STATUS_TIMEOUT 200 //ms +#define UPDATE_STATUS_TIMEOUT 300 //ms struct _NautilusActionBar { - GtkFrame parent; + GtkBox parent; GtkWidget *loading_label; GtkWidget *paste_button; GtkWidget *primary_label; GtkWidget *stack; - NautilusView *view; + NautilusWindowSlot *slot; gint update_status_timeout_id; }; -G_DEFINE_TYPE (NautilusActionBar, nautilus_action_bar, GTK_TYPE_FRAME) +G_DEFINE_TYPE (NautilusActionBar, nautilus_action_bar, GTK_TYPE_BOX) enum { PROP_0, - PROP_VIEW, + PROP_SLOT, N_PROPS }; static void -open_preview_cb (NautilusActionBar *actionbar) +open_preslot_cb (NautilusActionBar *actionbar) { GtkWidget *toplevel; GdkWindow *window; @@ -59,9 +59,9 @@ open_preview_cb (NautilusActionBar *actionbar) xid = 0; uri = NULL; - selection = nautilus_view_get_selection (actionbar->view); + selection = nautilus_window_slot_get_selection (actionbar->slot); - /* Only preview if exact 1 file is selected */ + /* Only preslot if exact 1 file is selected */ if (g_list_length (selection) != 1) goto out; @@ -134,7 +134,10 @@ setup_multiple_files_selection (NautilusActionBar *actionbar, nautilus_file_list_free (selection); - gtk_label_set_label (GTK_LABEL (actionbar->primary_label), primary_text ? primary_text : ""); + if (primary_text != NULL) + { + gtk_label_set_label (GTK_LABEL (actionbar->primary_label), primary_text); + } } static void @@ -183,24 +186,26 @@ real_update_status (gpointer data) { NautilusActionBar *actionbar = data; - if (nautilus_view_is_loading (actionbar->view)) + if (actionbar->slot != NULL && nautilus_window_slot_get_loading (actionbar->slot)) { gtk_label_set_label (GTK_LABEL (actionbar->loading_label), - nautilus_view_is_searching (actionbar->view) ? _("Searching") : _("Loading")); + nautilus_window_slot_get_searching (actionbar->slot) ? _("Searching") : _("Loading")); gtk_stack_set_visible_child_name (GTK_STACK (actionbar->stack), "loading_bar"); } else { GList *selection; - gint number_of_files; + gint number_of_files = 0; - selection = nautilus_view_get_selection (actionbar->view); - number_of_files = g_list_length (selection); + if (actionbar->slot != NULL) + { + selection = nautilus_window_slot_get_selection (actionbar->slot); + number_of_files = g_list_length (selection); + } if (number_of_files == 0) { - gtk_label_set_label (GTK_LABEL (actionbar->primary_label), ""); gtk_stack_set_visible_child_name (GTK_STACK (actionbar->stack), "background_bar"); } else if (number_of_files == 1) @@ -223,6 +228,7 @@ real_update_status (gpointer data) static void update_status (NautilusActionBar *actionbar) { + g_print ("update status\n"); if (actionbar->update_status_timeout_id > 0) { g_source_remove (actionbar->update_status_timeout_id); @@ -244,15 +250,22 @@ nautilus_action_bar_dispose (GObject *object) g_source_remove (self->update_status_timeout_id); self->update_status_timeout_id = 0; } - if (self->view != NULL) + if (self->slot != NULL) { - g_signal_handlers_disconnect_by_data (self->view, self); - g_clear_object (&self->view); + g_signal_handlers_disconnect_by_data (self->slot, self); + g_clear_object (&self->slot); } G_OBJECT_CLASS (nautilus_action_bar_parent_class)->dispose (object); } +void +nautilus_action_bar_set_slot (NautilusActionBar *self, + NautilusWindowSlot *slot) +{ + g_object_set (self, "slot", slot, NULL); +} + static void nautilus_action_bar_finalize (GObject *object) { @@ -272,8 +285,8 @@ nautilus_action_bar_get_property (GObject *object, switch (prop_id) { - case PROP_VIEW: - g_value_set_object (value, self->view); + case PROP_SLOT: + g_value_set_object (value, self->slot); break; default: @@ -290,21 +303,34 @@ nautilus_action_bar_set_property (GObject *object, NautilusActionBar *self = NAUTILUS_ACTION_BAR (object); switch (prop_id) + { + case PROP_SLOT: { - case PROP_VIEW: - if (g_set_object (&self->view, g_value_get_object (value))) + g_print ("setting slot\n"); + if (self->slot != NULL) { - g_signal_connect_swapped (self->view, "notify::selection", G_CALLBACK (update_status), self); - g_signal_connect_swapped (self->view, "notify::is-loading", G_CALLBACK (update_status), self); - g_signal_connect_swapped (self->view, "notify::is-searching", G_CALLBACK (update_status), self); - g_object_notify (object, "view"); + g_signal_handlers_disconnect_by_data (self->slot, self); } - - break; + g_set_object (&self->slot, g_value_get_object (value)); + if (self->slot != NULL) + { + g_signal_connect_swapped (self->slot, "notify::selection", + G_CALLBACK (update_status), self); + g_signal_connect_swapped (self->slot, "notify::loading", + G_CALLBACK (update_status), self); + g_signal_connect_swapped (self->slot, "notify::searching", + G_CALLBACK (update_status), self); + + g_object_notify (object, "slot"); + } + } + break; default: + { G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } + } } static void @@ -319,17 +345,17 @@ nautilus_action_bar_class_init (NautilusActionBarClass *klass) object_class->set_property = nautilus_action_bar_set_property; /** - * NautilusActionBar::view: + * NautilusActionBar::slot: * - * The view related to this actionbar. + * The slot related to this actionbar. */ g_object_class_install_property (object_class, - PROP_VIEW, - g_param_spec_object ("view", - "View of the actionbar", - "The view related to this actionbar", - NAUTILUS_TYPE_VIEW, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + PROP_SLOT, + g_param_spec_object ("slot", + "Current slot of the window", + "Current slot of the window", + NAUTILUS_TYPE_WINDOW_SLOT, + G_PARAM_READWRITE)); gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/nautilus/ui/nautilus-action-bar.ui"); @@ -338,7 +364,7 @@ nautilus_action_bar_class_init (NautilusActionBarClass *klass) gtk_widget_class_bind_template_child (widget_class, NautilusActionBar, primary_label); gtk_widget_class_bind_template_child (widget_class, NautilusActionBar, stack); - gtk_widget_class_bind_template_callback (widget_class, open_preview_cb); + gtk_widget_class_bind_template_callback (widget_class, open_preslot_cb); gtk_widget_class_set_css_name (widget_class, "actionbar"); } @@ -356,18 +382,9 @@ nautilus_action_bar_init (NautilusActionBar *self) #endif } -/** - * nautilus_action_bar_new: - * @view: a #NautilusView - * - * Creates a new actionbar related to @view. - * - * Returns: (transfer full): a #NautilusActionBar - */ -GtkWidget* -nautilus_action_bar_new (NautilusView *view) +NautilusActionBar* +nautilus_action_bar_new (void) { - return g_object_new (NAUTILUS_TYPE_ACTION_BAR, - "view", view, - NULL); + return NAUTILUS_ACTION_BAR (g_object_new (NAUTILUS_TYPE_ACTION_BAR, + NULL)); } diff --git a/src/nautilus-action-bar.h b/src/nautilus-action-bar.h index 0af85b3a9..1f26bf79b 100644 --- a/src/nautilus-action-bar.h +++ b/src/nautilus-action-bar.h @@ -21,15 +21,18 @@ #include <gtk/gtk.h> -#include "nautilus-view.h" +#include "nautilus-window-slot.h" G_BEGIN_DECLS #define NAUTILUS_TYPE_ACTION_BAR (nautilus_action_bar_get_type()) -G_DECLARE_FINAL_TYPE (NautilusActionBar, nautilus_action_bar, NAUTILUS, ACTION_BAR, GtkFrame) +G_DECLARE_FINAL_TYPE (NautilusActionBar, nautilus_action_bar, NAUTILUS, ACTION_BAR, GtkBox) -GtkWidget* nautilus_action_bar_new (NautilusView *view); +NautilusActionBar* nautilus_action_bar_new (void); + +void nautilus_action_bar_set_slot (NautilusActionBar *self, + NautilusWindowSlot *slot); void nautilus_action_bar_set_show_thumbnail (NautilusActionBar *actionbar, gboolean show_thumbnail); diff --git a/src/nautilus-window.c b/src/nautilus-window.c index 05fb98572..f63538ab1 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -59,6 +59,7 @@ #include "nautilus-signaller.h" #include "nautilus-trash-monitor.h" #include "nautilus-ui-utilities.h" +#include "nautilus-action-bar.h" #define DEBUG_FLAG NAUTILUS_DEBUG_WINDOW #include "nautilus-debug.h" @@ -112,6 +113,9 @@ typedef struct GVolume *selected_volume; /* the selected volume in the sidebar popup callback */ GFile *selected_file; /* the selected file in the sidebar popup callback */ + /* Action bar */ + NautilusActionBar *action_bar; + /* Main view */ GtkWidget *main_view; @@ -2426,6 +2430,8 @@ nautilus_window_constructed (GObject *self) g_signal_connect_swapped (nautilus_application_get_bookmarks (application), "changed", G_CALLBACK (nautilus_window_sync_bookmarks), window); + priv->action_bar = nautilus_action_bar_new (); + nautilus_toolbar_on_window_constructed (NAUTILUS_TOOLBAR (priv->toolbar)); nautilus_profile_end (NULL); @@ -2627,6 +2633,7 @@ nautilus_window_set_active_slot (NautilusWindow *window, { /* inform slot & view */ nautilus_window_slot_set_active (old_slot, FALSE); + nautilus_action_bar_set_slot (priv->action_bar, NULL); } priv->active_slot = new_slot; @@ -2635,6 +2642,7 @@ nautilus_window_set_active_slot (NautilusWindow *window, if (new_slot) { nautilus_toolbar_set_active_slot (NAUTILUS_TOOLBAR (priv->toolbar), new_slot); + nautilus_action_bar_set_slot (priv->action_bar, new_slot); /* inform slot & view */ nautilus_window_slot_set_active (new_slot, TRUE); @@ -2934,6 +2942,7 @@ nautilus_window_class_init (NautilusWindowClass *class) gtk_widget_class_bind_template_child_private (wclass, NautilusWindow, content_paned); gtk_widget_class_bind_template_child_private (wclass, NautilusWindow, sidebar); gtk_widget_class_bind_template_child_private (wclass, NautilusWindow, places_sidebar); + gtk_widget_class_bind_template_child_private (wclass, NautilusWindow, action_bar); gtk_widget_class_bind_template_child_private (wclass, NautilusWindow, main_view); gtk_widget_class_bind_template_child_private (wclass, NautilusWindow, notebook); gtk_widget_class_bind_template_child_private (wclass, NautilusWindow, in_app_notification_undo); diff --git a/src/resources/ui/nautilus-action-bar.ui b/src/resources/ui/nautilus-action-bar.ui index d70c6a52c..856a05bb9 100644 --- a/src/resources/ui/nautilus-action-bar.ui +++ b/src/resources/ui/nautilus-action-bar.ui @@ -2,16 +2,18 @@ <!-- Generated with glade 3.22.0 --> <interface> <requires lib="gtk+" version="3.18"/> - <template class="NautilusActionBar" parent="GtkFrame"> + <template class="NautilusActionBar" parent="GtkBox"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="label_xalign">0</property> - <property name="shadow_type">none</property> <child> <object class="GtkStack" id="stack"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="border_width">0</property> + <property name="margin_left">4</property> + <property name="margin_right">4</property> + <property name="margin_top">4</property> + <property name="margin_bottom">4</property> + <property name="hexpand">True</property> <property name="transition_type">crossfade</property> <child> <object class="GtkBox"> @@ -21,14 +23,21 @@ <object class="GtkBox"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="margin_left">4</property> <property name="spacing">4</property> <child> <object class="GtkButton"> - <property name="label" translatable="yes">Open</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> - <property name="action_name">view.open-with-default-application</property> + <property name="action_name">view.star</property> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">non-starred-symbolic</property> + </object> + </child> </object> <packing> <property name="expand">True</property> @@ -38,79 +47,122 @@ </child> <child> <object class="GtkButton"> - <property name="label" translatable="yes">Cut</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> - <property name="action_name">view.cut</property> + <property name="action_name">view.move-to-trash</property> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">user-trash-symbolic</property> + </object> + </child> </object> <packing> <property name="expand">True</property> <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkButton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">view-more-symbolic</property> + </object> + </child> + <style> + <class name="image-button"/> + </style> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> <property name="position">2</property> </packing> </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="pack_type">end</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="spacing">4</property> + <property name="homogeneous">True</property> <child> <object class="GtkButton"> - <property name="label" translatable="yes">Copy</property> + <property name="label" translatable="yes">Open</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> - <property name="action_name">view.copy</property> + <property name="action_name">view.open-with-default-application</property> </object> <packing> <property name="expand">True</property> <property name="fill">True</property> - <property name="position">4</property> + <property name="position">0</property> </packing> </child> <child> <object class="GtkButton"> - <property name="label" translatable="yes">Star</property> + <property name="label" translatable="yes">Copy</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> - <property name="action_name">view.star</property> + <property name="action_name">view.copy</property> </object> <packing> <property name="expand">True</property> <property name="fill">True</property> - <property name="position">6</property> + <property name="position">1</property> </packing> </child> <child> <object class="GtkButton"> - <property name="label" translatable="yes">Rename...</property> + <property name="label" translatable="yes">Cut</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> - <property name="action_name">view.rename</property> + <property name="action_name">view.cut</property> </object> <packing> <property name="expand">True</property> <property name="fill">True</property> - <property name="position">8</property> + <property name="position">3</property> </packing> </child> <child> <object class="GtkButton"> - <property name="label" translatable="yes">Move to Trash</property> + <property name="label" translatable="yes">Rename...</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> - <property name="action_name">view.move-to-trash</property> + <property name="action_name">view.rename</property> </object> <packing> <property name="expand">True</property> <property name="fill">True</property> - <property name="position">10</property> + <property name="position">3</property> </packing> </child> </object> <packing> <property name="expand">True</property> <property name="fill">True</property> - <property name="position">0</property> + <property name="pack_type">end</property> + <property name="position">1</property> </packing> </child> <child> @@ -118,36 +170,13 @@ <property name="width_request">180</property> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="margin_left">25</property> - <child> - <object class="GtkButton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <child> - <object class="GtkImage"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="icon_name">window-close-symbolic</property> - </object> - </child> - <style> - <class name="image-button"/> - <class name="flat"/> - </style> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">end</property> - <property name="position">0</property> - </packing> - </child> + <property name="margin_left">10</property> + <property name="margin_right">24</property> <child> <object class="GtkLabel" id="primary_label"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="margin_right">6</property> + <property name="margin_right">4</property> <property name="label" translatable="yes">org.nautilus.flatpakref</property> <property name="ellipsize">middle</property> <property name="single_line_mode">True</property> @@ -159,24 +188,9 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="pack_type">end</property> - <property name="position">2</property> + <property name="position">0</property> </packing> </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">end</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="margin_left">4</property> - <property name="margin_right">4</property> <child> <object class="GtkButton"> <property name="visible">True</property> @@ -186,24 +200,25 @@ <object class="GtkImage"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="icon_name">view-more-symbolic</property> + <property name="icon_name">window-close-symbolic</property> </object> </child> <style> <class name="image-button"/> + <class name="sidebar-button"/> </style> </object> <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">2</property> + <property name="position">1</property> </packing> </child> </object> <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">3</property> + <property name="position">2</property> </packing> </child> </object> @@ -217,7 +232,8 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="valign">center</property> - <property name="spacing">6</property> + <property name="margin_left">10</property> + <property name="spacing">4</property> <child> <object class="GtkSpinner"> <property name="visible">True</property> @@ -234,6 +250,7 @@ <object class="GtkLabel" id="loading_label"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="margin_left">4</property> <property name="label" translatable="yes">Loading</property> </object> <packing> @@ -257,7 +274,7 @@ </child> <style> <class name="image-button"/> - <class name="flat"/> + <class name="sidebar-button"/> </style> </object> <packing> @@ -281,6 +298,38 @@ <object class="GtkBox"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="margin_left">4</property> + <child> + <object class="GtkButton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">view-more-symbolic</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">end</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> <property name="spacing">4</property> <child> <object class="GtkButton"> @@ -335,46 +384,15 @@ <packing> <property name="expand">True</property> <property name="fill">True</property> - <property name="position">6</property> + <property name="position">4</property> </packing> </child> </object> <packing> <property name="expand">True</property> <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="margin_left">4</property> - <property name="margin_right">4</property> - <child> - <object class="GtkButton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <child> - <object class="GtkImage"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="icon_name">view-more-symbolic</property> - </object> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">2</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">2</property> + <property name="pack_type">end</property> + <property name="position">1</property> </packing> </child> <child> @@ -382,7 +400,7 @@ <property name="width_request">180</property> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="margin_left">25</property> + <property name="margin_left">10</property> <child> <placeholder/> </child> @@ -405,6 +423,11 @@ </packing> </child> </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> </child> </template> </interface> diff --git a/src/resources/ui/nautilus-window.ui b/src/resources/ui/nautilus-window.ui index 52efc2ecc..9dffbdea5 100644 --- a/src/resources/ui/nautilus-window.ui +++ b/src/resources/ui/nautilus-window.ui @@ -16,8 +16,9 @@ </object> </child> <child> - <object class="GtkGrid"> + <object class="GtkBox"> <property name="visible">True</property> + <property name="orientation">vertical</property> <child> <object class="GtkPaned" id="content_paned"> <property name="visible">True</property> @@ -203,6 +204,12 @@ </child> </object> </child> + <child> + <object class="NautilusActionBar" id="action_bar"> + <property name="visible">True</property> + <property name="hexpand">True</property> + </object> + </child> </object> </child> </template> |