| @@ -16,6 +16,11 @@ | |||||||
|       <summary>File Browser Filter Pattern</summary> |       <summary>File Browser Filter Pattern</summary> | ||||||
|       <description>The filter pattern to filter the file browser with. This filter works on top of the filter_mode.</description> |       <description>The filter pattern to filter the file browser with. This filter works on top of the filter_mode.</description> | ||||||
|     </key> |     </key> | ||||||
|  |     <key name="terminal-command" type="s"> | ||||||
|  |       <default>'x-terminal-emulator'</default> | ||||||
|  |       <summary>Terminal Command</summary> | ||||||
|  |       <description>The terminal command when using the "Open terminal here" command.</description> | ||||||
|  |     </key> | ||||||
|     <child name="on-load" schema="org.x.editor.plugins.filebrowser.on-load"/> |     <child name="on-load" schema="org.x.editor.plugins.filebrowser.on-load"/> | ||||||
|   </schema> |   </schema> | ||||||
|   <schema id="org.x.editor.plugins.filebrowser.on-load" path="/org/x/editor/plugins/filebrowser/on-load/"> |   <schema id="org.x.editor.plugins.filebrowser.on-load" path="/org/x/editor/plugins/filebrowser/on-load/"> | ||||||
|   | |||||||
| @@ -234,23 +234,23 @@ init_special_directories (XedFileBookmarksStore * model) | |||||||
|         g_object_unref (file); |         g_object_unref (file); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     path = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP); |     // path = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP); | ||||||
|     if (path != NULL) |     // if (path != NULL) | ||||||
|     { |     // { | ||||||
|         file = g_file_new_for_path (path); |     //     file = g_file_new_for_path (path); | ||||||
|         add_file (model, file, NULL, XED_FILE_BOOKMARKS_STORE_IS_DESKTOP | |     //     add_file (model, file, NULL, XED_FILE_BOOKMARKS_STORE_IS_DESKTOP | | ||||||
|                                      XED_FILE_BOOKMARKS_STORE_IS_SPECIAL_DIR, NULL); |     //                                  XED_FILE_BOOKMARKS_STORE_IS_SPECIAL_DIR, NULL); | ||||||
|         g_object_unref (file); |     //     g_object_unref (file); | ||||||
|     } |     // } | ||||||
|  |  | ||||||
|     path = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS); |     // path = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS); | ||||||
|     if (path != NULL) |     // if (path != NULL) | ||||||
|     { |     // { | ||||||
|         file = g_file_new_for_path (path); |     //     file = g_file_new_for_path (path); | ||||||
|         add_file (model, file, NULL, XED_FILE_BOOKMARKS_STORE_IS_DOCUMENTS | |     //     add_file (model, file, NULL, XED_FILE_BOOKMARKS_STORE_IS_DOCUMENTS | | ||||||
|                                      XED_FILE_BOOKMARKS_STORE_IS_SPECIAL_DIR, NULL); |     //                                  XED_FILE_BOOKMARKS_STORE_IS_SPECIAL_DIR, NULL); | ||||||
|         g_object_unref (file); |     //     g_object_unref (file); | ||||||
|     } |     // } | ||||||
|  |  | ||||||
|     file = g_file_new_for_uri ("file:///"); |     file = g_file_new_for_uri ("file:///"); | ||||||
|     add_file (model, file, _("File System"), XED_FILE_BOOKMARKS_STORE_IS_ROOT, NULL); |     add_file (model, file, _("File System"), XED_FILE_BOOKMARKS_STORE_IS_ROOT, NULL); | ||||||
| @@ -514,21 +514,37 @@ add_bookmark (XedFileBookmarksStore * model, | |||||||
|     return ret; |     return ret; | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static gchar * | ||||||
| init_bookmarks (XedFileBookmarksStore * model) | get_bookmarks_file (void) | ||||||
|  | { | ||||||
|  |     return g_build_filename (g_get_user_config_dir (), "gtk-3.0", "bookmarks", NULL); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | static gchar * | ||||||
|  | get_legacy_bookmarks_file (void) | ||||||
|  | { | ||||||
|  |     return g_build_filename (g_get_home_dir (), ".gtk-bookmarks", NULL); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | static gboolean | ||||||
|  | parse_bookmarks_file (XedFileBookmarksStore *model, | ||||||
|  |                       const gchar           *bookmarks, | ||||||
|  |                       gboolean              *added) | ||||||
|  |  | ||||||
| { | { | ||||||
|     gchar *bookmarks; |  | ||||||
|     GError *error = NULL; |     GError *error = NULL; | ||||||
|     gchar *contents; |     gchar *contents; | ||||||
|     gchar **lines; |     gchar **lines; | ||||||
|     gchar **line; |     gchar **line; | ||||||
|     gboolean added = FALSE; |  | ||||||
|  |  | ||||||
|     /* Read the bookmarks file */ |     if (!g_file_get_contents (bookmarks, &contents, NULL, &error)) | ||||||
|     bookmarks = g_build_filename (g_get_home_dir (), ".gtk-bookmarks", NULL); |  | ||||||
|  |  | ||||||
|     if (g_file_get_contents (bookmarks, &contents, NULL, &error)) |  | ||||||
|     { |     { | ||||||
|  |         /* The bookmarks file doesn't exist (which is perfectly fine) */ | ||||||
|  |         g_error_free (error); | ||||||
|  |  | ||||||
|  |         return FALSE; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     lines = g_strsplit (contents, "\n", 0); |     lines = g_strsplit (contents, "\n", 0); | ||||||
|  |  | ||||||
|     for (line = lines; *line; ++line) |     for (line = lines; *line; ++line) | ||||||
| @@ -536,6 +552,7 @@ init_bookmarks (XedFileBookmarksStore * model) | |||||||
|         if (**line) |         if (**line) | ||||||
|         { |         { | ||||||
|             GFile *location; |             GFile *location; | ||||||
|  |  | ||||||
|             gchar *pos; |             gchar *pos; | ||||||
|             gchar *name; |             gchar *name; | ||||||
|  |  | ||||||
| @@ -557,7 +574,7 @@ init_bookmarks (XedFileBookmarksStore * model) | |||||||
|             location = g_file_new_for_uri (*line); |             location = g_file_new_for_uri (*line); | ||||||
|             if (xed_utils_is_valid_location (location)) |             if (xed_utils_is_valid_location (location)) | ||||||
|             { |             { | ||||||
|                     added |= add_bookmark (model, name, *line); |                 *added |= add_bookmark (model, name, *line); | ||||||
|             } |             } | ||||||
|             g_object_unref (location); |             g_object_unref (location); | ||||||
|         } |         } | ||||||
| @@ -576,13 +593,27 @@ init_bookmarks (XedFileBookmarksStore * model) | |||||||
|         g_object_unref (file); |         g_object_unref (file); | ||||||
|  |  | ||||||
|         g_signal_connect (model->priv->bookmarks_monitor, "changed", |         g_signal_connect (model->priv->bookmarks_monitor, "changed", | ||||||
|                               (GCallback)on_bookmarks_file_changed, model); |                           G_CALLBACK (on_bookmarks_file_changed), model); | ||||||
|     } |     } | ||||||
|     } |  | ||||||
|     else |     return TRUE; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | static void | ||||||
|  | init_bookmarks (XedFileBookmarksStore *model) | ||||||
|  | { | ||||||
|  |     gchar *bookmarks; | ||||||
|  |     gboolean added = FALSE; | ||||||
|  |  | ||||||
|  |     bookmarks = get_bookmarks_file (); | ||||||
|  |  | ||||||
|  |     if (!parse_bookmarks_file (model, bookmarks, &added)) | ||||||
|     { |     { | ||||||
|         /* The bookmarks file doesn't exist (which is perfectly fine) */ |         g_free (bookmarks); | ||||||
|         g_error_free (error); |  | ||||||
|  |         /* try the old location (gtk <= 3.4) */ | ||||||
|  |         bookmarks = get_legacy_bookmarks_file (); | ||||||
|  |         parse_bookmarks_file (model, bookmarks, &added); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (added) |     if (added) | ||||||
|   | |||||||
| @@ -92,7 +92,9 @@ window_data_free (XedWindow *window) | |||||||
|     gtk_ui_manager_remove_action_group (manager, data->merged_actions); |     gtk_ui_manager_remove_action_group (manager, data->merged_actions); | ||||||
|  |  | ||||||
|     for (item = data->merge_ids; item; item = item->next) |     for (item = data->merge_ids; item; item = item->next) | ||||||
|  |     { | ||||||
|         gtk_ui_manager_remove_ui (manager, GPOINTER_TO_INT (item->data)); |         gtk_ui_manager_remove_ui (manager, GPOINTER_TO_INT (item->data)); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     g_list_free (data->merge_ids); |     g_list_free (data->merge_ids); | ||||||
|     g_object_unref (data->merged_actions); |     g_object_unref (data->merged_actions); | ||||||
| @@ -115,10 +117,8 @@ filter_data_new (XedWindow  *window, | |||||||
|  |  | ||||||
|     wdata = get_window_data (window); |     wdata = get_window_data (window); | ||||||
|  |  | ||||||
|     g_hash_table_insert (wdata->filters, |     g_hash_table_insert (wdata->filters, xed_message_type_identifier (xed_message_get_object_path (message), | ||||||
|                  xed_message_type_identifier (xed_message_get_object_path (message), |                                                                       xed_message_get_method (message)), data); | ||||||
|                                                 xed_message_get_method (message)), |  | ||||||
|                  data); |  | ||||||
|  |  | ||||||
|     return data; |     return data; | ||||||
| } | } | ||||||
| @@ -148,7 +148,9 @@ track_row_lookup (WindowData  *data, | |||||||
|     ref = (GtkTreeRowReference *)g_hash_table_lookup (data->row_tracking, id); |     ref = (GtkTreeRowReference *)g_hash_table_lookup (data->row_tracking, id); | ||||||
|  |  | ||||||
|     if (!ref) |     if (!ref) | ||||||
|  |     { | ||||||
|         return NULL; |         return NULL; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     return gtk_tree_row_reference_get_path (ref); |     return gtk_tree_row_reference_get_path (ref); | ||||||
| } | } | ||||||
| @@ -201,15 +203,23 @@ message_set_root_cb (XedMessageBus *bus, | |||||||
|     xed_message_get (message, "location", &root, NULL); |     xed_message_get (message, "location", &root, NULL); | ||||||
|  |  | ||||||
|     if (!root) |     if (!root) | ||||||
|  |     { | ||||||
|         return; |         return; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     if (xed_message_has_key (message, "virtual")) |     if (xed_message_has_key (message, "virtual")) | ||||||
|  |     { | ||||||
|         xed_message_get (message, "virtual", &virtual, NULL); |         xed_message_get (message, "virtual", &virtual, NULL); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     if (virtual) |     if (virtual) | ||||||
|  |     { | ||||||
|         xed_file_browser_widget_set_root_and_virtual_root (data->widget, root, virtual); |         xed_file_browser_widget_set_root_and_virtual_root (data->widget, root, virtual); | ||||||
|  |     } | ||||||
|     else |     else | ||||||
|  |     { | ||||||
|         xed_file_browser_widget_set_root (data->widget, root, TRUE); |         xed_file_browser_widget_set_root (data->widget, root, TRUE); | ||||||
|  |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void | ||||||
| @@ -239,11 +249,7 @@ message_set_emblem_cb (XedMessageBus *bus, | |||||||
|         GError *error = NULL; |         GError *error = NULL; | ||||||
|         GdkPixbuf *pixbuf; |         GdkPixbuf *pixbuf; | ||||||
|  |  | ||||||
|         pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), |         pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), emblem, 10, 0, &error); | ||||||
|                            emblem, |  | ||||||
|                            10, |  | ||||||
|                            0, |  | ||||||
|                            &error); |  | ||||||
|  |  | ||||||
|         if (pixbuf) |         if (pixbuf) | ||||||
|         { |         { | ||||||
| @@ -257,10 +263,7 @@ message_set_emblem_cb (XedMessageBus *bus, | |||||||
|                 g_value_init (&value, GDK_TYPE_PIXBUF); |                 g_value_init (&value, GDK_TYPE_PIXBUF); | ||||||
|                 g_value_set_object (&value, pixbuf); |                 g_value_set_object (&value, pixbuf); | ||||||
|  |  | ||||||
|                 xed_file_browser_store_set_value (store, |                 xed_file_browser_store_set_value (store, &iter, XED_FILE_BROWSER_STORE_COLUMN_EMBLEM, &value); | ||||||
|                                     &iter, |  | ||||||
|                                     XED_FILE_BROWSER_STORE_COLUMN_EMBLEM, |  | ||||||
|                                     &value); |  | ||||||
|  |  | ||||||
|                 g_value_unset (&value); |                 g_value_unset (&value); | ||||||
|             } |             } | ||||||
| @@ -320,36 +323,36 @@ set_item_message (WindowData   *data, | |||||||
|     XedFileBrowserStore *store; |     XedFileBrowserStore *store; | ||||||
|     GFile *location; |     GFile *location; | ||||||
|     guint flags = 0; |     guint flags = 0; | ||||||
|     gchar *track_id; |  | ||||||
|  |  | ||||||
|     store = xed_file_browser_widget_get_browser_store (data->widget); |     store = xed_file_browser_widget_get_browser_store (data->widget); | ||||||
|  |  | ||||||
|     gtk_tree_model_get (GTK_TREE_MODEL (store), iter, |     gtk_tree_model_get (GTK_TREE_MODEL (store), iter, | ||||||
|                         XED_FILE_BROWSER_STORE_COLUMN_LOCATION, &location, |                         XED_FILE_BROWSER_STORE_COLUMN_LOCATION, &location, | ||||||
|                         XED_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags, |                         XED_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags, | ||||||
|                         -1); |                         -1); | ||||||
|  |  | ||||||
|     if (!location) |     if (location) | ||||||
|         return; |     { | ||||||
|  |         gchar *track_id; | ||||||
|  |  | ||||||
|         if (path && gtk_tree_path_get_depth (path) != 0) |         if (path && gtk_tree_path_get_depth (path) != 0) | ||||||
|  |         { | ||||||
|             track_id = track_row (data, store, path, location); |             track_id = track_row (data, store, path, location); | ||||||
|  |         } | ||||||
|         else |         else | ||||||
|  |         { | ||||||
|             track_id = NULL; |             track_id = NULL; | ||||||
|  |         } | ||||||
|  |  | ||||||
|     xed_message_set (message, |         xed_message_set (message, "id", track_id, "location", location, NULL); | ||||||
|                "id", track_id, |  | ||||||
|                "location", location, |  | ||||||
|                NULL); |  | ||||||
|  |  | ||||||
|         if (xed_message_has_key (message, "is_directory")) |         if (xed_message_has_key (message, "is_directory")) | ||||||
|         { |         { | ||||||
|         xed_message_set (message, |             xed_message_set (message, "is_directory", FILE_IS_DIR (flags), NULL); | ||||||
|                    "is_directory", FILE_IS_DIR (flags), |  | ||||||
|                    NULL); |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         g_free (track_id); |         g_free (track_id); | ||||||
|  |         g_object_unref (location); | ||||||
|  |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static gboolean | static gboolean | ||||||
| @@ -383,6 +386,8 @@ custom_message_filter_func (XedFileBrowserWidget *widget, | |||||||
|     xed_message_bus_send_message_sync (wdata->bus, data->message); |     xed_message_bus_send_message_sync (wdata->bus, data->message); | ||||||
|     xed_message_get (data->message, "filter", &filter, NULL); |     xed_message_get (data->message, "filter", &filter, NULL); | ||||||
|  |  | ||||||
|  |     g_object_unref (location); | ||||||
|  |  | ||||||
|     return !filter; |     return !filter; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -399,10 +404,7 @@ message_add_filter_cb (XedMessageBus *bus, | |||||||
|     FilterData *filter_data; |     FilterData *filter_data; | ||||||
|     WindowData *data = get_window_data (window); |     WindowData *data = get_window_data (window); | ||||||
|  |  | ||||||
|     xed_message_get (message, |     xed_message_get (message, "object_path", &object_path, "method", &method, NULL); | ||||||
|                "object_path", &object_path, |  | ||||||
|                "method", &method, |  | ||||||
|                NULL); |  | ||||||
|  |  | ||||||
|     // Check if there exists such a 'callback' message |     // Check if there exists such a 'callback' message | ||||||
|     if (!object_path || !method) |     if (!object_path || !method) | ||||||
| @@ -459,7 +461,9 @@ message_remove_filter_cb (XedMessageBus *bus, | |||||||
|     xed_message_get (message, "id", &id, NULL); |     xed_message_get (message, "id", &id, NULL); | ||||||
|  |  | ||||||
|     if (!id) |     if (!id) | ||||||
|  |     { | ||||||
|         return; |         return; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     xed_file_browser_widget_remove_filter (data->widget, id); |     xed_file_browser_widget_remove_filter (data->widget, id); | ||||||
| } | } | ||||||
| @@ -513,9 +517,13 @@ message_set_show_hidden_cb (XedMessageBus *bus, | |||||||
|     mode = xed_file_browser_store_get_filter_mode (store); |     mode = xed_file_browser_store_get_filter_mode (store); | ||||||
|  |  | ||||||
|     if (active) |     if (active) | ||||||
|  |     { | ||||||
|         mode &= ~XED_FILE_BROWSER_STORE_FILTER_MODE_HIDE_HIDDEN; |         mode &= ~XED_FILE_BROWSER_STORE_FILTER_MODE_HIDE_HIDDEN; | ||||||
|  |     } | ||||||
|     else |     else | ||||||
|  |     { | ||||||
|         mode |= XED_FILE_BROWSER_STORE_FILTER_MODE_HIDE_HIDDEN; |         mode |= XED_FILE_BROWSER_STORE_FILTER_MODE_HIDE_HIDDEN; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     xed_file_browser_store_set_filter_mode (store, mode); |     xed_file_browser_store_set_filter_mode (store, mode); | ||||||
| } | } | ||||||
| @@ -535,9 +543,13 @@ message_set_show_binary_cb (XedMessageBus *bus, | |||||||
|     mode = xed_file_browser_store_get_filter_mode (store); |     mode = xed_file_browser_store_get_filter_mode (store); | ||||||
|  |  | ||||||
|     if (active) |     if (active) | ||||||
|  |     { | ||||||
|         mode &= ~XED_FILE_BROWSER_STORE_FILTER_MODE_HIDE_BINARY; |         mode &= ~XED_FILE_BROWSER_STORE_FILTER_MODE_HIDE_BINARY; | ||||||
|  |     } | ||||||
|     else |     else | ||||||
|  |     { | ||||||
|         mode |= XED_FILE_BROWSER_STORE_FILTER_MODE_HIDE_BINARY; |         mode |= XED_FILE_BROWSER_STORE_FILTER_MODE_HIDE_BINARY; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     xed_file_browser_store_set_filter_mode (store, mode); |     xed_file_browser_store_set_filter_mode (store, mode); | ||||||
| } | } | ||||||
| @@ -569,15 +581,14 @@ message_add_context_item_cb (XedMessageBus *bus, | |||||||
|     GtkUIManager *manager; |     GtkUIManager *manager; | ||||||
|     guint merge_id; |     guint merge_id; | ||||||
|  |  | ||||||
|     xed_message_get (message, |     xed_message_get (message, "action", &action, "path", &path, NULL); | ||||||
|                "action", &action, |  | ||||||
|                "path", &path, |  | ||||||
|                NULL); |  | ||||||
|  |  | ||||||
|     if (!action || !path) |     if (!action || !path) | ||||||
|     { |     { | ||||||
|         if (action) |         if (action) | ||||||
|  |         { | ||||||
|             g_object_unref (action); |             g_object_unref (action); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         g_free (path); |         g_free (path); | ||||||
|         return; |         return; | ||||||
| @@ -622,7 +633,9 @@ message_remove_context_item_cb (XedMessageBus *bus, | |||||||
|     xed_message_get (message, "id", &merge_id, NULL); |     xed_message_get (message, "id", &merge_id, NULL); | ||||||
|  |  | ||||||
|     if (merge_id == 0) |     if (merge_id == 0) | ||||||
|  |     { | ||||||
|         return; |         return; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     manager = xed_file_browser_widget_get_ui_manager (data->widget); |     manager = xed_file_browser_widget_get_ui_manager (data->widget); | ||||||
|  |  | ||||||
| @@ -778,7 +791,9 @@ store_row_deleted (XedFileBrowserStore *store, | |||||||
|     guint flags = 0; |     guint flags = 0; | ||||||
|  |  | ||||||
|     if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, path)) |     if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, path)) | ||||||
|  |     { | ||||||
|         return; |         return; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, |     gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, | ||||||
|                         XED_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags, |                         XED_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags, | ||||||
| @@ -804,11 +819,11 @@ store_virtual_root_changed (XedFileBrowserStore *store, | |||||||
|     vroot = xed_file_browser_store_get_virtual_root (store); |     vroot = xed_file_browser_store_get_virtual_root (store); | ||||||
|  |  | ||||||
|     if (!vroot) |     if (!vroot) | ||||||
|  |     { | ||||||
|         return; |         return; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     xed_message_set (data->message, |     xed_message_set (data->message, "location", vroot, NULL); | ||||||
|                "location", vroot, |  | ||||||
|                NULL); |  | ||||||
|  |  | ||||||
|     xed_message_bus_send_message_sync (wdata->bus, data->message); |     xed_message_bus_send_message_sync (wdata->bus, data->message); | ||||||
|  |  | ||||||
| @@ -981,7 +996,9 @@ message_unregistered (XedMessageBus  *bus, | |||||||
|     data = g_hash_table_lookup (wdata->filters, identifier); |     data = g_hash_table_lookup (wdata->filters, identifier); | ||||||
|  |  | ||||||
|     if (data) |     if (data) | ||||||
|  |     { | ||||||
|         xed_file_browser_widget_remove_filter (wdata->widget, data->id); |         xed_file_browser_widget_remove_filter (wdata->widget, data->id); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     g_free (identifier); |     g_free (identifier); | ||||||
| } | } | ||||||
| @@ -995,10 +1012,8 @@ xed_file_browser_messages_register (XedWindow            *window, | |||||||
|     register_methods (window, widget); |     register_methods (window, widget); | ||||||
|     register_signals (window, widget); |     register_signals (window, widget); | ||||||
|  |  | ||||||
|     g_signal_connect (xed_window_get_message_bus (window), |     g_signal_connect (xed_window_get_message_bus (window), "unregistered", | ||||||
|               "unregistered", |                       G_CALLBACK (message_unregistered), window); | ||||||
|               G_CALLBACK (message_unregistered), |  | ||||||
|               window); |  | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void | ||||||
|   | |||||||
| @@ -337,21 +337,11 @@ on_action_set_active_root (GtkAction            *action, | |||||||
|     set_root_from_doc (plugin, xed_window_get_active_document (XED_WINDOW (plugin->priv->window))); |     set_root_from_doc (plugin, xed_window_get_active_document (XED_WINDOW (plugin->priv->window))); | ||||||
| } | } | ||||||
|  |  | ||||||
| static gchar * |  | ||||||
| get_terminal (XedFileBrowserPlugin *plugin) |  | ||||||
| { |  | ||||||
|     // TODO : Identify the DE, find the preferred terminal application (xterminal shouldn't be hardcoded here, it should be set as default in the DE prefs) |  | ||||||
|     return g_strdup ("xterminal"); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| static void | static void | ||||||
| on_action_open_terminal (GtkAction            *action, | on_action_open_terminal (GtkAction            *action, | ||||||
|                          XedFileBrowserPlugin *plugin) |                          XedFileBrowserPlugin *plugin) | ||||||
| { | { | ||||||
|     XedFileBrowserPluginPrivate *priv = plugin->priv; |     XedFileBrowserPluginPrivate *priv = plugin->priv; | ||||||
|     gchar *terminal; |  | ||||||
|     gchar *local; |  | ||||||
|     gchar *argv[2]; |  | ||||||
|     GFile *file; |     GFile *file; | ||||||
|  |  | ||||||
|     GtkTreeIter iter; |     GtkTreeIter iter; | ||||||
| @@ -366,13 +356,13 @@ on_action_open_terminal (GtkAction            *action, | |||||||
|     store = xed_file_browser_widget_get_browser_store (priv->tree_widget); |     store = xed_file_browser_widget_get_browser_store (priv->tree_widget); | ||||||
|     gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, XED_FILE_BROWSER_STORE_COLUMN_LOCATION, &file, -1); |     gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, XED_FILE_BROWSER_STORE_COLUMN_LOCATION, &file, -1); | ||||||
|  |  | ||||||
|     if (file == NULL) |     if (file) | ||||||
|     { |     { | ||||||
|         return; |         gchar *terminal; | ||||||
|     } |         gchar *local; | ||||||
|  |         gchar *argv[2]; | ||||||
|     terminal = get_terminal (plugin); |  | ||||||
|  |  | ||||||
|  |         terminal = g_settings_get_string (priv->settings, "terminal-command"); | ||||||
|         local = g_file_get_path (file); |         local = g_file_get_path (file); | ||||||
|  |  | ||||||
|         argv[0] = terminal; |         argv[0] = terminal; | ||||||
| @@ -389,6 +379,8 @@ on_action_open_terminal (GtkAction            *action, | |||||||
|  |  | ||||||
|         g_free (terminal); |         g_free (terminal); | ||||||
|         g_free (local); |         g_free (local); | ||||||
|  |         g_object_unref (file); | ||||||
|  |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void | ||||||
| @@ -400,7 +392,6 @@ on_selection_changed_cb (GtkTreeSelection     *selection, | |||||||
|     GtkTreeModel *model; |     GtkTreeModel *model; | ||||||
|     GtkTreeIter iter; |     GtkTreeIter iter; | ||||||
|     gboolean sensitive; |     gboolean sensitive; | ||||||
|     GFile *location; |  | ||||||
|  |  | ||||||
|     tree_view = GTK_TREE_VIEW (xed_file_browser_widget_get_browser_view (priv->tree_widget)); |     tree_view = GTK_TREE_VIEW (xed_file_browser_widget_get_browser_view (priv->tree_widget)); | ||||||
|     model = gtk_tree_view_get_model (tree_view); |     model = gtk_tree_view_get_model (tree_view); | ||||||
| @@ -414,9 +405,19 @@ on_selection_changed_cb (GtkTreeSelection     *selection, | |||||||
|  |  | ||||||
|     if (sensitive) |     if (sensitive) | ||||||
|     { |     { | ||||||
|  |         GFile *location; | ||||||
|  |  | ||||||
|         gtk_tree_model_get (model, &iter, XED_FILE_BROWSER_STORE_COLUMN_LOCATION, &location, -1); |         gtk_tree_model_get (model, &iter, XED_FILE_BROWSER_STORE_COLUMN_LOCATION, &location, -1); | ||||||
|  |  | ||||||
|  |         if (location) | ||||||
|  |         { | ||||||
|             sensitive = g_file_has_uri_scheme (location, "file"); |             sensitive = g_file_has_uri_scheme (location, "file"); | ||||||
|  |             g_object_unref (location); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             sensitive = FALSE; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     gtk_action_set_sensitive (gtk_action_group_get_action (priv->single_selection_action_group, "OpenTerminal"), sensitive); |     gtk_action_set_sensitive (gtk_action_group_get_action (priv->single_selection_action_group, "OpenTerminal"), sensitive); | ||||||
| @@ -478,7 +479,7 @@ add_popup_ui (XedFileBrowserPlugin *plugin) | |||||||
|     gtk_action_group_add_actions (action_group, |     gtk_action_group_add_actions (action_group, | ||||||
|                                   extra_single_selection_actions, |                                   extra_single_selection_actions, | ||||||
|                                   G_N_ELEMENTS (extra_single_selection_actions), |                                   G_N_ELEMENTS (extra_single_selection_actions), | ||||||
|                                   priv->window); |                                   plugin); | ||||||
|     gtk_ui_manager_insert_action_group (manager, action_group, 0); |     gtk_ui_manager_insert_action_group (manager, action_group, 0); | ||||||
|     priv->single_selection_action_group = action_group; |     priv->single_selection_action_group = action_group; | ||||||
|  |  | ||||||
| @@ -927,11 +928,18 @@ get_filename_from_path (GtkTreeModel *model, | |||||||
| { | { | ||||||
|     GtkTreeIter iter; |     GtkTreeIter iter; | ||||||
|     GFile *location; |     GFile *location; | ||||||
|  |     gchar *ret = NULL; | ||||||
|  |  | ||||||
|     gtk_tree_model_get_iter (model, &iter, path); |     gtk_tree_model_get_iter (model, &iter, path); | ||||||
|     gtk_tree_model_get (model, &iter, XED_FILE_BROWSER_STORE_COLUMN_LOCATION, &location, -1); |     gtk_tree_model_get (model, &iter, XED_FILE_BROWSER_STORE_COLUMN_LOCATION, &location, -1); | ||||||
|  |  | ||||||
|     return xed_file_browser_utils_file_basename (location); |     if (location) | ||||||
|  |     { | ||||||
|  |         ret = xed_file_browser_utils_file_basename (location); | ||||||
|  |         g_object_unref (location); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     return ret; | ||||||
| } | } | ||||||
|  |  | ||||||
| static gboolean | static gboolean | ||||||
| @@ -961,8 +969,7 @@ on_confirm_no_trash_cb (XedFileBrowserWidget *widget, | |||||||
|                                                          GTK_MESSAGE_QUESTION, |                                                          GTK_MESSAGE_QUESTION, | ||||||
|                                                          message, |                                                          message, | ||||||
|                                                          secondary, |                                                          secondary, | ||||||
|                                                          GTK_STOCK_DELETE, |                                                          _("_Delete")); | ||||||
|                                                          NULL); |  | ||||||
|     g_free (secondary); |     g_free (secondary); | ||||||
|  |  | ||||||
|     return result; |     return result; | ||||||
| @@ -997,8 +1004,7 @@ on_confirm_delete_cb (XedFileBrowserWidget *widget, | |||||||
|                                                          GTK_MESSAGE_QUESTION, |                                                          GTK_MESSAGE_QUESTION, | ||||||
|                                                          message, |                                                          message, | ||||||
|                                                          secondary, |                                                          secondary, | ||||||
|                                                          GTK_STOCK_DELETE, |                                                          _("_Delete")); | ||||||
|                                                          NULL); |  | ||||||
|  |  | ||||||
|     g_free (message); |     g_free (message); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -104,7 +104,6 @@ struct _FileBrowserNodeDir | |||||||
| { | { | ||||||
|     FileBrowserNode node; |     FileBrowserNode node; | ||||||
|     GSList *children; |     GSList *children; | ||||||
|     GHashTable *hidden_file_hash; |  | ||||||
|  |  | ||||||
|     GCancellable *cancellable; |     GCancellable *cancellable; | ||||||
|     GFileMonitor *monitor; |     GFileMonitor *monitor; | ||||||
| @@ -160,40 +159,42 @@ static gboolean xed_file_browser_store_iter_children (GtkTreeModel *tree_model, | |||||||
| static gboolean xed_file_browser_store_iter_has_child (GtkTreeModel *tree_model, | static gboolean xed_file_browser_store_iter_has_child (GtkTreeModel *tree_model, | ||||||
|                                                        GtkTreeIter  *iter); |                                                        GtkTreeIter  *iter); | ||||||
| static gint xed_file_browser_store_iter_n_children (GtkTreeModel *tree_model, | static gint xed_file_browser_store_iter_n_children (GtkTreeModel *tree_model, | ||||||
|                                  GtkTreeIter * iter); |                                                     GtkTreeIter  *iter); | ||||||
| static gboolean xed_file_browser_store_iter_nth_child     (GtkTreeModel * tree_model, | static gboolean xed_file_browser_store_iter_nth_child (GtkTreeModel *tree_model, | ||||||
|                                  GtkTreeIter * iter, |                                                        GtkTreeIter  *iter, | ||||||
|                                  GtkTreeIter * parent, |                                                        GtkTreeIter  *parent, | ||||||
|                                                        gint          n); |                                                        gint          n); | ||||||
| static gboolean xed_file_browser_store_iter_parent        (GtkTreeModel * tree_model, | static gboolean xed_file_browser_store_iter_parent (GtkTreeModel *tree_model, | ||||||
|                                  GtkTreeIter * iter, |                                                     GtkTreeIter  *iter, | ||||||
|                                  GtkTreeIter * child); |                                                     GtkTreeIter  *child); | ||||||
| static void xed_file_browser_store_row_inserted     (GtkTreeModel * tree_model, | static void xed_file_browser_store_row_inserted (GtkTreeModel *tree_model, | ||||||
|                                  GtkTreePath * path, |                                                  GtkTreePath  *path, | ||||||
|                                  GtkTreeIter * iter); |                                                  GtkTreeIter  *iter); | ||||||
|  |  | ||||||
| static void xed_file_browser_store_drag_source_init       (GtkTreeDragSourceIface * iface); | static void xed_file_browser_store_drag_source_init (GtkTreeDragSourceIface *iface); | ||||||
| static gboolean xed_file_browser_store_row_draggable      (GtkTreeDragSource * drag_source, | static gboolean xed_file_browser_store_row_draggable (GtkTreeDragSource *drag_source, | ||||||
|                                  GtkTreePath       * path); |                                                       GtkTreePath       *path); | ||||||
| static gboolean xed_file_browser_store_drag_data_delete   (GtkTreeDragSource * drag_source, | static gboolean xed_file_browser_store_drag_data_delete (GtkTreeDragSource *drag_source, | ||||||
|                                  GtkTreePath       * path); |                                                          GtkTreePath       *path); | ||||||
| static gboolean xed_file_browser_store_drag_data_get      (GtkTreeDragSource * drag_source, | static gboolean xed_file_browser_store_drag_data_get (GtkTreeDragSource *drag_source, | ||||||
|                                  GtkTreePath       * path, |                                                       GtkTreePath       *path, | ||||||
|                                  GtkSelectionData  * selection_data); |                                                       GtkSelectionData  *selection_data); | ||||||
|  |  | ||||||
| static void file_browser_node_free                          (XedFileBrowserStore * model, | static void file_browser_node_free (XedFileBrowserStore *model, | ||||||
|                                  FileBrowserNode * node); |                                     FileBrowserNode     *node); | ||||||
| static void model_add_node                                  (XedFileBrowserStore * model, | static void model_add_node (XedFileBrowserStore *model, | ||||||
|                                  FileBrowserNode * child, |                             FileBrowserNode     *child, | ||||||
|                                  FileBrowserNode * parent); |                             FileBrowserNode     *parent); | ||||||
| static void model_clear                                     (XedFileBrowserStore * model, | static void model_clear (XedFileBrowserStore *model, | ||||||
|                          gboolean             free_nodes); |                          gboolean             free_nodes); | ||||||
| static gint model_sort_default                              (FileBrowserNode * node1, | static gint model_sort_default (FileBrowserNode *node1, | ||||||
|                                  FileBrowserNode * node2); |                                 FileBrowserNode *node2); | ||||||
| static void model_check_dummy                               (XedFileBrowserStore * model, | static void model_check_dummy (XedFileBrowserStore *model, | ||||||
|                                  FileBrowserNode * node); |                                FileBrowserNode     *node); | ||||||
| static void next_files_async                    (GFileEnumerator * enumerator, | static void next_files_async (GFileEnumerator *enumerator, | ||||||
|                                  AsyncNode * async); |                               AsyncNode       *async); | ||||||
|  |  | ||||||
|  | static void delete_files (AsyncData *data); | ||||||
|  |  | ||||||
| G_DEFINE_DYNAMIC_TYPE_EXTENDED (XedFileBrowserStore, xed_file_browser_store, | G_DEFINE_DYNAMIC_TYPE_EXTENDED (XedFileBrowserStore, xed_file_browser_store, | ||||||
|                                 G_TYPE_OBJECT, |                                 G_TYPE_OBJECT, | ||||||
| @@ -1027,6 +1028,7 @@ xed_file_browser_store_drag_data_get (GtkTreeDragSource *drag_source, | |||||||
|     ret = gtk_selection_data_set_uris (selection_data, uris); |     ret = gtk_selection_data_set_uris (selection_data, uris); | ||||||
|  |  | ||||||
|     g_free (uris[0]); |     g_free (uris[0]); | ||||||
|  |     g_object_unref (location); | ||||||
|  |  | ||||||
|     return ret; |     return ret; | ||||||
| } | } | ||||||
| @@ -1471,11 +1473,6 @@ file_browser_node_free (XedFileBrowserStore *model, | |||||||
|             g_file_monitor_cancel (dir->monitor); |             g_file_monitor_cancel (dir->monitor); | ||||||
|             g_object_unref (dir->monitor); |             g_object_unref (dir->monitor); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (dir->hidden_file_hash) |  | ||||||
|         { |  | ||||||
|             g_hash_table_destroy (dir->hidden_file_hash); |  | ||||||
|         } |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (node->file) |     if (node->file) | ||||||
| @@ -2082,9 +2079,7 @@ file_browser_node_set_from_info (XedFileBrowserStore *model, | |||||||
|                                  GFileInfo           *info, |                                  GFileInfo           *info, | ||||||
|                                  gboolean             isadded) |                                  gboolean             isadded) | ||||||
| { | { | ||||||
|     FileBrowserNodeDir *dir; |  | ||||||
|     gchar const *content; |     gchar const *content; | ||||||
|     gchar const *name; |  | ||||||
|     gboolean free_info = FALSE; |     gboolean free_info = FALSE; | ||||||
|     GtkTreePath *path; |     GtkTreePath *path; | ||||||
|     gchar *uri; |     gchar *uri; | ||||||
| @@ -2114,17 +2109,10 @@ file_browser_node_set_from_info (XedFileBrowserStore *model, | |||||||
|         free_info = TRUE; |         free_info = TRUE; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     dir = FILE_BROWSER_NODE_DIR (node->parent); |  | ||||||
|     name = g_file_info_get_name (info); |  | ||||||
|  |  | ||||||
|     if (g_file_info_get_is_hidden (info) || g_file_info_get_is_backup (info)) |     if (g_file_info_get_is_hidden (info) || g_file_info_get_is_backup (info)) | ||||||
|     { |     { | ||||||
|         node->flags |= XED_FILE_BROWSER_STORE_FLAG_IS_HIDDEN; |         node->flags |= XED_FILE_BROWSER_STORE_FLAG_IS_HIDDEN; | ||||||
|     } |     } | ||||||
|     else if (dir != NULL && dir->hidden_file_hash != NULL && g_hash_table_lookup (dir->hidden_file_hash, name) != NULL) |  | ||||||
|     { |  | ||||||
|         node->flags |= XED_FILE_BROWSER_STORE_FLAG_IS_HIDDEN; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) |     if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) | ||||||
|     { |     { | ||||||
| @@ -2276,15 +2264,17 @@ model_add_nodes_from_files (XedFileBrowserStore *model, | |||||||
|             (strcmp (name, ".") == 0 || |             (strcmp (name, ".") == 0 || | ||||||
|              strcmp (name, "..") == 0)) |              strcmp (name, "..") == 0)) | ||||||
|         { |         { | ||||||
|  |             g_object_unref (info); | ||||||
|             continue; |             continue; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         file = g_file_get_child (parent->file, name); |         file = g_file_get_child (parent->file, name); | ||||||
|  |  | ||||||
|         if ((node = node_list_contains_file (original_children, file)) == NULL) |         node = node_list_contains_file (original_children, file); | ||||||
|  |         if (node == NULL) | ||||||
|         { |         { | ||||||
|  |  | ||||||
|             if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) |             if (type == G_FILE_TYPE_DIRECTORY) | ||||||
|             { |             { | ||||||
|                 node = file_browser_node_dir_new (model, file, parent); |                 node = file_browser_node_dir_new (model, file, parent); | ||||||
|             } |             } | ||||||
| @@ -2337,83 +2327,6 @@ model_add_node_from_dir (XedFileBrowserStore *model, | |||||||
|     return node; |     return node; | ||||||
| } | } | ||||||
|  |  | ||||||
| /* Read is sync, but we only do it for local files */ |  | ||||||
| static void |  | ||||||
| parse_dot_hidden_file (FileBrowserNode *directory) |  | ||||||
| { |  | ||||||
|     gsize file_size; |  | ||||||
|     char *file_contents; |  | ||||||
|     GFile *child; |  | ||||||
|     GFileInfo *info; |  | ||||||
|     GFileType type; |  | ||||||
|     int i; |  | ||||||
|     FileBrowserNodeDir * dir = FILE_BROWSER_NODE_DIR (directory); |  | ||||||
|  |  | ||||||
|     /* FIXME: We only support .hidden on file: uri's for the moment. |  | ||||||
|      * Need to figure out if we should do this async or sync to extend |  | ||||||
|      * it to all types of uris. |  | ||||||
|      */ |  | ||||||
|     if (directory->file == NULL || !g_file_is_native (directory->file)) |  | ||||||
|     { |  | ||||||
|         return; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     child = g_file_get_child (directory->file, ".hidden"); |  | ||||||
|     info = g_file_query_info (child, G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL); |  | ||||||
|  |  | ||||||
|     type = info ? g_file_info_get_file_type (info) : G_FILE_TYPE_UNKNOWN; |  | ||||||
|  |  | ||||||
|     if (info) |  | ||||||
|     { |  | ||||||
|         g_object_unref (info); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     if (type != G_FILE_TYPE_REGULAR) |  | ||||||
|     { |  | ||||||
|         g_object_unref (child); |  | ||||||
|         return; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     if (!g_file_load_contents (child, NULL, &file_contents, &file_size, NULL, NULL)) |  | ||||||
|     { |  | ||||||
|         g_object_unref (child); |  | ||||||
|         return; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     g_object_unref (child); |  | ||||||
|  |  | ||||||
|     if (dir->hidden_file_hash == NULL) |  | ||||||
|     { |  | ||||||
|         dir->hidden_file_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /* Now parse the data */ |  | ||||||
|     i = 0; |  | ||||||
|     while (i < file_size) |  | ||||||
|     { |  | ||||||
|         int start; |  | ||||||
|  |  | ||||||
|         start = i; |  | ||||||
|         while (i < file_size && file_contents[i] != '\n') |  | ||||||
|         { |  | ||||||
|             i++; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         if (i > start) |  | ||||||
|         { |  | ||||||
|             char *hidden_filename; |  | ||||||
|  |  | ||||||
|             hidden_filename = g_strndup (file_contents + start, i - start); |  | ||||||
|             g_hash_table_insert (dir->hidden_file_hash, hidden_filename, hidden_filename); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         i++; |  | ||||||
|  |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     g_free (file_contents); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| static void | static void | ||||||
| on_directory_monitor_event (GFileMonitor      *monitor, | on_directory_monitor_event (GFileMonitor      *monitor, | ||||||
|                             GFile             *file, |                             GFile             *file, | ||||||
| @@ -2451,7 +2364,7 @@ async_node_free (AsyncNode *async) | |||||||
| { | { | ||||||
|     g_object_unref (async->cancellable); |     g_object_unref (async->cancellable); | ||||||
|     g_slist_free (async->original_children); |     g_slist_free (async->original_children); | ||||||
|     g_free (async); |     g_slice_free (AsyncNode, async); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void | ||||||
| @@ -2469,6 +2382,7 @@ model_iterate_next_files_cb (GFileEnumerator *enumerator, | |||||||
|     if (files == NULL) |     if (files == NULL) | ||||||
|     { |     { | ||||||
|         g_file_enumerator_close (enumerator, NULL, NULL); |         g_file_enumerator_close (enumerator, NULL, NULL); | ||||||
|  |         g_object_unref (enumerator); | ||||||
|         async_node_free (async); |         async_node_free (async); | ||||||
|  |  | ||||||
|         if (!error) |         if (!error) | ||||||
| @@ -2520,6 +2434,7 @@ model_iterate_next_files_cb (GFileEnumerator *enumerator, | |||||||
|     { |     { | ||||||
|         /* Check cancel state manually */ |         /* Check cancel state manually */ | ||||||
|         g_file_enumerator_close (enumerator, NULL, NULL); |         g_file_enumerator_close (enumerator, NULL, NULL); | ||||||
|  |         g_object_unref (enumerator); | ||||||
|         async_node_free (async); |         async_node_free (async); | ||||||
|     } |     } | ||||||
|     else |     else | ||||||
| @@ -2601,12 +2516,9 @@ model_load_directory (XedFileBrowserStore *model, | |||||||
|     node->flags |= XED_FILE_BROWSER_STORE_FLAG_LOADED; |     node->flags |= XED_FILE_BROWSER_STORE_FLAG_LOADED; | ||||||
|     model_begin_loading (model, node); |     model_begin_loading (model, node); | ||||||
|  |  | ||||||
|     /* Read the '.hidden' file first (if any) */ |  | ||||||
|     parse_dot_hidden_file (node); |  | ||||||
|  |  | ||||||
|     dir->cancellable = g_cancellable_new (); |     dir->cancellable = g_cancellable_new (); | ||||||
|  |  | ||||||
|     async = g_new (AsyncNode, 1); |     async = g_slice_new (AsyncNode); | ||||||
|     async->dir = dir; |     async->dir = dir; | ||||||
|     async->cancellable = g_object_ref (dir->cancellable); |     async->cancellable = g_object_ref (dir->cancellable); | ||||||
|     async->original_children = g_slist_copy (dir->children); |     async->original_children = g_slist_copy (dir->children); | ||||||
| @@ -3013,9 +2925,13 @@ mount_cb (GFile        *file, | |||||||
|  |  | ||||||
|     g_object_unref (mount_info->operation); |     g_object_unref (mount_info->operation); | ||||||
|     g_object_unref (mount_info->cancellable); |     g_object_unref (mount_info->cancellable); | ||||||
|     g_free (mount_info->virtual_root); |  | ||||||
|  |  | ||||||
|     g_free (mount_info); |     if (mount_info->virtual_root) | ||||||
|  |     { | ||||||
|  |         g_object_unref (mount_info->virtual_root); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     g_slice_free (MountInfo, mount_info); | ||||||
| } | } | ||||||
|  |  | ||||||
| static XedFileBrowserStoreResult | static XedFileBrowserStoreResult | ||||||
| @@ -3039,7 +2955,7 @@ model_mount_root (XedFileBrowserStore *model, | |||||||
|             /* Try to mount it */ |             /* Try to mount it */ | ||||||
|             FILE_BROWSER_NODE_DIR (model->priv->root)->cancellable = g_cancellable_new (); |             FILE_BROWSER_NODE_DIR (model->priv->root)->cancellable = g_cancellable_new (); | ||||||
|  |  | ||||||
|             mount_info = g_new(MountInfo, 1); |             mount_info = g_slice_new (MountInfo); | ||||||
|             mount_info->model = model; |             mount_info->model = model; | ||||||
|             mount_info->virtual_root = g_file_dup (virtual_root); |             mount_info->virtual_root = g_file_dup (virtual_root); | ||||||
|  |  | ||||||
| @@ -3633,7 +3549,7 @@ async_data_free (AsyncData *data) | |||||||
|         data->model->priv->async_handles = g_slist_remove (data->model->priv->async_handles, data); |         data->model->priv->async_handles = g_slist_remove (data->model->priv->async_handles, data); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     g_free (data); |     g_slice_free (AsyncData, data); | ||||||
| } | } | ||||||
|  |  | ||||||
| static gboolean | static gboolean | ||||||
| @@ -3646,93 +3562,101 @@ emit_no_trash (AsyncData *data) | |||||||
|     return ret; |     return ret; | ||||||
| } | } | ||||||
|  |  | ||||||
| typedef struct | static void | ||||||
|  | delete_file_finished (GFile        *file, | ||||||
|  |                       GAsyncResult *res, | ||||||
|  |                       AsyncData    *data) | ||||||
| { | { | ||||||
|     XedFileBrowserStore *model; |     GError *error = NULL; | ||||||
|     GFile *file; |     gboolean ok; | ||||||
| } IdleDelete; |  | ||||||
|  |  | ||||||
| static gboolean |     if (data->trash) | ||||||
| file_deleted (IdleDelete *data) |     { | ||||||
| { |         ok = g_file_trash_finish (file, res, &error); | ||||||
|     FileBrowserNode *node; |     } | ||||||
|     node = model_find_node (data->model, NULL, data->file); |     else | ||||||
|  |     { | ||||||
|  |         ok = g_file_delete_finish (file, res, &error); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     if (ok) | ||||||
|  |     { | ||||||
|  |         /* Remove the file from the model */ | ||||||
|  |         FileBrowserNode *node = model_find_node (data->model, NULL, file); | ||||||
|  |  | ||||||
|         if (node != NULL) |         if (node != NULL) | ||||||
|         { |         { | ||||||
|             model_remove_node (data->model, node, NULL, TRUE); |             model_remove_node (data->model, node, NULL, TRUE); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|     return FALSE; |         /* Process the next file */ | ||||||
| } |         data->iter = data->iter->next; | ||||||
|  |  | ||||||
| static gboolean |  | ||||||
| delete_files (GIOSchedulerJob *job, |  | ||||||
|               GCancellable    *cancellable, |  | ||||||
|               AsyncData       *data) |  | ||||||
| { |  | ||||||
|     GFile *file; |  | ||||||
|     GError *error = NULL; |  | ||||||
|     gboolean ret; |  | ||||||
|     gint code; |  | ||||||
|     IdleDelete delete; |  | ||||||
|  |  | ||||||
|     /* Check if our job is done */ |  | ||||||
|     if (!data->iter) |  | ||||||
|     { |  | ||||||
|         return FALSE; |  | ||||||
|     } |     } | ||||||
|  |     else if (!ok && error != NULL) | ||||||
|     /* Move a file to the trash */ |  | ||||||
|     file = G_FILE (data->iter->data); |  | ||||||
|  |  | ||||||
|     if (data->trash) |  | ||||||
|     { |     { | ||||||
|         ret = g_file_trash (file, cancellable, &error); |         gint code = error->code; | ||||||
|     } |  | ||||||
|     else |  | ||||||
|     { |  | ||||||
|         ret = g_file_delete (file, cancellable, &error); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     if (ret) |  | ||||||
|     { |  | ||||||
|         delete.model = data->model; |  | ||||||
|         delete.file = file; |  | ||||||
|  |  | ||||||
|         /* Remove the file from the model in the main loop */ |  | ||||||
|         g_io_scheduler_job_send_to_mainloop (job, (GSourceFunc)file_deleted, &delete, NULL); |  | ||||||
|     } |  | ||||||
|     else if (!ret && error) |  | ||||||
|     { |  | ||||||
|         code = error->code; |  | ||||||
|         g_error_free (error); |         g_error_free (error); | ||||||
|  |  | ||||||
|         if (data->trash && code == G_IO_ERROR_NOT_SUPPORTED) |         if (data->trash && code == G_IO_ERROR_NOT_SUPPORTED) | ||||||
|         { |         { | ||||||
|             /* Trash is not supported on this system ... */ |             /* Trash is not supported on this system. Ask the user | ||||||
|             if (g_io_scheduler_job_send_to_mainloop (job, (GSourceFunc)emit_no_trash, data, NULL)) |              * if he wants to delete completely the files instead. | ||||||
|  |              */ | ||||||
|  |             if (emit_no_trash (data)) | ||||||
|             { |             { | ||||||
|                 /* Changes this into a delete job */ |                 /* Changes this into a delete job */ | ||||||
|                 data->trash = FALSE; |                 data->trash = FALSE; | ||||||
|                 data->iter = data->files; |                 data->iter = data->files; | ||||||
|  |  | ||||||
|                 return TRUE; |  | ||||||
|             } |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|                 /* End the job */ |                 /* End the job */ | ||||||
|             return FALSE; |                 async_data_free (data); | ||||||
|  |                 return; | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|         else if (code == G_IO_ERROR_CANCELLED) |         else if (code == G_IO_ERROR_CANCELLED) | ||||||
|         { |         { | ||||||
|             /* Job has been cancelled, just let the job end */ |             /* Job has been cancelled, end the job */ | ||||||
|             return FALSE; |             async_data_free (data); | ||||||
|  |             return; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /* Process the next item */ |     /* Continue the job */ | ||||||
|     data->iter = data->iter->next; |     delete_files (data); | ||||||
|     return TRUE; | } | ||||||
|  |  | ||||||
|  | static void | ||||||
|  | delete_files (AsyncData *data) | ||||||
|  | { | ||||||
|  |     GFile *file; | ||||||
|  |  | ||||||
|  |     /* Check if our job is done */ | ||||||
|  |     if (data->iter == NULL) | ||||||
|  |     { | ||||||
|  |         async_data_free (data); | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     file = G_FILE (data->iter->data); | ||||||
|  |  | ||||||
|  |     if (data->trash) | ||||||
|  |     { | ||||||
|  |         g_file_trash_async (file, | ||||||
|  |                             G_PRIORITY_DEFAULT, | ||||||
|  |                             data->cancellable, | ||||||
|  |                             (GAsyncReadyCallback)delete_file_finished, | ||||||
|  |                             data); | ||||||
|  |     } | ||||||
|  |     else | ||||||
|  |     { | ||||||
|  |         g_file_delete_async (file, | ||||||
|  |                              G_PRIORITY_DEFAULT, | ||||||
|  |                              data->cancellable, | ||||||
|  |                              (GAsyncReadyCallback)delete_file_finished, | ||||||
|  |                              data); | ||||||
|  |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| XedFileBrowserStoreResult | XedFileBrowserStoreResult | ||||||
| @@ -3781,7 +3705,7 @@ xed_file_browser_store_delete_all (XedFileBrowserStore *model, | |||||||
|         files = g_list_prepend (files, g_object_ref (node->file)); |         files = g_list_prepend (files, g_object_ref (node->file)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     data = g_new (AsyncData, 1); |     data = g_slice_new (AsyncData); | ||||||
|  |  | ||||||
|     data->model = model; |     data->model = model; | ||||||
|     data->cancellable = g_cancellable_new (); |     data->cancellable = g_cancellable_new (); | ||||||
| @@ -3792,11 +3716,7 @@ xed_file_browser_store_delete_all (XedFileBrowserStore *model, | |||||||
|  |  | ||||||
|     model->priv->async_handles = g_slist_prepend (model->priv->async_handles, data); |     model->priv->async_handles = g_slist_prepend (model->priv->async_handles, data); | ||||||
|  |  | ||||||
|     g_io_scheduler_push_job ((GIOSchedulerJobFunc)delete_files, |     delete_files (data); | ||||||
|                              data, |  | ||||||
|                              (GDestroyNotify)async_data_free, |  | ||||||
|                              G_PRIORITY_DEFAULT, |  | ||||||
|                              data->cancellable); |  | ||||||
|     g_list_free (rows); |     g_list_free (rows); | ||||||
|  |  | ||||||
|     return XED_FILE_BROWSER_STORE_RESULT_OK; |     return XED_FILE_BROWSER_STORE_RESULT_OK; | ||||||
| @@ -3851,7 +3771,7 @@ xed_file_browser_store_new_file (XedFileBrowserStore *model, | |||||||
|  |  | ||||||
|     parent_node = FILE_BROWSER_NODE_DIR (parent->user_data); |     parent_node = FILE_BROWSER_NODE_DIR (parent->user_data); | ||||||
|     /* Translators: This is the default name of new files created by the file browser pane. */ |     /* Translators: This is the default name of new files created by the file browser pane. */ | ||||||
|     file = unique_new_name (((FileBrowserNode *) parent_node)->file, _("file")); |     file = unique_new_name (((FileBrowserNode *) parent_node)->file, _("Untitled File")); | ||||||
|  |  | ||||||
|     stream = g_file_create (file, G_FILE_CREATE_NONE, NULL, &error); |     stream = g_file_create (file, G_FILE_CREATE_NONE, NULL, &error); | ||||||
|  |  | ||||||
| @@ -3906,7 +3826,7 @@ xed_file_browser_store_new_directory (XedFileBrowserStore *model, | |||||||
|  |  | ||||||
|     parent_node = FILE_BROWSER_NODE_DIR (parent->user_data); |     parent_node = FILE_BROWSER_NODE_DIR (parent->user_data); | ||||||
|     /* Translators: This is the default name of new directories created by the file browser pane. */ |     /* Translators: This is the default name of new directories created by the file browser pane. */ | ||||||
|     file = unique_new_name (((FileBrowserNode *) parent_node)->file, _("directory")); |     file = unique_new_name (((FileBrowserNode *) parent_node)->file, _("Untitled Folder")); | ||||||
|  |  | ||||||
|     if (!g_file_make_directory (file, NULL, &error)) |     if (!g_file_make_directory (file, NULL, &error)) | ||||||
|     { |     { | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /* | /* | ||||||
|  * xed-file-bookmarks-store.c - Xed plugin providing easy file access |  * xed-file-browser-utils.c - Xed plugin providing easy file access | ||||||
|  * from the sidepanel |  * from the sidepanel | ||||||
|  * |  * | ||||||
|  * Copyright (C) 2006 - Jesse van den Kieboom <jesse@icecrew.nl> |  * Copyright (C) 2006 - Jesse van den Kieboom <jesse@icecrew.nl> | ||||||
| @@ -19,29 +19,32 @@ | |||||||
|  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. |  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include "xed-file-browser-utils.h" | #ifdef HAVE_CONFIG_H | ||||||
|  | #include <config.h> | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #include <glib/gi18n-lib.h> | ||||||
| #include <xed/xed-utils.h> | #include <xed/xed-utils.h> | ||||||
|  |  | ||||||
| static GdkPixbuf * | #include "xed-file-browser-utils.h" | ||||||
| process_icon_pixbuf (GdkPixbuf * pixbuf, |  | ||||||
| 		     gchar const * name, |  | ||||||
| 		     gint size, |  | ||||||
| 		     GError * error) |  | ||||||
| { |  | ||||||
| 	GdkPixbuf * scale; |  | ||||||
|  |  | ||||||
| 	if (error != NULL) { | static GdkPixbuf * | ||||||
| 		g_warning ("Could not load theme icon %s: %s", | process_icon_pixbuf (GdkPixbuf   *pixbuf, | ||||||
| 			   name, |                      gchar const *name, | ||||||
| 			   error->message); |                      gint         size, | ||||||
|  |                      GError      *error) | ||||||
|  | { | ||||||
|  |     GdkPixbuf *scale; | ||||||
|  |  | ||||||
|  |     if (error != NULL) | ||||||
|  |     { | ||||||
|  |         g_warning ("Could not load theme icon %s: %s", name, error->message); | ||||||
|         g_error_free (error); |         g_error_free (error); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| 	if (pixbuf && gdk_pixbuf_get_width (pixbuf) > size) { |     if (pixbuf && gdk_pixbuf_get_width (pixbuf) > size) | ||||||
| 		scale = gdk_pixbuf_scale_simple (pixbuf, |     { | ||||||
| 		                                 size, |         scale = gdk_pixbuf_scale_simple (pixbuf, size, size, GDK_INTERP_BILINEAR); | ||||||
| 		                                 size, |  | ||||||
| 		                                 GDK_INTERP_BILINEAR); |  | ||||||
|         g_object_unref (pixbuf); |         g_object_unref (pixbuf); | ||||||
|         pixbuf = scale; |         pixbuf = scale; | ||||||
|     } |     } | ||||||
| @@ -50,7 +53,7 @@ process_icon_pixbuf (GdkPixbuf * pixbuf, | |||||||
| } | } | ||||||
|  |  | ||||||
| GdkPixbuf * | GdkPixbuf * | ||||||
| xed_file_browser_utils_pixbuf_from_theme (gchar const * name, | xed_file_browser_utils_pixbuf_from_theme (gchar const *name, | ||||||
|                                           GtkIconSize  size) |                                           GtkIconSize  size) | ||||||
| { | { | ||||||
|     gint width; |     gint width; | ||||||
| @@ -59,11 +62,7 @@ xed_file_browser_utils_pixbuf_from_theme (gchar const * name, | |||||||
|  |  | ||||||
|     gtk_icon_size_lookup (size, &width, NULL); |     gtk_icon_size_lookup (size, &width, NULL); | ||||||
|  |  | ||||||
| 	pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), |     pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), name, width, 0, &error); | ||||||
| 					   name, |  | ||||||
| 					   width, |  | ||||||
| 					   0, |  | ||||||
| 					   &error); |  | ||||||
|  |  | ||||||
|     pixbuf = process_icon_pixbuf (pixbuf, name, width, error); |     pixbuf = process_icon_pixbuf (pixbuf, name, width, error); | ||||||
|  |  | ||||||
| @@ -71,27 +70,28 @@ xed_file_browser_utils_pixbuf_from_theme (gchar const * name, | |||||||
| } | } | ||||||
|  |  | ||||||
| GdkPixbuf * | GdkPixbuf * | ||||||
| xed_file_browser_utils_pixbuf_from_icon (GIcon * icon, | xed_file_browser_utils_pixbuf_from_icon (GIcon       *icon, | ||||||
|                                          GtkIconSize  size) |                                          GtkIconSize  size) | ||||||
| { | { | ||||||
| 	GdkPixbuf * ret = NULL; |     GdkPixbuf *ret = NULL; | ||||||
|     GtkIconTheme *theme; |     GtkIconTheme *theme; | ||||||
|     GtkIconInfo *info; |     GtkIconInfo *info; | ||||||
|     gint width; |     gint width; | ||||||
|  |  | ||||||
|     if (!icon) |     if (!icon) | ||||||
|  |     { | ||||||
|         return NULL; |         return NULL; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     theme = gtk_icon_theme_get_default (); |     theme = gtk_icon_theme_get_default (); | ||||||
|     gtk_icon_size_lookup (size, &width, NULL); |     gtk_icon_size_lookup (size, &width, NULL); | ||||||
|  |  | ||||||
| 	info = gtk_icon_theme_lookup_by_gicon (theme, |     info = gtk_icon_theme_lookup_by_gicon (theme, icon, width, GTK_ICON_LOOKUP_USE_BUILTIN); | ||||||
| 					       icon, |  | ||||||
| 					       width, |  | ||||||
| 					       GTK_ICON_LOOKUP_USE_BUILTIN); |  | ||||||
|  |  | ||||||
|     if (!info) |     if (!info) | ||||||
|  |     { | ||||||
|         return NULL; |         return NULL; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     ret = gtk_icon_info_load_icon (info, NULL); |     ret = gtk_icon_info_load_icon (info, NULL); | ||||||
|     gtk_icon_info_free (info); |     gtk_icon_info_free (info); | ||||||
| @@ -100,25 +100,25 @@ xed_file_browser_utils_pixbuf_from_icon (GIcon * icon, | |||||||
| } | } | ||||||
|  |  | ||||||
| GdkPixbuf * | GdkPixbuf * | ||||||
| xed_file_browser_utils_pixbuf_from_file (GFile * file, | xed_file_browser_utils_pixbuf_from_file (GFile       *file, | ||||||
|                                          GtkIconSize  size) |                                          GtkIconSize  size) | ||||||
| { | { | ||||||
| 	GIcon * icon; |     GIcon *icon; | ||||||
| 	GFileInfo * info; |     GFileInfo *info; | ||||||
| 	GdkPixbuf * ret = NULL; |     GdkPixbuf *ret = NULL; | ||||||
|  |  | ||||||
| 	info = g_file_query_info (file, |     info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_ICON, G_FILE_QUERY_INFO_NONE, NULL, NULL); | ||||||
| 				  G_FILE_ATTRIBUTE_STANDARD_ICON, |  | ||||||
| 				  G_FILE_QUERY_INFO_NONE, |  | ||||||
| 				  NULL, |  | ||||||
| 				  NULL); |  | ||||||
|  |  | ||||||
|     if (!info) |     if (!info) | ||||||
|  |     { | ||||||
|         return NULL; |         return NULL; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     icon = g_file_info_get_icon (info); |     icon = g_file_info_get_icon (info); | ||||||
|     if (icon != NULL) |     if (icon != NULL) | ||||||
|  |     { | ||||||
|         ret = xed_file_browser_utils_pixbuf_from_icon (icon, size); |         ret = xed_file_browser_utils_pixbuf_from_icon (icon, size); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     g_object_unref (info); |     g_object_unref (info); | ||||||
|  |  | ||||||
| @@ -126,22 +126,20 @@ xed_file_browser_utils_pixbuf_from_file (GFile * file, | |||||||
| } | } | ||||||
|  |  | ||||||
| gchar * | gchar * | ||||||
| xed_file_browser_utils_file_basename (GFile * file) | xed_file_browser_utils_file_basename (GFile *file) | ||||||
| { | { | ||||||
|     return xed_utils_basename_for_display (file); |     return xed_utils_basename_for_display (file); | ||||||
| } | } | ||||||
|  |  | ||||||
| gboolean | gboolean | ||||||
| xed_file_browser_utils_confirmation_dialog (XedWindow * window, | xed_file_browser_utils_confirmation_dialog (XedWindow      *window, | ||||||
|                                             GtkMessageType  type, |                                             GtkMessageType  type, | ||||||
|                                             gchar const    *message, |                                             gchar const    *message, | ||||||
|                                             gchar const    *secondary, |                                             gchar const    *secondary, | ||||||
| 		                              gchar const * button_stock, |                                             gchar const    *button_label) | ||||||
| 		                              gchar const * button_label) |  | ||||||
| { | { | ||||||
|     GtkWidget *dlg; |     GtkWidget *dlg; | ||||||
|     gint ret; |     gint ret; | ||||||
| 	GtkWidget *button; |  | ||||||
|  |  | ||||||
|     dlg = gtk_message_dialog_new (GTK_WINDOW (window), |     dlg = gtk_message_dialog_new (GTK_WINDOW (window), | ||||||
|                                   GTK_DIALOG_MODAL | |                                   GTK_DIALOG_MODAL | | ||||||
| @@ -150,36 +148,19 @@ xed_file_browser_utils_confirmation_dialog (XedWindow * window, | |||||||
|                                   GTK_BUTTONS_NONE, "%s", message); |                                   GTK_BUTTONS_NONE, "%s", message); | ||||||
|  |  | ||||||
|     if (secondary) |     if (secondary) | ||||||
| 		gtk_message_dialog_format_secondary_text |     { | ||||||
| 		    (GTK_MESSAGE_DIALOG (dlg), "%s", secondary); |         gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dlg), "%s", secondary); | ||||||
|  |  | ||||||
| 	/* Add a cancel button */ |  | ||||||
| 	button = gtk_button_new_from_stock (GTK_STOCK_CANCEL); |  | ||||||
| 	gtk_widget_show (button); |  | ||||||
|  |  | ||||||
| 	gtk_widget_set_can_default (button, TRUE); |  | ||||||
| 	gtk_dialog_add_action_widget (GTK_DIALOG (dlg), |  | ||||||
|                                       button, |  | ||||||
|                                       GTK_RESPONSE_CANCEL); |  | ||||||
|  |  | ||||||
| 	/* Add custom button */ |  | ||||||
| 	button = gtk_button_new_from_stock (button_stock); |  | ||||||
|  |  | ||||||
| 	if (button_label) { |  | ||||||
| 		gtk_button_set_use_stock (GTK_BUTTON (button), FALSE); |  | ||||||
| 		gtk_button_set_label (GTK_BUTTON (button), button_label); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
| 	gtk_widget_show (button); |     gtk_dialog_add_buttons (GTK_DIALOG (dlg), | ||||||
| 	gtk_widget_set_can_default (button, TRUE); |                             _("_Cancel"), GTK_RESPONSE_CANCEL, | ||||||
| 	gtk_dialog_add_action_widget (GTK_DIALOG (dlg), |                             button_label, GTK_RESPONSE_OK, | ||||||
|                                       button, |                             NULL); | ||||||
|                                       GTK_RESPONSE_OK); |  | ||||||
|  |     gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_RESPONSE_CANCEL); | ||||||
|  |  | ||||||
|     ret = gtk_dialog_run (GTK_DIALOG (dlg)); |     ret = gtk_dialog_run (GTK_DIALOG (dlg)); | ||||||
|     gtk_widget_destroy (dlg); |     gtk_widget_destroy (dlg); | ||||||
|  |  | ||||||
|     return (ret == GTK_RESPONSE_OK); |     return (ret == GTK_RESPONSE_OK); | ||||||
| } | } | ||||||
|  |  | ||||||
| // ex:ts=8:noet: |  | ||||||
|   | |||||||
| @@ -7,19 +7,18 @@ | |||||||
| GdkPixbuf *xed_file_browser_utils_pixbuf_from_theme (gchar const *name, | GdkPixbuf *xed_file_browser_utils_pixbuf_from_theme (gchar const *name, | ||||||
|                                                      GtkIconSize  size); |                                                      GtkIconSize  size); | ||||||
|  |  | ||||||
| GdkPixbuf *xed_file_browser_utils_pixbuf_from_icon	  (GIcon * icon, | GdkPixbuf *xed_file_browser_utils_pixbuf_from_icon (GIcon       *icon, | ||||||
|                                                     GtkIconSize  size); |                                                     GtkIconSize  size); | ||||||
| GdkPixbuf *xed_file_browser_utils_pixbuf_from_file	  (GFile * file, | GdkPixbuf *xed_file_browser_utils_pixbuf_from_file (GFile       *file, | ||||||
|                                                     GtkIconSize  size); |                                                     GtkIconSize  size); | ||||||
|  |  | ||||||
| gchar * xed_file_browser_utils_file_basename		  (GFile * file); | gchar * xed_file_browser_utils_file_basename (GFile *file); | ||||||
|  |  | ||||||
| gboolean xed_file_browser_utils_confirmation_dialog     (XedWindow * window, | gboolean xed_file_browser_utils_confirmation_dialog (XedWindow      *window, | ||||||
|                                                      GtkMessageType  type, |                                                      GtkMessageType  type, | ||||||
|                                                      gchar const    *message, |                                                      gchar const    *message, | ||||||
|                                                      gchar const    *secondary, |                                                      gchar const    *secondary, | ||||||
| 		                                           gchar const * button_stock, |                                                      gchar const    *button_label); | ||||||
| 		                                           gchar const * button_label); |  | ||||||
|  |  | ||||||
| #endif /* __XED_FILE_BROWSER_UTILS_H__ */ | #endif /* __XED_FILE_BROWSER_UTILS_H__ */ | ||||||
|  |  | ||||||
|   | |||||||
| @@ -44,8 +44,6 @@ struct _XedFileBrowserViewPrivate | |||||||
|     GtkTreeModel *model; |     GtkTreeModel *model; | ||||||
|     GtkTreeRowReference *editable; |     GtkTreeRowReference *editable; | ||||||
|  |  | ||||||
|     GdkCursor *busy_cursor; |  | ||||||
|  |  | ||||||
|     /* CLick policy */ |     /* CLick policy */ | ||||||
|     XedFileBrowserViewClickPolicy click_policy; |     XedFileBrowserViewClickPolicy click_policy; | ||||||
|     GtkTreePath *double_click_path[2]; /* Both clicks in a double click need to be on the same row */ |     GtkTreePath *double_click_path[2]; /* Both clicks in a double click need to be on the same row */ | ||||||
| @@ -128,8 +126,6 @@ xed_file_browser_view_finalize (GObject *object) | |||||||
|         obj->priv->expand_state = NULL; |         obj->priv->expand_state = NULL; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     g_object_unref (obj->priv->busy_cursor); |  | ||||||
|  |  | ||||||
|     G_OBJECT_CLASS (xed_file_browser_view_parent_class)->finalize (object); |     G_OBJECT_CLASS (xed_file_browser_view_parent_class)->finalize (object); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -169,7 +165,6 @@ row_expanded (GtkTreeView *tree_view, | |||||||
|               GtkTreePath *path) |               GtkTreePath *path) | ||||||
| { | { | ||||||
|     XedFileBrowserView *view = XED_FILE_BROWSER_VIEW (tree_view); |     XedFileBrowserView *view = XED_FILE_BROWSER_VIEW (tree_view); | ||||||
|     GFile *location; |  | ||||||
|  |  | ||||||
|     if (GTK_TREE_VIEW_CLASS (xed_file_browser_view_parent_class)->row_expanded) |     if (GTK_TREE_VIEW_CLASS (xed_file_browser_view_parent_class)->row_expanded) | ||||||
|     { |     { | ||||||
| @@ -183,9 +178,16 @@ row_expanded (GtkTreeView *tree_view, | |||||||
|  |  | ||||||
|     if (view->priv->restore_expand_state) |     if (view->priv->restore_expand_state) | ||||||
|     { |     { | ||||||
|  |         GFile *location; | ||||||
|  |  | ||||||
|         gtk_tree_model_get (view->priv->model, iter, XED_FILE_BROWSER_STORE_COLUMN_LOCATION, &location, -1); |         gtk_tree_model_get (view->priv->model, iter, XED_FILE_BROWSER_STORE_COLUMN_LOCATION, &location, -1); | ||||||
|  |  | ||||||
|         add_expand_state (view, location); |         add_expand_state (view, location); | ||||||
|  |  | ||||||
|  |         if (location) | ||||||
|  |         { | ||||||
|  |             g_object_unref (location); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     _xed_file_browser_store_iter_expanded (XED_FILE_BROWSER_STORE (view->priv->model), iter); |     _xed_file_browser_store_iter_expanded (XED_FILE_BROWSER_STORE (view->priv->model), iter); | ||||||
| @@ -197,7 +199,6 @@ row_collapsed (GtkTreeView *tree_view, | |||||||
|                GtkTreePath *path) |                GtkTreePath *path) | ||||||
| { | { | ||||||
|     XedFileBrowserView *view = XED_FILE_BROWSER_VIEW (tree_view); |     XedFileBrowserView *view = XED_FILE_BROWSER_VIEW (tree_view); | ||||||
|     GFile *location; |  | ||||||
|  |  | ||||||
|     if (GTK_TREE_VIEW_CLASS (xed_file_browser_view_parent_class)->row_collapsed) |     if (GTK_TREE_VIEW_CLASS (xed_file_browser_view_parent_class)->row_collapsed) | ||||||
|     { |     { | ||||||
| @@ -211,9 +212,16 @@ row_collapsed (GtkTreeView *tree_view, | |||||||
|  |  | ||||||
|     if (view->priv->restore_expand_state) |     if (view->priv->restore_expand_state) | ||||||
|     { |     { | ||||||
|  |         GFile *location; | ||||||
|  |  | ||||||
|         gtk_tree_model_get (view->priv->model, iter, XED_FILE_BROWSER_STORE_COLUMN_LOCATION, &location, -1); |         gtk_tree_model_get (view->priv->model, iter, XED_FILE_BROWSER_STORE_COLUMN_LOCATION, &location, -1); | ||||||
|  |  | ||||||
|         remove_expand_state (view, location); |         remove_expand_state (view, location); | ||||||
|  |  | ||||||
|  |         if (location) | ||||||
|  |         { | ||||||
|  |             g_object_unref (location); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     _xed_file_browser_store_iter_collapsed (XED_FILE_BROWSER_STORE (view->priv->model), iter); |     _xed_file_browser_store_iter_collapsed (XED_FILE_BROWSER_STORE (view->priv->model), iter); | ||||||
| @@ -436,6 +444,20 @@ activate_selected_items (XedFileBrowserView *view) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | static void | ||||||
|  | row_activated (GtkTreeView       *tree_view, | ||||||
|  |                GtkTreePath       *path, | ||||||
|  |                GtkTreeViewColumn *column) | ||||||
|  | { | ||||||
|  |     GtkTreeSelection *selection = gtk_tree_view_get_selection (tree_view); | ||||||
|  |  | ||||||
|  |     /* Make sure the activated row is the only one selected */ | ||||||
|  |     gtk_tree_selection_unselect_all (selection); | ||||||
|  |     gtk_tree_selection_select_path (selection, path); | ||||||
|  |  | ||||||
|  |     activate_selected_items (XED_FILE_BROWSER_VIEW (tree_view)); | ||||||
|  | } | ||||||
|  |  | ||||||
| static void | static void | ||||||
| toggle_hidden_filter (XedFileBrowserView *view) | toggle_hidden_filter (XedFileBrowserView *view) | ||||||
| { | { | ||||||
| @@ -751,7 +773,6 @@ fill_expand_state (XedFileBrowserView *view, | |||||||
| { | { | ||||||
|     GtkTreePath * path; |     GtkTreePath * path; | ||||||
|     GtkTreeIter child; |     GtkTreeIter child; | ||||||
|     GFile *location; |  | ||||||
|  |  | ||||||
|     if (!gtk_tree_model_iter_has_child (view->priv->model, iter)) |     if (!gtk_tree_model_iter_has_child (view->priv->model, iter)) | ||||||
|     { |     { | ||||||
| @@ -762,6 +783,8 @@ fill_expand_state (XedFileBrowserView *view, | |||||||
|  |  | ||||||
|     if (gtk_tree_view_row_expanded (GTK_TREE_VIEW (view), path)) |     if (gtk_tree_view_row_expanded (GTK_TREE_VIEW (view), path)) | ||||||
|     { |     { | ||||||
|  |         GFile *location; | ||||||
|  |  | ||||||
|         gtk_tree_model_get (view->priv->model, |         gtk_tree_model_get (view->priv->model, | ||||||
|                             iter, |                             iter, | ||||||
|                             XED_FILE_BROWSER_STORE_COLUMN_LOCATION, |                             XED_FILE_BROWSER_STORE_COLUMN_LOCATION, | ||||||
| @@ -769,6 +792,11 @@ fill_expand_state (XedFileBrowserView *view, | |||||||
|                             -1); |                             -1); | ||||||
|  |  | ||||||
|         add_expand_state (view, location); |         add_expand_state (view, location); | ||||||
|  |  | ||||||
|  |         if (location) | ||||||
|  |         { | ||||||
|  |             g_object_unref (location); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (gtk_tree_model_iter_children (view->priv->model, &child, iter)) |     if (gtk_tree_model_iter_children (view->priv->model, &child, iter)) | ||||||
| @@ -908,6 +936,7 @@ xed_file_browser_view_class_init (XedFileBrowserViewClass *klass) | |||||||
|     widget_class->key_press_event = key_press_event; |     widget_class->key_press_event = key_press_event; | ||||||
|  |  | ||||||
|     /* Tree view handlers */ |     /* Tree view handlers */ | ||||||
|  |     tree_view_class->row_activated = row_activated; | ||||||
|     tree_view_class->row_expanded = row_expanded; |     tree_view_class->row_expanded = row_expanded; | ||||||
|     tree_view_class->row_collapsed = row_collapsed; |     tree_view_class->row_collapsed = row_collapsed; | ||||||
|  |  | ||||||
| @@ -1038,8 +1067,6 @@ xed_file_browser_view_init (XedFileBrowserView *obj) | |||||||
|                                             drag_source_targets, |                                             drag_source_targets, | ||||||
|                                             G_N_ELEMENTS (drag_source_targets), |                                             G_N_ELEMENTS (drag_source_targets), | ||||||
|                                             GDK_ACTION_COPY); |                                             GDK_ACTION_COPY); | ||||||
|  |  | ||||||
|     obj->priv->busy_cursor = gdk_cursor_new (GDK_WATCH); |  | ||||||
| } | } | ||||||
|  |  | ||||||
| static gboolean | static gboolean | ||||||
| @@ -1275,7 +1302,6 @@ restore_expand_state (XedFileBrowserView  *view, | |||||||
|                       GtkTreeIter         *iter) |                       GtkTreeIter         *iter) | ||||||
| { | { | ||||||
|     GFile *location; |     GFile *location; | ||||||
|     GtkTreePath *path; |  | ||||||
|  |  | ||||||
|     gtk_tree_model_get (GTK_TREE_MODEL (model), |     gtk_tree_model_get (GTK_TREE_MODEL (model), | ||||||
|                         iter, |                         iter, | ||||||
| @@ -1283,10 +1309,9 @@ restore_expand_state (XedFileBrowserView  *view, | |||||||
|                         &location, |                         &location, | ||||||
|                         -1); |                         -1); | ||||||
|  |  | ||||||
|     if (!location) |     if (location) | ||||||
|     { |     { | ||||||
|         return; |         GtkTreePath *path; | ||||||
|     } |  | ||||||
|  |  | ||||||
|         path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), iter); |         path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), iter); | ||||||
|  |  | ||||||
| @@ -1296,6 +1321,8 @@ restore_expand_state (XedFileBrowserView  *view, | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         gtk_tree_path_free (path); |         gtk_tree_path_free (path); | ||||||
|  |         g_object_unref (location); | ||||||
|  |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void | ||||||
|   | |||||||
| @@ -1,14 +1,9 @@ | |||||||
| <ui> | <ui> | ||||||
|   <toolbar name="ToolBar"> |   <toolbar name="ToolBar"> | ||||||
|     <placeholder name="Tool_Opt1"/> |     <toolitem action="DirectoryPrevious"/> | ||||||
|  |     <toolitem action="DirectoryNext"/> | ||||||
|     <toolitem action="DirectoryUp"/> |     <toolitem action="DirectoryUp"/> | ||||||
|     <separator/> |  | ||||||
|     <toolitem action="DirectoryRefresh"/> |  | ||||||
|     <separator/> |  | ||||||
|     <placeholder name="Tool_Opt2"/> |     <placeholder name="Tool_Opt2"/> | ||||||
|     <separator/> |  | ||||||
|     <toolitem action="FilterHidden"/> |  | ||||||
|     <separator/> |  | ||||||
|     <placeholder name="Tool_Opt3"/> |     <placeholder name="Tool_Opt3"/> | ||||||
|   </toolbar> |   </toolbar> | ||||||
|  |  | ||||||
|   | |||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Reference in New Issue
	
	Block a user