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

Daniel Morales danielm at xfce.org
Mon Aug 18 17:30:00 CEST 2008


Author: danielm
Date: 2008-08-18 15:30:00 +0000 (Mon, 18 Aug 2008)
New Revision: 5274

Removed:
   thunar-shares-plugin/trunk/data/
   thunar-shares-plugin/trunk/libshares/libshares-paths.c
   thunar-shares-plugin/trunk/libshares/libshares-paths.h
   thunar-shares-plugin/trunk/libshares/libshares-xml.c
   thunar-shares-plugin/trunk/libshares/libshares-xml.h
Modified:
   thunar-shares-plugin/trunk/ChangeLog
   thunar-shares-plugin/trunk/Makefile.am
   thunar-shares-plugin/trunk/TODO
   thunar-shares-plugin/trunk/configure.in.in
   thunar-shares-plugin/trunk/libshares/Makefile.am
   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
Log:
	* data/*:
	* libshares/libshares-xml.[ch]:
	* libshares/libshares-paths.[ch]: Removed unnecessary files.
	* libshares/libshares-util.[ch]: Drop all GtkBuilder dependences,
	and some code stylish changes :) $
 

Modified: thunar-shares-plugin/trunk/ChangeLog
===================================================================
--- thunar-shares-plugin/trunk/ChangeLog	2008-08-18 08:30:04 UTC (rev 5273)
+++ thunar-shares-plugin/trunk/ChangeLog	2008-08-18 15:30:00 UTC (rev 5274)
@@ -1,3 +1,11 @@
+2008-08-18	Daniel Morales <daniel at daniel.com.uy>
+
+	* data/*:
+	* libshares/libshares-xml.[ch]:
+	* libshares/libshares-paths.[ch]: Removed unnecessary files.
+	* libshares/libshares-util.[ch]: Drop all GtkBuilder dependences,
+	and some code stylish changes :)
+
 2008-08-14	Daniel Morales <daniel at daniel.com.uy>
 
 	* data/Makefile.am:

Modified: thunar-shares-plugin/trunk/Makefile.am
===================================================================
--- thunar-shares-plugin/trunk/Makefile.am	2008-08-18 08:30:04 UTC (rev 5273)
+++ thunar-shares-plugin/trunk/Makefile.am	2008-08-18 15:30:00 UTC (rev 5274)
@@ -1,5 +1,5 @@
 
-SUBDIRS = data libshares thunar-plugin po
+SUBDIRS = libshares thunar-plugin po
 
 INTLTOOL =				\
 	intltool-extract.in		\

Modified: thunar-shares-plugin/trunk/TODO
===================================================================
--- thunar-shares-plugin/trunk/TODO	2008-08-18 08:30:04 UTC (rev 5273)
+++ thunar-shares-plugin/trunk/TODO	2008-08-18 15:30:00 UTC (rev 5274)
@@ -15,6 +15,3 @@
   * 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.
-
-  * Rewrite the admin and editor dialog to a Gobject like code. And drop
-  the GtkBuilder XML dependence.

Modified: thunar-shares-plugin/trunk/configure.in.in
===================================================================
--- thunar-shares-plugin/trunk/configure.in.in	2008-08-18 08:30:04 UTC (rev 5273)
+++ thunar-shares-plugin/trunk/configure.in.in	2008-08-18 15:30:00 UTC (rev 5274)
@@ -122,7 +122,6 @@
 
 AC_OUTPUT([
 	Makefile
-	data/Makefile
 	po/Makefile.in
 	libshares/Makefile
 	thunar-plugin/Makefile

Modified: thunar-shares-plugin/trunk/libshares/Makefile.am
===================================================================
--- thunar-shares-plugin/trunk/libshares/Makefile.am	2008-08-18 08:30:04 UTC (rev 5273)
+++ thunar-shares-plugin/trunk/libshares/Makefile.am	2008-08-18 15:30:00 UTC (rev 5274)
@@ -11,9 +11,7 @@
 
 libshares_la_SOURCES =					\
 	shares.c		shares.h		\
-	libshares-xml.c		libshares-xml.h		\
-	libshares-util.c	libshares-util.h	\
-	libshares-paths.c	libshares-paths.h
+	libshares-util.c	libshares-util.h
 
 libshares_la_CFLAGS =					\
 	$(PLATFORM_CFLAGS)				\

Deleted: thunar-shares-plugin/trunk/libshares/libshares-paths.c

Deleted: thunar-shares-plugin/trunk/libshares/libshares-paths.h

Modified: thunar-shares-plugin/trunk/libshares/libshares-util.c
===================================================================
--- thunar-shares-plugin/trunk/libshares/libshares-util.c	2008-08-18 08:30:04 UTC (rev 5273)
+++ thunar-shares-plugin/trunk/libshares/libshares-util.c	2008-08-18 15:30:00 UTC (rev 5274)
@@ -32,8 +32,6 @@
 #include "libshares-xml.h"
 #include "shares.h"
 
-#define XML_FILE "dialogs.xml"
-
 static gboolean tsp_ask_perms   (gboolean     need_r,
                                  gboolean     need_w,
                                  gboolean     need_x);
@@ -45,13 +43,13 @@
 gchar*
 tsp_get_local_file (ThunarxFileInfo *filex)
 {
-	gchar *file, *file_local;
+  gchar *file, *file_local;
 
-	file = thunarx_file_info_get_uri (filex);
-	file_local = g_filename_from_uri (file, NULL, NULL);
+  file = thunarx_file_info_get_uri (filex);
+  file_local = g_filename_from_uri (file, NULL, NULL);
 
-	g_free (file);
-	return file_local;
+  g_free (file);
+  return file_local;
 }
 
 /* Safe string comparison */
