mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-09-29 20:44:17 +00:00
toolbar: Handle location entry signals
There is no need for the window itself to do it. This will ensure they are handled the same way in the upcoming FileChooser window. Also fix signal parameter type to reflect the assumed object type. Part of: https://gitlab.gnome.org/GNOME/nautilus/-/work_items/3431
This commit is contained in:
parent
911e366ca9
commit
c908c94108
|
@ -676,7 +676,7 @@ nautilus_location_entry_class_init (NautilusLocationEntryClass *class)
|
|||
G_SIGNAL_RUN_LAST, 0,
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_generic,
|
||||
G_TYPE_NONE, 1, G_TYPE_OBJECT);
|
||||
G_TYPE_NONE, 1, G_TYPE_FILE);
|
||||
|
||||
shortcut = gtk_shortcut_new (gtk_keyval_trigger_new (GDK_KEY_Escape, 0),
|
||||
gtk_signal_action_new ("cancel"));
|
||||
|
|
|
@ -131,7 +131,7 @@ nautilus_toolbar_open_location_entry (NautilusToolbar *self)
|
|||
gtk_widget_grab_focus (self->location_entry);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
nautilus_toolbar_close_location_entry (NautilusToolbar *self)
|
||||
{
|
||||
if (!self->show_location_entry)
|
||||
|
@ -178,6 +178,17 @@ on_location_entry_focus_leave (GtkEventControllerFocus *controller,
|
|||
nautilus_toolbar_close_location_entry (toolbar);
|
||||
}
|
||||
|
||||
static void
|
||||
on_location_entry_location_changed (NautilusLocationEntry *entry,
|
||||
GFile *location,
|
||||
gpointer user_data)
|
||||
{
|
||||
NautilusToolbar *self = NAUTILUS_TOOLBAR (user_data);
|
||||
|
||||
nautilus_toolbar_close_location_entry (self);
|
||||
nautilus_window_slot_open_location_full (self->window_slot, location, 0, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
nautilus_toolbar_init (NautilusToolbar *self)
|
||||
{
|
||||
|
@ -197,6 +208,12 @@ nautilus_toolbar_init (NautilusToolbar *self)
|
|||
/* Setting a max width on one entry to effectively set a max expansion for
|
||||
* the whole title widget. */
|
||||
gtk_editable_set_max_width_chars (GTK_EDITABLE (self->location_entry), 88);
|
||||
g_signal_connect_object (self->location_entry, "location-changed",
|
||||
G_CALLBACK (on_location_entry_location_changed), self,
|
||||
G_CONNECT_DEFAULT);
|
||||
g_signal_connect_object (self->location_entry, "cancel",
|
||||
G_CALLBACK (nautilus_toolbar_close_location_entry), self,
|
||||
G_CONNECT_SWAPPED);
|
||||
|
||||
toolbar_update_appearance (self);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ GtkWidget *nautilus_toolbar_get_path_bar (NautilusToolbar *self);
|
|||
GtkWidget *nautilus_toolbar_get_location_entry (NautilusToolbar *self);
|
||||
|
||||
void nautilus_toolbar_open_location_entry (NautilusToolbar *self);
|
||||
void nautilus_toolbar_close_location_entry (NautilusToolbar *self);
|
||||
|
||||
void nautilus_toolbar_set_active_slot (NautilusToolbar *toolbar,
|
||||
NautilusWindowSlot *slot);
|
||||
|
|
|
@ -643,23 +643,6 @@ nautilus_window_grab_focus (GtkWidget *widget)
|
|||
return GTK_WIDGET_CLASS (nautilus_window_parent_class)->grab_focus (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
location_entry_cancel_callback (GtkWidget *widget,
|
||||
NautilusWindow *window)
|
||||
{
|
||||
nautilus_toolbar_close_location_entry (NAUTILUS_TOOLBAR (window->toolbar));
|
||||
}
|
||||
|
||||
static void
|
||||
location_entry_location_changed_callback (GtkWidget *widget,
|
||||
GFile *location,
|
||||
NautilusWindow *window)
|
||||
{
|
||||
nautilus_toolbar_close_location_entry (NAUTILUS_TOOLBAR (window->toolbar));
|
||||
|
||||
nautilus_window_open_location_full (window, location, 0, NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
remove_slot_from_window (NautilusWindowSlot *slot,
|
||||
NautilusWindow *window)
|
||||
|
@ -1289,21 +1272,12 @@ static void
|
|||
setup_toolbar (NautilusWindow *window)
|
||||
{
|
||||
GtkWidget *path_bar;
|
||||
GtkWidget *location_entry;
|
||||
|
||||
/* connect to the pathbar signals */
|
||||
path_bar = nautilus_toolbar_get_path_bar (NAUTILUS_TOOLBAR (window->toolbar));
|
||||
|
||||
g_signal_connect_swapped (path_bar, "open-location",
|
||||
G_CALLBACK (on_path_bar_open_location), window);
|
||||
|
||||
/* connect to the location entry signals */
|
||||
location_entry = nautilus_toolbar_get_location_entry (NAUTILUS_TOOLBAR (window->toolbar));
|
||||
|
||||
g_signal_connect_object (location_entry, "location-changed",
|
||||
G_CALLBACK (location_entry_location_changed_callback), window, 0);
|
||||
g_signal_connect_object (location_entry, "cancel",
|
||||
G_CALLBACK (location_entry_cancel_callback), window, 0);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
Loading…
Reference in a new issue