Hi all, this is my first attempt at writing a patch for Thunar, and I'm also
somewhat new to C, so please excuse any mistakes I may have made.  Also,
this email is a dupe because I sent a previous one with a test extension
that was too large.

I've written a patch that adds emblem support to thunarx master.  Basically
I started by adding a set_emblem method to the ThunarxFileInfoIface struct
and then working from there.  I also used some code from
thunar-emblem-chooser.c to get it working right.

The patch file is attached.  I can also attach my test extension that
demonstrates the functionality if anyone is interested.

I'd appreciate any feedback on my work, and hopefully this will get accepted
into the thunar master branch.

Thanks,
Adam Plumb
diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c
index a633242..bd9638d 100644
--- a/thunar/thunar-file.c
+++ b/thunar/thunar-file.c
@@ -101,6 +101,8 @@ static gchar             *thunar_file_info_get_uri_scheme      (ThunarxFileInfo
 static gchar             *thunar_file_info_get_mime_type       (ThunarxFileInfo        *file_info);
 static gboolean           thunar_file_info_has_mime_type       (ThunarxFileInfo        *file_info,
                                                                 const gchar            *mime_type);
+void                      thunar_file_info_set_emblem          (ThunarxFileInfo        *file_info,
+                                                                const gchar            *emblem_name);
 static gboolean           thunar_file_info_is_directory        (ThunarxFileInfo        *file_info);
 static GFileInfo         *thunar_file_info_get_file_info       (ThunarxFileInfo        *file_info);
 static GFileInfo         *thunar_file_info_get_filesystem_info (ThunarxFileInfo        *file_info);
@@ -241,6 +243,7 @@ thunar_file_info_init (ThunarxFileInfoIface *iface)
   iface->get_uri_scheme = thunar_file_info_get_uri_scheme;
   iface->get_mime_type = thunar_file_info_get_mime_type;
   iface->has_mime_type = thunar_file_info_has_mime_type;
+  iface->set_emblem = thunar_file_info_set_emblem;
   iface->is_directory = thunar_file_info_is_directory;
   iface->get_file_info = thunar_file_info_get_file_info;
   iface->get_filesystem_info = thunar_file_info_get_filesystem_info;
@@ -382,6 +385,23 @@ thunar_file_info_has_mime_type (ThunarxFileInfo *file_info,
 }
 
 
+void
+thunar_file_info_set_emblem (ThunarxFileInfo *file_info,
+                             const gchar     *emblem_name)
+{
+  GList *emblem_names = NULL;
+  
+  if (THUNAR_FILE (file_info)->info == NULL)
+    return;
+
+  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_foreach (emblem_names, (GFunc) g_free, NULL);
+  g_list_free (emblem_names);
+}
+
 
 static gboolean
 thunar_file_info_is_directory (ThunarxFileInfo *file_info)
diff --git a/thunarx/thunarx-file-info.c b/thunarx/thunarx-file-info.c
index 5646024..8eaf8c9 100644
--- a/thunarx/thunarx-file-info.c
+++ b/thunarx/thunarx-file-info.c
@@ -267,6 +267,15 @@ thunarx_file_info_has_mime_type (ThunarxFileInfo *file_info,
 
 
 
+void
+thunarx_file_info_set_emblem (ThunarxFileInfo *file_info,
+                              const gchar           *emblem_name)
+{
+  g_return_val_if_fail (THUNARX_IS_FILE_INFO (file_info), FALSE);
+  (*THUNARX_FILE_INFO_GET_IFACE (file_info)->set_emblem) (file_info, emblem_name);
+}
+
+
 /**
  * thunarx_file_info_is_directory:
  * @file_info : a #ThunarxFileInfo.
diff --git a/thunarx/thunarx-file-info.h b/thunarx/thunarx-file-info.h
index 13a7001..864fe9f 100644
--- a/thunarx/thunarx-file-info.h
+++ b/thunarx/thunarx-file-info.h
@@ -79,7 +79,8 @@ struct _ThunarxFileInfoIface
   gchar     *(*get_mime_type)       (ThunarxFileInfo *file_info);
   gboolean   (*has_mime_type)       (ThunarxFileInfo *file_info,
                                      const gchar     *mime_type);
-
+  void       (*set_emblem)          (ThunarxFileInfo *file_info,
+                                     const gchar     *emblem_name);
   gboolean   (*is_directory)        (ThunarxFileInfo *file_info);
 
   GFileInfo *(*get_file_info)       (ThunarxFileInfo *file_info);
@@ -118,6 +119,9 @@ gchar     *thunarx_file_info_get_mime_type       (ThunarxFileInfo *file_info);
 gboolean   thunarx_file_info_has_mime_type       (ThunarxFileInfo *file_info,
                                                   const gchar     *mime_type);
 
+void       thunarx_file_info_set_emblem          (ThunarxFileInfo *file_info,
+                                                  const gchar     *emblem_name);
+                                                  
 gboolean   thunarx_file_info_is_directory        (ThunarxFileInfo *file_info);
 
 GFileInfo *thunarx_file_info_get_file_info       (ThunarxFileInfo *file_info);
_______________________________________________
Thunar-dev mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/thunar-dev

Reply via email to