@@ -59,39 +57,40 @@
 tsp_str_equal (const char *txt1,
                const char *txt2)
 {
-	if (G_STR_EMPTY (txt1) || G_STR_EMPTY (txt2)){
-		if (G_STR_EMPTY (txt1) && G_STR_EMPTY (txt2)){
-			return TRUE;
-		}
-		return FALSE;
-	}
+  if (G_STR_EMPTY (txt1) || G_STR_EMPTY (txt2))
+  {
+    if (G_STR_EMPTY (txt1) && G_STR_EMPTY (txt2)){
+      return TRUE;
+    }
+    return FALSE;
+  }
 
-	return g_str_equal (txt1, txt2);
+  return g_str_equal (txt1, txt2);
 }
 
 /* Un-share a folder */
 gboolean
 tsp_shares_unshare (const gchar *path)
 {
-	gboolean ret = FALSE;
-	gboolean is_shared;
-	GError  *err = NULL;
+  gboolean ret = FALSE;
+  gboolean is_shared;
+  GError  *err = NULL;
 
-	/* Check if this path is shared */
-	shares_get_path_is_shared (path, &is_shared, NULL);
-	if (is_shared)
-	{
-		/* Un-share it */
-		ret = shares_modify_share (path, NULL, &err);
-		if (!ret){
-			tsp_show_error (NULL, err->message);
-			g_error_free (err);
-		} else {
-			ret = TRUE;
-		}
-	}
+  /* Check if this path is shared */
+  shares_get_path_is_shared (path, &is_shared, NULL);
+  if (is_shared)
+  {
+    /* Un-share it */
+    ret = shares_modify_share (path, NULL, &err);
+    if (!ret){
+      tsp_show_error (NULL, err->message);
+      g_error_free (err);
+    } else {
+      ret = TRUE;
+    }
+  }
 
-	return ret;
+  return ret;
 }
 
 /* Share a folder */
