static void nautilus_toolbar_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { NautilusToolbar *self = NAUTILUS_TOOLBAR (object); switch (property_id) { case PROP_ACTION_GROUP: self->priv->action_group = g_value_dup_object (value); break; case PROP_SHOW_LOCATION_ENTRY: nautilus_toolbar_set_show_location_entry (self, g_value_get_boolean (value)); break; case PROP_SHOW_SEARCH_BAR: nautilus_toolbar_set_show_search_bar (self, g_value_get_boolean (value)); break; case PROP_SHOW_MAIN_BAR: nautilus_toolbar_set_show_main_bar (self, g_value_get_boolean (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }
static void nautilus_toolbar_constructed (GObject *obj) { NautilusToolbar *self = NAUTILUS_TOOLBAR (obj); GtkToolItem *item; GtkWidget *hbox, *toolbar, *search; GtkStyleContext *context; const gchar *ui; G_OBJECT_CLASS (nautilus_toolbar_parent_class)->constructed (obj); gtk_style_context_set_junction_sides (gtk_widget_get_style_context (GTK_WIDGET (self)), GTK_JUNCTION_BOTTOM); /* add the UI */ ui = nautilus_ui_string_get ("nautilus-toolbar-ui.xml"); self->priv->ui_manager = gtk_ui_manager_new (); gtk_ui_manager_add_ui_from_string (self->priv->ui_manager, ui, -1, NULL); gtk_ui_manager_insert_action_group (self->priv->ui_manager, self->priv->action_group, 0); toolbar = gtk_ui_manager_get_widget (self->priv->ui_manager, "/Toolbar"); self->priv->toolbar = toolbar; context = gtk_widget_get_style_context (toolbar); gtk_style_context_add_class (context, GTK_STYLE_CLASS_PRIMARY_TOOLBAR); search = gtk_ui_manager_get_widget (self->priv->ui_manager, "/Toolbar/Search"); gtk_style_context_add_class (gtk_widget_get_style_context (search), GTK_STYLE_CLASS_RAISED); gtk_box_pack_start (GTK_BOX (self), self->priv->toolbar, TRUE, TRUE, 0); gtk_widget_show_all (self->priv->toolbar); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_widget_show (hbox); /* regular path bar */ self->priv->path_bar = g_object_new (NAUTILUS_TYPE_PATH_BAR, NULL); gtk_box_pack_start (GTK_BOX (hbox), self->priv->path_bar, TRUE, TRUE, 0); /* entry-like location bar */ self->priv->location_bar = nautilus_location_bar_new (); gtk_box_pack_start (GTK_BOX (hbox), self->priv->location_bar, TRUE, TRUE, 0); item = gtk_tool_item_new (); gtk_tool_item_set_expand (item, TRUE); gtk_container_add (GTK_CONTAINER (item), hbox); gtk_toolbar_insert (GTK_TOOLBAR (self->priv->toolbar), item, 0); gtk_widget_show (GTK_WIDGET (item)); /* search bar */ self->priv->search_bar = nautilus_search_bar_new (); gtk_box_pack_start (GTK_BOX (self), self->priv->search_bar, TRUE, TRUE, 0); g_signal_connect_swapped (nautilus_preferences, "changed::" NAUTILUS_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY, G_CALLBACK (toolbar_update_appearance), self); toolbar_update_appearance (self); }
static void nautilus_toolbar_dispose (GObject *obj) { NautilusToolbar *self = NAUTILUS_TOOLBAR (obj); g_clear_object (&self->priv->ui_manager); g_clear_object (&self->priv->action_group); G_OBJECT_CLASS (nautilus_toolbar_parent_class)->dispose (obj); }
static void nautilus_toolbar_dispose (GObject *obj) { NautilusToolbar *self = NAUTILUS_TOOLBAR (obj); g_signal_handlers_disconnect_by_func (nautilus_preferences, toolbar_update_appearance, self); unschedule_menu_popup_timeout (self); G_OBJECT_CLASS (nautilus_toolbar_parent_class)->dispose (obj); }
static void nautilus_toolbar_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { NautilusToolbar *self = NAUTILUS_TOOLBAR (object); switch (property_id) { case PROP_SHOW_LOCATION_ENTRY: g_value_set_boolean (value, self->priv->show_location_entry); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }
static void nautilus_toolbar_finalize (GObject *obj) { NautilusToolbar *self = NAUTILUS_TOOLBAR (obj); g_signal_handlers_disconnect_by_func (nautilus_preferences, toolbar_update_appearance, self); disconnect_progress_infos (self); unschedule_menu_popup_timeout (self); unschedule_remove_finished_operations (self); unschedule_operations_start (self); unschedule_operations_button_attention_style (self); g_signal_handlers_disconnect_by_data (self->priv->progress_manager, self); g_clear_object (&self->priv->progress_manager); G_OBJECT_CLASS (nautilus_toolbar_parent_class)->finalize (obj); }
static gboolean nautilus_toolbar_view_widget_transform_to (GBinding *binding, const GValue *from_value, GValue *to_value, gpointer user_data) { NautilusToolbar *toolbar; GtkWidget *view_widget; toolbar = NAUTILUS_TOOLBAR (user_data); view_widget = g_value_get_object (from_value); gtk_widget_set_sensitive (toolbar->priv->view_button, view_widget != NULL); gtk_menu_button_set_popover (GTK_MENU_BUTTON (toolbar->priv->view_button), NULL); g_value_set_object (to_value, view_widget); return TRUE; }
static void nautilus_toolbar_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { NautilusToolbar *self = NAUTILUS_TOOLBAR (object); switch (property_id) { case PROP_WINDOW: nautilus_toolbar_set_window (self, g_value_get_object (value)); break; case PROP_SHOW_LOCATION_ENTRY: nautilus_toolbar_set_show_location_entry (self, g_value_get_boolean (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }
static void nautilus_toolbar_constructed (GObject *obj) { NautilusToolbar *self = NAUTILUS_TOOLBAR (obj); GtkWidget *toolbar; GtkWidget *button; GtkWidget *menu; GtkWidget *box; GtkWidget *separator; GtkUIManager *ui_manager; gboolean rtl; G_OBJECT_CLASS (nautilus_toolbar_parent_class)->constructed (obj); gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (self)), "header-bar"); self->priv->toolbar = toolbar = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); g_object_set (toolbar, "margin", 8, NULL); gtk_container_add (GTK_CONTAINER (self), toolbar); rtl = gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL; ui_manager = nautilus_window_get_ui_manager (self->priv->window); gtk_style_context_set_junction_sides (gtk_widget_get_style_context (GTK_WIDGET (self)), GTK_JUNCTION_BOTTOM); /* Back and Forward */ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); /* Back */ button = toolbar_create_toolbutton (self, FALSE, FALSE, NAUTILUS_ACTION_BACK, NULL); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); gtk_action_set_icon_name (gtk_activatable_get_related_action (GTK_ACTIVATABLE (button)), rtl ? "go-previous-rtl-symbolic" : "go-previous-symbolic"); navigation_button_setup_menu (self, button, NAUTILUS_NAVIGATION_DIRECTION_BACK); gtk_container_add (GTK_CONTAINER (box), button); /* Forward */ button = toolbar_create_toolbutton (self, FALSE, FALSE, NAUTILUS_ACTION_FORWARD, NULL); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); gtk_action_set_icon_name (gtk_activatable_get_related_action (GTK_ACTIVATABLE (button)), rtl ? "go-next-rtl-symbolic" : "go-next-symbolic"); navigation_button_setup_menu (self, button, NAUTILUS_NAVIGATION_DIRECTION_FORWARD); gtk_container_add (GTK_CONTAINER (box), button); gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_RAISED); gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_LINKED); gtk_box_pack_start (GTK_BOX (toolbar), box, FALSE, FALSE, 0); if (rtl) { gtk_widget_set_margin_left (box, 12); } else { gtk_widget_set_margin_right (box, 12); } /* regular path bar */ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); self->priv->path_bar = g_object_new (NAUTILUS_TYPE_PATH_BAR, NULL); gtk_box_pack_start (GTK_BOX (box), self->priv->path_bar, TRUE, TRUE, 0); /* entry-like location bar */ self->priv->location_entry = nautilus_location_entry_new (); gtk_box_pack_start (GTK_BOX (box), self->priv->location_entry, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (toolbar), box, TRUE, TRUE, 0); /* search */ button = toolbar_create_toolbutton (self, FALSE, TRUE, NAUTILUS_ACTION_SEARCH, NULL); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); gtk_container_add (GTK_CONTAINER (toolbar), button); if (rtl) { gtk_widget_set_margin_right (button, 76); } else { gtk_widget_set_margin_left (button, 76); } /* View buttons */ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); button = toolbar_create_toolbutton (self, FALSE, TRUE, NAUTILUS_ACTION_VIEW_LIST, NULL); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); gtk_container_add (GTK_CONTAINER (box), button); button = toolbar_create_toolbutton (self, FALSE, TRUE, NAUTILUS_ACTION_VIEW_GRID, NULL); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); gtk_container_add (GTK_CONTAINER (box), button); button = toolbar_create_toolbutton (self, TRUE, FALSE, "go-down-symbolic", _("View options")); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); gtk_container_add (GTK_CONTAINER (box), button); menu = gtk_ui_manager_get_widget (ui_manager, "/ViewMenu"); gtk_menu_button_set_popup (GTK_MENU_BUTTON (button), menu); gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_RAISED); gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_LINKED); gtk_container_add (GTK_CONTAINER (toolbar), box); if (rtl) { gtk_widget_set_margin_right (box, 12); } else { gtk_widget_set_margin_left (box, 12); } /* Action Menu */ button = toolbar_create_toolbutton (self, TRUE, FALSE, "emblem-system-symbolic", _("Location options")); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); menu = gtk_ui_manager_get_widget (ui_manager, "/ActionMenu"); gtk_widget_set_halign (menu, GTK_ALIGN_END); gtk_menu_button_set_popup (GTK_MENU_BUTTON (button), menu); gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "win.gear-menu"); g_signal_connect (menu, "key-press-event", G_CALLBACK (gear_menu_key_press), self); gtk_container_add (GTK_CONTAINER (toolbar), button); if (rtl) { gtk_widget_set_margin_right (button, 12); } else { gtk_widget_set_margin_left (button, 12); } /* Separator and Close */ separator = gtk_separator_new (GTK_ORIENTATION_VERTICAL); gtk_container_add (GTK_CONTAINER (toolbar), separator); if (rtl) { gtk_widget_set_margin_right (separator, 8); } else { gtk_widget_set_margin_left (separator, 8); } button = gtk_button_new_from_icon_name ("window-close-symbolic", GTK_ICON_SIZE_MENU); gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); g_signal_connect (button, "clicked", G_CALLBACK (close_button_clicked), self); gtk_container_add (GTK_CONTAINER (toolbar), button); if (rtl) { gtk_widget_set_margin_right (button, 6); } else { gtk_widget_set_margin_left (button, 6); } g_signal_connect_swapped (nautilus_preferences, "changed::" NAUTILUS_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY, G_CALLBACK (toolbar_update_appearance), self); gtk_widget_show_all (toolbar); toolbar_update_appearance (self); }