[Goodies-commits] r5491 - in thunar-shares-plugin/trunk: libshares thunar-plugin

Daniel Morales danielm at xfce.org
Mon Sep 29 18:17:05 CEST 2008


Author: danielm
Date: 2008-09-29 16:17:05 +0000 (Mon, 29 Sep 2008)
New Revision: 5491

Modified:
   thunar-shares-plugin/trunk/libshares/libshares-util.c
   thunar-shares-plugin/trunk/libshares/libshares-util.h
   thunar-shares-plugin/trunk/thunar-plugin/tsp-admin-editor.c
   thunar-shares-plugin/trunk/thunar-plugin/tsp-admin.c
   thunar-shares-plugin/trunk/thunar-plugin/tsp-page.c
   thunar-shares-plugin/trunk/thunar-plugin/tsp-provider.c
Log:
Better libshares nameing, and add some GTK-doc to it

Modified: thunar-shares-plugin/trunk/libshares/libshares-util.c
===================================================================
--- thunar-shares-plugin/trunk/libshares/libshares-util.c	2008-09-29 15:36:18 UTC (rev 5490)
+++ thunar-shares-plugin/trunk/libshares/libshares-util.c	2008-09-29 16:17:05 UTC (rev 5491)
@@ -38,9 +38,17 @@
 static gboolean tsp_check_perms (const gchar *path,
                                  gboolean     is_writable);
 
-/* Gets a local file from the thunar-x file info*/
+/**
+ * libshares_get_local_file:
+ * @filex: Thunarx File Info
+ *
+ * Gets a local file from the thunar-x file info.
+ *
+ * Return value: A newly allocated string containing the absolute
+ * path. The returned string should be freed when no longer needed. 
+ **/
 gchar*
-tsp_get_local_file (ThunarxFileInfo *filex)
+libshares_get_local_file (ThunarxFileInfo *filex)
 {
   gchar *file, *file_local;
 
@@ -51,10 +59,18 @@
   return file_local;
 }
 
-/* Safe string comparison */
+/**
+ * libshares_str_equal:
+ * @txt1: String #1 to compare.
+ * @txt2: String #2 to compare.
+ *
+ * Compares two strings. Is NULL-safe.
+ *
+ * Return value: #TRUE if both strings are equal.
+ **/
 gboolean
-tsp_str_equal (const char *txt1,
-               const char *txt2)
+libshares_str_equal (const char *txt1,
+                     const char *txt2)
 {
   if (G_STR_EMPTY (txt1) || G_STR_EMPTY (txt2))
   {
@@ -67,9 +83,16 @@
   return g_str_equal (txt1, txt2);
 }
 
-/* Un-share a folder */
+/**
+ * libshares_shares_unshare:
+ * @path: Absolute path of the folder.
+ *
+ * UnShare a folder.
+ *
+ * Return value: #TRUE if the folder was unshared correctly.
+ **/
 gboolean
-tsp_shares_unshare (const gchar *path)
+libshares_shares_unshare (const gchar *path)
 {
   gboolean ret = FALSE;
   gboolean is_shared;
@@ -82,7 +105,7 @@
   /* Check error */
   if (!result)
   {
-    tsp_show_error (NULL, error->message);
+    libshares_show_error (NULL, error->message);
     g_error_free (error);
     error = NULL;
   }
@@ -92,7 +115,7 @@
     /* Un-share it */
     ret = shares_modify_share (path, NULL, &error);
     if (!ret){
-      tsp_show_error (NULL, error->message);
+      libshares_show_error (NULL, error->message);
       g_error_free (error);
     } else {
       ret = TRUE;
@@ -102,20 +125,33 @@
   /* Notify changes */
   if (ret)
   {
-    tsp_monitor_feed (path);
+    libshares_monitor_feed (path);
   }
 
   return ret;
 }
 
-/* Share a folder */
+/**
+ * libshares_shares_share:
+ * @file_local: Absolute path of the folder.
+ * @name: A name for the Share. Must be unique and < 12 chars long.
+ * @comments: Folder comment (optional)
+ * @is_writable: Allow write access.
+ * @guests_ok: Allow guest access.
+ * @old_name: Optional. Set this when editing info of a share.
+ *
+ * Shares a folder.
+ *
+ * Return value: A new ShareInfo struct if the folder was shared
+ * correctly, or NULL if error. Free this with shares_free_share_info ().
+ **/
 ShareInfo *
-tsp_shares_share (const gchar  *file_local,
-                  const gchar  *name,
-                  const gchar  *comments,
-                  gboolean      is_writable,
-                  gboolean      guests_ok,
-                  const gchar  *old_name)
+libshares_shares_share (const gchar  *file_local,
+                        const gchar  *name,
+                        const gchar  *comments,
+                        gboolean      is_writable,
+                        gboolean      guests_ok,
+                        const gchar  *old_name)
 {
   ShareInfo *share_info = NULL;
   gboolean   exists;
@@ -124,7 +160,7 @@
 
   /* Check share name */
   if (G_STR_EMPTY (name)){
-    tsp_show_error (NULL, _("Please, write a name."));
+    libshares_show_error (NULL, _("Please, write a name."));
     return NULL;
   }
 
@@ -132,7 +168,7 @@
   if (g_utf8_strlen (name, -1) > 12)
   {
     //-- Fixme this should be just a warning.
-    tsp_show_error (NULL, _("Share name is too long."));
+    libshares_show_error (NULL, _("Share name is too long."));
     return NULL;
   }
 
@@ -146,7 +182,7 @@
       gchar *str;
 
       str = g_strdup_printf (_("Error while getting share information: %s"), err->message);
-      tsp_show_error (NULL, str);
+      libshares_show_error (NULL, str);
       g_free (str);
       g_error_free (err);
 
@@ -155,7 +191,7 @@
 
     if (exists)
     {
-      tsp_show_error (NULL, _("Another share has the same name"));
+      libshares_show_error (NULL, _("Another share has the same name"));
       return NULL;
     }
   }
@@ -179,7 +215,7 @@
     ret = shares_modify_share (file_local, share_info, &err);
     if (!ret)
     {
-      tsp_show_error (NULL, err->message);
+      libshares_show_error (NULL, err->message);
       g_error_free (err);
       shares_free_share_info (share_info);
       share_info = NULL;
@@ -189,16 +225,23 @@
   /* Notify changes */
   if (share_info)
   {
-    tsp_monitor_feed (file_local);
+    libshares_monitor_feed (file_local);
   }
 
   return share_info;
 }
 
-/* Displays an error message :(*/
+/**
+ * libshares_show_error:
+ * @text: Main text (the bold one).
+ * @secondary: Secondary text. (error details)
+ *
+ * Displays an error dialog message :(.
+ *
+ **/
 void
-tsp_show_error (const char *text,
-                const char *secondary)
+libshares_show_error (const char *text,
+                      const char *secondary)
 {
   GtkWidget  *dialog;
 
@@ -220,9 +263,16 @@
   gtk_widget_destroy (dialog);
 }
 
-/* Asks 'text' to the user */
+/**
+ * libshares_ask_user:
+ * @text: Question :)
+ *
+ * Asks 'text' to the user.
+ *
+ * Return value: #TRUE if the users marks OK.
+ **/
 gboolean
-tsp_ask_user (const char *text)
+libshares_ask_user (const char *text)
 {
   GtkWidget *dialog;
   gboolean result;
@@ -240,8 +290,16 @@
   return result;
 }
 
+/**
+ * libshares_is_shareable:
+ * @info: FileInfo
+ *
+ * Checks if the fileinfo is shareable. (Folder, and local files checks).
+ *
+ * Return value: #TRUE is shareable.
+ **/
 gboolean
-tsp_is_shareable (ThunarxFileInfo *info)
+libshares_is_shareable (ThunarxFileInfo *info)
 {
   gboolean retval;
   gchar   *scheme;
@@ -259,9 +317,14 @@
   return retval;
 }
 
-/* Notify the file system about shareing changes */
+/**
+ * libshares_monitor_feed:
+ * @uri: Absolute path or URI of the file.
+ *
+ * Notify the file system about shareing changes.
+ **/
 void
-tsp_monitor_feed (const gchar *uri)
+libshares_monitor_feed (const gchar *uri)
 {
   ThunarVfsMonitor *monitor;
   ThunarVfsPath    *path;
@@ -284,7 +347,7 @@
                gboolean  need_w,
                gboolean  need_x)
 {
-  return tsp_ask_user (_("Thunar needs to add some permissions to your folder in order to share it. Do you agree?"));
+  return libshares_ask_user (_("Thunar needs to add some permissions to your folder in order to share it. Do you agree?"));
 }
 
 /* Checks if the current file has the necesary permissions */
@@ -325,7 +388,7 @@
 #endif
     if (g_chmod (path, new_mode) != 0)
     {
-      tsp_show_error (NULL, _("Error when changing folder permissions."));
+      libshares_show_error (NULL, _("Error when changing folder permissions."));
       return FALSE;
     }
   }

Modified: thunar-shares-plugin/trunk/libshares/libshares-util.h
===================================================================
--- thunar-shares-plugin/trunk/libshares/libshares-util.h	2008-09-29 15:36:18 UTC (rev 5490)
+++ thunar-shares-plugin/trunk/libshares/libshares-util.h	2008-09-29 16:17:05 UTC (rev 5491)
@@ -29,28 +29,28 @@
 
 #define G_STR_EMPTY(x) ((x) == NULL || (x)[0] == '\0')
 
-gchar   *tsp_get_local_file (ThunarxFileInfo *file);
+gchar     *libshares_get_local_file (ThunarxFileInfo *file);
 
-gboolean tsp_str_equal      (const char      *txt1,
-                             const char      *txt2);
+gboolean   libshares_str_equal      (const char      *txt1,
+                                     const char      *txt2);
 
-void     tsp_show_error     (const char      *text,
-                             const char      *secondary);
+void       libshares_show_error     (const char      *text,
+                                     const char      *secondary);
 
-gboolean tsp_ask_user       (const char      *text);
+gboolean   libshares_ask_user       (const char      *text);
 
-void     tsp_monitor_feed   (const gchar *uri);
+void       libshares_monitor_feed   (const gchar *uri);
 
-gboolean tsp_is_shareable   (ThunarxFileInfo *info);
+gboolean   libshares_is_shareable   (ThunarxFileInfo *info);
 
-gboolean tsp_shares_unshare (const gchar     *path);
+gboolean   libshares_shares_unshare (const gchar     *path);
 
-ShareInfo *tsp_shares_share (const gchar     *file_local,
-                             const gchar     *name,
-                             const gchar     *comments,
-                             gboolean         is_writable,
-                             gboolean         guests_ok,
-                             const gchar     *old_name);
+ShareInfo *libshares_shares_share   (const gchar     *file_local,
+                                     const gchar     *name,
+                                     const gchar     *comments,
+                                     gboolean         is_writable,
+                                     gboolean         guests_ok,
+                                     const gchar     *old_name);
 
 G_END_DECLS
 

Modified: thunar-shares-plugin/trunk/thunar-plugin/tsp-admin-editor.c
===================================================================
--- thunar-shares-plugin/trunk/thunar-plugin/tsp-admin-editor.c	2008-09-29 15:36:18 UTC (rev 5490)
+++ thunar-shares-plugin/trunk/thunar-plugin/tsp-admin-editor.c	2008-09-29 16:17:05 UTC (rev 5491)
@@ -202,12 +202,12 @@
   is_writable = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->share_write));
   guests_ok = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->share_guest));
 
-  share_info = tsp_shares_share (local_file,
-                                 name,
-                                 comments,
-                                 is_writable,
-                                 guests_ok,
-                                 editor->old_name);
+  share_info = libshares_shares_share (local_file,
+                                       name,
+                                       comments,
+                                       is_writable,
+                                       guests_ok,
+                                       editor->old_name);
 
   g_free (local_file);
 
@@ -248,7 +248,7 @@
   /* Check error */
   if (!result)
   {
-    tsp_show_error (_("There was an error while listing shares"), error->message);
+    libshares_show_error (_("There was an error while listing shares"), error->message);
     g_error_free (error);
   }
 

Modified: thunar-shares-plugin/trunk/thunar-plugin/tsp-admin.c
===================================================================
--- thunar-shares-plugin/trunk/thunar-plugin/tsp-admin.c	2008-09-29 15:36:18 UTC (rev 5490)
+++ thunar-shares-plugin/trunk/thunar-plugin/tsp-admin.c	2008-09-29 16:17:05 UTC (rev 5491)
@@ -262,7 +262,7 @@
     gtk_tree_model_get (model, &iter, TSP_MANAGER_COL_PATH, &path, -1);
 
     /* Remove from shares */
-    if (tsp_shares_unshare (path)){
+    if (libshares_shares_unshare (path)){
       gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
     }
 
@@ -323,7 +323,7 @@
   /* Check error */
   if (!result)
   {
-    tsp_show_error (_("There was an error while listing shares"), error->message);
+    libshares_show_error (_("There was an error while listing shares"), error->message);
     g_error_free (error);
   }
 

Modified: thunar-shares-plugin/trunk/thunar-plugin/tsp-page.c
===================================================================
--- thunar-shares-plugin/trunk/thunar-plugin/tsp-page.c	2008-09-29 15:36:18 UTC (rev 5490)
+++ thunar-shares-plugin/trunk/thunar-plugin/tsp-page.c	2008-09-29 16:17:05 UTC (rev 5491)
@@ -387,7 +387,7 @@
   /* Check error */
   if (!result)
   {
-    tsp_show_error (_("There was an error while getting the sharing information"), error->message);
+    libshares_show_error (_("There was an error while getting the sharing information"), error->message);
     g_error_free (error);
   }
 
@@ -489,7 +489,7 @@
   gchar   *local_file;
 
   share = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tsp_page->cb_share_folder));
-  local_file = tsp_get_local_file (tsp_page->file);
+  local_file = libshares_get_local_file (tsp_page->file);
 
   if (share)
   {
@@ -505,9 +505,9 @@
     is_writable = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tsp_page->cb_share_write));
     guests_ok = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tsp_page->cb_share_guest));
 
-    share_info = tsp_shares_share (local_file, name, comments,
-                                   is_writable, guests_ok,
-                                   tsp_page->share_name);
+    share_info = libshares_shares_share (local_file, name, comments,
+                                         is_writable, guests_ok,
+                                         tsp_page->share_name);
     if (share_info != NULL)
     {
       tsp_update_default (tsp_page, share_info);
@@ -515,7 +515,7 @@
     }
   } else {
     /* Un-share the folder */
-    if (tsp_shares_unshare (local_file))
+    if (libshares_shares_unshare (local_file))
     {
       tsp_update_default (tsp_page, NULL);
     }
@@ -561,8 +561,8 @@
     result = FALSE;
   } else if ((page->can_write != write) ||
             (page->can_guests != guests) ||
-            (!tsp_str_equal (page->share_comment, comment)) ||
-            (!tsp_str_equal (page->share_name, name))){
+            (!libshares_str_equal (page->share_comment, comment)) ||
+            (!libshares_str_equal (page->share_name, name))){
     result = TRUE;
   }
 

Modified: thunar-shares-plugin/trunk/thunar-plugin/tsp-provider.c
===================================================================
--- thunar-shares-plugin/trunk/thunar-plugin/tsp-provider.c	2008-09-29 15:36:18 UTC (rev 5490)
+++ thunar-shares-plugin/trunk/thunar-plugin/tsp-provider.c	2008-09-29 16:17:05 UTC (rev 5491)
@@ -127,7 +127,7 @@
 {
   if (g_list_length (files) != 1){
     return NULL;
-  } else if (!tsp_is_shareable (THUNARX_FILE_INFO (files->data))){
+  } else if (!libshares_is_shareable (THUNARX_FILE_INFO (files->data))){
     return NULL;
   }
 
@@ -168,11 +168,11 @@
 
   if (g_list_length (files) != 1){
     return NULL;
-  } else if (!tsp_is_shareable (THUNARX_FILE_INFO (files->data))){
+  } else if (!libshares_is_shareable (THUNARX_FILE_INFO (files->data))){
     return NULL;
   }
 
-  folder_path = tsp_get_local_file (THUNARX_FILE_INFO (files->data));
+  folder_path = libshares_get_local_file (THUNARX_FILE_INFO (files->data));
 
   if (G_LIKELY (folder_path == NULL)){
     return NULL;
@@ -215,7 +215,7 @@
   if (folder == NULL)
     return;
 
-  tsp_shares_unshare (folder);
+  libshares_shares_unshare (folder);
 }
 
 static void




More information about the Goodies-commits mailing list