[gnome-commander] Move retrieval of standard file type enum in GnomeCmdFile class
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] Move retrieval of standard file type enum in GnomeCmdFile class
- Date: Sun, 24 Jan 2021 16:41:06 +0000 (UTC)
commit 514178bbb056c54bd835a4778e34a969f53ab794
Author: Uwe Scholz <u scholz83 gmx de>
Date: Sun Jan 24 14:02:00 2021 +0100
Move retrieval of standard file type enum in GnomeCmdFile class
src/gnome-cmd-file-popmenu.cc | 34 +++++++---------------------------
src/gnome-cmd-file-popmenu.h | 1 -
src/gnome-cmd-file.cc | 26 ++++++++++++++++++++++++++
src/gnome-cmd-file.h | 1 +
4 files changed, 34 insertions(+), 28 deletions(-)
---
diff --git a/src/gnome-cmd-file-popmenu.cc b/src/gnome-cmd-file-popmenu.cc
index 14524dd4..5bde869d 100644
--- a/src/gnome-cmd-file-popmenu.cc
+++ b/src/gnome-cmd-file-popmenu.cc
@@ -394,29 +394,6 @@ static void add_fav_app_menu_item (GtkUIManager *uiManager, guint mergeIdFavApp,
}
-guint32 get_gfile_standard_type(GFile *gFile)
-{
- GError *error;
- error = nullptr;
- auto gcmdFileInfo = g_file_query_info(gFile,
- G_FILE_ATTRIBUTE_STANDARD_TYPE,
- G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
- nullptr,
- &error);
- if (error)
- {
- g_message ("retrieving file info failed: %s", error->message);
- g_error_free (error);
- }
-
- auto gFileStandardType = g_file_info_get_attribute_uint32 (gcmdFileInfo,
- G_FILE_ATTRIBUTE_STANDARD_TYPE);
-
- g_object_unref(gcmdFileInfo);
-
- return gFileStandardType;
-}
-
inline gboolean fav_app_matches_files (GnomeCmdApp *app, GList *files)
{
@@ -426,7 +403,8 @@ inline gboolean fav_app_matches_files (GnomeCmdApp *app, GList *files)
for (; files; files = files->next)
{
auto gnomeCmdFile = static_cast<GnomeCmdFile*> (files->data);
- if (get_gfile_standard_type(gnomeCmdFile->gFile) != G_FILE_TYPE_DIRECTORY)
+ if (gnomeCmdFile->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE)
+ != G_FILE_TYPE_DIRECTORY)
return FALSE;
}
return TRUE;
@@ -435,7 +413,8 @@ inline gboolean fav_app_matches_files (GnomeCmdApp *app, GList *files)
for (; files; files = files->next)
{
auto gnomeCmdFile = static_cast<GnomeCmdFile*> (files->data);
- if (get_gfile_standard_type(gnomeCmdFile->gFile) != G_FILE_TYPE_REGULAR)
+ if (gnomeCmdFile->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE)
+ != G_FILE_TYPE_REGULAR)
return FALSE;
}
return TRUE;
@@ -444,7 +423,7 @@ inline gboolean fav_app_matches_files (GnomeCmdApp *app, GList *files)
for (; files; files = files->next)
{
auto gnomeCmdFile = static_cast<GnomeCmdFile*> (files->data);
- auto gFileType = get_gfile_standard_type(gnomeCmdFile->gFile);
+ auto gFileType = gnomeCmdFile->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE);
if (gFileType != G_FILE_TYPE_REGULAR && gFileType != G_FILE_TYPE_DIRECTORY)
return FALSE;
}
@@ -461,7 +440,8 @@ inline gboolean fav_app_matches_files (GnomeCmdApp *app, GList *files)
#endif
auto gnomeCmdFile = static_cast<GnomeCmdFile*> (files->data);
- if (get_gfile_standard_type(gnomeCmdFile->gFile) != G_FILE_TYPE_REGULAR)
+ if (gnomeCmdFile->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE)
+ != G_FILE_TYPE_REGULAR)
return FALSE;
// Check that the file matches at least one pattern
diff --git a/src/gnome-cmd-file-popmenu.h b/src/gnome-cmd-file-popmenu.h
index f8c95f73..aa29079a 100644
--- a/src/gnome-cmd-file-popmenu.h
+++ b/src/gnome-cmd-file-popmenu.h
@@ -57,4 +57,3 @@ GtkUIManager *get_file_popup_ui_manager (GnomeCmdFileList *gnomeCmdFileList);
guint add_open_with_entries (GtkUIManager *ui_manager, GnomeCmdFileList *gnomeCmdFileList);
guint add_action_script_entries(GtkUIManager *uiManager, GList *files);
void add_execute_entry(GtkUIManager *ui_manager, GnomeCmdFileList *gnomeCmdFileList);
-guint32 get_gfile_standard_type(GFile *gFile);
diff --git a/src/gnome-cmd-file.cc b/src/gnome-cmd-file.cc
index 78b83bdc..2a88ea86 100644
--- a/src/gnome-cmd-file.cc
+++ b/src/gnome-cmd-file.cc
@@ -492,6 +492,32 @@ gchar *GnomeCmdFile::GetGfileAttributeString(const char *attribute)
}
+guint32 GnomeCmdFile::GetGfileAttributeUInt32(const char *attribute)
+{
+ GError *error;
+ error = nullptr;
+ guint32 gFileAttributeUInt32 = 0;
+
+ auto gcmdFileInfo = g_file_query_info(this->gFile,
+ attribute,
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+ nullptr,
+ &error);
+ if (error)
+ {
+ g_message ("retrieving file info failed: %s", error->message);
+ g_error_free (error);
+ }
+ else
+ {
+ gFileAttributeUInt32 = g_file_info_get_attribute_uint32 (gcmdFileInfo, attribute);
+ g_object_unref(gcmdFileInfo);
+ }
+
+ return gFileAttributeUInt32;
+}
+
+
gchar *GnomeCmdFile::get_default_application_name_string()
{
auto contentType = GetGfileAttributeString (G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
diff --git a/src/gnome-cmd-file.h b/src/gnome-cmd-file.h
index 73a527b2..dbb7941c 100644
--- a/src/gnome-cmd-file.h
+++ b/src/gnome-cmd-file.h
@@ -101,6 +101,7 @@ struct GnomeCmdFile
void invalidate_tree_size();
gboolean has_tree_size();
+ guint32 GetGfileAttributeUInt32(const char *attribute);
gchar *GetGfileAttributeString(const char *attribute);
gchar *get_default_application_name_string();
gchar *get_default_application_action_label(GAppInfo *gAppInfo);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]