@@ -103,75 +102,75 @@
                   gboolean      guests_ok,
                   const gchar  *old_name)
 {
-	ShareInfo *share_info = NULL;
-	gboolean   exists;
-	gboolean   ret;
-	GError    *err = NULL;
+  ShareInfo *share_info = NULL;
+  gboolean   exists;
+  gboolean   ret;
+  GError    *err = NULL;
 
-	/* Check share name */
-	if (G_STR_EMPTY (name)){
-		tsp_show_error (NULL, _("Please, write a name."));
-		return NULL;
-	}
+  /* Check share name */
+  if (G_STR_EMPTY (name)){
+    tsp_show_error (NULL, _("Please, write a name."));
+    return NULL;
+  }
 
-	/* 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;
-	}
+  /* 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;
+  /* 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);
+      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;
-		}
+      return NULL;
+    }
 
-		if (exists)
-		{
-			tsp_show_error (NULL, _("Another share has the same name"));
-			 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);
+  if (tsp_check_perms (file_local, is_writable))
+  {
+    share_info = g_new0 (ShareInfo, 1);
 
-		/* Fill the struct */
-		share_info->path = g_strdup (file_local);
-		share_info->share_name = g_strdup (name);
-		if (G_STR_EMPTY (comments)){
-			share_info->comment = g_strdup ("");
-		} else {
-			share_info->comment = g_strdup (comments);
-		}
-		share_info->is_writable = is_writable;
-		share_info->guest_ok = guests_ok;
+    /* Fill the struct */
+    share_info->path = g_strdup (file_local);
+    share_info->share_name = g_strdup (name);
+    if (G_STR_EMPTY (comments)){
+      share_info->comment = g_strdup ("");
+    } else {
+      share_info->comment = g_strdup (comments);
+    }
+    share_info->is_writable = is_writable;
+    share_info->guest_ok = guests_ok;
 
-		/* Share it */
-		ret = shares_modify_share (file_local, share_info, &err);
-		if (!ret){
-			tsp_show_error (NULL, err->message);
-			g_error_free (err);
-			shares_free_share_info (share_info);
-			share_info = NULL;
-		}
-	}
-	
-	return share_info;
+    /* Share it */
+    ret = shares_modify_share (file_local, share_info, &err);
+    if (!ret){
+      tsp_show_error (NULL, err->message);
+      g_error_free (err);
+      shares_free_share_info (share_info);
+      share_info = NULL;
+    }
+  }
+
+  return share_info;
 }
 
 /* Displays an error message :(*/
@@ -179,25 +178,44 @@
 tsp_show_error (const char *text,
                 const char *secondary)
 {
-	GtkBuilder *ui;
-	GtkWidget  *dialog;
+  GtkWidget  *dialog;
 
-	ui = tsp_xml_get_file (XML_FILE, 
-				"error_dialog", &dialog,
-				NULL);
+  dialog = gtk_message_dialog_new (NULL,
+                                   GTK_DIALOG_MODAL,
+                                   GTK_MESSAGE_ERROR,
+                                   GTK_BUTTONS_CLOSE,
+                                   NULL);
+  if (text){
+    gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), text);
+  } else {
+    gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), _("Cannot modify the share:"));
+  }
 
-	g_object_set (G_OBJECT (dialog), "secondary-text", secondary, NULL);
+  gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog), secondary);
 
-	if (text){
-		gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), text);
-	} else {
-		gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), _("Cannot modify the share:"));
-	}
+  gtk_dialog_run (GTK_DIALOG (dialog));
 
-	gtk_dialog_run (GTK_DIALOG (dialog));
+  gtk_widget_destroy (dialog);
+}
 
-	gtk_widget_destroy (dialog);
-	g_object_unref (ui);
+/* Asks 'text' to the user */
+gboolean
+tsp_ask_user (const char *text)
+{
+  GtkWidget *dialog;
+  gboolean result;
+
+  dialog = gtk_message_dialog_new (NULL,
+                                   GTK_DIALOG_MODAL,
+                                   GTK_MESSAGE_QUESTION,
+                                   GTK_BUTTONS_OK_CANCEL,
+                                   text);
+     
+  result = gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK;
+
+  gtk_widget_destroy (dialog);
+
+  return result;
 }
 
 /* Asks to the user if we can change the permissions of the folder */
