gedit r6795 - in trunk: . plugins/filebrowser
- From: jessevdk svn gnome org
- To: svn-commits-list gnome org
- Subject: gedit r6795 - in trunk: . plugins/filebrowser
- Date: Fri, 2 Jan 2009 17:12:59 +0000 (UTC)
Author: jessevdk
Date: Fri Jan 2 17:12:59 2009
New Revision: 6795
URL: http://svn.gnome.org/viewvc/gedit?rev=6795&view=rev
Log:
* plugins/filebrowser/gedit-file-browser-view.c:
* plugins/filebrowser/gedit-file-browser-widget.c:
* plugins/filebrowser/gedit-file-browser-store.c:
* plugins/filebrowser/gedit-file-browser-view.h:
Fixed switching from bookmarks to file view only after mounting
(fixes #551136). Fixed scrolling to rename position when renaming
a file. Fixed cancelling mount operation when switching to different
uri.
Modified:
trunk/ChangeLog
trunk/plugins/filebrowser/gedit-file-browser-store.c
trunk/plugins/filebrowser/gedit-file-browser-store.h
trunk/plugins/filebrowser/gedit-file-browser-view.c
trunk/plugins/filebrowser/gedit-file-browser-widget.c
Modified: trunk/plugins/filebrowser/gedit-file-browser-store.c
==============================================================================
--- trunk/plugins/filebrowser/gedit-file-browser-store.c (original)
+++ trunk/plugins/filebrowser/gedit-file-browser-store.c Fri Jan 2 17:12:59 2009
@@ -81,6 +81,13 @@
GSList *original_children;
};
+typedef struct {
+ GeditFileBrowserStore * model;
+ gchar * virtual_root;
+ GMountOperation * operation;
+ GCancellable * cancellable;
+} MountInfo;
+
struct _FileBrowserNode
{
GFile *file;
@@ -119,6 +126,7 @@
SortFunc sort_func;
GSList *async_handles;
+ MountInfo *mount_info;
};
static FileBrowserNode *model_find_node (GeditFileBrowserStore *model,
@@ -224,6 +232,17 @@
static guint model_signals[NUM_SIGNALS] = { 0 };
static void
+cancel_mount_operation (GeditFileBrowserStore *obj)
+{
+ if (obj->priv->mount_info != NULL)
+ {
+ obj->priv->mount_info->model = NULL;
+ g_cancellable_cancel (obj->priv->mount_info->cancellable);
+ obj->priv->mount_info = NULL;
+ }
+}
+
+static void
gedit_file_browser_store_finalize (GObject * object)
{
GeditFileBrowserStore *obj = GEDIT_FILE_BROWSER_STORE (object);
@@ -240,6 +259,8 @@
data->removed = TRUE;
}
+
+ cancel_mount_operation (obj);
g_slist_free (obj->priv->async_handles);
G_OBJECT_CLASS (gedit_file_browser_store_parent_class)->finalize (object);
@@ -2647,14 +2668,6 @@
return GEDIT_FILE_BROWSER_STORE_RESULT_OK;
}
-typedef struct {
- GeditFileBrowserStore * model;
- gchar * virtual_root;
- GMountOperation * operation;
- GCancellable * cancellable;
-} MountInfo;
-
-
static void
handle_root_error (GeditFileBrowserStore * model, GError *error)
{
@@ -2690,12 +2703,15 @@
GeditFileBrowserStore * model = mount_info->model;
mounted = g_file_mount_enclosing_volume_finish (file, res, &error);
-
- if (g_cancellable_is_cancelled (mount_info->cancellable))
+
+ if (mount_info->model)
+ {
+ model->priv->mount_info = NULL;
+ model_end_loading (model, model->priv->root);
+ }
+
+ if (!mount_info->model || g_cancellable_is_cancelled (mount_info->cancellable))
{
- if (error)
- g_error_free (error);
-
// Reset because it might be reused?
g_cancellable_reset (mount_info->cancellable);
}
@@ -2744,12 +2760,16 @@
mount_info->operation = gtk_mount_operation_new (NULL);
mount_info->cancellable = g_object_ref (FILE_BROWSER_NODE_DIR (model->priv->root)->cancellable);
+ model_begin_loading (model, model->priv->root);
g_file_mount_enclosing_volume (model->priv->root->file,
G_MOUNT_MOUNT_NONE,
mount_info->operation,
mount_info->cancellable,
(GAsyncReadyCallback)mount_cb,
mount_info);
+
+ model->priv->mount_info = mount_info;
+ return GEDIT_FILE_BROWSER_STORE_RESULT_MOUNTING;
}
else
{
@@ -2967,6 +2987,14 @@
return (iter1->user_data == iter2->user_data);
}
+void
+gedit_file_browser_store_cancel_mount_operation (GeditFileBrowserStore *store)
+{
+ g_return_if_fail (GEDIT_IS_FILE_BROWSER_STORE (store));
+
+ cancel_mount_operation (store);
+}
+
GeditFileBrowserStoreResult
gedit_file_browser_store_set_root_and_virtual_root (GeditFileBrowserStore *
model,
@@ -3010,6 +3038,9 @@
g_object_unref (vfile);
}
+
+ /* make sure to cancel any previous mount operations */
+ cancel_mount_operation (model);
/* Always clear the model before altering the nodes */
model_clear (model, TRUE);
Modified: trunk/plugins/filebrowser/gedit-file-browser-store.h
==============================================================================
--- trunk/plugins/filebrowser/gedit-file-browser-store.h (original)
+++ trunk/plugins/filebrowser/gedit-file-browser-store.h Fri Jan 2 17:12:59 2009
@@ -59,7 +59,8 @@
GEDIT_FILE_BROWSER_STORE_RESULT_NO_CHANGE,
GEDIT_FILE_BROWSER_STORE_RESULT_ERROR,
GEDIT_FILE_BROWSER_STORE_RESULT_NO_TRASH,
- GEDIT_FILE_BROWSER_STORE_RESULT_NUM,
+ GEDIT_FILE_BROWSER_STORE_RESULT_MOUNTING,
+ GEDIT_FILE_BROWSER_STORE_RESULT_NUM
} GeditFileBrowserStoreResult;
typedef enum
@@ -191,6 +192,8 @@
GtkTreeIter * parent,
GtkTreeIter * iter);
+void gedit_file_browser_store_cancel_mount_operation (GeditFileBrowserStore *store);
+
G_END_DECLS
#endif /* __GEDIT_FILE_BROWSER_STORE_H__ */
Modified: trunk/plugins/filebrowser/gedit-file-browser-view.c
==============================================================================
--- trunk/plugins/filebrowser/gedit-file-browser-view.c (original)
+++ trunk/plugins/filebrowser/gedit-file-browser-view.c Fri Jan 2 17:12:59 2009
@@ -41,7 +41,7 @@
GtkCellRenderer *text_renderer;
GtkTreeModel *model;
- GtkTreePath *editable;
+ GtkTreeRowReference *editable;
GdkCursor *busy_cursor;
@@ -92,12 +92,6 @@
gchar * path,
gchar * new_text,
GeditFileBrowserView * tree_view);
-static void on_begin_loading (GeditFileBrowserStore * model,
- GtkTreeIter * iter,
- GeditFileBrowserView * obj);
-static void on_end_loading (GeditFileBrowserStore * model,
- GtkTreeIter * iter,
- GeditFileBrowserView * obj);
static void on_begin_refresh (GeditFileBrowserStore * model,
GeditFileBrowserView * view);
@@ -929,9 +923,15 @@
underline = PANGO_UNDERLINE_SINGLE;
}
- if (GEDIT_IS_FILE_BROWSER_STORE (tree_model)) {
- if (obj->priv->editable != NULL)
- editable = gtk_tree_path_compare (path, obj->priv->editable) == 0;
+ if (GEDIT_IS_FILE_BROWSER_STORE (tree_model))
+ {
+ if (obj->priv->editable != NULL &&
+ gtk_tree_row_reference_valid (obj->priv->editable))
+ {
+ GtkTreePath *edpath = gtk_tree_row_reference_get_path (obj->priv->editable);
+
+ editable = edpath && gtk_tree_path_compare (path, edpath) == 0;
+ }
}
gtk_tree_path_free (path);
@@ -1039,11 +1039,6 @@
cell_data_cb,
tree_view, NULL);
- g_signal_connect (model, "begin-loading",
- G_CALLBACK (on_begin_loading), tree_view);
- g_signal_connect (model, "end-loading",
- G_CALLBACK (on_end_loading), tree_view);
-
if (tree_view->priv->restore_expand_state)
install_restore_signals (tree_view, model);
@@ -1055,15 +1050,6 @@
}
if (GEDIT_IS_FILE_BROWSER_STORE (tree_view->priv->model)) {
- /* Disconnect begin_loading and end_loading */
- g_signal_handlers_disconnect_by_func (tree_view->priv->model,
- on_begin_loading,
- tree_view);
-
- g_signal_handlers_disconnect_by_func (tree_view->priv->model,
- on_end_loading,
- tree_view);
-
if (tree_view->priv->restore_expand_state)
uninstall_restore_signals (tree_view,
tree_view->priv->model);
@@ -1078,7 +1064,8 @@
GtkTreeIter * iter)
{
guint flags;
- GtkTreePath *parent;
+ GtkTreeRowReference *rowref;
+ GtkTreePath *path;
g_return_if_fail (GEDIT_IS_FILE_BROWSER_VIEW (tree_view));
g_return_if_fail (GEDIT_IS_FILE_BROWSER_STORE
@@ -1089,24 +1076,32 @@
GEDIT_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags,
-1);
- if (FILE_IS_DIR (flags) || !FILE_IS_DUMMY (flags)) {
- tree_view->priv->editable =
- gtk_tree_model_get_path (tree_view->priv->model, iter);
+ if (!(FILE_IS_DIR (flags) || !FILE_IS_DUMMY (flags)))
+ return;
- /* Start editing */
- gtk_widget_grab_focus (GTK_WIDGET (tree_view));
-
- parent = gtk_tree_path_copy (tree_view->priv->editable);
-
- if (gtk_tree_path_up (parent))
- gtk_tree_view_expand_to_path (GTK_TREE_VIEW (tree_view),
- parent);
-
- gtk_tree_path_free (parent);
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (tree_view),
- tree_view->priv->editable,
- tree_view->priv->column, TRUE);
- }
+ path = gtk_tree_model_get_path (tree_view->priv->model, iter);
+ rowref = gtk_tree_row_reference_new (tree_view->priv->model, path);
+
+ /* Start editing */
+ gtk_widget_grab_focus (GTK_WIDGET (tree_view));
+
+ if (gtk_tree_path_up (path))
+ gtk_tree_view_expand_to_path (GTK_TREE_VIEW (tree_view),
+ path);
+
+ gtk_tree_path_free (path);
+ tree_view->priv->editable = rowref;
+
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (tree_view),
+ gtk_tree_row_reference_get_path (tree_view->priv->editable),
+ tree_view->priv->column, TRUE);
+
+ gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (tree_view),
+ gtk_tree_row_reference_get_path (tree_view->priv->editable),
+ tree_view->priv->column,
+ TRUE,
+ 0.5,
+ 1);
}
void
@@ -1140,7 +1135,7 @@
gboolean ret;
GError * error = NULL;
- gtk_tree_path_free (tree_view->priv->editable);
+ gtk_tree_row_reference_free (tree_view->priv->editable);
tree_view->priv->editable = NULL;
if (new_text == NULL || *new_text == '\0')
@@ -1163,24 +1158,6 @@
}
}
-static void
-on_begin_loading (GeditFileBrowserStore * model, GtkTreeIter * iter,
- GeditFileBrowserView * obj)
-{
- if (GDK_IS_WINDOW (GTK_WIDGET (obj)->window))
- gdk_window_set_cursor (GTK_WIDGET (obj)->window,
- obj->priv->busy_cursor);
-}
-
-static void
-on_end_loading (GeditFileBrowserStore * model, GtkTreeIter * iter,
- GeditFileBrowserView * obj)
-{
- if (GDK_IS_WINDOW (GTK_WIDGET (obj)->window))
- gdk_window_set_cursor (GTK_WIDGET (obj)->window,
- obj->priv->hand_cursor);
-}
-
static void
on_begin_refresh (GeditFileBrowserStore * model,
GeditFileBrowserView * view)
Modified: trunk/plugins/filebrowser/gedit-file-browser-widget.c
==============================================================================
--- trunk/plugins/filebrowser/gedit-file-browser-widget.c (original)
+++ trunk/plugins/filebrowser/gedit-file-browser-widget.c Fri Jan 2 17:12:59 2009
@@ -153,6 +153,8 @@
gboolean enable_delete;
GCancellable *cancellable;
+
+ GdkCursor *busy_cursor;
};
static void set_enable_delete (GeditFileBrowserWidget *obj,
@@ -349,6 +351,9 @@
g_hash_table_destroy (obj->priv->bookmarks_hash);
cancel_async_operation (obj);
+
+ gdk_cursor_unref (obj->priv->busy_cursor);
+
G_OBJECT_CLASS (gedit_file_browser_widget_parent_class)->finalize (object);
}
@@ -1072,6 +1077,28 @@
}
static void
+on_begin_loading (GeditFileBrowserStore *model,
+ GtkTreeIter *iter,
+ GeditFileBrowserWidget *obj)
+{
+ if (!GDK_IS_WINDOW (GTK_WIDGET (obj->priv->treeview)->window))
+ return;
+
+ gdk_window_set_cursor (GTK_WIDGET (obj)->window, obj->priv->busy_cursor);
+}
+
+static void
+on_end_loading (GeditFileBrowserStore *model,
+ GtkTreeIter *iter,
+ GeditFileBrowserWidget *obj)
+{
+ if (!GDK_IS_WINDOW (GTK_WIDGET (obj->priv->treeview)->window))
+ return;
+
+ gdk_window_set_cursor (GTK_WIDGET (obj)->window, NULL);
+}
+
+static void
create_tree (GeditFileBrowserWidget * obj)
{
GtkWidget *sw;
@@ -1120,6 +1147,18 @@
g_signal_connect (obj->priv->file_store, "notify::filter-mode",
G_CALLBACK (on_filter_mode_changed), obj);
+ g_signal_connect (obj->priv->file_store, "notify::virtual-root",
+ G_CALLBACK (on_virtual_root_changed), obj);
+
+ g_signal_connect (obj->priv->file_store, "begin-loading",
+ G_CALLBACK (on_begin_loading), obj);
+
+ g_signal_connect (obj->priv->file_store, "end-loading",
+ G_CALLBACK (on_end_loading), obj);
+
+ g_signal_connect (obj->priv->file_store, "error",
+ G_CALLBACK (on_file_store_error), obj);
+
init_bookmarks_hash (obj);
gtk_widget_show (sw);
@@ -1169,6 +1208,8 @@
free_name_icon);
gtk_box_set_spacing (GTK_BOX (obj), 3);
+
+ obj->priv->busy_cursor = gdk_cursor_new (GDK_WATCH);
}
/* Private */
@@ -1732,8 +1773,6 @@
gchar const *virtual_root)
{
GeditFileBrowserStoreResult result;
-
- show_files_real (obj, FALSE);
if (!virtual_root)
result =
@@ -1744,7 +1783,8 @@
gedit_file_browser_store_set_root_and_virtual_root
(obj->priv->file_store, root, virtual_root);
- show_files_real (obj, result == GEDIT_FILE_BROWSER_STORE_RESULT_NO_CHANGE);
+ if (result == GEDIT_FILE_BROWSER_STORE_RESULT_NO_CHANGE)
+ show_files_real (obj, TRUE);
}
void
@@ -2259,12 +2299,14 @@
if (flags & GEDIT_FILE_BOOKMARKS_STORE_IS_DRIVE)
{
/* handle a drive node */
+ gedit_file_browser_store_cancel_mount_operation (obj->priv->file_store);
activate_drive (obj, iter);
return;
}
else if (flags & GEDIT_FILE_BOOKMARKS_STORE_IS_VOLUME)
{
/* handle a volume node */
+ gedit_file_browser_store_cancel_mount_operation (obj->priv->file_store);
activate_volume (obj, iter);
return;
}
@@ -2345,6 +2387,12 @@
Location *loc;
GdkPixbuf *pixbuf;
+ if (gtk_tree_view_get_model (GTK_TREE_VIEW (obj->priv->treeview)) !=
+ GTK_TREE_MODEL (obj->priv->file_store))
+ {
+ show_files_real (obj, FALSE);
+ }
+
if (gedit_file_browser_store_get_iter_virtual_root (model, &iter)) {
gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
GEDIT_FILE_BROWSER_STORE_COLUMN_URI,
@@ -2484,16 +2532,6 @@
g_signal_connect (gobject, "file-activated",
G_CALLBACK
(on_file_activated), obj));
- add_signal (obj, model,
- g_signal_connect (model,
- "notify::virtual-root",
- G_CALLBACK
- (on_virtual_root_changed),
- obj));
- add_signal (obj, model,
- g_signal_connect (model, "error",
- G_CALLBACK
- (on_file_store_error), obj));
add_signal (obj, model,
g_signal_connect (model, "no-trash",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]