mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-06-30 23:46:35 +00:00
window-slot: Handle file activation on FileChooser
The view handles activation through mime-actions.c functions, which allow, among other things, opening files in other apps. We don't want that in the FileChooser modes. Opening folders is okay, but what we want to do when double-clicking a file depends on the exact mode and the filters that apply. Prepare to handle activation at a higher lever: the expected action will be implemented by the upcoming NautilusFileChooser, by handling the new NautilusWindowSlot::activate-files signal.
This commit is contained in:
parent
210a260fc9
commit
f5a5ae9511
|
@ -1311,7 +1311,13 @@ nautilus_files_view_activate_files (NautilusFilesView *view,
|
|||
NautilusOpenFlags flags,
|
||||
gboolean confirm_multiple)
|
||||
{
|
||||
NautilusFilesViewPrivate *priv;
|
||||
NautilusFilesViewPrivate *priv = nautilus_files_view_get_instance_private (view);
|
||||
|
||||
if (nautilus_window_slot_handle_activate_files (priv->slot, files))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GList *files_to_extract;
|
||||
GList *files_to_activate;
|
||||
char *path;
|
||||
|
@ -1321,8 +1327,6 @@ nautilus_files_view_activate_files (NautilusFilesView *view,
|
|||
return;
|
||||
}
|
||||
|
||||
priv = nautilus_files_view_get_instance_private (view);
|
||||
|
||||
files_to_extract = nautilus_file_list_filter (files,
|
||||
&files_to_activate,
|
||||
(NautilusFileFilterFunc) nautilus_mime_file_extracts,
|
||||
|
|
|
@ -67,6 +67,16 @@ enum
|
|||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
static GParamSpec *properties[NUM_PROPERTIES];
|
||||
|
||||
enum
|
||||
{
|
||||
SIGNAL_ACTIVATE_FILES,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static guint signals[LAST_SIGNAL];
|
||||
|
||||
struct _NautilusWindowSlot
|
||||
{
|
||||
AdwBin parent_instance;
|
||||
|
@ -150,8 +160,6 @@ struct _NautilusWindowSlot
|
|||
|
||||
G_DEFINE_TYPE (NautilusWindowSlot, nautilus_window_slot, ADW_TYPE_BIN);
|
||||
|
||||
static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
|
||||
|
||||
static const GtkPadActionEntry pad_actions[] =
|
||||
{
|
||||
{ GTK_PAD_ACTION_BUTTON, 3, -1, N_("Parent folder"), "up" },
|
||||
|
@ -567,6 +575,27 @@ nautilus_window_slot_search (NautilusWindowSlot *self,
|
|||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_window_slot_handle_activate_files (NautilusWindowSlot *self,
|
||||
GList *files)
|
||||
{
|
||||
if (self->mode == NAUTILUS_MODE_BROWSE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (files != NULL && files->next == NULL &&
|
||||
nautilus_file_opens_in_view (NAUTILUS_FILE (files->data)))
|
||||
{
|
||||
/* Single folder or folder-like item is always handled by the view. */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_signal_emit (self, signals[SIGNAL_ACTIVATE_FILES], 0, files);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_window_slot_handle_event (NautilusWindowSlot *self,
|
||||
GtkEventControllerKey *controller,
|
||||
|
@ -2997,6 +3026,12 @@ nautilus_window_slot_class_init (NautilusWindowSlotClass *klass)
|
|||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (oclass, NUM_PROPERTIES, properties);
|
||||
|
||||
signals[SIGNAL_ACTIVATE_FILES] = g_signal_new ("activate-files",
|
||||
G_TYPE_FROM_CLASS (oclass),
|
||||
G_SIGNAL_RUN_LAST, 0, NULL, NULL,
|
||||
g_cclosure_marshal_VOID__POINTER,
|
||||
G_TYPE_NONE, 1, G_TYPE_POINTER);
|
||||
}
|
||||
|
||||
GFile *
|
||||
|
|
|
@ -71,6 +71,8 @@ void nautilus_window_slot_stop_loading (NautilusWindowSlot *
|
|||
const gchar *nautilus_window_slot_get_title (NautilusWindowSlot *slot);
|
||||
void nautilus_window_slot_update_title (NautilusWindowSlot *slot);
|
||||
|
||||
gboolean nautilus_window_slot_handle_activate_files (NautilusWindowSlot *slot,
|
||||
GList *files);
|
||||
gboolean nautilus_window_slot_handle_event (NautilusWindowSlot *slot,
|
||||
GtkEventControllerKey *controller,
|
||||
guint keyval,
|
||||
|
|
Loading…
Reference in New Issue
Block a user