@@ -206,21 +224,7 @@
                gboolean  need_w,
                gboolean  need_x)
 {
-	GtkBuilder *ui;
-	GtkWidget  *dialog;
-	gboolean    result;
-
-	/* Get the dialogs */
-	ui = tsp_xml_get_file (XML_FILE, 
-				"permissions_dialog", &dialog,
-				NULL);
-
-	result = gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK;
-
-	gtk_widget_destroy (dialog);
-	g_object_unref (ui);
-
-	return result;
+  return tsp_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 */
@@ -228,42 +232,42 @@
 tsp_check_perms (const gchar *path,
                  gboolean     is_writable)
 {
-	struct stat st;
-	gboolean    need_r;
-	gboolean    need_w;
-	gboolean    need_x;
-	mode_t      new_mode;
-	mode_t      mode;
+  struct stat st;
+  gboolean    need_r;
+  gboolean    need_w;
+  gboolean    need_x;
+  mode_t      new_mode;
+  mode_t      mode;
 
-	if (stat (path, &st) != 0)
-		return FALSE;
+  if (stat (path, &st) != 0)
+    return FALSE;
 
-	mode = st.st_mode;
+  mode = st.st_mode;
 
-	new_mode = mode;
+  new_mode = mode;
 
-	need_r = (mode & THUNAR_VFS_FILE_MODE_OTH_READ) == 0;
-	new_mode |= THUNAR_VFS_FILE_MODE_OTH_READ;
+  need_r = (mode & THUNAR_VFS_FILE_MODE_OTH_READ) == 0;
+  new_mode |= THUNAR_VFS_FILE_MODE_OTH_READ;
 
-	need_w = is_writable && (mode & THUNAR_VFS_FILE_MODE_OTH_WRITE) == 0;
-	if (need_w)
-		new_mode |= THUNAR_VFS_FILE_MODE_OTH_WRITE;
+  need_w = is_writable && (mode & THUNAR_VFS_FILE_MODE_OTH_WRITE) == 0;
+  if (need_w)
+    new_mode |= THUNAR_VFS_FILE_MODE_OTH_WRITE;
 
-	need_x = (mode & THUNAR_VFS_FILE_MODE_OTH_EXEC) == 0;
-	new_mode |= THUNAR_VFS_FILE_MODE_OTH_EXEC;
+  need_x = (mode & THUNAR_VFS_FILE_MODE_OTH_EXEC) == 0;
+  new_mode |= THUNAR_VFS_FILE_MODE_OTH_EXEC;
 
-	if (need_r || need_w || need_x)
-	{
-		if (!tsp_ask_perms (need_r, need_w, need_x))
-			return FALSE;
+  if (need_r || need_w || need_x)
+  {
+    if (!tsp_ask_perms (need_r, need_w, need_x))
+      return FALSE;
 #ifdef G_ENABLE_DEBUG
-		g_message ("Changing permissions of '%s'", path);
+    g_message ("Changing permissions of '%s'", path);
 #endif
-		if (g_chmod (path, new_mode) != 0)
-		{
-			tsp_show_error (NULL, _("Error when changing folder permissions."));
-			return FALSE;
-		}
+    if (g_chmod (path, new_mode) != 0)
+    {
+      tsp_show_error (NULL, _("Error when changing folder permissions."));
+      return FALSE;
     }
-	return TRUE;
+  }
+  return TRUE;
 }

Modified: thunar-shares-plugin/trunk/libshares/libshares-util.h
===================================================================
--- thunar-shares-plugin/trunk/libshares/libshares-util.h	2008-08-18 08:30:04 UTC (rev 5273)
+++ thunar-shares-plugin/trunk/libshares/libshares-util.h	2008-08-18 15:30:00 UTC (rev 5274)
@@ -37,6 +37,8 @@
 void     tsp_show_error     (const char      *text,
                              const char      *secondary);
 
+gboolean tsp_ask_user       (const char      *text);
+
 gboolean tsp_shares_unshare (const gchar     *path);
 
 ShareInfo *tsp_shares_share (const gchar     *file_local,

Deleted: thunar-shares-plugin/trunk/libshares/libshares-xml.c

Deleted: thunar-shares-plugin/trunk/libshares/libshares-xml.h

Modified: thunar-shares-plugin/trunk/thunar-plugin/tsp-admin-editor.c
===================================================================
--- thunar-shares-plugin/trunk/thunar-plugin/tsp-admin-editor.c	2008-08-18 08:30:04 UTC (rev 5273)
+++ thunar-shares-plugin/trunk/thunar-plugin/tsp-admin-editor.c	2008-08-18 15:30:00 UTC (rev 5274)
@@ -211,7 +211,6 @@
     shares_free_share_info (share_info);
 
     /* Reload share list */
-    //tsp_admin_manager_reload_shares (editor->manager);
     manager = gtk_window_get_transient_for (GTK_WINDOW (editor));
     
     if (manager != NULL && TSP_ADMIN_IS_MANAGER (manager))




More information about the Goodies-commits mailing list