[Xfce4-commits] r29780 - in thunar/branches/migration-to-gio: . thunar
Jannis Pohlmann
jannis at xfce.org
Sun Apr 12 14:44:31 CEST 2009
Author: jannis
Date: 2009-04-12 12:44:31 +0000 (Sun, 12 Apr 2009)
New Revision: 29780
Modified:
thunar/branches/migration-to-gio/ChangeLog
thunar/branches/migration-to-gio/thunar/thunar-application.c
thunar/branches/migration-to-gio/thunar/thunar-file.c
thunar/branches/migration-to-gio/thunar/thunar-file.h
thunar/branches/migration-to-gio/thunar/thunar-list-model.c
thunar/branches/migration-to-gio/thunar/thunar-properties-dialog.c
Log:
* thunar/thunar-application.c, thunar/thunar-file.{c,h},
thunar/thunar-list-model.c, thunar/thunar-properties-dialog.c:
Make thunar_file_get_original_path() and
thunar_file_get_symlink_target() to return const strings. Update
ThunarApplication, ThunarListModel and ThunarPropertiesDialog to
reflect these changes. Implement thunar_file_is_trashed(),
thunar_file_is_desktop_file() and thunar_file_get_display_name()
based on GIO. Remove thunar_file_read_link().
Modified: thunar/branches/migration-to-gio/ChangeLog
===================================================================
--- thunar/branches/migration-to-gio/ChangeLog 2009-04-12 12:39:11 UTC (rev 29779)
+++ thunar/branches/migration-to-gio/ChangeLog 2009-04-12 12:44:31 UTC (rev 29780)
@@ -1,12 +1,22 @@
2009-04-12 Jannis Pohlmann <jannis at xfce.org>
+ * thunar/thunar-application.c, thunar/thunar-file.{c,h},
+ thunar/thunar-list-model.c, thunar/thunar-properties-dialog.c:
+ Make thunar_file_get_original_path() and
+ thunar_file_get_symlink_target() to return const strings. Update
+ ThunarApplication, ThunarListModel and ThunarPropertiesDialog to
+ reflect these changes. Implement thunar_file_is_trashed(),
+ thunar_file_is_desktop_file() and thunar_file_get_display_name()
+ based on GIO. Remove thunar_file_read_link().
+
+2009-04-12 Jannis Pohlmann <jannis at xfce.org>
+
* thunar/thunar-file.{c,h}: Re-implement thunar_file_is_local(),
thunar_file_is_ancestor(), thunar_file_is_executable(),
thunar_file_is_readable(), thunar_file_is_writable(),
thunar_file_is_hidden(), thunar_file_is_home(),
thunar_file_is_regular() and thunar_file_dup_uri() based on GIO.
-
2009-04-12 Jannis Pohlmann <jannis at xfce.org>
* thunar/thunar-file.{c,h}: Add GFileInfo filesystem info member to
Modified: thunar/branches/migration-to-gio/thunar/thunar-application.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-application.c 2009-04-12 12:39:11 UTC (rev 29779)
+++ thunar/branches/migration-to-gio/thunar/thunar-application.c 2009-04-12 12:44:31 UTC (rev 29780)
@@ -1580,6 +1580,7 @@
GClosure *new_files_closure)
{
ThunarVfsPath *target_path;
+ const gchar *original_path;
GtkWidget *dialog;
GtkWindow *window;
GdkScreen *screen;
@@ -1587,7 +1588,6 @@
GList *source_path_list = NULL;
GList *target_path_list = NULL;
GList *lp;
- gchar *original_path;
gchar *original_dir;
gchar *display_name;
gint response = GTK_RESPONSE_YES;
@@ -1614,7 +1614,6 @@
if (G_UNLIKELY (target_path == NULL))
{
/* invalid OriginalPath, cannot continue */
- g_free (original_path);
break;
}
@@ -1671,7 +1670,6 @@
}
/* cleanup */
- g_free (original_path);
g_free (original_dir);
}
Modified: thunar/branches/migration-to-gio/thunar/thunar-file.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-file.c 2009-04-12 12:39:11 UTC (rev 29779)
+++ thunar/branches/migration-to-gio/thunar/thunar-file.c 2009-04-12 12:44:31 UTC (rev 29780)
@@ -1802,8 +1802,7 @@
{
_thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE);
_thunar_return_val_if_fail (G_IS_FILE_INFO (file->ginfo), FALSE);
- return g_file_info_get_attribute_boolean (file->ginfo,
- G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN);
+ return g_file_info_get_is_hidden (file->ginfo);
}
@@ -1851,6 +1850,64 @@
/**
+ * thunar_file_is_trashed:
+ * @file : a #ThunarFile instance.
+ *
+ * Returns %TRUE if @file is a local file that resides in
+ * the trash bin.
+ *
+ * Return value: %TRUE if @file is in the trash, or
+ * the trash folder itself.
+ **/
+gboolean
+thunar_file_is_trashed (const ThunarFile *file)
+{
+ _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE);
+ return g_file_is_trashed (file->gfile);
+}
+
+
+
+/**
+ * thunar_file_is_desktop_file:
+ * @file : a #ThunarFile.
+ *
+ * Returns %TRUE if @file is a .desktop file, but not a .directory file.
+ *
+ * Return value: %TRUE if @file is a .desktop file.
+ **/
+gboolean
+thunar_file_is_desktop_file (const ThunarFile *file)
+{
+ _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE);
+ _thunar_return_val_if_fail (G_IS_FILE_INFO (file->ginfo), FALSE);
+
+ return g_content_type_equals (g_file_info_get_content_type (file->ginfo), "application/x-desktop")
+ && !g_str_has_suffix (thunar_file_get_basename (file), ".directory");
+}
+
+
+
+/**
+ * thunar_file_get_display_name:
+ * @file : a #ThunarFile instance.
+ *
+ * Returns the @file name in the UTF-8 encoding, which is
+ * suitable for displaying the file name in the GUI.
+ *
+ * Return value: the @file name suitable for display.
+ **/
+const gchar *
+thunar_file_get_display_name (const ThunarFile *file)
+{
+ _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE);
+ _thunar_return_val_if_fail (G_IS_FILE_INFO (file->ginfo), FALSE);
+ return g_file_info_get_display_name (file->ginfo);
+}
+
+
+
+/**
* thunar_file_get_deletion_date:
* @file : a #ThunarFile instance.
* @date_style : the style used to format the date.
@@ -1896,18 +1953,15 @@
* is located in the trash. Otherwise %NULL will be
* returned.
*
- * The caller is responsible to free the returned string
- * using g_free() when no longer needed.
- *
* Return value: the original path of @file if @file is
* in the trash, %NULL otherwise.
**/
-gchar*
+const gchar *
thunar_file_get_original_path (const ThunarFile *file)
{
_thunar_return_val_if_fail (THUNAR_IS_FILE (file), NULL);
_thunar_return_val_if_fail (G_IS_FILE_INFO (file->ginfo), NULL);
- return g_strdup (g_file_info_get_attribute_string (file->ginfo, "trash::orig-file"));
+ return g_file_info_get_attribute_string (file->ginfo, "trash::orig-file");
}
Modified: thunar/branches/migration-to-gio/thunar/thunar-file.h
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-file.h 2009-04-12 12:39:11 UTC (rev 29779)
+++ thunar/branches/migration-to-gio/thunar/thunar-file.h 2009-04-12 12:44:31 UTC (rev 29780)
@@ -214,10 +214,13 @@
gboolean thunar_file_is_hidden (const ThunarFile *file);
gboolean thunar_file_is_home (const ThunarFile *file);
gboolean thunar_file_is_regular (const ThunarFile *file);
+gboolean thunar_file_is_trashed (const ThunarFile *file);
+gboolean thunar_file_is_desktop_file (const ThunarFile *file);
+const gchar *thunar_file_get_display_name (const ThunarFile *file);
gchar *thunar_file_get_deletion_date (const ThunarFile *file,
ThunarDateStyle date_style) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
-gchar *thunar_file_get_original_path (const ThunarFile *file) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+const gchar *thunar_file_get_original_path (const ThunarFile *file);
gboolean thunar_file_is_chmodable (const ThunarFile *file);
gboolean thunar_file_is_renameable (const ThunarFile *file);
@@ -356,7 +359,6 @@
**/
#define thunar_file_dup_uri(file) (g_file_get_uri (THUNAR_FILE ((file))->gfile))
-
/**
* thunar_file_get_custom_icon:
* @file : a #ThunarFile instance.
@@ -372,8 +374,6 @@
**/
#define thunar_file_get_custom_icon(file) (g_strdup (thunar_vfs_info_get_custom_icon (THUNAR_FILE ((file))->info)))
-
-
/**
* thunar_file_changed:
* @file : a #ThunarFile instance.
@@ -387,54 +387,6 @@
}G_STMT_END
/**
- * thunar_file_is_trashed:
- * @file : a #ThunarFile instance.
- *
- * Returns %TRUE if @file is a local file that resides in
- * the trash bin.
- *
- * Return value: %TRUE if @file is in the trash, or
- * the trash folder itself.
- **/
-#define thunar_file_is_trashed(file) (g_file_is_trashed (THUNAR_FILE ((file))->gfile))
-
-/**
- * thunar_file_is_desktop_file:
- * @file : a #ThunarFile.
- *
- * Returns %TRUE if @file is a .desktop file, but not a .directory file.
- *
- * Return value: %TRUE if @file is a .desktop file.
- **/
-#define thunar_file_is_desktop_file(file) (exo_str_is_equal (thunar_vfs_mime_info_get_name (thunar_file_get_mime_info ((file))), "application/x-desktop") \
- && !exo_str_is_equal (thunar_vfs_path_get_name (thunar_file_get_path ((file))), ".directory"))
-
-/**
- * thunar_file_get_display_name:
- * @file : a #ThunarFile instance.
- *
- * Returns the @file name in the UTF-8 encoding, which is
- * suitable for displaying the file name in the GUI.
- *
- * Return value: the @file name suitable for display.
- **/
-#define thunar_file_get_display_name(file) (THUNAR_FILE ((file))->info->display_name)
-
-/**
- * thunar_file_read_link:
- * @file : a #ThunarFile instance.
- * @error : return location for errors or %NULL.
- *
- * Simple wrapper to thunar_vfs_info_read_link().
- *
- * Return value: the link target of @file or %NULL
- * if an error occurred.
- **/
-#define thunar_file_read_link(file, error) (thunar_vfs_info_read_link (THUNAR_FILE ((file))->info, (error)))
-
-
-
-/**
* thunar_file_get_thumb_state:
* @file : a #ThunarFile.
*
@@ -460,8 +412,6 @@
f->flags = (f->flags & ~THUNAR_FILE_THUMB_STATE_MASK) | (thumb_state); \
}G_STMT_END
-
-
/**
* thunar_file_list_copy:
* @file_list : a list of #ThunarFile<!---->s.
Modified: thunar/branches/migration-to-gio/thunar/thunar-list-model.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-list-model.c 2009-04-12 12:39:11 UTC (rev 29779)
+++ thunar/branches/migration-to-gio/thunar/thunar-list-model.c 2009-04-12 12:44:31 UTC (rev 29780)
@@ -2201,6 +2201,7 @@
GList *selected_items)
{
ThunarVfsFileSize size_summary;
+ const gchar *original_path;
GtkTreeIter iter;
ThunarFile *file;
guint64 size;
@@ -2291,11 +2292,11 @@
g_free (size_string);
/* append the original path (if any) */
- absolute_path = thunar_file_get_original_path (file);
- if (G_UNLIKELY (absolute_path != NULL))
+ original_path = thunar_file_get_original_path (file);
+ if (G_UNLIKELY (original_path != NULL))
{
/* append the original path to the statusbar text */
- display_name = g_filename_display_name (absolute_path);
+ display_name = g_filename_display_name (original_path);
s = g_strdup_printf ("%s, %s %s", text, _("Original Path:"), display_name);
g_free (display_name);
g_free (text);
@@ -2313,8 +2314,8 @@
g_free (text);
text = s;
}
+ g_free (absolute_path);
}
- g_free (absolute_path);
}
else
{
Modified: thunar/branches/migration-to-gio/thunar/thunar-properties-dialog.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-properties-dialog.c 2009-04-12 12:39:11 UTC (rev 29779)
+++ thunar/branches/migration-to-gio/thunar/thunar-properties-dialog.c 2009-04-12 12:44:31 UTC (rev 29780)
@@ -789,12 +789,14 @@
GtkIconTheme *icon_theme;
const gchar *icon_name;
const gchar *name;
+ const gchar *path;
GdkPixbuf *icon;
guint64 size;
glong offset;
gchar *display_name;
gchar *size_string;
gchar *str;
+ gchar *date;
_thunar_return_if_fail (THUNAR_IS_PROPERTIES_DIALOG (dialog));
_thunar_return_if_fail (THUNAR_IS_FILE (dialog->file));
@@ -873,14 +875,13 @@
NULL);
/* update the link target */
- str = thunar_file_is_symlink (dialog->file) ? thunar_file_read_link (dialog->file, NULL) : NULL;
- if (G_UNLIKELY (str != NULL))
+ path = thunar_file_is_symlink (dialog->file) ? thunar_file_get_symlink_target (dialog->file) : NULL;
+ if (G_UNLIKELY (path != NULL))
{
- display_name = g_filename_display_name (str);
+ display_name = g_filename_display_name (path);
gtk_label_set_text (GTK_LABEL (dialog->link_label), display_name);
gtk_widget_show (dialog->link_label);
g_free (display_name);
- g_free (str);
}
else
{
@@ -888,14 +889,13 @@
}
/* update the original path */
- str = thunar_file_get_original_path (dialog->file);
- if (G_UNLIKELY (str != NULL))
+ path = thunar_file_get_original_path (dialog->file);
+ if (G_UNLIKELY (path != NULL))
{
- display_name = g_filename_display_name (str);
+ display_name = g_filename_display_name (path);
gtk_label_set_text (GTK_LABEL (dialog->origin_label), display_name);
gtk_widget_show (dialog->origin_label);
g_free (display_name);
- g_free (str);
}
else
{
@@ -903,12 +903,12 @@
}
/* update the deleted time */
- str = thunar_file_get_deletion_date (dialog->file, date_style);
- if (G_LIKELY (str != NULL))
+ date = thunar_file_get_deletion_date (dialog->file, date_style);
+ if (G_LIKELY (date != NULL))
{
- gtk_label_set_text (GTK_LABEL (dialog->deleted_label), str);
+ gtk_label_set_text (GTK_LABEL (dialog->deleted_label), date);
gtk_widget_show (dialog->deleted_label);
- g_free (str);
+ g_free (date);
}
else
{
@@ -916,12 +916,12 @@
}
/* update the modified time */
- str = thunar_file_get_date_string (dialog->file, THUNAR_FILE_DATE_MODIFIED, date_style);
- if (G_LIKELY (str != NULL))
+ date = thunar_file_get_date_string (dialog->file, THUNAR_FILE_DATE_MODIFIED, date_style);
+ if (G_LIKELY (date != NULL))
{
- gtk_label_set_text (GTK_LABEL (dialog->modified_label), str);
+ gtk_label_set_text (GTK_LABEL (dialog->modified_label), date);
gtk_widget_show (dialog->modified_label);
- g_free (str);
+ g_free (date);
}
else
{
@@ -929,12 +929,12 @@
}
/* update the accessed time */
- str = thunar_file_get_date_string (dialog->file, THUNAR_FILE_DATE_ACCESSED, date_style);
- if (G_LIKELY (str != NULL))
+ date = thunar_file_get_date_string (dialog->file, THUNAR_FILE_DATE_ACCESSED, date_style);
+ if (G_LIKELY (date != NULL))
{
- gtk_label_set_text (GTK_LABEL (dialog->accessed_label), str);
+ gtk_label_set_text (GTK_LABEL (dialog->accessed_label), date);
gtk_widget_show (dialog->accessed_label);
- g_free (str);
+ g_free (date);
}
else
{
More information about the Xfce4-commits
mailing list