Commit bc5c0589 authored by Alexander Schwinn's avatar Alexander Schwinn

mount works, but doc missing

parent 4ab56c2a
......@@ -134,7 +134,8 @@ static void thunar_launcher_open_windows (Thuna
GList *directories);
static void thunar_launcher_poke (ThunarLauncher *launcher,
GAppInfo *application_to_use,
ThunarLauncherFolderOpenAction folder_open_action);
ThunarLauncherFolderOpenAction folder_open_action,
GClosure *operation_finished_closure);
static void thunar_launcher_poke_device_finish (ThunarBrowser *browser,
ThunarDevice *volume,
ThunarFile *mount_point,
......@@ -148,7 +149,8 @@ static void thunar_launcher_poke_files_finish (Thuna
gpointer user_data);
static ThunarLauncherPokeData *thunar_launcher_poke_data_new (GList *files_to_poke,
GAppInfo *application_to_use,
ThunarLauncherFolderOpenAction folder_open_action);
ThunarLauncherFolderOpenAction folder_open_action,
GClosure *operation_finished_closure);
static void thunar_launcher_poke_data_free (ThunarLauncherPokeData *data);
static void thunar_launcher_widget_destroyed (ThunarLauncher *launcher,
GtkWidget *widget);
......@@ -230,6 +232,7 @@ struct _ThunarLauncherPokeData
GList *files_poked;
GAppInfo *application_to_use;
ThunarLauncherFolderOpenAction folder_open_action;
GClosure *operation_finished_closure;
};
static GParamSpec *launcher_props[N_PROPERTIES] = { NULL, };
......@@ -267,9 +270,9 @@ static XfceGtkActionEntry thunar_launcher_action_entries[] =
{ THUNAR_LAUNCHER_ACTION_COPY, "<Actions>/ThunarLauncher/copy", "<Primary>C", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("_Copy"), N_ ("Prepare the selected files to be copied with a Paste command"), "edit-copy", G_CALLBACK (thunar_launcher_action_copy), },
{ THUNAR_LAUNCHER_ACTION_CUT, "<Actions>/ThunarLauncher/cut", "<Primary>X", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("Cu_t"), N_ ("Prepare the selected files to be moved with a Paste command"), "edit-cut", G_CALLBACK (thunar_launcher_action_cut), },
{ THUNAR_LAUNCHER_ACTION_MOUNT, NULL, "", XFCE_GTK_MENU_ITEM, N_ ("_Mount"), N_ ("Test"), NULL, G_CALLBACK (thunar_launcher_action_open), },
{ THUNAR_LAUNCHER_ACTION_UNMOUNT, NULL, "", XFCE_GTK_MENU_ITEM, N_ ("_Unmount"), N_ ("Test"), NULL, G_CALLBACK (thunar_launcher_action_unmount), },
{ THUNAR_LAUNCHER_ACTION_EJECT, NULL, "", XFCE_GTK_MENU_ITEM, N_ ("_Eject"), N_ ("Test"), NULL, G_CALLBACK (thunar_launcher_action_eject), },
{ THUNAR_LAUNCHER_ACTION_MOUNT, NULL, "", XFCE_GTK_MENU_ITEM, N_ ("_Mount"), N_ ("Mount the selected device"), NULL, G_CALLBACK (thunar_launcher_action_open), },
{ THUNAR_LAUNCHER_ACTION_UNMOUNT, NULL, "", XFCE_GTK_MENU_ITEM, N_ ("_Unmount"), N_ ("Unmount the selected device"), NULL, G_CALLBACK (thunar_launcher_action_unmount), },
{ THUNAR_LAUNCHER_ACTION_EJECT, NULL, "", XFCE_GTK_MENU_ITEM, N_ ("_Eject"), N_ ("Eject the selected device"), NULL, G_CALLBACK (thunar_launcher_action_eject), },
};
#define get_action_entry(id) xfce_gtk_get_action_entry_by_id(thunar_launcher_action_entries,G_N_ELEMENTS(thunar_launcher_action_entries),id)
......@@ -677,7 +680,7 @@ thunar_launcher_activate_selected_files (ThunarLauncher *launche
{
_thunar_return_if_fail (THUNAR_IS_LAUNCHER (launcher));
thunar_launcher_poke (launcher, app_info, action);
thunar_launcher_poke (launcher, app_info, action, NULL);
}
......@@ -913,13 +916,14 @@ thunar_launcher_open_windows (ThunarLauncher *launcher,
static void
thunar_launcher_poke (ThunarLauncher *launcher,
GAppInfo *application_to_use,
ThunarLauncherFolderOpenAction folder_open_action)
ThunarLauncherFolderOpenAction folder_open_action,
GClosure *operation_finished_closure)
{
ThunarLauncherPokeData *poke_data;
_thunar_return_if_fail (THUNAR_IS_LAUNCHER (launcher));
poke_data = thunar_launcher_poke_data_new (launcher->files_to_process, application_to_use, folder_open_action);
poke_data = thunar_launcher_poke_data_new (launcher->files_to_process, application_to_use, folder_open_action, operation_finished_closure);
if (launcher->device_to_process != NULL)
{
......@@ -948,6 +952,7 @@ static void thunar_launcher_poke_device_finish (ThunarBrowser *browser,
{
ThunarLauncherPokeData *poke_data = user_data;
gchar *device_name;
GValue dummy[1] = { { 0, }};
if (error != NULL)
{
......@@ -978,6 +983,13 @@ static void thunar_launcher_poke_device_finish (ThunarBrowser *browser,
thunar_navigator_change_directory (THUNAR_NAVIGATOR (browser), mount_point);
}
/* Some dummy item to make gtk happy */
g_value_init (&dummy[0], G_TYPE_POINTER);
g_value_set_pointer (&dummy[0], NULL);
g_closure_set_marshal (poke_data->operation_finished_closure, g_cclosure_marshal_VOID__VOID);
g_closure_invoke (poke_data->operation_finished_closure, NULL, 1, dummy, NULL);
thunar_launcher_poke_data_free (poke_data);
}
......@@ -1110,7 +1122,8 @@ thunar_launcher_poke_files_finish (ThunarBrowser *browser,
static ThunarLauncherPokeData *
thunar_launcher_poke_data_new (GList *files_to_poke,
GAppInfo *application_to_use,
ThunarLauncherFolderOpenAction folder_open_action)
ThunarLauncherFolderOpenAction folder_open_action,
GClosure *operation_finished_closure)
{
ThunarLauncherPokeData *data;
......@@ -1119,6 +1132,11 @@ thunar_launcher_poke_data_new (GList *files_to_poke,
data->files_poked = NULL;
data->application_to_use = application_to_use;
/* keep a reference on the closure */
if (operation_finished_closure != NULL)
g_closure_ref (operation_finished_closure);
data->operation_finished_closure = operation_finished_closure;
/* keep a reference on the appdata */
if (application_to_use != NULL)
g_object_ref (application_to_use);
......@@ -1139,6 +1157,8 @@ thunar_launcher_poke_data_free (ThunarLauncherPokeData *data)
if (data->application_to_use != NULL)
g_object_unref (data->application_to_use);
if (data->operation_finished_closure != NULL)
g_closure_unref (data->operation_finished_closure);
g_slice_free (ThunarLauncherPokeData, data);
}
......@@ -1176,9 +1196,9 @@ void thunar_launcher_open_selected_folders (ThunarLauncher *launcher,
_thunar_return_if_fail (thunar_file_is_directory (THUNAR_FILE (lp->data)));
if (open_in_tabs)
thunar_launcher_poke (launcher, NULL, THUNAR_LAUNCHER_OPEN_AS_NEW_TAB);
thunar_launcher_poke (launcher, NULL, THUNAR_LAUNCHER_OPEN_AS_NEW_TAB, NULL);
else
thunar_launcher_poke (launcher, NULL, THUNAR_LAUNCHER_OPEN_AS_NEW_WINDOW);
thunar_launcher_poke (launcher, NULL, THUNAR_LAUNCHER_OPEN_AS_NEW_WINDOW, NULL);
}
......@@ -2605,6 +2625,21 @@ thunar_launcher_action_paste_into_folder (ThunarLauncher *launcher)
}
/**
* thunar_launcher_action_mount:
* @launcher : a #ThunarLauncher instance
* @operation_finished_closure : A closure to be executed when the mount operation is finished
*
* Will open each selected folder in a new tab/window
**/
void
thunar_launcher_action_mount (ThunarLauncher *launcher,
GClosure *closure)
{
thunar_launcher_poke (launcher, NULL,THUNAR_LAUNCHER_NO_ACTION, closure);
}
static void
thunar_launcher_action_eject_finish (ThunarDevice *device,
......@@ -2707,6 +2742,9 @@ thunar_launcher_action_unmount (ThunarLauncher *launcher)
static GtkWidget*
thunar_launcher_build_application_submenu (ThunarLauncher *launcher,
GList *applications)
......
......@@ -70,7 +70,8 @@ typedef enum
{
THUNAR_LAUNCHER_CHANGE_DIRECTORY,
THUNAR_LAUNCHER_OPEN_AS_NEW_TAB,
THUNAR_LAUNCHER_OPEN_AS_NEW_WINDOW
THUNAR_LAUNCHER_OPEN_AS_NEW_WINDOW,
THUNAR_LAUNCHER_NO_ACTION,
} ThunarLauncherFolderOpenAction;
GType thunar_launcher_get_type (void) G_GNUC_CONST;
......@@ -97,8 +98,11 @@ gboolean thunar_launcher_append_custom_actions (ThunarLaun
GtkMenuShell *menu);
gboolean thunar_launcher_check_uca_key_activation (ThunarLauncher *launcher,
GdkEventKey *key_event);
void thunar_launcher_action_eject (ThunarLauncher *launcher);
void thunar_launcher_action_mount (ThunarLauncher *launcher,
GClosure *operation_finished_closure);
void thunar_launcher_action_unmount (ThunarLauncher *launcher);
void thunar_launcher_action_eject (ThunarLauncher *launcher);
G_END_DECLS;
......
......@@ -164,6 +164,7 @@ static void thunar_tree_view_set_show_hidden (T
gboolean show_hidden);
static GtkTreePath *thunar_tree_view_get_preferred_toplevel_path (ThunarTreeView *view,
ThunarFile *file);
static void thunar_tree_view_mount_finished (ThunarTreeView *view);
......@@ -194,6 +195,9 @@ struct _ThunarTreeView
guint drop_occurred : 1;
GList *drop_file_list; /* the list of URIs that are contained in the drop data */
/* Can be used to react on a finished mount operation */
GClosure *mount_finished_closure;
/* the "new-files" closure, which is used to
* open newly created directories once done.
*/
......@@ -407,6 +411,9 @@ thunar_tree_view_init (ThunarTreeView *view)
gtk_drag_dest_set (GTK_WIDGET (view), 0, drop_targets, G_N_ELEMENTS (drop_targets),
GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_MOVE);
view->mount_finished_closure = g_cclosure_new_swap (G_CALLBACK (thunar_tree_view_mount_finished), view, NULL);
g_closure_ref (view->mount_finished_closure);
g_closure_sink (view->mount_finished_closure);
view->new_files_closure = g_cclosure_new_swap (G_CALLBACK (thunar_tree_view_select_files), view, NULL);
g_closure_ref (view->new_files_closure);
g_closure_sink (view->new_files_closure);
......@@ -466,6 +473,13 @@ thunar_tree_view_finalize (GObject *object)
g_closure_unref (view->new_files_closure);
}
/* drop any existing "new-files" closure */
if (G_UNLIKELY (view->mount_finished_closure != NULL))
{
g_closure_invalidate (view->mount_finished_closure);
g_closure_unref (view->mount_finished_closure);
}
(*G_OBJECT_CLASS (thunar_tree_view_parent_class)->finalize) (object);
}
......@@ -797,6 +811,17 @@ thunar_tree_view_button_release_event (GtkWidget *widget,
static void thunar_tree_view_mount_finished (ThunarTreeView *view)
{
GtkTreePath *path;
/* Get path of currently highlighted item and expnad its row */
gtk_tree_view_get_cursor(GTK_TREE_VIEW (view), &path, NULL);
gtk_tree_view_expand_row (GTK_TREE_VIEW (view), path, FALSE);
}
static gboolean
thunar_tree_view_key_press_event(GtkWidget *widget,
GdkEventKey *event)
......@@ -864,17 +889,28 @@ thunar_tree_view_key_press_event(GtkWidget *widget,
case GDK_KEY_Right:
case GDK_KEY_KP_Right:
/* if branch is not expanded then expand it */
if (!gtk_tree_view_row_expanded (GTK_TREE_VIEW (view), path))
gtk_tree_view_expand_row (GTK_TREE_VIEW (view), path, FALSE);
else /* if branch is already expanded then move to first child */
{
gtk_tree_path_down (path);
gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), path, NULL, FALSE);
thunar_tree_view_action_open (view);
gtk_tree_view_expand_row (GTK_TREE_VIEW (view), path, FALSE);
}
/* if this is a toplevel item and a mountable device, mount it */
if (gtk_tree_model_get_iter (GTK_TREE_MODEL (view->model), &iter, path))
gtk_tree_model_get (GTK_TREE_MODEL (view->model), &iter,
THUNAR_TREE_MODEL_COLUMN_DEVICE, &device, -1);
if (device != NULL && thunar_device_is_mounted (device) == FALSE)
{
g_object_set (G_OBJECT (view->launcher), "selected-device", device, NULL);
g_object_set (G_OBJECT (view->launcher), "selected-files", NULL, "current-directory", NULL, NULL);
thunar_launcher_action_mount (view->launcher, view->mount_finished_closure);
}
else
{
/* if branch is not expanded then expand it */
if (!gtk_tree_view_row_expanded (GTK_TREE_VIEW (view), path))
gtk_tree_view_expand_row (GTK_TREE_VIEW (view), path, FALSE);
else /* if branch is already expanded then move to first child */
{
gtk_tree_path_down (path);
gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), path, NULL, FALSE);
thunar_tree_view_action_open (view);
}
}
stopPropagation = TRUE;
break;
......@@ -1137,10 +1173,15 @@ thunar_tree_view_test_expand_row (GtkTreeView *tree_view,
/* check if we have a device */
if (G_UNLIKELY (device != NULL))
{
thunar_tree_view_action_open (THUNAR_TREE_VIEW (tree_view));
/* check if we need to mount the device first */
if (!thunar_device_is_mounted (device))
{
/* we need to mount the device before we can expand the row */
expandable = FALSE;
/* we need to mount the device before we can expand the row */
expandable = FALSE;
/* The closure will expand the row after the mount operation finished */
thunar_launcher_action_mount (view->launcher, view->mount_finished_closure);
}
/* release the device */
g_object_unref (G_OBJECT (device));
......@@ -1455,8 +1496,6 @@ thunar_tree_view_action_open (ThunarTreeView *view)
{
ThunarFile *file;
ThunarDevice *device;
GList *files = NULL;
gboolean file_is_available;
device = thunar_tree_view_get_selected_device (view);
file = thunar_tree_view_get_selected_file (view);
......@@ -1468,9 +1507,9 @@ thunar_tree_view_action_open (ThunarTreeView *view)
else
{
g_object_set (G_OBJECT (view->launcher), "selected-device", device, NULL);
g_object_set (G_OBJECT (view->launcher), "selected-files", NULL, "current-directory", NULL, NULL);
thunar_launcher_activate_selected_files (view->launcher, THUNAR_LAUNCHER_CHANGE_DIRECTORY, NULL);
}
g_object_set (G_OBJECT (view->launcher), "selected-files", NULL, "current-directory", NULL, NULL);
thunar_launcher_action_mount (view->launcher, view->mount_finished_closure);
}
}
else if (file != NULL)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment