[Goodies-commits] r5205 - in thunar-shares-plugin/trunk: . data libshares thunar-plugin

Daniel Morales danielm at xfce.org
Wed Aug 6 20:13:32 CEST 2008


Author: danielm
Date: 2008-08-06 18:13:31 +0000 (Wed, 06 Aug 2008)
New Revision: 5205

Modified:
   thunar-shares-plugin/trunk/ChangeLog
   thunar-shares-plugin/trunk/TODO
   thunar-shares-plugin/trunk/data/thunar-page.xml
   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-page.c
Log:
	* data/thunar-page.xml:
	* libshares/libshares-util.[ch]:
	* thunar-plugin/tsp-admin-editor.c:
	* thunar-plugin/tsp-page.c: Add share name checks. (Length and look
	for already used names before change details)
	* TODO: Added 0.20 milestone points to do before next release. $
 

Modified: thunar-shares-plugin/trunk/ChangeLog
===================================================================
--- thunar-shares-plugin/trunk/ChangeLog	2008-08-06 00:05:30 UTC (rev 5204)
+++ thunar-shares-plugin/trunk/ChangeLog	2008-08-06 18:13:31 UTC (rev 5205)
@@ -1,3 +1,12 @@
+2008-08-06	Daniel Morales <daniel at daniel.com.uy>
+
+	* data/thunar-page.xml:
+	* libshares/libshares-util.[ch]:
+	* thunar-plugin/tsp-admin-editor.c:
+	* thunar-plugin/tsp-page.c: Add share name checks. (Length and look
+	for already used names before change details)
+	* TODO: Added 0.20 milestone points to do before next release.
+
 2008-08-05	Daniel Morales <daniel at daniel.com.uy>
 
 	* libshares/share.[ch]: 

Modified: thunar-shares-plugin/trunk/TODO
===================================================================
--- thunar-shares-plugin/trunk/TODO	2008-08-06 00:05:30 UTC (rev 5204)
+++ thunar-shares-plugin/trunk/TODO	2008-08-06 18:13:31 UTC (rev 5205)
@@ -8,3 +8,15 @@
 
   * We need to review the permissions hierarchy check:
     (libshares/libshares-util.c: tsp_check_perms)
+
+MILESONE 0.20
+=======================================================================
+
+  * If we open two or more properties dialogs of the same folder and
+    we change the share options there, those changes aren't reflected
+    in the other dialogs. Also when changing details from shares-admin
+    dialog.
+
+  * Add error checks when we call shares_get_share_info_for_path().
+
+  * 12 chars share-name check should warn the user, isn't a error.

Modified: thunar-shares-plugin/trunk/data/thunar-page.xml
===================================================================
--- thunar-shares-plugin/trunk/data/thunar-page.xml	2008-08-06 00:05:30 UTC (rev 5204)
+++ thunar-shares-plugin/trunk/data/thunar-page.xml	2008-08-06 18:13:31 UTC (rev 5205)
@@ -81,7 +81,6 @@
           <object class="GtkEntry" id="entry_share_name">
             <property name="visible">True</property>
             <property name="can_focus">True</property>
-            <property name="max_length">12</property>
           </object>
           <packing>
             <property name="padding">0</property>

Modified: thunar-shares-plugin/trunk/libshares/libshares-util.c
===================================================================
--- thunar-shares-plugin/trunk/libshares/libshares-util.c	2008-08-06 00:05:30 UTC (rev 5204)
+++ thunar-shares-plugin/trunk/libshares/libshares-util.c	2008-08-06 18:13:31 UTC (rev 5205)
@@ -100,9 +100,11 @@
                   const gchar  *name,
                   const gchar  *comments,
                   gboolean      is_writable,
-                  gboolean      guests_ok)
+                  gboolean      guests_ok,
+                  const gchar  *old_name)
 {
 	ShareInfo *share_info = NULL;
+	gboolean   exists;
 	gboolean   ret;
 	GError    *err = NULL;
 
@@ -112,8 +114,38 @@
 		return NULL;
 	}
 
-	/* TODO: check if the share name is already used(?) */
+	/* Check length */
+	if (g_utf8_strlen (name, -1) > 12)
+	{
+		//-- Fixme this should be just a warning.
+		tsp_show_error (NULL, _("Share name is too long."));
+		return NULL;
+	}
 
+	/* Do the name check only if this is a new share, or if
+	   the user is changing the share name */
+	if ((old_name == NULL) || (g_utf8_collate (name, old_name) != 0))
+	{
+		/* Check if the share name is already used */
+		if (!shares_get_share_name_exists (name, &exists, &err))
+		{
+			gchar *str;
+
+			str = g_strdup_printf (_("Error while getting share information: %s"), err->message);
+			tsp_show_error (NULL, str);
+			g_free (str);
+			g_error_free (err);
+
+			return NULL;
+		}
+
+		if (exists)
+		{
+			tsp_show_error (NULL, _("Another share has the same name"));
+			 return NULL;
+		}
+	}
+
 	if (tsp_check_perms (file_local, is_writable))
 	{
 		share_info = g_new0 (ShareInfo, 1);

Modified: thunar-shares-plugin/trunk/libshares/libshares-util.h
===================================================================
--- thunar-shares-plugin/trunk/libshares/libshares-util.h	2008-08-06 00:05:30 UTC (rev 5204)
+++ thunar-shares-plugin/trunk/libshares/libshares-util.h	2008-08-06 18:13:31 UTC (rev 5205)
@@ -43,7 +43,8 @@
                              const gchar     *name,
                              const gchar     *comments,
                              gboolean         is_writable,
-                             gboolean         guests_ok);
+                             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-08-06 00:05:30 UTC (rev 5204)
+++ thunar-shares-plugin/trunk/thunar-plugin/tsp-admin-editor.c	2008-08-06 18:13:31 UTC (rev 5205)
@@ -48,6 +48,9 @@
 	GtkWidget  *share_label1;
 	GtkWidget  *share_hbox1;
 
+	/* Current share name */
+	gchar      *old_name;
+
 	gpointer    admin;
 } TspAdminEdit;
 
@@ -84,7 +87,7 @@
 		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);
+		 							   is_writable, guests_ok, editor->old_name);
 		if (share_info)
 		{
 			shares_free_share_info (share_info);
@@ -105,6 +108,9 @@
 editor_destroy_cb (GtkWidget    *widget,
                    TspAdminEdit *editor)
 {
+	if (editor->old_name != NULL)
+		g_free (editor->old_name);
+
 	g_free (editor);
 }
 
@@ -168,11 +174,13 @@
 	if (G_STR_EMPTY (path)){
 		const gchar *home_dir;
 
-		gtk_window_set_title (GTK_WINDOW (editor->dialog),
-											_("Thunar - Add a share"));
+		gtk_window_set_title (GTK_WINDOW (editor->dialog), _("Thunar - Add a share"));
 
 		home_dir = g_get_home_dir ();
 
+		if (editor->old_name != NULL)
+			g_free (editor->old_name);
+
 		/* Show folders chooser */
 		gtk_widget_show (editor->share_hbox1);
 		gtk_widget_show (editor->share_label1);
@@ -190,12 +198,12 @@
 					GTK_ENTRY (editor->share_comments), "");
 
 	} else {
-		gtk_window_set_title (GTK_WINDOW (editor->dialog),
-											_("Thunar - Edit share"));
 		/* Load values */
 		ShareInfo *share_info;
 		gboolean   result;
 
+		gtk_window_set_title (GTK_WINDOW (editor->dialog), _("Thunar - Edit share"));
+
 		/* Hide folders chooser */
 		gtk_widget_hide (editor->share_hbox1);
 		gtk_widget_hide (editor->share_label1);
@@ -203,6 +211,8 @@
 		result = shares_get_share_info_for_path (path, &share_info, NULL);
 		if (share_info)
 		{
+			editor->old_name = g_strdup (share_info->share_name);
+
 			gtk_file_chooser_set_current_folder (
 					GTK_FILE_CHOOSER (editor->share_folder), path);
 			gtk_toggle_button_set_active (

Modified: thunar-shares-plugin/trunk/thunar-plugin/tsp-page.c
===================================================================
--- thunar-shares-plugin/trunk/thunar-plugin/tsp-page.c	2008-08-06 00:05:30 UTC (rev 5204)
+++ thunar-shares-plugin/trunk/thunar-plugin/tsp-page.c	2008-08-06 18:13:31 UTC (rev 5205)
@@ -394,14 +394,15 @@
 		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);
-		if (share_info)
+		 							   is_writable, guests_ok,
+		 							   tsp_page->share_name);
+		if (share_info != NULL)
 		{
 			tsp_update_default (tsp_page, share_info);
 			shares_free_share_info (share_info);
 		}
 	} else {
-		/* Un-share file */
+		/* Un-share the folder */
 		if (tsp_shares_unshare (local_file)){
 			tsp_update_default (tsp_page, NULL);
 		}




More information about the Goodies-commits mailing list