[gedit] Update coding style in file browser plugin (fixes bug #616964)
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Update coding style in file browser plugin (fixes bug #616964)
- Date: Wed, 28 Apr 2010 07:14:50 +0000 (UTC)
commit eefaaf6eacc9a2f31a36074bf66be2e8cf2207fb
Author: Garrett Regier <alias301 gmail com>
Date: Tue Apr 27 11:01:32 2010 -0700
Update coding style in file browser plugin (fixes bug #616964)
plugins/filebrowser/gedit-file-bookmarks-store.c | 413 +++---
plugins/filebrowser/gedit-file-bookmarks-store.h | 15 +-
plugins/filebrowser/gedit-file-browser-messages.c | 42 +-
plugins/filebrowser/gedit-file-browser-messages.h | 6 +-
plugins/filebrowser/gedit-file-browser-plugin.c | 515 ++++----
plugins/filebrowser/gedit-file-browser-plugin.h | 11 +-
plugins/filebrowser/gedit-file-browser-store.c | 1574 +++++++++++---------
plugins/filebrowser/gedit-file-browser-store.h | 174 ++--
plugins/filebrowser/gedit-file-browser-utils.c | 65 +-
plugins/filebrowser/gedit-file-browser-utils.h | 49 +-
plugins/filebrowser/gedit-file-browser-view.c | 426 +++---
plugins/filebrowser/gedit-file-browser-view.h | 51 +-
plugins/filebrowser/gedit-file-browser-widget.c | 939 +++++++------
plugins/filebrowser/gedit-file-browser-widget.h | 107 +-
14 files changed, 2358 insertions(+), 2029 deletions(-)
---
diff --git a/plugins/filebrowser/gedit-file-bookmarks-store.c b/plugins/filebrowser/gedit-file-bookmarks-store.c
index eaec8d4..3fa74cb 100644
--- a/plugins/filebrowser/gedit-file-bookmarks-store.c
+++ b/plugins/filebrowser/gedit-file-bookmarks-store.c
@@ -1,19 +1,19 @@
/*
- * gedit-file-bookmarks-store.c - Gedit plugin providing easy file access
+ * gedit-file-bookmarks-store.c - Gedit plugin providing easy file access
* from the sidepanel
- *
+ *
* Copyright (C) 2006 - Jesse van den Kieboom <jesse icecrew nl>
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@@ -32,38 +32,39 @@
G_TYPE_INSTANCE_GET_PRIVATE((object), GEDIT_TYPE_FILE_BOOKMARKS_STORE, \
GeditFileBookmarksStorePrivate))
-struct _GeditFileBookmarksStorePrivate
+struct _GeditFileBookmarksStorePrivate
{
- GVolumeMonitor * volume_monitor;
- GFileMonitor * bookmarks_monitor;
+ GVolumeMonitor *volume_monitor;
+ GFileMonitor *bookmarks_monitor;
};
-static void remove_node (GtkTreeModel * model,
- GtkTreeIter * iter);
-
-static void on_fs_changed (GVolumeMonitor *monitor,
- GObject *object,
- GeditFileBookmarksStore *model);
-
-static void on_bookmarks_file_changed (GFileMonitor * monitor,
- GFile * file,
- GFile * other_file,
- GFileMonitorEvent event_type,
- GeditFileBookmarksStore * model);
-static gboolean find_with_flags (GtkTreeModel * model,
- GtkTreeIter * iter,
- gpointer obj,
- guint flags,
- guint notflags);
+static void remove_node (GtkTreeModel *model,
+ GtkTreeIter *iter);
+
+static void on_fs_changed (GVolumeMonitor *monitor,
+ GObject *object,
+ GeditFileBookmarksStore *model);
+
+static void on_bookmarks_file_changed (GFileMonitor *monitor,
+ GFile *file,
+ GFile *other_file,
+ GFileMonitorEvent event_type,
+ GeditFileBookmarksStore *model);
+static gboolean find_with_flags (GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer obj,
+ guint flags,
+ guint notflags);
GEDIT_PLUGIN_DEFINE_TYPE(GeditFileBookmarksStore, gedit_file_bookmarks_store, GTK_TYPE_TREE_STORE)
static void
-gedit_file_bookmarks_store_dispose (GObject * object)
+gedit_file_bookmarks_store_dispose (GObject *object)
{
GeditFileBookmarksStore *obj = GEDIT_FILE_BOOKMARKS_STORE (object);
- if (obj->priv->volume_monitor != NULL) {
+ if (obj->priv->volume_monitor != NULL)
+ {
g_signal_handlers_disconnect_by_func (obj->priv->volume_monitor,
on_fs_changed,
obj);
@@ -72,7 +73,8 @@ gedit_file_bookmarks_store_dispose (GObject * object)
obj->priv->volume_monitor = NULL;
}
- if (obj->priv->bookmarks_monitor != NULL) {
+ if (obj->priv->bookmarks_monitor != NULL)
+ {
g_object_unref (obj->priv->bookmarks_monitor);
obj->priv->bookmarks_monitor = NULL;
}
@@ -81,7 +83,7 @@ gedit_file_bookmarks_store_dispose (GObject * object)
}
static void
-gedit_file_bookmarks_store_finalize (GObject * object)
+gedit_file_bookmarks_store_finalize (GObject *object)
{
G_OBJECT_CLASS (gedit_file_bookmarks_store_parent_class)->finalize (object);
}
@@ -98,19 +100,19 @@ gedit_file_bookmarks_store_class_init (GeditFileBookmarksStoreClass *klass)
}
static void
-gedit_file_bookmarks_store_init (GeditFileBookmarksStore * obj)
+gedit_file_bookmarks_store_init (GeditFileBookmarksStore *obj)
{
obj->priv = GEDIT_FILE_BOOKMARKS_STORE_GET_PRIVATE (obj);
}
/* Private */
static void
-add_node (GeditFileBookmarksStore *model,
- GdkPixbuf *pixbuf,
- const gchar *name,
- GObject *obj,
- guint flags,
- GtkTreeIter *iter)
+add_node (GeditFileBookmarksStore *model,
+ GdkPixbuf *pixbuf,
+ const gchar *name,
+ GObject *obj,
+ guint flags,
+ GtkTreeIter *iter)
{
GtkTreeIter newiter;
@@ -128,11 +130,11 @@ add_node (GeditFileBookmarksStore *model,
}
static gboolean
-add_file (GeditFileBookmarksStore *model,
- GFile *file,
- const gchar *name,
- guint flags,
- GtkTreeIter *iter)
+add_file (GeditFileBookmarksStore *model,
+ GFile *file,
+ const gchar *name,
+ guint flags,
+ GtkTreeIter *iter)
{
GdkPixbuf *pixbuf = NULL;
gboolean native;
@@ -140,7 +142,8 @@ add_file (GeditFileBookmarksStore *model,
native = g_file_is_native (file);
- if (native && !g_file_query_exists (file, NULL)) {
+ if (native && !g_file_query_exists (file, NULL))
+ {
return FALSE;
}
@@ -151,20 +154,19 @@ add_file (GeditFileBookmarksStore *model,
else if (flags & GEDIT_FILE_BOOKMARKS_STORE_IS_ROOT)
pixbuf = gedit_file_browser_utils_pixbuf_from_theme ("drive-harddisk", GTK_ICON_SIZE_MENU);
- if (pixbuf == NULL) {
+ if (pixbuf == NULL)
+ {
/* getting the icon is a sync get_info call, so we just do it for local files */
- if (native) {
+ if (native)
pixbuf = gedit_file_browser_utils_pixbuf_from_file (file, GTK_ICON_SIZE_MENU);
- } else {
+ else
pixbuf = gedit_file_browser_utils_pixbuf_from_theme ("folder", GTK_ICON_SIZE_MENU);
- }
}
- if (name == NULL) {
+ if (name == NULL)
newname = gedit_file_browser_utils_file_basename (file);
- } else {
+ else
newname = g_strdup (name);
- }
add_node (model, pixbuf, newname, G_OBJECT (file), flags, iter);
@@ -177,8 +179,9 @@ add_file (GeditFileBookmarksStore *model,
}
static void
-check_mount_separator (GeditFileBookmarksStore * model, guint flags,
- gboolean added)
+check_mount_separator (GeditFileBookmarksStore *model,
+ guint flags,
+ gboolean added)
{
GtkTreeIter iter;
gboolean found;
@@ -188,21 +191,20 @@ check_mount_separator (GeditFileBookmarksStore * model, guint flags,
flags |
GEDIT_FILE_BOOKMARKS_STORE_IS_SEPARATOR, 0);
- if (added && !found) {
+ if (added && !found)
/* Add the separator */
add_node (model, NULL, NULL, NULL,
flags | GEDIT_FILE_BOOKMARKS_STORE_IS_SEPARATOR,
NULL);
- } else if (!added && found) {
+ else if (!added && found)
remove_node (GTK_TREE_MODEL (model), &iter);
- }
}
static void
-init_special_directories (GeditFileBookmarksStore * model)
+init_special_directories (GeditFileBookmarksStore *model)
{
gchar const *path;
- GFile * file;
+ GFile *file;
path = g_get_home_dir ();
if (path != NULL)
@@ -227,14 +229,14 @@ init_special_directories (GeditFileBookmarksStore * model)
{
file = g_file_new_for_path (path);
add_file (model, file, NULL, GEDIT_FILE_BOOKMARKS_STORE_IS_DOCUMENTS |
- GEDIT_FILE_BOOKMARKS_STORE_IS_SPECIAL_DIR, NULL);
+ GEDIT_FILE_BOOKMARKS_STORE_IS_SPECIAL_DIR, NULL);
g_object_unref (file);
}
-
+
file = g_file_new_for_uri ("file:///");
add_file (model, file, _("File System"), GEDIT_FILE_BOOKMARKS_STORE_IS_ROOT, NULL);
g_object_unref (file);
-
+
check_mount_separator (model, GEDIT_FILE_BOOKMARKS_STORE_IS_ROOT, TRUE);
}
@@ -249,50 +251,50 @@ get_fs_properties (gpointer fs,
*flags = GEDIT_FILE_BOOKMARKS_STORE_IS_FS;
*name = NULL;
*pixbuf = NULL;
-
+
if (G_IS_DRIVE (fs))
{
icon = g_drive_get_icon (G_DRIVE (fs));
*name = g_drive_get_name (G_DRIVE (fs));
-
+
*flags |= GEDIT_FILE_BOOKMARKS_STORE_IS_DRIVE;
}
else if (G_IS_VOLUME (fs))
{
icon = g_volume_get_icon (G_VOLUME (fs));
*name = g_volume_get_name (G_VOLUME (fs));
-
+
*flags |= GEDIT_FILE_BOOKMARKS_STORE_IS_VOLUME;
}
else if (G_IS_MOUNT (fs))
{
icon = g_mount_get_icon (G_MOUNT (fs));
*name = g_mount_get_name (G_MOUNT (fs));
-
+
*flags |= GEDIT_FILE_BOOKMARKS_STORE_IS_MOUNT;
}
-
+
if (icon)
{
*pixbuf = gedit_file_browser_utils_pixbuf_from_icon (icon, GTK_ICON_SIZE_MENU);
g_object_unref (icon);
}
}
-
+
static void
add_fs (GeditFileBookmarksStore *model,
- gpointer fs,
- guint flags,
- GtkTreeIter *iter)
+ gpointer fs,
+ guint flags,
+ GtkTreeIter *iter)
{
gchar *name;
GdkPixbuf *pixbuf;
guint fsflags;
-
+
get_fs_properties (fs, &name, &pixbuf, &fsflags);
add_node (model, pixbuf, name, fs, flags | fsflags, iter);
-
+
if (pixbuf)
g_object_unref (pixbuf);
@@ -301,13 +303,13 @@ add_fs (GeditFileBookmarksStore *model,
}
static void
-process_volume_cb (GVolume *volume,
+process_volume_cb (GVolume *volume,
GeditFileBookmarksStore *model)
{
GMount *mount;
guint flags = GEDIT_FILE_BOOKMARKS_STORE_NONE;
mount = g_volume_get_mount (volume);
-
+
/* CHECK: should we use the LOCAL/REMOTE thing still? */
if (mount)
{
@@ -325,22 +327,20 @@ process_volume_cb (GVolume *volume,
static void
process_drive_novolumes (GeditFileBookmarksStore *model,
- GDrive *drive)
+ GDrive *drive)
{
if (g_drive_is_media_removable (drive) &&
!g_drive_is_media_check_automatic (drive) &&
g_drive_can_poll_for_media (drive))
- {
- /* This can be the case for floppy drives or other
+ /* This can be the case for floppy drives or other
drives where media detection fails. We show the
drive and poll for media when the user activates
it */
add_fs (model, drive, GEDIT_FILE_BOOKMARKS_STORE_NONE, NULL);
- }
}
static void
-process_drive_cb (GDrive *drive,
+process_drive_cb (GDrive *drive,
GeditFileBookmarksStore *model)
{
GList *volumes;
@@ -356,14 +356,14 @@ process_drive_cb (GDrive *drive,
else
{
process_drive_novolumes (model, drive);
- }
+ }
}
static void
init_drives (GeditFileBookmarksStore *model)
{
GList *drives;
-
+
drives = g_volume_monitor_get_connected_drives (model->priv->volume_monitor);
g_list_foreach (drives, (GFunc)process_drive_cb, model);
@@ -372,19 +372,19 @@ init_drives (GeditFileBookmarksStore *model)
}
static void
-process_volume_nodrive_cb (GVolume *volume,
+process_volume_nodrive_cb (GVolume *volume,
GeditFileBookmarksStore *model)
{
GDrive *drive;
-
+
drive = g_volume_get_drive (volume);
-
+
if (drive)
{
g_object_unref (drive);
return;
}
-
+
process_volume_cb (volume, model);
}
@@ -392,49 +392,46 @@ static void
init_volumes (GeditFileBookmarksStore *model)
{
GList *volumes;
-
+
volumes = g_volume_monitor_get_volumes (model->priv->volume_monitor);
-
+
g_list_foreach (volumes, (GFunc)process_volume_nodrive_cb, model);
g_list_foreach (volumes, (GFunc)g_object_unref, NULL);
g_list_free (volumes);
}
static void
-process_mount_novolume_cb (GMount *mount,
+process_mount_novolume_cb (GMount *mount,
GeditFileBookmarksStore *model)
{
GVolume *volume;
-
+
volume = g_mount_get_volume (mount);
-
+
if (volume)
- {
g_object_unref (volume);
- }
else if (!g_mount_is_shadowed (mount))
- {
/* Add the mount */
add_fs (model, mount, GEDIT_FILE_BOOKMARKS_STORE_NONE, NULL);
- }
}
static void
init_mounts (GeditFileBookmarksStore *model)
{
GList *mounts;
-
+
mounts = g_volume_monitor_get_mounts (model->priv->volume_monitor);
-
+
g_list_foreach (mounts, (GFunc)process_mount_novolume_cb, model);
g_list_foreach (mounts, (GFunc)g_object_unref, NULL);
g_list_free (mounts);
}
static void
-init_fs (GeditFileBookmarksStore * model)
+init_fs (GeditFileBookmarksStore *model)
{
- if (model->priv->volume_monitor == NULL) {
+ if (model->priv->volume_monitor == NULL)
+ {
const gchar **ptr;
const gchar *signals[] = {
"drive-connected", "drive-changed", "drive-disconnected",
@@ -442,55 +439,52 @@ init_fs (GeditFileBookmarksStore * model)
"mount-added", "mount-removed", "mount-changed",
NULL
};
-
+
model->priv->volume_monitor = g_volume_monitor_get ();
- /* Connect signals */
+ /* Connect signals */
for (ptr = signals; *ptr; ptr++)
- {
g_signal_connect (model->priv->volume_monitor,
*ptr,
G_CALLBACK (on_fs_changed), model);
- }
}
/* First go through all the connected drives */
init_drives (model);
-
+
/* Then add all volumes, not associated with a drive */
init_volumes (model);
-
+
/* Then finally add all mounts that have no volume */
init_mounts (model);
}
static gboolean
-add_bookmark (GeditFileBookmarksStore * model,
- gchar const * name,
- gchar const * uri)
+add_bookmark (GeditFileBookmarksStore *model,
+ gchar const *name,
+ gchar const *uri)
{
- GFile * file;
+ GFile *file;
gboolean ret;
guint flags = GEDIT_FILE_BOOKMARKS_STORE_IS_BOOKMARK;
GtkTreeIter iter;
-
+
file = g_file_new_for_uri (uri);
-
- if (g_file_is_native (file)) {
+
+ if (g_file_is_native (file))
flags |= GEDIT_FILE_BOOKMARKS_STORE_IS_LOCAL_BOOKMARK;
- } else {
+ else
flags |= GEDIT_FILE_BOOKMARKS_STORE_IS_REMOTE_BOOKMARK;
- }
ret = add_file (model, file, name, flags, &iter);
g_object_unref (file);
-
+
return ret;
}
static void
-init_bookmarks (GeditFileBookmarksStore * model)
+init_bookmarks (GeditFileBookmarksStore *model)
{
gchar *bookmarks;
GError *error = NULL;
@@ -504,29 +498,37 @@ init_bookmarks (GeditFileBookmarksStore * model)
".gtk-bookmarks",
NULL);
- if (g_file_get_contents (bookmarks, &contents, NULL, &error)) {
+ if (g_file_get_contents (bookmarks, &contents, NULL, &error))
+ {
lines = g_strsplit (contents, "\n", 0);
- for (line = lines; *line; ++line) {
- if (**line) {
+ 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) {
+ if (pos != NULL)
+ {
*pos = '\0';
name = pos + 1;
- } else {
+ }
+ else
+ {
name = NULL;
}
/* the bookmarks file should contain valid
* URIs, but paranoia is good */
location = g_file_new_for_uri (*line);
- if (gedit_utils_is_valid_location (location)) {
+ if (gedit_utils_is_valid_location (location))
+ {
added |= add_bookmark (model, name, *line);
}
g_object_unref (location);
@@ -537,24 +539,28 @@ init_bookmarks (GeditFileBookmarksStore * model)
g_free (contents);
/* Add a watch */
- if (model->priv->bookmarks_monitor == NULL) {
- GFile * file;
+ 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,
+ g_signal_connect (model->priv->bookmarks_monitor,
+ "changed",
+ G_CALLBACK (on_bookmarks_file_changed),
model);
}
- } else {
+ }
+ else
+ {
/* The bookmarks file doesn't exist (which is perfectly fine) */
g_error_free (error);
}
- if (added) {
+ if (added)
+ {
/* Bookmarks separator */
add_node (model, NULL, NULL, NULL,
GEDIT_FILE_BOOKMARKS_STORE_IS_BOOKMARK |
@@ -575,7 +581,7 @@ static gint flags_order[] = {
};
static gint
-utf8_casecmp (gchar const *s1, const gchar * s2)
+utf8_casecmp (gchar const *s1, const gchar *s2)
{
gchar *n1;
gchar *n2;
@@ -593,8 +599,9 @@ utf8_casecmp (gchar const *s1, const gchar * s2)
}
static gint
-bookmarks_compare_names (GtkTreeModel * model, GtkTreeIter * a,
- GtkTreeIter * b)
+bookmarks_compare_names (GtkTreeModel *model,
+ GtkTreeIter *a,
+ GtkTreeIter *b)
{
gchar *n1;
gchar *n2;
@@ -631,8 +638,9 @@ bookmarks_compare_names (GtkTreeModel * model, GtkTreeIter * a,
}
static gint
-bookmarks_compare_flags (GtkTreeModel * model, GtkTreeIter * a,
- GtkTreeIter * b)
+bookmarks_compare_flags (GtkTreeModel *model,
+ GtkTreeIter *a,
+ GtkTreeIter *b)
{
guint f1;
guint f2;
@@ -648,14 +656,17 @@ bookmarks_compare_flags (GtkTreeModel * model, GtkTreeIter * a,
GEDIT_FILE_BOOKMARKS_STORE_COLUMN_FLAGS, &f2,
-1);
- for (flags = flags_order; *flags != -1; ++flags) {
- if ((f1 & *flags) != (f2 & *flags)) {
- if (f1 & *flags) {
+ for (flags = flags_order; *flags != -1; ++flags)
+ {
+ if ((f1 & *flags) != (f2 & *flags))
+ {
+ if (f1 & *flags)
return -1;
- } else {
+ else
return 1;
- }
- } else if ((f1 & *flags) && (f1 & sep) != (f2 & sep)) {
+ }
+ else if ((f1 & *flags) && (f1 & sep) != (f2 & sep))
+ {
if (f1 & sep)
return -1;
else
@@ -667,8 +678,10 @@ bookmarks_compare_flags (GtkTreeModel * model, GtkTreeIter * a,
}
static gint
-bookmarks_compare_func (GtkTreeModel * model, GtkTreeIter * a,
- GtkTreeIter * b, gpointer user_data)
+bookmarks_compare_func (GtkTreeModel *model,
+ GtkTreeIter *a,
+ GtkTreeIter *b,
+ gpointer user_data)
{
gint result;
@@ -681,42 +694,46 @@ bookmarks_compare_func (GtkTreeModel * model, GtkTreeIter * a,
}
static gboolean
-find_with_flags (GtkTreeModel * model, GtkTreeIter * iter, gpointer obj,
- guint flags, guint notflags)
+find_with_flags (GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer obj,
+ guint flags,
+ guint notflags)
{
GtkTreeIter child;
guint childflags = 0;
- GObject * childobj;
+ GObject *childobj;
gboolean fequal;
-
+
if (!gtk_tree_model_get_iter_first (model, &child))
return FALSE;
- do {
+ do
+ {
gtk_tree_model_get (model, &child,
GEDIT_FILE_BOOKMARKS_STORE_COLUMN_OBJECT,
&childobj,
GEDIT_FILE_BOOKMARKS_STORE_COLUMN_FLAGS,
&childflags, -1);
-
+
fequal = (obj == childobj);
-
+
if (childobj)
g_object_unref (childobj);
-
+
if ((obj == NULL || fequal) &&
(childflags & flags) == flags
- && !(childflags & notflags)) {
+ && !(childflags & notflags))
*iter = child;
return TRUE;
- }
- } while (gtk_tree_model_iter_next (model, &child));
+ }
+ while (gtk_tree_model_iter_next (model, &child));
return FALSE;
}
static void
-remove_node (GtkTreeModel * model, GtkTreeIter * iter)
+remove_node (GtkTreeModel *model, GtkTreeIter *iter)
{
guint flags;
@@ -724,19 +741,17 @@ remove_node (GtkTreeModel * model, GtkTreeIter * iter)
GEDIT_FILE_BOOKMARKS_STORE_COLUMN_FLAGS, &flags,
-1);
- if (!(flags & GEDIT_FILE_BOOKMARKS_STORE_IS_SEPARATOR)) {
- if (flags & GEDIT_FILE_BOOKMARKS_STORE_IS_FS) {
- check_mount_separator (GEDIT_FILE_BOOKMARKS_STORE (model),
- flags & GEDIT_FILE_BOOKMARKS_STORE_IS_FS,
- FALSE);
- }
- }
+ if (!(flags & GEDIT_FILE_BOOKMARKS_STORE_IS_SEPARATOR) &&
+ flags & GEDIT_FILE_BOOKMARKS_STORE_IS_FS)
+ check_mount_separator (GEDIT_FILE_BOOKMARKS_STORE (model),
+ flags & GEDIT_FILE_BOOKMARKS_STORE_IS_FS,
+ FALSE);
gtk_tree_store_remove (GTK_TREE_STORE (model), iter);
}
static void
-remove_bookmarks (GeditFileBookmarksStore * model)
+remove_bookmarks (GeditFileBookmarksStore *model)
{
GtkTreeIter iter;
@@ -748,7 +763,7 @@ remove_bookmarks (GeditFileBookmarksStore * model)
}
static void
-initialize_fill (GeditFileBookmarksStore * model)
+initialize_fill (GeditFileBookmarksStore *model)
{
init_special_directories (model);
init_fs (model);
@@ -785,22 +800,22 @@ gedit_file_bookmarks_store_new (void)
}
GFile *
-gedit_file_bookmarks_store_get_location (GeditFileBookmarksStore * model,
- GtkTreeIter * iter)
+gedit_file_bookmarks_store_get_location (GeditFileBookmarksStore *model,
+ GtkTreeIter *iter)
{
- GObject * obj;
- GFile * file = NULL;
+ GObject *obj;
+ GFile *file = NULL;
guint flags;
GFile * ret = NULL;
gboolean isfs;
-
+
g_return_val_if_fail (GEDIT_IS_FILE_BOOKMARKS_STORE (model), NULL);
g_return_val_if_fail (iter != NULL, NULL);
gtk_tree_model_get (GTK_TREE_MODEL (model), iter,
GEDIT_FILE_BOOKMARKS_STORE_COLUMN_FLAGS,
&flags,
- GEDIT_FILE_BOOKMARKS_STORE_COLUMN_OBJECT,
+ GEDIT_FILE_BOOKMARKS_STORE_COLUMN_OBJECT,
&obj,
-1);
@@ -808,37 +823,33 @@ gedit_file_bookmarks_store_get_location (GeditFileBookmarksStore * model,
return NULL;
isfs = (flags & GEDIT_FILE_BOOKMARKS_STORE_IS_FS);
-
+
if (isfs && (flags & GEDIT_FILE_BOOKMARKS_STORE_IS_MOUNT))
- {
file = g_mount_get_root (G_MOUNT (obj));
- }
else if (!isfs)
- {
file = g_object_ref (obj);
- }
-
+
g_object_unref (obj);
-
+
if (file)
{
ret = g_file_dup (file);
g_object_unref (file);
}
-
+
return ret;
}
void
-gedit_file_bookmarks_store_refresh (GeditFileBookmarksStore * model)
+gedit_file_bookmarks_store_refresh (GeditFileBookmarksStore *model)
{
gtk_tree_store_clear (GTK_TREE_STORE (model));
initialize_fill (model);
}
static void
-on_fs_changed (GVolumeMonitor *monitor,
- GObject *object,
+on_fs_changed (GVolumeMonitor *monitor,
+ GObject *object,
GeditFileBookmarksStore *model)
{
GtkTreeModel *tree_model = GTK_TREE_MODEL (model);
@@ -849,34 +860,34 @@ on_fs_changed (GVolumeMonitor *monitor,
/* clear all fs items */
while (find_with_flags (tree_model, &iter, NULL, flags, noflags))
remove_node (tree_model, &iter);
-
+
/* then reinitialize */
init_fs (model);
}
static void
-on_bookmarks_file_changed (GFileMonitor * monitor,
- GFile * file,
- GFile * other_file,
- GFileMonitorEvent event_type,
- GeditFileBookmarksStore * model)
-{
- switch (event_type) {
- case G_FILE_MONITOR_EVENT_CHANGED:
- case G_FILE_MONITOR_EVENT_CREATED:
- /* Re-initialize bookmarks */
- remove_bookmarks (model);
- init_bookmarks (model);
- break;
- case G_FILE_MONITOR_EVENT_DELETED: // FIXME: shouldn't we also monitor the directory?
- /* Remove bookmarks */
- remove_bookmarks (model);
- g_object_unref (monitor);
- model->priv->bookmarks_monitor = NULL;
- break;
- default:
- break;
+on_bookmarks_file_changed (GFileMonitor *monitor,
+ GFile *file,
+ GFile *other_file,
+ GFileMonitorEvent event_type,
+ GeditFileBookmarksStore *model)
+{
+ switch (event_type)
+ {
+ case G_FILE_MONITOR_EVENT_CHANGED:
+ case G_FILE_MONITOR_EVENT_CREATED:
+ /* Re-initialize bookmarks */
+ remove_bookmarks (model);
+ init_bookmarks (model);
+ break;
+ /* FIXME: shouldn't we also monitor the directory? */
+ case G_FILE_MONITOR_EVENT_DELETED:
+ /* Remove bookmarks */
+ remove_bookmarks (model);
+ g_object_unref (monitor);
+ model->priv->bookmarks_monitor = NULL;
+ break;
+ default:
+ break;
}
}
-
-// ex:ts=8:noet:
diff --git a/plugins/filebrowser/gedit-file-bookmarks-store.h b/plugins/filebrowser/gedit-file-bookmarks-store.h
index d0152c1..89da7f9 100644
--- a/plugins/filebrowser/gedit-file-bookmarks-store.h
+++ b/plugins/filebrowser/gedit-file-bookmarks-store.h
@@ -76,15 +76,14 @@ struct _GeditFileBookmarksStoreClass
GtkTreeStoreClass parent_class;
};
-GType gedit_file_bookmarks_store_get_type (void) G_GNUC_CONST;
-GType gedit_file_bookmarks_store_register_type (GTypeModule * module);
+GType gedit_file_bookmarks_store_get_type (void) G_GNUC_CONST;
+GType gedit_file_bookmarks_store_register_type (GTypeModule *module);
-GeditFileBookmarksStore *gedit_file_bookmarks_store_new (void);
-GFile *gedit_file_bookmarks_store_get_location (GeditFileBookmarksStore * model,
- GtkTreeIter * iter);
-void gedit_file_bookmarks_store_refresh (GeditFileBookmarksStore * model);
+GeditFileBookmarksStore *gedit_file_bookmarks_store_new (void);
+GFile *gedit_file_bookmarks_store_get_location (GeditFileBookmarksStore *model,
+ GtkTreeIter *iter);
+void gedit_file_bookmarks_store_refresh (GeditFileBookmarksStore *model);
G_END_DECLS
-#endif /* __GEDIT_FILE_BOOKMARKS_STORE_H__ */
-// ex:ts=8:noet:
+#endif /* __GEDIT_FILE_BOOKMARKS_STORE_H__ */
diff --git a/plugins/filebrowser/gedit-file-browser-messages.c b/plugins/filebrowser/gedit-file-browser-messages.c
index 7258950..0bf33b7 100644
--- a/plugins/filebrowser/gedit-file-browser-messages.c
+++ b/plugins/filebrowser/gedit-file-browser-messages.c
@@ -1,3 +1,23 @@
+/*
+ * gedit-file-browser-messages.c
+ *
+ * Copyright (C) 2006 - Jesse van den Kieboom <jesse icecrew nl>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
#include "gedit-file-browser-messages.h"
#include "gedit-file-browser-store.h"
#include <gedit/gedit-message.h>
@@ -9,7 +29,7 @@
typedef struct
{
- GeditWindow *window;
+ GeditWindow *window;
GeditMessage *message;
} MessageCacheData;
@@ -35,7 +55,7 @@ typedef struct
{
gulong id;
- GeditWindow *window;
+ GeditWindow *window;
GeditMessage *message;
} FilterData;
@@ -73,7 +93,7 @@ window_data_new (GeditWindow *window,
}
static WindowData *
-get_window_data (GeditWindow * window)
+get_window_data (GeditWindow *window)
{
return (WindowData *) (g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY));
}
@@ -161,8 +181,8 @@ message_cache_data_free (MessageCacheData *data)
}
static MessageCacheData *
-message_cache_data_new (GeditWindow *window,
- GeditMessage *message)
+message_cache_data_new (GeditWindow *window,
+ GeditMessage *message)
{
MessageCacheData *data = g_slice_new (MessageCacheData);
@@ -343,11 +363,9 @@ set_item_message (WindowData *data,
NULL);
if (gedit_message_has_key (message, "is_directory"))
- {
gedit_message_set (message,
"is_directory", FILE_IS_DIR (flags),
NULL);
- }
g_free (track_id);
}
@@ -404,7 +422,7 @@ message_add_filter_cb (GeditMessageBus *bus,
"method", &method,
NULL);
- // Check if there exists such a 'callback' message
+ /* Check if there exists such a 'callback' message */
if (!object_path || !method)
{
g_free (object_path);
@@ -423,14 +441,12 @@ message_add_filter_cb (GeditMessageBus *bus,
return;
}
- // Check if the message type has the correct arguments
+ /* Check if the message type has the correct arguments */
if (gedit_message_type_lookup (message_type, "id") != G_TYPE_STRING ||
gedit_message_type_lookup (message_type, "location") != G_TYPE_FILE ||
gedit_message_type_lookup (message_type, "is_directory") != G_TYPE_BOOLEAN ||
gedit_message_type_lookup (message_type, "filter") != G_TYPE_BOOLEAN)
- {
return;
- }
cbmessage = gedit_message_type_instantiate (message_type,
"id", NULL,
@@ -439,7 +455,7 @@ message_add_filter_cb (GeditMessageBus *bus,
"filter", FALSE,
NULL);
- // Register the custom filter on the widget
+ /* Register the custom filter on the widget */
filter_data = filter_data_new (window, cbmessage);
id = gedit_file_browser_widget_add_filter (data->widget,
(GeditFileBrowserWidgetFilterFunc)custom_message_filter_func,
@@ -582,7 +598,7 @@ message_add_context_item_cb (GeditMessageBus *bus,
g_free (path);
return;
}
-
+
gtk_action_group_add_action (data->merged_actions, action);
manager = gedit_file_browser_widget_get_ui_manager (data->widget);
name = g_strconcat (gtk_action_get_name (action), "MenuItem", NULL);
diff --git a/plugins/filebrowser/gedit-file-browser-messages.h b/plugins/filebrowser/gedit-file-browser-messages.h
index e62094e..994e3dd 100644
--- a/plugins/filebrowser/gedit-file-browser-messages.h
+++ b/plugins/filebrowser/gedit-file-browser-messages.h
@@ -26,10 +26,8 @@
#include <gedit/gedit-message-bus.h>
#include "gedit-file-browser-widget.h"
-void gedit_file_browser_messages_register (GeditWindow *window,
+void gedit_file_browser_messages_register (GeditWindow *window,
GeditFileBrowserWidget *widget);
-void gedit_file_browser_messages_unregister (GeditWindow *window);
+void gedit_file_browser_messages_unregister (GeditWindow *window);
#endif /* __GEDIT_FILE_BROWSER_MESSAGES_H__ */
-
-// ex:ts=8:noet:
diff --git a/plugins/filebrowser/gedit-file-browser-plugin.c b/plugins/filebrowser/gedit-file-browser-plugin.c
index 90bef12..e2b7ba2 100644
--- a/plugins/filebrowser/gedit-file-browser-plugin.c
+++ b/plugins/filebrowser/gedit-file-browser-plugin.c
@@ -1,25 +1,24 @@
/*
* gedit-file-browser-plugin.c - Gedit plugin providing easy file access
* from the sidepanel
- *
+ *
* Copyright (C) 2006 - Jesse van den Kieboom <jesse icecrew nl>
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -56,52 +55,52 @@ struct _GeditFileBrowserPluginPrivate
typedef struct _GeditFileBrowserPluginData
{
- GeditFileBrowserWidget * tree_widget;
- gulong merge_id;
- GtkActionGroup * action_group;
- GtkActionGroup * single_selection_action_group;
- gboolean auto_root;
- gulong end_loading_handle;
- gboolean confirm_trash;
-
- guint click_policy_handle;
- guint enable_delete_handle;
- guint confirm_trash_handle;
+ GeditFileBrowserWidget *tree_widget;
+ gulong merge_id;
+ GtkActionGroup *action_group;
+ GtkActionGroup *single_selection_action_group;
+ gboolean auto_root;
+ gulong end_loading_handle;
+ gboolean confirm_trash;
+
+ guint click_policy_handle;
+ guint enable_delete_handle;
+ guint confirm_trash_handle;
} GeditFileBrowserPluginData;
-static void on_location_activated_cb (GeditFileBrowserWidget * widget,
- GFile *location,
- GeditWindow * window);
-static void on_error_cb (GeditFileBrowserWidget * widget,
- guint code,
- gchar const *message,
- GeditWindow * window);
-static void on_model_set_cb (GeditFileBrowserView * widget,
- GParamSpec *arg1,
- GeditWindow * window);
-static void on_virtual_root_changed_cb (GeditFileBrowserStore * model,
- GParamSpec * param,
- GeditWindow * window);
-static void on_filter_mode_changed_cb (GeditFileBrowserStore * model,
- GParamSpec * param,
- GeditWindow * window);
-static void on_rename_cb (GeditFileBrowserStore * model,
- GFile * oldfile,
- GFile * newfile,
- GeditWindow * window);
-static void on_filter_pattern_changed_cb (GeditFileBrowserWidget * widget,
- GParamSpec * param,
- GeditWindow * window);
-static void on_tab_added_cb (GeditWindow * window,
- GeditTab * tab,
- GeditFileBrowserPluginData * data);
-static gboolean on_confirm_delete_cb (GeditFileBrowserWidget * widget,
- GeditFileBrowserStore * store,
- GList * rows,
- GeditWindow * window);
-static gboolean on_confirm_no_trash_cb (GeditFileBrowserWidget * widget,
- GList * files,
- GeditWindow * window);
+static void on_location_activated_cb (GeditFileBrowserWidget *widget,
+ GFile *location,
+ GeditWindow *window);
+static void on_error_cb (GeditFileBrowserWidget *widget,
+ guint code,
+ gchar const *message,
+ GeditWindow *window);
+static void on_model_set_cb (GeditFileBrowserView *widget,
+ GParamSpec *arg1,
+ GeditWindow *window);
+static void on_virtual_root_changed_cb (GeditFileBrowserStore *model,
+ GParamSpec *param,
+ GeditWindow *window);
+static void on_filter_mode_changed_cb (GeditFileBrowserStore *model,
+ GParamSpec *param,
+ GeditWindow *window);
+static void on_rename_cb (GeditFileBrowserStore *model,
+ GFile *oldfile,
+ GFile *newfile,
+ GeditWindow *window);
+static void on_filter_pattern_changed_cb (GeditFileBrowserWidget *widget,
+ GParamSpec *param,
+ GeditWindow *window);
+static void on_tab_added_cb (GeditWindow *window,
+ GeditTab *tab,
+ GeditFileBrowserPluginData *data);
+static gboolean on_confirm_delete_cb (GeditFileBrowserWidget *widget,
+ GeditFileBrowserStore *store,
+ GList *rows,
+ GeditWindow *window);
+static gboolean on_confirm_no_trash_cb (GeditFileBrowserWidget *widget,
+ GList *files,
+ GeditWindow *window);
GEDIT_PLUGIN_REGISTER_TYPE_WITH_CODE (GeditFileBrowserPlugin, filetree_plugin, \
gedit_file_browser_enum_and_flag_register_type (type_module); \
@@ -113,29 +112,29 @@ GEDIT_PLUGIN_REGISTER_TYPE_WITH_CODE (GeditFileBrowserPlugin, filetree_plugin,
static void
-filetree_plugin_init (GeditFileBrowserPlugin * plugin)
+filetree_plugin_init (GeditFileBrowserPlugin *plugin)
{
plugin->priv = GEDIT_FILE_BROWSER_PLUGIN_GET_PRIVATE (plugin);
}
static void
-filetree_plugin_finalize (GObject * object)
+filetree_plugin_finalize (GObject *object)
{
- //GeditFileBrowserPlugin * plugin = GEDIT_FILE_BROWSER_PLUGIN (object);
+ /* GeditFileBrowserPlugin *plugin = GEDIT_FILE_BROWSER_PLUGIN (object); */
G_OBJECT_CLASS (filetree_plugin_parent_class)->finalize (object);
}
static GeditFileBrowserPluginData *
-get_plugin_data (GeditWindow * window)
+get_plugin_data (GeditWindow *window)
{
return (GeditFileBrowserPluginData *) (g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY));
}
static void
-on_end_loading_cb (GeditFileBrowserStore * store,
- GtkTreeIter * iter,
- GeditFileBrowserPluginData * data)
+on_end_loading_cb (GeditFileBrowserStore *store,
+ GtkTreeIter *iter,
+ GeditFileBrowserPluginData *data)
{
/* Disconnect the signal */
g_signal_handler_disconnect (store, data->end_loading_handle);
@@ -152,7 +151,8 @@ prepare_auto_root (GeditFileBrowserPluginData *data)
store = gedit_file_browser_widget_get_browser_store (data->tree_widget);
- if (data->end_loading_handle != 0) {
+ if (data->end_loading_handle != 0)
+ {
g_signal_handler_disconnect (store, data->end_loading_handle);
data->end_loading_handle = 0;
}
@@ -166,11 +166,11 @@ prepare_auto_root (GeditFileBrowserPluginData *data)
static void
restore_default_location (GeditFileBrowserPluginData *data)
{
- gchar * root;
- gchar * virtual_root;
+ gchar *root;
+ gchar *virtual_root;
gboolean bookmarks;
gboolean remote;
- GConfClient * client;
+ GConfClient *client;
client = gconf_client_get_default ();
if (!client)
@@ -180,7 +180,8 @@ restore_default_location (GeditFileBrowserPluginData *data)
FILE_BROWSER_BASE_KEY "/on_load/tree_view",
NULL);
- if (bookmarks) {
+ if (bookmarks)
+ {
g_object_unref (client);
gedit_file_browser_widget_show_bookmarks (data->tree_widget);
return;
@@ -189,28 +190,33 @@ restore_default_location (GeditFileBrowserPluginData *data)
root = gconf_client_get_string (client,
FILE_BROWSER_BASE_KEY "/on_load/root",
NULL);
- virtual_root = gconf_client_get_string (client,
- FILE_BROWSER_BASE_KEY "/on_load/virtual_root",
- NULL);
+ virtual_root = gconf_client_get_string (client,
+ FILE_BROWSER_BASE_KEY "/on_load/virtual_root",
+ NULL);
remote = gconf_client_get_bool (client,
FILE_BROWSER_BASE_KEY "/on_load/enable_remote",
NULL);
- if (root != NULL && *root != '\0') {
+ if (root != NULL && *root != '\0')
+ {
GFile *rootfile;
GFile *vrootfile;
rootfile = g_file_new_for_uri (root);
vrootfile = g_file_new_for_uri (virtual_root);
- if (remote || g_file_is_native (rootfile)) {
- if (virtual_root != NULL && *virtual_root != '\0') {
+ if (remote || g_file_is_native (rootfile))
+ {
+ if (virtual_root != NULL && *virtual_root != '\0')
+ {
prepare_auto_root (data);
gedit_file_browser_widget_set_root_and_virtual_root (data->tree_widget,
rootfile,
vrootfile);
- } else {
+ }
+ else
+ {
prepare_auto_root (data);
gedit_file_browser_widget_set_root (data->tree_widget,
rootfile,
@@ -228,9 +234,9 @@ restore_default_location (GeditFileBrowserPluginData *data)
}
static void
-restore_filter (GeditFileBrowserPluginData * data)
+restore_filter (GeditFileBrowserPluginData *data)
{
- GConfClient * client;
+ GConfClient *client;
gchar *filter_mode;
GeditFileBrowserStoreFilterMode mode;
gchar *pattern;
@@ -247,25 +253,25 @@ restore_filter (GeditFileBrowserPluginData * data)
/* Filter mode */
mode = gedit_file_browser_store_filter_mode_get_default ();
- if (filter_mode != NULL) {
- if (strcmp (filter_mode, "hidden") == 0) {
+ if (filter_mode != NULL)
+ {
+ if (strcmp (filter_mode, "hidden") == 0)
mode = GEDIT_FILE_BROWSER_STORE_FILTER_MODE_HIDE_HIDDEN;
- } else if (strcmp (filter_mode, "binary") == 0) {
+ else if (strcmp (filter_mode, "binary") == 0)
mode = GEDIT_FILE_BROWSER_STORE_FILTER_MODE_HIDE_BINARY;
- } else if (strcmp (filter_mode, "hidden_and_binary") == 0 ||
- strcmp (filter_mode, "binary_and_hidden") == 0) {
+ else if (strcmp (filter_mode, "hidden_and_binary") == 0 ||
+ strcmp (filter_mode, "binary_and_hidden") == 0)
mode = GEDIT_FILE_BROWSER_STORE_FILTER_MODE_HIDE_HIDDEN |
GEDIT_FILE_BROWSER_STORE_FILTER_MODE_HIDE_BINARY;
- } else if (strcmp (filter_mode, "none") == 0 ||
- *filter_mode == '\0') {
+ else if (strcmp (filter_mode, "none") == 0 ||
+ *filter_mode == '\0')
mode = GEDIT_FILE_BROWSER_STORE_FILTER_MODE_NONE;
- }
}
/* Set the filter mode */
gedit_file_browser_store_set_filter_mode (
- gedit_file_browser_widget_get_browser_store (data->tree_widget),
- mode);
+ gedit_file_browser_widget_get_browser_store (data->tree_widget),
+ mode);
pattern = gconf_client_get_string (client,
FILE_BROWSER_BASE_KEY "/filter_pattern",
@@ -290,12 +296,12 @@ click_policy_from_string (gchar const *click_policy)
static void
on_click_policy_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
+ guint cnxn_id,
+ GConfEntry *entry,
+ gpointer user_data)
{
GConfValue *value;
- GeditFileBrowserPluginData * data;
+ GeditFileBrowserPluginData *data;
gchar const *click_policy;
GeditFileBrowserViewClickPolicy policy = GEDIT_FILE_BROWSER_VIEW_CLICK_POLICY_DOUBLE;
GeditFileBrowserView *view;
@@ -303,9 +309,9 @@ on_click_policy_changed (GConfClient *client,
data = (GeditFileBrowserPluginData *)(user_data);
value = gconf_entry_get_value (entry);
- if (value && value->type == GCONF_VALUE_STRING) {
+ if (value && value->type == GCONF_VALUE_STRING)
+ {
click_policy = gconf_value_get_string (value);
-
policy = click_policy_from_string (click_policy);
}
@@ -315,9 +321,9 @@ on_click_policy_changed (GConfClient *client,
static void
on_enable_delete_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
+ guint cnxn_id,
+ GConfEntry *entry,
+ gpointer user_data)
{
GConfValue *value;
GeditFileBrowserPluginData *data;
@@ -334,9 +340,9 @@ on_enable_delete_changed (GConfClient *client,
static void
on_confirm_trash_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
+ guint cnxn_id,
+ GConfEntry *entry,
+ gpointer user_data)
{
GConfValue *value;
GeditFileBrowserPluginData *data;
@@ -379,7 +385,8 @@ install_nautilus_prefs (GeditFileBrowserPluginData *data)
view = gedit_file_browser_widget_get_browser_view (data->tree_widget);
gedit_file_browser_view_set_click_policy (view, policy);
- if (pref) {
+ if (pref)
+ {
data->click_policy_handle =
gconf_client_notify_add (client,
NAUTILUS_CLICK_POLICY_BASE_KEY "/" NAUTILUS_CLICK_POLICY_KEY,
@@ -423,8 +430,8 @@ install_nautilus_prefs (GeditFileBrowserPluginData *data)
}
static void
-set_root_from_doc (GeditFileBrowserPluginData * data,
- GeditDocument * doc)
+set_root_from_doc (GeditFileBrowserPluginData *data,
+ GeditDocument *doc)
{
GFile *file;
GFile *parent;
@@ -438,8 +445,8 @@ set_root_from_doc (GeditFileBrowserPluginData * data,
parent = g_file_get_parent (file);
- if (parent != NULL) {
-
+ if (parent != NULL)
+ {
gedit_file_browser_widget_set_root (data->tree_widget,
parent,
TRUE);
@@ -451,8 +458,8 @@ set_root_from_doc (GeditFileBrowserPluginData * data,
}
static void
-on_action_set_active_root (GtkAction * action,
- GeditWindow * window)
+on_action_set_active_root (GtkAction *action,
+ GeditWindow *window)
{
GeditFileBrowserPluginData *data;
@@ -464,8 +471,8 @@ on_action_set_active_root (GtkAction * action,
static gchar *
get_terminal (void)
{
- GConfClient * client;
- gchar * terminal;
+ GConfClient *client;
+ gchar *terminal;
client = gconf_client_get_default ();
terminal = gconf_client_get_string (client,
@@ -473,7 +480,8 @@ get_terminal (void)
NULL);
g_object_unref (client);
- if (terminal == NULL) {
+ if (terminal == NULL)
+ {
const gchar *term = g_getenv ("TERM");
if (term != NULL)
@@ -486,17 +494,17 @@ get_terminal (void)
}
static void
-on_action_open_terminal (GtkAction * action,
- GeditWindow * window)
+on_action_open_terminal (GtkAction *action,
+ GeditWindow *window)
{
- GeditFileBrowserPluginData * data;
- gchar * terminal;
- gchar * local;
- gchar * argv[2];
- GFile * file;
+ GeditFileBrowserPluginData *data;
+ gchar *terminal;
+ gchar *local;
+ gchar *argv[2];
+ GFile *file;
GtkTreeIter iter;
- GeditFileBrowserStore * store;
+ GeditFileBrowserStore *store;
data = get_plugin_data (window);
@@ -538,12 +546,12 @@ static void
on_selection_changed_cb (GtkTreeSelection *selection,
GeditWindow *window)
{
- GeditFileBrowserPluginData * data;
- GtkTreeView * tree_view;
- GtkTreeModel * model;
+ GeditFileBrowserPluginData *data;
+ GtkTreeView *tree_view;
+ GtkTreeModel *model;
GtkTreeIter iter;
gboolean sensitive;
- GFile * location;
+ GFile *location;
data = get_plugin_data (window);
@@ -555,7 +563,8 @@ on_selection_changed_cb (GtkTreeSelection *selection,
sensitive = gedit_file_browser_widget_get_selected_directory (data->tree_widget, &iter);
- if (sensitive) {
+ if (sensitive)
+ {
gtk_tree_model_get (model, &iter,
GEDIT_FILE_BROWSER_STORE_COLUMN_LOCATION,
&location, -1);
@@ -564,8 +573,8 @@ on_selection_changed_cb (GtkTreeSelection *selection,
}
gtk_action_set_sensitive (
- gtk_action_group_get_action (data->single_selection_action_group,
- "OpenTerminal"),
+ gtk_action_group_get_action (data->single_selection_action_group,
+ "OpenTerminal"),
sensitive);
}
@@ -602,12 +611,12 @@ static GtkActionEntry extra_single_selection_actions[] = {
};
static void
-add_popup_ui (GeditWindow * window)
+add_popup_ui (GeditWindow *window)
{
- GeditFileBrowserPluginData * data;
- GtkUIManager * manager;
- GtkActionGroup * action_group;
- GError * error = NULL;
+ GeditFileBrowserPluginData *data;
+ GtkUIManager *manager;
+ GtkActionGroup *action_group;
+ GError *error = NULL;
data = get_plugin_data (window);
manager = gedit_file_browser_widget_get_ui_manager (data->tree_widget);
@@ -635,17 +644,18 @@ add_popup_ui (GeditWindow * window)
-1,
&error);
- if (data->merge_id == 0) {
+ if (data->merge_id == 0)
+ {
g_warning("Unable to merge UI: %s", error->message);
g_error_free(error);
}
}
static void
-remove_popup_ui (GeditWindow * window)
+remove_popup_ui (GeditWindow *window)
{
- GeditFileBrowserPluginData * data;
- GtkUIManager * manager;
+ GeditFileBrowserPluginData *data;
+ GtkUIManager *manager;
data = get_plugin_data (window);
manager = gedit_file_browser_widget_get_ui_manager (data->tree_widget);
@@ -659,10 +669,11 @@ remove_popup_ui (GeditWindow * window)
}
static void
-impl_updateui (GeditPlugin * plugin, GeditWindow * window)
+impl_updateui (GeditPlugin *plugin,
+ GeditWindow *window)
{
- GeditFileBrowserPluginData * data;
- GeditDocument * doc;
+ GeditFileBrowserPluginData *data;
+ GeditDocument *doc;
data = get_plugin_data (window);
@@ -670,18 +681,18 @@ impl_updateui (GeditPlugin * plugin, GeditWindow * window)
gtk_action_set_sensitive (gtk_action_group_get_action (data->action_group,
"SetActiveRoot"),
- doc != NULL &&
- !gedit_document_is_untitled (doc));
+ doc != NULL && !gedit_document_is_untitled (doc));
}
static void
-impl_activate (GeditPlugin * plugin, GeditWindow * window)
+impl_activate (GeditPlugin *plugin,
+ GeditWindow *window)
{
- GeditPanel * panel;
- GeditFileBrowserPluginData * data;
- GtkWidget * image;
- GdkPixbuf * pixbuf;
- GeditFileBrowserStore * store;
+ GeditPanel *panel;
+ GeditFileBrowserPluginData *data;
+ GtkWidget *image;
+ GdkPixbuf *pixbuf;
+ GeditFileBrowserStore *store;
gchar *data_dir;
data = g_new0 (GeditFileBrowserPluginData, 1);
@@ -723,10 +734,13 @@ impl_activate (GeditPlugin * plugin, GeditWindow * window)
pixbuf = gedit_file_browser_utils_pixbuf_from_theme("system-file-manager",
GTK_ICON_SIZE_MENU);
- if (pixbuf) {
+ if (pixbuf)
+ {
image = gtk_image_new_from_pixbuf(pixbuf);
g_object_unref(pixbuf);
- } else {
+ }
+ else
+ {
image = gtk_image_new_from_stock(GTK_STOCK_INDEX, GTK_ICON_SIZE_MENU);
}
@@ -780,10 +794,11 @@ impl_activate (GeditPlugin * plugin, GeditWindow * window)
}
static void
-impl_deactivate (GeditPlugin * plugin, GeditWindow * window)
+impl_deactivate (GeditPlugin *plugin,
+ GeditWindow *window)
{
- GeditFileBrowserPluginData * data;
- GeditPanel * panel;
+ GeditFileBrowserPluginData *data;
+ GeditPanel *panel;
GConfClient *client;
data = get_plugin_data (window);
@@ -819,10 +834,10 @@ impl_deactivate (GeditPlugin * plugin, GeditWindow * window)
}
static void
-filetree_plugin_class_init (GeditFileBrowserPluginClass * klass)
+filetree_plugin_class_init (GeditFileBrowserPluginClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GeditPluginClass * plugin_class = GEDIT_PLUGIN_CLASS (klass);
+ GeditPluginClass *plugin_class = GEDIT_PLUGIN_CLASS (klass);
object_class->finalize = filetree_plugin_finalize;
@@ -836,19 +851,22 @@ filetree_plugin_class_init (GeditFileBrowserPluginClass * klass)
/* Callbacks */
static void
-on_location_activated_cb (GeditFileBrowserWidget * tree_widget,
- GFile *location, GeditWindow * window)
+on_location_activated_cb (GeditFileBrowserWidget *tree_widget,
+ GFile *location,
+ GeditWindow *window)
{
gedit_commands_load_location (window, location, NULL, 0, 0);
}
static void
-on_error_cb (GeditFileBrowserWidget * tree_widget,
- guint code, gchar const *message, GeditWindow * window)
+on_error_cb (GeditFileBrowserWidget *tree_widget,
+ guint code,
+ gchar const *message,
+ GeditWindow *window)
{
- gchar * title;
- GtkWidget * dlg;
- GeditFileBrowserPluginData * data;
+ gchar *title;
+ GtkWidget *dlg;
+ GeditFileBrowserPluginData *data;
data = get_plugin_data (window);
@@ -861,40 +879,32 @@ on_error_cb (GeditFileBrowserWidget * tree_widget,
return;
}
- switch (code) {
- case GEDIT_FILE_BROWSER_ERROR_NEW_DIRECTORY:
- title =
- _("An error occurred while creating a new directory");
- break;
- case GEDIT_FILE_BROWSER_ERROR_NEW_FILE:
- title = _("An error occurred while creating a new file");
- break;
- case GEDIT_FILE_BROWSER_ERROR_RENAME:
- title =
- _
- ("An error occurred while renaming a file or directory");
- break;
- case GEDIT_FILE_BROWSER_ERROR_DELETE:
- title =
- _
- ("An error occurred while deleting a file or directory");
- break;
- case GEDIT_FILE_BROWSER_ERROR_OPEN_DIRECTORY:
- title =
- _
- ("An error occurred while opening a directory in the file manager");
- break;
- case GEDIT_FILE_BROWSER_ERROR_SET_ROOT:
- title =
- _("An error occurred while setting a root directory");
- break;
- case GEDIT_FILE_BROWSER_ERROR_LOAD_DIRECTORY:
- title =
- _("An error occurred while loading a directory");
- break;
- default:
- title = _("An error occurred");
- break;
+ switch (code)
+ {
+ case GEDIT_FILE_BROWSER_ERROR_NEW_DIRECTORY:
+ title = _("An error occurred while creating a new directory");
+ break;
+ case GEDIT_FILE_BROWSER_ERROR_NEW_FILE:
+ title = _("An error occurred while creating a new file");
+ break;
+ case GEDIT_FILE_BROWSER_ERROR_RENAME:
+ title = _("An error occurred while renaming a file or directory");
+ break;
+ case GEDIT_FILE_BROWSER_ERROR_DELETE:
+ title = _("An error occurred while deleting a file or directory");
+ break;
+ case GEDIT_FILE_BROWSER_ERROR_OPEN_DIRECTORY:
+ title = _("An error occurred while opening a directory in the file manager");
+ break;
+ case GEDIT_FILE_BROWSER_ERROR_SET_ROOT:
+ title = _("An error occurred while setting a root directory");
+ break;
+ case GEDIT_FILE_BROWSER_ERROR_LOAD_DIRECTORY:
+ title = _("An error occurred while loading a directory");
+ break;
+ default:
+ title = _("An error occurred");
+ break;
}
dlg = gtk_message_dialog_new (GTK_WINDOW (window),
@@ -910,13 +920,13 @@ on_error_cb (GeditFileBrowserWidget * tree_widget,
}
static void
-on_model_set_cb (GeditFileBrowserView * widget,
- GParamSpec *arg1,
- GeditWindow * window)
+on_model_set_cb (GeditFileBrowserView *widget,
+ GParamSpec *arg1,
+ GeditWindow *window)
{
- GeditFileBrowserPluginData * data = get_plugin_data (window);
- GtkTreeModel * model;
- GConfClient * client;
+ GeditFileBrowserPluginData *data = get_plugin_data (window);
+ GtkTreeModel *model;
+ GConfClient *client;
model = gtk_tree_view_get_model (GTK_TREE_VIEW (gedit_file_browser_widget_get_browser_view (data->tree_widget)));
@@ -932,11 +942,11 @@ on_model_set_cb (GeditFileBrowserView * widget,
}
static void
-on_filter_mode_changed_cb (GeditFileBrowserStore * model,
- GParamSpec * param,
- GeditWindow * window)
+on_filter_mode_changed_cb (GeditFileBrowserStore *model,
+ GParamSpec *param,
+ GeditWindow *window)
{
- GConfClient * client;
+ GConfClient *client;
GeditFileBrowserStoreFilterMode mode;
client = gconf_client_get_default ();
@@ -947,64 +957,68 @@ on_filter_mode_changed_cb (GeditFileBrowserStore * model,
mode = gedit_file_browser_store_get_filter_mode (model);
if ((mode & GEDIT_FILE_BROWSER_STORE_FILTER_MODE_HIDE_HIDDEN) &&
- (mode & GEDIT_FILE_BROWSER_STORE_FILTER_MODE_HIDE_BINARY)) {
+ (mode & GEDIT_FILE_BROWSER_STORE_FILTER_MODE_HIDE_BINARY))
gconf_client_set_string (client,
FILE_BROWSER_BASE_KEY "/filter_mode",
"hidden_and_binary",
NULL);
- } else if (mode & GEDIT_FILE_BROWSER_STORE_FILTER_MODE_HIDE_HIDDEN) {
+ else if (mode & GEDIT_FILE_BROWSER_STORE_FILTER_MODE_HIDE_HIDDEN)
gconf_client_set_string (client,
FILE_BROWSER_BASE_KEY "/filter_mode",
"hidden",
NULL);
- } else if (mode & GEDIT_FILE_BROWSER_STORE_FILTER_MODE_HIDE_BINARY) {
+ else if (mode & GEDIT_FILE_BROWSER_STORE_FILTER_MODE_HIDE_BINARY)
gconf_client_set_string (client,
FILE_BROWSER_BASE_KEY "/filter_mode",
"binary",
NULL);
- } else {
+ else
gconf_client_set_string (client,
FILE_BROWSER_BASE_KEY "/filter_mode",
"none",
NULL);
- }
g_object_unref (client);
}
static void
-on_rename_cb (GeditFileBrowserStore * store,
- GFile * oldfile,
- GFile * newfile,
- GeditWindow * window)
+on_rename_cb (GeditFileBrowserStore *store,
+ GFile *oldfile,
+ GFile *newfile,
+ GeditWindow *window)
{
- GeditApp * app;
- GList * documents;
- GList * item;
- GeditDocument * doc;
- GFile * docfile;
+ GeditApp *app;
+ GList *documents;
+ GList *item;
+ GeditDocument *doc;
+ GFile *docfile;
/* Find all documents and set its uri to newuri where it matches olduri */
app = gedit_app_get_default ();
documents = gedit_app_get_documents (app);
- for (item = documents; item; item = item->next) {
+ for (item = documents; item; item = item->next)
+ {
doc = GEDIT_DOCUMENT (item->data);
docfile = gedit_document_get_location (doc);
if (!docfile)
continue;
- if (g_file_equal (docfile, oldfile)) {
+ if (g_file_equal (docfile, oldfile))
+ {
gedit_document_set_location (doc, newfile);
- } else {
+ }
+ else
+ {
gchar *relative;
relative = g_file_get_relative_path (oldfile, docfile);
- if (relative) {
- /* relative now contains the part in docfile without
+ if (relative)
+ {
+ /* Relative now contains the part in docfile without
the prefix oldfile */
g_object_unref (docfile);
@@ -1023,12 +1037,12 @@ on_rename_cb (GeditFileBrowserStore * store,
}
static void
-on_filter_pattern_changed_cb (GeditFileBrowserWidget * widget,
- GParamSpec * param,
- GeditWindow * window)
+on_filter_pattern_changed_cb (GeditFileBrowserWidget *widget,
+ GParamSpec *param,
+ GeditWindow *window)
{
- GConfClient * client;
- gchar * pattern;
+ GConfClient *client;
+ gchar *pattern;
client = gconf_client_get_default ();
@@ -1052,20 +1066,22 @@ on_filter_pattern_changed_cb (GeditFileBrowserWidget * widget,
}
static void
-on_virtual_root_changed_cb (GeditFileBrowserStore * store,
- GParamSpec * param,
- GeditWindow * window)
+on_virtual_root_changed_cb (GeditFileBrowserStore *store,
+ GParamSpec *param,
+ GeditWindow *window)
{
- GeditFileBrowserPluginData * data = get_plugin_data (window);
- GFile * root;
- GFile * virtual_root;
+ GeditFileBrowserPluginData *data = get_plugin_data (window);
+ GFile *root;
+ GFile *virtual_root;
gchar *uri_root = NULL;
- GConfClient * client;
+ GConfClient *client;
root = gedit_file_browser_store_get_root (store);
if (!root)
+ {
return;
+ }
else
{
uri_root = g_file_get_uri (root);
@@ -1085,13 +1101,16 @@ on_virtual_root_changed_cb (GeditFileBrowserStore * store,
virtual_root = gedit_file_browser_store_get_virtual_root (store);
- if (!virtual_root) {
+ if (!virtual_root)
+ {
/* Set virtual to same as root then */
gconf_client_set_string (client,
FILE_BROWSER_BASE_KEY "/on_load/virtual_root",
uri_root,
NULL);
- } else {
+ }
+ else
+ {
gchar *uri_vroot;
uri_vroot = g_file_get_uri (virtual_root);
@@ -1112,9 +1131,9 @@ on_virtual_root_changed_cb (GeditFileBrowserStore * store,
}
static void
-on_tab_added_cb (GeditWindow * window,
- GeditTab * tab,
- GeditFileBrowserPluginData * data)
+on_tab_added_cb (GeditWindow *window,
+ GeditTab *tab,
+ GeditFileBrowserPluginData *data)
{
GConfClient *client;
gboolean open;
@@ -1129,7 +1148,8 @@ on_tab_added_cb (GeditWindow * window,
FILE_BROWSER_BASE_KEY "/open_at_first_doc",
NULL);
- if (open) {
+ if (open)
+ {
GeditDocument *doc;
GFile *location;
@@ -1161,7 +1181,8 @@ on_tab_added_cb (GeditWindow * window,
}
static gchar *
-get_filename_from_path (GtkTreeModel *model, GtkTreePath *path)
+get_filename_from_path (GtkTreeModel *model,
+ GtkTreePath *path)
{
GtkTreeIter iter;
GFile *location;
@@ -1175,9 +1196,9 @@ get_filename_from_path (GtkTreeModel *model, GtkTreePath *path)
}
static gboolean
-on_confirm_no_trash_cb (GeditFileBrowserWidget * widget,
- GList * files,
- GeditWindow * window)
+on_confirm_no_trash_cb (GeditFileBrowserWidget *widget,
+ GList *files,
+ GeditWindow *window)
{
gchar *normal;
gchar *message;
@@ -1186,11 +1207,14 @@ on_confirm_no_trash_cb (GeditFileBrowserWidget * widget,
message = _("Cannot move file to trash, do you\nwant to delete permanently?");
- if (files->next == NULL) {
+ if (files->next == NULL)
+ {
normal = gedit_file_browser_utils_file_basename (G_FILE (files->data));
secondary = g_strdup_printf (_("The file \"%s\" cannot be moved to the trash."), normal);
g_free (normal);
- } else {
+ }
+ else
+ {
secondary = g_strdup (_("The selected files cannot be moved to the trash."));
}
@@ -1207,9 +1231,9 @@ on_confirm_no_trash_cb (GeditFileBrowserWidget * widget,
static gboolean
on_confirm_delete_cb (GeditFileBrowserWidget *widget,
- GeditFileBrowserStore *store,
- GList *paths,
- GeditWindow *window)
+ GeditFileBrowserStore *store,
+ GList *paths,
+ GeditWindow *window)
{
gchar *normal;
gchar *message;
@@ -1222,11 +1246,14 @@ on_confirm_delete_cb (GeditFileBrowserWidget *widget,
if (!data->confirm_trash)
return TRUE;
- if (paths->next == NULL) {
+ if (paths->next == NULL)
+ {
normal = get_filename_from_path (GTK_TREE_MODEL (store), (GtkTreePath *)(paths->data));
message = g_strdup_printf (_("Are you sure you want to permanently delete \"%s\"?"), normal);
g_free (normal);
- } else {
+ }
+ else
+ {
message = g_strdup (_("Are you sure you want to permanently delete the selected files?"));
}
@@ -1243,5 +1270,3 @@ on_confirm_delete_cb (GeditFileBrowserWidget *widget,
return result;
}
-
-// ex:ts=8:noet:
diff --git a/plugins/filebrowser/gedit-file-browser-plugin.h b/plugins/filebrowser/gedit-file-browser-plugin.h
index 19ca86b..258f011 100644
--- a/plugins/filebrowser/gedit-file-browser-plugin.h
+++ b/plugins/filebrowser/gedit-file-browser-plugin.h
@@ -46,12 +46,10 @@ struct _GeditFileBrowserPlugin
{
GeditPlugin parent_instance;
- /*< private > */
+ /* < private > */
GeditFileBrowserPluginPrivate *priv;
};
-
-
struct _GeditFileBrowserPluginClass
{
GeditPluginClass parent_class;
@@ -60,12 +58,11 @@ struct _GeditFileBrowserPluginClass
/*
* Public methods
*/
-GType filetree_plugin_get_type (void) G_GNUC_CONST;
+GType filetree_plugin_get_type (void) G_GNUC_CONST;
/* All the plugins must implement this function */
-G_MODULE_EXPORT GType register_gedit_plugin (GTypeModule * module);
+G_MODULE_EXPORT GType register_gedit_plugin (GTypeModule *module);
G_END_DECLS
-#endif /* __GEDIT_FILE_BROWSER_PLUGIN_H__ */
-// ex:ts=8:noet:
+#endif /* __GEDIT_FILE_BROWSER_PLUGIN_H__ */
diff --git a/plugins/filebrowser/gedit-file-browser-store.c b/plugins/filebrowser/gedit-file-browser-store.c
index ae22e1f..0b15f22 100644
--- a/plugins/filebrowser/gedit-file-browser-store.c
+++ b/plugins/filebrowser/gedit-file-browser-store.c
@@ -1,19 +1,19 @@
/*
* gedit-file-browser-store.c - Gedit plugin providing easy file access
* from the sidepanel
- *
+ *
* Copyright (C) 2006 - Jesse van den Kieboom <jesse icecrew nl>
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@@ -61,16 +61,16 @@ typedef struct _FileBrowserNodeDir FileBrowserNodeDir;
typedef struct _AsyncData AsyncData;
typedef struct _AsyncNode AsyncNode;
-typedef gint (*SortFunc) (FileBrowserNode * node1,
- FileBrowserNode * node2);
+typedef gint (*SortFunc) (FileBrowserNode *node1,
+ FileBrowserNode *node2);
struct _AsyncData
{
- GeditFileBrowserStore * model;
- GCancellable * cancellable;
+ GeditFileBrowserStore *model;
+ GCancellable *cancellable;
gboolean trash;
- GList * files;
- GList * iter;
+ GList *files;
+ GList *iter;
gboolean removed;
};
@@ -82,10 +82,10 @@ struct _AsyncNode
};
typedef struct {
- GeditFileBrowserStore * model;
- GFile * virtual_root;
- GMountOperation * operation;
- GCancellable * cancellable;
+ GeditFileBrowserStore *model;
+ GFile *virtual_root;
+ GMountOperation *operation;
+ GCancellable *cancellable;
} MountInfo;
struct _FileBrowserNode
@@ -129,73 +129,73 @@ struct _GeditFileBrowserStorePrivate
MountInfo *mount_info;
};
-static FileBrowserNode *model_find_node (GeditFileBrowserStore *model,
- FileBrowserNode *node,
- GFile *uri);
-static void model_remove_node (GeditFileBrowserStore * model,
- FileBrowserNode * node,
- GtkTreePath * path,
- gboolean free_nodes);
-
-static void set_virtual_root_from_node (GeditFileBrowserStore * model,
- FileBrowserNode * node);
-
-static void gedit_file_browser_store_iface_init (GtkTreeModelIface * iface);
-static GtkTreeModelFlags gedit_file_browser_store_get_flags (GtkTreeModel * tree_model);
-static gint gedit_file_browser_store_get_n_columns (GtkTreeModel * tree_model);
-static GType gedit_file_browser_store_get_column_type (GtkTreeModel * tree_model,
- gint index);
-static gboolean gedit_file_browser_store_get_iter (GtkTreeModel * tree_model,
- GtkTreeIter * iter,
- GtkTreePath * path);
-static GtkTreePath *gedit_file_browser_store_get_path (GtkTreeModel * tree_model,
- GtkTreeIter * iter);
-static void gedit_file_browser_store_get_value (GtkTreeModel * tree_model,
- GtkTreeIter * iter,
- gint column,
- GValue * value);
-static gboolean gedit_file_browser_store_iter_next (GtkTreeModel * tree_model,
- GtkTreeIter * iter);
-static gboolean gedit_file_browser_store_iter_children (GtkTreeModel * tree_model,
- GtkTreeIter * iter,
- GtkTreeIter * parent);
-static gboolean gedit_file_browser_store_iter_has_child (GtkTreeModel * tree_model,
- GtkTreeIter * iter);
-static gint gedit_file_browser_store_iter_n_children (GtkTreeModel * tree_model,
- GtkTreeIter * iter);
-static gboolean gedit_file_browser_store_iter_nth_child (GtkTreeModel * tree_model,
- GtkTreeIter * iter,
- GtkTreeIter * parent,
- gint n);
-static gboolean gedit_file_browser_store_iter_parent (GtkTreeModel * tree_model,
- GtkTreeIter * iter,
- GtkTreeIter * child);
-static void gedit_file_browser_store_row_inserted (GtkTreeModel * tree_model,
- GtkTreePath * path,
- GtkTreeIter * iter);
-
-static void gedit_file_browser_store_drag_source_init (GtkTreeDragSourceIface * iface);
-static gboolean gedit_file_browser_store_row_draggable (GtkTreeDragSource * drag_source,
- GtkTreePath * path);
-static gboolean gedit_file_browser_store_drag_data_delete (GtkTreeDragSource * drag_source,
- GtkTreePath * path);
-static gboolean gedit_file_browser_store_drag_data_get (GtkTreeDragSource * drag_source,
- GtkTreePath * path,
- GtkSelectionData * selection_data);
-
-static void file_browser_node_free (GeditFileBrowserStore * model,
- FileBrowserNode * node);
-static void model_add_node (GeditFileBrowserStore * model,
- FileBrowserNode * child,
- FileBrowserNode * parent);
-static void model_clear (GeditFileBrowserStore * model,
- gboolean free_nodes);
-static gint model_sort_default (FileBrowserNode * node1,
- FileBrowserNode * node2);
-static void model_check_dummy (GeditFileBrowserStore * model,
- FileBrowserNode * node);
-static void next_files_async (GFileEnumerator * enumerator,
- AsyncNode * async);
+static FileBrowserNode *model_find_node (GeditFileBrowserStore *model,
+ FileBrowserNode *node,
+ GFile *uri);
+static void model_remove_node (GeditFileBrowserStore *model,
+ FileBrowserNode *node,
+ GtkTreePath *path,
+ gboolean free_nodes);
+
+static void set_virtual_root_from_node (GeditFileBrowserStore *model,
+ FileBrowserNode *node);
+
+static void gedit_file_browser_store_iface_init (GtkTreeModelIface *iface);
+static GtkTreeModelFlags gedit_file_browser_store_get_flags (GtkTreeModel *tree_model);
+static gint gedit_file_browser_store_get_n_columns (GtkTreeModel *tree_model);
+static GType gedit_file_browser_store_get_column_type (GtkTreeModel *tree_model,
+ gint index);
+static gboolean gedit_file_browser_store_get_iter (GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ GtkTreePath *path);
+static GtkTreePath *gedit_file_browser_store_get_path (GtkTreeModel *tree_model,
+ GtkTreeIter *iter);
+static void gedit_file_browser_store_get_value (GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ gint column,
+ GValue *value);
+static gboolean gedit_file_browser_store_iter_next (GtkTreeModel *tree_model,
+ GtkTreeIter *iter);
+static gboolean gedit_file_browser_store_iter_children (GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ GtkTreeIter *parent);
+static gboolean gedit_file_browser_store_iter_has_child (GtkTreeModel *tree_model,
+ GtkTreeIter *iter);
+static gint gedit_file_browser_store_iter_n_children (GtkTreeModel *tree_model,
+ GtkTreeIter *iter);
+static gboolean gedit_file_browser_store_iter_nth_child (GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ GtkTreeIter *parent,
+ gint n);
+static gboolean gedit_file_browser_store_iter_parent (GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ GtkTreeIter *child);
+static void gedit_file_browser_store_row_inserted (GtkTreeModel *tree_model,
+ GtkTreePath *path,
+ GtkTreeIter *iter);
+
+static void gedit_file_browser_store_drag_source_init (GtkTreeDragSourceIface *iface);
+static gboolean gedit_file_browser_store_row_draggable (GtkTreeDragSource *drag_source,
+ GtkTreePath *path);
+static gboolean gedit_file_browser_store_drag_data_delete (GtkTreeDragSource *drag_source,
+ GtkTreePath *path);
+static gboolean gedit_file_browser_store_drag_data_get (GtkTreeDragSource *drag_source,
+ GtkTreePath *path,
+ GtkSelectionData *selection_data);
+
+static void file_browser_node_free (GeditFileBrowserStore *model,
+ FileBrowserNode *node);
+static void model_add_node (GeditFileBrowserStore *model,
+ FileBrowserNode *child,
+ FileBrowserNode *parent);
+static void model_clear (GeditFileBrowserStore *model,
+ gboolean free_nodes);
+static gint model_sort_default (FileBrowserNode *node1,
+ FileBrowserNode *node2);
+static void model_check_dummy (GeditFileBrowserStore *model,
+ FileBrowserNode *node);
+static void next_files_async (GFileEnumerator *enumerator,
+ AsyncNode *async);
GEDIT_PLUGIN_DEFINE_TYPE_WITH_CODE (GeditFileBrowserStore, gedit_file_browser_store,
G_TYPE_OBJECT,
@@ -243,7 +243,7 @@ cancel_mount_operation (GeditFileBrowserStore *obj)
}
static void
-gedit_file_browser_store_finalize (GObject * object)
+gedit_file_browser_store_finalize (GObject *object)
{
GeditFileBrowserStore *obj = GEDIT_FILE_BROWSER_STORE (object);
GSList *item;
@@ -270,9 +270,12 @@ static void
set_gvalue_from_node (GValue *value,
FileBrowserNode *node)
{
- if (node == NULL) {
+ if (node == NULL)
+ {
g_value_set_object (value, NULL);
- } else {
+ }
+ else
+ {
g_value_set_object (value, node->file);
}
}
@@ -323,7 +326,7 @@ gedit_file_browser_store_set_property (GObject *object,
}
static void
-gedit_file_browser_store_class_init (GeditFileBrowserStoreClass * klass)
+gedit_file_browser_store_class_init (GeditFileBrowserStoreClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -425,7 +428,7 @@ gedit_file_browser_store_class_init (GeditFileBrowserStoreClass * klass)
}
static void
-gedit_file_browser_store_iface_init (GtkTreeModelIface * iface)
+gedit_file_browser_store_iface_init (GtkTreeModelIface *iface)
{
iface->get_flags = gedit_file_browser_store_get_flags;
iface->get_n_columns = gedit_file_browser_store_get_n_columns;
@@ -443,7 +446,7 @@ gedit_file_browser_store_iface_init (GtkTreeModelIface * iface)
}
static void
-gedit_file_browser_store_drag_source_init (GtkTreeDragSourceIface * iface)
+gedit_file_browser_store_drag_source_init (GtkTreeDragSourceIface *iface)
{
iface->row_draggable = gedit_file_browser_store_row_draggable;
iface->drag_data_delete = gedit_file_browser_store_drag_data_delete;
@@ -451,28 +454,24 @@ gedit_file_browser_store_drag_source_init (GtkTreeDragSourceIface * iface)
}
static void
-gedit_file_browser_store_init (GeditFileBrowserStore * obj)
+gedit_file_browser_store_init (GeditFileBrowserStore *obj)
{
obj->priv = GEDIT_FILE_BROWSER_STORE_GET_PRIVATE (obj);
- obj->priv->column_types[GEDIT_FILE_BROWSER_STORE_COLUMN_LOCATION] =
- G_TYPE_FILE;
- obj->priv->column_types[GEDIT_FILE_BROWSER_STORE_COLUMN_NAME] =
- G_TYPE_STRING;
- obj->priv->column_types[GEDIT_FILE_BROWSER_STORE_COLUMN_FLAGS] =
- G_TYPE_UINT;
- obj->priv->column_types[GEDIT_FILE_BROWSER_STORE_COLUMN_ICON] =
- GDK_TYPE_PIXBUF;
- obj->priv->column_types[GEDIT_FILE_BROWSER_STORE_COLUMN_EMBLEM] =
- GDK_TYPE_PIXBUF;
-
- // Default filter mode is hiding the hidden files
+ obj->priv->column_types[GEDIT_FILE_BROWSER_STORE_COLUMN_LOCATION] = G_TYPE_FILE;
+ obj->priv->column_types[GEDIT_FILE_BROWSER_STORE_COLUMN_NAME] = G_TYPE_STRING;
+ obj->priv->column_types[GEDIT_FILE_BROWSER_STORE_COLUMN_FLAGS] = G_TYPE_UINT;
+ obj->priv->column_types[GEDIT_FILE_BROWSER_STORE_COLUMN_ICON] = GDK_TYPE_PIXBUF;
+ obj->priv->column_types[GEDIT_FILE_BROWSER_STORE_COLUMN_EMBLEM] = GDK_TYPE_PIXBUF;
+
+ /* Default filter mode is hiding the hidden files */
obj->priv->filter_mode = gedit_file_browser_store_filter_mode_get_default ();
obj->priv->sort_func = model_sort_default;
}
static gboolean
-node_has_parent (FileBrowserNode * node, FileBrowserNode * parent)
+node_has_parent (FileBrowserNode *node,
+ FileBrowserNode *parent)
{
if (node->parent == NULL)
return FALSE;
@@ -484,14 +483,15 @@ node_has_parent (FileBrowserNode * node, FileBrowserNode * parent)
}
static gboolean
-node_in_tree (GeditFileBrowserStore * model, FileBrowserNode * node)
+node_in_tree (GeditFileBrowserStore *model,
+ FileBrowserNode *node)
{
return node_has_parent (node, model->priv->virtual_root);
}
static gboolean
-model_node_visibility (GeditFileBrowserStore * model,
- FileBrowserNode * node)
+model_node_visibility (GeditFileBrowserStore *model,
+ FileBrowserNode *node)
{
if (node == NULL)
return FALSE;
@@ -509,16 +509,17 @@ model_node_visibility (GeditFileBrowserStore * model,
}
static gboolean
-model_node_inserted (GeditFileBrowserStore * model,
- FileBrowserNode * node)
+model_node_inserted (GeditFileBrowserStore *model,
+ FileBrowserNode *node)
{
- return node == model->priv->virtual_root || (model_node_visibility (model, node) && node->inserted);
+ return node == model->priv->virtual_root ||
+ (model_node_visibility (model, node) && node->inserted);
}
/* Interface implementation */
static GtkTreeModelFlags
-gedit_file_browser_store_get_flags (GtkTreeModel * tree_model)
+gedit_file_browser_store_get_flags (GtkTreeModel *tree_model)
{
g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_STORE (tree_model),
(GtkTreeModelFlags) 0);
@@ -527,7 +528,7 @@ gedit_file_browser_store_get_flags (GtkTreeModel * tree_model)
}
static gint
-gedit_file_browser_store_get_n_columns (GtkTreeModel * tree_model)
+gedit_file_browser_store_get_n_columns (GtkTreeModel *tree_model)
{
g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_STORE (tree_model), 0);
@@ -535,7 +536,8 @@ gedit_file_browser_store_get_n_columns (GtkTreeModel * tree_model)
}
static GType
-gedit_file_browser_store_get_column_type (GtkTreeModel * tree_model, gint idx)
+gedit_file_browser_store_get_column_type (GtkTreeModel *tree_model,
+ gint idx)
{
g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_STORE (tree_model),
G_TYPE_INVALID);
@@ -546,12 +548,13 @@ gedit_file_browser_store_get_column_type (GtkTreeModel * tree_model, gint idx)
}
static gboolean
-gedit_file_browser_store_get_iter (GtkTreeModel * tree_model,
- GtkTreeIter * iter, GtkTreePath * path)
+gedit_file_browser_store_get_iter (GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ GtkTreePath *path)
{
- gint * indices, depth, i;
- FileBrowserNode * node;
- GeditFileBrowserStore * model;
+ gint *indices, depth, i;
+ FileBrowserNode *node;
+ GeditFileBrowserStore *model;
gint num;
g_assert (GEDIT_IS_FILE_BROWSER_STORE (tree_model));
@@ -562,8 +565,9 @@ gedit_file_browser_store_get_iter (GtkTreeModel * tree_model,
depth = gtk_tree_path_get_depth (path);
node = model->priv->virtual_root;
- for (i = 0; i < depth; ++i) {
- GSList * item;
+ for (i = 0; i < depth; ++i)
+ {
+ GSList *item;
if (node == NULL)
return FALSE;
@@ -573,13 +577,16 @@ gedit_file_browser_store_get_iter (GtkTreeModel * tree_model,
if (!NODE_IS_DIR (node))
return FALSE;
- for (item = FILE_BROWSER_NODE_DIR (node)->children; item; item = item->next) {
- FileBrowserNode * child;
+ for (item = FILE_BROWSER_NODE_DIR (node)->children; item; item = item->next)
+ {
+ FileBrowserNode *child;
child = (FileBrowserNode *) (item->data);
- if (model_node_inserted (model, child)) {
- if (num == indices[i]) {
+ if (model_node_inserted (model, child))
+ {
+ if (num == indices[i])
+ {
node = child;
break;
}
@@ -602,15 +609,16 @@ gedit_file_browser_store_get_iter (GtkTreeModel * tree_model,
}
static GtkTreePath *
-gedit_file_browser_store_get_path_real (GeditFileBrowserStore * model,
- FileBrowserNode * node)
+gedit_file_browser_store_get_path_real (GeditFileBrowserStore *model,
+ FileBrowserNode *node)
{
GtkTreePath *path;
gint num = 0;
path = gtk_tree_path_new ();
- while (node != model->priv->virtual_root) {
+ while (node != model->priv->virtual_root)
+ {
GSList *item;
if (node->parent == NULL) {
@@ -620,20 +628,25 @@ gedit_file_browser_store_get_path_real (GeditFileBrowserStore * model,
num = 0;
- for (item = FILE_BROWSER_NODE_DIR (node->parent)->children; item; item = item->next) {
+ for (item = FILE_BROWSER_NODE_DIR (node->parent)->children; item; item = item->next)
+ {
FileBrowserNode *check;
check = (FileBrowserNode *) (item->data);
- if (model_node_visibility (model, check) && (check == node || check->inserted)) {
- if (check == node) {
+ if (model_node_visibility (model, check) && (check == node || check->inserted))
+ {
+ if (check == node)
+ {
gtk_tree_path_prepend_index (path,
num);
break;
}
++num;
- } else if (check == node) {
+ }
+ else if (check == node)
+ {
if (NODE_IS_DUMMY (node))
g_warning ("Dummy not visible???");
@@ -649,8 +662,8 @@ gedit_file_browser_store_get_path_real (GeditFileBrowserStore * model,
}
static GtkTreePath *
-gedit_file_browser_store_get_path (GtkTreeModel * tree_model,
- GtkTreeIter * iter)
+gedit_file_browser_store_get_path (GtkTreeModel *tree_model,
+ GtkTreeIter *iter)
{
g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_STORE (tree_model), NULL);
g_return_val_if_fail (iter != NULL, NULL);
@@ -661,10 +674,10 @@ gedit_file_browser_store_get_path (GtkTreeModel * tree_model,
}
static void
-gedit_file_browser_store_get_value (GtkTreeModel * tree_model,
- GtkTreeIter * iter,
- gint column,
- GValue * value)
+gedit_file_browser_store_get_value (GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ gint column,
+ GValue *value)
{
FileBrowserNode *node;
@@ -676,35 +689,36 @@ gedit_file_browser_store_get_value (GtkTreeModel * tree_model,
g_value_init (value, GEDIT_FILE_BROWSER_STORE (tree_model)->priv->column_types[column]);
- switch (column) {
- case GEDIT_FILE_BROWSER_STORE_COLUMN_LOCATION:
- set_gvalue_from_node (value, node);
- break;
- case GEDIT_FILE_BROWSER_STORE_COLUMN_NAME:
- g_value_set_string (value, node->name);
- break;
- case GEDIT_FILE_BROWSER_STORE_COLUMN_FLAGS:
- g_value_set_uint (value, node->flags);
- break;
- case GEDIT_FILE_BROWSER_STORE_COLUMN_ICON:
- g_value_set_object (value, node->icon);
- break;
- case GEDIT_FILE_BROWSER_STORE_COLUMN_EMBLEM:
- g_value_set_object (value, node->emblem);
- break;
- default:
- g_return_if_reached ();
+ switch (column)
+ {
+ case GEDIT_FILE_BROWSER_STORE_COLUMN_LOCATION:
+ set_gvalue_from_node (value, node);
+ break;
+ case GEDIT_FILE_BROWSER_STORE_COLUMN_NAME:
+ g_value_set_string (value, node->name);
+ break;
+ case GEDIT_FILE_BROWSER_STORE_COLUMN_FLAGS:
+ g_value_set_uint (value, node->flags);
+ break;
+ case GEDIT_FILE_BROWSER_STORE_COLUMN_ICON:
+ g_value_set_object (value, node->icon);
+ break;
+ case GEDIT_FILE_BROWSER_STORE_COLUMN_EMBLEM:
+ g_value_set_object (value, node->emblem);
+ break;
+ default:
+ g_return_if_reached ();
}
}
static gboolean
-gedit_file_browser_store_iter_next (GtkTreeModel * tree_model,
- GtkTreeIter * iter)
+gedit_file_browser_store_iter_next (GtkTreeModel *tree_model,
+ GtkTreeIter *iter)
{
- GeditFileBrowserStore * model;
- FileBrowserNode * node;
- GSList * item;
- GSList * first;
+ GeditFileBrowserStore *model;
+ FileBrowserNode *node;
+ GSList *item;
+ GSList *first;
g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_STORE (tree_model),
FALSE);
@@ -719,8 +733,10 @@ gedit_file_browser_store_iter_next (GtkTreeModel * tree_model,
first = g_slist_next (g_slist_find (FILE_BROWSER_NODE_DIR (node->parent)->children, node));
- for (item = first; item; item = item->next) {
- if (model_node_inserted (model, (FileBrowserNode *) (item->data))) {
+ for (item = first; item; item = item->next)
+ {
+ if (model_node_inserted (model, (FileBrowserNode *) (item->data)))
+ {
iter->user_data = item->data;
return TRUE;
}
@@ -730,18 +746,16 @@ gedit_file_browser_store_iter_next (GtkTreeModel * tree_model,
}
static gboolean
-gedit_file_browser_store_iter_children (GtkTreeModel * tree_model,
- GtkTreeIter * iter,
- GtkTreeIter * parent)
+gedit_file_browser_store_iter_children (GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ GtkTreeIter *parent)
{
- FileBrowserNode * node;
- GeditFileBrowserStore * model;
- GSList * item;
+ FileBrowserNode *node;
+ GeditFileBrowserStore *model;
+ GSList *item;
- g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_STORE (tree_model),
- FALSE);
- g_return_val_if_fail (parent == NULL
- || parent->user_data != NULL, FALSE);
+ g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_STORE (tree_model), FALSE);
+ g_return_val_if_fail (parent == NULL || parent->user_data != NULL, FALSE);
model = GEDIT_FILE_BROWSER_STORE (tree_model);
@@ -756,8 +770,10 @@ gedit_file_browser_store_iter_children (GtkTreeModel * tree_model,
if (!NODE_IS_DIR (node))
return FALSE;
- for (item = FILE_BROWSER_NODE_DIR (node)->children; item; item = item->next) {
- if (model_node_inserted (model, (FileBrowserNode *) (item->data))) {
+ for (item = FILE_BROWSER_NODE_DIR (node)->children; item; item = item->next)
+ {
+ if (model_node_inserted (model, (FileBrowserNode *) (item->data)))
+ {
iter->user_data = item->data;
return TRUE;
}
@@ -767,15 +783,16 @@ gedit_file_browser_store_iter_children (GtkTreeModel * tree_model,
}
static gboolean
-filter_tree_model_iter_has_child_real (GeditFileBrowserStore * model,
- FileBrowserNode * node)
+filter_tree_model_iter_has_child_real (GeditFileBrowserStore *model,
+ FileBrowserNode *node)
{
GSList *item;
if (!NODE_IS_DIR (node))
return FALSE;
- for (item = FILE_BROWSER_NODE_DIR (node)->children; item; item = item->next) {
+ for (item = FILE_BROWSER_NODE_DIR (node)->children; item; item = item->next)
+ {
if (model_node_inserted (model, (FileBrowserNode *) (item->data)))
return TRUE;
}
@@ -784,8 +801,8 @@ filter_tree_model_iter_has_child_real (GeditFileBrowserStore * model,
}
static gboolean
-gedit_file_browser_store_iter_has_child (GtkTreeModel * tree_model,
- GtkTreeIter * iter)
+gedit_file_browser_store_iter_has_child (GtkTreeModel *tree_model,
+ GtkTreeIter *iter)
{
FileBrowserNode *node;
GeditFileBrowserStore *model;
@@ -806,8 +823,8 @@ gedit_file_browser_store_iter_has_child (GtkTreeModel * tree_model,
}
static gint
-gedit_file_browser_store_iter_n_children (GtkTreeModel * tree_model,
- GtkTreeIter * iter)
+gedit_file_browser_store_iter_n_children (GtkTreeModel *tree_model,
+ GtkTreeIter *iter)
{
FileBrowserNode *node;
GeditFileBrowserStore *model;
@@ -837,19 +854,18 @@ gedit_file_browser_store_iter_n_children (GtkTreeModel * tree_model,
}
static gboolean
-gedit_file_browser_store_iter_nth_child (GtkTreeModel * tree_model,
- GtkTreeIter * iter,
- GtkTreeIter * parent, gint n)
+gedit_file_browser_store_iter_nth_child (GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ GtkTreeIter *parent,
+ gint n)
{
FileBrowserNode *node;
GeditFileBrowserStore *model;
GSList *item;
gint num = 0;
- g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_STORE (tree_model),
- FALSE);
- g_return_val_if_fail (parent == NULL
- || parent->user_data != NULL, FALSE);
+ g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_STORE (tree_model), FALSE);
+ g_return_val_if_fail (parent == NULL || parent->user_data != NULL, FALSE);
model = GEDIT_FILE_BROWSER_STORE (tree_model);
@@ -862,9 +878,12 @@ gedit_file_browser_store_iter_nth_child (GtkTreeModel * tree_model,
return FALSE;
for (item = FILE_BROWSER_NODE_DIR (node)->children; item;
- item = item->next) {
- if (model_node_inserted (model, (FileBrowserNode *) (item->data))) {
- if (num == n) {
+ item = item->next)
+ {
+ if (model_node_inserted (model, (FileBrowserNode *) (item->data)))
+ {
+ if (num == n)
+ {
iter->user_data = item->data;
return TRUE;
}
@@ -877,9 +896,9 @@ gedit_file_browser_store_iter_nth_child (GtkTreeModel * tree_model,
}
static gboolean
-gedit_file_browser_store_iter_parent (GtkTreeModel * tree_model,
- GtkTreeIter * iter,
- GtkTreeIter * child)
+gedit_file_browser_store_iter_parent (GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ GtkTreeIter *child)
{
FileBrowserNode *node;
GeditFileBrowserStore *model;
@@ -902,18 +921,18 @@ gedit_file_browser_store_iter_parent (GtkTreeModel * tree_model,
}
static void
-gedit_file_browser_store_row_inserted (GtkTreeModel * tree_model,
- GtkTreePath * path,
- GtkTreeIter * iter)
+gedit_file_browser_store_row_inserted (GtkTreeModel *tree_model,
+ GtkTreePath *path,
+ GtkTreeIter *iter)
{
- FileBrowserNode * node = (FileBrowserNode *)(iter->user_data);
+ FileBrowserNode *node = (FileBrowserNode *)(iter->user_data);
node->inserted = TRUE;
}
static gboolean
-gedit_file_browser_store_row_draggable (GtkTreeDragSource * drag_source,
- GtkTreePath * path)
+gedit_file_browser_store_row_draggable (GtkTreeDragSource *drag_source,
+ GtkTreePath *path)
{
GtkTreeIter iter;
GeditFileBrowserStoreFlag flags;
@@ -932,16 +951,16 @@ gedit_file_browser_store_row_draggable (GtkTreeDragSource * drag_source,
}
static gboolean
-gedit_file_browser_store_drag_data_delete (GtkTreeDragSource * drag_source,
- GtkTreePath * path)
+gedit_file_browser_store_drag_data_delete (GtkTreeDragSource *drag_source,
+ GtkTreePath *path)
{
return FALSE;
}
static gboolean
-gedit_file_browser_store_drag_data_get (GtkTreeDragSource * drag_source,
- GtkTreePath * path,
- GtkSelectionData * selection_data)
+gedit_file_browser_store_drag_data_get (GtkTreeDragSource *drag_source,
+ GtkTreePath *path,
+ GtkSelectionData *selection_data)
{
GtkTreeIter iter;
GFile *location;
@@ -973,7 +992,8 @@ gedit_file_browser_store_drag_data_get (GtkTreeDragSource * drag_source,
/* Private */
static void
-model_begin_loading (GeditFileBrowserStore * model, FileBrowserNode * node)
+model_begin_loading (GeditFileBrowserStore *model,
+ FileBrowserNode *node)
{
GtkTreeIter iter;
@@ -982,7 +1002,8 @@ model_begin_loading (GeditFileBrowserStore * model, FileBrowserNode * node)
}
static void
-model_end_loading (GeditFileBrowserStore * model, FileBrowserNode * node)
+model_end_loading (GeditFileBrowserStore *model,
+ FileBrowserNode *node)
{
GtkTreeIter iter;
@@ -991,8 +1012,8 @@ model_end_loading (GeditFileBrowserStore * model, FileBrowserNode * node)
}
static void
-model_node_update_visibility (GeditFileBrowserStore * model,
- FileBrowserNode * node)
+model_node_update_visibility (GeditFileBrowserStore *model,
+ FileBrowserNode *node)
{
GtkTreeIter iter;
@@ -1000,29 +1021,38 @@ model_node_update_visibility (GeditFileBrowserStore * model,
if (FILTER_HIDDEN (model->priv->filter_mode) &&
NODE_IS_HIDDEN (node))
+ {
node->flags |= GEDIT_FILE_BROWSER_STORE_FLAG_IS_FILTERED;
+ }
else if (FILTER_BINARY (model->priv->filter_mode) &&
(!NODE_IS_TEXT (node) && !NODE_IS_DIR (node)))
+ {
node->flags |= GEDIT_FILE_BROWSER_STORE_FLAG_IS_FILTERED;
- else if (model->priv->filter_func) {
+ }
+ else if (model->priv->filter_func)
+ {
iter.user_data = node;
- if (!model->priv->
- filter_func (model, &iter,
- model->priv->filter_user_data))
- node->flags |=
- GEDIT_FILE_BROWSER_STORE_FLAG_IS_FILTERED;
+ if (!model->priv->filter_func (model, &iter,
+ model->priv->filter_user_data))
+ node->flags |= GEDIT_FILE_BROWSER_STORE_FLAG_IS_FILTERED;
}
}
static gint
-collate_nodes (FileBrowserNode * node1, FileBrowserNode * node2)
+collate_nodes (FileBrowserNode *node1,
+ FileBrowserNode *node2)
{
if (node1->name == NULL)
+ {
return -1;
+ }
else if (node2->name == NULL)
+ {
return 1;
- else {
+ }
+ else
+ {
gchar *k1, *k2;
gint result;
@@ -1039,7 +1069,8 @@ collate_nodes (FileBrowserNode * node1, FileBrowserNode * node2)
}
static gint
-model_sort_default (FileBrowserNode * node1, FileBrowserNode * node2)
+model_sort_default (FileBrowserNode *node1,
+ FileBrowserNode *node2)
{
gint f1;
gint f2;
@@ -1048,35 +1079,28 @@ model_sort_default (FileBrowserNode * node1, FileBrowserNode * node2)
f2 = NODE_IS_DUMMY (node2);
if (f1 && f2)
- {
return 0;
- }
else if (f1 || f2)
- {
return f1 ? -1 : 1;
- }
f1 = NODE_IS_DIR (node1);
f2 = NODE_IS_DIR (node2);
if (f1 != f2)
- {
return f1 ? -1 : 1;
- }
f1 = NODE_IS_HIDDEN (node1);
f2 = NODE_IS_HIDDEN (node2);
if (f1 != f2)
- {
return f2 ? -1 : 1;
- }
return collate_nodes (node1, node2);
}
static void
-model_resort_node (GeditFileBrowserStore * model, FileBrowserNode * node)
+model_resort_node (GeditFileBrowserStore *model,
+ FileBrowserNode *node)
{
FileBrowserNodeDir *dir;
GSList *item;
@@ -1088,14 +1112,18 @@ model_resort_node (GeditFileBrowserStore * model, FileBrowserNode * node)
dir = FILE_BROWSER_NODE_DIR (node->parent);
- if (!model_node_visibility (model, node->parent)) {
+ if (!model_node_visibility (model, node->parent))
+ {
/* Just sort the children of the parent */
dir->children = g_slist_sort (dir->children,
(GCompareFunc) (model->priv->
sort_func));
- } else {
+ }
+ else
+ {
/* Store current positions */
- for (item = dir->children; item; item = item->next) {
+ for (item = dir->children; item; item = item->next)
+ {
child = (FileBrowserNode *) (item->data);
if (model_node_visibility (model, child))
@@ -1109,7 +1137,8 @@ model_resort_node (GeditFileBrowserStore * model, FileBrowserNode * node)
pos = 0;
/* Store the new positions */
- for (item = dir->children; item; item = item->next) {
+ for (item = dir->children; item; item = item->next)
+ {
child = (FileBrowserNode *) (item->data);
if (model_node_visibility (model, child))
@@ -1117,9 +1146,7 @@ model_resort_node (GeditFileBrowserStore * model, FileBrowserNode * node)
}
iter.user_data = node->parent;
- path =
- gedit_file_browser_store_get_path_real (model,
- node->parent);
+ path = gedit_file_browser_store_get_path_real (model, node->parent);
gtk_tree_model_rows_reordered (GTK_TREE_MODEL (model),
path, &iter, neworder);
@@ -1130,9 +1157,9 @@ model_resort_node (GeditFileBrowserStore * model, FileBrowserNode * node)
}
static void
-row_changed (GeditFileBrowserStore * model,
- GtkTreePath ** path,
- GtkTreeIter * iter)
+row_changed (GeditFileBrowserStore *model,
+ GtkTreePath **path,
+ GtkTreeIter *iter)
{
GtkTreeRowReference *ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (model), *path);
@@ -1146,9 +1173,9 @@ row_changed (GeditFileBrowserStore * model,
}
static void
-row_inserted (GeditFileBrowserStore * model,
- GtkTreePath ** path,
- GtkTreeIter * iter)
+row_inserted (GeditFileBrowserStore *model,
+ GtkTreePath **path,
+ GtkTreeIter *iter)
{
/* This function creates a row reference for the path because it's
uncertain what might change the actual model/view when we insert
@@ -1157,7 +1184,7 @@ row_inserted (GeditFileBrowserStore * model,
the path remains pointed towards the inserted node, we use the
reference to keep track. */
GtkTreeRowReference *ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (model), *path);
- GtkTreePath * copy = gtk_tree_path_copy (*path);
+ GtkTreePath *copy = gtk_tree_path_copy (*path);
gtk_tree_model_row_inserted (GTK_TREE_MODEL(model), copy, iter);
gtk_tree_path_free (copy);
@@ -1177,8 +1204,8 @@ row_inserted (GeditFileBrowserStore * model,
}
static void
-row_deleted (GeditFileBrowserStore * model,
- const GtkTreePath * path)
+row_deleted (GeditFileBrowserStore *model,
+ const GtkTreePath *path)
{
GtkTreePath *copy = gtk_tree_path_copy (path);
@@ -1189,9 +1216,9 @@ row_deleted (GeditFileBrowserStore * model,
}
static void
-model_refilter_node (GeditFileBrowserStore * model,
- FileBrowserNode * node,
- GtkTreePath ** path)
+model_refilter_node (GeditFileBrowserStore *model,
+ FileBrowserNode *node,
+ GtkTreePath **path)
{
gboolean old_visible;
gboolean new_visible;
@@ -1220,13 +1247,15 @@ model_refilter_node (GeditFileBrowserStore * model,
path = &tmppath;
}
- if (NODE_IS_DIR (node)) {
+ if (NODE_IS_DIR (node))
+ {
if (in_tree)
gtk_tree_path_down (*path);
dir = FILE_BROWSER_NODE_DIR (node);
- for (item = dir->children; item; item = item->next) {
+ for (item = dir->children; item; item = item->next)
+ {
model_refilter_node (model,
(FileBrowserNode *) (item->data),
path);
@@ -1236,19 +1265,26 @@ model_refilter_node (GeditFileBrowserStore * model,
gtk_tree_path_up (*path);
}
- if (in_tree) {
+ if (in_tree)
+ {
new_visible = model_node_visibility (model, node);
- if (old_visible != new_visible) {
- if (old_visible) {
+ if (old_visible != new_visible)
+ {
+ if (old_visible)
+ {
node->inserted = FALSE;
row_deleted (model, *path);
- } else {
+ }
+ else
+ {
iter.user_data = node;
row_inserted (model, path, &iter);
gtk_tree_path_next (*path);
}
- } else if (old_visible) {
+ }
+ else if (old_visible)
+ {
gtk_tree_path_next (*path);
}
}
@@ -1260,28 +1296,29 @@ model_refilter_node (GeditFileBrowserStore * model,
}
static void
-model_refilter (GeditFileBrowserStore * model)
+model_refilter (GeditFileBrowserStore *model)
{
model_refilter_node (model, model->priv->root, NULL);
}
static void
-file_browser_node_set_name (FileBrowserNode * node)
+file_browser_node_set_name (FileBrowserNode *node)
{
g_free (node->name);
- if (node->file) {
+ if (node->file)
node->name = gedit_file_browser_utils_file_basename (node->file);
- } else {
+ else
node->name = NULL;
- }
}
static void
-file_browser_node_init (FileBrowserNode * node, GFile * file,
- FileBrowserNode * parent)
+file_browser_node_init (FileBrowserNode *node,
+ GFile *file,
+ FileBrowserNode *parent)
{
- if (file != NULL) {
+ if (file != NULL)
+ {
node->file = g_object_ref (file);
file_browser_node_set_name (node);
}
@@ -1290,7 +1327,8 @@ file_browser_node_init (FileBrowserNode * node, GFile * file,
}
static FileBrowserNode *
-file_browser_node_new (GFile * file, FileBrowserNode * parent)
+file_browser_node_new (GFile *file,
+ FileBrowserNode *parent)
{
FileBrowserNode *node = g_slice_new0 (FileBrowserNode);
@@ -1299,8 +1337,9 @@ file_browser_node_new (GFile * file, FileBrowserNode * parent)
}
static FileBrowserNode *
-file_browser_node_dir_new (GeditFileBrowserStore * model,
- GFile * file, FileBrowserNode * parent)
+file_browser_node_dir_new (GeditFileBrowserStore *model,
+ GFile *file,
+ FileBrowserNode *parent)
{
FileBrowserNode *node =
(FileBrowserNode *) g_slice_new0 (FileBrowserNodeDir);
@@ -1315,20 +1354,20 @@ file_browser_node_dir_new (GeditFileBrowserStore * model,
}
static void
-file_browser_node_free_children (GeditFileBrowserStore * model,
- FileBrowserNode * node)
+file_browser_node_free_children (GeditFileBrowserStore *model,
+ FileBrowserNode *node)
{
GSList *item;
if (node == NULL)
return;
- if (NODE_IS_DIR (node)) {
+ if (NODE_IS_DIR (node))
+ {
for (item = FILE_BROWSER_NODE_DIR (node)->children; item;
item = item->next)
file_browser_node_free (model,
- (FileBrowserNode *) (item->
- data));
+ (FileBrowserNode *) (item->data));
g_slist_free (FILE_BROWSER_NODE_DIR (node)->children);
FILE_BROWSER_NODE_DIR (node)->children = NULL;
@@ -1339,8 +1378,8 @@ file_browser_node_free_children (GeditFileBrowserStore * model,
}
static void
-file_browser_node_free (GeditFileBrowserStore * model,
- FileBrowserNode * node)
+file_browser_node_free (GeditFileBrowserStore *model,
+ FileBrowserNode *node)
{
if (node == NULL)
return;
@@ -1351,7 +1390,8 @@ file_browser_node_free (GeditFileBrowserStore * model,
dir = FILE_BROWSER_NODE_DIR (node);
- if (dir->cancellable) {
+ if (dir->cancellable)
+ {
g_cancellable_cancel (dir->cancellable);
g_object_unref (dir->cancellable);
@@ -1360,7 +1400,8 @@ file_browser_node_free (GeditFileBrowserStore * model,
file_browser_node_free_children (model, node);
- if (dir->monitor) {
+ if (dir->monitor)
+ {
g_file_monitor_cancel (dir->monitor);
g_object_unref (dir->monitor);
}
@@ -1396,16 +1437,16 @@ file_browser_node_free (GeditFileBrowserStore * model,
* @node: the FileBrowserNode to remove
* @path: the path of the node, or NULL to let the path be calculated
* @free_nodes: whether to also remove the nodes from memory
- *
+ *
* Removes all the children of node from the model. This function is used
* to remove the child nodes from the _model_. Don't use it to just free
* a node.
- **/
+ */
static void
-model_remove_node_children (GeditFileBrowserStore * model,
- FileBrowserNode * node,
- GtkTreePath * path,
- gboolean free_nodes)
+model_remove_node_children (GeditFileBrowserStore *model,
+ FileBrowserNode *node,
+ GtkTreePath *path,
+ gboolean free_nodes)
{
FileBrowserNodeDir *dir;
GtkTreePath *path_child;
@@ -1420,9 +1461,10 @@ model_remove_node_children (GeditFileBrowserStore * model,
if (dir->children == NULL)
return;
- if (!model_node_visibility (model, node)) {
- // Node is invisible and therefore the children can just
- // be freed
+ if (!model_node_visibility (model, node))
+ {
+ /* Node is invisible and therefore the children can just
+ be freed */
if (free_nodes)
file_browser_node_free_children (model, node);
@@ -1430,8 +1472,7 @@ model_remove_node_children (GeditFileBrowserStore * model,
}
if (path == NULL)
- path_child =
- gedit_file_browser_store_get_path_real (model, node);
+ path_child = gedit_file_browser_store_get_path_real (model, node);
else
path_child = gtk_tree_path_copy (path);
@@ -1439,10 +1480,9 @@ model_remove_node_children (GeditFileBrowserStore * model,
list = g_slist_copy (dir->children);
- for (item = list; item; item = item->next) {
+ for (item = list; item; item = item->next)
model_remove_node (model, (FileBrowserNode *) (item->data),
path_child, free_nodes);
- }
g_slist_free (list);
gtk_tree_path_free (path_child);
@@ -1459,19 +1499,19 @@ model_remove_node_children (GeditFileBrowserStore * model,
* Removes this node and all its children from the model. This function is used
* to remove the node from the _model_. Don't use it to just free
* a node.
- **/
+ */
static void
-model_remove_node (GeditFileBrowserStore * model,
- FileBrowserNode * node,
- GtkTreePath * path,
- gboolean free_nodes)
+model_remove_node (GeditFileBrowserStore *model,
+ FileBrowserNode *node,
+ GtkTreePath *path,
+ gboolean free_nodes)
{
gboolean free_path = FALSE;
FileBrowserNode *parent;
- if (path == NULL) {
- path =
- gedit_file_browser_store_get_path_real (model, node);
+ if (path == NULL)
+ {
+ path = gedit_file_browser_store_get_path_real (model, node);
free_path = TRUE;
}
@@ -1490,7 +1530,8 @@ model_remove_node (GeditFileBrowserStore * model,
parent = node->parent;
- if (free_nodes) {
+ if (free_nodes)
+ {
/* Remove the node from the parents children list */
if (parent)
FILE_BROWSER_NODE_DIR (node->parent)->children =
@@ -1514,13 +1555,14 @@ model_remove_node (GeditFileBrowserStore * model,
* model_clear:
* @model: the #GeditFileBrowserStore
* @free_nodes: whether to also remove the nodes from memory
- *
+ *
* Removes all nodes from the model. This function is used
* to remove all the nodes from the _model_. Don't use it to just free the
* nodes in the model.
- **/
+ */
static void
-model_clear (GeditFileBrowserStore * model, gboolean free_nodes)
+model_clear (GeditFileBrowserStore *model,
+ gboolean free_nodes)
{
GtkTreePath *path;
FileBrowserNodeDir *dir;
@@ -1532,14 +1574,17 @@ model_clear (GeditFileBrowserStore * model, gboolean free_nodes)
gtk_tree_path_free (path);
/* Remove the dummy if there is one */
- if (model->priv->virtual_root) {
+ if (model->priv->virtual_root)
+ {
dir = FILE_BROWSER_NODE_DIR (model->priv->virtual_root);
- if (dir->children != NULL) {
+ if (dir->children != NULL)
+ {
dummy = (FileBrowserNode *) (dir->children->data);
- if (NODE_IS_DUMMY (dummy)
- && model_node_visibility (model, dummy)) {
+ if (NODE_IS_DUMMY (dummy) &&
+ model_node_visibility (model, dummy))
+ {
path = gtk_tree_path_new_first ();
dummy->inserted = FALSE;
@@ -1551,8 +1596,9 @@ model_clear (GeditFileBrowserStore * model, gboolean free_nodes)
}
static void
-file_browser_node_unload (GeditFileBrowserStore * model,
- FileBrowserNode * node, gboolean remove_children)
+file_browser_node_unload (GeditFileBrowserStore *model,
+ FileBrowserNode *node,
+ gboolean remove_children)
{
FileBrowserNodeDir *dir;
@@ -1567,7 +1613,8 @@ file_browser_node_unload (GeditFileBrowserStore * model,
if (remove_children)
model_remove_node_children (model, node, NULL, TRUE);
- if (dir->cancellable) {
+ if (dir->cancellable)
+ {
g_cancellable_cancel (dir->cancellable);
g_object_unref (dir->cancellable);
@@ -1575,7 +1622,8 @@ file_browser_node_unload (GeditFileBrowserStore * model,
dir->cancellable = NULL;
}
- if (dir->monitor) {
+ if (dir->monitor)
+ {
g_file_monitor_cancel (dir->monitor);
g_object_unref (dir->monitor);
@@ -1586,9 +1634,9 @@ file_browser_node_unload (GeditFileBrowserStore * model,
}
static void
-model_recomposite_icon_real (GeditFileBrowserStore * tree_model,
- FileBrowserNode * node,
- GFileInfo * info)
+model_recomposite_icon_real (GeditFileBrowserStore *tree_model,
+ FileBrowserNode *node,
+ GFileInfo *info)
{
GdkPixbuf *icon;
@@ -1598,32 +1646,40 @@ model_recomposite_icon_real (GeditFileBrowserStore * tree_model,
if (node->file == NULL)
return;
- if (info) {
+ if (info)
+ {
GIcon *gicon = g_file_info_get_icon (info);
+
if (gicon != NULL)
icon = gedit_file_browser_utils_pixbuf_from_icon (gicon, GTK_ICON_SIZE_MENU);
else
icon = NULL;
- } else {
+ }
+ else
+ {
icon = gedit_file_browser_utils_pixbuf_from_file (node->file, GTK_ICON_SIZE_MENU);
}
if (node->icon)
g_object_unref (node->icon);
- if (node->emblem) {
+ if (node->emblem)
+ {
gint icon_size;
gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, NULL, &icon_size);
- if (icon == NULL) {
+ if (icon == NULL)
+ {
node->icon =
gdk_pixbuf_new (gdk_pixbuf_get_colorspace (node->emblem),
gdk_pixbuf_get_has_alpha (node->emblem),
gdk_pixbuf_get_bits_per_sample (node->emblem),
icon_size,
icon_size);
- } else {
+ }
+ else
+ {
node->icon = gdk_pixbuf_copy (icon);
g_object_unref (icon);
}
@@ -1632,14 +1688,16 @@ model_recomposite_icon_real (GeditFileBrowserStore * tree_model,
icon_size - 10, icon_size - 10, 10,
10, icon_size - 10, icon_size - 10,
1, 1, GDK_INTERP_NEAREST, 255);
- } else {
+ }
+ else
+ {
node->icon = icon;
}
}
static void
-model_recomposite_icon (GeditFileBrowserStore * tree_model,
- GtkTreeIter * iter)
+model_recomposite_icon (GeditFileBrowserStore *tree_model,
+ GtkTreeIter *iter)
{
g_return_if_fail (GEDIT_IS_FILE_BROWSER_STORE (tree_model));
g_return_if_fail (iter != NULL);
@@ -1651,8 +1709,8 @@ model_recomposite_icon (GeditFileBrowserStore * tree_model,
}
static FileBrowserNode *
-model_create_dummy_node (GeditFileBrowserStore * model,
- FileBrowserNode * parent)
+model_create_dummy_node (GeditFileBrowserStore *model,
+ FileBrowserNode *parent)
{
FileBrowserNode *dummy;
@@ -1666,8 +1724,8 @@ model_create_dummy_node (GeditFileBrowserStore * model,
}
static FileBrowserNode *
-model_add_dummy_node (GeditFileBrowserStore * model,
- FileBrowserNode * parent)
+model_add_dummy_node (GeditFileBrowserStore *model,
+ FileBrowserNode *parent)
{
FileBrowserNode *dummy;
@@ -1682,10 +1740,12 @@ model_add_dummy_node (GeditFileBrowserStore * model,
}
static void
-model_check_dummy (GeditFileBrowserStore * model, FileBrowserNode * node)
+model_check_dummy (GeditFileBrowserStore *model,
+ FileBrowserNode *node)
{
- // Hide the dummy child if needed
- if (NODE_IS_DIR (node)) {
+ /* Hide the dummy child if needed */
+ if (NODE_IS_DIR (node))
+ {
FileBrowserNode *dummy;
GtkTreeIter iter;
GtkTreePath *path;
@@ -1694,35 +1754,39 @@ model_check_dummy (GeditFileBrowserStore * model, FileBrowserNode * node)
dir = FILE_BROWSER_NODE_DIR (node);
- if (dir->children == NULL) {
+ if (dir->children == NULL)
+ {
model_add_dummy_node (model, node);
return;
}
dummy = (FileBrowserNode *) (dir->children->data);
- if (!NODE_IS_DUMMY (dummy)) {
+ if (!NODE_IS_DUMMY (dummy))
+ {
dummy = model_create_dummy_node (model, node);
dir->children = g_slist_prepend (dir->children, dummy);
}
- if (!model_node_visibility (model, node)) {
- dummy->flags |=
- GEDIT_FILE_BROWSER_STORE_FLAG_IS_HIDDEN;
+ if (!model_node_visibility (model, node))
+ {
+ dummy->flags |= GEDIT_FILE_BROWSER_STORE_FLAG_IS_HIDDEN;
return;
}
/* Temporarily set the node to invisible to check
- * for real children */
+ for real children */
flags = dummy->flags;
dummy->flags |= GEDIT_FILE_BROWSER_STORE_FLAG_IS_HIDDEN;
- if (!filter_tree_model_iter_has_child_real (model, node)) {
+ if (!filter_tree_model_iter_has_child_real (model, node))
+ {
dummy->flags &=
~GEDIT_FILE_BROWSER_STORE_FLAG_IS_HIDDEN;
- if (FILE_IS_HIDDEN (flags)) {
- // Was hidden, needs to be inserted
+ if (FILE_IS_HIDDEN (flags))
+ {
+ /* Was hidden, needs to be inserted */
iter.user_data = dummy;
path =
gedit_file_browser_store_get_path_real
@@ -1731,18 +1795,17 @@ model_check_dummy (GeditFileBrowserStore * model, FileBrowserNode * node)
row_inserted (model, &path, &iter);
gtk_tree_path_free (path);
}
- } else {
- if (!FILE_IS_HIDDEN (flags)) {
- // Was shown, needs to be removed
+ }
+ else
+ {
+ if (!FILE_IS_HIDDEN (flags))
+ {
+ /* Was shown, needs to be removed */
- // To get the path we need to set it to visible temporarily
- dummy->flags &=
- ~GEDIT_FILE_BROWSER_STORE_FLAG_IS_HIDDEN;
- path =
- gedit_file_browser_store_get_path_real
- (model, dummy);
- dummy->flags |=
- GEDIT_FILE_BROWSER_STORE_FLAG_IS_HIDDEN;
+ /* To get the path we need to set it to visible temporarily */
+ dummy->flags &= ~GEDIT_FILE_BROWSER_STORE_FLAG_IS_HIDDEN;
+ 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);
@@ -1753,33 +1816,33 @@ model_check_dummy (GeditFileBrowserStore * model, FileBrowserNode * node)
}
static void
-insert_node_sorted (GeditFileBrowserStore * model,
- FileBrowserNode * child,
- FileBrowserNode * parent)
+insert_node_sorted (GeditFileBrowserStore *model,
+ FileBrowserNode *child,
+ FileBrowserNode *parent)
{
FileBrowserNodeDir *dir;
dir = FILE_BROWSER_NODE_DIR (parent);
- if (model->priv->sort_func == NULL) {
+ if (model->priv->sort_func == NULL)
dir->children = g_slist_append (dir->children, child);
- } else {
+ else
dir->children =
g_slist_insert_sorted (dir->children, child,
- (GCompareFunc) (model->priv->
- sort_func));
- }
+ (GCompareFunc) (model->priv->sort_func));
}
static void
-model_add_node (GeditFileBrowserStore * model, FileBrowserNode * child,
- FileBrowserNode * parent)
+model_add_node (GeditFileBrowserStore *model,
+ FileBrowserNode *child,
+ FileBrowserNode *parent)
{
/* Add child to parents children */
insert_node_sorted (model, child, parent);
if (model_node_visibility (model, parent) &&
- model_node_visibility (model, child)) {
+ model_node_visibility (model, child))
+ {
GtkTreeIter iter;
GtkTreePath *path;
@@ -1796,9 +1859,9 @@ model_add_node (GeditFileBrowserStore * model, FileBrowserNode * child,
}
static void
-model_add_nodes_batch (GeditFileBrowserStore * model,
- GSList * children,
- FileBrowserNode * parent)
+model_add_nodes_batch (GeditFileBrowserStore *model,
+ GSList *children,
+ FileBrowserNode *parent)
{
GSList *sorted_children;
GSList *child;
@@ -1816,23 +1879,26 @@ model_add_nodes_batch (GeditFileBrowserStore * model,
model_check_dummy (model, parent);
- while (child) {
+ while (child)
+ {
FileBrowserNode *node = child->data;
GtkTreeIter iter;
GtkTreePath *path;
- /* reached the end of the first list, just append the second */
- if (l == NULL) {
-
+ /* Reached the end of the first list, just append the second */
+ if (l == NULL)
+ {
dir->children = g_slist_concat (dir->children, child);
- for (l = child; l; l = l->next) {
+ for (l = child; l; l = l->next)
+ {
if (model_node_visibility (model, parent) &&
- model_node_visibility (model, l->data)) {
+ model_node_visibility (model, l->data))
+ {
iter.user_data = l->data;
path = gedit_file_browser_store_get_path_real (model, l->data);
- // Emit row inserted
+ /* Emit row inserted */
row_inserted (model, &path, &iter);
gtk_tree_path_free (path);
}
@@ -1843,13 +1909,17 @@ model_add_nodes_batch (GeditFileBrowserStore * model,
break;
}
- if (model->priv->sort_func (l->data, node) > 0) {
+ if (model->priv->sort_func (l->data, node) > 0)
+ {
GSList *next_child;
- if (prev == NULL) {
- /* prepend to the list */
+ if (prev == NULL)
+ {
+ /* Prepend to the list */
dir->children = g_slist_prepend (dir->children, child);
- } else {
+ }
+ else
+ {
prev->next = child;
}
@@ -1859,20 +1929,23 @@ model_add_nodes_batch (GeditFileBrowserStore * model,
child = next_child;
if (model_node_visibility (model, parent) &&
- model_node_visibility (model, node)) {
+ model_node_visibility (model, node))
+ {
iter.user_data = node;
path = gedit_file_browser_store_get_path_real (model, node);
- // Emit row inserted
+ /* Emit row inserted */
row_inserted (model, &path, &iter);
gtk_tree_path_free (path);
}
model_check_dummy (model, node);
- /* try again at the same l position with the
- * next child */
- } else {
+ /* Try again at the same l position with the
+ next child */
+ }
+ else
+ {
/* Move to the next item in the list */
prev = l;
@@ -1882,9 +1955,9 @@ model_add_nodes_batch (GeditFileBrowserStore * model,
}
static gchar const *
-backup_content_type (GFileInfo * info)
+backup_content_type (GFileInfo *info)
{
- gchar const * content;
+ gchar const *content;
if (!g_file_info_get_is_backup (info))
return NULL;
@@ -1898,28 +1971,31 @@ backup_content_type (GFileInfo * info)
}
static void
-file_browser_node_set_from_info (GeditFileBrowserStore * model,
- FileBrowserNode * node,
- GFileInfo * info,
- gboolean isadded)
-{
- FileBrowserNodeDir * dir;
- gchar const * content;
- gchar const * name;
+file_browser_node_set_from_info (GeditFileBrowserStore *model,
+ FileBrowserNode *node,
+ GFileInfo *info,
+ gboolean isadded)
+{
+ FileBrowserNodeDir *dir;
+ gchar const *content;
+ gchar const *name;
gboolean free_info = FALSE;
- GtkTreePath * path;
- gchar * uri;
- GError * error = NULL;
+ GtkTreePath *path;
+ gchar *uri;
+ GError *error = NULL;
- if (info == NULL) {
+ if (info == NULL)
+ {
info = g_file_query_info (node->file,
STANDARD_ATTRIBUTE_TYPES,
G_FILE_QUERY_INFO_NONE,
NULL,
&error);
- if (!info) {
- if (!(error->domain == G_IO_ERROR && error->code == G_IO_ERROR_NOT_FOUND)) {
+ if (!info)
+ {
+ if (!(error->domain == G_IO_ERROR && error->code == G_IO_ERROR_NOT_FOUND))
+ {
uri = g_file_get_uri (node->file);
g_warning ("Could not get info for %s: %s", uri, error->message);
g_free (uri);
@@ -1942,8 +2018,11 @@ file_browser_node_set_from_info (GeditFileBrowserStore * model,
node->flags |= GEDIT_FILE_BROWSER_STORE_FLAG_IS_HIDDEN;
if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY)
+ {
node->flags |= GEDIT_FILE_BROWSER_STORE_FLAG_IS_DIRECTORY;
- else {
+ }
+ else
+ {
if (!(content = backup_content_type (info)))
content = g_file_info_get_content_type (info);
@@ -1958,29 +2037,34 @@ file_browser_node_set_from_info (GeditFileBrowserStore * model,
if (free_info)
g_object_unref (info);
- if (isadded) {
+ if (isadded)
+ {
path = gedit_file_browser_store_get_path_real (model, node);
model_refilter_node (model, node, &path);
gtk_tree_path_free (path);
model_check_dummy (model, node->parent);
- } else {
+ }
+ else
+ {
model_node_update_visibility (model, node);
}
}
static FileBrowserNode *
-node_list_contains_file (GSList *children, GFile * file)
+node_list_contains_file (GSList *children,
+ GFile *file)
{
GSList *item;
- for (item = children; item; item = item->next) {
+ for (item = children; item; item = item->next)
+ {
FileBrowserNode *node;
node = (FileBrowserNode *) (item->data);
- if (node->file != NULL
- && g_file_equal (node->file, file))
+ if (node->file != NULL &&
+ g_file_equal (node->file, file))
return node;
}
@@ -1988,17 +2072,19 @@ node_list_contains_file (GSList *children, GFile * file)
}
static FileBrowserNode *
-model_add_node_from_file (GeditFileBrowserStore * model,
- FileBrowserNode * parent,
- GFile * file,
- GFileInfo * info)
+model_add_node_from_file (GeditFileBrowserStore *model,
+ FileBrowserNode *parent,
+ GFile *file,
+ GFileInfo *info)
{
FileBrowserNode *node;
gboolean free_info = FALSE;
- GError * error = NULL;
+ GError *error = NULL;
- if ((node = node_list_contains_file (FILE_BROWSER_NODE_DIR (parent)->children, file)) == NULL) {
- if (info == NULL) {
+ if ((node = node_list_contains_file (FILE_BROWSER_NODE_DIR (parent)->children, file)) == NULL)
+ {
+ if (info == NULL)
+ {
info = g_file_query_info (file,
STANDARD_ATTRIBUTE_TYPES,
G_FILE_QUERY_INFO_NONE,
@@ -2007,15 +2093,20 @@ model_add_node_from_file (GeditFileBrowserStore * model,
free_info = TRUE;
}
- if (!info) {
+ if (!info)
+ {
g_warning ("Error querying file info: %s", error->message);
g_error_free (error);
/* FIXME: What to do now then... */
node = file_browser_node_new (file, parent);
- } else if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) {
+ }
+ else if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY)
+ {
node = file_browser_node_dir_new (model, file, parent);
- } else {
+ }
+ else
+ {
node = file_browser_node_new (file, parent);
}
@@ -2033,19 +2124,20 @@ model_add_node_from_file (GeditFileBrowserStore * model,
* not have to check if a file already exists among the ones we just
* added */
static void
-model_add_nodes_from_files (GeditFileBrowserStore * model,
- FileBrowserNode * parent,
- GSList * original_children,
- GList * files)
+model_add_nodes_from_files (GeditFileBrowserStore *model,
+ FileBrowserNode *parent,
+ GSList *original_children,
+ GList *files)
{
GList *item;
GSList *nodes = NULL;
- for (item = files; item; item = item->next) {
+ for (item = files; item; item = item->next)
+ {
GFileInfo *info = G_FILE_INFO (item->data);
GFileType type;
- gchar const * name;
- GFile * file;
+ gchar const *name;
+ GFile *file;
FileBrowserNode *node;
type = g_file_info_get_file_type (info);
@@ -2053,7 +2145,8 @@ model_add_nodes_from_files (GeditFileBrowserStore * model,
/* Skip all non regular, non directory files */
if (type != G_FILE_TYPE_REGULAR &&
type != G_FILE_TYPE_DIRECTORY &&
- type != G_FILE_TYPE_SYMBOLIC_LINK) {
+ type != G_FILE_TYPE_SYMBOLIC_LINK)
+ {
g_object_unref (info);
continue;
}
@@ -2063,19 +2156,20 @@ model_add_nodes_from_files (GeditFileBrowserStore * model,
/* Skip '.' and '..' directories */
if (type == G_FILE_TYPE_DIRECTORY &&
(strcmp (name, ".") == 0 ||
- strcmp (name, "..") == 0)) {
+ strcmp (name, "..") == 0))
+ {
continue;
}
file = g_file_get_child (parent->file, name);
- if ((node = node_list_contains_file (original_children, file)) == NULL) {
+ if ((node = node_list_contains_file (original_children, file)) == NULL)
+ {
- if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) {
+ if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY)
node = file_browser_node_dir_new (model, file, parent);
- } else {
+ else
node = file_browser_node_new (file, parent);
- }
file_browser_node_set_from_info (model, node, info, FALSE);
@@ -2091,24 +2185,23 @@ model_add_nodes_from_files (GeditFileBrowserStore * model,
}
static FileBrowserNode *
-model_add_node_from_dir (GeditFileBrowserStore * model,
- FileBrowserNode * parent,
- GFile * file)
+model_add_node_from_dir (GeditFileBrowserStore *model,
+ FileBrowserNode *parent,
+ GFile *file)
{
FileBrowserNode *node;
/* Check if it already exists */
- if ((node = node_list_contains_file (FILE_BROWSER_NODE_DIR (parent)->children, file)) == NULL) {
+ if ((node = node_list_contains_file (FILE_BROWSER_NODE_DIR (parent)->children, file)) == NULL)
+ {
node = file_browser_node_dir_new (model, file, parent);
file_browser_node_set_from_info (model, node, NULL, FALSE);
- if (node->name == NULL) {
+ if (node->name == NULL)
file_browser_node_set_name (node);
- }
- if (node->icon == NULL) {
+ if (node->icon == NULL)
node->icon = gedit_file_browser_utils_pixbuf_from_theme ("folder", GTK_ICON_SIZE_MENU);
- }
model_add_node (model, node, parent);
}
@@ -2126,7 +2219,7 @@ parse_dot_hidden_file (FileBrowserNode *directory)
GFileInfo *info;
GFileType type;
int i;
- FileBrowserNodeDir * dir = FILE_BROWSER_NODE_DIR (directory);
+ 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
@@ -2144,33 +2237,33 @@ parse_dot_hidden_file (FileBrowserNode *directory)
if (info)
g_object_unref (info);
- if (type != G_FILE_TYPE_REGULAR) {
+ if (type != G_FILE_TYPE_REGULAR)
+ {
g_object_unref (child);
-
return;
}
- if (!g_file_load_contents (child, NULL, &file_contents, &file_size, NULL, NULL)) {
+ 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) {
+ 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) {
+ while (i < file_size)
+ {
int start;
start = i;
- while (i < file_size && file_contents[i] != '\n') {
+ while (i < file_size && file_contents[i] != '\n')
i++;
- }
if (i > start) {
char *hidden_filename;
@@ -2188,31 +2281,30 @@ parse_dot_hidden_file (FileBrowserNode *directory)
}
static void
-on_directory_monitor_event (GFileMonitor * monitor,
- GFile * file,
- GFile * other_file,
- GFileMonitorEvent event_type,
- FileBrowserNode * parent)
+on_directory_monitor_event (GFileMonitor *monitor,
+ GFile *file,
+ GFile *other_file,
+ GFileMonitorEvent event_type,
+ FileBrowserNode *parent)
{
FileBrowserNode *node;
FileBrowserNodeDir *dir = FILE_BROWSER_NODE_DIR (parent);
- switch (event_type) {
- case G_FILE_MONITOR_EVENT_DELETED:
- node = node_list_contains_file (dir->children, file);
+ switch (event_type)
+ {
+ case G_FILE_MONITOR_EVENT_DELETED:
+ node = node_list_contains_file (dir->children, file);
- if (node != NULL) {
- model_remove_node (dir->model, node, NULL, TRUE);
- }
- break;
- case G_FILE_MONITOR_EVENT_CREATED:
- if (g_file_query_exists (file, NULL)) {
- model_add_node_from_file (dir->model, parent, file, NULL);
- }
+ if (node != NULL)
+ model_remove_node (dir->model, node, NULL, TRUE);
+ break;
+ case G_FILE_MONITOR_EVENT_CREATED:
+ if (g_file_query_exists (file, NULL))
+ model_add_node_from_file (dir->model, parent, file, NULL);
- break;
- default:
- break;
+ break;
+ default:
+ break;
}
}
@@ -2225,18 +2317,19 @@ async_node_free (AsyncNode *async)
}
static void
-model_iterate_next_files_cb (GFileEnumerator * enumerator,
- GAsyncResult * result,
- AsyncNode * async)
-{
- GList * files;
- GError * error = NULL;
- FileBrowserNodeDir * dir = async->dir;
- FileBrowserNode * parent = (FileBrowserNode *)dir;
+model_iterate_next_files_cb (GFileEnumerator *enumerator,
+ GAsyncResult *result,
+ AsyncNode *async)
+{
+ GList *files;
+ GError *error = NULL;
+ FileBrowserNodeDir *dir = async->dir;
+ FileBrowserNode *parent = (FileBrowserNode *)dir;
files = g_file_enumerator_next_files_finish (enumerator, result, &error);
- if (files == NULL) {
+ if (files == NULL)
+ {
g_file_enumerator_close (enumerator, NULL, NULL);
async_node_free (async);
@@ -2251,24 +2344,25 @@ model_iterate_next_files_cb (GFileEnumerator * enumerator,
* http://bugzilla.gnome.org/show_bug.cgi?id=565924
*/
#ifndef G_OS_WIN32
- if (g_file_is_native (parent->file) && dir->monitor == NULL) {
+ if (g_file_is_native (parent->file) && dir->monitor == NULL)
+ {
dir->monitor = g_file_monitor_directory (parent->file,
G_FILE_MONITOR_NONE,
NULL,
NULL);
if (dir->monitor != NULL)
- {
g_signal_connect (dir->monitor,
"changed",
G_CALLBACK (on_directory_monitor_event),
parent);
- }
}
#endif
model_check_dummy (dir->model, parent);
model_end_loading (dir->model, parent);
- } else {
+ }
+ else
+ {
/* Simply return if we were cancelled */
if (error->domain == G_IO_ERROR && error->code == G_IO_ERROR_CANCELLED)
return;
@@ -2283,11 +2377,15 @@ model_iterate_next_files_cb (GFileEnumerator * enumerator,
file_browser_node_unload (dir->model, (FileBrowserNode *)parent, TRUE);
g_error_free (error);
}
- } else if (g_cancellable_is_cancelled (async->cancellable)) {
+ }
+ else if (g_cancellable_is_cancelled (async->cancellable))
+ {
/* Check cancel state manually */
g_file_enumerator_close (enumerator, NULL, NULL);
async_node_free (async);
- } else {
+ }
+ else
+ {
model_add_nodes_from_files (dir->model, parent, async->original_children, files);
g_list_free (files);
@@ -2296,8 +2394,8 @@ model_iterate_next_files_cb (GFileEnumerator * enumerator,
}
static void
-next_files_async (GFileEnumerator * enumerator,
- AsyncNode * async)
+next_files_async (GFileEnumerator *enumerator,
+ AsyncNode *async)
{
g_file_enumerator_next_files_async (enumerator,
DIRECTORY_LOAD_ITEMS_PER_CALLBACK,
@@ -2308,12 +2406,12 @@ next_files_async (GFileEnumerator * enumerator,
}
static void
-model_iterate_children_cb (GFile * file,
- GAsyncResult * result,
- AsyncNode * async)
+model_iterate_children_cb (GFile *file,
+ GAsyncResult *result,
+ AsyncNode *async)
{
- GError * error = NULL;
- GFileEnumerator * enumerator;
+ GError *error = NULL;
+ GFileEnumerator *enumerator;
if (g_cancellable_is_cancelled (async->cancellable))
{
@@ -2323,7 +2421,8 @@ model_iterate_children_cb (GFile * file,
enumerator = g_file_enumerate_children_finish (file, result, &error);
- if (enumerator == NULL) {
+ if (enumerator == NULL)
+ {
/* Simply return if we were cancelled or if the dir is not there */
FileBrowserNodeDir *dir = async->dir;
@@ -2337,14 +2436,16 @@ model_iterate_children_cb (GFile * file,
file_browser_node_unload (dir->model, (FileBrowserNode *)dir, TRUE);
g_error_free (error);
async_node_free (async);
- } else {
+ }
+ else
+ {
next_files_async (enumerator, async);
}
}
static void
-model_load_directory (GeditFileBrowserStore * model,
- FileBrowserNode * node)
+model_load_directory (GeditFileBrowserStore *model,
+ FileBrowserNode *node)
{
FileBrowserNodeDir *dir;
AsyncNode *async;
@@ -2354,9 +2455,8 @@ model_load_directory (GeditFileBrowserStore * model,
dir = FILE_BROWSER_NODE_DIR (node);
/* Cancel a previous load */
- if (dir->cancellable != NULL) {
+ if (dir->cancellable != NULL)
file_browser_node_unload (dir->model, node, TRUE);
- }
node->flags |= GEDIT_FILE_BROWSER_STORE_FLAG_LOADED;
model_begin_loading (model, node);
@@ -2382,14 +2482,17 @@ model_load_directory (GeditFileBrowserStore * model,
}
static GList *
-get_parent_files (GeditFileBrowserStore * model, GFile * file)
+get_parent_files (GeditFileBrowserStore *model,
+ GFile *file)
{
- GList * result = NULL;
+ GList *result = NULL;
result = g_list_prepend (result, g_object_ref (file));
- while ((file = g_file_get_parent (file))) {
- if (g_file_equal (file, model->priv->root->file)) {
+ while ((file = g_file_get_parent (file)))
+ {
+ if (g_file_equal (file, model->priv->root->file))
+ {
g_object_unref (file);
break;
}
@@ -2401,49 +2504,55 @@ get_parent_files (GeditFileBrowserStore * model, GFile * file)
}
static void
-model_fill (GeditFileBrowserStore * model, FileBrowserNode * node,
- GtkTreePath ** path)
+model_fill (GeditFileBrowserStore *model,
+ FileBrowserNode *node,
+ GtkTreePath **path)
{
gboolean free_path = FALSE;
GtkTreeIter iter = {0,};
GSList *item;
FileBrowserNode *child;
- if (node == NULL) {
+ if (node == NULL)
+ {
node = model->priv->virtual_root;
*path = gtk_tree_path_new ();
free_path = TRUE;
}
- if (*path == NULL) {
- *path =
- gedit_file_browser_store_get_path_real (model, node);
+ if (*path == NULL)
+ {
+ *path = gedit_file_browser_store_get_path_real (model, node);
free_path = TRUE;
}
- if (!model_node_visibility (model, node)) {
+ if (!model_node_visibility (model, node))
+ {
if (free_path)
gtk_tree_path_free (*path);
return;
}
- if (node != model->priv->virtual_root) {
+ if (node != model->priv->virtual_root)
+ {
/* Insert node */
iter.user_data = node;
-
row_inserted(model, path, &iter);
}
- if (NODE_IS_DIR (node)) {
+ if (NODE_IS_DIR (node))
+ {
/* Go to the first child */
gtk_tree_path_down (*path);
for (item = FILE_BROWSER_NODE_DIR (node)->children; item;
- item = item->next) {
+ item = item->next)
+ {
child = (FileBrowserNode *) (item->data);
- if (model_node_visibility (model, child)) {
+ if (model_node_visibility (model, child))
+ {
model_fill (model, child, path);
/* Increase path for next child */
@@ -2462,8 +2571,8 @@ model_fill (GeditFileBrowserStore * model, FileBrowserNode * node,
}
static void
-set_virtual_root_from_node (GeditFileBrowserStore * model,
- FileBrowserNode * node)
+set_virtual_root_from_node (GeditFileBrowserStore *model,
+ FileBrowserNode *node)
{
FileBrowserNode *next;
FileBrowserNode *prev;
@@ -2477,23 +2586,28 @@ set_virtual_root_from_node (GeditFileBrowserStore * model,
next = prev->parent;
/* Free all the nodes below that we don't need in cache */
- while (prev != model->priv->root) {
+ while (prev != model->priv->root)
+ {
dir = FILE_BROWSER_NODE_DIR (next);
copy = g_slist_copy (dir->children);
- for (item = copy; item; item = item->next) {
+ for (item = copy; item; item = item->next)
+ {
check = (FileBrowserNode *) (item->data);
- if (prev == node) {
+ if (prev == node)
+ {
/* Only free the children, keeping this depth in cache */
- if (check != node) {
- file_browser_node_free_children
- (model, check);
+ if (check != node)
+ {
+ file_browser_node_free_children (model, check);
file_browser_node_unload (model,
check,
FALSE);
}
- } else if (check != prev) {
+ }
+ else if (check != prev)
+ {
/* Only free when the node is not in the chain */
dir->children =
g_slist_remove (dir->children, check);
@@ -2511,26 +2625,25 @@ set_virtual_root_from_node (GeditFileBrowserStore * model,
/* Free all the nodes up that we don't need in cache */
for (item = FILE_BROWSER_NODE_DIR (node)->children; item;
- item = item->next) {
+ item = item->next)
+ {
check = (FileBrowserNode *) (item->data);
- if (NODE_IS_DIR (check)) {
- for (copy =
- FILE_BROWSER_NODE_DIR (check)->children; copy;
- copy = copy->next) {
+ if (NODE_IS_DIR (check))
+ {
+ for (copy = FILE_BROWSER_NODE_DIR (check)->children;
+ copy; copy = copy->next)
+ {
file_browser_node_free_children (model,
- (FileBrowserNode
- *)
- (copy->
- data));
+ (FileBrowserNode*) (copy->data));
file_browser_node_unload (model,
- (FileBrowserNode
- *) (copy->data),
+ (FileBrowserNode*) (copy->data),
FALSE);
}
- } else if (NODE_IS_DUMMY (check)) {
- check->flags |=
- GEDIT_FILE_BROWSER_STORE_FLAG_IS_HIDDEN;
+ }
+ else if (NODE_IS_DUMMY (check))
+ {
+ check->flags |= GEDIT_FILE_BROWSER_STORE_FLAG_IS_HIDDEN;
}
}
@@ -2548,13 +2661,13 @@ set_virtual_root_from_node (GeditFileBrowserStore * model,
}
static void
-set_virtual_root_from_file (GeditFileBrowserStore * model,
- GFile * file)
+set_virtual_root_from_file (GeditFileBrowserStore *model,
+ GFile *file)
{
- GList * files;
- GList * item;
- FileBrowserNode * parent;
- GFile * check;
+ GList *files;
+ GList *item;
+ FileBrowserNode *parent;
+ GFile *check;
/* Always clear the model before altering the nodes */
model_clear (model, FALSE);
@@ -2563,7 +2676,8 @@ set_virtual_root_from_file (GeditFileBrowserStore * model,
files = get_parent_files (model, file);
parent = model->priv->root;
- for (item = files; item; item = item->next) {
+ for (item = files; item; item = item->next)
+ {
check = G_FILE (item->data);
parent = model_add_node_from_dir (model, parent, check);
@@ -2575,9 +2689,9 @@ set_virtual_root_from_file (GeditFileBrowserStore * model,
}
static FileBrowserNode *
-model_find_node_children (GeditFileBrowserStore * model,
- FileBrowserNode * parent,
- GFile * file)
+model_find_node_children (GeditFileBrowserStore *model,
+ FileBrowserNode *parent,
+ GFile *file)
{
FileBrowserNodeDir *dir;
FileBrowserNode *child;
@@ -2589,7 +2703,8 @@ model_find_node_children (GeditFileBrowserStore * model,
dir = FILE_BROWSER_NODE_DIR (parent);
- for (children = dir->children; children; children = children->next) {
+ for (children = dir->children; children; children = children->next)
+ {
child = (FileBrowserNode *)(children->data);
result = model_find_node (model, child, file);
@@ -2602,9 +2717,9 @@ model_find_node_children (GeditFileBrowserStore * model,
}
static FileBrowserNode *
-model_find_node (GeditFileBrowserStore * model,
- FileBrowserNode * node,
- GFile * file)
+model_find_node (GeditFileBrowserStore *model,
+ FileBrowserNode *node,
+ GFile *file)
{
if (node == NULL)
node = model->priv->root;
@@ -2623,21 +2738,22 @@ gedit_file_browser_store_error_quark (void)
{
static GQuark quark = 0;
- if (G_UNLIKELY (quark == 0)) {
+ if (G_UNLIKELY (quark == 0))
quark = g_quark_from_string ("gedit_file_browser_store_error");
- }
return quark;
}
static GFile *
-unique_new_name (GFile * directory, gchar const * name)
+unique_new_name (GFile *directory,
+ gchar const *name)
{
- GFile * newuri = NULL;
+ GFile *newuri = NULL;
guint num = 0;
- gchar * newname;
+ gchar *newname;
- while (newuri == NULL || g_file_query_exists (newuri, NULL)) {
+ while (newuri == NULL || g_file_query_exists (newuri, NULL))
+ {
if (newuri != NULL)
g_object_unref (newuri);
@@ -2656,15 +2772,15 @@ unique_new_name (GFile * directory, gchar const * name)
}
static GeditFileBrowserStoreResult
-model_root_mounted (GeditFileBrowserStore * model, GFile * virtual_root)
+model_root_mounted (GeditFileBrowserStore *model,
+ GFile *virtual_root)
{
model_check_dummy (model, model->priv->root);
g_object_notify (G_OBJECT (model), "root");
if (virtual_root != NULL)
- return
- gedit_file_browser_store_set_virtual_root_from_location
- (model, virtual_root);
+ return gedit_file_browser_store_set_virtual_root_from_location
+ (model, virtual_root);
else
set_virtual_root_from_node (model,
model->priv->root);
@@ -2673,9 +2789,10 @@ model_root_mounted (GeditFileBrowserStore * model, GFile * virtual_root)
}
static void
-handle_root_error (GeditFileBrowserStore * model, GError *error)
+handle_root_error (GeditFileBrowserStore *model,
+ GError *error)
{
- FileBrowserNode * root;
+ FileBrowserNode *root;
g_signal_emit (model,
model_signals[ERROR],
@@ -2698,13 +2815,13 @@ handle_root_error (GeditFileBrowserStore * model, GError *error)
}
static void
-mount_cb (GFile * file,
- GAsyncResult * res,
- MountInfo * mount_info)
+mount_cb (GFile *file,
+ GAsyncResult *res,
+ MountInfo *mount_info)
{
gboolean mounted;
- GError * error = NULL;
- GeditFileBrowserStore * model = mount_info->model;
+ GError *error = NULL;
+ GeditFileBrowserStore *model = mount_info->model;
mounted = g_file_mount_enclosing_volume_finish (file, res, &error);
@@ -2716,7 +2833,7 @@ mount_cb (GFile * file,
if (!mount_info->model || g_cancellable_is_cancelled (mount_info->cancellable))
{
- // Reset because it might be reused?
+ /* Reset because it might be reused? */
g_cancellable_reset (mount_info->cancellable);
}
else if (mounted)
@@ -2739,11 +2856,12 @@ mount_cb (GFile * file,
}
static GeditFileBrowserStoreResult
-model_mount_root (GeditFileBrowserStore * model, GFile * virtual_root)
+model_mount_root (GeditFileBrowserStore *model,
+ GFile *virtual_root)
{
- GFileInfo * info;
- GError * error = NULL;
- MountInfo * mount_info;
+ GFileInfo *info;
+ GError *error = NULL;
+ MountInfo *mount_info;
info = g_file_query_info (model->priv->root->file,
G_FILE_ATTRIBUTE_STANDARD_TYPE,
@@ -2751,8 +2869,10 @@ model_mount_root (GeditFileBrowserStore * model, GFile * virtual_root)
NULL,
&error);
- if (!info) {
- if (error->code == G_IO_ERROR_NOT_MOUNTED) {
+ if (!info)
+ {
+ if (error->code == G_IO_ERROR_NOT_MOUNTED)
+ {
/* Try to mount it */
FILE_BROWSER_NODE_DIR (model->priv->root)->cancellable = g_cancellable_new ();
@@ -2781,7 +2901,9 @@ model_mount_root (GeditFileBrowserStore * model, GFile * virtual_root)
}
g_error_free (error);
- } else {
+ }
+ else
+ {
g_object_unref (info);
return model_root_mounted (model, virtual_root);
@@ -2804,17 +2926,17 @@ gedit_file_browser_store_new (GFile *root)
}
void
-gedit_file_browser_store_set_value (GeditFileBrowserStore * tree_model,
- GtkTreeIter * iter, gint column,
- GValue * value)
+gedit_file_browser_store_set_value (GeditFileBrowserStore *tree_model,
+ GtkTreeIter *iter,
+ gint column,
+ GValue *value)
{
gpointer data;
FileBrowserNode *node;
GtkTreePath *path;
g_return_if_fail (GEDIT_IS_FILE_BROWSER_STORE (tree_model));
- g_return_if_fail (column ==
- GEDIT_FILE_BROWSER_STORE_COLUMN_EMBLEM);
+ g_return_if_fail (column == GEDIT_FILE_BROWSER_STORE_COLUMN_EMBLEM);
g_return_if_fail (G_VALUE_HOLDS_OBJECT (value));
g_return_if_fail (iter != NULL);
g_return_if_fail (iter->user_data != NULL);
@@ -2836,7 +2958,8 @@ gedit_file_browser_store_set_value (GeditFileBrowserStore * tree_model,
model_recomposite_icon (tree_model, iter);
- if (model_node_visibility (tree_model, node)) {
+ if (model_node_visibility (tree_model, node))
+ {
path = gedit_file_browser_store_get_path (GTK_TREE_MODEL (tree_model),
iter);
row_changed (tree_model, &path, iter);
@@ -2845,8 +2968,8 @@ gedit_file_browser_store_set_value (GeditFileBrowserStore * tree_model,
}
GeditFileBrowserStoreResult
-gedit_file_browser_store_set_virtual_root (GeditFileBrowserStore * model,
- GtkTreeIter * iter)
+gedit_file_browser_store_set_virtual_root (GeditFileBrowserStore *model,
+ GtkTreeIter *iter)
{
g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_STORE (model),
GEDIT_FILE_BROWSER_STORE_RESULT_NO_CHANGE);
@@ -2863,13 +2986,14 @@ gedit_file_browser_store_set_virtual_root (GeditFileBrowserStore * model,
}
GeditFileBrowserStoreResult
-gedit_file_browser_store_set_virtual_root_from_location
- (GeditFileBrowserStore * model, GFile *root) {
-
+gedit_file_browser_store_set_virtual_root_from_location (GeditFileBrowserStore *model,
+ GFile *root)
+{
g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_STORE (model),
GEDIT_FILE_BROWSER_STORE_RESULT_NO_CHANGE);
- if (root == NULL) {
+ if (root == NULL)
+ {
gchar *uri;
uri = g_file_get_uri (root);
@@ -2880,28 +3004,29 @@ gedit_file_browser_store_set_virtual_root_from_location
/* Check if uri is already the virtual root */
if (model->priv->virtual_root &&
- g_file_equal (model->priv->virtual_root->file, root)) {
+ g_file_equal (model->priv->virtual_root->file, root))
+ {
return GEDIT_FILE_BROWSER_STORE_RESULT_NO_CHANGE;
}
/* Check if uri is the root itself */
- if (g_file_equal (model->priv->root->file, root)) {
-
+ if (g_file_equal (model->priv->root->file, root))
+ {
/* Always clear the model before altering the nodes */
model_clear (model, FALSE);
set_virtual_root_from_node (model, model->priv->root);
return GEDIT_FILE_BROWSER_STORE_RESULT_OK;
}
- if (!g_file_has_prefix (root, model->priv->root->file)) {
+ if (!g_file_has_prefix (root, model->priv->root->file))
+ {
gchar *str, *str1;
str = g_file_get_parse_name (model->priv->root->file);
str1 = g_file_get_parse_name (root);
- g_warning
- ("Virtual root (%s) is not below actual root (%s)",
- str1, str);
+ g_warning ("Virtual root (%s) is not below actual root (%s)",
+ str1, str);
g_free (str);
g_free (str1);
@@ -2915,8 +3040,7 @@ gedit_file_browser_store_set_virtual_root_from_location
}
GeditFileBrowserStoreResult
-gedit_file_browser_store_set_virtual_root_top (GeditFileBrowserStore *
- model)
+gedit_file_browser_store_set_virtual_root_top (GeditFileBrowserStore *model)
{
g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_STORE (model),
GEDIT_FILE_BROWSER_STORE_RESULT_NO_CHANGE);
@@ -2931,8 +3055,7 @@ gedit_file_browser_store_set_virtual_root_top (GeditFileBrowserStore *
}
GeditFileBrowserStoreResult
-gedit_file_browser_store_set_virtual_root_up (GeditFileBrowserStore *
- model)
+gedit_file_browser_store_set_virtual_root_up (GeditFileBrowserStore *model)
{
g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_STORE (model),
GEDIT_FILE_BROWSER_STORE_RESULT_NO_CHANGE);
@@ -2948,8 +3071,8 @@ gedit_file_browser_store_set_virtual_root_up (GeditFileBrowserStore *
}
gboolean
-gedit_file_browser_store_get_iter_virtual_root (GeditFileBrowserStore *
- model, GtkTreeIter * iter)
+gedit_file_browser_store_get_iter_virtual_root (GeditFileBrowserStore *model,
+ GtkTreeIter *iter)
{
g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_STORE (model), FALSE);
g_return_val_if_fail (iter != NULL, FALSE);
@@ -2962,8 +3085,8 @@ gedit_file_browser_store_get_iter_virtual_root (GeditFileBrowserStore *
}
gboolean
-gedit_file_browser_store_get_iter_root (GeditFileBrowserStore * model,
- GtkTreeIter * iter)
+gedit_file_browser_store_get_iter_root (GeditFileBrowserStore *model,
+ GtkTreeIter *iter)
{
g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_STORE (model), FALSE);
g_return_val_if_fail (iter != NULL, FALSE);
@@ -2976,9 +3099,9 @@ gedit_file_browser_store_get_iter_root (GeditFileBrowserStore * model,
}
gboolean
-gedit_file_browser_store_iter_equal (GeditFileBrowserStore * model,
- GtkTreeIter * iter1,
- GtkTreeIter * iter2)
+gedit_file_browser_store_iter_equal (GeditFileBrowserStore *model,
+ GtkTreeIter *iter1,
+ GtkTreeIter *iter2)
{
g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_STORE (model), FALSE);
g_return_val_if_fail (iter1 != NULL, FALSE);
@@ -2998,12 +3121,11 @@ gedit_file_browser_store_cancel_mount_operation (GeditFileBrowserStore *store)
}
GeditFileBrowserStoreResult
-gedit_file_browser_store_set_root_and_virtual_root (GeditFileBrowserStore *
- model,
- GFile *root,
- GFile *virtual_root)
+gedit_file_browser_store_set_root_and_virtual_root (GeditFileBrowserStore *model,
+ GFile *root,
+ GFile *virtual_root)
{
- FileBrowserNode * node;
+ FileBrowserNode *node;
gboolean equal = FALSE;
g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_STORE (model),
@@ -3012,7 +3134,8 @@ gedit_file_browser_store_set_root_and_virtual_root (GeditFileBrowserStore *
if (root == NULL && model->priv->root == NULL)
return GEDIT_FILE_BROWSER_STORE_RESULT_NO_CHANGE;
- if (root != NULL && model->priv->root != NULL) {
+ if (root != NULL && model->priv->root != NULL)
+ {
equal = g_file_equal (root, model->priv->root->file);
if (equal && virtual_root == NULL) {
@@ -3020,13 +3143,15 @@ gedit_file_browser_store_set_root_and_virtual_root (GeditFileBrowserStore *
}
}
- if (virtual_root) {
- if (equal && g_file_equal (virtual_root, model->priv->virtual_root->file)) {
+ if (virtual_root)
+ {
+ if (equal && g_file_equal (virtual_root, model->priv->virtual_root->file))
+ {
return GEDIT_FILE_BROWSER_STORE_RESULT_NO_CHANGE;
}
}
- /* make sure to cancel any previous mount operations */
+ /* Make sure to cancel any previous mount operations */
cancel_mount_operation (model);
/* Always clear the model before altering the nodes */
@@ -3036,13 +3161,16 @@ gedit_file_browser_store_set_root_and_virtual_root (GeditFileBrowserStore *
model->priv->root = NULL;
model->priv->virtual_root = NULL;
- if (root != NULL) {
+ if (root != NULL)
+ {
/* Create the root node */
node = file_browser_node_dir_new (model, root, NULL);
model->priv->root = node;
return model_mount_root (model, virtual_root);
- } else {
+ }
+ else
+ {
g_object_notify (G_OBJECT (model), "root");
g_object_notify (G_OBJECT (model), "virtual-root");
}
@@ -3051,8 +3179,8 @@ gedit_file_browser_store_set_root_and_virtual_root (GeditFileBrowserStore *
}
GeditFileBrowserStoreResult
-gedit_file_browser_store_set_root (GeditFileBrowserStore * model,
- GFile *root)
+gedit_file_browser_store_set_root (GeditFileBrowserStore *model,
+ GFile *root)
{
g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_STORE (model),
GEDIT_FILE_BROWSER_STORE_RESULT_NO_CHANGE);
@@ -3062,7 +3190,7 @@ gedit_file_browser_store_set_root (GeditFileBrowserStore * model,
}
GFile *
-gedit_file_browser_store_get_root (GeditFileBrowserStore * model)
+gedit_file_browser_store_get_root (GeditFileBrowserStore *model)
{
g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_STORE (model), NULL);
@@ -3073,7 +3201,7 @@ gedit_file_browser_store_get_root (GeditFileBrowserStore * model)
}
GFile *
-gedit_file_browser_store_get_virtual_root (GeditFileBrowserStore * model)
+gedit_file_browser_store_get_virtual_root (GeditFileBrowserStore *model)
{
g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_STORE (model), NULL);
@@ -3084,8 +3212,8 @@ gedit_file_browser_store_get_virtual_root (GeditFileBrowserStore * model)
}
void
-_gedit_file_browser_store_iter_expanded (GeditFileBrowserStore * model,
- GtkTreeIter * iter)
+_gedit_file_browser_store_iter_expanded (GeditFileBrowserStore *model,
+ GtkTreeIter *iter)
{
FileBrowserNode *node;
@@ -3095,15 +3223,14 @@ _gedit_file_browser_store_iter_expanded (GeditFileBrowserStore * model,
node = (FileBrowserNode *) (iter->user_data);
- if (NODE_IS_DIR (node) && !NODE_LOADED (node)) {
+ if (NODE_IS_DIR (node) && !NODE_LOADED (node))
/* Load it now */
model_load_directory (model, node);
- }
}
void
-_gedit_file_browser_store_iter_collapsed (GeditFileBrowserStore * model,
- GtkTreeIter * iter)
+_gedit_file_browser_store_iter_collapsed (GeditFileBrowserStore *model,
+ GtkTreeIter *iter)
{
FileBrowserNode *node;
GSList *item;
@@ -3114,14 +3241,16 @@ _gedit_file_browser_store_iter_collapsed (GeditFileBrowserStore * model,
node = (FileBrowserNode *) (iter->user_data);
- if (NODE_IS_DIR (node) && NODE_LOADED (node)) {
+ if (NODE_IS_DIR (node) && NODE_LOADED (node))
+ {
/* Unload children of the children, keeping 1 depth in cache */
- for (item = FILE_BROWSER_NODE_DIR (node)->children; item;
- item = item->next) {
+ for (item = FILE_BROWSER_NODE_DIR (node)->children; item; item = item->next)
+ {
node = (FileBrowserNode *) (item->data);
- if (NODE_IS_DIR (node) && NODE_LOADED (node)) {
+ if (NODE_IS_DIR (node) && NODE_LOADED (node))
+ {
file_browser_node_unload (model, node,
TRUE);
model_check_dummy (model, node);
@@ -3131,15 +3260,14 @@ _gedit_file_browser_store_iter_collapsed (GeditFileBrowserStore * model,
}
GeditFileBrowserStoreFilterMode
-gedit_file_browser_store_get_filter_mode (GeditFileBrowserStore * model)
+gedit_file_browser_store_get_filter_mode (GeditFileBrowserStore *model)
{
return model->priv->filter_mode;
}
void
-gedit_file_browser_store_set_filter_mode (GeditFileBrowserStore * model,
- GeditFileBrowserStoreFilterMode
- mode)
+gedit_file_browser_store_set_filter_mode (GeditFileBrowserStore *model,
+ GeditFileBrowserStoreFilterMode mode)
{
g_return_if_fail (GEDIT_IS_FILE_BROWSER_STORE (model));
@@ -3153,9 +3281,9 @@ gedit_file_browser_store_set_filter_mode (GeditFileBrowserStore * model,
}
void
-gedit_file_browser_store_set_filter_func (GeditFileBrowserStore * model,
- GeditFileBrowserStoreFilterFunc
- func, gpointer user_data)
+gedit_file_browser_store_set_filter_func (GeditFileBrowserStore *model,
+ GeditFileBrowserStoreFilterFunc func,
+ gpointer user_data)
{
g_return_if_fail (GEDIT_IS_FILE_BROWSER_STORE (model));
@@ -3165,7 +3293,7 @@ gedit_file_browser_store_set_filter_func (GeditFileBrowserStore * model,
}
void
-gedit_file_browser_store_refilter (GeditFileBrowserStore * model)
+gedit_file_browser_store_refilter (GeditFileBrowserStore *model)
{
model_refilter (model);
}
@@ -3177,7 +3305,7 @@ gedit_file_browser_store_filter_mode_get_default (void)
}
void
-gedit_file_browser_store_refresh (GeditFileBrowserStore * model)
+gedit_file_browser_store_refresh (GeditFileBrowserStore *model)
{
g_return_if_fail (GEDIT_IS_FILE_BROWSER_STORE (model));
@@ -3192,18 +3320,19 @@ gedit_file_browser_store_refresh (GeditFileBrowserStore * model)
}
static void
-reparent_node (FileBrowserNode * node, gboolean reparent)
+reparent_node (FileBrowserNode *node,
+ gboolean reparent)
{
- FileBrowserNodeDir * dir;
- GSList * child;
- GFile * parent;
- gchar * base;
+ FileBrowserNodeDir *dir;
+ GSList *child;
+ GFile *parent;
+ gchar *base;
- if (!node->file) {
+ if (!node->file)
return;
- }
- if (reparent) {
+ if (reparent)
+ {
parent = node->parent->file;
base = g_file_get_basename (node->file);
g_object_unref (node->file);
@@ -3212,26 +3341,26 @@ reparent_node (FileBrowserNode * node, gboolean reparent)
g_free (base);
}
- if (NODE_IS_DIR (node)) {
+ if (NODE_IS_DIR (node))
+ {
dir = FILE_BROWSER_NODE_DIR (node);
- for (child = dir->children; child; child = child->next) {
+ for (child = dir->children; child; child = child->next)
reparent_node ((FileBrowserNode *)child->data, TRUE);
- }
}
}
gboolean
-gedit_file_browser_store_rename (GeditFileBrowserStore * model,
- GtkTreeIter * iter,
- const gchar * new_name,
- GError ** error)
+gedit_file_browser_store_rename (GeditFileBrowserStore *model,
+ GtkTreeIter *iter,
+ const gchar *new_name,
+ GError **error)
{
FileBrowserNode *node;
- GFile * file;
- GFile * parent;
- GFile * previous;
- GError * err = NULL;
+ GFile *file;
+ GFile *parent;
+ GFile *previous;
+ GError *err = NULL;
GtkTreePath *path;
g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_STORE (model), FALSE);
@@ -3246,12 +3375,14 @@ gedit_file_browser_store_rename (GeditFileBrowserStore * model,
file = g_file_get_child (parent, new_name);
g_object_unref (parent);
- if (g_file_equal (node->file, file)) {
+ if (g_file_equal (node->file, file))
+ {
g_object_unref (file);
return TRUE;
}
- if (g_file_move (node->file, file, G_FILE_COPY_NONE, NULL, NULL, NULL, &err)) {
+ if (g_file_move (node->file, file, G_FILE_COPY_NONE, NULL, NULL, NULL, &err))
+ {
previous = node->file;
node->file = file;
@@ -3261,20 +3392,25 @@ gedit_file_browser_store_rename (GeditFileBrowserStore * model,
reparent_node (node, FALSE);
- if (model_node_visibility (model, node)) {
+ if (model_node_visibility (model, node))
+ {
path = gedit_file_browser_store_get_path_real (model, node);
row_changed (model, &path, iter);
gtk_tree_path_free (path);
/* Reorder this item */
model_resort_node (model, node);
- } else {
+ }
+ else
+ {
g_object_unref (previous);
if (error != NULL)
*error = g_error_new_literal (gedit_file_browser_store_error_quark (),
GEDIT_FILE_BROWSER_ERROR_RENAME,
- _("The renamed file is currently filtered out. You need to adjust your filter settings to make the file visible"));
+ _("The renamed file is currently filtered out."
+ "You need to adjust your filter settings to "
+ "make the file visible"));
return FALSE;
}
@@ -3283,16 +3419,19 @@ gedit_file_browser_store_rename (GeditFileBrowserStore * model,
g_object_unref (previous);
return TRUE;
- } else {
+ }
+ else
+ {
g_object_unref (file);
- if (err) {
- if (error != NULL) {
- *error =
- g_error_new_literal
- (gedit_file_browser_store_error_quark (),
- GEDIT_FILE_BROWSER_ERROR_RENAME,
- err->message);
+ if (err)
+ {
+ if (error != NULL)
+ {
+ *error = g_error_new_literal
+ (gedit_file_browser_store_error_quark (),
+ GEDIT_FILE_BROWSER_ERROR_RENAME,
+ err->message);
}
g_error_free (err);
@@ -3303,7 +3442,7 @@ gedit_file_browser_store_rename (GeditFileBrowserStore * model,
}
static void
-async_data_free (AsyncData * data)
+async_data_free (AsyncData *data)
{
g_object_unref (data->cancellable);
@@ -3317,7 +3456,7 @@ async_data_free (AsyncData * data)
}
static gboolean
-emit_no_trash (AsyncData * data)
+emit_no_trash (AsyncData *data)
{
/* Emit the no trash error */
gboolean ret;
@@ -3327,14 +3466,14 @@ emit_no_trash (AsyncData * data)
}
typedef struct {
- GeditFileBrowserStore * model;
- GFile * file;
+ GeditFileBrowserStore *model;
+ GFile *file;
} IdleDelete;
static gboolean
-file_deleted (IdleDelete * data)
+file_deleted (IdleDelete *data)
{
- FileBrowserNode * node;
+ FileBrowserNode *node;
node = model_find_node (data->model, NULL, data->file);
if (node != NULL)
@@ -3344,12 +3483,12 @@ file_deleted (IdleDelete * data)
}
static gboolean
-delete_files (GIOSchedulerJob * job,
- GCancellable * cancellable,
- AsyncData * data)
+delete_files (GIOSchedulerJob *job,
+ GCancellable *cancellable,
+ AsyncData *data)
{
- GFile * file;
- GError * error = NULL;
+ GFile *file;
+ GError *error = NULL;
gboolean ret;
gint code;
IdleDelete delete;
@@ -3366,17 +3505,21 @@ delete_files (GIOSchedulerJob * job,
else
ret = g_file_delete (file, cancellable, &error);
- if (ret) {
+ if (ret)
+ {
delete.model = data->model;
delete.file = file;
/* Remove the file from the model in the main loop */
g_io_scheduler_job_send_to_mainloop (job, (GSourceFunc)file_deleted, &delete, NULL);
- } else if (!ret && error) {
+ }
+ else if (!ret && error)
+ {
code = error->code;
g_error_free (error);
- if (data->trash && code == G_IO_ERROR_NOT_SUPPORTED) {
+ if (data->trash && code == G_IO_ERROR_NOT_SUPPORTED)
+ {
/* Trash is not supported on this system ... */
if (g_io_scheduler_job_send_to_mainloop (job, (GSourceFunc)emit_no_trash, data, NULL))
{
@@ -3389,7 +3532,9 @@ delete_files (GIOSchedulerJob * job,
/* End the job */
return FALSE;
- } else if (code == G_IO_ERROR_CANCELLED) {
+ }
+ else if (code == G_IO_ERROR_CANCELLED)
+ {
/* Job has been cancelled, just let the job end */
return FALSE;
}
@@ -3402,15 +3547,16 @@ delete_files (GIOSchedulerJob * job,
GeditFileBrowserStoreResult
gedit_file_browser_store_delete_all (GeditFileBrowserStore *model,
- GList *rows, gboolean trash)
+ GList *rows,
+ gboolean trash)
{
- FileBrowserNode * node;
- AsyncData * data;
- GList * files = NULL;
- GList * row;
+ FileBrowserNode *node;
+ AsyncData *data;
+ GList *files = NULL;
+ GList *row;
GtkTreeIter iter;
- GtkTreePath * prev = NULL;
- GtkTreePath * path;
+ GtkTreePath *prev = NULL;
+ GtkTreePath *path;
g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_STORE (model), GEDIT_FILE_BROWSER_STORE_RESULT_NO_CHANGE);
@@ -3422,7 +3568,8 @@ gedit_file_browser_store_delete_all (GeditFileBrowserStore *model,
a directory that's also deleted */
rows = g_list_sort (g_list_copy (rows), (GCompareFunc)gtk_tree_path_compare);
- for (row = rows; row; row = row->next) {
+ for (row = rows; row; row = row->next)
+ {
path = (GtkTreePath *)(row->data);
if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, path))
@@ -3447,8 +3594,7 @@ gedit_file_browser_store_delete_all (GeditFileBrowserStore *model,
data->iter = files;
data->removed = FALSE;
- model->priv->async_handles =
- g_slist_prepend (model->priv->async_handles, data);
+ model->priv->async_handles = g_slist_prepend (model->priv->async_handles, data);
g_io_scheduler_push_job ((GIOSchedulerJobFunc)delete_files,
data,
@@ -3461,8 +3607,9 @@ gedit_file_browser_store_delete_all (GeditFileBrowserStore *model,
}
GeditFileBrowserStoreResult
-gedit_file_browser_store_delete (GeditFileBrowserStore * model,
- GtkTreeIter * iter, gboolean trash)
+gedit_file_browser_store_delete (GeditFileBrowserStore *model,
+ GtkTreeIter *iter,
+ gboolean trash)
{
FileBrowserNode *node;
GList *rows = NULL;
@@ -3487,16 +3634,16 @@ gedit_file_browser_store_delete (GeditFileBrowserStore * model,
}
gboolean
-gedit_file_browser_store_new_file (GeditFileBrowserStore * model,
- GtkTreeIter * parent,
- GtkTreeIter * iter)
+gedit_file_browser_store_new_file (GeditFileBrowserStore *model,
+ GtkTreeIter *parent,
+ GtkTreeIter *iter)
{
- GFile * file;
- GFileOutputStream * stream;
+ GFile *file;
+ GFileOutputStream *stream;
FileBrowserNodeDir *parent_node;
gboolean result = FALSE;
FileBrowserNode *node;
- GError * error = NULL;
+ GError *error = NULL;
g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_STORE (model), FALSE);
g_return_val_if_fail (parent != NULL, FALSE);
@@ -3507,7 +3654,7 @@ gedit_file_browser_store_new_file (GeditFileBrowserStore * model,
g_return_val_if_fail (iter != NULL, FALSE);
parent_node = FILE_BROWSER_NODE_DIR (parent->user_data);
- /* Translators: This is the default name of new files created by the file browser pane. */
+ /*vTranslators: This is the default name of new files created by the file browser pane. */
file = unique_new_name (((FileBrowserNode *) parent_node)->file, _("file"));
stream = g_file_create (file, G_FILE_CREATE_NONE, NULL, &error);
@@ -3518,21 +3665,27 @@ gedit_file_browser_store_new_file (GeditFileBrowserStore * model,
GEDIT_FILE_BROWSER_ERROR_NEW_FILE,
error->message);
g_error_free (error);
- } else {
+ }
+ else
+ {
g_object_unref (stream);
node = model_add_node_from_file (model,
(FileBrowserNode *)parent_node,
file,
NULL);
- if (model_node_visibility (model, node)) {
+ if (model_node_visibility (model, node))
+ {
iter->user_data = node;
result = TRUE;
- } else {
+ }
+ else
+ {
g_signal_emit (model, model_signals[ERROR], 0,
GEDIT_FILE_BROWSER_ERROR_NEW_FILE,
- _
- ("The new file is currently filtered out. You need to adjust your filter settings to make the file visible"));
+ _("The new file is currently filtered out. "
+ "You need to adjust your filter "
+ "settings to make the file visible"));
}
}
@@ -3541,13 +3694,13 @@ gedit_file_browser_store_new_file (GeditFileBrowserStore * model,
}
gboolean
-gedit_file_browser_store_new_directory (GeditFileBrowserStore * model,
- GtkTreeIter * parent,
- GtkTreeIter * iter)
+gedit_file_browser_store_new_directory (GeditFileBrowserStore *model,
+ GtkTreeIter *parent,
+ GtkTreeIter *iter)
{
- GFile * file;
+ GFile *file;
FileBrowserNodeDir *parent_node;
- GError * error = NULL;
+ GError *error = NULL;
FileBrowserNode *node;
gboolean result = FALSE;
@@ -3563,30 +3716,35 @@ gedit_file_browser_store_new_directory (GeditFileBrowserStore * model,
/* Translators: This is the default name of new directories created by the file browser pane. */
file = unique_new_name (((FileBrowserNode *) parent_node)->file, _("directory"));
- if (!g_file_make_directory (file, NULL, &error)) {
+ if (!g_file_make_directory (file, NULL, &error))
+ {
g_signal_emit (model, model_signals[ERROR], 0,
GEDIT_FILE_BROWSER_ERROR_NEW_DIRECTORY,
error->message);
g_error_free (error);
- } else {
+ }
+ else
+ {
node = model_add_node_from_file (model,
(FileBrowserNode *)parent_node,
file,
NULL);
- if (model_node_visibility (model, node)) {
+ if (model_node_visibility (model, node))
+ {
iter->user_data = node;
result = TRUE;
- } else {
+ }
+ else
+ {
g_signal_emit (model, model_signals[ERROR], 0,
GEDIT_FILE_BROWSER_ERROR_NEW_FILE,
- _
- ("The new directory is currently filtered out. You need to adjust your filter settings to make the directory visible"));
+ _("The new directory is currently filtered "
+ "out. You need to adjust your filter "
+ "settings to make the directory visible"));
}
}
g_object_unref (file);
return result;
}
-
-// ex:ts=8:noet:
diff --git a/plugins/filebrowser/gedit-file-browser-store.h b/plugins/filebrowser/gedit-file-browser-store.h
index 635e72f..8c4bc6e 100644
--- a/plugins/filebrowser/gedit-file-browser-store.h
+++ b/plugins/filebrowser/gedit-file-browser-store.h
@@ -1,19 +1,19 @@
/*
* gedit-file-browser-store.h - Gedit plugin providing easy file access
* from the sidepanel
- *
+ *
* Copyright (C) 2006 - Jesse van den Kieboom <jesse icecrew nl>
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@@ -81,10 +81,9 @@ typedef struct _GeditFileBrowserStore GeditFileBrowserStore;
typedef struct _GeditFileBrowserStoreClass GeditFileBrowserStoreClass;
typedef struct _GeditFileBrowserStorePrivate GeditFileBrowserStorePrivate;
-typedef gboolean (*GeditFileBrowserStoreFilterFunc) (GeditFileBrowserStore
- * model,
- GtkTreeIter * iter,
- gpointer user_data);
+typedef gboolean (*GeditFileBrowserStoreFilterFunc) (GeditFileBrowserStore *model,
+ GtkTreeIter *iter,
+ gpointer user_data);
struct _GeditFileBrowserStore
{
@@ -97,104 +96,103 @@ 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);
};
-GType gedit_file_browser_store_get_type (void) G_GNUC_CONST;
-GType gedit_file_browser_store_register_type (GTypeModule * module);
+GType gedit_file_browser_store_get_type (void) G_GNUC_CONST;
+GType gedit_file_browser_store_register_type (GTypeModule *module);
-GeditFileBrowserStore *gedit_file_browser_store_new (GFile *root);
+GeditFileBrowserStore *gedit_file_browser_store_new (GFile *root);
GeditFileBrowserStoreResult
-gedit_file_browser_store_set_root_and_virtual_root (GeditFileBrowserStore * model,
- GFile *root,
- GFile *virtual_root);
+gedit_file_browser_store_set_root_and_virtual_root (GeditFileBrowserStore *model,
+ GFile *root,
+ GFile *virtual_root);
GeditFileBrowserStoreResult
-gedit_file_browser_store_set_root (GeditFileBrowserStore * model,
- GFile *root);
+gedit_file_browser_store_set_root (GeditFileBrowserStore *model,
+ GFile *root);
GeditFileBrowserStoreResult
-gedit_file_browser_store_set_virtual_root (GeditFileBrowserStore * model,
- GtkTreeIter * iter);
+gedit_file_browser_store_set_virtual_root (GeditFileBrowserStore *model,
+ GtkTreeIter *iter);
GeditFileBrowserStoreResult
-gedit_file_browser_store_set_virtual_root_from_location (GeditFileBrowserStore * model,
- GFile *root);
+gedit_file_browser_store_set_virtual_root_from_location (GeditFileBrowserStore *model,
+ GFile *root);
GeditFileBrowserStoreResult
-gedit_file_browser_store_set_virtual_root_up (GeditFileBrowserStore * model);
+gedit_file_browser_store_set_virtual_root_up (GeditFileBrowserStore *model);
GeditFileBrowserStoreResult
-gedit_file_browser_store_set_virtual_root_top (GeditFileBrowserStore * model);
-
-gboolean
-gedit_file_browser_store_get_iter_virtual_root (GeditFileBrowserStore * model,
- GtkTreeIter * iter);
-gboolean gedit_file_browser_store_get_iter_root (GeditFileBrowserStore * model,
- GtkTreeIter * iter);
-GFile * gedit_file_browser_store_get_root (GeditFileBrowserStore * model);
-GFile * gedit_file_browser_store_get_virtual_root (GeditFileBrowserStore * model);
-
-gboolean gedit_file_browser_store_iter_equal (GeditFileBrowserStore * model,
- GtkTreeIter * iter1,
- GtkTreeIter * iter2);
-
-void gedit_file_browser_store_set_value (GeditFileBrowserStore * tree_model,
- GtkTreeIter * iter,
- gint column,
- GValue * value);
-
-void _gedit_file_browser_store_iter_expanded (GeditFileBrowserStore * model,
- GtkTreeIter * iter);
-void _gedit_file_browser_store_iter_collapsed (GeditFileBrowserStore * model,
- GtkTreeIter * iter);
+gedit_file_browser_store_set_virtual_root_top (GeditFileBrowserStore *model);
+
+gboolean gedit_file_browser_store_get_iter_virtual_root (GeditFileBrowserStore *model,
+ GtkTreeIter *iter);
+gboolean gedit_file_browser_store_get_iter_root (GeditFileBrowserStore *model,
+ GtkTreeIter *iter);
+GFile *gedit_file_browser_store_get_root (GeditFileBrowserStore *model);
+GFile *gedit_file_browser_store_get_virtual_root (GeditFileBrowserStore *model);
+
+gboolean gedit_file_browser_store_iter_equal (GeditFileBrowserStore *model,
+ GtkTreeIter *iter1,
+ GtkTreeIter *iter2);
+
+void gedit_file_browser_store_set_value (GeditFileBrowserStore *tree_model,
+ GtkTreeIter *iter,
+ gint column,
+ GValue *value);
+
+void _gedit_file_browser_store_iter_expanded (GeditFileBrowserStore *model,
+ GtkTreeIter *iter);
+void _gedit_file_browser_store_iter_collapsed (GeditFileBrowserStore *model,
+ GtkTreeIter *iter);
GeditFileBrowserStoreFilterMode
-gedit_file_browser_store_get_filter_mode (GeditFileBrowserStore * model);
-void gedit_file_browser_store_set_filter_mode (GeditFileBrowserStore * model,
- GeditFileBrowserStoreFilterMode mode);
-void gedit_file_browser_store_set_filter_func (GeditFileBrowserStore * model,
- GeditFileBrowserStoreFilterFunc func,
- gpointer user_data);
-void gedit_file_browser_store_refilter (GeditFileBrowserStore * model);
+gedit_file_browser_store_get_filter_mode (GeditFileBrowserStore *model);
+void gedit_file_browser_store_set_filter_mode (GeditFileBrowserStore *model,
+ GeditFileBrowserStoreFilterMode mode);
+void gedit_file_browser_store_set_filter_func (GeditFileBrowserStore *model,
+ GeditFileBrowserStoreFilterFunc func,
+ gpointer user_data);
+void gedit_file_browser_store_refilter (GeditFileBrowserStore *model);
GeditFileBrowserStoreFilterMode
-gedit_file_browser_store_filter_mode_get_default (void);
+gedit_file_browser_store_filter_mode_get_default (void);
-void gedit_file_browser_store_refresh (GeditFileBrowserStore * model);
-gboolean gedit_file_browser_store_rename (GeditFileBrowserStore * model,
- GtkTreeIter * iter,
- gchar const *new_name,
- GError ** error);
+void gedit_file_browser_store_refresh (GeditFileBrowserStore *model);
+gboolean gedit_file_browser_store_rename (GeditFileBrowserStore *model,
+ GtkTreeIter *iter,
+ gchar const *new_name,
+ GError **error);
GeditFileBrowserStoreResult
-gedit_file_browser_store_delete (GeditFileBrowserStore * model,
- GtkTreeIter * iter,
- gboolean trash);
+gedit_file_browser_store_delete (GeditFileBrowserStore *model,
+ GtkTreeIter *iter,
+ gboolean trash);
GeditFileBrowserStoreResult
-gedit_file_browser_store_delete_all (GeditFileBrowserStore * model,
- GList *rows,
- gboolean trash);
+gedit_file_browser_store_delete_all (GeditFileBrowserStore *model,
+ GList *rows,
+ gboolean trash);
-gboolean gedit_file_browser_store_new_file (GeditFileBrowserStore * model,
- GtkTreeIter * parent,
- GtkTreeIter * iter);
-gboolean gedit_file_browser_store_new_directory (GeditFileBrowserStore * model,
- GtkTreeIter * parent,
- GtkTreeIter * iter);
+gboolean gedit_file_browser_store_new_file (GeditFileBrowserStore *model,
+ GtkTreeIter *parent,
+ GtkTreeIter *iter);
+gboolean gedit_file_browser_store_new_directory (GeditFileBrowserStore *model,
+ GtkTreeIter *parent,
+ GtkTreeIter *iter);
-void gedit_file_browser_store_cancel_mount_operation (GeditFileBrowserStore *store);
+void
+gedit_file_browser_store_cancel_mount_operation (GeditFileBrowserStore *store);
G_END_DECLS
-#endif /* __GEDIT_FILE_BROWSER_STORE_H__ */
-// ex:ts=8:noet:
+#endif /* __GEDIT_FILE_BROWSER_STORE_H__ */
diff --git a/plugins/filebrowser/gedit-file-browser-utils.c b/plugins/filebrowser/gedit-file-browser-utils.c
index 87e2e9d..d1f5851 100644
--- a/plugins/filebrowser/gedit-file-browser-utils.c
+++ b/plugins/filebrowser/gedit-file-browser-utils.c
@@ -1,19 +1,19 @@
/*
- * gedit-file-bookmarks-store.c - Gedit plugin providing easy file access
+ * gedit-file-bookmarks-utils.c - Gedit plugin providing easy file access
* from the sidepanel
- *
+ *
* Copyright (C) 2006 - Jesse van den Kieboom <jesse icecrew nl>
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@@ -23,21 +23,23 @@
#include <gedit/gedit-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) {
+ 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) {
+ if (pixbuf && gdk_pixbuf_get_width (pixbuf) > size)
+ {
scale = gdk_pixbuf_scale_simple (pixbuf,
size,
size,
@@ -50,8 +52,8 @@ process_icon_pixbuf (GdkPixbuf * pixbuf,
}
GdkPixbuf *
-gedit_file_browser_utils_pixbuf_from_theme (gchar const * name,
- GtkIconSize size)
+gedit_file_browser_utils_pixbuf_from_theme (gchar const *name,
+ GtkIconSize size)
{
gint width;
GError *error = NULL;
@@ -71,10 +73,10 @@ gedit_file_browser_utils_pixbuf_from_theme (gchar const * name,
}
GdkPixbuf *
-gedit_file_browser_utils_pixbuf_from_icon (GIcon * icon,
- GtkIconSize size)
+gedit_file_browser_utils_pixbuf_from_icon (GIcon *icon,
+ GtkIconSize size)
{
- GdkPixbuf * ret = NULL;
+ GdkPixbuf *ret = NULL;
GtkIconTheme *theme;
GtkIconInfo *info;
gint width;
@@ -100,12 +102,12 @@ gedit_file_browser_utils_pixbuf_from_icon (GIcon * icon,
}
GdkPixbuf *
-gedit_file_browser_utils_pixbuf_from_file (GFile * file,
- GtkIconSize size)
+gedit_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,
@@ -126,18 +128,18 @@ gedit_file_browser_utils_pixbuf_from_file (GFile * file,
}
gchar *
-gedit_file_browser_utils_file_basename (GFile * file)
+gedit_file_browser_utils_file_basename (GFile *file)
{
return gedit_utils_basename_for_display (file);
}
gboolean
-gedit_file_browser_utils_confirmation_dialog (GeditWindow * window,
- GtkMessageType type,
- gchar const *message,
- gchar const *secondary,
- gchar const * button_stock,
- gchar const * button_label)
+gedit_file_browser_utils_confirmation_dialog (GeditWindow *window,
+ GtkMessageType type,
+ gchar const *message,
+ gchar const *secondary,
+ gchar const *button_stock,
+ gchar const *button_label)
{
GtkWidget *dlg;
gint ret;
@@ -165,7 +167,8 @@ gedit_file_browser_utils_confirmation_dialog (GeditWindow * window,
/* Add custom button */
button = gtk_button_new_from_stock (button_stock);
- if (button_label) {
+ if (button_label)
+ {
gtk_button_set_use_stock (GTK_BUTTON (button), FALSE);
gtk_button_set_label (GTK_BUTTON (button), button_label);
}
@@ -181,5 +184,3 @@ gedit_file_browser_utils_confirmation_dialog (GeditWindow * window,
return (ret == GTK_RESPONSE_OK);
}
-
-// ex:ts=8:noet:
diff --git a/plugins/filebrowser/gedit-file-browser-utils.h b/plugins/filebrowser/gedit-file-browser-utils.h
index fa5c999..0499da4 100644
--- a/plugins/filebrowser/gedit-file-browser-utils.h
+++ b/plugins/filebrowser/gedit-file-browser-utils.h
@@ -1,26 +1,45 @@
+/*
+ * gedit-file-browser-utils.h - Gedit plugin providing easy file access
+ * from the sidepanel
+ *
+ * Copyright (C) 2006 - Jesse van den Kieboom <jesse icecrew nl>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
#ifndef __GEDIT_FILE_BROWSER_UTILS_H__
#define __GEDIT_FILE_BROWSER_UTILS_H__
#include <gedit/gedit-window.h>
#include <gio/gio.h>
-GdkPixbuf *gedit_file_browser_utils_pixbuf_from_theme (gchar const *name,
- GtkIconSize size);
+GdkPixbuf *gedit_file_browser_utils_pixbuf_from_theme (gchar const *name,
+ GtkIconSize size);
-GdkPixbuf *gedit_file_browser_utils_pixbuf_from_icon (GIcon * icon,
- GtkIconSize size);
-GdkPixbuf *gedit_file_browser_utils_pixbuf_from_file (GFile * file,
- GtkIconSize size);
+GdkPixbuf *gedit_file_browser_utils_pixbuf_from_icon (GIcon *icon,
+ GtkIconSize size);
+GdkPixbuf *gedit_file_browser_utils_pixbuf_from_file (GFile *file,
+ GtkIconSize size);
-gchar * gedit_file_browser_utils_file_basename (GFile * file);
+gchar *gedit_file_browser_utils_file_basename (GFile *file);
-gboolean gedit_file_browser_utils_confirmation_dialog (GeditWindow * window,
- GtkMessageType type,
- gchar const *message,
- gchar const *secondary,
- gchar const * button_stock,
- gchar const * button_label);
+gboolean gedit_file_browser_utils_confirmation_dialog (GeditWindow *window,
+ GtkMessageType type,
+ gchar const *message,
+ gchar const *secondary,
+ gchar const *button_stock,
+ gchar const *button_label);
#endif /* __GEDIT_FILE_BROWSER_UTILS_H__ */
-
-// ex:ts=8:noet:
diff --git a/plugins/filebrowser/gedit-file-browser-view.c b/plugins/filebrowser/gedit-file-browser-view.c
index 4aa8dcf..4a985e4 100644
--- a/plugins/filebrowser/gedit-file-browser-view.c
+++ b/plugins/filebrowser/gedit-file-browser-view.c
@@ -1,19 +1,19 @@
/*
* gedit-file-browser-view.c - Gedit plugin providing easy file access
* from the sidepanel
- *
+ *
* Copyright (C) 2006 - Jesse van den Kieboom <jesse icecrew nl>
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@@ -45,9 +45,10 @@ struct _GeditFileBrowserViewPrivate
GdkCursor *busy_cursor;
- /* CLick policy */
+ /* Click policy */
GeditFileBrowserViewClickPolicy click_policy;
- GtkTreePath *double_click_path[2]; /* Both clicks in a double click need to be on the same row */
+ /* Both clicks in a double click need to be on the same row */
+ GtkTreePath *double_click_path[2];
GtkTreePath *hover_path;
GdkCursor *hand_cursor;
gboolean ignore_release;
@@ -57,7 +58,7 @@ struct _GeditFileBrowserViewPrivate
gboolean restore_expand_state;
gboolean is_refresh;
- GHashTable * expand_state;
+ GHashTable *expand_state;
};
/* Properties */
@@ -88,32 +89,32 @@ static const GtkTargetEntry drag_source_targets[] = {
GEDIT_PLUGIN_DEFINE_TYPE (GeditFileBrowserView, gedit_file_browser_view,
GTK_TYPE_TREE_VIEW)
-static void on_cell_edited (GtkCellRendererText * cell,
- gchar * path,
- gchar * new_text,
- GeditFileBrowserView * tree_view);
+static void on_cell_edited (GtkCellRendererText *cell,
+ gchar *path,
+ gchar *new_text,
+ GeditFileBrowserView *tree_view);
-static void on_begin_refresh (GeditFileBrowserStore * model,
- GeditFileBrowserView * view);
-static void on_end_refresh (GeditFileBrowserStore * model,
- GeditFileBrowserView * view);
+static void on_begin_refresh (GeditFileBrowserStore *model,
+ GeditFileBrowserView *view);
+static void on_end_refresh (GeditFileBrowserStore *model,
+ GeditFileBrowserView *view);
-static void on_unload (GeditFileBrowserStore * model,
- GFile * location,
- GeditFileBrowserView * view);
+static void on_unload (GeditFileBrowserStore *model,
+ GFile *location,
+ GeditFileBrowserView *view);
-static void on_row_inserted (GeditFileBrowserStore * model,
- GtkTreePath * path,
- GtkTreeIter * iter,
- GeditFileBrowserView * view);
+static void on_row_inserted (GeditFileBrowserStore *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ GeditFileBrowserView *view);
static void
-gedit_file_browser_view_finalize (GObject * object)
+gedit_file_browser_view_finalize (GObject *object)
{
- GeditFileBrowserView *obj = GEDIT_FILE_BROWSER_VIEW(object);
+ GeditFileBrowserView *obj = GEDIT_FILE_BROWSER_VIEW (object);
if (obj->priv->hand_cursor)
- gdk_cursor_unref(obj->priv->hand_cursor);
+ gdk_cursor_unref (obj->priv->hand_cursor);
if (obj->priv->hover_path)
gtk_tree_path_free (obj->priv->hover_path);
@@ -126,13 +127,12 @@ gedit_file_browser_view_finalize (GObject * object)
gdk_cursor_unref (obj->priv->busy_cursor);
- G_OBJECT_CLASS (gedit_file_browser_view_parent_class)->
- finalize (object);
+ G_OBJECT_CLASS (gedit_file_browser_view_parent_class)->finalize (object);
}
static void
-add_expand_state (GeditFileBrowserView * view,
- GFile * location)
+add_expand_state (GeditFileBrowserView *view,
+ GFile *location)
{
if (!location)
return;
@@ -142,8 +142,8 @@ add_expand_state (GeditFileBrowserView * view,
}
static void
-remove_expand_state (GeditFileBrowserView * view,
- GFile * location)
+remove_expand_state (GeditFileBrowserView *view,
+ GFile *location)
{
if (!location)
return;
@@ -153,9 +153,9 @@ remove_expand_state (GeditFileBrowserView * view,
}
static void
-row_expanded (GtkTreeView * tree_view,
- GtkTreeIter * iter,
- GtkTreePath * path)
+row_expanded (GtkTreeView *tree_view,
+ GtkTreeIter *iter,
+ GtkTreePath *path)
{
GeditFileBrowserView *view = GEDIT_FILE_BROWSER_VIEW (tree_view);
GFile *location;
@@ -182,12 +182,12 @@ row_expanded (GtkTreeView * tree_view,
}
static void
-row_collapsed (GtkTreeView * tree_view,
- GtkTreeIter * iter,
- GtkTreePath * path)
+row_collapsed (GtkTreeView *tree_view,
+ GtkTreeIter *iter,
+ GtkTreePath *path)
{
GeditFileBrowserView *view = GEDIT_FILE_BROWSER_VIEW (tree_view);
- GFile * location;
+ GFile *location;
if (GTK_TREE_VIEW_CLASS (gedit_file_browser_view_parent_class)->row_collapsed)
GTK_TREE_VIEW_CLASS (gedit_file_browser_view_parent_class)->row_collapsed (tree_view, iter, path);
@@ -211,28 +211,30 @@ row_collapsed (GtkTreeView * tree_view,
}
static gboolean
-leave_notify_event (GtkWidget *widget,
+leave_notify_event (GtkWidget *widget,
GdkEventCrossing *event)
{
GeditFileBrowserView *view = GEDIT_FILE_BROWSER_VIEW (widget);
if (view->priv->click_policy == GEDIT_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE &&
- view->priv->hover_path != NULL) {
+ view->priv->hover_path != NULL)
+ {
gtk_tree_path_free (view->priv->hover_path);
view->priv->hover_path = NULL;
}
- // Chainup
+ /* Chainup */
return GTK_WIDGET_CLASS (gedit_file_browser_view_parent_class)->leave_notify_event (widget, event);
}
static gboolean
-enter_notify_event (GtkWidget *widget,
+enter_notify_event (GtkWidget *widget,
GdkEventCrossing *event)
{
GeditFileBrowserView *view = GEDIT_FILE_BROWSER_VIEW (widget);
- if (view->priv->click_policy == GEDIT_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE) {
+ if (view->priv->click_policy == GEDIT_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE)
+ {
if (view->priv->hover_path != NULL)
gtk_tree_path_free (view->priv->hover_path);
@@ -246,25 +248,27 @@ enter_notify_event (GtkWidget *widget,
view->priv->hand_cursor);
}
- // Chainup
+ /* Chainup */
return GTK_WIDGET_CLASS (gedit_file_browser_view_parent_class)->enter_notify_event (widget, event);
}
static gboolean
-motion_notify_event (GtkWidget * widget,
- GdkEventMotion * event)
+motion_notify_event (GtkWidget *widget,
+ GdkEventMotion *event)
{
GtkTreePath *old_hover_path;
GeditFileBrowserView *view = GEDIT_FILE_BROWSER_VIEW (widget);
- if (view->priv->click_policy == GEDIT_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE) {
+ if (view->priv->click_policy == GEDIT_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE)
+ {
old_hover_path = view->priv->hover_path;
gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
event->x, event->y,
&view->priv->hover_path,
NULL, NULL, NULL);
- if ((old_hover_path != NULL) != (view->priv->hover_path != NULL)) {
+ if ((old_hover_path != NULL) != (view->priv->hover_path != NULL))
+ {
if (view->priv->hover_path != NULL)
gdk_window_set_cursor (gtk_widget_get_window (widget),
view->priv->hand_cursor);
@@ -277,7 +281,7 @@ motion_notify_event (GtkWidget * widget,
gtk_tree_path_free (old_hover_path);
}
- // Chainup
+ /* Chainup */
return GTK_WIDGET_CLASS (gedit_file_browser_view_parent_class)->motion_notify_event (widget, event);
}
@@ -291,11 +295,15 @@ set_click_policy_property (GeditFileBrowserView *obj,
obj->priv->click_policy = click_policy;
- if (click_policy == GEDIT_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE) {
+ if (click_policy == GEDIT_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE)
+ {
if (obj->priv->hand_cursor == NULL)
obj->priv->hand_cursor = gdk_cursor_new(GDK_HAND2);
- } else if (click_policy == GEDIT_FILE_BROWSER_VIEW_CLICK_POLICY_DOUBLE) {
- if (obj->priv->hover_path != NULL) {
+ }
+ else if (click_policy == GEDIT_FILE_BROWSER_VIEW_CLICK_POLICY_DOUBLE)
+ {
+ if (obj->priv->hover_path != NULL)
+ {
if (gtk_tree_model_get_iter (GTK_TREE_MODEL (obj->priv->model),
&iter, obj->priv->hover_path))
gtk_tree_model_row_changed (GTK_TREE_MODEL (obj->priv->model),
@@ -305,7 +313,8 @@ set_click_policy_property (GeditFileBrowserView *obj,
obj->priv->hover_path = NULL;
}
- if (GTK_WIDGET_REALIZED (GTK_WIDGET (obj))) {
+ if (GTK_WIDGET_REALIZED (GTK_WIDGET (obj)))
+ {
win = gtk_widget_get_window (GTK_WIDGET (obj));
gdk_window_set_cursor (win, NULL);
@@ -315,7 +324,8 @@ set_click_policy_property (GeditFileBrowserView *obj,
gdk_display_flush (display);
}
- if (obj->priv->hand_cursor) {
+ if (obj->priv->hand_cursor)
+ {
gdk_cursor_unref (obj->priv->hand_cursor);
obj->priv->hand_cursor = NULL;
}
@@ -330,7 +340,8 @@ directory_activated (GeditFileBrowserView *view,
}
static void
-activate_selected_files (GeditFileBrowserView *view) {
+activate_selected_files (GeditFileBrowserView *view)
+{
GtkTreeView *tree_view = GTK_TREE_VIEW (view);
GtkTreeSelection *selection = gtk_tree_view_get_selection (tree_view);
GList *rows, *row;
@@ -341,7 +352,8 @@ activate_selected_files (GeditFileBrowserView *view) {
rows = gtk_tree_selection_get_selected_rows (selection, &view->priv->model);
- for (row = rows; row; row = row->next) {
+ for (row = rows; row; row = row->next)
+ {
path = (GtkTreePath *)(row->data);
/* Get iter from path */
@@ -350,26 +362,22 @@ activate_selected_files (GeditFileBrowserView *view) {
gtk_tree_model_get (view->priv->model, &iter, GEDIT_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags, -1);
- if (FILE_IS_DIR (flags)) {
- if (directory == NULL)
- directory = path;
-
- } else if (!FILE_IS_DUMMY (flags)) {
+ if (FILE_IS_DIR (flags) && directory == NULL)
+ directory = path;
+ else if (!FILE_IS_DUMMY (flags))
g_signal_emit (view, signals[FILE_ACTIVATED], 0, &iter);
- }
}
- if (directory != NULL) {
- if (gtk_tree_model_get_iter (view->priv->model, &iter, directory))
- g_signal_emit (view, signals[DIRECTORY_ACTIVATED], 0, &iter);
- }
+ if (directory != NULL && gtk_tree_model_get_iter (view->priv->model, &iter, directory))
+ g_signal_emit (view, signals[DIRECTORY_ACTIVATED], 0, &iter);
g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
g_list_free (rows);
}
static void
-activate_selected_bookmark (GeditFileBrowserView *view) {
+activate_selected_bookmark (GeditFileBrowserView *view)
+{
GtkTreeView *tree_view = GTK_TREE_VIEW (view);
GtkTreeSelection *selection = gtk_tree_view_get_selection (tree_view);
GtkTreeIter iter;
@@ -433,20 +441,27 @@ did_not_drag (GeditFileBrowserView *view,
selection = gtk_tree_view_get_selection (tree_view);
if (gtk_tree_view_get_path_at_pos (tree_view, event->x, event->y,
- &path, NULL, NULL, NULL)) {
- if ((view->priv->click_policy == GEDIT_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE)
- && !button_event_modifies_selection(event)
- && (event->button == 1 || event->button == 2)) {
+ &path, NULL, NULL, NULL))
+ {
+ if ((view->priv->click_policy == GEDIT_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE) &&
+ !button_event_modifies_selection (event) &&
+ (event->button == 1 || event->button == 2))
+ {
/* Activate all selected items, and leave them selected */
activate_selected_items (view);
- } else if ((event->button == 1 || event->button == 2)
- && ((event->state & GDK_CONTROL_MASK) != 0 ||
- (event->state & GDK_SHIFT_MASK) == 0)
- && view->priv->selected_on_button_down) {
- if (!button_event_modifies_selection (event)) {
+ }
+ else if ((event->button == 1 || event->button == 2) &&
+ ((event->state & GDK_CONTROL_MASK) != 0 ||
+ (event->state & GDK_SHIFT_MASK) == 0) &&
+ view->priv->selected_on_button_down)
+ {
+ if (!button_event_modifies_selection (event))
+ {
gtk_tree_selection_unselect_all (selection);
gtk_tree_selection_select_path (selection, path);
- } else {
+ }
+ else
+ {
gtk_tree_selection_unselect_path (selection, path);
}
}
@@ -456,16 +471,16 @@ did_not_drag (GeditFileBrowserView *view,
}
static gboolean
-button_release_event (GtkWidget *widget,
+button_release_event (GtkWidget *widget,
GdkEventButton *event)
{
GeditFileBrowserView *view = GEDIT_FILE_BROWSER_VIEW (widget);
- if (event->button == view->priv->drag_button) {
+ if (event->button == view->priv->drag_button)
+ {
view->priv->drag_button = 0;
- if (!view->priv->drag_started &&
- !view->priv->ignore_release)
+ if (!view->priv->drag_started && !view->priv->ignore_release)
did_not_drag (view, event);
}
@@ -489,7 +504,7 @@ button_press_event (GtkWidget *widget,
gboolean on_expander;
gboolean call_parent;
gboolean selected;
- GtkWidgetClass *widget_parent = GTK_WIDGET_CLASS(gedit_file_browser_view_parent_class);
+ GtkWidgetClass *widget_parent = GTK_WIDGET_CLASS (gedit_file_browser_view_parent_class);
tree_view = GTK_TREE_VIEW (widget);
view = GEDIT_FILE_BROWSER_VIEW (widget);
@@ -510,19 +525,20 @@ button_press_event (GtkWidget *widget,
/* Ignore double click if we are in single click mode */
if (view->priv->click_policy == GEDIT_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE &&
- click_count >= 2) {
+ click_count >= 2)
return TRUE;
- }
view->priv->ignore_release = FALSE;
call_parent = TRUE;
if (gtk_tree_view_get_path_at_pos (tree_view, event->x, event->y,
- &path, NULL, NULL, NULL)) {
+ &path, NULL, NULL, NULL))
+ {
/* Keep track of path of last click so double clicks only happen
* on the same item */
if ((event->button == 1 || event->button == 2) &&
- event->type == GDK_BUTTON_PRESS) {
+ event->type == GDK_BUTTON_PRESS)
+ {
if (view->priv->double_click_path[1])
gtk_tree_path_free (view->priv->double_click_path[1]);
@@ -530,14 +546,17 @@ button_press_event (GtkWidget *widget,
view->priv->double_click_path[0] = gtk_tree_path_copy (path);
}
- if (event->type == GDK_2BUTTON_PRESS) {
+ if (event->type == GDK_2BUTTON_PRESS)
+ {
if (view->priv->double_click_path[1] &&
gtk_tree_path_compare (view->priv->double_click_path[0], view->priv->double_click_path[1]) == 0)
activate_selected_items (view);
/* Chain up */
widget_parent->button_press_event (widget, event);
- } else {
+ }
+ else
+ {
/* We're going to filter out some situations where
* we can't let the default code run because all
* but one row would be would be deselected. We don't
@@ -550,7 +569,8 @@ button_press_event (GtkWidget *widget,
if ((event->button == 1 || event->button == 2) &&
((event->state & GDK_CONTROL_MASK) != 0 ||
- (event->state & GDK_SHIFT_MASK) == 0)) {
+ (event->state & GDK_SHIFT_MASK) == 0))
+ {
gtk_widget_style_get (widget,
"expander-size", &expander_size,
"horizontal-separator", &horizontal_separator,
@@ -560,35 +580,47 @@ button_press_event (GtkWidget *widget,
view->priv->selected_on_button_down = selected;
- if (selected) {
+ if (selected)
+ {
call_parent = on_expander || gtk_tree_selection_count_selected_rows (selection) == 1;
view->priv->ignore_release = call_parent && view->priv->click_policy != GEDIT_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE;
- } else if ((event->state & GDK_CONTROL_MASK) != 0) {
+ }
+ else if ((event->state & GDK_CONTROL_MASK) != 0)
+ {
call_parent = FALSE;
gtk_tree_selection_select_path (selection, path);
- } else {
+ }
+ else
+ {
view->priv->ignore_release = on_expander;
}
}
- if (call_parent) {
+ if (call_parent)
+ {
/* Chain up */
widget_parent->button_press_event (widget, event);
- } else if (selected) {
+ }
+ else if (selected)
+ {
gtk_widget_grab_focus (widget);
}
if ((event->button == 1 || event->button == 2) &&
- event->type == GDK_BUTTON_PRESS) {
+ event->type == GDK_BUTTON_PRESS)
+ {
view->priv->drag_started = FALSE;
view->priv->drag_button = event->button;
}
}
gtk_tree_path_free (path);
- } else {
+ }
+ else
+ {
if ((event->button == 1 || event->button == 2) &&
- event->type == GDK_BUTTON_PRESS) {
+ event->type == GDK_BUTTON_PRESS)
+ {
if (view->priv->double_click_path[1])
gtk_tree_path_free (view->priv->double_click_path[1]);
@@ -618,36 +650,41 @@ key_press_event (GtkWidget *widget,
modifiers = gtk_accelerator_get_default_mod_mask ();
- switch (event->keyval) {
- case GDK_space:
- if (event->state & GDK_CONTROL_MASK) {
- handled = FALSE;
- break;
- }
- if (!GTK_WIDGET_HAS_FOCUS (widget)) {
- handled = FALSE;
- break;
- }
-
- activate_selected_items (view);
- handled = TRUE;
- break;
+ switch (event->keyval)
+ {
+ case GDK_space:
+ if (event->state & GDK_CONTROL_MASK)
+ {
+ handled = FALSE;
+ break;
+ }
+ if (!GTK_WIDGET_HAS_FOCUS (widget))
+ {
+ handled = FALSE;
+ break;
+ }
- case GDK_Return:
- case GDK_KP_Enter:
- activate_selected_items (view);
- handled = TRUE;
- break;
+ activate_selected_items (view);
+ handled = TRUE;
+ break;
- case GDK_h:
- if ((event->state & modifiers) == GDK_CONTROL_MASK) {
- toggle_hidden_filter (view);
+ case GDK_Return:
+ case GDK_KP_Enter:
+ activate_selected_items (view);
handled = TRUE;
break;
- }
- default:
- handled = FALSE;
+ case GDK_h:
+ if ((event->state & modifiers) == GDK_CONTROL_MASK)
+ {
+ toggle_hidden_filter (view);
+ handled = TRUE;
+ break;
+ }
+
+ default:
+ handled = FALSE;
+ break;
}
/* Chain up */
@@ -658,9 +695,10 @@ key_press_event (GtkWidget *widget,
}
static void
-fill_expand_state (GeditFileBrowserView * view, GtkTreeIter * iter)
+fill_expand_state (GeditFileBrowserView *view,
+ GtkTreeIter *iter)
{
- GtkTreePath * path;
+ GtkTreePath *path;
GtkTreeIter child;
GFile *location;
@@ -684,15 +722,16 @@ fill_expand_state (GeditFileBrowserView * view, GtkTreeIter * iter)
{
do {
fill_expand_state (view, &child);
- } while (gtk_tree_model_iter_next (view->priv->model, &child));
+ }
+ while (gtk_tree_model_iter_next (view->priv->model, &child));
}
gtk_tree_path_free (path);
}
static void
-uninstall_restore_signals (GeditFileBrowserView * tree_view,
- GtkTreeModel * model)
+uninstall_restore_signals (GeditFileBrowserView *tree_view,
+ GtkTreeModel *model)
{
g_signal_handlers_disconnect_by_func (model,
on_begin_refresh,
@@ -712,8 +751,8 @@ uninstall_restore_signals (GeditFileBrowserView * tree_view,
}
static void
-install_restore_signals (GeditFileBrowserView * tree_view,
- GtkTreeModel * model)
+install_restore_signals (GeditFileBrowserView *tree_view,
+ GtkTreeModel *model)
{
g_signal_connect (model,
"begin-refresh",
@@ -737,8 +776,8 @@ install_restore_signals (GeditFileBrowserView * tree_view,
}
static void
-set_restore_expand_state (GeditFileBrowserView * view,
- gboolean state)
+set_restore_expand_state (GeditFileBrowserView *view,
+ gboolean state)
{
if (state == view->priv->restore_expand_state)
return;
@@ -816,7 +855,7 @@ set_property (GObject *object,
}
static void
-gedit_file_browser_view_class_init (GeditFileBrowserViewClass * klass)
+gedit_file_browser_view_class_init (GeditFileBrowserViewClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkTreeViewClass *tree_view_class = GTK_TREE_VIEW_CLASS (klass);
@@ -895,9 +934,11 @@ gedit_file_browser_view_class_init (GeditFileBrowserViewClass * klass)
}
static void
-cell_data_cb (GtkTreeViewColumn * tree_column, GtkCellRenderer * cell,
- GtkTreeModel * tree_model, GtkTreeIter * iter,
- GeditFileBrowserView * obj)
+cell_data_cb (GtkTreeViewColumn *tree_column,
+ GtkCellRenderer *cell,
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ GeditFileBrowserView *obj)
{
GtkTreePath *path;
PangoUnderline underline = PANGO_UNDERLINE_NONE;
@@ -905,21 +946,17 @@ cell_data_cb (GtkTreeViewColumn * tree_column, GtkCellRenderer * cell,
path = gtk_tree_model_get_path (tree_model, iter);
- if (obj->priv->click_policy == GEDIT_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE) {
- if (obj->priv->hover_path != NULL &&
- gtk_tree_path_compare (path, obj->priv->hover_path) == 0)
- underline = PANGO_UNDERLINE_SINGLE;
- }
+ if (obj->priv->click_policy == GEDIT_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE &&
+ obj->priv->hover_path != NULL &&
+ gtk_tree_path_compare (path, obj->priv->hover_path) == 0)
+ underline = PANGO_UNDERLINE_SINGLE;
- if (GEDIT_IS_FILE_BROWSER_STORE (tree_model))
+ if (GEDIT_IS_FILE_BROWSER_STORE (tree_model) &&
+ obj->priv->editable != NULL &&
+ gtk_tree_row_reference_valid (obj->priv->editable))
{
- 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;
- }
+ 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);
@@ -927,7 +964,7 @@ cell_data_cb (GtkTreeViewColumn * tree_column, GtkCellRenderer * cell,
}
static void
-gedit_file_browser_view_init (GeditFileBrowserView * obj)
+gedit_file_browser_view_init (GeditFileBrowserView *obj)
{
obj->priv = GEDIT_FILE_BROWSER_VIEW_GET_PRIVATE (obj);
@@ -967,8 +1004,9 @@ gedit_file_browser_view_init (GeditFileBrowserView * obj)
}
static gboolean
-bookmarks_separator_func (GtkTreeModel * model, GtkTreeIter * iter,
- gpointer user_data)
+bookmarks_separator_func (GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer user_data)
{
guint flags;
@@ -991,8 +1029,8 @@ gedit_file_browser_view_new (void)
}
void
-gedit_file_browser_view_set_model (GeditFileBrowserView * tree_view,
- GtkTreeModel * model)
+gedit_file_browser_view_set_model (GeditFileBrowserView *tree_view,
+ GtkTreeModel *model)
{
GtkTreeSelection *selection;
@@ -1001,7 +1039,8 @@ gedit_file_browser_view_set_model (GeditFileBrowserView * tree_view,
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
- if (GEDIT_IS_FILE_BOOKMARKS_STORE (model)) {
+ if (GEDIT_IS_FILE_BOOKMARKS_STORE (model))
+ {
gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW
(tree_view),
@@ -1014,7 +1053,9 @@ gedit_file_browser_view_set_model (GeditFileBrowserView * tree_view,
(GtkTreeCellDataFunc)
cell_data_cb,
tree_view, NULL);
- } else {
+ }
+ else
+ {
gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW
(tree_view), NULL,
@@ -1032,12 +1073,14 @@ gedit_file_browser_view_set_model (GeditFileBrowserView * tree_view,
}
- if (tree_view->priv->hover_path != NULL) {
+ if (tree_view->priv->hover_path != NULL)
+ {
gtk_tree_path_free (tree_view->priv->hover_path);
tree_view->priv->hover_path = NULL;
}
- if (GEDIT_IS_FILE_BROWSER_STORE (tree_view->priv->model)) {
+ if (GEDIT_IS_FILE_BROWSER_STORE (tree_view->priv->model))
+ {
if (tree_view->priv->restore_expand_state)
uninstall_restore_signals (tree_view,
tree_view->priv->model);
@@ -1048,8 +1091,8 @@ gedit_file_browser_view_set_model (GeditFileBrowserView * tree_view,
}
void
-gedit_file_browser_view_start_rename (GeditFileBrowserView * tree_view,
- GtkTreeIter * iter)
+gedit_file_browser_view_start_rename (GeditFileBrowserView *tree_view,
+ GtkTreeIter *iter)
{
guint flags;
GtkTreeRowReference *rowref;
@@ -1093,8 +1136,8 @@ gedit_file_browser_view_start_rename (GeditFileBrowserView * tree_view,
}
void
-gedit_file_browser_view_set_click_policy (GeditFileBrowserView *tree_view,
- GeditFileBrowserViewClickPolicy policy)
+gedit_file_browser_view_set_click_policy (GeditFileBrowserView *tree_view,
+ GeditFileBrowserViewClickPolicy policy)
{
g_return_if_fail (GEDIT_IS_FILE_BROWSER_VIEW (tree_view));
@@ -1104,8 +1147,8 @@ gedit_file_browser_view_set_click_policy (GeditFileBrowserView *tree_view,
}
void
-gedit_file_browser_view_set_restore_expand_state (GeditFileBrowserView * tree_view,
- gboolean restore_expand_state)
+gedit_file_browser_view_set_restore_expand_state (GeditFileBrowserView *tree_view,
+ gboolean restore_expand_state)
{
g_return_if_fail (GEDIT_IS_FILE_BROWSER_VIEW (tree_view));
@@ -1115,13 +1158,15 @@ gedit_file_browser_view_set_restore_expand_state (GeditFileBrowserView * tree_vi
/* Signal handlers */
static void
-on_cell_edited (GtkCellRendererText * cell, gchar * path, gchar * new_text,
- GeditFileBrowserView * tree_view)
+on_cell_edited (GtkCellRendererText *cell,
+ gchar *path,
+ gchar *new_text,
+ GeditFileBrowserView *tree_view)
{
- GtkTreePath * treepath;
+ GtkTreePath *treepath;
GtkTreeIter iter;
gboolean ret;
- GError * error = NULL;
+ GError *error = NULL;
gtk_tree_row_reference_free (tree_view->priv->editable);
tree_view->priv->editable = NULL;
@@ -1133,28 +1178,29 @@ on_cell_edited (GtkCellRendererText * cell, gchar * path, gchar * new_text,
ret = gtk_tree_model_get_iter (GTK_TREE_MODEL (tree_view->priv->model), &iter, treepath);
gtk_tree_path_free (treepath);
- if (ret) {
+ if (ret)
+ {
if (gedit_file_browser_store_rename (GEDIT_FILE_BROWSER_STORE (tree_view->priv->model),
- &iter, new_text, &error)) {
+ &iter, new_text, &error))
+ {
treepath = gtk_tree_model_get_path (GTK_TREE_MODEL (tree_view->priv->model), &iter);
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (tree_view),
treepath, NULL,
FALSE, 0.0, 0.0);
gtk_tree_path_free (treepath);
}
- else {
- if (error) {
- g_signal_emit (tree_view, signals[ERROR], 0,
- error->code, error->message);
- g_error_free (error);
- }
+ else if (error)
+ {
+ g_signal_emit (tree_view, signals[ERROR], 0,
+ error->code, error->message);
+ g_error_free (error);
}
}
}
static void
-on_begin_refresh (GeditFileBrowserStore * model,
- GeditFileBrowserView * view)
+on_begin_refresh (GeditFileBrowserStore *model,
+ GeditFileBrowserView *view)
{
/* Store the refresh state, so we can handle unloading of nodes while
refreshing properly */
@@ -1162,8 +1208,8 @@ on_begin_refresh (GeditFileBrowserStore * model,
}
static void
-on_end_refresh (GeditFileBrowserStore * model,
- GeditFileBrowserView * view)
+on_end_refresh (GeditFileBrowserStore *model,
+ GeditFileBrowserView *view)
{
/* Store the refresh state, so we can handle unloading of nodes while
refreshing properly */
@@ -1183,12 +1229,12 @@ on_unload (GeditFileBrowserStore *model,
}
static void
-restore_expand_state (GeditFileBrowserView * view,
- GeditFileBrowserStore * model,
- GtkTreeIter * iter)
+restore_expand_state (GeditFileBrowserView *view,
+ GeditFileBrowserStore *model,
+ GtkTreeIter *iter)
{
- GFile * location;
- GtkTreePath * path;
+ GFile *location;
+ GtkTreePath *path;
gtk_tree_model_get (GTK_TREE_MODEL (model),
iter,
@@ -1212,13 +1258,13 @@ restore_expand_state (GeditFileBrowserView * view,
}
static void
-on_row_inserted (GeditFileBrowserStore * model,
- GtkTreePath * path,
- GtkTreeIter * iter,
- GeditFileBrowserView * view)
+on_row_inserted (GeditFileBrowserStore *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ GeditFileBrowserView *view)
{
GtkTreeIter parent;
- GtkTreePath * copy;
+ GtkTreePath *copy;
if (gtk_tree_model_iter_has_child (GTK_TREE_MODEL (model), iter))
restore_expand_state (view, model, iter);
@@ -1234,5 +1280,3 @@ on_row_inserted (GeditFileBrowserStore * model,
gtk_tree_path_free (copy);
}
-
-// ex:ts=8:noet:
diff --git a/plugins/filebrowser/gedit-file-browser-view.h b/plugins/filebrowser/gedit-file-browser-view.h
index a5ada25..500d17a 100644
--- a/plugins/filebrowser/gedit-file-browser-view.h
+++ b/plugins/filebrowser/gedit-file-browser-view.h
@@ -1,19 +1,19 @@
/*
* gedit-file-browser-view.h - Gedit plugin providing easy file access
* from the sidepanel
- *
+ *
* Copyright (C) 2006 - Jesse van den Kieboom <jesse icecrew nl>
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@@ -54,31 +54,30 @@ struct _GeditFileBrowserViewClass
GtkTreeViewClass parent_class;
/* Signals */
- void (*error) (GeditFileBrowserView * filetree,
- guint code,
- gchar const *message);
- void (*file_activated) (GeditFileBrowserView * filetree,
- GtkTreeIter *iter);
- void (*directory_activated) (GeditFileBrowserView * filetree,
- GtkTreeIter *iter);
- void (*bookmark_activated) (GeditFileBrowserView * filetree,
- GtkTreeIter *iter);
+ void (* error) (GeditFileBrowserView *filetree,
+ guint code,
+ gchar const *message);
+ void (* file_activated) (GeditFileBrowserView *filetree,
+ GtkTreeIter *iter);
+ void (* directory_activated) (GeditFileBrowserView *filetree,
+ GtkTreeIter *iter);
+ void (* bookmark_activated) (GeditFileBrowserView *filetree,
+ GtkTreeIter *iter);
};
-GType gedit_file_browser_view_get_type (void) G_GNUC_CONST;
-GType gedit_file_browser_view_register_type (GTypeModule * module);
+GType gedit_file_browser_view_get_type (void) G_GNUC_CONST;
+GType gedit_file_browser_view_register_type (GTypeModule *module);
-GtkWidget *gedit_file_browser_view_new (void);
-void gedit_file_browser_view_set_model (GeditFileBrowserView * tree_view,
- GtkTreeModel * model);
-void gedit_file_browser_view_start_rename (GeditFileBrowserView * tree_view,
- GtkTreeIter * iter);
-void gedit_file_browser_view_set_click_policy (GeditFileBrowserView * tree_view,
- GeditFileBrowserViewClickPolicy policy);
-void gedit_file_browser_view_set_restore_expand_state (GeditFileBrowserView * tree_view,
- gboolean restore_expand_state);
+GtkWidget *gedit_file_browser_view_new (void);
+void gedit_file_browser_view_set_model (GeditFileBrowserView *tree_view,
+ GtkTreeModel *model);
+void gedit_file_browser_view_start_rename (GeditFileBrowserView *tree_view,
+ GtkTreeIter *iter);
+void gedit_file_browser_view_set_click_policy (GeditFileBrowserView *tree_view,
+ GeditFileBrowserViewClickPolicy policy);
+void gedit_file_browser_view_set_restore_expand_state (GeditFileBrowserView *tree_view,
+ gboolean restore_expand_state);
G_END_DECLS
-#endif /* __GEDIT_FILE_BROWSER_VIEW_H__ */
-// ex:ts=8:noet:
+#endif /* __GEDIT_FILE_BROWSER_VIEW_H__ */
diff --git a/plugins/filebrowser/gedit-file-browser-widget.c b/plugins/filebrowser/gedit-file-browser-widget.c
index a305047..3e21f8e 100644
--- a/plugins/filebrowser/gedit-file-browser-widget.c
+++ b/plugins/filebrowser/gedit-file-browser-widget.c
@@ -1,19 +1,19 @@
/*
* gedit-file-browser-widget.c - Gedit plugin providing easy file access
* from the sidepanel
- *
+ *
* Copyright (C) 2006 - Jesse van den Kieboom <jesse icecrew nl>
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@@ -160,79 +160,79 @@ struct _GeditFileBrowserWidgetPrivate
};
static void set_enable_delete (GeditFileBrowserWidget *obj,
- gboolean enable);
-static void on_model_set (GObject * gobject,
- GParamSpec * arg1,
- GeditFileBrowserWidget * obj);
-static void on_treeview_error (GeditFileBrowserView * tree_view,
- guint code,
- gchar * message,
- GeditFileBrowserWidget * obj);
-static void on_file_store_error (GeditFileBrowserStore * store,
- guint code,
- gchar * message,
- GeditFileBrowserWidget * obj);
-static gboolean on_file_store_no_trash (GeditFileBrowserStore * store,
- GList * files,
- GeditFileBrowserWidget * obj);
-static void on_combo_changed (GtkComboBox * combo,
- GeditFileBrowserWidget * obj);
-static gboolean on_treeview_popup_menu (GeditFileBrowserView * treeview,
- GeditFileBrowserWidget * obj);
-static gboolean on_treeview_button_press_event (GeditFileBrowserView * treeview,
- GdkEventButton * event,
- GeditFileBrowserWidget * obj);
-static gboolean on_treeview_key_press_event (GeditFileBrowserView * treeview,
- GdkEventKey * event,
- GeditFileBrowserWidget * obj);
-static void on_selection_changed (GtkTreeSelection * selection,
- GeditFileBrowserWidget * obj);
-
-static void on_virtual_root_changed (GeditFileBrowserStore * model,
- GParamSpec *param,
- GeditFileBrowserWidget * obj);
-
-static gboolean on_entry_filter_activate (GeditFileBrowserWidget * obj);
-static void on_location_jump_activate (GtkMenuItem * item,
- GeditFileBrowserWidget * obj);
-static void on_bookmarks_row_changed (GtkTreeModel * model,
- GtkTreePath * path,
- GtkTreeIter * iter,
- GeditFileBrowserWidget * obj);
-static void on_bookmarks_row_deleted (GtkTreeModel * model,
- GtkTreePath * path,
- GeditFileBrowserWidget * obj);
-static void on_filter_mode_changed (GeditFileBrowserStore * model,
- GParamSpec * param,
- GeditFileBrowserWidget * obj);
-static void on_action_directory_previous (GtkAction * action,
- GeditFileBrowserWidget * obj);
-static void on_action_directory_next (GtkAction * action,
- GeditFileBrowserWidget * obj);
-static void on_action_directory_up (GtkAction * action,
- GeditFileBrowserWidget * obj);
-static void on_action_directory_new (GtkAction * action,
- GeditFileBrowserWidget * obj);
-static void on_action_file_open (GtkAction * action,
- GeditFileBrowserWidget * obj);
-static void on_action_file_new (GtkAction * action,
- GeditFileBrowserWidget * obj);
-static void on_action_file_rename (GtkAction * action,
- GeditFileBrowserWidget * obj);
-static void on_action_file_delete (GtkAction * action,
- GeditFileBrowserWidget * obj);
-static void on_action_file_move_to_trash (GtkAction * action,
- GeditFileBrowserWidget * obj);
-static void on_action_directory_refresh (GtkAction * action,
- GeditFileBrowserWidget * obj);
-static void on_action_directory_open (GtkAction * action,
- GeditFileBrowserWidget * obj);
-static void on_action_filter_hidden (GtkAction * action,
- GeditFileBrowserWidget * obj);
-static void on_action_filter_binary (GtkAction * action,
- GeditFileBrowserWidget * obj);
-static void on_action_bookmark_open (GtkAction * action,
- GeditFileBrowserWidget * obj);
+ gboolean enable);
+static void on_model_set (GObject *gobject,
+ GParamSpec *arg1,
+ GeditFileBrowserWidget *obj);
+static void on_treeview_error (GeditFileBrowserView *tree_view,
+ guint code,
+ gchar *message,
+ GeditFileBrowserWidget *obj);
+static void on_file_store_error (GeditFileBrowserStore *store,
+ guint code,
+ gchar *message,
+ GeditFileBrowserWidget *obj);
+static gboolean on_file_store_no_trash (GeditFileBrowserStore *store,
+ GList *files,
+ GeditFileBrowserWidget *obj);
+static void on_combo_changed (GtkComboBox *combo,
+ GeditFileBrowserWidget *obj);
+static gboolean on_treeview_popup_menu (GeditFileBrowserView *treeview,
+ GeditFileBrowserWidget *obj);
+static gboolean on_treeview_button_press_event (GeditFileBrowserView *treeview,
+ GdkEventButton *event,
+ GeditFileBrowserWidget *obj);
+static gboolean on_treeview_key_press_event (GeditFileBrowserView *treeview,
+ GdkEventKey *event,
+ GeditFileBrowserWidget *obj);
+static void on_selection_changed (GtkTreeSelection *selection,
+ GeditFileBrowserWidget *obj);
+
+static void on_virtual_root_changed (GeditFileBrowserStore *model,
+ GParamSpec *param,
+ GeditFileBrowserWidget *obj);
+
+static gboolean on_entry_filter_activate (GeditFileBrowserWidget *obj);
+static void on_location_jump_activate (GtkMenuItem *item,
+ GeditFileBrowserWidget *obj);
+static void on_bookmarks_row_changed (GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ GeditFileBrowserWidget *obj);
+static void on_bookmarks_row_deleted (GtkTreeModel *model,
+ GtkTreePath *path,
+ GeditFileBrowserWidget *obj);
+static void on_filter_mode_changed (GeditFileBrowserStore *model,
+ GParamSpec *param,
+ GeditFileBrowserWidget *obj);
+static void on_action_directory_previous (GtkAction *action,
+ GeditFileBrowserWidget *obj);
+static void on_action_directory_next (GtkAction *action,
+ GeditFileBrowserWidget *obj);
+static void on_action_directory_up (GtkAction *action,
+ GeditFileBrowserWidget *obj);
+static void on_action_directory_new (GtkAction *action,
+ GeditFileBrowserWidget *obj);
+static void on_action_file_open (GtkAction *action,
+ GeditFileBrowserWidget *obj);
+static void on_action_file_new (GtkAction *action,
+ GeditFileBrowserWidget *obj);
+static void on_action_file_rename (GtkAction *action,
+ GeditFileBrowserWidget *obj);
+static void on_action_file_delete (GtkAction *action,
+ GeditFileBrowserWidget *obj);
+static void on_action_file_move_to_trash (GtkAction *action,
+ GeditFileBrowserWidget *obj);
+static void on_action_directory_refresh (GtkAction *action,
+ GeditFileBrowserWidget *obj);
+static void on_action_directory_open (GtkAction *action,
+ GeditFileBrowserWidget *obj);
+static void on_action_filter_hidden (GtkAction *action,
+ GeditFileBrowserWidget *obj);
+static void on_action_filter_binary (GtkAction *action,
+ GeditFileBrowserWidget *obj);
+static void on_action_bookmark_open (GtkAction *action,
+ GeditFileBrowserWidget *obj);
GEDIT_PLUGIN_DEFINE_TYPE (GeditFileBrowserWidget, gedit_file_browser_widget,
GTK_TYPE_VBOX)
@@ -240,7 +240,7 @@ GEDIT_PLUGIN_DEFINE_TYPE (GeditFileBrowserWidget, gedit_file_browser_widget,
static void
free_name_icon (gpointer data)
{
- NameIcon * item;
+ NameIcon *item;
if (data == NULL)
return;
@@ -256,10 +256,10 @@ free_name_icon (gpointer data)
}
static FilterFunc *
-filter_func_new (GeditFileBrowserWidget * obj,
- GeditFileBrowserWidgetFilterFunc func,
- gpointer user_data,
- GDestroyNotify notify)
+filter_func_new (GeditFileBrowserWidget *obj,
+ GeditFileBrowserWidgetFilterFunc func,
+ gpointer user_data,
+ GDestroyNotify notify)
{
FilterFunc *result;
@@ -273,7 +273,7 @@ filter_func_new (GeditFileBrowserWidget * obj,
}
static void
-location_free (Location * loc)
+location_free (Location *loc)
{
if (loc->root)
g_object_unref (loc->root);
@@ -285,8 +285,9 @@ location_free (Location * loc)
}
static gboolean
-combo_find_by_id (GeditFileBrowserWidget * obj, guint id,
- GtkTreeIter * iter)
+combo_find_by_id (GeditFileBrowserWidget *obj,
+ guint id,
+ GtkTreeIter *iter)
{
guint checkid;
GtkTreeModel *model = GTK_TREE_MODEL (obj->priv->combo_model);
@@ -294,21 +295,24 @@ combo_find_by_id (GeditFileBrowserWidget * obj, guint id,
if (iter == NULL)
return FALSE;
- if (gtk_tree_model_get_iter_first (model, iter)) {
- do {
+ if (gtk_tree_model_get_iter_first (model, iter))
+ {
+ do
+ {
gtk_tree_model_get (model, iter, COLUMN_ID,
&checkid, -1);
if (checkid == id)
return TRUE;
- } while (gtk_tree_model_iter_next (model, iter));
+ }
+ while (gtk_tree_model_iter_next (model, iter));
}
return FALSE;
}
static void
-remove_path_items (GeditFileBrowserWidget * obj)
+remove_path_items (GeditFileBrowserWidget *obj)
{
GtkTreeIter iter;
@@ -329,7 +333,7 @@ cancel_async_operation (GeditFileBrowserWidget *widget)
}
static void
-gedit_file_browser_widget_finalize (GObject * object)
+gedit_file_browser_widget_finalize (GObject *object)
{
GeditFileBrowserWidget *obj = GEDIT_FILE_BROWSER_WIDGET (object);
GList *loc;
@@ -364,7 +368,7 @@ gedit_file_browser_widget_finalize (GObject * object)
}
static void
-gedit_file_browser_widget_get_property (GObject *object,
+gedit_file_browser_widget_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
@@ -386,7 +390,7 @@ gedit_file_browser_widget_get_property (GObject *object,
}
static void
-gedit_file_browser_widget_set_property (GObject *object,
+gedit_file_browser_widget_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
@@ -409,7 +413,7 @@ gedit_file_browser_widget_set_property (GObject *object,
}
static void
-gedit_file_browser_widget_class_init (GeditFileBrowserWidgetClass * klass)
+gedit_file_browser_widget_class_init (GeditFileBrowserWidgetClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -478,7 +482,9 @@ gedit_file_browser_widget_class_init (GeditFileBrowserWidgetClass * klass)
}
static void
-add_signal (GeditFileBrowserWidget * obj, gpointer object, gulong id)
+add_signal (GeditFileBrowserWidget *obj,
+ gpointer object,
+ gulong id)
{
SignalNode *node = g_new (SignalNode, 1);
@@ -490,12 +496,13 @@ add_signal (GeditFileBrowserWidget * obj, gpointer object, gulong id)
}
static void
-clear_signals (GeditFileBrowserWidget * obj)
+clear_signals (GeditFileBrowserWidget *obj)
{
GSList *item;
SignalNode *node;
- for (item = obj->priv->signal_pool; item; item = item->next) {
+ for (item = obj->priv->signal_pool; item; item = item->next)
+ {
node = (SignalNode *) (item->data);
g_signal_handler_disconnect (node->object, node->id);
@@ -507,7 +514,7 @@ clear_signals (GeditFileBrowserWidget * obj)
}
static gboolean
-separator_func (GtkTreeModel * model, GtkTreeIter * iter, gpointer data)
+separator_func (GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
{
guint id;
@@ -517,11 +524,13 @@ separator_func (GtkTreeModel * model, GtkTreeIter * iter, gpointer data)
}
static gboolean
-get_from_bookmark_file (GeditFileBrowserWidget * obj, GFile * file,
- gchar ** name, GdkPixbuf ** icon)
+get_from_bookmark_file (GeditFileBrowserWidget *obj,
+ GFile *file,
+ gchar **name,
+ GdkPixbuf **icon)
{
gpointer data;
- NameIcon * item;
+ NameIcon *item;
data = g_hash_table_lookup (obj->priv->bookmarks_hash, file);
@@ -537,17 +546,18 @@ get_from_bookmark_file (GeditFileBrowserWidget * obj, GFile * file,
}
static void
-insert_path_item (GeditFileBrowserWidget * obj,
- GFile * file,
- GtkTreeIter * after,
- GtkTreeIter * iter,
- guint indent)
+insert_path_item (GeditFileBrowserWidget *obj,
+ GFile *file,
+ GtkTreeIter *after,
+ GtkTreeIter *iter,
+ guint indent)
{
- gchar * unescape;
- GdkPixbuf * icon = NULL;
+ gchar *unescape;
+ GdkPixbuf *icon = NULL;
/* Try to get the icon and name from the bookmarks hash */
- if (!get_from_bookmark_file (obj, file, &unescape, &icon)) {
+ if (!get_from_bookmark_file (obj, file, &unescape, &icon))
+ {
/* It's not a bookmark, fetch the name and the icon ourselves */
unescape = gedit_file_browser_utils_file_basename (file);
@@ -574,7 +584,7 @@ insert_path_item (GeditFileBrowserWidget * obj,
}
static void
-insert_separator_item (GeditFileBrowserWidget * obj)
+insert_separator_item (GeditFileBrowserWidget *obj)
{
GtkTreeIter iter;
@@ -586,7 +596,8 @@ insert_separator_item (GeditFileBrowserWidget * obj)
}
static void
-combo_set_active_by_id (GeditFileBrowserWidget * obj, guint id)
+combo_set_active_by_id (GeditFileBrowserWidget *obj,
+ guint id)
{
GtkTreeIter iter;
@@ -596,18 +607,20 @@ combo_set_active_by_id (GeditFileBrowserWidget * obj, guint id)
}
static guint
-uri_num_parents (GFile * from, GFile * to)
+uri_num_parents (GFile *from,
+ GFile *to)
{
/* Determine the number of 'levels' to get from #from to #to. */
guint parents = 0;
- GFile * parent;
+ GFile *parent;
if (from == NULL)
return 0;
g_object_ref (from);
- while ((parent = g_file_get_parent (from)) && !(to && g_file_equal (from, to))) {
+ while ((parent = g_file_get_parent (from)) && !(to && g_file_equal (from, to)))
+ {
g_object_unref (from);
from = parent;
@@ -619,16 +632,17 @@ uri_num_parents (GFile * from, GFile * to)
}
static void
-insert_location_path (GeditFileBrowserWidget * obj)
+insert_location_path (GeditFileBrowserWidget *obj)
{
Location *loc;
GFile *current = NULL;
- GFile * tmp;
+ GFile *tmp;
GtkTreeIter separator;
GtkTreeIter iter;
guint indent;
- if (!obj->priv->current_location) {
+ if (!obj->priv->current_location)
+ {
g_message ("insert_location_path: no current location");
return;
}
@@ -640,10 +654,12 @@ insert_location_path (GeditFileBrowserWidget * obj)
indent = uri_num_parents (loc->virtual_root, loc->root);
- while (current != NULL) {
+ while (current != NULL)
+ {
insert_path_item (obj, current, &separator, &iter, indent--);
- if (current == loc->virtual_root) {
+ if (current == loc->virtual_root)
+ {
g_signal_handlers_block_by_func (obj->priv->combo,
on_combo_changed,
obj);
@@ -656,7 +672,8 @@ insert_location_path (GeditFileBrowserWidget * obj)
obj);
}
- if (g_file_equal (current, loc->root) || !gedit_utils_file_has_parent (current)) {
+ if (g_file_equal (current, loc->root) || !gedit_utils_file_has_parent (current))
+ {
if (current != loc->virtual_root)
g_object_unref (current);
break;
@@ -672,7 +689,8 @@ insert_location_path (GeditFileBrowserWidget * obj)
}
static void
-check_current_item (GeditFileBrowserWidget * obj, gboolean show_path)
+check_current_item (GeditFileBrowserWidget *obj,
+ gboolean show_path)
{
GtkTreeIter separator;
gboolean has_sep;
@@ -680,17 +698,21 @@ check_current_item (GeditFileBrowserWidget * obj, gboolean show_path)
remove_path_items (obj);
has_sep = combo_find_by_id (obj, SEPARATOR_ID, &separator);
- if (show_path) {
+ if (show_path)
+ {
if (!has_sep)
insert_separator_item (obj);
insert_location_path (obj);
- } else if (has_sep)
+ }
+ else if (has_sep)
+ {
gtk_tree_store_remove (obj->priv->combo_model, &separator);
+ }
}
static void
-fill_combo_model (GeditFileBrowserWidget * obj)
+fill_combo_model (GeditFileBrowserWidget *obj)
{
GtkTreeStore *store = obj->priv->combo_model;
GtkTreeIter iter;
@@ -711,21 +733,24 @@ fill_combo_model (GeditFileBrowserWidget * obj)
}
static void
-indent_cell_data_func (GtkCellLayout * cell_layout,
- GtkCellRenderer * cell,
- GtkTreeModel * model,
- GtkTreeIter * iter,
- gpointer data)
+indent_cell_data_func (GtkCellLayout *cell_layout,
+ GtkCellRenderer *cell,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer data)
{
- gchar * indent;
+ gchar *indent;
guint num;
gtk_tree_model_get (model, iter, COLUMN_INDENT, &num, -1);
if (num == 0)
+ {
g_object_set (cell, "text", "", NULL);
- else {
- indent = g_strnfill (num * 2, ' ');
+ }
+ else
+ {
+ indent = g_strnfill (num *2, ' ');
g_object_set (cell, "text", indent, NULL);
g_free (indent);
@@ -733,7 +758,7 @@ indent_cell_data_func (GtkCellLayout * cell_layout,
}
static void
-create_combo (GeditFileBrowserWidget * obj)
+create_combo (GeditFileBrowserWidget *obj)
{
GtkCellRenderer *renderer;
@@ -857,8 +882,8 @@ static const GtkActionEntry bookmark_actions[] =
};
static void
-create_toolbar (GeditFileBrowserWidget * obj,
- const gchar *data_dir)
+create_toolbar (GeditFileBrowserWidget *obj,
+ const gchar *data_dir)
{
GtkUIManager *manager;
GError *error = NULL;
@@ -876,7 +901,8 @@ create_toolbar (GeditFileBrowserWidget * obj,
g_free (ui_file);
- if (error != NULL) {
+ if (error != NULL)
+ {
g_warning ("Error in adding ui from file %s: %s",
XML_UI_FILE, error->message);
g_error_free (error);
@@ -1020,7 +1046,7 @@ create_toolbar (GeditFileBrowserWidget * obj,
static void
set_enable_delete (GeditFileBrowserWidget *obj,
- gboolean enable)
+ gboolean enable)
{
GtkAction *action;
obj->priv->enable_delete = enable;
@@ -1028,21 +1054,22 @@ set_enable_delete (GeditFileBrowserWidget *obj,
if (obj->priv->action_group_selection == NULL)
return;
- action =
- gtk_action_group_get_action (obj->priv->action_group_selection,
- "FileDelete");
+ action = gtk_action_group_get_action (obj->priv->action_group_selection,
+ "FileDelete");
g_object_set (action, "visible", enable, "sensitive", enable, NULL);
}
static gboolean
-filter_real (GeditFileBrowserStore * model, GtkTreeIter * iter,
- GeditFileBrowserWidget * obj)
+filter_real (GeditFileBrowserStore *model,
+ GtkTreeIter *iter,
+ GeditFileBrowserWidget *obj)
{
GSList *item;
FilterFunc *func;
- for (item = obj->priv->filter_funcs; item; item = item->next) {
+ for (item = obj->priv->filter_funcs; item; item = item->next)
+ {
func = (FilterFunc *) (item->data);
if (!func->func (obj, model, iter, func->user_data))
@@ -1053,14 +1080,14 @@ filter_real (GeditFileBrowserStore * model, GtkTreeIter * iter,
}
static void
-add_bookmark_hash (GeditFileBrowserWidget * obj,
- GtkTreeIter * iter)
+add_bookmark_hash (GeditFileBrowserWidget *obj,
+ GtkTreeIter *iter)
{
GtkTreeModel *model;
- GdkPixbuf * pixbuf;
- gchar * name;
- GFile * location;
- NameIcon * item;
+ GdkPixbuf *pixbuf;
+ gchar *name;
+ GFile *location;
+ NameIcon *item;
model = GTK_TREE_MODEL (obj->priv->bookmarks_store);
@@ -1087,7 +1114,7 @@ add_bookmark_hash (GeditFileBrowserWidget * obj,
}
static void
-init_bookmarks_hash (GeditFileBrowserWidget * obj)
+init_bookmarks_hash (GeditFileBrowserWidget *obj)
{
GtkTreeIter iter;
GtkTreeModel *model;
@@ -1097,9 +1124,11 @@ init_bookmarks_hash (GeditFileBrowserWidget * obj)
if (!gtk_tree_model_get_iter_first (model, &iter))
return;
- do {
+ do
+ {
add_bookmark_hash (obj, &iter);
- } while (gtk_tree_model_iter_next (model, &iter));
+ }
+ while (gtk_tree_model_iter_next (model, &iter));
g_signal_connect (obj->priv->bookmarks_store,
"row-changed",
@@ -1136,7 +1165,7 @@ on_end_loading (GeditFileBrowserStore *model,
}
static void
-create_tree (GeditFileBrowserWidget * obj)
+create_tree (GeditFileBrowserWidget *obj)
{
GtkWidget *sw;
@@ -1203,7 +1232,7 @@ create_tree (GeditFileBrowserWidget * obj)
}
static void
-create_filter (GeditFileBrowserWidget * obj)
+create_filter (GeditFileBrowserWidget *obj)
{
GtkWidget *expander;
GtkWidget *vbox;
@@ -1235,7 +1264,7 @@ create_filter (GeditFileBrowserWidget * obj)
}
static void
-gedit_file_browser_widget_init (GeditFileBrowserWidget * obj)
+gedit_file_browser_widget_init (GeditFileBrowserWidget *obj)
{
obj->priv = GEDIT_FILE_BROWSER_WIDGET_GET_PRIVATE (obj);
@@ -1252,14 +1281,15 @@ gedit_file_browser_widget_init (GeditFileBrowserWidget * obj)
/* Private */
static void
-update_sensitivity (GeditFileBrowserWidget * obj)
+update_sensitivity (GeditFileBrowserWidget *obj)
{
GtkTreeModel *model =
gtk_tree_view_get_model (GTK_TREE_VIEW (obj->priv->treeview));
GtkAction *action;
gint mode;
- if (GEDIT_IS_FILE_BROWSER_STORE (model)) {
+ if (GEDIT_IS_FILE_BROWSER_STORE (model))
+ {
gtk_action_group_set_sensitive (obj->priv->action_group,
TRUE);
gtk_action_group_set_sensitive (obj->priv->bookmark_action_group,
@@ -1275,16 +1305,17 @@ update_sensitivity (GeditFileBrowserWidget * obj)
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
!(mode &
GEDIT_FILE_BROWSER_STORE_FILTER_MODE_HIDE_HIDDEN));
- } else if (GEDIT_IS_FILE_BOOKMARKS_STORE (model)) {
+ }
+ else if (GEDIT_IS_FILE_BOOKMARKS_STORE (model))
+ {
gtk_action_group_set_sensitive (obj->priv->action_group,
FALSE);
gtk_action_group_set_sensitive (obj->priv->bookmark_action_group,
TRUE);
/* Set the filter toggle to normal up state, just for visual pleasure */
- action =
- gtk_action_group_get_action (obj->priv->action_group,
- "FilterHidden");
+ action = gtk_action_group_get_action (obj->priv->action_group,
+ "FilterHidden");
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
FALSE);
}
@@ -1295,7 +1326,7 @@ update_sensitivity (GeditFileBrowserWidget * obj)
static gboolean
gedit_file_browser_widget_get_first_selected (GeditFileBrowserWidget *obj,
- GtkTreeIter *iter)
+ GtkTreeIter *iter)
{
GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (obj->priv->treeview));
GtkTreeModel *model;
@@ -1314,7 +1345,9 @@ gedit_file_browser_widget_get_first_selected (GeditFileBrowserWidget *obj,
}
static gboolean
-popup_menu (GeditFileBrowserWidget * obj, GdkEventButton * event, GtkTreeModel * model)
+popup_menu (GeditFileBrowserWidget *obj,
+ GdkEventButton *event,
+ GtkTreeModel *model)
{
GtkWidget *menu;
@@ -1327,11 +1360,13 @@ popup_menu (GeditFileBrowserWidget * obj, GdkEventButton * event, GtkTreeModel *
g_return_val_if_fail (menu != NULL, FALSE);
- if (event != NULL) {
+ if (event != NULL)
+ {
GtkTreeSelection *selection;
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (obj->priv->treeview));
- if (gtk_tree_selection_count_selected_rows (selection) <= 1) {
+ if (gtk_tree_selection_count_selected_rows (selection) <= 1)
+ {
GtkTreePath *path;
if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (obj->priv->treeview),
@@ -1346,7 +1381,9 @@ popup_menu (GeditFileBrowserWidget * obj, GdkEventButton * event, GtkTreeModel *
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
event->button, event->time);
- } else {
+ }
+ else
+ {
gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
gedit_utils_menu_position_under_tree_view,
obj->priv->treeview, 0,
@@ -1358,8 +1395,10 @@ popup_menu (GeditFileBrowserWidget * obj, GdkEventButton * event, GtkTreeModel *
}
static gboolean
-filter_glob (GeditFileBrowserWidget * obj, GeditFileBrowserStore * store,
- GtkTreeIter * iter, gpointer user_data)
+filter_glob (GeditFileBrowserWidget *obj,
+ GeditFileBrowserStore *store,
+ GtkTreeIter *iter,
+ gpointer user_data)
{
gchar *name;
gboolean result;
@@ -1376,9 +1415,8 @@ filter_glob (GeditFileBrowserWidget * obj, GeditFileBrowserStore * store,
if (FILE_IS_DIR (flags) || FILE_IS_DUMMY (flags))
result = TRUE;
else
- result =
- g_pattern_match_string (obj->priv->filter_pattern,
- name);
+ result = g_pattern_match_string (obj->priv->filter_pattern,
+ name);
g_free (name);
@@ -1386,7 +1424,7 @@ filter_glob (GeditFileBrowserWidget * obj, GeditFileBrowserStore * store,
}
static void
-rename_selected_file (GeditFileBrowserWidget * obj)
+rename_selected_file (GeditFileBrowserWidget *obj)
{
GtkTreeModel *model;
GtkTreeIter iter;
@@ -1418,7 +1456,8 @@ get_deletable_files (GeditFileBrowserWidget *obj) {
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (obj->priv->treeview));
rows = gtk_tree_selection_get_selected_rows (selection, &model);
- for (row = rows; row; row = row->next) {
+ for (row = rows; row; row = row->next)
+ {
path = (GtkTreePath *)(row->data);
if (!gtk_tree_model_get_iter (model, &iter, path))
@@ -1441,7 +1480,8 @@ get_deletable_files (GeditFileBrowserWidget *obj) {
}
static gboolean
-delete_selected_files (GeditFileBrowserWidget * obj, gboolean trash)
+delete_selected_files (GeditFileBrowserWidget *obj,
+ gboolean trash)
{
GtkTreeModel *model;
gboolean confirm;
@@ -1458,7 +1498,8 @@ delete_selected_files (GeditFileBrowserWidget * obj, gboolean trash)
if (!rows)
return FALSE;
- if (!trash) {
+ if (!trash)
+ {
g_signal_emit (obj, signals[CONFIRM_DELETE], 0, model, rows, &confirm);
if (!confirm)
@@ -1475,9 +1516,9 @@ delete_selected_files (GeditFileBrowserWidget * obj, gboolean trash)
}
static gboolean
-on_file_store_no_trash (GeditFileBrowserStore * store,
- GList * files,
- GeditFileBrowserWidget * obj)
+on_file_store_no_trash (GeditFileBrowserStore *store,
+ GList *files,
+ GeditFileBrowserWidget *obj)
{
gboolean confirm = FALSE;
@@ -1487,14 +1528,15 @@ on_file_store_no_trash (GeditFileBrowserStore * store,
}
static GFile *
-get_topmost_file (GFile * file)
+get_topmost_file (GFile *file)
{
- GFile * tmp;
- GFile * current;
+ GFile *tmp;
+ GFile *current;
current = g_object_ref (file);
- while ((tmp = g_file_get_parent (current)) != NULL) {
+ while ((tmp = g_file_get_parent (current)) != NULL)
+ {
g_object_unref (current);
current = tmp;
}
@@ -1503,8 +1545,9 @@ get_topmost_file (GFile * file)
}
static GtkWidget *
-create_goto_menu_item (GeditFileBrowserWidget * obj, GList * item,
- GdkPixbuf * icon)
+create_goto_menu_item (GeditFileBrowserWidget *obj,
+ GList *item,
+ GdkPixbuf *icon)
{
GtkWidget *result;
GtkWidget *image;
@@ -1514,14 +1557,16 @@ create_goto_menu_item (GeditFileBrowserWidget * obj, GList * item,
loc = (Location *) (item->data);
- if (!get_from_bookmark_file (obj, loc->virtual_root, &unescape, &pixbuf)) {
+ if (!get_from_bookmark_file (obj, loc->virtual_root, &unescape, &pixbuf))
+ {
unescape = gedit_file_browser_utils_file_basename (loc->virtual_root);
if (icon)
pixbuf = g_object_ref (icon);
}
- if (pixbuf) {
+ if (pixbuf)
+ {
image = gtk_image_new_from_pixbuf (pixbuf);
g_object_unref (pixbuf);
@@ -1530,7 +1575,9 @@ create_goto_menu_item (GeditFileBrowserWidget * obj, GList * item,
result = gtk_image_menu_item_new_with_label (unescape);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (result),
image);
- } else {
+ }
+ else
+ {
result = gtk_menu_item_new_with_label (unescape);
}
@@ -1546,7 +1593,7 @@ create_goto_menu_item (GeditFileBrowserWidget * obj, GList * item,
}
static GList *
-list_next_iterator (GList * list)
+list_next_iterator (GList *list)
{
if (!list)
return NULL;
@@ -1555,7 +1602,7 @@ list_next_iterator (GList * list)
}
static GList *
-list_prev_iterator (GList * list)
+list_prev_iterator (GList *list)
{
if (!list)
return NULL;
@@ -1564,8 +1611,9 @@ list_prev_iterator (GList * list)
}
static void
-jump_to_location (GeditFileBrowserWidget * obj, GList * item,
- gboolean previous)
+jump_to_location (GeditFileBrowserWidget *obj,
+ GList *item,
+ gboolean previous)
{
Location *loc;
GtkWidget *widget;
@@ -1578,11 +1626,14 @@ jump_to_location (GeditFileBrowserWidget * obj, GList * item,
if (!obj->priv->locations)
return;
- if (previous) {
+ if (previous)
+ {
iter_func = list_next_iterator;
menu_from = obj->priv->location_previous_menu;
menu_to = obj->priv->location_next_menu;
- } else {
+ }
+ else
+ {
iter_func = list_prev_iterator;
menu_from = obj->priv->location_next_menu;
menu_to = obj->priv->location_previous_menu;
@@ -1595,8 +1646,10 @@ jump_to_location (GeditFileBrowserWidget * obj, GList * item,
to be added to the menu */
widget = obj->priv->current_location_menu_item;
- while (obj->priv->current_location != item) {
- if (widget) {
+ while (obj->priv->current_location != item)
+ {
+ if (widget)
+ {
/* Prepend the menu item to the menu */
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu_to),
widget);
@@ -1612,12 +1665,15 @@ jump_to_location (GeditFileBrowserWidget * obj, GList * item,
obj->priv->current_location_menu_item = widget;
- if (obj->priv->current_location == NULL) {
+ if (obj->priv->current_location == NULL)
+ {
obj->priv->current_location = obj->priv->locations;
if (obj->priv->current_location == item)
break;
- } else {
+ }
+ else
+ {
obj->priv->current_location =
iter_func (obj->priv->current_location);
}
@@ -1640,7 +1696,7 @@ jump_to_location (GeditFileBrowserWidget * obj, GList * item,
}
static void
-clear_next_locations (GeditFileBrowserWidget * obj)
+clear_next_locations (GeditFileBrowserWidget *obj)
{
GList *children;
GList *item;
@@ -1648,23 +1704,21 @@ clear_next_locations (GeditFileBrowserWidget * obj)
if (obj->priv->current_location == NULL)
return;
- while (obj->priv->current_location->prev) {
- location_free ((Location *) (obj->priv->current_location->
- prev->data));
+ while (obj->priv->current_location->prev)
+ {
+ location_free ((Location *) (obj->priv->current_location->prev->data));
obj->priv->locations =
g_list_remove_link (obj->priv->locations,
obj->priv->current_location->prev);
}
- children =
- gtk_container_get_children (GTK_CONTAINER
- (obj->priv->location_next_menu));
+ children = gtk_container_get_children (GTK_CONTAINER
+ (obj->priv->location_next_menu));
- for (item = children; item; item = item->next) {
+ for (item = children; item; item = item->next)
gtk_container_remove (GTK_CONTAINER
(obj->priv->location_next_menu),
GTK_WIDGET (item->data));
- }
g_list_free (children);
@@ -1674,9 +1728,9 @@ clear_next_locations (GeditFileBrowserWidget * obj)
}
static void
-update_filter_mode (GeditFileBrowserWidget * obj,
- GtkAction * action,
- GeditFileBrowserStoreFilterMode mode)
+update_filter_mode (GeditFileBrowserWidget *obj,
+ GtkAction *action,
+ GeditFileBrowserStoreFilterMode mode)
{
gboolean active =
gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
@@ -1684,7 +1738,8 @@ update_filter_mode (GeditFileBrowserWidget * obj,
gtk_tree_view_get_model (GTK_TREE_VIEW (obj->priv->treeview));
gint now;
- if (GEDIT_IS_FILE_BROWSER_STORE (model)) {
+ if (GEDIT_IS_FILE_BROWSER_STORE (model))
+ {
now =
gedit_file_browser_store_get_filter_mode
(GEDIT_FILE_BROWSER_STORE (model));
@@ -1700,9 +1755,9 @@ update_filter_mode (GeditFileBrowserWidget * obj,
}
static void
-set_filter_pattern_real (GeditFileBrowserWidget * obj,
- gchar const * pattern,
- gboolean update_entry)
+set_filter_pattern_real (GeditFileBrowserWidget *obj,
+ gchar const *pattern,
+ gboolean update_entry)
{
GtkTreeModel *model;
@@ -1723,20 +1778,23 @@ set_filter_pattern_real (GeditFileBrowserWidget * obj,
g_free (obj->priv->filter_pattern_str);
obj->priv->filter_pattern_str = g_strdup (pattern);
- if (obj->priv->filter_pattern) {
+ if (obj->priv->filter_pattern)
+ {
g_pattern_spec_free (obj->priv->filter_pattern);
obj->priv->filter_pattern = NULL;
}
- if (pattern == NULL) {
- if (obj->priv->glob_filter_id != 0) {
+ if (pattern == NULL)
+ {
+ if (obj->priv->glob_filter_id != 0)
+ {
gedit_file_browser_widget_remove_filter (obj,
- obj->
- priv->
- glob_filter_id);
+ obj->priv->glob_filter_id);
obj->priv->glob_filter_id = 0;
}
- } else {
+ }
+ else
+ {
obj->priv->filter_pattern = g_pattern_spec_new (pattern);
if (obj->priv->glob_filter_id == 0)
@@ -1747,11 +1805,13 @@ set_filter_pattern_real (GeditFileBrowserWidget * obj,
NULL);
}
- if (update_entry) {
+ if (update_entry)
+ {
if (obj->priv->filter_pattern_str == NULL)
gtk_entry_set_text (GTK_ENTRY (obj->priv->filter_entry),
"");
- else {
+ else
+ {
gtk_entry_set_text (GTK_ENTRY (obj->priv->filter_entry),
obj->priv->filter_pattern_str);
@@ -1787,7 +1847,7 @@ gedit_file_browser_widget_new (const gchar *data_dir)
}
void
-gedit_file_browser_widget_show_bookmarks (GeditFileBrowserWidget * obj)
+gedit_file_browser_widget_show_bookmarks (GeditFileBrowserWidget *obj)
{
/* Select bookmarks in the combo box */
g_signal_handlers_block_by_func (obj->priv->combo,
@@ -1799,8 +1859,7 @@ gedit_file_browser_widget_show_bookmarks (GeditFileBrowserWidget * obj)
check_current_item (obj, FALSE);
gedit_file_browser_view_set_model (obj->priv->treeview,
- GTK_TREE_MODEL (obj->priv->
- bookmarks_store));
+ GTK_TREE_MODEL (obj->priv->bookmarks_store));
}
static void
@@ -1808,47 +1867,45 @@ show_files_real (GeditFileBrowserWidget *obj,
gboolean do_root_changed)
{
gedit_file_browser_view_set_model (obj->priv->treeview,
- GTK_TREE_MODEL (obj->priv->
- file_store));
+ GTK_TREE_MODEL (obj->priv->file_store));
if (do_root_changed)
on_virtual_root_changed (obj->priv->file_store, NULL, obj);
}
void
-gedit_file_browser_widget_show_files (GeditFileBrowserWidget * obj)
+gedit_file_browser_widget_show_files (GeditFileBrowserWidget *obj)
{
show_files_real (obj, TRUE);
}
void
gedit_file_browser_widget_set_root_and_virtual_root (GeditFileBrowserWidget *obj,
- GFile *root,
- GFile *virtual_root)
+ GFile *root,
+ GFile *virtual_root)
{
GeditFileBrowserStoreResult result;
if (!virtual_root)
- result =
- gedit_file_browser_store_set_root_and_virtual_root
- (obj->priv->file_store, root, root);
+ result = gedit_file_browser_store_set_root_and_virtual_root
+ (obj->priv->file_store, root, root);
else
- result =
- gedit_file_browser_store_set_root_and_virtual_root
- (obj->priv->file_store, root, virtual_root);
+ result = gedit_file_browser_store_set_root_and_virtual_root
+ (obj->priv->file_store, root, virtual_root);
if (result == GEDIT_FILE_BROWSER_STORE_RESULT_NO_CHANGE)
show_files_real (obj, TRUE);
}
void
-gedit_file_browser_widget_set_root (GeditFileBrowserWidget * obj,
- GFile *root,
- gboolean virtual_root)
+gedit_file_browser_widget_set_root (GeditFileBrowserWidget *obj,
+ GFile *root,
+ gboolean virtual_root)
{
GFile *parent;
- if (!virtual_root) {
+ if (!virtual_root)
+ {
gedit_file_browser_widget_set_root_and_virtual_root (obj,
root,
NULL);
@@ -1867,59 +1924,57 @@ gedit_file_browser_widget_set_root (GeditFileBrowserWidget * obj,
}
GeditFileBrowserStore *
-gedit_file_browser_widget_get_browser_store (GeditFileBrowserWidget * obj)
+gedit_file_browser_widget_get_browser_store (GeditFileBrowserWidget *obj)
{
return obj->priv->file_store;
}
GeditFileBookmarksStore *
-gedit_file_browser_widget_get_bookmarks_store (GeditFileBrowserWidget * obj)
+gedit_file_browser_widget_get_bookmarks_store (GeditFileBrowserWidget *obj)
{
return obj->priv->bookmarks_store;
}
GeditFileBrowserView *
-gedit_file_browser_widget_get_browser_view (GeditFileBrowserWidget * obj)
+gedit_file_browser_widget_get_browser_view (GeditFileBrowserWidget *obj)
{
return obj->priv->treeview;
}
GtkUIManager *
-gedit_file_browser_widget_get_ui_manager (GeditFileBrowserWidget * obj)
+gedit_file_browser_widget_get_ui_manager (GeditFileBrowserWidget *obj)
{
return obj->priv->manager;
}
GtkWidget *
-gedit_file_browser_widget_get_filter_entry (GeditFileBrowserWidget * obj)
+gedit_file_browser_widget_get_filter_entry (GeditFileBrowserWidget *obj)
{
return obj->priv->filter_entry;
}
gulong
-gedit_file_browser_widget_add_filter (GeditFileBrowserWidget * obj,
- GeditFileBrowserWidgetFilterFunc func,
- gpointer user_data,
- GDestroyNotify notify)
+gedit_file_browser_widget_add_filter (GeditFileBrowserWidget *obj,
+ GeditFileBrowserWidgetFilterFunc func,
+ gpointer user_data,
+ GDestroyNotify notify)
{
FilterFunc *f;
GtkTreeModel *model =
gtk_tree_view_get_model (GTK_TREE_VIEW (obj->priv->treeview));
f = filter_func_new (obj, func, user_data, notify);
- obj->priv->filter_funcs =
- g_slist_append (obj->priv->filter_funcs, f);
+ obj->priv->filter_funcs = g_slist_append (obj->priv->filter_funcs, f);
if (GEDIT_IS_FILE_BROWSER_STORE (model))
- gedit_file_browser_store_refilter (GEDIT_FILE_BROWSER_STORE
- (model));
+ gedit_file_browser_store_refilter (GEDIT_FILE_BROWSER_STORE (model));
return f->id;
}
void
-gedit_file_browser_widget_remove_filter (GeditFileBrowserWidget * obj,
- gulong id)
+gedit_file_browser_widget_remove_filter (GeditFileBrowserWidget *obj,
+ gulong id)
{
GSList *item;
FilterFunc *func;
@@ -1943,15 +1998,15 @@ gedit_file_browser_widget_remove_filter (GeditFileBrowserWidget * obj,
}
void
-gedit_file_browser_widget_set_filter_pattern (GeditFileBrowserWidget * obj,
- gchar const *pattern)
+gedit_file_browser_widget_set_filter_pattern (GeditFileBrowserWidget *obj,
+ gchar const *pattern)
{
set_filter_pattern_real (obj, pattern, TRUE);
}
gboolean
-gedit_file_browser_widget_get_selected_directory (GeditFileBrowserWidget * obj,
- GtkTreeIter * iter)
+gedit_file_browser_widget_get_selected_directory (GeditFileBrowserWidget *obj,
+ GtkTreeIter *iter)
{
GtkTreeModel *model =
gtk_tree_view_get_model (GTK_TREE_VIEW (obj->priv->treeview));
@@ -1961,17 +2016,17 @@ gedit_file_browser_widget_get_selected_directory (GeditFileBrowserWidget * obj,
if (!GEDIT_IS_FILE_BROWSER_STORE (model))
return FALSE;
- if (!gedit_file_browser_widget_get_first_selected (obj, iter)) {
- if (!gedit_file_browser_store_get_iter_virtual_root
- (GEDIT_FILE_BROWSER_STORE (model), iter))
- return FALSE;
- }
+ if (!gedit_file_browser_widget_get_first_selected (obj, iter) &&
+ !gedit_file_browser_store_get_iter_virtual_root
+ (GEDIT_FILE_BROWSER_STORE (model), iter))
+ return FALSE;
gtk_tree_model_get (model, iter,
GEDIT_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags,
-1);
- if (!FILE_IS_DIR (flags)) {
+ if (!FILE_IS_DIR (flags))
+ {
/* Get the parent, because the selection is a file */
gtk_tree_model_iter_parent (model, &parent, iter);
*iter = parent;
@@ -2001,7 +2056,8 @@ gedit_file_browser_widget_get_num_selected_files_or_directories (GeditFileBrowse
rows = gtk_tree_selection_get_selected_rows (selection, &model);
- for (row = rows; row; row = row->next) {
+ for (row = rows; row; row = row->next)
+ {
path = (GtkTreePath *)(row->data);
/* Get iter from path */
@@ -2012,7 +2068,8 @@ gedit_file_browser_widget_get_num_selected_files_or_directories (GeditFileBrowse
GEDIT_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags,
-1);
- if (!FILE_IS_DUMMY (flags)) {
+ if (!FILE_IS_DUMMY (flags))
+ {
if (!FILE_IS_DIR (flags))
++(*files);
else
@@ -2058,7 +2115,8 @@ async_free (AsyncData *async)
}
static void
-set_busy (GeditFileBrowserWidget *obj, gboolean busy)
+set_busy (GeditFileBrowserWidget *obj,
+ gboolean busy)
{
GdkCursor *cursor;
GdkWindow *window;
@@ -2304,9 +2362,12 @@ gedit_file_browser_widget_refresh (GeditFileBrowserWidget *obj)
gtk_tree_view_get_model (GTK_TREE_VIEW (obj->priv->treeview));
if (GEDIT_IS_FILE_BROWSER_STORE (model))
+ {
gedit_file_browser_store_refresh (GEDIT_FILE_BROWSER_STORE
(model));
- else if (GEDIT_IS_FILE_BOOKMARKS_STORE (model)) {
+ }
+ else if (GEDIT_IS_FILE_BOOKMARKS_STORE (model))
+ {
g_hash_table_ref (obj->priv->bookmarks_hash);
g_hash_table_destroy (obj->priv->bookmarks_hash);
@@ -2318,14 +2379,14 @@ gedit_file_browser_widget_refresh (GeditFileBrowserWidget *obj)
void
gedit_file_browser_widget_history_back (GeditFileBrowserWidget *obj)
{
- if (obj->priv->locations) {
+ if (obj->priv->locations)
+ {
if (obj->priv->current_location)
jump_to_location (obj,
- obj->priv->current_location->
- next, TRUE);
- else {
+ obj->priv->current_location->next,
+ TRUE);
+ else
jump_to_location (obj, obj->priv->locations, TRUE);
- }
}
}
@@ -2364,29 +2425,30 @@ bookmark_open (GeditFileBrowserWidget *obj,
return;
}
- location =
- gedit_file_bookmarks_store_get_location
- (GEDIT_FILE_BOOKMARKS_STORE (model), iter);
+ location = gedit_file_bookmarks_store_get_location
+ (GEDIT_FILE_BOOKMARKS_STORE (model), iter);
- if (location) {
+ if (location)
+ {
/* here we check if the bookmark is a mount point, or if it
is a remote bookmark. If that's the case, we will set the
root to the uri of the bookmark and not try to set the
topmost parent as root (since that may as well not be the
mount point anymore) */
if ((flags & GEDIT_FILE_BOOKMARKS_STORE_IS_MOUNT) ||
- (flags & GEDIT_FILE_BOOKMARKS_STORE_IS_REMOTE_BOOKMARK)) {
+ (flags & GEDIT_FILE_BOOKMARKS_STORE_IS_REMOTE_BOOKMARK))
gedit_file_browser_widget_set_root (obj,
location,
FALSE);
- } else {
+ else
gedit_file_browser_widget_set_root (obj,
location,
TRUE);
- }
g_object_unref (location);
- } else {
+ }
+ else
+ {
g_warning ("No uri!");
}
}
@@ -2404,7 +2466,8 @@ file_open (GeditFileBrowserWidget *obj,
GEDIT_FILE_BROWSER_STORE_COLUMN_LOCATION, &location,
-1);
- if (!FILE_IS_DIR (flags) && !FILE_IS_DUMMY (flags)) {
+ if (!FILE_IS_DIR (flags) && !FILE_IS_DUMMY (flags))
+ {
g_signal_emit (obj, signals[LOCATION_ACTIVATED], 0, location);
}
}
@@ -2424,13 +2487,15 @@ directory_open (GeditFileBrowserWidget *obj,
GEDIT_FILE_BROWSER_STORE_COLUMN_LOCATION, &location,
-1);
- if (FILE_IS_DIR (flags) && location) {
+ if (FILE_IS_DIR (flags) && location)
+ {
gchar *uri;
result = TRUE;
uri = g_file_get_uri (location);
- if (!gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (obj)), uri, GDK_CURRENT_TIME, &error)) {
+ if (!gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (obj)), uri, GDK_CURRENT_TIME, &error))
+ {
g_signal_emit (obj, signals[ERROR], 0,
GEDIT_FILE_BROWSER_ERROR_OPEN_DIRECTORY,
error->message);
@@ -2466,8 +2531,8 @@ on_file_activated (GeditFileBrowserView *tree_view,
}
static gboolean
-virtual_root_is_root (GeditFileBrowserWidget * obj,
- GeditFileBrowserStore * model)
+virtual_root_is_root (GeditFileBrowserWidget *obj,
+ GeditFileBrowserStore *model)
{
GtkTreeIter root;
GtkTreeIter virtual_root;
@@ -2482,9 +2547,9 @@ virtual_root_is_root (GeditFileBrowserWidget * obj,
}
static void
-on_virtual_root_changed (GeditFileBrowserStore * model,
- GParamSpec * param,
- GeditFileBrowserWidget * obj)
+on_virtual_root_changed (GeditFileBrowserStore *model,
+ GParamSpec *param,
+ GeditFileBrowserWidget *obj)
{
GtkTreeIter iter;
GFile *location;
@@ -2495,17 +2560,18 @@ on_virtual_root_changed (GeditFileBrowserStore * model,
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)) {
+ 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_LOCATION,
&location, -1);
- if (gedit_file_browser_store_get_iter_root (model, &root)) {
- if (!obj->priv->changing_location) {
+ if (gedit_file_browser_store_get_iter_root (model, &root))
+ {
+ if (!obj->priv->changing_location)
+ {
/* Remove all items from obj->priv->current_location on */
if (obj->priv->current_location)
clear_next_locations (obj);
@@ -2514,15 +2580,14 @@ on_virtual_root_changed (GeditFileBrowserStore * model,
loc->root = gedit_file_browser_store_get_root (model);
loc->virtual_root = g_object_ref (location);
- if (obj->priv->current_location) {
+ if (obj->priv->current_location)
+ {
/* Add current location to the menu so we can go back
to it later */
gtk_menu_shell_prepend
(GTK_MENU_SHELL
- (obj->priv->
- location_previous_menu),
- obj->priv->
- current_location_menu_item);
+ (obj->priv->location_previous_menu),
+ obj->priv->current_location_menu_item);
}
obj->priv->locations =
@@ -2538,57 +2603,45 @@ on_virtual_root_changed (GeditFileBrowserStore * model,
obj->priv->locations;
obj->priv->current_location_menu_item =
create_goto_menu_item (obj,
- obj->priv->
- current_location,
+ obj->priv->current_location,
pixbuf);
- g_object_ref_sink (obj->priv->
- current_location_menu_item);
+ g_object_ref_sink (obj->priv->current_location_menu_item);
if (pixbuf)
g_object_unref (pixbuf);
}
- action =
- gtk_action_group_get_action (obj->priv->
- action_group,
- "DirectoryUp");
+ action = gtk_action_group_get_action (obj->priv->action_group,
+ "DirectoryUp");
gtk_action_set_sensitive (action,
!virtual_root_is_root (obj, model));
- action =
- gtk_action_group_get_action (obj->priv->
- action_group_sensitive,
- "DirectoryPrevious");
+ action = gtk_action_group_get_action (obj->priv->action_group_sensitive,
+ "DirectoryPrevious");
gtk_action_set_sensitive (action,
- obj->priv->
- current_location != NULL
- && obj->priv->
- current_location->next !=
- NULL);
-
- action =
- gtk_action_group_get_action (obj->priv->
- action_group_sensitive,
- "DirectoryNext");
+ obj->priv->current_location != NULL &&
+ obj->priv->current_location->next != NULL);
+
+ action = gtk_action_group_get_action (obj->priv->action_group_sensitive,
+ "DirectoryNext");
gtk_action_set_sensitive (action,
- obj->priv->
- current_location != NULL
- && obj->priv->
- current_location->prev !=
- NULL);
+ obj->priv->current_location != NULL &&
+ obj->priv->current_location->prev != NULL);
}
check_current_item (obj, TRUE);
- } else {
+ }
+ else
+ {
g_message ("NO!");
}
}
static void
-on_model_set (GObject * gobject, GParamSpec * arg1,
- GeditFileBrowserWidget * obj)
+on_model_set (GObject *gobject, GParamSpec *arg1,
+ GeditFileBrowserWidget *obj)
{
GtkTreeModel *model;
@@ -2596,11 +2649,13 @@ on_model_set (GObject * gobject, GParamSpec * arg1,
clear_signals (obj);
- if (GEDIT_IS_FILE_BOOKMARKS_STORE (model)) {
+ if (GEDIT_IS_FILE_BOOKMARKS_STORE (model))
+ {
clear_next_locations (obj);
/* Add the current location to the back menu */
- if (obj->priv->current_location) {
+ if (obj->priv->current_location)
+ {
GtkAction *action;
gtk_menu_shell_prepend (GTK_MENU_SHELL (obj->priv->location_previous_menu),
@@ -2621,7 +2676,9 @@ on_model_set (GObject * gobject, GParamSpec * arg1,
g_signal_connect (gobject, "bookmark-activated",
G_CALLBACK
(on_bookmark_activated), obj));
- } else if (GEDIT_IS_FILE_BROWSER_STORE (model)) {
+ }
+ else if (GEDIT_IS_FILE_BROWSER_STORE (model))
+ {
/* make sure any async operation is cancelled */
cancel_async_operation (obj);
@@ -2642,25 +2699,30 @@ on_model_set (GObject * gobject, GParamSpec * arg1,
}
static void
-on_file_store_error (GeditFileBrowserStore * store, guint code,
- gchar * message, GeditFileBrowserWidget * obj)
+on_file_store_error (GeditFileBrowserStore *store,
+ guint code,
+ gchar *message,
+ GeditFileBrowserWidget *obj)
{
g_signal_emit (obj, signals[ERROR], 0, code, message);
}
static void
-on_treeview_error (GeditFileBrowserView * tree_view, guint code,
- gchar * message, GeditFileBrowserWidget * obj)
+on_treeview_error (GeditFileBrowserView *tree_view,
+ guint code,
+ gchar *message,
+ GeditFileBrowserWidget *obj)
{
g_signal_emit (obj, signals[ERROR], 0, code, message);
}
static void
-on_combo_changed (GtkComboBox * combo, GeditFileBrowserWidget * obj)
+on_combo_changed (GtkComboBox *combo,
+ GeditFileBrowserWidget *obj)
{
GtkTreeIter iter;
guint id;
- GFile * file;
+ GFile *file;
if (!gtk_combo_box_get_active_iter (combo, &iter))
return;
@@ -2668,81 +2730,79 @@ on_combo_changed (GtkComboBox * combo, GeditFileBrowserWidget * obj)
gtk_tree_model_get (GTK_TREE_MODEL (obj->priv->combo_model), &iter,
COLUMN_ID, &id, -1);
- switch (id) {
- case BOOKMARKS_ID:
- gedit_file_browser_widget_show_bookmarks (obj);
- break;
+ switch (id)
+ {
+ case BOOKMARKS_ID:
+ gedit_file_browser_widget_show_bookmarks (obj);
+ break;
- case PATH_ID:
- gtk_tree_model_get (GTK_TREE_MODEL
- (obj->priv->combo_model), &iter,
- COLUMN_FILE, &file, -1);
+ case PATH_ID:
+ gtk_tree_model_get (GTK_TREE_MODEL
+ (obj->priv->combo_model), &iter,
+ COLUMN_FILE, &file, -1);
- gedit_file_browser_store_set_virtual_root_from_location
- (obj->priv->file_store, file);
+ gedit_file_browser_store_set_virtual_root_from_location
+ (obj->priv->file_store, file);
- g_object_unref (file);
- break;
+ g_object_unref (file);
+ break;
}
}
static gboolean
-on_treeview_popup_menu (GeditFileBrowserView * treeview,
- GeditFileBrowserWidget * obj)
+on_treeview_popup_menu (GeditFileBrowserView *treeview,
+ GeditFileBrowserWidget *obj)
{
return popup_menu (obj, NULL, gtk_tree_view_get_model (GTK_TREE_VIEW (treeview)));
}
static gboolean
-on_treeview_button_press_event (GeditFileBrowserView * treeview,
- GdkEventButton * event,
- GeditFileBrowserWidget * obj)
+on_treeview_button_press_event (GeditFileBrowserView *treeview,
+ GdkEventButton *event,
+ GeditFileBrowserWidget *obj)
{
- if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
+ if (event->type == GDK_BUTTON_PRESS && event->button == 3)
return popup_menu (obj, event,
gtk_tree_view_get_model (GTK_TREE_VIEW (treeview)));
- }
return FALSE;
}
static gboolean
-do_change_directory (GeditFileBrowserWidget * obj,
- GdkEventKey * event)
+do_change_directory (GeditFileBrowserWidget *obj,
+ GdkEventKey *event)
{
- GtkAction * action = NULL;
+ GtkAction *action = NULL;
if ((event->state &
(~GDK_CONTROL_MASK & ~GDK_SHIFT_MASK & ~GDK_MOD1_MASK)) ==
event->state && event->keyval == GDK_BackSpace)
- action = gtk_action_group_get_action (obj->priv->
- action_group_sensitive,
+ action = gtk_action_group_get_action (obj->priv->action_group_sensitive,
"DirectoryPrevious");
else if (!((event->state & GDK_MOD1_MASK) &&
(event->state & (~GDK_CONTROL_MASK & ~GDK_SHIFT_MASK)) == event->state))
return FALSE;
- switch (event->keyval) {
+ switch (event->keyval)
+ {
case GDK_Left:
- action = gtk_action_group_get_action (obj->priv->
- action_group_sensitive,
+ action = gtk_action_group_get_action (obj->priv->action_group_sensitive,
"DirectoryPrevious");
- break;
+ break;
case GDK_Right:
- action = gtk_action_group_get_action (obj->priv->
- action_group_sensitive,
+ action = gtk_action_group_get_action (obj->priv->action_group_sensitive,
"DirectoryNext");
- break;
+ break;
case GDK_Up:
- action = gtk_action_group_get_action (obj->priv->
- action_group,
+ action = gtk_action_group_get_action (obj->priv->action_group,
"DirectoryUp");
- break;
+ break;
default:
- break;
+ break;
}
- if (action != NULL) {
+ if (action != NULL)
+ {
gtk_action_activate (action);
return TRUE;
}
@@ -2751,9 +2811,9 @@ do_change_directory (GeditFileBrowserWidget * obj,
}
static gboolean
-on_treeview_key_press_event (GeditFileBrowserView * treeview,
- GdkEventKey * event,
- GeditFileBrowserWidget * obj)
+on_treeview_key_press_event (GeditFileBrowserView *treeview,
+ GdkEventKey *event,
+ GeditFileBrowserWidget *obj)
{
guint modifiers;
@@ -2766,24 +2826,25 @@ on_treeview_key_press_event (GeditFileBrowserView * treeview,
modifiers = gtk_accelerator_get_default_mod_mask ();
- if (event->keyval == GDK_Delete
- || event->keyval == GDK_KP_Delete) {
+ if (event->keyval == GDK_Delete || event->keyval == GDK_KP_Delete)
+ {
- if ((event->state & modifiers) == GDK_SHIFT_MASK) {
- if (obj->priv->enable_delete) {
- delete_selected_files (obj, FALSE);
- return TRUE;
- }
- } else if ((event->state & modifiers) == 0) {
+ if ((event->state & modifiers) == GDK_SHIFT_MASK &&
+ obj->priv->enable_delete)
+ {
+ delete_selected_files (obj, FALSE);
+ return TRUE;
+ }
+ else if ((event->state & modifiers) == 0)
+ {
delete_selected_files (obj, TRUE);
return TRUE;
}
}
- if ((event->keyval == GDK_F2)
- && (event->state & modifiers) == 0) {
+ if ((event->keyval == GDK_F2) && (event->state & modifiers) == 0)
+ {
rename_selected_file (obj);
-
return TRUE;
}
@@ -2791,8 +2852,8 @@ on_treeview_key_press_event (GeditFileBrowserView * treeview,
}
static void
-on_selection_changed (GtkTreeSelection * selection,
- GeditFileBrowserWidget * obj)
+on_selection_changed (GtkTreeSelection *selection,
+ GeditFileBrowserWidget *obj)
{
GtkTreeModel *model;
guint selected = 0;
@@ -2802,11 +2863,9 @@ on_selection_changed (GtkTreeSelection * selection,
model = gtk_tree_view_get_model (GTK_TREE_VIEW (obj->priv->treeview));
if (GEDIT_IS_FILE_BROWSER_STORE (model))
- {
selected = gedit_file_browser_widget_get_num_selected_files_or_directories (obj,
&files,
&dirs);
- }
gtk_action_group_set_sensitive (obj->priv->action_group_selection,
selected > 0);
@@ -2819,7 +2878,7 @@ on_selection_changed (GtkTreeSelection * selection,
}
static gboolean
-on_entry_filter_activate (GeditFileBrowserWidget * obj)
+on_entry_filter_activate (GeditFileBrowserWidget *obj)
{
gchar const *text;
@@ -2830,42 +2889,40 @@ on_entry_filter_activate (GeditFileBrowserWidget * obj)
}
static void
-on_location_jump_activate (GtkMenuItem * item,
- GeditFileBrowserWidget * obj)
+on_location_jump_activate (GtkMenuItem *item,
+ GeditFileBrowserWidget *obj)
{
GList *location;
location = g_object_get_data (G_OBJECT (item), LOCATION_DATA_KEY);
- if (obj->priv->current_location) {
+ if (obj->priv->current_location)
jump_to_location (obj, location,
g_list_position (obj->priv->locations,
location) >
g_list_position (obj->priv->locations,
obj->priv->
current_location));
- } else {
+ else
jump_to_location (obj, location, TRUE);
- }
-
}
static void
-on_bookmarks_row_changed (GtkTreeModel * model,
- GtkTreePath * path,
- GtkTreeIter * iter,
+on_bookmarks_row_changed (GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
GeditFileBrowserWidget *obj)
{
add_bookmark_hash (obj, iter);
}
static void
-on_bookmarks_row_deleted (GtkTreeModel * model,
- GtkTreePath * path,
+on_bookmarks_row_deleted (GtkTreeModel *model,
+ GtkTreePath *path,
GeditFileBrowserWidget *obj)
{
GtkTreeIter iter;
- GFile * location;
+ GFile *location;
if (!gtk_tree_model_get_iter (model, &iter, path))
return;
@@ -2882,12 +2939,12 @@ on_bookmarks_row_deleted (GtkTreeModel * model,
}
static void
-on_filter_mode_changed (GeditFileBrowserStore * model,
- GParamSpec * param,
- GeditFileBrowserWidget * obj)
+on_filter_mode_changed (GeditFileBrowserStore *model,
+ GParamSpec *param,
+ GeditFileBrowserWidget *obj)
{
gint mode;
- GtkToggleAction * action;
+ GtkToggleAction *action;
gboolean active;
mode = gedit_file_browser_store_get_filter_mode (model);
@@ -2908,21 +2965,22 @@ on_filter_mode_changed (GeditFileBrowserStore * model,
}
static void
-on_action_directory_next (GtkAction * action, GeditFileBrowserWidget * obj)
+on_action_directory_next (GtkAction *action,
+ GeditFileBrowserWidget *obj)
{
gedit_file_browser_widget_history_forward (obj);
}
static void
-on_action_directory_previous (GtkAction * action,
- GeditFileBrowserWidget * obj)
+on_action_directory_previous (GtkAction *action,
+ GeditFileBrowserWidget *obj)
{
gedit_file_browser_widget_history_back (obj);
}
static void
-on_action_directory_up (GtkAction * action,
- GeditFileBrowserWidget * obj)
+on_action_directory_up (GtkAction *action,
+ GeditFileBrowserWidget *obj)
{
GtkTreeModel *model;
@@ -2935,7 +2993,8 @@ on_action_directory_up (GtkAction * action,
}
static void
-on_action_directory_new (GtkAction * action, GeditFileBrowserWidget * obj)
+on_action_directory_new (GtkAction *action,
+ GeditFileBrowserWidget *obj)
{
GtkTreeModel *model;
GtkTreeIter parent;
@@ -2950,14 +3009,14 @@ on_action_directory_new (GtkAction * action, GeditFileBrowserWidget * obj)
return;
if (gedit_file_browser_store_new_directory
- (GEDIT_FILE_BROWSER_STORE (model), &parent, &iter)) {
+ (GEDIT_FILE_BROWSER_STORE (model), &parent, &iter))
gedit_file_browser_view_start_rename (obj->priv->treeview,
&iter);
- }
}
static void
-on_action_file_open (GtkAction * action, GeditFileBrowserWidget * obj)
+on_action_file_open (GtkAction *action,
+ GeditFileBrowserWidget *obj)
{
GtkTreeModel *model;
GtkTreeSelection *selection;
@@ -2974,7 +3033,8 @@ on_action_file_open (GtkAction * action, GeditFileBrowserWidget * obj)
rows = gtk_tree_selection_get_selected_rows (selection, &model);
- for (row = rows; row; row = row->next) {
+ for (row = rows; row; row = row->next)
+ {
path = (GtkTreePath *)(row->data);
if (gtk_tree_model_get_iter (model, &iter, path))
@@ -2987,7 +3047,8 @@ on_action_file_open (GtkAction * action, GeditFileBrowserWidget * obj)
}
static void
-on_action_file_new (GtkAction * action, GeditFileBrowserWidget * obj)
+on_action_file_new (GtkAction *action,
+ GeditFileBrowserWidget *obj)
{
GtkTreeModel *model;
GtkTreeIter parent;
@@ -3002,39 +3063,42 @@ on_action_file_new (GtkAction * action, GeditFileBrowserWidget * obj)
return;
if (gedit_file_browser_store_new_file
- (GEDIT_FILE_BROWSER_STORE (model), &parent, &iter)) {
+ (GEDIT_FILE_BROWSER_STORE (model), &parent, &iter))
gedit_file_browser_view_start_rename (obj->priv->treeview,
&iter);
- }
}
static void
-on_action_file_rename (GtkAction * action, GeditFileBrowserWidget * obj)
+on_action_file_rename (GtkAction *action,
+ GeditFileBrowserWidget *obj)
{
rename_selected_file (obj);
}
static void
-on_action_file_delete (GtkAction * action, GeditFileBrowserWidget * obj)
+on_action_file_delete (GtkAction *action,
+ GeditFileBrowserWidget *obj)
{
delete_selected_files (obj, FALSE);
}
static void
-on_action_file_move_to_trash (GtkAction * action, GeditFileBrowserWidget * obj)
+on_action_file_move_to_trash (GtkAction *action,
+ GeditFileBrowserWidget *obj)
{
delete_selected_files (obj, TRUE);
}
static void
-on_action_directory_refresh (GtkAction * action,
- GeditFileBrowserWidget * obj)
+on_action_directory_refresh (GtkAction *action,
+ GeditFileBrowserWidget *obj)
{
gedit_file_browser_widget_refresh (obj);
}
static void
-on_action_directory_open (GtkAction * action, GeditFileBrowserWidget * obj)
+on_action_directory_open (GtkAction *action,
+ GeditFileBrowserWidget *obj)
{
GtkTreeModel *model;
GtkTreeSelection *selection;
@@ -3052,7 +3116,8 @@ on_action_directory_open (GtkAction * action, GeditFileBrowserWidget * obj)
rows = gtk_tree_selection_get_selected_rows (selection, &model);
- for (row = rows; row; row = row->next) {
+ for (row = rows; row; row = row->next)
+ {
path = (GtkTreePath *)(row->data);
if (gtk_tree_model_get_iter (model, &iter, path))
@@ -3061,16 +3126,16 @@ on_action_directory_open (GtkAction * action, GeditFileBrowserWidget * obj)
gtk_tree_path_free (path);
}
- if (!directory_opened) {
- if (gedit_file_browser_widget_get_selected_directory (obj, &iter))
+ if (!directory_opened &&
+ gedit_file_browser_widget_get_selected_directory (obj, &iter))
directory_open (obj, model, &iter);
- }
g_list_free (rows);
}
static void
-on_action_filter_hidden (GtkAction * action, GeditFileBrowserWidget * obj)
+on_action_filter_hidden (GtkAction *action,
+ GeditFileBrowserWidget *obj)
{
update_filter_mode (obj,
action,
@@ -3078,7 +3143,8 @@ on_action_filter_hidden (GtkAction * action, GeditFileBrowserWidget * obj)
}
static void
-on_action_filter_binary (GtkAction * action, GeditFileBrowserWidget * obj)
+on_action_filter_binary (GtkAction *action,
+ GeditFileBrowserWidget *obj)
{
update_filter_mode (obj,
action,
@@ -3086,7 +3152,8 @@ on_action_filter_binary (GtkAction * action, GeditFileBrowserWidget * obj)
}
static void
-on_action_bookmark_open (GtkAction * action, GeditFileBrowserWidget * obj)
+on_action_bookmark_open (GtkAction *action,
+ GeditFileBrowserWidget *obj)
{
GtkTreeModel *model;
GtkTreeSelection *selection;
@@ -3101,5 +3168,3 @@ on_action_bookmark_open (GtkAction * action, GeditFileBrowserWidget * obj)
if (gtk_tree_selection_get_selected (selection, NULL, &iter))
bookmark_open (obj, model, &iter);
}
-
-// ex:ts=8:noet:
diff --git a/plugins/filebrowser/gedit-file-browser-widget.h b/plugins/filebrowser/gedit-file-browser-widget.h
index 3936293..911454e 100644
--- a/plugins/filebrowser/gedit-file-browser-widget.h
+++ b/plugins/filebrowser/gedit-file-browser-widget.h
@@ -1,19 +1,19 @@
/*
* gedit-file-browser-widget.h - Gedit plugin providing easy file access
* from the sidepanel
- *
+ *
* Copyright (C) 2006 - Jesse van den Kieboom <jesse icecrew nl>
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@@ -41,10 +41,10 @@ typedef struct _GeditFileBrowserWidgetClass GeditFileBrowserWidgetClass;
typedef struct _GeditFileBrowserWidgetPrivate GeditFileBrowserWidgetPrivate;
typedef
-gboolean (*GeditFileBrowserWidgetFilterFunc) (GeditFileBrowserWidget * obj,
- GeditFileBrowserStore *
- model, GtkTreeIter * iter,
- gpointer user_data);
+gboolean (*GeditFileBrowserWidgetFilterFunc) (GeditFileBrowserWidget *obj,
+ GeditFileBrowserStore *model,
+ GtkTreeIter *iter,
+ gpointer user_data);
struct _GeditFileBrowserWidget
{
@@ -58,64 +58,63 @@ struct _GeditFileBrowserWidgetClass
GtkVBoxClass parent_class;
/* Signals */
- void (*location_activated) (GeditFileBrowserWidget * widget,
- GFile *location);
- void (*error) (GeditFileBrowserWidget * widget,
- guint code,
- gchar const *message);
- gboolean (*confirm_delete) (GeditFileBrowserWidget * widget,
- GeditFileBrowserStore * model,
- GList *list);
- gboolean (*confirm_no_trash) (GeditFileBrowserWidget * widget,
- GList *list);
+ void (* location_activated) (GeditFileBrowserWidget *widget,
+ GFile *location);
+ void (* error) (GeditFileBrowserWidget *widget,
+ guint code,
+ gchar const *message);
+ gboolean (* confirm_delete) (GeditFileBrowserWidget *widget,
+ GeditFileBrowserStore *model,
+ GList *list);
+ gboolean (* confirm_no_trash) (GeditFileBrowserWidget *widget,
+ GList *list);
};
-GType gedit_file_browser_widget_get_type (void) G_GNUC_CONST;
-GType gedit_file_browser_widget_register_type (GTypeModule * module);
+GType gedit_file_browser_widget_get_type (void) G_GNUC_CONST;
+GType gedit_file_browser_widget_register_type (GTypeModule *module);
-GtkWidget *gedit_file_browser_widget_new (const gchar *data_dir);
+GtkWidget *gedit_file_browser_widget_new (const gchar *data_dir);
-void gedit_file_browser_widget_show_bookmarks (GeditFileBrowserWidget * obj);
-void gedit_file_browser_widget_show_files (GeditFileBrowserWidget * obj);
+void gedit_file_browser_widget_show_bookmarks (GeditFileBrowserWidget *obj);
+void gedit_file_browser_widget_show_files (GeditFileBrowserWidget *obj);
-void gedit_file_browser_widget_set_root (GeditFileBrowserWidget * obj,
- GFile *root,
- gboolean virtual_root);
-void
-gedit_file_browser_widget_set_root_and_virtual_root (GeditFileBrowserWidget * obj,
- GFile *root,
- GFile *virtual_root);
+void gedit_file_browser_widget_set_root (GeditFileBrowserWidget *obj,
+ GFile *root,
+ gboolean virtual_root);
+void gedit_file_browser_widget_set_root_and_virtual_root
+ (GeditFileBrowserWidget *obj,
+ GFile *root,
+ GFile *virtual_root);
-gboolean
-gedit_file_browser_widget_get_selected_directory (GeditFileBrowserWidget * obj,
- GtkTreeIter * iter);
+gboolean gedit_file_browser_widget_get_selected_directory
+ (GeditFileBrowserWidget *obj,
+ GtkTreeIter *iter);
-GeditFileBrowserStore *
-gedit_file_browser_widget_get_browser_store (GeditFileBrowserWidget * obj);
-GeditFileBookmarksStore *
-gedit_file_browser_widget_get_bookmarks_store (GeditFileBrowserWidget * obj);
+GeditFileBrowserStore *
+gedit_file_browser_widget_get_browser_store (GeditFileBrowserWidget *obj);
+GeditFileBookmarksStore *
+gedit_file_browser_widget_get_bookmarks_store (GeditFileBrowserWidget *obj);
GeditFileBrowserView *
-gedit_file_browser_widget_get_browser_view (GeditFileBrowserWidget * obj);
+gedit_file_browser_widget_get_browser_view (GeditFileBrowserWidget *obj);
GtkWidget *
-gedit_file_browser_widget_get_filter_entry (GeditFileBrowserWidget * obj);
+gedit_file_browser_widget_get_filter_entry (GeditFileBrowserWidget *obj);
-GtkUIManager *
-gedit_file_browser_widget_get_ui_manager (GeditFileBrowserWidget * obj);
+GtkUIManager *
+gedit_file_browser_widget_get_ui_manager (GeditFileBrowserWidget *obj);
-gulong gedit_file_browser_widget_add_filter (GeditFileBrowserWidget * obj,
- GeditFileBrowserWidgetFilterFunc func,
- gpointer user_data,
- GDestroyNotify notify);
-void gedit_file_browser_widget_remove_filter (GeditFileBrowserWidget * obj,
- gulong id);
-void gedit_file_browser_widget_set_filter_pattern (GeditFileBrowserWidget * obj,
- gchar const *pattern);
+gulong gedit_file_browser_widget_add_filter (GeditFileBrowserWidget *obj,
+ GeditFileBrowserWidgetFilterFunc func,
+ gpointer user_data,
+ GDestroyNotify notify);
+void gedit_file_browser_widget_remove_filter (GeditFileBrowserWidget *obj,
+ gulong id);
+void gedit_file_browser_widget_set_filter_pattern (GeditFileBrowserWidget *obj,
+ gchar const *pattern);
-void gedit_file_browser_widget_refresh (GeditFileBrowserWidget * obj);
-void gedit_file_browser_widget_history_back (GeditFileBrowserWidget * obj);
-void gedit_file_browser_widget_history_forward (GeditFileBrowserWidget * obj);
+void gedit_file_browser_widget_refresh (GeditFileBrowserWidget *obj);
+void gedit_file_browser_widget_history_back (GeditFileBrowserWidget *obj);
+void gedit_file_browser_widget_history_forward (GeditFileBrowserWidget *obj);
G_END_DECLS
-#endif /* __GEDIT_FILE_BROWSER_WIDGET_H__ */
-// ex:ts=8:noet:
+#endif /* __GEDIT_FILE_BROWSER_WIDGET_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]