[gnome-commander] GnomeCmdFile: more C++ rework
- From: Piotr Eljasiak <epiotr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] GnomeCmdFile: more C++ rework
- Date: Sat, 14 Aug 2010 16:07:28 +0000 (UTC)
commit 3965e27f3111e1d1967862e625476ada573e1e69
Author: Piotr Eljasiak <epiotr src gnome org>
Date: Sat Aug 14 18:06:58 2010 +0200
GnomeCmdFile: more C++ rework
src/gnome-cmd-dir.cc | 2 +-
src/gnome-cmd-file-list.cc | 8 ++++----
src/gnome-cmd-file.cc | 31 +++++++++++++------------------
src/gnome-cmd-file.h | 12 ++++++------
4 files changed, 24 insertions(+), 29 deletions(-)
---
diff --git a/src/gnome-cmd-dir.cc b/src/gnome-cmd-dir.cc
index 6446316..6cb9781 100644
--- a/src/gnome-cmd-dir.cc
+++ b/src/gnome-cmd-dir.cc
@@ -796,7 +796,7 @@ void gnome_cmd_dir_file_changed (GnomeCmdDir *dir, const gchar *uri_str)
dir->priv->needs_mtime_update = TRUE;
f->update_info(info);
- gnome_cmd_file_invalidate_metadata (f);
+ f->invalidate_metadata();
g_signal_emit (dir, signals[FILE_CHANGED], 0, f);
}
diff --git a/src/gnome-cmd-file-list.cc b/src/gnome-cmd-file-list.cc
index 56dbbc7..d99cfa4 100644
--- a/src/gnome-cmd-file-list.cc
+++ b/src/gnome-cmd-file-list.cc
@@ -265,7 +265,7 @@ inline FileFormatData::FileFormatData(GnomeCmdFile *f, gboolean tree_size)
{
// If the user wants a character instead of icon for filetype set it now
if (gnome_cmd_data.layout == GNOME_CMD_LAYOUT_TEXT)
- text[GnomeCmdFileList::COLUMN_ICON] = (gchar *) gnome_cmd_file_get_type_string (f);
+ text[GnomeCmdFileList::COLUMN_ICON] = (gchar *) f->get_type_string();
else
text[GnomeCmdFileList::COLUMN_ICON] = NULL;
@@ -1324,7 +1324,7 @@ static void on_dir_file_renamed (GnomeCmdDir *dir, GnomeCmdFile *f, GnomeCmdFile
if (fl->has_file(f))
{
- // gnome_cmd_file_invalidate_metadata (f, TAG_FILE); // FIXME: should be handled in GnomeCmdDir, not here
+ // f->invalidate_metadata(TAG_FILE); // FIXME: should be handled in GnomeCmdDir, not here
fl->update_file(f);
GnomeCmdFileList::ColumnID sort_col = fl->get_sort_column();
@@ -1674,7 +1674,7 @@ inline void add_file_to_clist (GnomeCmdFileList *fl, GnomeCmdFile *f, gint in_ro
GdkPixmap *pixmap;
GdkBitmap *mask;
- if (gnome_cmd_file_get_type_pixmap_and_mask (f, &pixmap, &mask))
+ if (f->get_type_pixmap_and_mask(&pixmap, &mask))
gtk_clist_set_pixmap (clist, row, 0, pixmap, mask);
}
@@ -1790,7 +1790,7 @@ void GnomeCmdFileList::update_file(GnomeCmdFile *f)
GdkPixmap *pixmap;
GdkBitmap *mask;
- if (gnome_cmd_file_get_type_pixmap_and_mask (f, &pixmap, &mask))
+ if (f->get_type_pixmap_and_mask(&pixmap, &mask))
gtk_clist_set_pixmap (*this, row, 0, pixmap, mask);
}
}
diff --git a/src/gnome-cmd-file.cc b/src/gnome-cmd-file.cc
index 0d70be9..98280c5 100644
--- a/src/gnome-cmd-file.cc
+++ b/src/gnome-cmd-file.cc
@@ -198,12 +198,10 @@ GnomeCmdFile *gnome_cmd_file_new_from_uri (GnomeVFSURI *uri)
}
-void gnome_cmd_file_invalidate_metadata (GnomeCmdFile *f)
+void GnomeCmdFile::invalidate_metadata()
{
- g_return_if_fail (f != NULL);
-
- delete f->metadata;
- f->metadata = NULL;
+ delete metadata;
+ metadata = NULL;
}
@@ -609,19 +607,18 @@ const gchar *gnome_cmd_file_get_perm (GnomeCmdFile *f)
}
-const gchar *gnome_cmd_file_get_type_string (GnomeCmdFile *f)
+const gchar *GnomeCmdFile::get_type_string()
{
static gchar type_str[MAX_TYPE_LENGTH];
- g_return_val_if_fail (f != NULL, NULL);
- g_return_val_if_fail (f->info != NULL, NULL);
+ g_return_val_if_fail (info != NULL, NULL);
- type2string (f->info->type, type_str, MAX_TYPE_LENGTH);
+ type2string (info->type, type_str, MAX_TYPE_LENGTH);
return type_str;
}
-const gchar *gnome_cmd_file_get_type_desc (GnomeCmdFile *f)
+const gchar *GnomeCmdFile::get_type_desc()
{
static const gchar *type_strings[] = {
N_("Unknown file type"),
@@ -634,22 +631,20 @@ const gchar *gnome_cmd_file_get_type_desc (GnomeCmdFile *f)
N_("Symbolic link")
};
- g_return_val_if_fail (f != NULL, NULL);
- g_return_val_if_fail (f->info != NULL, NULL);
+ g_return_val_if_fail (info != NULL, NULL);
- if (!f->info->symlink_name)
- return type_strings[f->info->type];
+ if (!info->symlink_name)
+ return type_strings[info->type];
return type_strings[GNOME_VFS_FILE_TYPE_SYMBOLIC_LINK];
}
-gboolean gnome_cmd_file_get_type_pixmap_and_mask (GnomeCmdFile *f, GdkPixmap **pixmap, GdkBitmap **mask)
+gboolean GnomeCmdFile::get_type_pixmap_and_mask(GdkPixmap **pixmap, GdkBitmap **mask)
{
- g_return_val_if_fail (f != NULL, NULL);
- g_return_val_if_fail (f->info != NULL, NULL);
+ g_return_val_if_fail (info != NULL, NULL);
- return IMAGE_get_pixmap_and_mask (f->info->type, f->info->mime_type, f->info->symlink_name != NULL, pixmap, mask);
+ return IMAGE_get_pixmap_and_mask (info->type, info->mime_type, info->symlink_name != NULL, pixmap, mask);
}
diff --git a/src/gnome-cmd-file.h b/src/gnome-cmd-file.h
index e5cc7b4..ac7a486 100644
--- a/src/gnome-cmd-file.h
+++ b/src/gnome-cmd-file.h
@@ -44,6 +44,8 @@ struct GnomeCmdFile
gchar *collate_key; // necessary for proper sorting of UTF-8 encoded file names
GnomeCmdFileMetadata *metadata;
+ void invalidate_metadata();
+
gchar *get_path();
gchar *get_dirname();
gchar *get_unescaped_dirname();
@@ -51,6 +53,10 @@ struct GnomeCmdFile
char *get_collation_fname() const { return collate_key ? collate_key : info->name; }
+ const gchar *get_type_string();
+ const gchar *get_type_desc();
+ gboolean get_type_pixmap_and_mask(GdkPixmap **pixmap, GdkBitmap **mask);
+
void update_info(GnomeVFSFileInfo *info);
gboolean is_local();
gboolean is_executable();
@@ -80,8 +86,6 @@ GnomeCmdFile *gnome_cmd_file_new_from_uri (const gchar *local_full_path);
GnomeCmdFile *gnome_cmd_file_new (GnomeVFSFileInfo *info, GnomeCmdDir *dir);
void gnome_cmd_file_setup (GnomeCmdFile *f, GnomeVFSFileInfo *info, GnomeCmdDir *dir);
-void gnome_cmd_file_invalidate_metadata (GnomeCmdFile *f);
-
GnomeCmdFile *gnome_cmd_file_ref (GnomeCmdFile *f);
void gnome_cmd_file_unref (GnomeCmdFile *f);
@@ -117,10 +121,6 @@ const gchar *gnome_cmd_file_get_mime_type (GnomeCmdFile *f);
gboolean gnome_cmd_file_has_mime_type (GnomeCmdFile *f, const gchar *mime_type);
gboolean gnome_cmd_file_mime_begins_with (GnomeCmdFile *f, const gchar *mime_type_start);
-const gchar *gnome_cmd_file_get_type_string (GnomeCmdFile *f);
-const gchar *gnome_cmd_file_get_type_desc (GnomeCmdFile *f);
-gboolean gnome_cmd_file_get_type_pixmap_and_mask (GnomeCmdFile *f, GdkPixmap **pixmap, GdkBitmap **mask);
-
void gnome_cmd_file_show_properties (GnomeCmdFile *f);
void gnome_cmd_file_show_chown_dialog (GList *files);
void gnome_cmd_file_show_chmod_dialog (GList *files);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]