[gnome-commander] Use gio to find out the file type in many parts of the source code
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] Use gio to find out the file type in many parts of the source code
- Date: Sun, 24 Jan 2021 16:41:06 +0000 (UTC)
commit 76d00a42569cd684bcb09305fbceea6a5ca845c6
Author: Uwe Scholz <u scholz83 gmx de>
Date: Sun Jan 24 17:35:36 2021 +0100
Use gio to find out the file type in many parts of the source code
Some images for GnomeVFS mime types are not needed anymore.
pixmaps/mime-icons/Makefile.am | 4 ----
pixmaps/mime-icons/i-blockdev.png | Bin 346 -> 0 bytes
pixmaps/mime-icons/i-chardev.png | Bin 260 -> 0 bytes
pixmaps/mime-icons/i-fifo.png | Bin 703 -> 0 bytes
pixmaps/mime-icons/i-socket.png | Bin 336 -> 0 bytes
src/dialogs/gnome-cmd-chmod-dialog.cc | 6 +++--
src/dialogs/gnome-cmd-chown-dialog.cc | 2 +-
src/dialogs/gnome-cmd-file-props-dialog.cc | 8 +++----
src/dialogs/gnome-cmd-search-dialog.cc | 2 +-
src/gnome-cmd-dir.cc | 1 -
src/gnome-cmd-file-list.cc | 21 +++++++++---------
src/gnome-cmd-file-selector.cc | 20 +++++++++--------
src/gnome-cmd-file.cc | 13 ++++++-----
src/gnome-cmd-main-win.cc | 2 +-
src/gnome-cmd-user-actions.cc | 10 ++++-----
src/imageloader.cc | 34 ++++++++++-------------------
src/imageloader.h | 2 +-
src/ls_colors.cc | 26 ++++++++++------------
src/ls_colors.h | 2 +-
src/tags/gnome-cmd-tags-file.cc | 2 +-
20 files changed, 71 insertions(+), 84 deletions(-)
---
diff --git a/pixmaps/mime-icons/Makefile.am b/pixmaps/mime-icons/Makefile.am
index 0d808d1b..f9e6a618 100644
--- a/pixmaps/mime-icons/Makefile.am
+++ b/pixmaps/mime-icons/Makefile.am
@@ -39,13 +39,9 @@ pixmaps_DATA = \
gnome-video-plain.png \
gnome-x-directory-smb-server.png \
gnome-x-directory-smb-workgroup.png \
- i-blockdev.png \
- i-chardev.png \
i-directory.png \
- i-fifo.png \
i-music.png \
i-regular.png \
- i-socket.png \
i-symlink.png
diff --git a/src/dialogs/gnome-cmd-chmod-dialog.cc b/src/dialogs/gnome-cmd-chmod-dialog.cc
index cb0550bb..c08d5567 100644
--- a/src/dialogs/gnome-cmd-chmod-dialog.cc
+++ b/src/dialogs/gnome-cmd-chmod-dialog.cc
@@ -66,7 +66,9 @@ static void do_chmod (GnomeCmdFile *in, GnomeVFSFilePermissions perm, gboolean r
g_return_if_fail (in != NULL);
g_return_if_fail (in->info != NULL);
- if (!(recursive && mode == CHMOD_DIRS_ONLY && in->info->type != GNOME_VFS_FILE_TYPE_DIRECTORY))
+ if (!(recursive
+ && mode == CHMOD_DIRS_ONLY
+ && in->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) != G_FILE_TYPE_DIRECTORY))
{
GnomeVFSResult ret = in->chmod(perm);
@@ -77,7 +79,7 @@ static void do_chmod (GnomeCmdFile *in, GnomeVFSFilePermissions perm, gboolean r
return;
}
- if (in->info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
+ if (in->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_DIRECTORY)
{
GnomeCmdDir *dir = gnome_cmd_dir_ref (GNOME_CMD_DIR (in));
diff --git a/src/dialogs/gnome-cmd-chown-dialog.cc b/src/dialogs/gnome-cmd-chown-dialog.cc
index 185678fe..92d39827 100644
--- a/src/dialogs/gnome-cmd-chown-dialog.cc
+++ b/src/dialogs/gnome-cmd-chown-dialog.cc
@@ -63,7 +63,7 @@ static void do_chown (GnomeCmdFile *in, uid_t uid, gid_t gid, gboolean recurse)
if (!recurse)
return;
- if (in->info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
+ if (in->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_DIRECTORY)
{
GnomeCmdDir *dir = gnome_cmd_dir_ref (GNOME_CMD_DIR (in));
diff --git a/src/dialogs/gnome-cmd-file-props-dialog.cc b/src/dialogs/gnome-cmd-file-props-dialog.cc
index 8a80ba1e..086fb4a7 100644
--- a/src/dialogs/gnome-cmd-file-props-dialog.cc
+++ b/src/dialogs/gnome-cmd-file-props-dialog.cc
@@ -425,7 +425,7 @@ static GtkWidget *create_properties_tab (GnomeCmdFilePropsDialogPrivate *data)
table_add (table, label, 1, y++, GTK_FILL);
g_free(contentTypeString);
- if (data->f->info->type != GNOME_VFS_FILE_TYPE_DIRECTORY)
+ if (data->f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) != G_FILE_TYPE_DIRECTORY)
{
GtkWidget *hbox;
@@ -474,12 +474,12 @@ static GtkWidget *create_properties_tab (GnomeCmdFilePropsDialogPrivate *data)
label = create_label (dialog, s);
table_add (table, label, 1, y++, GTK_FILL);
g_free (s);
- if (data->f->info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
+ if (data->f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_DIRECTORY)
do_calc_tree_size (data);
data->size_label = label;
- if (data->f->info->type != GNOME_VFS_FILE_TYPE_CHARACTER_DEVICE)
+ if (data->f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) != G_FILE_TYPE_SPECIAL)
gcmd_tags_bulk_load (data->f);
if (data->f->metadata)
@@ -550,7 +550,7 @@ static GtkTreeModel *create_and_fill_model (GnomeCmdFile *f)
G_TYPE_STRING,
G_TYPE_STRING);
- if (f->info->type == GNOME_VFS_FILE_TYPE_CHARACTER_DEVICE || !gcmd_tags_bulk_load (f))
+ if (f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_SPECIAL ||
!gcmd_tags_bulk_load (f))
return GTK_TREE_MODEL (treestore);
GnomeCmdTagClass prev_tagclass = TAG_NONE_CLASS;
diff --git a/src/dialogs/gnome-cmd-search-dialog.cc b/src/dialogs/gnome-cmd-search-dialog.cc
index 6c763eb5..17a0e338 100644
--- a/src/dialogs/gnome-cmd-search-dialog.cc
+++ b/src/dialogs/gnome-cmd-search-dialog.cc
@@ -428,7 +428,7 @@ void SearchData::search_dir_r(GnomeCmdDir *dir, long level)
}
}
else // if the file is a regular one, it
might match the search criteria
- if (f->info->type == GNOME_VFS_FILE_TYPE_REGULAR)
+ if (f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_DIRECTORY)
{
if (!name_matches(f->info->name)) // if the name doesn't match, let's
go to the next file
continue;
diff --git a/src/gnome-cmd-dir.cc b/src/gnome-cmd-dir.cc
index afc7450b..a3603b5a 100644
--- a/src/gnome-cmd-dir.cc
+++ b/src/gnome-cmd-dir.cc
@@ -404,7 +404,6 @@ static GList *create_file_list (GnomeCmdDir *dir, GList *info_list)
if (info && info->name)
{
-
if (strcmp (info->name, ".") == 0 || strcmp (info->name, "..") == 0)
{
gnome_vfs_file_info_unref (info);
diff --git a/src/gnome-cmd-file-list.cc b/src/gnome-cmd-file-list.cc
index bec533d1..8d861e14 100644
--- a/src/gnome-cmd-file-list.cc
+++ b/src/gnome-cmd-file-list.cc
@@ -324,7 +324,7 @@ FileFormatData::FileFormatData(GnomeCmdFileList *fl, GnomeCmdFile *f, gboolean t
g_free (t2);
if (gnome_cmd_data.options.ext_disp_mode == GNOME_CMD_EXT_DISP_STRIPPED
- && f->info->type == GNOME_VFS_FILE_TYPE_REGULAR)
+ && f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_REGULAR)
{
gchar *t = strip_extension (f->get_name());
fname = get_utf8 (t);
@@ -351,7 +351,7 @@ FileFormatData::FileFormatData(GnomeCmdFileList *fl, GnomeCmdFile *f, gboolean t
text[GnomeCmdFileList::COLUMN_SIZE] = tree_size ? (gchar *) f->get_tree_size_as_str() : (gchar *)
f->get_size();
- if (f->info->type != GNOME_VFS_FILE_TYPE_DIRECTORY || !f->is_dotdot)
+ if (f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) != G_FILE_TYPE_DIRECTORY || !f->is_dotdot)
{
text[GnomeCmdFileList::COLUMN_DATE] = (gchar *) f->get_mdate(FALSE);
text[GnomeCmdFileList::COLUMN_PERM] = (gchar *) f->get_perm();
@@ -1355,10 +1355,10 @@ inline gboolean mime_exec_file (GnomeCmdFile *f)
{
g_return_val_if_fail (f != nullptr, FALSE);
- if (f->info->type == GNOME_VFS_FILE_TYPE_REGULAR)
+ if (f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_REGULAR)
{
mime_exec_single (f);
- return TRUE;
+ return TRUE;
}
return FALSE;
@@ -2379,9 +2379,10 @@ void gnome_cmd_file_list_view (GnomeCmdFileList *fl, gint internal_viewer)
GnomeCmdFile *f = fl->get_selected_file();
- if (!f) return;
+ if (!f)
+ return;
- if (f->info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
+ if (f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_DIRECTORY)
gnome_cmd_show_message (*main_win, _("Not an ordinary file."), f->info->name);
else
gnome_cmd_file_view (f, internal_viewer);
@@ -2396,7 +2397,7 @@ void gnome_cmd_file_list_edit (GnomeCmdFileList *fl)
if (!f) return;
- if (f->info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
+ if (f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_DIRECTORY)
gnome_cmd_show_message (*main_win, _("Not an ordinary file."), f->info->name);
else
gnome_cmd_file_edit (f);
@@ -2920,7 +2921,7 @@ void GnomeCmdFileList::invalidate_tree_size()
for (auto i = get_visible_files(); i; i = i->next)
{
auto f = static_cast<GnomeCmdFile*> (i->data);
- if (f->info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
+ if (f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_DIRECTORY)
f->invalidate_tree_size();
}
}
@@ -3067,7 +3068,7 @@ static void drag_data_received (GtkWidget *widget, GdkDragContext *context, gint
// the drop was over a directory in the list, which means that the
// xfer should be done to that directory instead of the current one in the list
- if (f && f->info->type==GNOME_VFS_FILE_TYPE_DIRECTORY)
+ if (f && f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_DIRECTORY)
to = f->is_dotdot ? gnome_cmd_dir_get_parent (to) : gnome_cmd_dir_get_child (to, f->info->name);
// transform the drag data to a list with URIs
@@ -3154,7 +3155,7 @@ static gboolean drag_motion (GtkWidget *widget, GdkDragContext *context, gint x,
{
GnomeCmdFile *f = fl->get_file_at_row(row);
- if (f->info->type != GNOME_VFS_FILE_TYPE_DIRECTORY)
+ if (f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) != G_FILE_TYPE_DIRECTORY)
row = -1;
gnome_cmd_clist_set_drag_row (*fl, row);
diff --git a/src/gnome-cmd-file-selector.cc b/src/gnome-cmd-file-selector.cc
index a9a9937e..ed83a631 100644
--- a/src/gnome-cmd-file-selector.cc
+++ b/src/gnome-cmd-file-selector.cc
@@ -117,9 +117,9 @@ inline void GnomeCmdFileSelector::update_selected_files_label()
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch-enum"
#endif
- switch (f->info->type)
+ switch (f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE))
{
- case GNOME_VFS_FILE_TYPE_DIRECTORY:
+ case G_FILE_TYPE_DIRECTORY:
if (!f->is_dotdot)
{
num_dirs++;
@@ -128,7 +128,7 @@ inline void GnomeCmdFileSelector::update_selected_files_label()
}
break;
- case GNOME_VFS_FILE_TYPE_REGULAR:
+ case G_FILE_TYPE_REGULAR:
num_files++;
total_bytes += f->info->size;
break;
@@ -151,15 +151,15 @@ inline void GnomeCmdFileSelector::update_selected_files_label()
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch-enum"
#endif
- switch (f->info->type)
+ switch (f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE))
{
- case GNOME_VFS_FILE_TYPE_DIRECTORY:
+ case G_FILE_TYPE_DIRECTORY:
num_sel_dirs++;
if (f->has_tree_size())
sel_bytes += f->get_tree_size();
break;
- case GNOME_VFS_FILE_TYPE_REGULAR:
+ case G_FILE_TYPE_REGULAR:
num_sel_files++;
sel_bytes += f->info->size;
break;
@@ -246,7 +246,7 @@ void GnomeCmdFileSelector::do_file_specific_action (GnomeCmdFileList *fl, GnomeC
g_return_if_fail (f != nullptr);
g_return_if_fail (f->info != nullptr);
- if (f->info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
+ if (f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_DIRECTORY)
{
if (!fl->locked)
{
@@ -484,7 +484,9 @@ static void on_list_list_clicked (GnomeCmdFileList *fl, GnomeCmdFile *f, GdkEven
if (f && f->is_dotdot)
fs->new_tab(gnome_cmd_dir_get_parent (fl->cwd));
else
- fs->new_tab(f && f->info->type==GNOME_VFS_FILE_TYPE_DIRECTORY ? GNOME_CMD_DIR (f) :
fl->cwd);
+ fs->new_tab(f && f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) ==
G_FILE_TYPE_DIRECTORY
+ ? GNOME_CMD_DIR (f)
+ : fl->cwd);
}
break;
@@ -1281,7 +1283,7 @@ gboolean GnomeCmdFileSelector::key_pressed(GdkEventKey *event)
case GDK_Right:
case GDK_KP_Right:
f = list->get_selected_file();
- if (f && f->info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
+ if (f && f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_DIRECTORY)
do_file_specific_action (list, f);
g_signal_stop_emission_by_name (list, "key-press-event");
return TRUE;
diff --git a/src/gnome-cmd-file.cc b/src/gnome-cmd-file.cc
index 0f9010ad..be4811ff 100644
--- a/src/gnome-cmd-file.cc
+++ b/src/gnome-cmd-file.cc
@@ -596,7 +596,7 @@ const gchar *GnomeCmdFile::get_extension()
{
g_return_val_if_fail (info != nullptr, nullptr);
- if (info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
+ if (GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_DIRECTORY)
return nullptr;
const char *s = strrchr (info->name, '.'); // does NOT work on UTF-8 strings, should be (MUCH
SLOWER):
@@ -664,7 +664,7 @@ const gchar *GnomeCmdFile::get_size()
g_return_val_if_fail (info != nullptr, nullptr);
- if (info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
+ if (GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_DIRECTORY)
return dir_indicator;
return size2string (info->size, gnome_cmd_data.options.size_disp_mode);
@@ -673,7 +673,7 @@ const gchar *GnomeCmdFile::get_size()
GnomeVFSFileSize GnomeCmdFile::get_tree_size()
{
- if (info->type != GNOME_VFS_FILE_TYPE_DIRECTORY)
+ if (GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) != G_FILE_TYPE_DIRECTORY)
return info->size;
if (is_dotdot)
@@ -694,7 +694,7 @@ const gchar *GnomeCmdFile::get_tree_size_as_str()
{
g_return_val_if_fail (info != nullptr, nullptr);
- if (info->type != GNOME_VFS_FILE_TYPE_DIRECTORY)
+ if (GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) != G_FILE_TYPE_DIRECTORY)
return get_size();
if (is_dotdot)
@@ -728,7 +728,8 @@ gboolean GnomeCmdFile::get_type_pixmap_and_mask(GdkPixmap **pixmap, GdkBitmap **
{
g_return_val_if_fail (info != nullptr, FALSE);
- return IMAGE_get_pixmap_and_mask (info->type, info->mime_type, info->symlink_name != nullptr, pixmap,
mask);
+ return IMAGE_get_pixmap_and_mask (GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE),
+ info->mime_type, info->symlink_name != nullptr, pixmap, mask);
}
@@ -901,7 +902,7 @@ gboolean GnomeCmdFile::is_local()
gboolean GnomeCmdFile::is_executable()
{
- if (info->type != GNOME_VFS_FILE_TYPE_REGULAR)
+ if (GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) != G_FILE_TYPE_REGULAR)
return FALSE;
if (!is_local())
diff --git a/src/gnome-cmd-main-win.cc b/src/gnome-cmd-main-win.cc
index 5ad29848..783b1da2 100644
--- a/src/gnome-cmd-main-win.cc
+++ b/src/gnome-cmd-main-win.cc
@@ -1253,7 +1253,7 @@ void GnomeCmdMainWin::set_fs_directory_to_opposite(FileSelectorID fsID)
{
GnomeCmdFile *file = other->file_list()->get_selected_file();
- if (file && file->info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
+ if (file->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_DIRECTORY)
dir = GNOME_CMD_IS_DIR (file) ? GNOME_CMD_DIR (file) : gnome_cmd_dir_new_from_info (file->info,
dir);
}
diff --git a/src/gnome-cmd-user-actions.cc b/src/gnome-cmd-user-actions.cc
index 7e080f1f..3461e20a 100644
--- a/src/gnome-cmd-user-actions.cc
+++ b/src/gnome-cmd-user-actions.cc
@@ -1382,7 +1382,7 @@ void mark_compare_directories (GtkMenuItem *menuitem, gpointer not_used)
{
auto f2 = static_cast<GnomeCmdFile*> (i2->data);
- if (!f2->is_dotdot && f2->info->type!=GNOME_VFS_FILE_TYPE_DIRECTORY)
+ if (!f2->is_dotdot && f2->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) !=
G_FILE_TYPE_DIRECTORY)
files2[f2->get_name()] = f2;
}
@@ -1392,7 +1392,7 @@ void mark_compare_directories (GtkMenuItem *menuitem, gpointer not_used)
{
auto f1 = static_cast<GnomeCmdFile*> (i1->data);
- if (f1->is_dotdot || f1->info->type==GNOME_VFS_FILE_TYPE_DIRECTORY)
+ if (f1->is_dotdot || f1->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) ==
G_FILE_TYPE_DIRECTORY)
continue;
map<const char *,GnomeCmdFile *,ltstr>::iterator i2 = files2.find(f1->get_name());
@@ -1619,7 +1619,7 @@ void view_directory (GtkMenuItem *menuitem, gpointer not_used)
GnomeCmdFileList *fl = fs->file_list();
GnomeCmdFile *f = fl->get_selected_file();
- if (f && f->info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
+ if (f && f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_DIRECTORY)
fs->do_file_specific_action (fl, f);
}
@@ -1750,7 +1750,7 @@ void view_in_new_tab (GtkMenuItem *menuitem, gpointer not_used)
GnomeCmdFileSelector *fs = get_fs (ACTIVE);
GnomeCmdFile *file = fs->file_list()->get_selected_file();
- if (file && file->info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
+ if (file && file->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_DIRECTORY)
fs->new_tab(GNOME_CMD_DIR (file), FALSE);
else
fs->new_tab(fs->get_directory(), FALSE);
@@ -1762,7 +1762,7 @@ void view_in_inactive_tab (GtkMenuItem *menuitem, gpointer file_list)
GnomeCmdFileList *fl = file_list ? GNOME_CMD_FILE_LIST (file_list) : get_fl (ACTIVE);
GnomeCmdFile *file = fl->get_selected_file();
- if (file && file->info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
+ if (file && file->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_DIRECTORY)
get_fs (INACTIVE)->new_tab(GNOME_CMD_DIR (file), FALSE);
else
get_fs (INACTIVE)->new_tab(fl->cwd, FALSE);
diff --git a/src/imageloader.cc b/src/imageloader.cc
index 8192983c..d5a07b50 100644
--- a/src/imageloader.cc
+++ b/src/imageloader.cc
@@ -180,15 +180,11 @@ inline char *get_mime_icon_name (const gchar *mime_type)
* Returns the filename that an image representing the given filetype
* should have.
*/
-static const gchar *get_type_icon_name (GnomeVFSFileType type)
+static const gchar *get_type_icon_name (guint32 type)
{
static const gchar *names[] = {
"i-directory.png",
"i-regular.png",
- "i-chardev.png",
- "i-blockdev.png",
- "i-fifo.png",
- "i-socket.png",
"i-symlink.png"
};
@@ -198,20 +194,13 @@ static const gchar *get_type_icon_name (GnomeVFSFileType type)
#endif
switch (type)
{
- case GNOME_VFS_FILE_TYPE_DIRECTORY:
+ case G_FILE_TYPE_DIRECTORY:
return names[0];
- case GNOME_VFS_FILE_TYPE_REGULAR:
+ case G_FILE_TYPE_REGULAR:
return names[1];
- case GNOME_VFS_FILE_TYPE_CHARACTER_DEVICE:
- return names[2];
- case GNOME_VFS_FILE_TYPE_BLOCK_DEVICE:
- return names[3];
- case GNOME_VFS_FILE_TYPE_FIFO:
- return names[4];
- case GNOME_VFS_FILE_TYPE_SOCKET:
- return names[5];
- case GNOME_VFS_FILE_TYPE_SYMBOLIC_LINK:
+ case G_FILE_TYPE_SYMBOLIC_LINK:
return names[6];
+ //TODO: Add filetype names for G_FILE_TYPE_SHORTCUT and G_FILE_TYPE_MOUNTABLE
default:
return names[1];
@@ -226,9 +215,8 @@ static const gchar *get_type_icon_name (GnomeVFSFileType type)
/**
* Returns the full path to an image for the given filetype in the given directory.
- *
*/
-inline gchar *get_mime_file_type_icon_path (GnomeVFSFileType type, const gchar *icon_dir)
+inline gchar *get_mime_file_type_icon_path (guint32 type, const gchar *icon_dir)
{
return g_build_filename (icon_dir, get_type_icon_name (type), nullptr);
}
@@ -328,7 +316,7 @@ static gboolean load_icon (const gchar *icon_path, GdkPixmap **pm, GdkBitmap **b
* If symlink is true a smaller symlink image is painted over the image to indicate this.
*/
static gboolean get_mime_icon_in_dir (const gchar *icon_dir,
- GnomeVFSFileType type,
+ guint32 type,
const gchar *mime_type,
gboolean symlink,
GdkPixmap **pixmap,
@@ -337,7 +325,7 @@ static gboolean get_mime_icon_in_dir (const gchar *icon_dir,
if (!mime_type)
return FALSE;
- if (type == GNOME_VFS_FILE_TYPE_SYMBOLIC_LINK)
+ if (type == G_FILE_TYPE_SYMBOLIC_LINK)
return FALSE;
auto entry = static_cast<CacheEntry*> (g_hash_table_lookup (mime_cache, mime_type));
@@ -400,7 +388,7 @@ static gboolean get_mime_icon_in_dir (const gchar *icon_dir,
}
-static gboolean get_mime_icon (GnomeVFSFileType type,
+static gboolean get_mime_icon (guint32 type,
const gchar *mime_type,
gboolean symlink,
GdkPixmap **pixmap,
@@ -413,7 +401,7 @@ static gboolean get_mime_icon (GnomeVFSFileType type,
}
-inline gboolean get_type_icon (GnomeVFSFileType type,
+inline gboolean get_type_icon (guint32 type,
gboolean symlink,
GdkPixmap **pixmap,
GdkBitmap **mask)
@@ -427,7 +415,7 @@ inline gboolean get_type_icon (GnomeVFSFileType type,
}
-gboolean IMAGE_get_pixmap_and_mask (GnomeVFSFileType type,
+gboolean IMAGE_get_pixmap_and_mask (guint32 type,
const gchar *mime_type,
gboolean symlink,
GdkPixmap **pixmap,
diff --git a/src/imageloader.h b/src/imageloader.h
index c41cef67..6fdcec45 100644
--- a/src/imageloader.h
+++ b/src/imageloader.h
@@ -85,7 +85,7 @@ inline GdkPixbuf *IMAGE_get_pixbuf (Pixmap pixmap_id)
return pixmap ? pixmap->pixbuf : NULL;
}
-gboolean IMAGE_get_pixmap_and_mask (GnomeVFSFileType type,
+gboolean IMAGE_get_pixmap_and_mask (guint32 type,
const gchar *mime_type,
gboolean symlink,
GdkPixmap **pixmap,
diff --git a/src/ls_colors.cc b/src/ls_colors.cc
index 9eb30bbf..10ce0d63 100644
--- a/src/ls_colors.cc
+++ b/src/ls_colors.cc
@@ -88,7 +88,7 @@ static LsColor *ext_color (gchar *key, gchar *val)
key++;
while (key[0] == '.');
col = g_new (LsColor, 1);
- col->type = GNOME_VFS_FILE_TYPE_REGULAR;
+ col->type = G_FILE_TYPE_REGULAR;
col->ext = g_strdup (key);
col->fg = nullptr;
col->bg = nullptr;
@@ -115,19 +115,17 @@ static LsColor *type_color (gchar *key, gchar *val)
// col->bg = nullptr;
if (strcmp (key, "fi") == 0)
- col->type = GNOME_VFS_FILE_TYPE_REGULAR;
+ col->type = G_FILE_TYPE_REGULAR;
else if (strcmp (key, "di") == 0)
- col->type = GNOME_VFS_FILE_TYPE_DIRECTORY;
- else if (strcmp (key, "pi") == 0)
- col->type = GNOME_VFS_FILE_TYPE_FIFO;
- else if (strcmp (key, "so") == 0)
- col->type = GNOME_VFS_FILE_TYPE_SOCKET;
- else if (strcmp (key, "bd") == 0)
- col->type = GNOME_VFS_FILE_TYPE_BLOCK_DEVICE;
- else if (strcmp (key, "cd") == 0)
- col->type = GNOME_VFS_FILE_TYPE_CHARACTER_DEVICE;
+ col->type = G_FILE_TYPE_DIRECTORY;
else if (strcmp (key, "ln") == 0)
- col->type = GNOME_VFS_FILE_TYPE_SYMBOLIC_LINK;
+ col->type = G_FILE_TYPE_SYMBOLIC_LINK;
+ else if (strcmp (key, "pi") == 0)
+ col->type = G_FILE_TYPE_SPECIAL;
+ else if (strcmp (key, "sc") == 0)
+ col->type = G_FILE_TYPE_SHORTCUT;
+ else if (strcmp (key, "mn") == 0)
+ col->type = G_FILE_TYPE_MOUNTABLE;
else
{
g_free (col);
@@ -203,8 +201,8 @@ void ls_colors_init ()
LsColor *ls_colors_get (GnomeCmdFile *f)
{
- if (f->info->symlink_name)
- return type_colors[GNOME_VFS_FILE_TYPE_SYMBOLIC_LINK];
+ if (f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_SYMBOLIC_LINK)
+ return type_colors[G_FILE_TYPE_SYMBOLIC_LINK];
LsColor *col = nullptr;
const gchar *ext = f->get_extension();
diff --git a/src/ls_colors.h b/src/ls_colors.h
index fe78efd0..eb49a75d 100644
--- a/src/ls_colors.h
+++ b/src/ls_colors.h
@@ -25,7 +25,7 @@
struct LsColor
{
- GnomeVFSFileType type;
+ GFileType type;
gchar *ext;
GdkColor *fg, *bg;
};
diff --git a/src/tags/gnome-cmd-tags-file.cc b/src/tags/gnome-cmd-tags-file.cc
index 650cccfc..cb91d703 100644
--- a/src/tags/gnome-cmd-tags-file.cc
+++ b/src/tags/gnome-cmd-tags-file.cc
@@ -67,5 +67,5 @@ void gcmd_tags_file_load_metadata(GnomeCmdFile *f)
f->metadata->add(TAG_FILE_PERMISSIONS, perm2textstring(f->info->permissions,buff,sizeof(buff)));
- f->metadata->add(TAG_FILE_FORMAT, f->info->type==GNOME_VFS_FILE_TYPE_DIRECTORY ? "Folder" :
f->info->mime_type);
+ f->metadata->add(TAG_FILE_FORMAT, f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) ==
G_FILE_TYPE_DIRECTORY ? "Folder" : f->info->mime_type);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]