Commit 59595a7a authored by Garrett Regier's avatar Garrett Regier

Fix the file browser's "deleted" message bus signal

Tested with a modified git plugin and the "deleted"
message bus signal now works properly.

https://bugzilla.gnome.org/show_bug.cgi?id=726618
parent 574d8089
......@@ -38,7 +38,7 @@ typedef struct
typedef struct
{
guint row_inserted_id;
guint row_deleted_id;
guint before_row_deleted_id;
guint root_changed_id;
guint begin_loading_id;
guint end_loading_id;
......@@ -788,9 +788,9 @@ store_row_inserted (GeditFileBrowserStore *store,
}
static void
store_row_deleted (GeditFileBrowserStore *store,
GtkTreePath *path,
MessageCacheData *data)
store_before_row_deleted (GeditFileBrowserStore *store,
GtkTreePath *path,
MessageCacheData *data)
{
GtkTreeIter iter;
guint flags = 0;
......@@ -805,9 +805,17 @@ store_row_deleted (GeditFileBrowserStore *store,
if (!FILE_IS_DUMMY (flags) && !FILE_IS_FILTERED (flags))
{
WindowData *wdata = get_window_data (data->window);
gchar *id;
set_item_message (wdata, &iter, path, data->message);
/* Must get the ID before the plugin can modify it */
g_object_get (data->message, "id", &id, NULL);
gedit_message_bus_send_message_sync (wdata->bus, data->message);
g_hash_table_remove (wdata->row_tracking, id);
g_free (id);
}
}
......@@ -925,10 +933,10 @@ register_signals (GeditWindow *window,
"method", "deleted",
NULL);
data->row_deleted_id =
data->before_row_deleted_id =
g_signal_connect_data (store,
"row-deleted",
G_CALLBACK (store_row_deleted),
"before-row-deleted",
G_CALLBACK (store_before_row_deleted),
message_cache_data_new (window, message),
(GClosureNotify)message_cache_data_free,
0);
......@@ -1022,7 +1030,7 @@ cleanup_signals (GeditWindow *window)
store = gedit_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->before_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);
......
......@@ -226,6 +226,7 @@ enum
BEGIN_REFRESH,
END_REFRESH,
UNLOAD,
BEFORE_ROW_DELETED,
NUM_SIGNALS
};
......@@ -445,6 +446,15 @@ gedit_file_browser_store_class_init (GeditFileBrowserStoreClass *klass)
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
G_TYPE_FILE);
model_signals[BEFORE_ROW_DELETED] =
g_signal_new ("before-row-deleted",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GeditFileBrowserStoreClass,
before_row_deleted), NULL, NULL,
g_cclosure_marshal_VOID__BOXED,
G_TYPE_NONE, 1,
GTK_TYPE_TREE_PATH | G_SIGNAL_TYPE_STATIC_SCOPE);
}
static void
......@@ -1259,13 +1269,33 @@ row_inserted (GeditFileBrowserStore *model,
static void
row_deleted (GeditFileBrowserStore *model,
const GtkTreePath *path)
FileBrowserNode *node,
const GtkTreePath *path)
{
GtkTreePath *copy = gtk_tree_path_copy (path);
gboolean hidden;
GtkTreePath *copy;
/* Delete a copy of the actual path here because the row-deleted
signal may alter the path */
gtk_tree_model_row_deleted (GTK_TREE_MODEL(model), copy);
/* We should always be called when the row is still inserted */
g_return_if_fail (node->inserted == TRUE);
hidden = FILE_IS_HIDDEN (node->flags);
node->flags &= ~GEDIT_FILE_BROWSER_STORE_FLAG_IS_HIDDEN;
/* Create temporary copies of the path as the signals may alter it */
copy = gtk_tree_path_copy (path);
g_signal_emit (model, model_signals[BEFORE_ROW_DELETED], 0, copy);
gtk_tree_path_free (copy);
node->inserted = FALSE;
if (hidden)
{
node->flags |= GEDIT_FILE_BROWSER_STORE_FLAG_IS_HIDDEN;
}
copy = gtk_tree_path_copy (path);
gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), copy);
gtk_tree_path_free (copy);
}
......@@ -1327,8 +1357,7 @@ model_refilter_node (GeditFileBrowserStore *model,
{
if (old_visible)
{
node->inserted = FALSE;
row_deleted (model, *path);
row_deleted (model, node, *path);
}
else
{
......@@ -1576,8 +1605,7 @@ model_remove_node (GeditFileBrowserStore *model,
not the virtual root) */
if (model_node_visibility (model, node) && node != model->priv->virtual_root)
{
node->inserted = FALSE;
row_deleted (model, path);
row_deleted (model, node, path);
}
if (free_path)
......@@ -1645,9 +1673,7 @@ model_clear (GeditFileBrowserStore *model,
model_node_visibility (model, dummy))
{
path = gtk_tree_path_new_first ();
dummy->inserted = FALSE;
row_deleted (model, path);
row_deleted (model, dummy, path);
gtk_tree_path_free (path);
}
}
......@@ -1868,8 +1894,7 @@ model_check_dummy (GeditFileBrowserStore *model,
path = gedit_file_browser_store_get_path_real (model, dummy);
dummy->flags |= GEDIT_FILE_BROWSER_STORE_FLAG_IS_HIDDEN;
dummy->inserted = FALSE;
row_deleted (model, path);
row_deleted (model, dummy, path);
gtk_tree_path_free (path);
}
}
......
......@@ -98,22 +98,24 @@ struct _GeditFileBrowserStoreClass {
GObjectClass parent_class;
/* Signals */
void (* begin_loading) (GeditFileBrowserStore *model,
GtkTreeIter *iter);
void (* end_loading) (GeditFileBrowserStore *model,
GtkTreeIter *iter);
void (* error) (GeditFileBrowserStore *model,
guint code,
gchar *message);
gboolean (* no_trash) (GeditFileBrowserStore *model,
GList *files);
void (* rename) (GeditFileBrowserStore *model,
GFile *oldfile,
GFile *newfile);
void (* begin_refresh) (GeditFileBrowserStore *model);
void (* end_refresh) (GeditFileBrowserStore *model);
void (* unload) (GeditFileBrowserStore *model,
GFile *location);
void (* begin_loading) (GeditFileBrowserStore *model,
GtkTreeIter *iter);
void (* end_loading) (GeditFileBrowserStore *model,
GtkTreeIter *iter);
void (* error) (GeditFileBrowserStore *model,
guint code,
gchar *message);
gboolean (* no_trash) (GeditFileBrowserStore *model,
GList *files);
void (* rename) (GeditFileBrowserStore *model,
GFile *oldfile,
GFile *newfile);
void (* begin_refresh) (GeditFileBrowserStore *model);
void (* end_refresh) (GeditFileBrowserStore *model);
void (* unload) (GeditFileBrowserStore *model,
GFile *location);
void (* before_row_deleted) (GeditFileBrowserStore *model,
GtkTreePath *path);
};
GType gedit_file_browser_store_get_type (void) G_GNUC_CONST;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment