| @@ -16,6 +16,11 @@ | ||||
|       <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> | ||||
|     </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"/> | ||||
|   </schema> | ||||
|   <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); | ||||
|     } | ||||
|  | ||||
|     path = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP); | ||||
|     if (path != NULL) | ||||
|     { | ||||
|         file = g_file_new_for_path (path); | ||||
|         add_file (model, file, NULL, XED_FILE_BOOKMARKS_STORE_IS_DESKTOP | | ||||
|                                      XED_FILE_BOOKMARKS_STORE_IS_SPECIAL_DIR, NULL); | ||||
|         g_object_unref (file); | ||||
|     } | ||||
|     // path = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP); | ||||
|     // if (path != NULL) | ||||
|     // { | ||||
|     //     file = g_file_new_for_path (path); | ||||
|     //     add_file (model, file, NULL, XED_FILE_BOOKMARKS_STORE_IS_DESKTOP | | ||||
|     //                                  XED_FILE_BOOKMARKS_STORE_IS_SPECIAL_DIR, NULL); | ||||
|     //     g_object_unref (file); | ||||
|     // } | ||||
|  | ||||
|     path = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS); | ||||
|     if (path != NULL) | ||||
|     { | ||||
|         file = g_file_new_for_path (path); | ||||
|         add_file (model, file, NULL, XED_FILE_BOOKMARKS_STORE_IS_DOCUMENTS | | ||||
|                                      XED_FILE_BOOKMARKS_STORE_IS_SPECIAL_DIR, NULL); | ||||
|         g_object_unref (file); | ||||
|     } | ||||
|     // path = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS); | ||||
|     // if (path != NULL) | ||||
|     // { | ||||
|     //     file = g_file_new_for_path (path); | ||||
|     //     add_file (model, file, NULL, XED_FILE_BOOKMARKS_STORE_IS_DOCUMENTS | | ||||
|     //                                  XED_FILE_BOOKMARKS_STORE_IS_SPECIAL_DIR, NULL); | ||||
|     //     g_object_unref (file); | ||||
|     // } | ||||
|  | ||||
|     file = g_file_new_for_uri ("file:///"); | ||||
|     add_file (model, file, _("File System"), XED_FILE_BOOKMARKS_STORE_IS_ROOT, NULL); | ||||
| @@ -514,75 +514,106 @@ add_bookmark (XedFileBookmarksStore * model, | ||||
|     return ret; | ||||
| } | ||||
|  | ||||
| static void | ||||
| init_bookmarks (XedFileBookmarksStore * model) | ||||
| static gchar * | ||||
| 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; | ||||
|     gchar *contents; | ||||
|     gchar **lines; | ||||
|     gchar **line; | ||||
|     gboolean added = FALSE; | ||||
|  | ||||
|     /* Read the bookmarks file */ | ||||
|     bookmarks = g_build_filename (g_get_home_dir (), ".gtk-bookmarks", NULL); | ||||
|  | ||||
|     if (g_file_get_contents (bookmarks, &contents, NULL, &error)) | ||||
|     { | ||||
|         lines = g_strsplit (contents, "\n", 0); | ||||
|  | ||||
|         for (line = lines; *line; ++line) | ||||
|         { | ||||
|             if (**line) | ||||
|             { | ||||
|                 GFile *location; | ||||
|                 gchar *pos; | ||||
|                 gchar *name; | ||||
|  | ||||
|                 /* CHECK: is this really utf8? */ | ||||
|                 pos = g_utf8_strchr (*line, -1, ' '); | ||||
|  | ||||
|                 if (pos != NULL) | ||||
|                 { | ||||
|                     *pos = '\0'; | ||||
|                     name = pos + 1; | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     name = NULL; | ||||
|                 } | ||||
|  | ||||
|                 /* the bookmarks file should contain valid | ||||
|                  * URIs, but paranoia is good */ | ||||
|                 location = g_file_new_for_uri (*line); | ||||
|                 if (xed_utils_is_valid_location (location)) | ||||
|                 { | ||||
|                     added |= add_bookmark (model, name, *line); | ||||
|                 } | ||||
|                 g_object_unref (location); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         g_strfreev (lines); | ||||
|         g_free (contents); | ||||
|  | ||||
|         /* Add a watch */ | ||||
|         if (model->priv->bookmarks_monitor == NULL) | ||||
|         { | ||||
|             GFile * file; | ||||
|  | ||||
|             file = g_file_new_for_path (bookmarks); | ||||
|             model->priv->bookmarks_monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, NULL); | ||||
|             g_object_unref (file); | ||||
|  | ||||
|             g_signal_connect (model->priv->bookmarks_monitor, "changed", | ||||
|                               (GCallback)on_bookmarks_file_changed, model); | ||||
|         } | ||||
|     } | ||||
|     else | ||||
|     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); | ||||
|  | ||||
|     for (line = lines; *line; ++line) | ||||
|     { | ||||
|         if (**line) | ||||
|         { | ||||
|             GFile *location; | ||||
|  | ||||
|             gchar *pos; | ||||
|             gchar *name; | ||||
|  | ||||
|             /* CHECK: is this really utf8? */ | ||||
|             pos = g_utf8_strchr (*line, -1, ' '); | ||||
|  | ||||
|             if (pos != NULL) | ||||
|             { | ||||
|                 *pos = '\0'; | ||||
|                 name = pos + 1; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 name = NULL; | ||||
|             } | ||||
|  | ||||
|             /* the bookmarks file should contain valid | ||||
|             * URIs, but paranoia is good */ | ||||
|             location = g_file_new_for_uri (*line); | ||||
|             if (xed_utils_is_valid_location (location)) | ||||
|             { | ||||
|                 *added |= add_bookmark (model, name, *line); | ||||
|             } | ||||
|             g_object_unref (location); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     g_strfreev (lines); | ||||
|     g_free (contents); | ||||
|  | ||||
|     /* Add a watch */ | ||||
|     if (model->priv->bookmarks_monitor == NULL) | ||||
|     { | ||||
|         GFile * file; | ||||
|  | ||||
|         file = g_file_new_for_path (bookmarks); | ||||
|         model->priv->bookmarks_monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, NULL); | ||||
|         g_object_unref (file); | ||||
|  | ||||
|         g_signal_connect (model->priv->bookmarks_monitor, "changed", | ||||
|                           G_CALLBACK (on_bookmarks_file_changed), model); | ||||
|     } | ||||
|  | ||||
|     return TRUE; | ||||
| } | ||||
|  | ||||
| static void | ||||
| init_bookmarks (XedFileBookmarksStore *model) | ||||
| { | ||||
|     gchar *bookmarks; | ||||
|     gboolean added = FALSE; | ||||
|  | ||||
|     bookmarks = get_bookmarks_file (); | ||||
|  | ||||
|     if (!parse_bookmarks_file (model, bookmarks, &added)) | ||||
|     { | ||||
|         g_free (bookmarks); | ||||
|  | ||||
|         /* try the old location (gtk <= 3.4) */ | ||||
|         bookmarks = get_legacy_bookmarks_file (); | ||||
|         parse_bookmarks_file (model, bookmarks, &added); | ||||
|     } | ||||
|  | ||||
|     if (added) | ||||
|   | ||||
| @@ -2,8 +2,8 @@ | ||||
| #include "xed-file-browser-store.h" | ||||
| #include <xed/xed-message.h> | ||||
|  | ||||
| #define MESSAGE_OBJECT_PATH     "/plugins/filebrowser" | ||||
| #define WINDOW_DATA_KEY         "XedFileBrowserMessagesWindowData" | ||||
| #define MESSAGE_OBJECT_PATH "/plugins/filebrowser" | ||||
| #define WINDOW_DATA_KEY     "XedFileBrowserMessagesWindowData" | ||||
|  | ||||
| #define BUS_CONNECT(bus, name, data) xed_message_bus_connect(bus, MESSAGE_OBJECT_PATH, #name, (XedMessageCallback)  message_##name##_cb, data, NULL) | ||||
|  | ||||
| @@ -41,7 +41,7 @@ typedef struct | ||||
|  | ||||
| static WindowData * | ||||
| window_data_new (XedWindow            *window, | ||||
|          XedFileBrowserWidget *widget) | ||||
|                  XedFileBrowserWidget *widget) | ||||
| { | ||||
|     WindowData *data = g_slice_new (WindowData); | ||||
|     GtkUIManager *manager; | ||||
| @@ -50,14 +50,14 @@ window_data_new (XedWindow            *window, | ||||
|     data->bus = xed_window_get_message_bus (window); | ||||
|     data->widget = widget; | ||||
|     data->row_tracking = g_hash_table_new_full (g_str_hash, | ||||
|                             g_str_equal, | ||||
|                             (GDestroyNotify)g_free, | ||||
|                             (GDestroyNotify)gtk_tree_row_reference_free); | ||||
|                                                 g_str_equal, | ||||
|                                                 (GDestroyNotify)g_free, | ||||
|                                                 (GDestroyNotify)gtk_tree_row_reference_free); | ||||
|  | ||||
|     data->filters = g_hash_table_new_full (g_str_hash, | ||||
|                            g_str_equal, | ||||
|                            (GDestroyNotify)g_free, | ||||
|                            NULL); | ||||
|                                            g_str_equal, | ||||
|                                            (GDestroyNotify)g_free, | ||||
|                                            NULL); | ||||
|  | ||||
|     manager = xed_file_browser_widget_get_ui_manager (widget); | ||||
|  | ||||
| @@ -92,7 +92,9 @@ window_data_free (XedWindow *window) | ||||
|     gtk_ui_manager_remove_action_group (manager, data->merged_actions); | ||||
|  | ||||
|     for (item = data->merge_ids; item; item = item->next) | ||||
|     { | ||||
|         gtk_ui_manager_remove_ui (manager, GPOINTER_TO_INT (item->data)); | ||||
|     } | ||||
|  | ||||
|     g_list_free (data->merge_ids); | ||||
|     g_object_unref (data->merged_actions); | ||||
| @@ -104,7 +106,7 @@ window_data_free (XedWindow *window) | ||||
|  | ||||
| static FilterData * | ||||
| filter_data_new (XedWindow  *window, | ||||
|          XedMessage *message) | ||||
|                  XedMessage *message) | ||||
| { | ||||
|     FilterData *data = g_slice_new (FilterData); | ||||
|     WindowData *wdata; | ||||
| @@ -115,10 +117,8 @@ filter_data_new (XedWindow  *window, | ||||
|  | ||||
|     wdata = get_window_data (window); | ||||
|  | ||||
|     g_hash_table_insert (wdata->filters, | ||||
|                  xed_message_type_identifier (xed_message_get_object_path (message), | ||||
|                                                 xed_message_get_method (message)), | ||||
|                  data); | ||||
|     g_hash_table_insert (wdata->filters, xed_message_type_identifier (xed_message_get_object_path (message), | ||||
|                                                                       xed_message_get_method (message)), data); | ||||
|  | ||||
|     return data; | ||||
| } | ||||
| @@ -130,7 +130,7 @@ filter_data_free (FilterData *data) | ||||
|     gchar *identifier; | ||||
|  | ||||
|     identifier = xed_message_type_identifier (xed_message_get_object_path (data->message), | ||||
|                                         xed_message_get_method (data->message)); | ||||
|                                               xed_message_get_method (data->message)); | ||||
|  | ||||
|     g_hash_table_remove (wdata->filters, identifier); | ||||
|     g_free (identifier); | ||||
| @@ -141,14 +141,16 @@ filter_data_free (FilterData *data) | ||||
|  | ||||
| static GtkTreePath * | ||||
| track_row_lookup (WindowData  *data, | ||||
|           const gchar *id) | ||||
|                   const gchar *id) | ||||
| { | ||||
|     GtkTreeRowReference *ref; | ||||
|  | ||||
|     ref = (GtkTreeRowReference *)g_hash_table_lookup (data->row_tracking, id); | ||||
|  | ||||
|     if (!ref) | ||||
|     { | ||||
|         return NULL; | ||||
|     } | ||||
|  | ||||
|     return gtk_tree_row_reference_get_path (ref); | ||||
| } | ||||
| @@ -161,8 +163,8 @@ message_cache_data_free (MessageCacheData *data) | ||||
| } | ||||
|  | ||||
| static MessageCacheData * | ||||
| message_cache_data_new (XedWindow            *window, | ||||
|             XedMessage           *message) | ||||
| message_cache_data_new (XedWindow  *window, | ||||
|                         XedMessage *message) | ||||
| { | ||||
|     MessageCacheData *data = g_slice_new (MessageCacheData); | ||||
|  | ||||
| @@ -174,8 +176,8 @@ message_cache_data_new (XedWindow            *window, | ||||
|  | ||||
| static void | ||||
| message_get_root_cb (XedMessageBus *bus, | ||||
|              XedMessage    *message, | ||||
|              WindowData      *data) | ||||
|                      XedMessage    *message, | ||||
|                      WindowData    *data) | ||||
| { | ||||
|     XedFileBrowserStore *store; | ||||
|     GFile *location; | ||||
| @@ -192,8 +194,8 @@ message_get_root_cb (XedMessageBus *bus, | ||||
|  | ||||
| static void | ||||
| message_set_root_cb (XedMessageBus *bus, | ||||
|              XedMessage    *message, | ||||
|              WindowData      *data) | ||||
|                      XedMessage    *message, | ||||
|                      WindowData    *data) | ||||
| { | ||||
|     GFile *root; | ||||
|     GFile *virtual = NULL; | ||||
| @@ -201,21 +203,29 @@ message_set_root_cb (XedMessageBus *bus, | ||||
|     xed_message_get (message, "location", &root, NULL); | ||||
|  | ||||
|     if (!root) | ||||
|     { | ||||
|         return; | ||||
|     } | ||||
|  | ||||
|     if (xed_message_has_key (message, "virtual")) | ||||
|     { | ||||
|         xed_message_get (message, "virtual", &virtual, NULL); | ||||
|     } | ||||
|  | ||||
|     if (virtual) | ||||
|     { | ||||
|         xed_file_browser_widget_set_root_and_virtual_root (data->widget, root, virtual); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         xed_file_browser_widget_set_root (data->widget, root, TRUE); | ||||
|     } | ||||
| } | ||||
|  | ||||
| static void | ||||
| message_set_emblem_cb (XedMessageBus *bus, | ||||
|                XedMessage    *message, | ||||
|                WindowData      *data) | ||||
|                        XedMessage    *message, | ||||
|                        WindowData    *data) | ||||
| { | ||||
|     gchar *id = NULL; | ||||
|     gchar *emblem = NULL; | ||||
| @@ -239,11 +249,7 @@ message_set_emblem_cb (XedMessageBus *bus, | ||||
|         GError *error = NULL; | ||||
|         GdkPixbuf *pixbuf; | ||||
|  | ||||
|         pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), | ||||
|                            emblem, | ||||
|                            10, | ||||
|                            0, | ||||
|                            &error); | ||||
|         pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), emblem, 10, 0, &error); | ||||
|  | ||||
|         if (pixbuf) | ||||
|         { | ||||
| @@ -257,10 +263,7 @@ message_set_emblem_cb (XedMessageBus *bus, | ||||
|                 g_value_init (&value, GDK_TYPE_PIXBUF); | ||||
|                 g_value_set_object (&value, pixbuf); | ||||
|  | ||||
|                 xed_file_browser_store_set_value (store, | ||||
|                                     &iter, | ||||
|                                     XED_FILE_BROWSER_STORE_COLUMN_EMBLEM, | ||||
|                                     &value); | ||||
|                 xed_file_browser_store_set_value (store, &iter, XED_FILE_BROWSER_STORE_COLUMN_EMBLEM, &value); | ||||
|  | ||||
|                 g_value_unset (&value); | ||||
|             } | ||||
| @@ -278,7 +281,7 @@ message_set_emblem_cb (XedMessageBus *bus, | ||||
|  | ||||
| static gchar * | ||||
| item_id (const gchar *path, | ||||
|      GFile *location) | ||||
|          GFile       *location) | ||||
| { | ||||
|     gchar *uri; | ||||
|     gchar *id; | ||||
| @@ -291,10 +294,10 @@ item_id (const gchar *path, | ||||
| } | ||||
|  | ||||
| static gchar * | ||||
| track_row (WindowData            *data, | ||||
|        XedFileBrowserStore *store, | ||||
|        GtkTreePath           *path, | ||||
|        GFile               *location) | ||||
| track_row (WindowData          *data, | ||||
|            XedFileBrowserStore *store, | ||||
|            GtkTreePath         *path, | ||||
|            GFile               *location) | ||||
| { | ||||
|     GtkTreeRowReference *ref; | ||||
|     gchar *id; | ||||
| @@ -312,51 +315,51 @@ track_row (WindowData            *data, | ||||
| } | ||||
|  | ||||
| static void | ||||
| set_item_message (WindowData   *data, | ||||
|           GtkTreeIter  *iter, | ||||
|           GtkTreePath  *path, | ||||
|           XedMessage *message) | ||||
| set_item_message (WindowData  *data, | ||||
|                   GtkTreeIter *iter, | ||||
|                   GtkTreePath *path, | ||||
|                   XedMessage  *message) | ||||
| { | ||||
|     XedFileBrowserStore *store; | ||||
|     GFile *location; | ||||
|     guint flags = 0; | ||||
|     gchar *track_id; | ||||
|  | ||||
|     store = xed_file_browser_widget_get_browser_store (data->widget); | ||||
|  | ||||
|     gtk_tree_model_get (GTK_TREE_MODEL (store), iter, | ||||
|                 XED_FILE_BROWSER_STORE_COLUMN_LOCATION, &location, | ||||
|                 XED_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags, | ||||
|                 -1); | ||||
|                         XED_FILE_BROWSER_STORE_COLUMN_LOCATION, &location, | ||||
|                         XED_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags, | ||||
|                         -1); | ||||
|  | ||||
|     if (!location) | ||||
|         return; | ||||
|  | ||||
|     if (path && gtk_tree_path_get_depth (path) != 0) | ||||
|         track_id = track_row (data, store, path, location); | ||||
|     else | ||||
|         track_id = NULL; | ||||
|  | ||||
|     xed_message_set (message, | ||||
|                "id", track_id, | ||||
|                "location", location, | ||||
|                NULL); | ||||
|  | ||||
|     if (xed_message_has_key (message, "is_directory")) | ||||
|     if (location) | ||||
|     { | ||||
|         xed_message_set (message, | ||||
|                    "is_directory", FILE_IS_DIR (flags), | ||||
|                    NULL); | ||||
|     } | ||||
|         gchar *track_id; | ||||
|  | ||||
|     g_free (track_id); | ||||
|         if (path && gtk_tree_path_get_depth (path) != 0) | ||||
|         { | ||||
|             track_id = track_row (data, store, path, location); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             track_id = NULL; | ||||
|         } | ||||
|  | ||||
|         xed_message_set (message, "id", track_id, "location", location, NULL); | ||||
|  | ||||
|         if (xed_message_has_key (message, "is_directory")) | ||||
|         { | ||||
|             xed_message_set (message, "is_directory", FILE_IS_DIR (flags), NULL); | ||||
|         } | ||||
|  | ||||
|         g_free (track_id); | ||||
|         g_object_unref (location); | ||||
|     } | ||||
| } | ||||
|  | ||||
| static gboolean | ||||
| custom_message_filter_func (XedFileBrowserWidget *widget, | ||||
|                 XedFileBrowserStore  *store, | ||||
|                 GtkTreeIter            *iter, | ||||
|                 FilterData             *data) | ||||
|                             XedFileBrowserStore  *store, | ||||
|                             GtkTreeIter          *iter, | ||||
|                             FilterData           *data) | ||||
| { | ||||
|     WindowData *wdata = get_window_data (data->window); | ||||
|     GFile *location; | ||||
| @@ -365,9 +368,9 @@ custom_message_filter_func (XedFileBrowserWidget *widget, | ||||
|     GtkTreePath *path; | ||||
|  | ||||
|     gtk_tree_model_get (GTK_TREE_MODEL (store), iter, | ||||
|                 XED_FILE_BROWSER_STORE_COLUMN_LOCATION, &location, | ||||
|                 XED_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags, | ||||
|                 -1); | ||||
|                         XED_FILE_BROWSER_STORE_COLUMN_LOCATION, &location, | ||||
|                         XED_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags, | ||||
|                         -1); | ||||
|  | ||||
|     if (!location || FILE_IS_DUMMY (flags)) | ||||
|     { | ||||
| @@ -383,13 +386,15 @@ custom_message_filter_func (XedFileBrowserWidget *widget, | ||||
|     xed_message_bus_send_message_sync (wdata->bus, data->message); | ||||
|     xed_message_get (data->message, "filter", &filter, NULL); | ||||
|  | ||||
|     g_object_unref (location); | ||||
|  | ||||
|     return !filter; | ||||
| } | ||||
|  | ||||
| static void | ||||
| message_add_filter_cb (XedMessageBus *bus, | ||||
|                XedMessage    *message, | ||||
|                XedWindow     *window) | ||||
|                        XedMessage    *message, | ||||
|                        XedWindow     *window) | ||||
| { | ||||
|     gchar *object_path = NULL; | ||||
|     gchar *method = NULL; | ||||
| @@ -399,10 +404,7 @@ message_add_filter_cb (XedMessageBus *bus, | ||||
|     FilterData *filter_data; | ||||
|     WindowData *data = get_window_data (window); | ||||
|  | ||||
|     xed_message_get (message, | ||||
|                "object_path", &object_path, | ||||
|                "method", &method, | ||||
|                NULL); | ||||
|     xed_message_get (message, "object_path", &object_path, "method", &method, NULL); | ||||
|  | ||||
|     // Check if there exists such a 'callback' message | ||||
|     if (!object_path || !method) | ||||
| @@ -433,41 +435,43 @@ message_add_filter_cb (XedMessageBus *bus, | ||||
|     } | ||||
|  | ||||
|     cbmessage = xed_message_type_instantiate (message_type, | ||||
|                             "id", NULL, | ||||
|                             "location", NULL, | ||||
|                             "is_directory", FALSE, | ||||
|                             "filter", FALSE, | ||||
|                             NULL); | ||||
|                                              "id", NULL, | ||||
|                                              "location", NULL, | ||||
|                                              "is_directory", FALSE, | ||||
|                                              "filter", FALSE, | ||||
|                                              NULL); | ||||
|  | ||||
|     // Register the custom filter on the widget | ||||
|     filter_data = filter_data_new (window, cbmessage); | ||||
|     id = xed_file_browser_widget_add_filter (data->widget, | ||||
|                            (XedFileBrowserWidgetFilterFunc)custom_message_filter_func, | ||||
|                            filter_data, | ||||
|                            (GDestroyNotify)filter_data_free); | ||||
|                                              (XedFileBrowserWidgetFilterFunc)custom_message_filter_func, | ||||
|                                              filter_data, | ||||
|                                              (GDestroyNotify)filter_data_free); | ||||
|  | ||||
|     filter_data->id = id; | ||||
| } | ||||
|  | ||||
| static void | ||||
| message_remove_filter_cb (XedMessageBus *bus, | ||||
|                   XedMessage    *message, | ||||
|                   WindowData      *data) | ||||
|                           XedMessage    *message, | ||||
|                           WindowData    *data) | ||||
| { | ||||
|     gulong id = 0; | ||||
|  | ||||
|     xed_message_get (message, "id", &id, NULL); | ||||
|  | ||||
|     if (!id) | ||||
|     { | ||||
|         return; | ||||
|     } | ||||
|  | ||||
|     xed_file_browser_widget_remove_filter (data->widget, id); | ||||
| } | ||||
|  | ||||
| static void | ||||
| message_up_cb (XedMessageBus *bus, | ||||
|            XedMessage    *message, | ||||
|            WindowData      *data) | ||||
|                XedMessage    *message, | ||||
|                WindowData    *data) | ||||
| { | ||||
|     XedFileBrowserStore *store = xed_file_browser_widget_get_browser_store (data->widget); | ||||
|  | ||||
| @@ -476,32 +480,32 @@ message_up_cb (XedMessageBus *bus, | ||||
|  | ||||
| static void | ||||
| message_history_back_cb (XedMessageBus *bus, | ||||
|                  XedMessage    *message, | ||||
|                  WindowData      *data) | ||||
|                          XedMessage    *message, | ||||
|                          WindowData    *data) | ||||
| { | ||||
|     xed_file_browser_widget_history_back (data->widget); | ||||
| } | ||||
|  | ||||
| static void | ||||
| message_history_forward_cb (XedMessageBus *bus, | ||||
|                     XedMessage    *message, | ||||
|                     WindowData      *data) | ||||
|                             XedMessage    *message, | ||||
|                             WindowData    *data) | ||||
| { | ||||
|     xed_file_browser_widget_history_forward (data->widget); | ||||
| } | ||||
|  | ||||
| static void | ||||
| message_refresh_cb (XedMessageBus *bus, | ||||
|             XedMessage    *message, | ||||
|             WindowData      *data) | ||||
|                     XedMessage    *message, | ||||
|                     WindowData    *data) | ||||
| { | ||||
|     xed_file_browser_widget_refresh (data->widget); | ||||
| } | ||||
|  | ||||
| static void | ||||
| message_set_show_hidden_cb (XedMessageBus *bus, | ||||
|                     XedMessage    *message, | ||||
|                     WindowData      *data) | ||||
|                             XedMessage    *message, | ||||
|                             WindowData    *data) | ||||
| { | ||||
|     gboolean active = FALSE; | ||||
|     XedFileBrowserStore *store; | ||||
| @@ -513,17 +517,21 @@ message_set_show_hidden_cb (XedMessageBus *bus, | ||||
|     mode = xed_file_browser_store_get_filter_mode (store); | ||||
|  | ||||
|     if (active) | ||||
|     { | ||||
|         mode &= ~XED_FILE_BROWSER_STORE_FILTER_MODE_HIDE_HIDDEN; | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         mode |= XED_FILE_BROWSER_STORE_FILTER_MODE_HIDE_HIDDEN; | ||||
|     } | ||||
|  | ||||
|     xed_file_browser_store_set_filter_mode (store, mode); | ||||
| } | ||||
|  | ||||
| static void | ||||
| message_set_show_binary_cb (XedMessageBus *bus, | ||||
|                     XedMessage    *message, | ||||
|                     WindowData      *data) | ||||
|                             XedMessage    *message, | ||||
|                             WindowData    *data) | ||||
| { | ||||
|     gboolean active = FALSE; | ||||
|     XedFileBrowserStore *store; | ||||
| @@ -535,33 +543,37 @@ message_set_show_binary_cb (XedMessageBus *bus, | ||||
|     mode = xed_file_browser_store_get_filter_mode (store); | ||||
|  | ||||
|     if (active) | ||||
|     { | ||||
|         mode &= ~XED_FILE_BROWSER_STORE_FILTER_MODE_HIDE_BINARY; | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         mode |= XED_FILE_BROWSER_STORE_FILTER_MODE_HIDE_BINARY; | ||||
|     } | ||||
|  | ||||
|     xed_file_browser_store_set_filter_mode (store, mode); | ||||
| } | ||||
|  | ||||
| static void | ||||
| message_show_bookmarks_cb (XedMessageBus *bus, | ||||
|                    XedMessage    *message, | ||||
|                    WindowData      *data) | ||||
|                            XedMessage    *message, | ||||
|                            WindowData    *data) | ||||
| { | ||||
|     xed_file_browser_widget_show_bookmarks (data->widget); | ||||
| } | ||||
|  | ||||
| static void | ||||
| message_show_files_cb (XedMessageBus *bus, | ||||
|                XedMessage    *message, | ||||
|                WindowData      *data) | ||||
|                        XedMessage    *message, | ||||
|                        WindowData    *data) | ||||
| { | ||||
|     xed_file_browser_widget_show_files (data->widget); | ||||
| } | ||||
|  | ||||
| static void | ||||
| message_add_context_item_cb (XedMessageBus *bus, | ||||
|                  XedMessage    *message, | ||||
|                  WindowData      *data) | ||||
|                              XedMessage    *message, | ||||
|                              WindowData    *data) | ||||
| { | ||||
|     GtkAction *action = NULL; | ||||
|     gchar *path = NULL; | ||||
| @@ -569,15 +581,14 @@ message_add_context_item_cb (XedMessageBus *bus, | ||||
|     GtkUIManager *manager; | ||||
|     guint merge_id; | ||||
|  | ||||
|     xed_message_get (message, | ||||
|                "action", &action, | ||||
|                "path", &path, | ||||
|                NULL); | ||||
|     xed_message_get (message, "action", &action, "path", &path, NULL); | ||||
|  | ||||
|     if (!action || !path) | ||||
|     { | ||||
|         if (action) | ||||
|         { | ||||
|             g_object_unref (action); | ||||
|         } | ||||
|  | ||||
|         g_free (path); | ||||
|         return; | ||||
| @@ -589,12 +600,12 @@ message_add_context_item_cb (XedMessageBus *bus, | ||||
|     merge_id = gtk_ui_manager_new_merge_id (manager); | ||||
|  | ||||
|     gtk_ui_manager_add_ui (manager, | ||||
|                    merge_id, | ||||
|                    path, | ||||
|                    name, | ||||
|                    gtk_action_get_name (action), | ||||
|                    GTK_UI_MANAGER_AUTO, | ||||
|                    FALSE); | ||||
|                            merge_id, | ||||
|                            path, | ||||
|                            name, | ||||
|                            gtk_action_get_name (action), | ||||
|                            GTK_UI_MANAGER_AUTO, | ||||
|                            FALSE); | ||||
|  | ||||
|     if (gtk_ui_manager_get_widget (manager, path)) | ||||
|     { | ||||
| @@ -613,8 +624,8 @@ message_add_context_item_cb (XedMessageBus *bus, | ||||
|  | ||||
| static void | ||||
| message_remove_context_item_cb (XedMessageBus *bus, | ||||
|                 XedMessage    *message, | ||||
|                 WindowData      *data) | ||||
|                                 XedMessage    *message, | ||||
|                                 WindowData    *data) | ||||
| { | ||||
|     guint merge_id = 0; | ||||
|     GtkUIManager *manager; | ||||
| @@ -622,7 +633,9 @@ message_remove_context_item_cb (XedMessageBus *bus, | ||||
|     xed_message_get (message, "id", &merge_id, NULL); | ||||
|  | ||||
|     if (merge_id == 0) | ||||
|     { | ||||
|         return; | ||||
|     } | ||||
|  | ||||
|     manager = xed_file_browser_widget_get_ui_manager (data->widget); | ||||
|  | ||||
| @@ -632,8 +645,8 @@ message_remove_context_item_cb (XedMessageBus *bus, | ||||
|  | ||||
| static void | ||||
| message_get_view_cb (XedMessageBus *bus, | ||||
|              XedMessage    *message, | ||||
|              WindowData      *data) | ||||
|                      XedMessage    *message, | ||||
|                      WindowData    *data) | ||||
| { | ||||
|     XedFileBrowserView *view; | ||||
|     view = xed_file_browser_widget_get_browser_view (data->widget); | ||||
| @@ -643,59 +656,59 @@ message_get_view_cb (XedMessageBus *bus, | ||||
|  | ||||
| static void | ||||
| register_methods (XedWindow            *window, | ||||
|           XedFileBrowserWidget *widget) | ||||
|                   XedFileBrowserWidget *widget) | ||||
| { | ||||
|     XedMessageBus *bus = xed_window_get_message_bus (window); | ||||
|     WindowData *data = get_window_data (window); | ||||
|  | ||||
|     /* Register method calls */ | ||||
|     xed_message_bus_register (bus, | ||||
|                     MESSAGE_OBJECT_PATH, "get_root", | ||||
|                     1, | ||||
|                     "location", G_TYPE_FILE, | ||||
|                     NULL); | ||||
|                               MESSAGE_OBJECT_PATH, "get_root", | ||||
|                               1, | ||||
|                               "location", G_TYPE_FILE, | ||||
|                               NULL); | ||||
|  | ||||
|     xed_message_bus_register (bus, | ||||
|                     MESSAGE_OBJECT_PATH, "set_root", | ||||
|                     1, | ||||
|                     "location", G_TYPE_FILE, | ||||
|                     "virtual", G_TYPE_STRING, | ||||
|                     NULL); | ||||
|                               MESSAGE_OBJECT_PATH, "set_root", | ||||
|                               1, | ||||
|                               "location", G_TYPE_FILE, | ||||
|                               "virtual", G_TYPE_STRING, | ||||
|                               NULL); | ||||
|  | ||||
|     xed_message_bus_register (bus, | ||||
|                     MESSAGE_OBJECT_PATH, "set_emblem", | ||||
|                     0, | ||||
|                     "id", G_TYPE_STRING, | ||||
|                     "emblem", G_TYPE_STRING, | ||||
|                     NULL); | ||||
|                               MESSAGE_OBJECT_PATH, "set_emblem", | ||||
|                               0, | ||||
|                               "id", G_TYPE_STRING, | ||||
|                               "emblem", G_TYPE_STRING, | ||||
|                               NULL); | ||||
|  | ||||
|     xed_message_bus_register (bus, | ||||
|                     MESSAGE_OBJECT_PATH, "add_filter", | ||||
|                     1, | ||||
|                     "object_path", G_TYPE_STRING, | ||||
|                     "method", G_TYPE_STRING, | ||||
|                     "id", G_TYPE_ULONG, | ||||
|                     NULL); | ||||
|                               MESSAGE_OBJECT_PATH, "add_filter", | ||||
|                               1, | ||||
|                               "object_path", G_TYPE_STRING, | ||||
|                               "method", G_TYPE_STRING, | ||||
|                               "id", G_TYPE_ULONG, | ||||
|                               NULL); | ||||
|  | ||||
|     xed_message_bus_register (bus, | ||||
|                     MESSAGE_OBJECT_PATH, "remove_filter", | ||||
|                     0, | ||||
|                     "id", G_TYPE_ULONG, | ||||
|                     NULL); | ||||
|                               MESSAGE_OBJECT_PATH, "remove_filter", | ||||
|                               0, | ||||
|                               "id", G_TYPE_ULONG, | ||||
|                               NULL); | ||||
|  | ||||
|     xed_message_bus_register (bus, | ||||
|                     MESSAGE_OBJECT_PATH, "add_context_item", | ||||
|                     1, | ||||
|                     "action", GTK_TYPE_ACTION, | ||||
|                     "path", G_TYPE_STRING, | ||||
|                     "id", G_TYPE_UINT, | ||||
|                     NULL); | ||||
|                               MESSAGE_OBJECT_PATH, "add_context_item", | ||||
|                               1, | ||||
|                               "action", GTK_TYPE_ACTION, | ||||
|                               "path", G_TYPE_STRING, | ||||
|                               "id", G_TYPE_UINT, | ||||
|                               NULL); | ||||
|  | ||||
|     xed_message_bus_register (bus, | ||||
|                     MESSAGE_OBJECT_PATH, "remove_context_item", | ||||
|                     0, | ||||
|                     "id", G_TYPE_UINT, | ||||
|                     NULL); | ||||
|                               MESSAGE_OBJECT_PATH, "remove_context_item", | ||||
|                               0, | ||||
|                               "id", G_TYPE_UINT, | ||||
|                               NULL); | ||||
|  | ||||
|     xed_message_bus_register (bus, MESSAGE_OBJECT_PATH, "up", 0, NULL); | ||||
|  | ||||
| @@ -705,24 +718,24 @@ register_methods (XedWindow            *window, | ||||
|     xed_message_bus_register (bus, MESSAGE_OBJECT_PATH, "refresh", 0, NULL); | ||||
|  | ||||
|     xed_message_bus_register (bus, | ||||
|                     MESSAGE_OBJECT_PATH, "set_show_hidden", | ||||
|                     0, | ||||
|                     "active", G_TYPE_BOOLEAN, | ||||
|                     NULL); | ||||
|                               MESSAGE_OBJECT_PATH, "set_show_hidden", | ||||
|                               0, | ||||
|                               "active", G_TYPE_BOOLEAN, | ||||
|                               NULL); | ||||
|     xed_message_bus_register (bus, | ||||
|                     MESSAGE_OBJECT_PATH, "set_show_binary", | ||||
|                     0, | ||||
|                     "active", G_TYPE_BOOLEAN, | ||||
|                     NULL); | ||||
|                               MESSAGE_OBJECT_PATH, "set_show_binary", | ||||
|                               0, | ||||
|                               "active", G_TYPE_BOOLEAN, | ||||
|                               NULL); | ||||
|  | ||||
|     xed_message_bus_register (bus, MESSAGE_OBJECT_PATH, "show_bookmarks", 0, NULL); | ||||
|     xed_message_bus_register (bus, MESSAGE_OBJECT_PATH, "show_files", 0, NULL); | ||||
|  | ||||
|     xed_message_bus_register (bus, | ||||
|                     MESSAGE_OBJECT_PATH, "get_view", | ||||
|                     1, | ||||
|                     "view", XED_TYPE_FILE_BROWSER_VIEW, | ||||
|                     NULL); | ||||
|                               MESSAGE_OBJECT_PATH, "get_view", | ||||
|                               1, | ||||
|                               "view", XED_TYPE_FILE_BROWSER_VIEW, | ||||
|                               NULL); | ||||
|  | ||||
|     BUS_CONNECT (bus, get_root, data); | ||||
|     BUS_CONNECT (bus, set_root, data); | ||||
| @@ -750,15 +763,15 @@ register_methods (XedWindow            *window, | ||||
|  | ||||
| static void | ||||
| store_row_inserted (XedFileBrowserStore *store, | ||||
|             GtkTreePath       *path, | ||||
|             GtkTreeIter           *iter, | ||||
|             MessageCacheData      *data) | ||||
|                     GtkTreePath         *path, | ||||
|                     GtkTreeIter         *iter, | ||||
|                     MessageCacheData    *data) | ||||
| { | ||||
|     guint flags = 0; | ||||
|  | ||||
|     gtk_tree_model_get (GTK_TREE_MODEL (store), iter, | ||||
|                 XED_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags, | ||||
|                 -1); | ||||
|                         XED_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags, | ||||
|                         -1); | ||||
|  | ||||
|     if (!FILE_IS_DUMMY (flags) && !FILE_IS_FILTERED (flags)) | ||||
|     { | ||||
| @@ -771,18 +784,20 @@ store_row_inserted (XedFileBrowserStore *store, | ||||
|  | ||||
| static void | ||||
| store_row_deleted (XedFileBrowserStore *store, | ||||
|            GtkTreePath       *path, | ||||
|            MessageCacheData      *data) | ||||
|                    GtkTreePath         *path, | ||||
|                    MessageCacheData    *data) | ||||
| { | ||||
|     GtkTreeIter iter; | ||||
|     guint flags = 0; | ||||
|  | ||||
|     if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, path)) | ||||
|     { | ||||
|         return; | ||||
|     } | ||||
|  | ||||
|     gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, | ||||
|                 XED_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags, | ||||
|                 -1); | ||||
|                         XED_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags, | ||||
|                         -1); | ||||
|  | ||||
|     if (!FILE_IS_DUMMY (flags) && !FILE_IS_FILTERED (flags)) | ||||
|     { | ||||
| @@ -795,8 +810,8 @@ store_row_deleted (XedFileBrowserStore *store, | ||||
|  | ||||
| static void | ||||
| store_virtual_root_changed (XedFileBrowserStore *store, | ||||
|                 GParamSpec            *spec, | ||||
|                 MessageCacheData      *data) | ||||
|                             GParamSpec          *spec, | ||||
|                             MessageCacheData    *data) | ||||
| { | ||||
|     WindowData *wdata = get_window_data (data->window); | ||||
|     GFile *vroot; | ||||
| @@ -804,11 +819,11 @@ store_virtual_root_changed (XedFileBrowserStore *store, | ||||
|     vroot = xed_file_browser_store_get_virtual_root (store); | ||||
|  | ||||
|     if (!vroot) | ||||
|     { | ||||
|         return; | ||||
|     } | ||||
|  | ||||
|     xed_message_set (data->message, | ||||
|                "location", vroot, | ||||
|                NULL); | ||||
|     xed_message_set (data->message, "location", vroot, NULL); | ||||
|  | ||||
|     xed_message_bus_send_message_sync (wdata->bus, data->message); | ||||
|  | ||||
| @@ -817,8 +832,8 @@ store_virtual_root_changed (XedFileBrowserStore *store, | ||||
|  | ||||
| static void | ||||
| store_begin_loading (XedFileBrowserStore *store, | ||||
|              GtkTreeIter           *iter, | ||||
|              MessageCacheData      *data) | ||||
|                      GtkTreeIter         *iter, | ||||
|                      MessageCacheData    *data) | ||||
| { | ||||
|     GtkTreePath *path; | ||||
|     WindowData *wdata = get_window_data (data->window); | ||||
| @@ -833,8 +848,8 @@ store_begin_loading (XedFileBrowserStore *store, | ||||
|  | ||||
| static void | ||||
| store_end_loading (XedFileBrowserStore *store, | ||||
|            GtkTreeIter           *iter, | ||||
|            MessageCacheData      *data) | ||||
|                    GtkTreeIter         *iter, | ||||
|                    MessageCacheData    *data) | ||||
| { | ||||
|     GtkTreePath *path; | ||||
|     WindowData *wdata = get_window_data (data->window); | ||||
| @@ -849,7 +864,7 @@ store_end_loading (XedFileBrowserStore *store, | ||||
|  | ||||
| static void | ||||
| register_signals (XedWindow            *window, | ||||
|           XedFileBrowserWidget *widget) | ||||
|                   XedFileBrowserWidget *widget) | ||||
| { | ||||
|     XedMessageBus *bus = xed_window_get_message_bus (window); | ||||
|     XedFileBrowserStore *store; | ||||
| @@ -864,141 +879,141 @@ register_signals (XedWindow            *window, | ||||
|  | ||||
|     /* Register signals */ | ||||
|     root_changed_type = xed_message_bus_register (bus, | ||||
|                     MESSAGE_OBJECT_PATH, "root_changed", | ||||
|                     0, | ||||
|                     "id", G_TYPE_STRING, | ||||
|                     "location", G_TYPE_FILE, | ||||
|                     NULL); | ||||
|                                                   MESSAGE_OBJECT_PATH, "root_changed", | ||||
|                                                   0, | ||||
|                                                   "id", G_TYPE_STRING, | ||||
|                                                   "location", G_TYPE_FILE, | ||||
|                                                   NULL); | ||||
|  | ||||
|     begin_loading_type = xed_message_bus_register (bus, | ||||
|                     MESSAGE_OBJECT_PATH, "begin_loading", | ||||
|                     0, | ||||
|                     "id", G_TYPE_STRING, | ||||
|                     "location", G_TYPE_FILE, | ||||
|                     NULL); | ||||
|                                                    MESSAGE_OBJECT_PATH, "begin_loading", | ||||
|                                                    0, | ||||
|                                                    "id", G_TYPE_STRING, | ||||
|                                                    "location", G_TYPE_FILE, | ||||
|                                                    NULL); | ||||
|  | ||||
|     end_loading_type = xed_message_bus_register (bus, | ||||
|                     MESSAGE_OBJECT_PATH, "end_loading", | ||||
|                     0, | ||||
|                     "id", G_TYPE_STRING, | ||||
|                     "location", G_TYPE_FILE, | ||||
|                     NULL); | ||||
|                                                  MESSAGE_OBJECT_PATH, "end_loading", | ||||
|                                                  0, | ||||
|                                                  "id", G_TYPE_STRING, | ||||
|                                                  "location", G_TYPE_FILE, | ||||
|                                                  NULL); | ||||
|  | ||||
|     inserted_type = xed_message_bus_register (bus, | ||||
|                             MESSAGE_OBJECT_PATH, "inserted", | ||||
|                             0, | ||||
|                             "id", G_TYPE_STRING, | ||||
|                             "location", G_TYPE_FILE, | ||||
|                             "is_directory", G_TYPE_BOOLEAN, | ||||
|                             NULL); | ||||
|                                               MESSAGE_OBJECT_PATH, "inserted", | ||||
|                                               0, | ||||
|                                               "id", G_TYPE_STRING, | ||||
|                                               "location", G_TYPE_FILE, | ||||
|                                               "is_directory", G_TYPE_BOOLEAN, | ||||
|                                               NULL); | ||||
|  | ||||
|     deleted_type = xed_message_bus_register (bus, | ||||
|                            MESSAGE_OBJECT_PATH, "deleted", | ||||
|                            0, | ||||
|                            "id", G_TYPE_STRING, | ||||
|                            "location", G_TYPE_FILE, | ||||
|                            "is_directory", G_TYPE_BOOLEAN, | ||||
|                            NULL); | ||||
|                                              MESSAGE_OBJECT_PATH, "deleted", | ||||
|                                              0, | ||||
|                                              "id", G_TYPE_STRING, | ||||
|                                              "location", G_TYPE_FILE, | ||||
|                                              "is_directory", G_TYPE_BOOLEAN, | ||||
|                                              NULL); | ||||
|  | ||||
|     store = xed_file_browser_widget_get_browser_store (widget); | ||||
|  | ||||
|     message = xed_message_type_instantiate (inserted_type, | ||||
|                           "id", NULL, | ||||
|                           "location", NULL, | ||||
|                           "is_directory", FALSE, | ||||
|                           NULL); | ||||
|                                             "id", NULL, | ||||
|                                             "location", NULL, | ||||
|                                             "is_directory", FALSE, | ||||
|                                             NULL); | ||||
|  | ||||
|     data = get_window_data (window); | ||||
|  | ||||
|     data->row_inserted_id = | ||||
|         g_signal_connect_data (store, | ||||
|                        "row-inserted", | ||||
|                        G_CALLBACK (store_row_inserted), | ||||
|                        message_cache_data_new (window, message), | ||||
|                        (GClosureNotify)message_cache_data_free, | ||||
|                        0); | ||||
|                                "row-inserted", | ||||
|                                G_CALLBACK (store_row_inserted), | ||||
|                                message_cache_data_new (window, message), | ||||
|                                (GClosureNotify)message_cache_data_free, | ||||
|                                0); | ||||
|  | ||||
|     message = xed_message_type_instantiate (deleted_type, | ||||
|                           "id", NULL, | ||||
|                           "location", NULL, | ||||
|                           "is_directory", FALSE, | ||||
|                           NULL); | ||||
|                                             "id", NULL, | ||||
|                                             "location", NULL, | ||||
|                                             "is_directory", FALSE, | ||||
|                                             NULL); | ||||
|     data->row_deleted_id = | ||||
|         g_signal_connect_data (store, | ||||
|                        "row-deleted", | ||||
|                        G_CALLBACK (store_row_deleted), | ||||
|                        message_cache_data_new (window, message), | ||||
|                        (GClosureNotify)message_cache_data_free, | ||||
|                        0); | ||||
|                                "row-deleted", | ||||
|                                G_CALLBACK (store_row_deleted), | ||||
|                                message_cache_data_new (window, message), | ||||
|                                (GClosureNotify)message_cache_data_free, | ||||
|                                0); | ||||
|  | ||||
|     message = xed_message_type_instantiate (root_changed_type, | ||||
|                           "id", NULL, | ||||
|                           "location", NULL, | ||||
|                           NULL); | ||||
|                                             "id", NULL, | ||||
|                                             "location", NULL, | ||||
|                                             NULL); | ||||
|     data->root_changed_id = | ||||
|         g_signal_connect_data (store, | ||||
|                        "notify::virtual-root", | ||||
|                        G_CALLBACK (store_virtual_root_changed), | ||||
|                        message_cache_data_new (window, message), | ||||
|                        (GClosureNotify)message_cache_data_free, | ||||
|                        0); | ||||
|                                "notify::virtual-root", | ||||
|                                G_CALLBACK (store_virtual_root_changed), | ||||
|                                message_cache_data_new (window, message), | ||||
|                                (GClosureNotify)message_cache_data_free, | ||||
|                                0); | ||||
|  | ||||
|     message = xed_message_type_instantiate (begin_loading_type, | ||||
|                           "id", NULL, | ||||
|                           "location", NULL, | ||||
|                           NULL); | ||||
|                                             "id", NULL, | ||||
|                                             "location", NULL, | ||||
|                                             NULL); | ||||
|     data->begin_loading_id = | ||||
|         g_signal_connect_data (store, | ||||
|                       "begin_loading", | ||||
|                        G_CALLBACK (store_begin_loading), | ||||
|                        message_cache_data_new (window, message), | ||||
|                        (GClosureNotify)message_cache_data_free, | ||||
|                        0); | ||||
|                                "begin_loading", | ||||
|                                G_CALLBACK (store_begin_loading), | ||||
|                                message_cache_data_new (window, message), | ||||
|                                (GClosureNotify)message_cache_data_free, | ||||
|                                0); | ||||
|  | ||||
|     message = xed_message_type_instantiate (end_loading_type, | ||||
|                           "id", NULL, | ||||
|                           "location", NULL, | ||||
|                           NULL); | ||||
|                                             "id", NULL, | ||||
|                                             "location", NULL, | ||||
|                                             NULL); | ||||
|     data->end_loading_id = | ||||
|         g_signal_connect_data (store, | ||||
|                        "end_loading", | ||||
|                        G_CALLBACK (store_end_loading), | ||||
|                        message_cache_data_new (window, message), | ||||
|                        (GClosureNotify)message_cache_data_free, | ||||
|                        0); | ||||
|                                "end_loading", | ||||
|                                G_CALLBACK (store_end_loading), | ||||
|                                message_cache_data_new (window, message), | ||||
|                                (GClosureNotify)message_cache_data_free, | ||||
|                                0); | ||||
| } | ||||
|  | ||||
| static void | ||||
| message_unregistered (XedMessageBus  *bus, | ||||
|               XedMessageType *message_type, | ||||
|               XedWindow      *window) | ||||
|                       XedMessageType *message_type, | ||||
|                       XedWindow      *window) | ||||
| { | ||||
|     gchar *identifier = xed_message_type_identifier (xed_message_type_get_object_path (message_type), | ||||
|                                xed_message_type_get_method (message_type)); | ||||
|                                                      xed_message_type_get_method (message_type)); | ||||
|     FilterData *data; | ||||
|     WindowData *wdata = get_window_data (window); | ||||
|  | ||||
|     data = g_hash_table_lookup (wdata->filters, identifier); | ||||
|  | ||||
|     if (data) | ||||
|     { | ||||
|         xed_file_browser_widget_remove_filter (wdata->widget, data->id); | ||||
|     } | ||||
|  | ||||
|     g_free (identifier); | ||||
| } | ||||
|  | ||||
| void | ||||
| xed_file_browser_messages_register (XedWindow            *window, | ||||
|                       XedFileBrowserWidget *widget) | ||||
|                                     XedFileBrowserWidget *widget) | ||||
| { | ||||
|     window_data_new (window, widget); | ||||
|  | ||||
|     register_methods (window, widget); | ||||
|     register_signals (window, widget); | ||||
|  | ||||
|     g_signal_connect (xed_window_get_message_bus (window), | ||||
|               "unregistered", | ||||
|               G_CALLBACK (message_unregistered), | ||||
|               window); | ||||
|     g_signal_connect (xed_window_get_message_bus (window), "unregistered", | ||||
|                       G_CALLBACK (message_unregistered), window); | ||||
| } | ||||
|  | ||||
| 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))); | ||||
| } | ||||
|  | ||||
| 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 | ||||
| on_action_open_terminal (GtkAction            *action, | ||||
|                          XedFileBrowserPlugin *plugin) | ||||
| { | ||||
|     XedFileBrowserPluginPrivate *priv = plugin->priv; | ||||
|     gchar *terminal; | ||||
|     gchar *local; | ||||
|     gchar *argv[2]; | ||||
|     GFile *file; | ||||
|  | ||||
|     GtkTreeIter iter; | ||||
| @@ -366,29 +356,31 @@ on_action_open_terminal (GtkAction            *action, | ||||
|     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); | ||||
|  | ||||
|     if (file == NULL) | ||||
|     if (file) | ||||
|     { | ||||
|         return; | ||||
|         gchar *terminal; | ||||
|         gchar *local; | ||||
|         gchar *argv[2]; | ||||
|  | ||||
|         terminal = g_settings_get_string (priv->settings, "terminal-command"); | ||||
|         local = g_file_get_path (file); | ||||
|  | ||||
|         argv[0] = terminal; | ||||
|         argv[1] = NULL; | ||||
|  | ||||
|         g_spawn_async (local, | ||||
|                        argv, | ||||
|                        NULL, | ||||
|                        G_SPAWN_SEARCH_PATH, | ||||
|                        NULL, | ||||
|                        NULL, | ||||
|                        NULL, | ||||
|                        NULL); | ||||
|  | ||||
|         g_free (terminal); | ||||
|         g_free (local); | ||||
|         g_object_unref (file); | ||||
|     } | ||||
|  | ||||
|     terminal = get_terminal (plugin); | ||||
|  | ||||
|     local = g_file_get_path (file); | ||||
|  | ||||
|     argv[0] = terminal; | ||||
|     argv[1] = NULL; | ||||
|  | ||||
|     g_spawn_async (local, | ||||
|                    argv, | ||||
|                    NULL, | ||||
|                    G_SPAWN_SEARCH_PATH, | ||||
|                    NULL, | ||||
|                    NULL, | ||||
|                    NULL, | ||||
|                    NULL); | ||||
|  | ||||
|     g_free (terminal); | ||||
|     g_free (local); | ||||
| } | ||||
|  | ||||
| static void | ||||
| @@ -400,7 +392,6 @@ on_selection_changed_cb (GtkTreeSelection     *selection, | ||||
|     GtkTreeModel *model; | ||||
|     GtkTreeIter iter; | ||||
|     gboolean sensitive; | ||||
|     GFile *location; | ||||
|  | ||||
|     tree_view = GTK_TREE_VIEW (xed_file_browser_widget_get_browser_view (priv->tree_widget)); | ||||
|     model = gtk_tree_view_get_model (tree_view); | ||||
| @@ -414,9 +405,19 @@ on_selection_changed_cb (GtkTreeSelection     *selection, | ||||
|  | ||||
|     if (sensitive) | ||||
|     { | ||||
|         GFile *location; | ||||
|  | ||||
|         gtk_tree_model_get (model, &iter, XED_FILE_BROWSER_STORE_COLUMN_LOCATION, &location, -1); | ||||
|  | ||||
|         sensitive = g_file_has_uri_scheme (location, "file"); | ||||
|         if (location) | ||||
|         { | ||||
|             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); | ||||
| @@ -478,7 +479,7 @@ add_popup_ui (XedFileBrowserPlugin *plugin) | ||||
|     gtk_action_group_add_actions (action_group, | ||||
|                                   extra_single_selection_actions, | ||||
|                                   G_N_ELEMENTS (extra_single_selection_actions), | ||||
|                                   priv->window); | ||||
|                                   plugin); | ||||
|     gtk_ui_manager_insert_action_group (manager, action_group, 0); | ||||
|     priv->single_selection_action_group = action_group; | ||||
|  | ||||
| @@ -927,11 +928,18 @@ get_filename_from_path (GtkTreeModel *model, | ||||
| { | ||||
|     GtkTreeIter iter; | ||||
|     GFile *location; | ||||
|     gchar *ret = NULL; | ||||
|  | ||||
|     gtk_tree_model_get_iter (model, &iter, path); | ||||
|     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 | ||||
| @@ -961,8 +969,7 @@ on_confirm_no_trash_cb (XedFileBrowserWidget *widget, | ||||
|                                                          GTK_MESSAGE_QUESTION, | ||||
|                                                          message, | ||||
|                                                          secondary, | ||||
|                                                          GTK_STOCK_DELETE, | ||||
|                                                          NULL); | ||||
|                                                          _("_Delete")); | ||||
|     g_free (secondary); | ||||
|  | ||||
|     return result; | ||||
| @@ -997,8 +1004,7 @@ on_confirm_delete_cb (XedFileBrowserWidget *widget, | ||||
|                                                          GTK_MESSAGE_QUESTION, | ||||
|                                                          message, | ||||
|                                                          secondary, | ||||
|                                                          GTK_STOCK_DELETE, | ||||
|                                                          NULL); | ||||
|                                                          _("_Delete")); | ||||
|  | ||||
|     g_free (message); | ||||
|  | ||||
|   | ||||
| @@ -104,7 +104,6 @@ struct _FileBrowserNodeDir | ||||
| { | ||||
|     FileBrowserNode node; | ||||
|     GSList *children; | ||||
|     GHashTable *hidden_file_hash; | ||||
|  | ||||
|     GCancellable *cancellable; | ||||
|     GFileMonitor *monitor; | ||||
| @@ -131,12 +130,12 @@ static FileBrowserNode *model_find_node (XedFileBrowserStore *model, | ||||
|                                          FileBrowserNode     *node, | ||||
|                                          GFile               *uri); | ||||
| static void model_remove_node (XedFileBrowserStore *model, | ||||
|                                FileBrowserNode *node, | ||||
|                                GtkTreePath *path, | ||||
|                                gboolean free_nodes); | ||||
|                                FileBrowserNode     *node, | ||||
|                                GtkTreePath         *path, | ||||
|                                gboolean             free_nodes); | ||||
|  | ||||
| static void set_virtual_root_from_node (XedFileBrowserStore *model, | ||||
|                                         FileBrowserNode *node); | ||||
|                                         FileBrowserNode     *node); | ||||
|  | ||||
| static void xed_file_browser_store_iface_init (GtkTreeModelIface *iface); | ||||
| static GtkTreeModelFlags xed_file_browser_store_get_flags (GtkTreeModel *tree_model); | ||||
| @@ -158,42 +157,44 @@ static gboolean xed_file_browser_store_iter_children (GtkTreeModel *tree_model, | ||||
|                                                       GtkTreeIter *iter, | ||||
|                                                       GtkTreeIter *parent); | ||||
| 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, | ||||
|                                  GtkTreeIter * iter); | ||||
| static gboolean xed_file_browser_store_iter_nth_child     (GtkTreeModel * tree_model, | ||||
|                                  GtkTreeIter * iter, | ||||
|                                  GtkTreeIter * parent, | ||||
|                                  gint n); | ||||
| static gboolean xed_file_browser_store_iter_parent        (GtkTreeModel * tree_model, | ||||
|                                  GtkTreeIter * iter, | ||||
|                                  GtkTreeIter * child); | ||||
| static void xed_file_browser_store_row_inserted     (GtkTreeModel * tree_model, | ||||
|                                  GtkTreePath * path, | ||||
|                                  GtkTreeIter * iter); | ||||
|                                                     GtkTreeIter  *iter); | ||||
| static gboolean xed_file_browser_store_iter_nth_child (GtkTreeModel *tree_model, | ||||
|                                                        GtkTreeIter  *iter, | ||||
|                                                        GtkTreeIter  *parent, | ||||
|                                                        gint          n); | ||||
| static gboolean xed_file_browser_store_iter_parent (GtkTreeModel *tree_model, | ||||
|                                                     GtkTreeIter  *iter, | ||||
|                                                     GtkTreeIter  *child); | ||||
| static void xed_file_browser_store_row_inserted (GtkTreeModel *tree_model, | ||||
|                                                  GtkTreePath  *path, | ||||
|                                                  GtkTreeIter  *iter); | ||||
|  | ||||
| static void xed_file_browser_store_drag_source_init       (GtkTreeDragSourceIface * iface); | ||||
| static gboolean xed_file_browser_store_row_draggable      (GtkTreeDragSource * drag_source, | ||||
|                                  GtkTreePath       * path); | ||||
| static gboolean xed_file_browser_store_drag_data_delete   (GtkTreeDragSource * drag_source, | ||||
|                                  GtkTreePath       * path); | ||||
| static gboolean xed_file_browser_store_drag_data_get      (GtkTreeDragSource * drag_source, | ||||
|                                  GtkTreePath       * path, | ||||
|                                  GtkSelectionData  * selection_data); | ||||
| static void xed_file_browser_store_drag_source_init (GtkTreeDragSourceIface *iface); | ||||
| static gboolean xed_file_browser_store_row_draggable (GtkTreeDragSource *drag_source, | ||||
|                                                       GtkTreePath       *path); | ||||
| static gboolean xed_file_browser_store_drag_data_delete (GtkTreeDragSource *drag_source, | ||||
|                                                          GtkTreePath       *path); | ||||
| static gboolean xed_file_browser_store_drag_data_get (GtkTreeDragSource *drag_source, | ||||
|                                                       GtkTreePath       *path, | ||||
|                                                       GtkSelectionData  *selection_data); | ||||
|  | ||||
| static void file_browser_node_free                          (XedFileBrowserStore * model, | ||||
|                                  FileBrowserNode * node); | ||||
| static void model_add_node                                  (XedFileBrowserStore * model, | ||||
|                                  FileBrowserNode * child, | ||||
|                                  FileBrowserNode * parent); | ||||
| static void model_clear                                     (XedFileBrowserStore * model, | ||||
|                                  gboolean free_nodes); | ||||
| static gint model_sort_default                              (FileBrowserNode * node1, | ||||
|                                  FileBrowserNode * node2); | ||||
| static void model_check_dummy                               (XedFileBrowserStore * model, | ||||
|                                  FileBrowserNode * node); | ||||
| static void next_files_async                    (GFileEnumerator * enumerator, | ||||
|                                  AsyncNode * async); | ||||
| static void file_browser_node_free (XedFileBrowserStore *model, | ||||
|                                     FileBrowserNode     *node); | ||||
| static void model_add_node (XedFileBrowserStore *model, | ||||
|                             FileBrowserNode     *child, | ||||
|                             FileBrowserNode     *parent); | ||||
| static void model_clear (XedFileBrowserStore *model, | ||||
|                          gboolean             free_nodes); | ||||
| static gint model_sort_default (FileBrowserNode *node1, | ||||
|                                 FileBrowserNode *node2); | ||||
| static void model_check_dummy (XedFileBrowserStore *model, | ||||
|                                FileBrowserNode     *node); | ||||
| static void next_files_async (GFileEnumerator *enumerator, | ||||
|                               AsyncNode       *async); | ||||
|  | ||||
| static void delete_files (AsyncData *data); | ||||
|  | ||||
| G_DEFINE_DYNAMIC_TYPE_EXTENDED (XedFileBrowserStore, xed_file_browser_store, | ||||
|                                 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); | ||||
|  | ||||
|     g_free (uris[0]); | ||||
|     g_object_unref (location); | ||||
|  | ||||
|     return ret; | ||||
| } | ||||
| @@ -1471,11 +1473,6 @@ file_browser_node_free (XedFileBrowserStore *model, | ||||
|             g_file_monitor_cancel (dir->monitor); | ||||
|             g_object_unref (dir->monitor); | ||||
|         } | ||||
|  | ||||
|         if (dir->hidden_file_hash) | ||||
|         { | ||||
|             g_hash_table_destroy (dir->hidden_file_hash); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     if (node->file) | ||||
| @@ -2082,9 +2079,7 @@ file_browser_node_set_from_info (XedFileBrowserStore *model, | ||||
|                                  GFileInfo           *info, | ||||
|                                  gboolean             isadded) | ||||
| { | ||||
|     FileBrowserNodeDir *dir; | ||||
|     gchar const *content; | ||||
|     gchar const *name; | ||||
|     gboolean free_info = FALSE; | ||||
|     GtkTreePath *path; | ||||
|     gchar *uri; | ||||
| @@ -2114,17 +2109,10 @@ file_browser_node_set_from_info (XedFileBrowserStore *model, | ||||
|         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)) | ||||
|     { | ||||
|         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) | ||||
|     { | ||||
| @@ -2276,15 +2264,17 @@ model_add_nodes_from_files (XedFileBrowserStore *model, | ||||
|             (strcmp (name, ".") == 0 || | ||||
|              strcmp (name, "..") == 0)) | ||||
|         { | ||||
|             g_object_unref (info); | ||||
|             continue; | ||||
|         } | ||||
|  | ||||
|         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); | ||||
|             } | ||||
| @@ -2337,83 +2327,6 @@ model_add_node_from_dir (XedFileBrowserStore *model, | ||||
|     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 | ||||
| on_directory_monitor_event (GFileMonitor      *monitor, | ||||
|                             GFile             *file, | ||||
| @@ -2451,7 +2364,7 @@ async_node_free (AsyncNode *async) | ||||
| { | ||||
|     g_object_unref (async->cancellable); | ||||
|     g_slist_free (async->original_children); | ||||
|     g_free (async); | ||||
|     g_slice_free (AsyncNode, async); | ||||
| } | ||||
|  | ||||
| static void | ||||
| @@ -2469,6 +2382,7 @@ model_iterate_next_files_cb (GFileEnumerator *enumerator, | ||||
|     if (files == NULL) | ||||
|     { | ||||
|         g_file_enumerator_close (enumerator, NULL, NULL); | ||||
|         g_object_unref (enumerator); | ||||
|         async_node_free (async); | ||||
|  | ||||
|         if (!error) | ||||
| @@ -2520,6 +2434,7 @@ model_iterate_next_files_cb (GFileEnumerator *enumerator, | ||||
|     { | ||||
|         /* Check cancel state manually */ | ||||
|         g_file_enumerator_close (enumerator, NULL, NULL); | ||||
|         g_object_unref (enumerator); | ||||
|         async_node_free (async); | ||||
|     } | ||||
|     else | ||||
| @@ -2601,12 +2516,9 @@ model_load_directory (XedFileBrowserStore *model, | ||||
|     node->flags |= XED_FILE_BROWSER_STORE_FLAG_LOADED; | ||||
|     model_begin_loading (model, node); | ||||
|  | ||||
|     /* Read the '.hidden' file first (if any) */ | ||||
|     parse_dot_hidden_file (node); | ||||
|  | ||||
|     dir->cancellable = g_cancellable_new (); | ||||
|  | ||||
|     async = g_new (AsyncNode, 1); | ||||
|     async = g_slice_new (AsyncNode); | ||||
|     async->dir = dir; | ||||
|     async->cancellable = g_object_ref (dir->cancellable); | ||||
|     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->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 | ||||
| @@ -3039,7 +2955,7 @@ model_mount_root (XedFileBrowserStore *model, | ||||
|             /* Try to mount it */ | ||||
|             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->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); | ||||
|     } | ||||
|  | ||||
|     g_free (data); | ||||
|     g_slice_free (AsyncData, data); | ||||
| } | ||||
|  | ||||
| static gboolean | ||||
| @@ -3646,93 +3562,101 @@ emit_no_trash (AsyncData *data) | ||||
|     return ret; | ||||
| } | ||||
|  | ||||
| typedef struct | ||||
| static void | ||||
| delete_file_finished (GFile        *file, | ||||
|                       GAsyncResult *res, | ||||
|                       AsyncData    *data) | ||||
| { | ||||
|     XedFileBrowserStore *model; | ||||
|     GFile *file; | ||||
| } IdleDelete; | ||||
|  | ||||
| static gboolean | ||||
| file_deleted (IdleDelete *data) | ||||
| { | ||||
|     FileBrowserNode *node; | ||||
|     node = model_find_node (data->model, NULL, data->file); | ||||
|  | ||||
|     if (node != NULL) | ||||
|     { | ||||
|         model_remove_node (data->model, node, NULL, TRUE); | ||||
|     } | ||||
|  | ||||
|     return FALSE; | ||||
| } | ||||
|  | ||||
| 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; | ||||
|     } | ||||
|  | ||||
|     /* Move a file to the trash */ | ||||
|     file = G_FILE (data->iter->data); | ||||
|     gboolean ok; | ||||
|  | ||||
|     if (data->trash) | ||||
|     { | ||||
|         ret = g_file_trash (file, cancellable, &error); | ||||
|         ok = g_file_trash_finish (file, res, &error); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         ret = g_file_delete (file, cancellable, &error); | ||||
|         ok = g_file_delete_finish (file, res, &error); | ||||
|     } | ||||
|  | ||||
|     if (ret) | ||||
|     if (ok) | ||||
|     { | ||||
|         delete.model = data->model; | ||||
|         delete.file = file; | ||||
|         /* Remove the file from the model */ | ||||
|         FileBrowserNode *node = model_find_node (data->model, NULL, file); | ||||
|  | ||||
|         /* Remove the file from the model in the main loop */ | ||||
|         g_io_scheduler_job_send_to_mainloop (job, (GSourceFunc)file_deleted, &delete, NULL); | ||||
|         if (node != NULL) | ||||
|         { | ||||
|             model_remove_node (data->model, node, NULL, TRUE); | ||||
|         } | ||||
|  | ||||
|         /* Process the next file */ | ||||
|         data->iter = data->iter->next; | ||||
|     } | ||||
|     else if (!ret && error) | ||||
|     else if (!ok && error != NULL) | ||||
|     { | ||||
|         code = error->code; | ||||
|         gint code = error->code; | ||||
|         g_error_free (error); | ||||
|  | ||||
|         if (data->trash && code == G_IO_ERROR_NOT_SUPPORTED) | ||||
|         { | ||||
|             /* Trash is not supported on this system ... */ | ||||
|             if (g_io_scheduler_job_send_to_mainloop (job, (GSourceFunc)emit_no_trash, data, NULL)) | ||||
|             /* Trash is not supported on this system. Ask the user | ||||
|              * if he wants to delete completely the files instead. | ||||
|              */ | ||||
|             if (emit_no_trash (data)) | ||||
|             { | ||||
|                 /* Changes this into a delete job */ | ||||
|                 data->trash = FALSE; | ||||
|                 data->iter = data->files; | ||||
|  | ||||
|                 return TRUE; | ||||
|             } | ||||
|  | ||||
|             /* End the job */ | ||||
|             return FALSE; | ||||
|             else | ||||
|             { | ||||
|                 /* End the job */ | ||||
|                 async_data_free (data); | ||||
|                 return; | ||||
|             } | ||||
|         } | ||||
|         else if (code == G_IO_ERROR_CANCELLED) | ||||
|         { | ||||
|             /* Job has been cancelled, just let the job end */ | ||||
|             return FALSE; | ||||
|             /* Job has been cancelled, end the job */ | ||||
|             async_data_free (data); | ||||
|             return; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /* Process the next item */ | ||||
|     data->iter = data->iter->next; | ||||
|     return TRUE; | ||||
|     /* Continue the job */ | ||||
|     delete_files (data); | ||||
| } | ||||
|  | ||||
| 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 | ||||
| @@ -3781,7 +3705,7 @@ xed_file_browser_store_delete_all (XedFileBrowserStore *model, | ||||
|         files = g_list_prepend (files, g_object_ref (node->file)); | ||||
|     } | ||||
|  | ||||
|     data = g_new (AsyncData, 1); | ||||
|     data = g_slice_new (AsyncData); | ||||
|  | ||||
|     data->model = model; | ||||
|     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); | ||||
|  | ||||
|     g_io_scheduler_push_job ((GIOSchedulerJobFunc)delete_files, | ||||
|                              data, | ||||
|                              (GDestroyNotify)async_data_free, | ||||
|                              G_PRIORITY_DEFAULT, | ||||
|                              data->cancellable); | ||||
|     delete_files (data); | ||||
|     g_list_free (rows); | ||||
|  | ||||
|     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); | ||||
|     /* 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); | ||||
|  | ||||
| @@ -3906,7 +3826,7 @@ xed_file_browser_store_new_directory (XedFileBrowserStore *model, | ||||
|  | ||||
|     parent_node = FILE_BROWSER_NODE_DIR (parent->user_data); | ||||
|     /* 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)) | ||||
|     { | ||||
|   | ||||
| @@ -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 | ||||
|  * | ||||
|  * Copyright (C) 2006 - Jesse van den Kieboom <jesse@icecrew.nl> | ||||
| @@ -19,167 +19,148 @@ | ||||
|  * 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-file-browser-utils.h" | ||||
|  | ||||
| static GdkPixbuf * | ||||
| process_icon_pixbuf (GdkPixbuf * pixbuf, | ||||
| 		     gchar const * name, | ||||
| 		     gint size, | ||||
| 		     GError * error) | ||||
| process_icon_pixbuf (GdkPixbuf   *pixbuf, | ||||
|                      gchar const *name, | ||||
|                      gint         size, | ||||
|                      GError      *error) | ||||
| { | ||||
| 	GdkPixbuf * scale; | ||||
|     GdkPixbuf *scale; | ||||
|  | ||||
| 	if (error != NULL) { | ||||
| 		g_warning ("Could not load theme icon %s: %s", | ||||
| 			   name, | ||||
| 			   error->message); | ||||
| 		g_error_free (error); | ||||
| 	} | ||||
|     if (error != NULL) | ||||
|     { | ||||
|         g_warning ("Could not load theme icon %s: %s", name, error->message); | ||||
|         g_error_free (error); | ||||
|     } | ||||
|  | ||||
| 	if (pixbuf && gdk_pixbuf_get_width (pixbuf) > size) { | ||||
| 		scale = gdk_pixbuf_scale_simple (pixbuf, | ||||
| 		                                 size, | ||||
| 		                                 size, | ||||
| 		                                 GDK_INTERP_BILINEAR); | ||||
| 		g_object_unref (pixbuf); | ||||
| 		pixbuf = scale; | ||||
| 	} | ||||
|     if (pixbuf && gdk_pixbuf_get_width (pixbuf) > size) | ||||
|     { | ||||
|         scale = gdk_pixbuf_scale_simple (pixbuf, size, size, GDK_INTERP_BILINEAR); | ||||
|         g_object_unref (pixbuf); | ||||
|         pixbuf = scale; | ||||
|     } | ||||
|  | ||||
| 	return pixbuf; | ||||
|     return pixbuf; | ||||
| } | ||||
|  | ||||
| GdkPixbuf * | ||||
| xed_file_browser_utils_pixbuf_from_theme (gchar const * name, | ||||
|                                             GtkIconSize size) | ||||
| xed_file_browser_utils_pixbuf_from_theme (gchar const *name, | ||||
|                                           GtkIconSize  size) | ||||
| { | ||||
| 	gint width; | ||||
| 	GError *error = NULL; | ||||
| 	GdkPixbuf *pixbuf; | ||||
|     gint width; | ||||
|     GError *error = NULL; | ||||
|     GdkPixbuf *pixbuf; | ||||
|  | ||||
| 	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 (), | ||||
| 					   name, | ||||
| 					   width, | ||||
| 					   0, | ||||
| 					   &error); | ||||
|     pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), name, width, 0, &error); | ||||
|  | ||||
| 	pixbuf = process_icon_pixbuf (pixbuf, name, width, error); | ||||
|     pixbuf = process_icon_pixbuf (pixbuf, name, width, error); | ||||
|  | ||||
| 	return pixbuf; | ||||
|     return pixbuf; | ||||
| } | ||||
|  | ||||
| GdkPixbuf * | ||||
| xed_file_browser_utils_pixbuf_from_icon (GIcon * icon, | ||||
|                                            GtkIconSize size) | ||||
| xed_file_browser_utils_pixbuf_from_icon (GIcon       *icon, | ||||
|                                          GtkIconSize  size) | ||||
| { | ||||
| 	GdkPixbuf * ret = NULL; | ||||
| 	GtkIconTheme *theme; | ||||
| 	GtkIconInfo *info; | ||||
| 	gint width; | ||||
|     GdkPixbuf *ret = NULL; | ||||
|     GtkIconTheme *theme; | ||||
|     GtkIconInfo *info; | ||||
|     gint width; | ||||
|  | ||||
| 	if (!icon) | ||||
| 		return NULL; | ||||
|     if (!icon) | ||||
|     { | ||||
|         return NULL; | ||||
|     } | ||||
|  | ||||
| 	theme = gtk_icon_theme_get_default (); | ||||
| 	gtk_icon_size_lookup (size, &width, NULL); | ||||
|     theme = gtk_icon_theme_get_default (); | ||||
|     gtk_icon_size_lookup (size, &width, NULL); | ||||
|  | ||||
| 	info = gtk_icon_theme_lookup_by_gicon (theme, | ||||
| 					       icon, | ||||
| 					       width, | ||||
| 					       GTK_ICON_LOOKUP_USE_BUILTIN); | ||||
|     info = gtk_icon_theme_lookup_by_gicon (theme, icon, width, GTK_ICON_LOOKUP_USE_BUILTIN); | ||||
|  | ||||
| 	if (!info) | ||||
| 		return NULL; | ||||
|     if (!info) | ||||
|     { | ||||
|         return NULL; | ||||
|     } | ||||
|  | ||||
| 	ret = gtk_icon_info_load_icon (info, NULL); | ||||
| 	gtk_icon_info_free (info); | ||||
|     ret = gtk_icon_info_load_icon (info, NULL); | ||||
|     gtk_icon_info_free (info); | ||||
|  | ||||
| 	return ret; | ||||
|     return ret; | ||||
| } | ||||
|  | ||||
| GdkPixbuf * | ||||
| xed_file_browser_utils_pixbuf_from_file (GFile * file, | ||||
|                                            GtkIconSize size) | ||||
| xed_file_browser_utils_pixbuf_from_file (GFile       *file, | ||||
|                                          GtkIconSize  size) | ||||
| { | ||||
| 	GIcon * icon; | ||||
| 	GFileInfo * info; | ||||
| 	GdkPixbuf * ret = NULL; | ||||
|     GIcon *icon; | ||||
|     GFileInfo *info; | ||||
|     GdkPixbuf *ret = NULL; | ||||
|  | ||||
| 	info = g_file_query_info (file, | ||||
| 				  G_FILE_ATTRIBUTE_STANDARD_ICON, | ||||
| 				  G_FILE_QUERY_INFO_NONE, | ||||
| 				  NULL, | ||||
| 				  NULL); | ||||
|     info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_ICON, G_FILE_QUERY_INFO_NONE, NULL, NULL); | ||||
|  | ||||
| 	if (!info) | ||||
| 		return NULL; | ||||
|     if (!info) | ||||
|     { | ||||
|         return NULL; | ||||
|     } | ||||
|  | ||||
| 	icon = g_file_info_get_icon (info); | ||||
| 	if (icon != NULL) | ||||
| 		ret = xed_file_browser_utils_pixbuf_from_icon (icon, size); | ||||
|     icon = g_file_info_get_icon (info); | ||||
|     if (icon != NULL) | ||||
|     { | ||||
|         ret = xed_file_browser_utils_pixbuf_from_icon (icon, size); | ||||
|     } | ||||
|  | ||||
| 	g_object_unref (info); | ||||
|     g_object_unref (info); | ||||
|  | ||||
| 	return ret; | ||||
|     return ret; | ||||
| } | ||||
|  | ||||
| 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 | ||||
| xed_file_browser_utils_confirmation_dialog (XedWindow * window, | ||||
|                                               GtkMessageType type, | ||||
|                                               gchar const *message, | ||||
| 		                              gchar const *secondary, | ||||
| 		                              gchar const * button_stock, | ||||
| 		                              gchar const * button_label) | ||||
| xed_file_browser_utils_confirmation_dialog (XedWindow      *window, | ||||
|                                             GtkMessageType  type, | ||||
|                                             gchar const    *message, | ||||
|                                             gchar const    *secondary, | ||||
|                                             gchar const    *button_label) | ||||
| { | ||||
| 	GtkWidget *dlg; | ||||
| 	gint ret; | ||||
| 	GtkWidget *button; | ||||
|     GtkWidget *dlg; | ||||
|     gint ret; | ||||
|  | ||||
| 	dlg = gtk_message_dialog_new (GTK_WINDOW (window), | ||||
| 				      GTK_DIALOG_MODAL | | ||||
| 				      GTK_DIALOG_DESTROY_WITH_PARENT, | ||||
| 				      type, | ||||
| 				      GTK_BUTTONS_NONE, "%s", message); | ||||
|     dlg = gtk_message_dialog_new (GTK_WINDOW (window), | ||||
|                                   GTK_DIALOG_MODAL | | ||||
|                                   GTK_DIALOG_DESTROY_WITH_PARENT, | ||||
|                                   type, | ||||
|                                   GTK_BUTTONS_NONE, "%s", message); | ||||
|  | ||||
| 	if (secondary) | ||||
| 		gtk_message_dialog_format_secondary_text | ||||
| 		    (GTK_MESSAGE_DIALOG (dlg), "%s", secondary); | ||||
|     if (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_dialog_add_buttons (GTK_DIALOG (dlg), | ||||
|                             _("_Cancel"), GTK_RESPONSE_CANCEL, | ||||
|                             button_label, GTK_RESPONSE_OK, | ||||
|                             NULL); | ||||
|  | ||||
| 	gtk_widget_set_can_default (button, TRUE); | ||||
| 	gtk_dialog_add_action_widget (GTK_DIALOG (dlg), | ||||
|                                       button, | ||||
|                                       GTK_RESPONSE_CANCEL); | ||||
|     gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_RESPONSE_CANCEL); | ||||
|  | ||||
| 	/* Add custom button */ | ||||
| 	button = gtk_button_new_from_stock (button_stock); | ||||
|     ret = gtk_dialog_run (GTK_DIALOG (dlg)); | ||||
|     gtk_widget_destroy (dlg); | ||||
|  | ||||
| 	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_widget_set_can_default (button, TRUE); | ||||
| 	gtk_dialog_add_action_widget (GTK_DIALOG (dlg), | ||||
|                                       button, | ||||
|                                       GTK_RESPONSE_OK); | ||||
|  | ||||
| 	ret = gtk_dialog_run (GTK_DIALOG (dlg)); | ||||
| 	gtk_widget_destroy (dlg); | ||||
|  | ||||
| 	return (ret == GTK_RESPONSE_OK); | ||||
|     return (ret == GTK_RESPONSE_OK); | ||||
| } | ||||
|  | ||||
| // ex:ts=8:noet: | ||||
|   | ||||
| @@ -4,22 +4,21 @@ | ||||
| #include <xed/xed-window.h> | ||||
| #include <gio/gio.h> | ||||
|  | ||||
| GdkPixbuf *xed_file_browser_utils_pixbuf_from_theme     (gchar const *name, | ||||
|                                                            GtkIconSize size); | ||||
| GdkPixbuf *xed_file_browser_utils_pixbuf_from_theme (gchar const *name, | ||||
|                                                      GtkIconSize  size); | ||||
|  | ||||
| GdkPixbuf *xed_file_browser_utils_pixbuf_from_icon	  (GIcon * icon, | ||||
|                                                            GtkIconSize size); | ||||
| GdkPixbuf *xed_file_browser_utils_pixbuf_from_file	  (GFile * file, | ||||
|                                                            GtkIconSize size); | ||||
| GdkPixbuf *xed_file_browser_utils_pixbuf_from_icon (GIcon       *icon, | ||||
|                                                     GtkIconSize  size); | ||||
| GdkPixbuf *xed_file_browser_utils_pixbuf_from_file (GFile       *file, | ||||
|                                                     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, | ||||
|                                                            GtkMessageType type, | ||||
|                                                            gchar const *message, | ||||
| 		                                           gchar const *secondary, | ||||
| 		                                           gchar const * button_stock, | ||||
| 		                                           gchar const * button_label); | ||||
| gboolean xed_file_browser_utils_confirmation_dialog (XedWindow      *window, | ||||
|                                                      GtkMessageType  type, | ||||
|                                                      gchar const    *message, | ||||
|                                                      gchar const    *secondary, | ||||
|                                                      gchar const    *button_label); | ||||
|  | ||||
| #endif /* __XED_FILE_BROWSER_UTILS_H__ */ | ||||
|  | ||||
|   | ||||
| @@ -44,8 +44,6 @@ struct _XedFileBrowserViewPrivate | ||||
|     GtkTreeModel *model; | ||||
|     GtkTreeRowReference *editable; | ||||
|  | ||||
|     GdkCursor *busy_cursor; | ||||
|  | ||||
|     /* CLick policy */ | ||||
|     XedFileBrowserViewClickPolicy click_policy; | ||||
|     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; | ||||
|     } | ||||
|  | ||||
|     g_object_unref (obj->priv->busy_cursor); | ||||
|  | ||||
|     G_OBJECT_CLASS (xed_file_browser_view_parent_class)->finalize (object); | ||||
| } | ||||
|  | ||||
| @@ -169,7 +165,6 @@ row_expanded (GtkTreeView *tree_view, | ||||
|               GtkTreePath *path) | ||||
| { | ||||
|     XedFileBrowserView *view = XED_FILE_BROWSER_VIEW (tree_view); | ||||
|     GFile *location; | ||||
|  | ||||
|     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) | ||||
|     { | ||||
|         GFile *location; | ||||
|  | ||||
|         gtk_tree_model_get (view->priv->model, iter, XED_FILE_BROWSER_STORE_COLUMN_LOCATION, &location, -1); | ||||
|  | ||||
|         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); | ||||
| @@ -197,7 +199,6 @@ row_collapsed (GtkTreeView *tree_view, | ||||
|                GtkTreePath *path) | ||||
| { | ||||
|     XedFileBrowserView *view = XED_FILE_BROWSER_VIEW (tree_view); | ||||
|     GFile *location; | ||||
|  | ||||
|     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) | ||||
|     { | ||||
|         GFile *location; | ||||
|  | ||||
|         gtk_tree_model_get (view->priv->model, iter, XED_FILE_BROWSER_STORE_COLUMN_LOCATION, &location, -1); | ||||
|  | ||||
|         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); | ||||
| @@ -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 | ||||
| toggle_hidden_filter (XedFileBrowserView *view) | ||||
| { | ||||
| @@ -751,7 +773,6 @@ fill_expand_state (XedFileBrowserView *view, | ||||
| { | ||||
|     GtkTreePath * path; | ||||
|     GtkTreeIter child; | ||||
|     GFile *location; | ||||
|  | ||||
|     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)) | ||||
|     { | ||||
|         GFile *location; | ||||
|  | ||||
|         gtk_tree_model_get (view->priv->model, | ||||
|                             iter, | ||||
|                             XED_FILE_BROWSER_STORE_COLUMN_LOCATION, | ||||
| @@ -769,6 +792,11 @@ fill_expand_state (XedFileBrowserView *view, | ||||
|                             -1); | ||||
|  | ||||
|         add_expand_state (view, location); | ||||
|  | ||||
|         if (location) | ||||
|         { | ||||
|             g_object_unref (location); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     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; | ||||
|  | ||||
|     /* Tree view handlers */ | ||||
|     tree_view_class->row_activated = row_activated; | ||||
|     tree_view_class->row_expanded = row_expanded; | ||||
|     tree_view_class->row_collapsed = row_collapsed; | ||||
|  | ||||
| @@ -1038,8 +1067,6 @@ xed_file_browser_view_init (XedFileBrowserView *obj) | ||||
|                                             drag_source_targets, | ||||
|                                             G_N_ELEMENTS (drag_source_targets), | ||||
|                                             GDK_ACTION_COPY); | ||||
|  | ||||
|     obj->priv->busy_cursor = gdk_cursor_new (GDK_WATCH); | ||||
| } | ||||
|  | ||||
| static gboolean | ||||
| @@ -1275,7 +1302,6 @@ restore_expand_state (XedFileBrowserView  *view, | ||||
|                       GtkTreeIter         *iter) | ||||
| { | ||||
|     GFile *location; | ||||
|     GtkTreePath *path; | ||||
|  | ||||
|     gtk_tree_model_get (GTK_TREE_MODEL (model), | ||||
|                         iter, | ||||
| @@ -1283,19 +1309,20 @@ restore_expand_state (XedFileBrowserView  *view, | ||||
|                         &location, | ||||
|                         -1); | ||||
|  | ||||
|     if (!location) | ||||
|     if (location) | ||||
|     { | ||||
|         return; | ||||
|         GtkTreePath *path; | ||||
|  | ||||
|         path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), iter); | ||||
|  | ||||
|         if (g_hash_table_lookup (view->priv->expand_state, location)) | ||||
|         { | ||||
|             gtk_tree_view_expand_row (GTK_TREE_VIEW (view), path, FALSE); | ||||
|         } | ||||
|  | ||||
|         gtk_tree_path_free (path); | ||||
|         g_object_unref (location); | ||||
|     } | ||||
|  | ||||
|     path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), iter); | ||||
|  | ||||
|     if (g_hash_table_lookup (view->priv->expand_state, location)) | ||||
|     { | ||||
|         gtk_tree_view_expand_row (GTK_TREE_VIEW (view), path, FALSE); | ||||
|     } | ||||
|  | ||||
|     gtk_tree_path_free (path); | ||||
| } | ||||
|  | ||||
| static void | ||||
|   | ||||
| @@ -1,14 +1,9 @@ | ||||
| <ui> | ||||
|   <toolbar name="ToolBar"> | ||||
|     <placeholder name="Tool_Opt1"/> | ||||
|     <toolitem action="DirectoryPrevious"/> | ||||
|     <toolitem action="DirectoryNext"/> | ||||
|     <toolitem action="DirectoryUp"/> | ||||
|     <separator/> | ||||
|     <toolitem action="DirectoryRefresh"/> | ||||
|     <separator/> | ||||
|     <placeholder name="Tool_Opt2"/> | ||||
|     <separator/> | ||||
|     <toolitem action="FilterHidden"/> | ||||
|     <separator/> | ||||
|     <placeholder name="Tool_Opt3"/> | ||||
|   </toolbar> | ||||
|  | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Reference in New Issue
	
	Block a user