diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index a633242..de7c35d 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -105,6 +105,12 @@ static gboolean thunar_file_info_is_directory (ThunarxFileInfo static GFileInfo *thunar_file_info_get_file_info (ThunarxFileInfo *file_info); static GFileInfo *thunar_file_info_get_filesystem_info (ThunarxFileInfo *file_info); static GFile *thunar_file_info_get_location (ThunarxFileInfo *file_info); +void thunar_file_info_add_emblem (ThunarxFileInfo *file_info, + const gchar *emblem_name); +void thunar_file_info_remove_emblem (ThunarxFileInfo *file_info, + const gchar *emblem_name); +void thunar_file_info_remove_emblems (ThunarxFileInfo *file_info); + static void thunar_file_info_changed (ThunarxFileInfo *file_info); static gboolean thunar_file_denies_access_permission (const ThunarFile *file, ThunarFileMode usr_permissions, @@ -245,6 +251,9 @@ thunar_file_info_init (ThunarxFileInfoIface *iface) iface->get_file_info = thunar_file_info_get_file_info; iface->get_filesystem_info = thunar_file_info_get_filesystem_info; iface->get_location = thunar_file_info_get_location; + iface->add_emblem = thunar_file_info_add_emblem; + iface->remove_emblem = thunar_file_info_remove_emblem; + iface->remove_emblems = thunar_file_info_remove_emblems; iface->changed = thunar_file_info_changed; } @@ -426,6 +435,58 @@ thunar_file_info_get_location (ThunarxFileInfo *file_info) +void +thunar_file_info_add_emblem (ThunarxFileInfo *file_info, + const gchar *emblem_name) +{ + GList *emblem_names = NULL; + + _thunar_return_if_fail (THUNAR_IS_FILE (file_info)); + + emblem_names = thunar_file_get_emblem_names (THUNAR_FILE (file_info)); + + if(g_list_find_custom (emblem_names, emblem_name, (GCompareFunc) strcmp) == NULL) + emblem_names = g_list_append (emblem_names, g_strdup (emblem_name)); + + thunar_file_set_emblem_names (THUNAR_FILE (file_info), emblem_names); + + //release the emblem name list + g_list_free (emblem_names); +} + + + +void +thunar_file_info_remove_emblem (ThunarxFileInfo *file_info, + const gchar *emblem_name) +{ + GList *emblem_names = NULL; + GList *l = NULL; + + _thunar_return_if_fail (THUNAR_IS_FILE (file_info)); + + emblem_names = thunar_file_get_emblem_names (THUNAR_FILE (file_info)); + + while ((l = g_list_find_custom (emblem_names, emblem_name, (GCompareFunc) strcmp))) + emblem_names = g_list_delete_link (emblem_names, l); + + thunar_file_set_emblem_names (THUNAR_FILE (file_info), emblem_names); + + //release the emblem name list + g_list_free (emblem_names); + g_list_free (l); +} + + + +void +thunar_file_info_remove_emblems (ThunarxFileInfo *file_info) +{ + thunar_file_set_emblem_names (THUNAR_FILE (file_info), NULL); +} + + + static void thunar_file_info_changed (ThunarxFileInfo *file_info) { diff --git a/thunarx/thunarx-file-info.c b/thunarx/thunarx-file-info.c index 5646024..a65b559 100644 --- a/thunarx/thunarx-file-info.c +++ b/thunarx/thunarx-file-info.c @@ -349,6 +349,58 @@ thunarx_file_info_get_location (ThunarxFileInfo *file_info) } +/** + * thunarx_file_info_add_emblem: + * @file_info : a #ThunarxFileInfo. + * @emblem_name : The emblem name to add + * + * Applies a custom emblem to a file or folder + * + **/ +void +thunarx_file_info_add_emblem (ThunarxFileInfo *file_info, + const gchar *emblem_name) +{ + g_return_if_fail (THUNARX_IS_FILE_INFO (file_info)); + (*THUNARX_FILE_INFO_GET_IFACE (file_info)->add_emblem) (file_info, emblem_name); +} + + + +/** + * thunarx_file_info_remove_emblem: + * @file_info : a #ThunarxFileInfo. + * @emblem_name : The emblem name to remove + * + * Removes a custom emblem from a file or folder + * + **/ +void +thunarx_file_info_remove_emblem (ThunarxFileInfo *file_info, + const gchar *emblem_name) +{ + g_return_if_fail (THUNARX_IS_FILE_INFO (file_info)); + (*THUNARX_FILE_INFO_GET_IFACE (file_info)->remove_emblem) (file_info, emblem_name); +} + + + +/** + * thunarx_file_info_remove_emblems: + * @file_info : a #ThunarxFileInfo. + * @emblem_name : The emblem name to add + * + * Removes all custom emblems from a file or folder + * + **/ +void +thunarx_file_info_remove_emblems (ThunarxFileInfo *file_info) +{ + g_return_if_fail (THUNARX_IS_FILE_INFO (file_info)); + (*THUNARX_FILE_INFO_GET_IFACE (file_info)->remove_emblems) (file_info); +} + + /** * thunarx_file_info_changed: diff --git a/thunarx/thunarx-file-info.h b/thunarx/thunarx-file-info.h index 13a7001..45903c7 100644 --- a/thunarx/thunarx-file-info.h +++ b/thunarx/thunarx-file-info.h @@ -87,9 +87,12 @@ struct _ThunarxFileInfoIface GFile *(*get_location) (ThunarxFileInfo *file_info); /*< private >*/ - void (*reserved0) (void); - void (*reserved1) (void); - void (*reserved2) (void); + void (*add_emblem) (ThunarxFileInfo *file_info, + const gchar *emblem_name); + void (*remove_emblem) (ThunarxFileInfo *file_info, + const gchar *emblem_name); + void (*remove_emblems) (ThunarxFileInfo *file_info); + void (*reserved3) (void); void (*reserved4) (void); void (*reserved5) (void); @@ -117,13 +120,19 @@ gchar *thunarx_file_info_get_uri_scheme (ThunarxFileInfo *file_info); gchar *thunarx_file_info_get_mime_type (ThunarxFileInfo *file_info); gboolean thunarx_file_info_has_mime_type (ThunarxFileInfo *file_info, const gchar *mime_type); - + gboolean thunarx_file_info_is_directory (ThunarxFileInfo *file_info); GFileInfo *thunarx_file_info_get_file_info (ThunarxFileInfo *file_info); GFileInfo *thunarx_file_info_get_filesystem_info (ThunarxFileInfo *file_info); GFile *thunarx_file_info_get_location (ThunarxFileInfo *file_info); +void thunarx_file_info_add_emblem (ThunarxFileInfo *file_info, + const gchar *emblem_name); +void thunarx_file_info_remove_emblem (ThunarxFileInfo *file_info, + const gchar *emblem_name); +void thunarx_file_info_remove_emblems (ThunarxFileInfo *file_info); + void thunarx_file_info_changed (ThunarxFileInfo *file_info); void thunarx_file_info_renamed (ThunarxFileInfo *file_info);