Updating branch refs/heads/master to 65dd2ddba44e7bf809fc0bbacb63bd6eb4d24d99 (commit) from a5ba2d88a8534cfc0173ab10f3ad5a777ee92f0f (commit)
commit 65dd2ddba44e7bf809fc0bbacb63bd6eb4d24d99 Author: Nick Schermer <n...@xfce.org> Date: Fri Dec 7 20:42:49 2012 +0100 Session save mount operation passwords. Also centralize the code. thunar/thunar-browser.c | 25 +++---------------- thunar/thunar-gtk-extensions.c | 23 ++++++++++++++++++ thunar/thunar-gtk-extensions.h | 50 ++++++++++++++++++++------------------- thunar/thunar-launcher.c | 6 +---- thunar/thunar-shortcuts-view.c | 8 +---- thunar/thunar-tree-view.c | 16 +++--------- 6 files changed, 60 insertions(+), 68 deletions(-) diff --git a/thunar/thunar-browser.c b/thunar/thunar-browser.c index 9813936..a6e5b80 100644 --- a/thunar/thunar-browser.c +++ b/thunar/thunar-browser.c @@ -28,6 +28,7 @@ #include <thunar/thunar-file.h> #include <thunar/thunar-private.h> #include <thunar/thunar-util.h> +#include <thunar/thunar-gtk-extensions.h> @@ -187,24 +188,6 @@ thunar_browser_poke_device_data_free (PokeDeviceData *poke_data) -static GMountOperation * -thunar_browser_mount_operation_new (gpointer parent) -{ - GMountOperation *mount_operation; - GtkWindow *window = NULL; - GdkScreen *screen = NULL; - - mount_operation = gtk_mount_operation_new (NULL); - - screen = thunar_util_parse_parent (parent, &window); - gtk_mount_operation_set_screen (GTK_MOUNT_OPERATION (mount_operation), screen); - gtk_mount_operation_set_parent (GTK_MOUNT_OPERATION (mount_operation), window); - - return mount_operation; -} - - - static void thunar_browser_poke_mountable_file_finish (GFile *location, ThunarFile *file, @@ -473,7 +456,7 @@ thunar_browser_poke_file_internal (ThunarBrowser *browser, poke_data = thunar_browser_poke_file_data_new (browser, location, source, file, func, location_func, user_data); - mount_operation = thunar_browser_mount_operation_new (widget); + mount_operation = thunar_gtk_mount_operation_new (widget); g_file_mount_mountable (thunar_file_get_file (file), G_MOUNT_MOUNT_NONE, mount_operation, NULL, @@ -488,7 +471,7 @@ thunar_browser_poke_file_internal (ThunarBrowser *browser, poke_data = thunar_browser_poke_file_data_new (browser, location, source, file, func, location_func, user_data); - mount_operation = thunar_browser_mount_operation_new (widget); + mount_operation = thunar_gtk_mount_operation_new (widget); g_file_mount_enclosing_volume (thunar_file_get_file (file), G_MOUNT_MOUNT_NONE, mount_operation, NULL, @@ -659,7 +642,7 @@ thunar_browser_poke_device (ThunarBrowser *browser, { poke_data = thunar_browser_poke_device_data_new (browser, device, func, user_data); - mount_operation = thunar_browser_mount_operation_new (widget); + mount_operation = thunar_gtk_mount_operation_new (widget); thunar_device_mount (device, mount_operation, diff --git a/thunar/thunar-gtk-extensions.c b/thunar/thunar-gtk-extensions.c index 0b4232c..1938a95 100644 --- a/thunar/thunar-gtk-extensions.c +++ b/thunar/thunar-gtk-extensions.c @@ -29,6 +29,7 @@ #include <thunar/thunar-gtk-extensions.h> #include <thunar/thunar-private.h> +#include <thunar/thunar-util.h> @@ -248,3 +249,25 @@ thunar_gtk_widget_set_tooltip (GtkWidget *widget, +/** + * thunar_gtk_mount_operation_new: + * @parent : a #GtkWindow or non-toplevel widget. + * + * Create a mount operation with some defaults. + **/ +GMountOperation * +thunar_gtk_mount_operation_new (gpointer parent) +{ + GMountOperation *operation; + GdkScreen *screen; + GtkWindow *window = NULL; + + screen = thunar_util_parse_parent (parent, &window); + + operation = gtk_mount_operation_new (window); + g_mount_operation_set_password_save (G_MOUNT_OPERATION (operation), G_PASSWORD_SAVE_FOR_SESSION); + if (window == NULL && screen != NULL) + gtk_mount_operation_set_screen (GTK_MOUNT_OPERATION (operation), screen); + + return operation; +} diff --git a/thunar/thunar-gtk-extensions.h b/thunar/thunar-gtk-extensions.h index 276394d..881fe0c 100644 --- a/thunar/thunar-gtk-extensions.h +++ b/thunar/thunar-gtk-extensions.h @@ -24,30 +24,32 @@ G_BEGIN_DECLS; -void thunar_gtk_action_set_tooltip (GtkAction *action, - const gchar *format, - ...) G_GNUC_PRINTF (2, 3); - -void thunar_gtk_action_group_set_action_sensitive (GtkActionGroup *action_group, - const gchar *action_name, - gboolean sensitive); - -void thunar_gtk_label_set_a11y_relation (GtkLabel *label, - GtkWidget *widget); - -void thunar_gtk_menu_run (GtkMenu *menu, - gpointer parent, - GtkMenuPositionFunc func, - gpointer data, - guint button, - guint32 activate_time); - -GtkAction *thunar_gtk_ui_manager_get_action_by_name (GtkUIManager *ui_manager, - const gchar *action_name); - -void thunar_gtk_widget_set_tooltip (GtkWidget *widget, - const gchar *format, - ...) G_GNUC_PRINTF (2, 3); +void thunar_gtk_action_set_tooltip (GtkAction *action, + const gchar *format, + ...) G_GNUC_PRINTF (2, 3); + +void thunar_gtk_action_group_set_action_sensitive (GtkActionGroup *action_group, + const gchar *action_name, + gboolean sensitive); + +void thunar_gtk_label_set_a11y_relation (GtkLabel *label, + GtkWidget *widget); + +void thunar_gtk_menu_run (GtkMenu *menu, + gpointer parent, + GtkMenuPositionFunc func, + gpointer data, + guint button, + guint32 activate_time); + +GtkAction *thunar_gtk_ui_manager_get_action_by_name (GtkUIManager *ui_manager, + const gchar *action_name); + +void thunar_gtk_widget_set_tooltip (GtkWidget *widget, + const gchar *format, + ...) G_GNUC_PRINTF (2, 3); + +GMountOperation *thunar_gtk_mount_operation_new (gpointer parent); G_END_DECLS; diff --git a/thunar/thunar-launcher.c b/thunar/thunar-launcher.c index f4f192a..700eaf3 100644 --- a/thunar/thunar-launcher.c +++ b/thunar/thunar-launcher.c @@ -1581,7 +1581,6 @@ thunar_launcher_action_sendto_device (GtkAction *action, { ThunarLauncherMountData *data; GMountOperation *mount_operation; - GtkWidget *window; ThunarDevice *device; GList *files; @@ -1601,14 +1600,11 @@ thunar_launcher_action_sendto_device (GtkAction *action, /* make sure to mount the device first, if it's not already mounted */ if (!thunar_device_is_mounted (device)) { - /* determine the toplevel window */ - window = gtk_widget_get_toplevel (launcher->widget); - /* allocate mount data */ data = thunar_launcher_mount_data_new (launcher, files); /* allocate a GTK+ mount operation */ - mount_operation = gtk_mount_operation_new (GTK_WINDOW (window)); + mount_operation = thunar_gtk_mount_operation_new (launcher->widget); /* try to mount the device and later start sending the files */ thunar_device_mount (device, diff --git a/thunar/thunar-shortcuts-view.c b/thunar/thunar-shortcuts-view.c index 1d57020..8e4c60d 100644 --- a/thunar/thunar-shortcuts-view.c +++ b/thunar/thunar-shortcuts-view.c @@ -1863,7 +1863,6 @@ thunar_shortcuts_view_eject (ThunarShortcutsView *view) GtkTreeIter iter; ThunarDevice *device; GMountOperation *mount_operation; - GtkWidget *window; GtkTreeModel *child_model; _thunar_return_if_fail (THUNAR_IS_SHORTCUTS_VIEW (view)); @@ -1877,8 +1876,7 @@ thunar_shortcuts_view_eject (ThunarShortcutsView *view) _thunar_return_if_fail (THUNAR_IS_DEVICE (device)); /* prepare a mount operation */ - window = gtk_widget_get_toplevel (GTK_WIDGET (view)); - mount_operation = gtk_mount_operation_new (GTK_WINDOW (window)); + mount_operation = thunar_gtk_mount_operation_new (GTK_WIDGET (view)); /* start the spinner */ child_model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model)); @@ -2007,7 +2005,6 @@ thunar_shortcuts_view_unmount (ThunarShortcutsView *view) GtkTreeIter iter; ThunarDevice *device; GMountOperation *mount_operation; - GtkWidget *window; GtkTreeModel *child_model; _thunar_return_if_fail (THUNAR_IS_SHORTCUTS_VIEW (view)); @@ -2021,8 +2018,7 @@ thunar_shortcuts_view_unmount (ThunarShortcutsView *view) _thunar_return_if_fail (THUNAR_IS_DEVICE (device)); /* prepare a mount operation */ - window = gtk_widget_get_toplevel (GTK_WIDGET (view)); - mount_operation = gtk_mount_operation_new (GTK_WINDOW (window)); + mount_operation = thunar_gtk_mount_operation_new (GTK_WIDGET (view)); /* start the spinner */ child_model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model)); diff --git a/thunar/thunar-tree-view.c b/thunar/thunar-tree-view.c index 0d87711..1bca480 100644 --- a/thunar/thunar-tree-view.c +++ b/thunar/thunar-tree-view.c @@ -991,7 +991,6 @@ thunar_tree_view_test_expand_row (GtkTreeView *tree_view, ThunarTreeViewMountData *data; GMountOperation *mount_operation; ThunarTreeView *view = THUNAR_TREE_VIEW (tree_view); - GtkWidget *window; gboolean expandable = TRUE; ThunarDevice *device; @@ -1011,8 +1010,7 @@ thunar_tree_view_test_expand_row (GtkTreeView *tree_view, data = thunar_tree_view_mount_data_new (view, path, FALSE, OPEN_IN_VIEW); /* allocate a GTK+ mount operation */ - window = gtk_widget_get_toplevel (GTK_WIDGET (view)); - mount_operation = gtk_mount_operation_new (GTK_WINDOW (window)); + mount_operation = thunar_gtk_mount_operation_new (GTK_WIDGET (view)); /* try to mount the device and expand the row on success. the * data is destroyed in the finish callback */ @@ -1831,7 +1829,6 @@ thunar_tree_view_action_eject (ThunarTreeView *view) { ThunarDevice *device; GMountOperation *mount_operation; - GtkWidget *window; _thunar_return_if_fail (THUNAR_IS_TREE_VIEW (view)); @@ -1840,8 +1837,7 @@ thunar_tree_view_action_eject (ThunarTreeView *view) if (G_LIKELY (device != NULL)) { /* prepare a mount operation */ - window = gtk_widget_get_toplevel (GTK_WIDGET (view)); - mount_operation = gtk_mount_operation_new (GTK_WINDOW (window)); + mount_operation = thunar_gtk_mount_operation_new (GTK_WIDGET (view)); /* eject */ thunar_device_eject (device, @@ -1888,7 +1884,6 @@ thunar_tree_view_action_unmount (ThunarTreeView *view) { ThunarDevice *device; GMountOperation *mount_operation; - GtkWidget *window; _thunar_return_if_fail (THUNAR_IS_TREE_VIEW (view)); @@ -1897,8 +1892,7 @@ thunar_tree_view_action_unmount (ThunarTreeView *view) if (G_LIKELY (device != NULL)) { /* prepare a mount operation */ - window = gtk_widget_get_toplevel (GTK_WIDGET (view)); - mount_operation = gtk_mount_operation_new (GTK_WINDOW (window)); + mount_operation = thunar_gtk_mount_operation_new (GTK_WIDGET (view)); /* eject */ thunar_device_unmount (device, @@ -1993,7 +1987,6 @@ thunar_tree_view_mount (ThunarTreeView *view, { ThunarTreeViewMountData *data; GMountOperation *mount_operation; - GtkWidget *window; ThunarDevice *device; _thunar_return_if_fail (THUNAR_IS_TREE_VIEW (view)); @@ -2009,8 +2002,7 @@ thunar_tree_view_mount (ThunarTreeView *view, data = thunar_tree_view_mount_data_new (view, NULL, open_after_mounting, open_in); /* allocate a GTK+ mount operation */ - window = gtk_widget_get_toplevel (GTK_WIDGET (view)); - mount_operation = gtk_mount_operation_new (GTK_WINDOW (window)); + mount_operation = thunar_gtk_mount_operation_new (GTK_WIDGET (view)); /* try to mount the device and expand the row on success. the * data is destroyed in the finish callback */ _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits