diff options
author | Laurent Napias <[email protected]> | 2019-06-29 10:29:13 +0200 |
---|---|---|
committer | ZenWalker <[email protected]> | 2019-07-06 21:46:58 +0200 |
commit | db655f3fb2f67b695d36369e584fcb598e0e1bea (patch) | |
tree | ff7a4404cb6f0d1d8ca3a08ee50c60641641f1b4 /plugins/filebrowser/pluma-file-browser-messages.c | |
parent | 5153fb08a2e26015d07e7b3805de15d38bd05a9d (diff) | |
download | pluma-db655f3fb2f67b695d36369e584fcb598e0e1bea.tar.bz2 pluma-db655f3fb2f67b695d36369e584fcb598e0e1bea.tar.xz |
Remove trailing whitespaces
Diffstat (limited to 'plugins/filebrowser/pluma-file-browser-messages.c')
-rw-r--r-- | plugins/filebrowser/pluma-file-browser-messages.c | 354 |
1 files changed, 177 insertions, 177 deletions
diff --git a/plugins/filebrowser/pluma-file-browser-messages.c b/plugins/filebrowser/pluma-file-browser-messages.c index f4b20d05..2c703973 100644 --- a/plugins/filebrowser/pluma-file-browser-messages.c +++ b/plugins/filebrowser/pluma-file-browser-messages.c @@ -9,7 +9,7 @@ typedef struct { - PlumaWindow *window; + PlumaWindow *window; PlumaMessage *message; } MessageCacheData; @@ -23,18 +23,18 @@ typedef struct GList *merge_ids; GtkActionGroup *merged_actions; - + PlumaMessageBus *bus; PlumaFileBrowserWidget *widget; GHashTable *row_tracking; - + GHashTable *filters; } WindowData; typedef struct { gulong id; - + PlumaWindow *window; PlumaMessage *message; } FilterData; @@ -46,10 +46,10 @@ window_data_new (PlumaWindow *window, WindowData *data = g_slice_new (WindowData); GtkUIManager *manager; GList *groups; - + data->bus = pluma_window_get_message_bus (window); data->widget = widget; - data->row_tracking = g_hash_table_new_full (g_str_hash, + data->row_tracking = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify)g_free, (GDestroyNotify)gtk_tree_row_reference_free); @@ -58,15 +58,15 @@ window_data_new (PlumaWindow *window, g_str_equal, (GDestroyNotify)g_free, NULL); - + manager = pluma_file_browser_widget_get_ui_manager (widget); data->merge_ids = NULL; data->merged_actions = gtk_action_group_new ("MessageMergedActions"); - + groups = gtk_ui_manager_get_action_groups (manager); gtk_ui_manager_insert_action_group (manager, data->merged_actions, g_list_length (groups)); - + g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, data); return data; @@ -84,13 +84,13 @@ window_data_free (PlumaWindow *window) WindowData *data = get_window_data (window); GtkUIManager *manager; GList *item; - - g_hash_table_destroy (data->row_tracking); + + g_hash_table_destroy (data->row_tracking); g_hash_table_destroy (data->filters); manager = pluma_file_browser_widget_get_ui_manager (data->widget); 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)); @@ -103,19 +103,19 @@ window_data_free (PlumaWindow *window) } static FilterData * -filter_data_new (PlumaWindow *window, +filter_data_new (PlumaWindow *window, PlumaMessage *message) { FilterData *data = g_slice_new (FilterData); WindowData *wdata; - + data->window = window; data->id = 0; data->message = message; - + wdata = get_window_data (window); - - g_hash_table_insert (wdata->filters, + + g_hash_table_insert (wdata->filters, pluma_message_type_identifier (pluma_message_get_object_path (message), pluma_message_get_method (message)), data); @@ -128,10 +128,10 @@ filter_data_free (FilterData *data) { WindowData *wdata = get_window_data (data->window); gchar *identifier; - + identifier = pluma_message_type_identifier (pluma_message_get_object_path (data->message), pluma_message_get_method (data->message)); - + g_hash_table_remove (wdata->filters, identifier); g_free (identifier); @@ -140,16 +140,16 @@ filter_data_free (FilterData *data) } static GtkTreePath * -track_row_lookup (WindowData *data, +track_row_lookup (WindowData *data, 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); } @@ -165,10 +165,10 @@ message_cache_data_new (PlumaWindow *window, PlumaMessage *message) { MessageCacheData *data = g_slice_new (MessageCacheData); - + data->window = window; data->message = message; - + return data; } @@ -179,10 +179,10 @@ message_get_root_cb (PlumaMessageBus *bus, { PlumaFileBrowserStore *store; gchar *uri; - + store = pluma_file_browser_widget_get_browser_store (data->widget); uri = pluma_file_browser_store_get_virtual_root (store); - + pluma_message_set (message, "uri", uri, NULL); g_free (uri); } @@ -194,12 +194,12 @@ message_set_root_cb (PlumaMessageBus *bus, { gchar *root = NULL; gchar *virtual = NULL; - + pluma_message_get (message, "uri", &root, NULL); - + if (!root) return; - + if (pluma_message_has_key (message, "virtual")) pluma_message_get (message, "virtual", &virtual, NULL); @@ -207,7 +207,7 @@ message_set_root_cb (PlumaMessageBus *bus, pluma_file_browser_widget_set_root_and_virtual_root (data->widget, root, virtual); else pluma_file_browser_widget_set_root (data->widget, root, TRUE); - + g_free (root); g_free (virtual); } @@ -221,57 +221,57 @@ message_set_emblem_cb (PlumaMessageBus *bus, gchar *emblem = NULL; GtkTreePath *path; PlumaFileBrowserStore *store; - + pluma_message_get (message, "id", &id, "emblem", &emblem, NULL); - + if (!id || !emblem) { g_free (id); g_free (emblem); - + return; } - + path = track_row_lookup (data, id); - + if (path != NULL) { GError *error = NULL; GdkPixbuf *pixbuf; - - pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), - emblem, - 10, - 0, + + pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), + emblem, + 10, + 0, &error); - + if (pixbuf) { GValue value = { 0, }; GtkTreeIter iter; - + store = pluma_file_browser_widget_get_browser_store (data->widget); - + if (gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, path)) { g_value_init (&value, GDK_TYPE_PIXBUF); g_value_set_object (&value, pixbuf); - - pluma_file_browser_store_set_value (store, + + pluma_file_browser_store_set_value (store, &iter, PLUMA_FILE_BROWSER_STORE_COLUMN_EMBLEM, &value); - + g_value_unset (&value); } - + g_object_unref (pixbuf); } - + if (error) g_error_free (error); } - + g_free (id); g_free (emblem); } @@ -292,20 +292,20 @@ track_row (WindowData *data, GtkTreeRowReference *ref; gchar *id; gchar *pathstr; - + pathstr = gtk_tree_path_to_string (path); id = item_id (pathstr, uri); - + ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (store), path); g_hash_table_insert (data->row_tracking, g_strdup (id), ref); - + g_free (pathstr); - + return id; } static void -set_item_message (WindowData *data, +set_item_message (WindowData *data, GtkTreeIter *iter, GtkTreePath *path, PlumaMessage *message) @@ -314,14 +314,14 @@ set_item_message (WindowData *data, gchar *uri = NULL; guint flags = 0; gchar *track_id; - + store = pluma_file_browser_widget_get_browser_store (data->widget); - + gtk_tree_model_get (GTK_TREE_MODEL (store), iter, PLUMA_FILE_BROWSER_STORE_COLUMN_URI, &uri, PLUMA_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags, -1); - + if (!uri) return; @@ -334,13 +334,13 @@ set_item_message (WindowData *data, "id", track_id, "uri", uri, NULL); - + if (pluma_message_has_key (message, "is_directory")) { - pluma_message_set (message, + pluma_message_set (message, "is_directory", FILE_IS_DIR (flags), NULL); - } + } g_free (uri); g_free (track_id); @@ -357,27 +357,27 @@ custom_message_filter_func (PlumaFileBrowserWidget *widget, guint flags = 0; gboolean filter = FALSE; GtkTreePath *path; - - gtk_tree_model_get (GTK_TREE_MODEL (store), iter, + + gtk_tree_model_get (GTK_TREE_MODEL (store), iter, PLUMA_FILE_BROWSER_STORE_COLUMN_URI, &uri, PLUMA_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags, -1); - + if (!uri || FILE_IS_DUMMY (flags)) { g_free (uri); return FALSE; } - + path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), iter); set_item_message (wdata, iter, path, data->message); gtk_tree_path_free (path); - + pluma_message_set (data->message, "filter", filter, NULL); pluma_message_bus_send_message_sync (wdata->bus, data->message); pluma_message_get (data->message, "filter", &filter, NULL); - + return !filter; } @@ -393,31 +393,31 @@ message_add_filter_cb (PlumaMessageBus *bus, PlumaMessage *cbmessage; FilterData *filter_data; WindowData *data = get_window_data (window); - - pluma_message_get (message, + + pluma_message_get (message, "object_path", &object_path, "method", &method, NULL); - + // Check if there exists such a 'callback' message if (!object_path || !method) { g_free (object_path); g_free (method); - + return; } - + message_type = pluma_message_bus_lookup (bus, object_path, method); - + if (!message_type) { g_free (object_path); g_free (method); - + return; } - + // Check if the message type has the correct arguments if (pluma_message_type_lookup (message_type, "id") != G_TYPE_STRING || pluma_message_type_lookup (message_type, "uri") != G_TYPE_STRING || @@ -426,7 +426,7 @@ message_add_filter_cb (PlumaMessageBus *bus, { return; } - + cbmessage = pluma_message_type_instantiate (message_type, "id", NULL, "uri", NULL, @@ -436,7 +436,7 @@ message_add_filter_cb (PlumaMessageBus *bus, // Register the custom filter on the widget filter_data = filter_data_new (window, cbmessage); - id = pluma_file_browser_widget_add_filter (data->widget, + id = pluma_file_browser_widget_add_filter (data->widget, (PlumaFileBrowserWidgetFilterFunc)custom_message_filter_func, filter_data, (GDestroyNotify)filter_data_free); @@ -450,12 +450,12 @@ message_remove_filter_cb (PlumaMessageBus *bus, WindowData *data) { gulong id = 0; - + pluma_message_get (message, "id", &id, NULL); - + if (!id) return; - + pluma_file_browser_widget_remove_filter (data->widget, id); } @@ -465,7 +465,7 @@ message_up_cb (PlumaMessageBus *bus, WindowData *data) { PlumaFileBrowserStore *store = pluma_file_browser_widget_get_browser_store (data->widget); - + pluma_file_browser_store_set_virtual_root_up (store); } @@ -501,12 +501,12 @@ message_set_show_hidden_cb (PlumaMessageBus *bus, gboolean active = FALSE; PlumaFileBrowserStore *store; PlumaFileBrowserStoreFilterMode mode; - + pluma_message_get (message, "active", &active, NULL); - + store = pluma_file_browser_widget_get_browser_store (data->widget); mode = pluma_file_browser_store_get_filter_mode (store); - + if (active) mode &= ~PLUMA_FILE_BROWSER_STORE_FILTER_MODE_HIDE_HIDDEN; else @@ -523,12 +523,12 @@ message_set_show_binary_cb (PlumaMessageBus *bus, gboolean active = FALSE; PlumaFileBrowserStore *store; PlumaFileBrowserStoreFilterMode mode; - + pluma_message_get (message, "active", &active, NULL); - + store = pluma_file_browser_widget_get_browser_store (data->widget); mode = pluma_file_browser_store_get_filter_mode (store); - + if (active) mode &= ~PLUMA_FILE_BROWSER_STORE_FILTER_MODE_HIDE_BINARY; else @@ -563,12 +563,12 @@ message_add_context_item_cb (PlumaMessageBus *bus, gchar *name; GtkUIManager *manager; guint merge_id; - - pluma_message_get (message, - "action", &action, - "path", &path, + + pluma_message_get (message, + "action", &action, + "path", &path, NULL); - + if (!action || !path) { if (action) @@ -577,20 +577,20 @@ message_add_context_item_cb (PlumaMessageBus *bus, g_free (path); return; } - + gtk_action_group_add_action (data->merged_actions, action); manager = pluma_file_browser_widget_get_ui_manager (data->widget); name = g_strconcat (gtk_action_get_name (action), "MenuItem", NULL); merge_id = gtk_ui_manager_new_merge_id (manager); - - gtk_ui_manager_add_ui (manager, + + gtk_ui_manager_add_ui (manager, merge_id, path, name, gtk_action_get_name (action), GTK_UI_MANAGER_AUTO, FALSE); - + if (gtk_ui_manager_get_widget (manager, path)) { data->merge_ids = g_list_prepend (data->merge_ids, GINT_TO_POINTER (merge_id)); @@ -600,7 +600,7 @@ message_add_context_item_cb (PlumaMessageBus *bus, { pluma_message_set (message, "id", 0, NULL); } - + g_object_unref (action); g_free (path); g_free (name); @@ -613,14 +613,14 @@ message_remove_context_item_cb (PlumaMessageBus *bus, { guint merge_id = 0; GtkUIManager *manager; - + pluma_message_get (message, "id", &merge_id, NULL); - + if (merge_id == 0) return; - + manager = pluma_file_browser_widget_get_ui_manager (data->widget); - + data->merge_ids = g_list_remove (data->merge_ids, GINT_TO_POINTER (merge_id)); gtk_ui_manager_remove_ui (manager, merge_id); } @@ -644,26 +644,26 @@ register_methods (PlumaWindow *window, WindowData *data = get_window_data (window); /* Register method calls */ - pluma_message_bus_register (bus, - MESSAGE_OBJECT_PATH, "get_root", + pluma_message_bus_register (bus, + MESSAGE_OBJECT_PATH, "get_root", 1, "uri", G_TYPE_STRING, NULL); - - pluma_message_bus_register (bus, - MESSAGE_OBJECT_PATH, "set_root", - 1, + + pluma_message_bus_register (bus, + MESSAGE_OBJECT_PATH, "set_root", + 1, "uri", G_TYPE_STRING, "virtual", G_TYPE_STRING, NULL); - + pluma_message_bus_register (bus, MESSAGE_OBJECT_PATH, "set_emblem", 0, "id", G_TYPE_STRING, "emblem", G_TYPE_STRING, NULL); - + pluma_message_bus_register (bus, MESSAGE_OBJECT_PATH, "add_filter", 1, @@ -671,13 +671,13 @@ register_methods (PlumaWindow *window, "method", G_TYPE_STRING, "id", G_TYPE_ULONG, NULL); - + pluma_message_bus_register (bus, MESSAGE_OBJECT_PATH, "remove_filter", 0, "id", G_TYPE_ULONG, NULL); - + pluma_message_bus_register (bus, MESSAGE_OBJECT_PATH, "add_context_item", 1, @@ -691,22 +691,22 @@ register_methods (PlumaWindow *window, 0, "id", G_TYPE_UINT, NULL); - + pluma_message_bus_register (bus, MESSAGE_OBJECT_PATH, "up", 0, NULL); - + pluma_message_bus_register (bus, MESSAGE_OBJECT_PATH, "history_back", 0, NULL); pluma_message_bus_register (bus, MESSAGE_OBJECT_PATH, "history_forward", 0, NULL); - + pluma_message_bus_register (bus, MESSAGE_OBJECT_PATH, "refresh", 0, NULL); - pluma_message_bus_register (bus, - MESSAGE_OBJECT_PATH, "set_show_hidden", - 0, + pluma_message_bus_register (bus, + MESSAGE_OBJECT_PATH, "set_show_hidden", + 0, "active", G_TYPE_BOOLEAN, NULL); - pluma_message_bus_register (bus, + pluma_message_bus_register (bus, MESSAGE_OBJECT_PATH, "set_show_binary", - 0, + 0, "active", G_TYPE_BOOLEAN, NULL); @@ -733,10 +733,10 @@ register_methods (PlumaWindow *window, BUS_CONNECT (bus, history_forward, data); BUS_CONNECT (bus, refresh, data); - + BUS_CONNECT (bus, set_show_hidden, data); BUS_CONNECT (bus, set_show_binary, data); - + BUS_CONNECT (bus, show_bookmarks, data); BUS_CONNECT (bus, show_files, data); @@ -752,19 +752,19 @@ store_row_inserted (PlumaFileBrowserStore *store, gchar *uri = NULL; guint flags = 0; - gtk_tree_model_get (GTK_TREE_MODEL (store), iter, + gtk_tree_model_get (GTK_TREE_MODEL (store), iter, PLUMA_FILE_BROWSER_STORE_COLUMN_URI, &uri, PLUMA_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags, -1); - + if (!FILE_IS_DUMMY (flags) && !FILE_IS_FILTERED (flags)) { WindowData *wdata = get_window_data (data->window); - + set_item_message (wdata, iter, path, data->message); pluma_message_bus_send_message_sync (wdata->bus, data->message); } - + g_free (uri); } @@ -776,23 +776,23 @@ store_row_deleted (PlumaFileBrowserStore *store, GtkTreeIter iter; gchar *uri = NULL; 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, + + gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, PLUMA_FILE_BROWSER_STORE_COLUMN_URI, &uri, PLUMA_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags, -1); - + if (!FILE_IS_DUMMY (flags) && !FILE_IS_FILTERED (flags)) { WindowData *wdata = get_window_data (data->window); - + set_item_message (wdata, &iter, path, data->message); pluma_message_bus_send_message_sync (wdata->bus, data->message); } - + g_free (uri); } @@ -803,18 +803,18 @@ store_virtual_root_changed (PlumaFileBrowserStore *store, { WindowData *wdata = get_window_data (data->window); gchar *uri; - + uri = pluma_file_browser_store_get_virtual_root (store); - + if (!uri) return; - + pluma_message_set (data->message, "uri", uri, NULL); - + pluma_message_bus_send_message_sync (wdata->bus, data->message); - + g_free (uri); } @@ -825,11 +825,11 @@ store_begin_loading (PlumaFileBrowserStore *store, { GtkTreePath *path; WindowData *wdata = get_window_data (data->window); - + path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), iter); - + set_item_message (wdata, iter, path, data->message); - + pluma_message_bus_send_message_sync (wdata->bus, data->message); gtk_tree_path_free (path); } @@ -841,15 +841,15 @@ store_end_loading (PlumaFileBrowserStore *store, { GtkTreePath *path; WindowData *wdata = get_window_data (data->window); - + path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), iter); - + set_item_message (wdata, iter, path, data->message); - + pluma_message_bus_send_message_sync (wdata->bus, data->message); gtk_tree_path_free (path); } - + static void register_signals (PlumaWindow *window, PlumaFileBrowserWidget *widget) @@ -861,7 +861,7 @@ register_signals (PlumaWindow *window, PlumaMessageType *begin_loading_type; PlumaMessageType *end_loading_type; PlumaMessageType *root_changed_type; - + PlumaMessage *message; WindowData *data; @@ -872,7 +872,7 @@ register_signals (PlumaWindow *window, "id", G_TYPE_STRING, "uri", G_TYPE_STRING, NULL); - + begin_loading_type = pluma_message_bus_register (bus, MESSAGE_OBJECT_PATH, "begin_loading", 0, @@ -904,41 +904,41 @@ register_signals (PlumaWindow *window, NULL); store = pluma_file_browser_widget_get_browser_store (widget); - - message = pluma_message_type_instantiate (inserted_type, + + message = pluma_message_type_instantiate (inserted_type, "id", NULL, - "uri", NULL, - "is_directory", FALSE, + "uri", 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), + 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); - message = pluma_message_type_instantiate (deleted_type, - "id", NULL, + message = pluma_message_type_instantiate (deleted_type, + "id", NULL, "uri", NULL, - "is_directory", FALSE, + "is_directory", FALSE, NULL); - data->row_deleted_id = - g_signal_connect_data (store, - "row-deleted", - G_CALLBACK (store_row_deleted), + 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); - + message = pluma_message_type_instantiate (root_changed_type, "id", NULL, "uri", NULL, NULL); - data->root_changed_id = + data->root_changed_id = g_signal_connect_data (store, "notify::virtual-root", G_CALLBACK (store_virtual_root_changed), @@ -949,8 +949,8 @@ register_signals (PlumaWindow *window, message = pluma_message_type_instantiate (begin_loading_type, "id", NULL, "uri", NULL, - NULL); - data->begin_loading_id = + NULL); + data->begin_loading_id = g_signal_connect_data (store, "begin_loading", G_CALLBACK (store_begin_loading), @@ -962,7 +962,7 @@ register_signals (PlumaWindow *window, "id", NULL, "uri", NULL, NULL); - data->end_loading_id = + data->end_loading_id = g_signal_connect_data (store, "end_loading", G_CALLBACK (store_end_loading), @@ -980,28 +980,28 @@ message_unregistered (PlumaMessageBus *bus, pluma_message_type_get_method (message_type)); FilterData *data; WindowData *wdata = get_window_data (window); - + data = g_hash_table_lookup (wdata->filters, identifier); - + if (data) pluma_file_browser_widget_remove_filter (wdata->widget, data->id); - + g_free (identifier); } -void -pluma_file_browser_messages_register (PlumaWindow *window, +void +pluma_file_browser_messages_register (PlumaWindow *window, PlumaFileBrowserWidget *widget) { window_data_new (window, widget); - + register_methods (window, widget); register_signals (window, widget); - + g_signal_connect (pluma_window_get_message_bus (window), "unregistered", G_CALLBACK (message_unregistered), - window); + window); } static void @@ -1009,15 +1009,15 @@ cleanup_signals (PlumaWindow *window) { WindowData *data = get_window_data (window); PlumaFileBrowserStore *store; - + store = pluma_file_browser_widget_get_browser_store (data->widget); - + g_signal_handler_disconnect (store, data->row_inserted_id); g_signal_handler_disconnect (store, data->row_deleted_id); g_signal_handler_disconnect (store, data->root_changed_id); g_signal_handler_disconnect (store, data->begin_loading_id); g_signal_handler_disconnect (store, data->end_loading_id); - + g_signal_handlers_disconnect_by_func (data->bus, message_unregistered, window); } @@ -1025,7 +1025,7 @@ void pluma_file_browser_messages_unregister (PlumaWindow *window) { PlumaMessageBus *bus = pluma_window_get_message_bus (window); - + cleanup_signals (window); pluma_message_bus_unregister_all (bus, MESSAGE_OBJECT_PATH); |