[Goodies-commits] r5432 - in thunar-shares-plugin/trunk: . libshares thunar-plugin
Daniel Morales
danielm at xfce.org
Mon Sep 22 18:32:22 CEST 2008
Author: danielm
Date: 2008-09-22 16:32:21 +0000 (Mon, 22 Sep 2008)
New Revision: 5432
Modified:
thunar-shares-plugin/trunk/ChangeLog
thunar-shares-plugin/trunk/TODO
thunar-shares-plugin/trunk/configure.in.in
thunar-shares-plugin/trunk/libshares/libshares-util.c
thunar-shares-plugin/trunk/thunar-plugin/thunar-shares-plugin.c
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:
* configure.in.in: Correct debug checks. We don't want full by
default.
* thunar-plugin/tsp-provider.c: Only show the Share tab on file
properties when the file schema is "file://".
* thunar-plugin/tsp-page.c:
* thunar-plugin/tsp-admin.c:
* thunar-plugin/tsp-admin-editor.c:
* libshares/libshares-util.c: Add errors checks.
* Better code-tab on edited files. $
Modified: thunar-shares-plugin/trunk/ChangeLog
===================================================================
--- thunar-shares-plugin/trunk/ChangeLog 2008-09-22 07:44:15 UTC (rev 5431)
+++ thunar-shares-plugin/trunk/ChangeLog 2008-09-22 16:32:21 UTC (rev 5432)
@@ -1,5 +1,17 @@
2008-08-18 Daniel Morales <daniel at daniel.com.uy>
+ * configure.in.in: Correct debug checks. We don't want full by
+ default.
+ * thunar-plugin/tsp-provider.c: Only show the Share tab on file
+ properties when the file schema is "file://".
+ * thunar-plugin/tsp-page.c:
+ * thunar-plugin/tsp-admin.c:
+ * thunar-plugin/tsp-admin-editor.c:
+ * libshares/libshares-util.c: Add errors checks.
+ * Better code-tab on edited files.
+
+2008-08-18 Daniel Morales <daniel at daniel.com.uy>
+
* data/*:
* libshares/libshares-xml.[ch]:
* libshares/libshares-paths.[ch]: Removed unnecessary files.
Modified: thunar-shares-plugin/trunk/TODO
===================================================================
--- thunar-shares-plugin/trunk/TODO 2008-09-22 07:44:15 UTC (rev 5431)
+++ thunar-shares-plugin/trunk/TODO 2008-09-22 16:32:21 UTC (rev 5432)
@@ -3,6 +3,7 @@
* Add emblems to shared folders (Thunar doesn't allow to add/remove
emblembs from plugins yet).
+ - Maybe we can use tdb: ${HOME}/.cache/Thunar/metafile.tdb
* Maybe some help button at shares-admin dialog.
@@ -12,6 +13,4 @@
MILESTONE 0.20
=======================================================================
- * 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/configure.in.in
===================================================================
--- thunar-shares-plugin/trunk/configure.in.in 2008-09-22 07:44:15 UTC (rev 5431)
+++ thunar-shares-plugin/trunk/configure.in.in 2008-09-22 16:32:21 UTC (rev 5432)
@@ -63,8 +63,8 @@
dnl Debugging support
dnl -------------------------------------------------------
AC_ARG_ENABLE([debug],
-AC_HELP_STRING([--enable-debug=@<:@no/minimum/yes/full@:>@], [Turn on debugging @<:@default=tap_debug_default@:>@]),
- [], [enable_debug=tap_debug_default])
+AC_HELP_STRING([--enable-debug=@<:@no/minimum/yes/full@:>@], [Turn on debugging @<:@default=tsp_debug_default@:>@]),
+ [], [enable_debug=tsp_debug_default])
AC_MSG_CHECKING([whether to enable debugging support])
if test x"$enable_debug" = x"full" -o x"$enable_debug" = x"yes"; then
dnl Check whether the compiler accepts the -fno-strict-aliasing
Modified: thunar-shares-plugin/trunk/libshares/libshares-util.c
===================================================================
--- thunar-shares-plugin/trunk/libshares/libshares-util.c 2008-09-22 07:44:15 UTC (rev 5431)
+++ thunar-shares-plugin/trunk/libshares/libshares-util.c 2008-09-22 16:32:21 UTC (rev 5432)
@@ -73,17 +73,27 @@
{
gboolean ret = FALSE;
gboolean is_shared;
- GError *err = NULL;
+ gboolean result;
+ GError *error = NULL;
/* Check if this path is shared */
- shares_get_path_is_shared (path, &is_shared, NULL);
+ result = shares_get_path_is_shared (path, &is_shared, &error);
+
+ /* Check error */
+ if (!result)
+ {
+ tsp_show_error (NULL, error->message);
+ g_error_free (error);
+ error = NULL;
+ }
+
if (is_shared)
{
/* Un-share it */
- ret = shares_modify_share (path, NULL, &err);
+ ret = shares_modify_share (path, NULL, &error);
if (!ret){
- tsp_show_error (NULL, err->message);
- g_error_free (err);
+ tsp_show_error (NULL, error->message);
+ g_error_free (error);
} else {
ret = TRUE;
}
Modified: thunar-shares-plugin/trunk/thunar-plugin/thunar-shares-plugin.c
===================================================================
--- thunar-shares-plugin/trunk/thunar-plugin/thunar-shares-plugin.c 2008-09-22 07:44:15 UTC (rev 5431)
+++ thunar-shares-plugin/trunk/thunar-plugin/thunar-shares-plugin.c 2008-09-22 16:32:21 UTC (rev 5432)
@@ -69,7 +69,7 @@
thunar_extension_shutdown (void)
{
#ifdef G_ENABLE_DEBUG
- g_message ("Shutting down thunar-archive-plugin extension");
+ g_message ("Shutting down thunar-shares-plugin extension");
#endif
/* Free all shares */
Modified: thunar-shares-plugin/trunk/thunar-plugin/tsp-admin-editor.c
===================================================================
--- thunar-shares-plugin/trunk/thunar-plugin/tsp-admin-editor.c 2008-09-22 07:44:15 UTC (rev 5431)
+++ thunar-shares-plugin/trunk/thunar-plugin/tsp-admin-editor.c 2008-09-22 16:32:21 UTC (rev 5432)
@@ -228,6 +228,7 @@
{
ShareInfo *share_info;
gboolean result;
+ GError *error = NULL;
/* Dialog changes */
gtk_widget_hide (editor->share_folder);
@@ -235,21 +236,24 @@
gtk_window_set_title (GTK_WINDOW (editor), _("Thunar - Edit share"));
/* Load share info */
- result = shares_get_share_info_for_path (path, &share_info, NULL);
+ result = shares_get_share_info_for_path (path, &share_info, &error);
+
+ /* Check error */
+ if (!result)
+ {
+ tsp_show_error (_("There was an error while listing shares"), error->message);
+ g_error_free (error);
+ }
+
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 (
- GTK_TOGGLE_BUTTON (editor->share_write), share_info->is_writable);
- gtk_toggle_button_set_active (
- GTK_TOGGLE_BUTTON (editor->share_guest), share_info->guest_ok);
- gtk_entry_set_text (
- GTK_ENTRY (editor->share_name), share_info->share_name);
- gtk_entry_set_text (
- GTK_ENTRY (editor->share_comments), share_info->comment);
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (editor->share_folder), path);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->share_write), share_info->is_writable);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->share_guest), share_info->guest_ok);
+ gtk_entry_set_text (GTK_ENTRY (editor->share_name), share_info->share_name);
+ gtk_entry_set_text (GTK_ENTRY (editor->share_comments), share_info->comment);
shares_free_share_info (share_info);
}
Modified: thunar-shares-plugin/trunk/thunar-plugin/tsp-admin.c
===================================================================
--- thunar-shares-plugin/trunk/thunar-plugin/tsp-admin.c 2008-09-22 07:44:15 UTC (rev 5431)
+++ thunar-shares-plugin/trunk/thunar-plugin/tsp-admin.c 2008-09-22 16:32:21 UTC (rev 5432)
@@ -314,10 +314,19 @@
void
tsp_admin_manager_reload_shares (TspAdminManager *manager)
{
- GSList *info_list = NULL;
+ gboolean result;
+ GSList *info_list = NULL;
+ GError *error = NULL;
- shares_get_share_info_list (&info_list, NULL);
+ result = shares_get_share_info_list (&info_list, &error);
+ /* Check error */
+ if (!result)
+ {
+ tsp_show_error (_("There was an error while listing shares"), error->message);
+ g_error_free (error);
+ }
+
if (info_list)
{
GtkTreeModel *model;
Modified: thunar-shares-plugin/trunk/thunar-plugin/tsp-page.c
===================================================================
--- thunar-shares-plugin/trunk/thunar-plugin/tsp-page.c 2008-09-22 07:44:15 UTC (rev 5431)
+++ thunar-shares-plugin/trunk/thunar-plugin/tsp-page.c 2008-09-22 16:32:21 UTC (rev 5432)
@@ -33,8 +33,8 @@
/* Property identifiers */
enum
{
- PROP_0,
- PROP_FILE,
+ PROP_0,
+ PROP_FILE,
};
static void tsp_page_class_init (TspPageClass *klass);
@@ -72,30 +72,30 @@
struct _TspPageClass
{
- ThunarxPropertyPageClass __parent__;
+ ThunarxPropertyPageClass __parent__;
};
struct _TspPage
{
- ThunarxPropertyPage __parent__;
- ThunarxFileInfo *file;
+ ThunarxPropertyPage __parent__;
+ ThunarxFileInfo *file;
- GtkWidget *cb_share_folder;
- GtkWidget *entry_share_name;
- GtkWidget *cb_share_write;
- GtkWidget *entry_share_comments;
- GtkWidget *label_comments;
- GtkWidget *label_name;
- GtkWidget *button_apply;
- GtkWidget *cb_share_guest;
- GtkWidget *label_status;
+ GtkWidget *cb_share_folder;
+ GtkWidget *entry_share_name;
+ GtkWidget *cb_share_write;
+ GtkWidget *entry_share_comments;
+ GtkWidget *label_comments;
+ GtkWidget *label_name;
+ GtkWidget *button_apply;
+ GtkWidget *cb_share_guest;
+ GtkWidget *label_status;
- /* Default values for the file */
- gboolean is_shared;
- gboolean can_write;
- gboolean can_guests;
- gchar *share_name;
- gchar *share_comment;
+ /* Default values for the file */
+ gboolean is_shared;
+ gboolean can_write;
+ gboolean can_guests;
+ gchar *share_name;
+ gchar *share_comment;
};
/* implements the tsp_page_get_type() and tsp_page_register_type() functions */
@@ -104,135 +104,135 @@
static void
tsp_page_class_init (TspPageClass *klass)
{
- GObjectClass *gobject_class;
+ GObjectClass *gobject_class;
- gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->finalize = tsp_page_finalize;
- gobject_class->get_property = tsp_page_get_property;
- gobject_class->set_property = tsp_page_set_property;
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = tsp_page_finalize;
+ gobject_class->get_property = tsp_page_get_property;
+ gobject_class->set_property = tsp_page_set_property;
- /**
- * TspPage:file:
- *
- * The ThunarxFileInfo displayed by this TspPage.
- **/
- g_object_class_install_property (gobject_class,
- PROP_FILE,
- g_param_spec_object ("file", "file", "file",
- THUNARX_TYPE_FILE_INFO,
- G_PARAM_READWRITE));
+ /**
+ * TspPage:file:
+ *
+ * The ThunarxFileInfo displayed by this TspPage.
+ **/
+ g_object_class_install_property (gobject_class,
+ PROP_FILE,
+ g_param_spec_object ("file", "file", "file",
+ THUNARX_TYPE_FILE_INFO,
+ G_PARAM_READWRITE));
}
static void
tsp_page_init (TspPage *page)
{
- GtkWidget *vbox1;
- GtkWidget *hbox1;
- GtkWidget *widget;
+ GtkWidget *vbox1;
+ GtkWidget *hbox1;
+ GtkWidget *widget;
- /* Main container */
- vbox1 = gtk_vbox_new (FALSE, 0);
- gtk_container_set_border_width (GTK_CONTAINER (vbox1), 5);
+ /* Main container */
+ vbox1 = gtk_vbox_new (FALSE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox1), 5);
- /* Header */
- hbox1 = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, TRUE, 5);
+ /* Header */
+ hbox1 = gtk_hbox_new (FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, TRUE, 5);
- widget = gtk_image_new ();
- gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gnome-fs-share", GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_padding (GTK_MISC (widget), 13, 0);
- gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.50);
- gtk_box_pack_start (GTK_BOX (hbox1), widget, FALSE, FALSE, 0);
+ widget = gtk_image_new ();
+ gtk_image_set_from_icon_name (GTK_IMAGE (widget), "gnome-fs-share", GTK_ICON_SIZE_DIALOG);
+ gtk_misc_set_padding (GTK_MISC (widget), 13, 0);
+ gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.50);
+ gtk_box_pack_start (GTK_BOX (hbox1), widget, FALSE, FALSE, 0);
- widget = gtk_label_new (_("<b>Folder Sharing</b>"));
- gtk_label_set_use_markup (GTK_LABEL(widget), TRUE);
- gtk_misc_set_alignment (GTK_MISC (widget), 0.0f, 0.50f);
- gtk_box_pack_start (GTK_BOX (hbox1), widget, FALSE, TRUE, 5);
+ widget = gtk_label_new (_("<b>Folder Sharing</b>"));
+ gtk_label_set_use_markup (GTK_LABEL(widget), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (widget), 0.0f, 0.50f);
+ gtk_box_pack_start (GTK_BOX (hbox1), widget, FALSE, TRUE, 5);
- /* Horizontal separator */
- widget = gtk_hseparator_new ();
- gtk_box_pack_start (GTK_BOX (vbox1), widget, FALSE, TRUE, 5);
+ /* Horizontal separator */
+ widget = gtk_hseparator_new ();
+ gtk_box_pack_start (GTK_BOX (vbox1), widget, FALSE, TRUE, 5);
- /* Share check button */
- page->cb_share_folder = gtk_check_button_new_with_label (_("Share this folder"));
- g_signal_connect (G_OBJECT (page->cb_share_folder), "toggled", G_CALLBACK (tsp_page_share_toggled), page);
- gtk_box_pack_start (GTK_BOX (vbox1), page->cb_share_folder, FALSE, FALSE, 5);
+ /* Share check button */
+ page->cb_share_folder = gtk_check_button_new_with_label (_("Share this folder"));
+ g_signal_connect (G_OBJECT (page->cb_share_folder), "toggled", G_CALLBACK (tsp_page_share_toggled), page);
+ gtk_box_pack_start (GTK_BOX (vbox1), page->cb_share_folder, FALSE, FALSE, 5);
- /* Share name */
- hbox1 = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 5);
-
- page->label_name = gtk_label_new (_("Share Name:"));
- gtk_misc_set_padding (GTK_MISC (page->label_name), 5, 0);
- gtk_misc_set_alignment (GTK_MISC (page->label_name), 0.0f, 0.50f);
- gtk_box_pack_start (GTK_BOX (hbox1), page->label_name, FALSE, FALSE, 0);
-
- page->entry_share_name = gtk_entry_new ();
- g_signal_connect (G_OBJECT (page->entry_share_name), "changed", G_CALLBACK (tsp_page_name_changed), page);
- gtk_box_pack_start (GTK_BOX (hbox1), page->entry_share_name, TRUE, TRUE, 0);
+ /* Share name */
+ hbox1 = gtk_hbox_new (FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 5);
- /* Write access */
- page->cb_share_write = gtk_check_button_new_with_label (_("Allow others users to write in this folder"));
- g_signal_connect (G_OBJECT (page->cb_share_write), "toggled", G_CALLBACK (tsp_page_write_toggled), page);
- gtk_box_pack_start (GTK_BOX (vbox1), page->cb_share_write, FALSE, FALSE, 5);
-
- /* Guest access */
- page->cb_share_guest = gtk_check_button_new_with_label (_("Allow Guest access"));
- g_signal_connect (G_OBJECT (page->cb_share_guest), "toggled", G_CALLBACK (tsp_page_guest_toggled), page);
- gtk_box_pack_start (GTK_BOX (vbox1), page->cb_share_guest, FALSE, FALSE, 5);
-
- /* Share comments */
- hbox1 = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 5);
-
- page->label_comments = gtk_label_new (_("Comments:"));
- gtk_misc_set_padding (GTK_MISC (page->label_comments), 5, 0);
- gtk_misc_set_alignment (GTK_MISC (page->label_comments), 0.0f, 0.50f);
- gtk_box_pack_start (GTK_BOX (hbox1), page->label_comments, FALSE, FALSE, 0);
-
- page->entry_share_comments = gtk_entry_new ();
- g_signal_connect (G_OBJECT (page->entry_share_comments), "changed", G_CALLBACK (tsp_page_cmt_changed), page);
- gtk_box_pack_start (GTK_BOX (hbox1), page->entry_share_comments, TRUE, TRUE, 0);
-
- /* Apply button */
- hbox1 = gtk_hbutton_box_new ();
- gtk_box_set_spacing (GTK_BOX (hbox1), 5);
- gtk_hbutton_box_set_layout_default (GTK_BUTTONBOX_END);
- gtk_box_pack_start (GTK_BOX (vbox1), hbox1, TRUE, TRUE, 7);
-
- page->button_apply = gtk_button_new_from_stock (GTK_STOCK_APPLY);
- g_signal_connect (G_OBJECT (page->button_apply), "clicked", G_CALLBACK (tsp_page_apply_clicked), page);
- gtk_box_pack_end (GTK_BOX (hbox1), page->button_apply, FALSE, FALSE, 0);
-
- /* Status label */
- page->label_status = gtk_label_new (NULL);
- gtk_label_set_use_markup (GTK_LABEL (page->label_status), TRUE);
- gtk_misc_set_alignment (GTK_MISC (page->label_status ), 0.0f, 0.50f);
- gtk_misc_set_padding (GTK_MISC (page->label_status), 5, 0);
- gtk_box_pack_start (GTK_BOX (vbox1), page->label_status, FALSE, FALSE, 5);
-
- /* Add to the dialog */
- gtk_container_add (GTK_CONTAINER (page), vbox1);
- gtk_container_set_border_width (GTK_CONTAINER (page), 5);
- gtk_widget_show_all (vbox1);
+ page->label_name = gtk_label_new (_("Share Name:"));
+ gtk_misc_set_padding (GTK_MISC (page->label_name), 5, 0);
+ gtk_misc_set_alignment (GTK_MISC (page->label_name), 0.0f, 0.50f);
+ gtk_box_pack_start (GTK_BOX (hbox1), page->label_name, FALSE, FALSE, 0);
+
+ page->entry_share_name = gtk_entry_new ();
+ g_signal_connect (G_OBJECT (page->entry_share_name), "changed", G_CALLBACK (tsp_page_name_changed), page);
+ gtk_box_pack_start (GTK_BOX (hbox1), page->entry_share_name, TRUE, TRUE, 0);
+
+ /* Write access */
+ page->cb_share_write = gtk_check_button_new_with_label (_("Allow others users to write in this folder"));
+ g_signal_connect (G_OBJECT (page->cb_share_write), "toggled", G_CALLBACK (tsp_page_write_toggled), page);
+ gtk_box_pack_start (GTK_BOX (vbox1), page->cb_share_write, FALSE, FALSE, 5);
+
+ /* Guest access */
+ page->cb_share_guest = gtk_check_button_new_with_label (_("Allow Guest access"));
+ g_signal_connect (G_OBJECT (page->cb_share_guest), "toggled", G_CALLBACK (tsp_page_guest_toggled), page);
+ gtk_box_pack_start (GTK_BOX (vbox1), page->cb_share_guest, FALSE, FALSE, 5);
+
+ /* Share comments */
+ hbox1 = gtk_hbox_new (FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 5);
+
+ page->label_comments = gtk_label_new (_("Comments:"));
+ gtk_misc_set_padding (GTK_MISC (page->label_comments), 5, 0);
+ gtk_misc_set_alignment (GTK_MISC (page->label_comments), 0.0f, 0.50f);
+ gtk_box_pack_start (GTK_BOX (hbox1), page->label_comments, FALSE, FALSE, 0);
+
+ page->entry_share_comments = gtk_entry_new ();
+ g_signal_connect (G_OBJECT (page->entry_share_comments), "changed", G_CALLBACK (tsp_page_cmt_changed), page);
+ gtk_box_pack_start (GTK_BOX (hbox1), page->entry_share_comments, TRUE, TRUE, 0);
+
+ /* Apply button */
+ hbox1 = gtk_hbutton_box_new ();
+ gtk_box_set_spacing (GTK_BOX (hbox1), 5);
+ gtk_hbutton_box_set_layout_default (GTK_BUTTONBOX_END);
+ gtk_box_pack_start (GTK_BOX (vbox1), hbox1, TRUE, TRUE, 7);
+
+ page->button_apply = gtk_button_new_from_stock (GTK_STOCK_APPLY);
+ g_signal_connect (G_OBJECT (page->button_apply), "clicked", G_CALLBACK (tsp_page_apply_clicked), page);
+ gtk_box_pack_end (GTK_BOX (hbox1), page->button_apply, FALSE, FALSE, 0);
+
+ /* Status label */
+ page->label_status = gtk_label_new (NULL);
+ gtk_label_set_use_markup (GTK_LABEL (page->label_status), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (page->label_status ), 0.0f, 0.50f);
+ gtk_misc_set_padding (GTK_MISC (page->label_status), 5, 0);
+ gtk_box_pack_start (GTK_BOX (vbox1), page->label_status, FALSE, FALSE, 5);
+
+ /* Add to the dialog */
+ gtk_container_add (GTK_CONTAINER (page), vbox1);
+ gtk_container_set_border_width (GTK_CONTAINER (page), 5);
+ gtk_widget_show_all (vbox1);
}
static void
tsp_page_finalize (GObject *object)
{
- TspPage *tsp_page = TSP_PAGE (object);
+ TspPage *tsp_page = TSP_PAGE (object);
- /* disconnect from the file */
- tsp_page_set_file (tsp_page, NULL);
+ /* disconnect from the file */
+ tsp_page_set_file (tsp_page, NULL);
- /* Free some memory */
- if (!G_STR_EMPTY (tsp_page->share_name))
- g_free (tsp_page->share_name);
+ /* Free some memory */
+ if (!G_STR_EMPTY (tsp_page->share_name))
+ g_free (tsp_page->share_name);
- if (!G_STR_EMPTY (tsp_page->share_comment))
- g_free (tsp_page->share_comment);
+ if (!G_STR_EMPTY (tsp_page->share_comment))
+ g_free (tsp_page->share_comment);
- (*G_OBJECT_CLASS (tsp_page_parent_class)->finalize) (object);
+ (*G_OBJECT_CLASS (tsp_page_parent_class)->finalize) (object);
}
static void
@@ -241,18 +241,18 @@
GValue *value,
GParamSpec *pspec)
{
- TspPage *tsp_page = TSP_PAGE (object);
+ TspPage *tsp_page = TSP_PAGE (object);
- switch (prop_id)
- {
- case PROP_FILE:
- g_value_set_object (value, tsp_page_get_file (tsp_page));
- break;
+ switch (prop_id)
+ {
+ case PROP_FILE:
+ g_value_set_object (value, tsp_page_get_file (tsp_page));
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
@@ -261,63 +261,64 @@
const GValue *value,
GParamSpec *pspec)
{
- TspPage *tsp_page = TSP_PAGE (object);
+ TspPage *tsp_page = TSP_PAGE (object);
- switch (prop_id)
- {
- case PROP_FILE:
- tsp_page_set_file (tsp_page, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id)
+ {
+ case PROP_FILE:
+ tsp_page_set_file (tsp_page, g_value_get_object (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
GtkWidget*
tsp_page_new (ThunarxFileInfo *file)
{
- TspPage *page = g_object_new (TSP_TYPE_PAGE, "file", file, NULL);
+ TspPage *page = g_object_new (TSP_TYPE_PAGE, "file", file, NULL);
- thunarx_property_page_set_label (THUNARX_PROPERTY_PAGE (page), _("Share"));
+ thunarx_property_page_set_label (THUNARX_PROPERTY_PAGE (page), _("Share"));
- return GTK_WIDGET (page);
+ return GTK_WIDGET (page);
}
ThunarxFileInfo*
tsp_page_get_file (TspPage *tsp_page)
{
- g_return_val_if_fail (TSP_IS_PAGE (tsp_page), NULL);
- return tsp_page->file;
+ g_return_val_if_fail (TSP_IS_PAGE (tsp_page), NULL);
+ return tsp_page->file;
}
void
tsp_page_set_file (TspPage *tsp_page,
ThunarxFileInfo *file)
{
- g_return_if_fail (TSP_IS_PAGE (tsp_page));
- g_return_if_fail (file == NULL || THUNARX_IS_FILE_INFO (file));
+ g_return_if_fail (TSP_IS_PAGE (tsp_page));
+ g_return_if_fail (file == NULL || THUNARX_IS_FILE_INFO (file));
- if (tsp_page->file == file){
- return;
- }
+ if (tsp_page->file == file){
+ return;
+ }
- if (tsp_page->file != NULL)
- {
- g_signal_handlers_disconnect_by_func (tsp_page->file, tsp_page_file_changed, tsp_page);
- g_object_unref (G_OBJECT (tsp_page->file));
- }
+ if (tsp_page->file != NULL)
+ {
+ g_signal_handlers_disconnect_by_func (tsp_page->file, tsp_page_file_changed, tsp_page);
+ g_object_unref (G_OBJECT (tsp_page->file));
+ }
- tsp_page->file = file;
+ tsp_page->file = file;
- if (file != NULL)
- {
- g_object_ref (tsp_page->file);
- tsp_page_file_changed (file, tsp_page);
- g_signal_connect (file, "changed", G_CALLBACK (tsp_page_file_changed), tsp_page);
- }
+ if (file != NULL)
+ {
+ g_object_ref (tsp_page->file);
+ tsp_page_file_changed (file, tsp_page);
+ g_signal_connect (file, "changed", G_CALLBACK (tsp_page_file_changed), tsp_page);
+ }
- g_object_notify (G_OBJECT (tsp_page), "file");
+ g_object_notify (G_OBJECT (tsp_page), "file");
}
/* File changed */
@@ -325,39 +326,44 @@
tsp_page_file_changed (ThunarxFileInfo *file,
TspPage *tsp_page)
{
- ShareInfo *share_info;
- gboolean result;
- gchar *uri, *file_local;
+ ShareInfo *share_info;
+ gboolean result;
+ GError *error = NULL;
+ gchar *uri, *file_local;
- /* Load share info */
- uri = thunarx_file_info_get_uri (tsp_page->file);
- file_local = g_filename_from_uri (uri, NULL, NULL);
+ /* Load share info */
+ uri = thunarx_file_info_get_uri (tsp_page->file);
+ file_local = g_filename_from_uri (uri, NULL, NULL);
- result = shares_get_share_info_for_path (file_local, &share_info, NULL);
- if (share_info)
- {
- tsp_page_sensibility (tsp_page, TRUE);
+ result = shares_get_share_info_for_path (file_local, &share_info, &error);
- gtk_toggle_button_set_active (
- GTK_TOGGLE_BUTTON (tsp_page->cb_share_folder), TRUE);
- gtk_toggle_button_set_active (
- GTK_TOGGLE_BUTTON (tsp_page->cb_share_write), share_info->is_writable);
- gtk_toggle_button_set_active (
- GTK_TOGGLE_BUTTON (tsp_page->cb_share_guest), share_info->guest_ok);
- gtk_entry_set_text (
- GTK_ENTRY (tsp_page->entry_share_name), share_info->share_name);
- gtk_entry_set_text (
- GTK_ENTRY (tsp_page->entry_share_comments), share_info->comment);
+ /* Check error */
+ if (!result)
+ {
+ tsp_show_error (_("There was an error while getting the sharing information"), error->message);
+ g_error_free (error);
+ }
- tsp_update_default (tsp_page, share_info);
- shares_free_share_info (share_info);
- } else {
- tsp_update_default (tsp_page, NULL);
- tsp_page_sensibility (tsp_page, FALSE);
- }
+ /* Check if shared */
+ if (share_info)
+ {
+ tsp_page_sensibility (tsp_page, TRUE);
- g_free (uri);
- g_free (file_local);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tsp_page->cb_share_folder), TRUE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tsp_page->cb_share_write), share_info->is_writable);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tsp_page->cb_share_guest), share_info->guest_ok);
+ gtk_entry_set_text (GTK_ENTRY (tsp_page->entry_share_name), share_info->share_name);
+ gtk_entry_set_text (GTK_ENTRY (tsp_page->entry_share_comments), share_info->comment);
+
+ tsp_update_default (tsp_page, share_info);
+ shares_free_share_info (share_info);
+ } else {
+ tsp_update_default (tsp_page, NULL);
+ tsp_page_sensibility (tsp_page, FALSE);
+ }
+
+ g_free (uri);
+ g_free (file_local);
}
/* Share name changed */
@@ -365,7 +371,7 @@
tsp_page_name_changed (GtkEditable *editable,
TspPage *tsp_page)
{
- tsp_check_changes (tsp_page);
+ tsp_check_changes (tsp_page);
}
/* Share comment changed */
@@ -373,7 +379,7 @@
tsp_page_cmt_changed (GtkEditable *editable,
TspPage *tsp_page)
{
- tsp_check_changes (tsp_page);
+ tsp_check_changes (tsp_page);
}
/* Allow users to write in the folder toggled */
@@ -381,7 +387,7 @@
tsp_page_write_toggled (GtkToggleButton *togglebutton,
TspPage *tsp_page)
{
- tsp_check_changes (tsp_page);
+ tsp_check_changes (tsp_page);
}
/* Allow guests access toggled */
@@ -389,7 +395,7 @@
tsp_page_guest_toggled (GtkToggleButton *togglebutton,
TspPage *tsp_page)
{
- tsp_check_changes (tsp_page);
+ tsp_check_changes (tsp_page);
}
/* Share folder toggled */
@@ -397,34 +403,34 @@
tsp_page_share_toggled (GtkToggleButton *togglebutton,
TspPage *tsp_page)
{
- gboolean share = gtk_toggle_button_get_active (togglebutton);
+ gboolean share = gtk_toggle_button_get_active (togglebutton);
- /* Toggle sharing */
- tsp_page_sensibility (tsp_page, share);
+ /* Toggle sharing */
+ tsp_page_sensibility (tsp_page, share);
- /* Sharing (?) */
- if (share)
- {
- const gchar *defauln;
- gchar *name_utf8;
- gchar *name;
+ /* Sharing (?) */
+ if (share)
+ {
+ const gchar *defauln;
+ gchar *name_utf8;
+ gchar *name;
- /* Check if we alredy had a name for it */
- defauln = gtk_entry_get_text (GTK_ENTRY (tsp_page->entry_share_name));
- if (G_STR_EMPTY (defauln))
- {
- name = thunarx_file_info_get_name (tsp_page->file);
- name_utf8 = g_filename_display_name (name);
+ /* Check if we alredy had a name for it */
+ defauln = gtk_entry_get_text (GTK_ENTRY (tsp_page->entry_share_name));
+ if (G_STR_EMPTY (defauln))
+ {
+ name = thunarx_file_info_get_name (tsp_page->file);
+ name_utf8 = g_filename_display_name (name);
- /* First sharename is the filename */
- gtk_entry_set_text (GTK_ENTRY (tsp_page->entry_share_name), name_utf8);
-
- g_free (name_utf8);
- g_free (name);
- }
- }
+ /* First sharename is the filename */
+ gtk_entry_set_text (GTK_ENTRY (tsp_page->entry_share_name), name_utf8);
+
+ g_free (name_utf8);
+ g_free (name);
+ }
+ }
- tsp_check_changes (tsp_page);
+ tsp_check_changes (tsp_page);
}
/* Apply button clicked */
@@ -432,95 +438,96 @@
tsp_page_apply_clicked (GtkButton *button,
TspPage *tsp_page)
{
- gboolean share;
- gchar *local_file;
+ gboolean share;
+ 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);
+ share = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tsp_page->cb_share_folder));
+ local_file = tsp_get_local_file (tsp_page->file);
- if (share){
- const gchar *comments;
- const gchar *name;
- ShareInfo *share_info;
- gboolean is_writable;
- gboolean guests_ok;
+ if (share)
+ {
+ const gchar *comments;
+ const gchar *name;
+ ShareInfo *share_info;
+ gboolean is_writable;
+ gboolean guests_ok;
- /* Share file */
- comments = gtk_entry_get_text (GTK_ENTRY (tsp_page->entry_share_comments));
- name = gtk_entry_get_text (GTK_ENTRY (tsp_page->entry_share_name));
- 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 file */
+ comments = gtk_entry_get_text (GTK_ENTRY (tsp_page->entry_share_comments));
+ name = gtk_entry_get_text (GTK_ENTRY (tsp_page->entry_share_name));
+ 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);
- if (share_info != NULL)
- {
- tsp_update_default (tsp_page, share_info);
- shares_free_share_info (share_info);
+ share_info = tsp_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);
+ shares_free_share_info (share_info);
- /* Notify other pages of the changes made */
- thunarx_file_info_changed (tsp_page->file);
- }
- } else {
- /* Un-share the folder */
- if (tsp_shares_unshare (local_file)){
- tsp_update_default (tsp_page, NULL);
+ /* Notify other pages of the changes made */
+ thunarx_file_info_changed (tsp_page->file);
+ }
+ } else {
+ /* Un-share the folder */
+ if (tsp_shares_unshare (local_file)){
+ tsp_update_default (tsp_page, NULL);
- /* Notify other pages of the changes made */
- thunarx_file_info_changed (tsp_page->file);
- }
- }
+ /* Notify other pages of the changes made */
+ thunarx_file_info_changed (tsp_page->file);
+ }
+ }
- g_free (local_file);
+ g_free (local_file);
}
/* Disable ore enable widgets when 'share folder' is toggled */
static void
-tsp_page_sensibility (TspPage *tsp_page,
- gboolean sens)
+tsp_page_sensibility (TspPage *tsp_page,
+ gboolean sens)
{
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tsp_page->cb_share_folder), sens);
- gtk_widget_set_sensitive (GTK_WIDGET (tsp_page->entry_share_name), sens);
- gtk_widget_set_sensitive (GTK_WIDGET (tsp_page->cb_share_write), sens);
- gtk_widget_set_sensitive (GTK_WIDGET (tsp_page->entry_share_comments), sens);
- gtk_widget_set_sensitive (GTK_WIDGET (tsp_page->label_name), sens);
- gtk_widget_set_sensitive (GTK_WIDGET (tsp_page->label_comments), sens);
- gtk_widget_set_sensitive (GTK_WIDGET (tsp_page->label_comments), sens);
- gtk_widget_set_sensitive (GTK_WIDGET (tsp_page->cb_share_guest), sens);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tsp_page->cb_share_folder), sens);
+ gtk_widget_set_sensitive (GTK_WIDGET (tsp_page->entry_share_name), sens);
+ gtk_widget_set_sensitive (GTK_WIDGET (tsp_page->cb_share_write), sens);
+ gtk_widget_set_sensitive (GTK_WIDGET (tsp_page->entry_share_comments), sens);
+ gtk_widget_set_sensitive (GTK_WIDGET (tsp_page->label_name), sens);
+ gtk_widget_set_sensitive (GTK_WIDGET (tsp_page->label_comments), sens);
+ gtk_widget_set_sensitive (GTK_WIDGET (tsp_page->label_comments), sens);
+ gtk_widget_set_sensitive (GTK_WIDGET (tsp_page->cb_share_guest), sens);
}
/* Checks if the settings of the current file has been changed */
static
gboolean tsp_check_changes (TspPage *page)
{
- const gchar *name, *comment;
- gboolean shared, guests, write;
- gboolean result = FALSE;
+ const gchar *name, *comment;
+ gboolean shared, guests, write;
+ gboolean result = FALSE;
- /* Get the info */
- shared = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (page->cb_share_folder));
- guests = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (page->cb_share_guest));
- write = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (page->cb_share_write));
- name = gtk_entry_get_text (GTK_ENTRY (page->entry_share_name));
- comment = gtk_entry_get_text (GTK_ENTRY (page->entry_share_comments));
-
- /* Shared? */
- if (page->is_shared != shared){
- result = TRUE;
- } else if (!page->is_shared && !shared){
- 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))){
- result = TRUE;
- }
+ /* Get the info */
+ shared = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (page->cb_share_folder));
+ guests = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (page->cb_share_guest));
+ write = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (page->cb_share_write));
+ name = gtk_entry_get_text (GTK_ENTRY (page->entry_share_name));
+ comment = gtk_entry_get_text (GTK_ENTRY (page->entry_share_comments));
- /* Update button */
- gtk_widget_set_sensitive (page->button_apply, result);
+ /* Shared? */
+ if (page->is_shared != shared){
+ result = TRUE;
+ } else if (!page->is_shared && !shared){
+ 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))){
+ result = TRUE;
+ }
- return result;
+ /* Update button */
+ gtk_widget_set_sensitive (page->button_apply, result);
+
+ return result;
}
/* Sets the default settings for the current file */
@@ -528,33 +535,33 @@
tsp_update_default (TspPage *page,
ShareInfo *info)
{
- if (!G_STR_EMPTY (page->share_name))
- g_free (page->share_name);
+ if (!G_STR_EMPTY (page->share_name))
+ g_free (page->share_name);
- if (!G_STR_EMPTY (page->share_comment))
- g_free (page->share_comment);
+ if (!G_STR_EMPTY (page->share_comment))
+ g_free (page->share_comment);
- page->share_name = NULL;
- page->share_comment = NULL;
+ page->share_name = NULL;
+ page->share_comment = NULL;
- if (!info){
- /* Not shared info */
- page->is_shared = FALSE;
- page->can_write = FALSE;
- page->can_guests = FALSE;
- } else {
- /* Shared info */
- page->is_shared = TRUE;
- page->can_write = info->is_writable;
- page->can_guests = info->guest_ok;
+ if (!info) {
+ /* Not shared info */
+ page->is_shared = FALSE;
+ page->can_write = FALSE;
+ page->can_guests = FALSE;
+ } else {
+ /* Shared info */
+ page->is_shared = TRUE;
+ page->can_write = info->is_writable;
+ page->can_guests = info->guest_ok;
- if (!G_STR_EMPTY (info->share_name))
- page->share_name = g_strdup (info->share_name);
+ if (!G_STR_EMPTY (info->share_name))
+ page->share_name = g_strdup (info->share_name);
- if (!G_STR_EMPTY (info->comment))
- page->share_comment = g_strdup (info->comment);
- }
+ if (!G_STR_EMPTY (info->comment))
+ page->share_comment = g_strdup (info->comment);
+ }
- /* Disable button */
- gtk_widget_set_sensitive (page->button_apply, FALSE);
+ /* Disable button */
+ gtk_widget_set_sensitive (page->button_apply, FALSE);
}
Modified: thunar-shares-plugin/trunk/thunar-plugin/tsp-provider.c
===================================================================
--- thunar-shares-plugin/trunk/thunar-plugin/tsp-provider.c 2008-09-22 07:44:15 UTC (rev 5431)
+++ thunar-shares-plugin/trunk/thunar-plugin/tsp-provider.c 2008-09-22 16:32:21 UTC (rev 5432)
@@ -46,12 +46,12 @@
struct _TspProviderClass
{
- GObjectClass __parent__;
+ GObjectClass __parent__;
};
struct _TspProvider
{
- GObject __parent__;
+ GObject __parent__;
};
THUNARX_DEFINE_TYPE_WITH_CODE (TspProvider,
@@ -65,81 +65,91 @@
static void
tsp_provider_class_init (TspProviderClass *klass)
{
- GObjectClass *gobject_class;
+ GObjectClass *gobject_class;
- gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->finalize = tsp_provider_finalize;
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = tsp_provider_finalize;
}
static void
tsp_provider_init (TspProvider *tsp_provider)
{
- /* Bleh..! */
+ /* Bleh..! */
}
static void
tsp_provider_finalize (GObject *object)
{
- /*TspProvider *tsp_provider = TSP_PROVIDER (object);*/
-
- (*G_OBJECT_CLASS (tsp_provider_parent_class)->finalize) (object);
+ /*TspProvider *tsp_provider = TSP_PROVIDER (object);*/
+
+ (*G_OBJECT_CLASS (tsp_provider_parent_class)->finalize) (object);
}
static void
tsp_provider_page_provider_init (ThunarxPropertyPageProviderIface *iface)
{
- iface->get_pages = tsp_provider_get_pages;
+ iface->get_pages = tsp_provider_get_pages;
}
static void
tsp_provider_prefs_provider_init (ThunarxPreferencesProviderIface *iface)
{
- iface->get_actions = tsp_provider_get_actions;
+ iface->get_actions = tsp_provider_get_actions;
}
static GList*
tsp_provider_get_pages (ThunarxPropertyPageProvider *property_page_provider,
GList *files)
{
- if (g_list_length (files) != 1){
- return NULL;
- } else if (!thunarx_file_info_is_directory (THUNARX_FILE_INFO (files->data))){
- return NULL;
- }
+ gchar *file_info;
+ GList *pages = NULL;
- return g_list_append (NULL, (gpointer)tsp_page_new (files->data));
+ if (g_list_length (files) != 1){
+ return NULL;
+ } else if (!thunarx_file_info_is_directory (THUNARX_FILE_INFO (files->data))){
+ return NULL;
+ }
+
+ file_info = thunarx_file_info_get_uri_scheme (THUNARX_FILE_INFO (files->data));
+
+ if (g_str_equal ("file", file_info))
+ {
+ pages = g_list_append (NULL, (gpointer)tsp_page_new (files->data));
+ }
+
+ g_free (file_info);
+
+ return pages;
}
static GList*
tsp_provider_get_actions (ThunarxPreferencesProvider *provider,
GtkWidget *window)
{
- GtkAction *action;
- GClosure *closure;
+ GtkAction *action;
+ GClosure *closure;
- action = gtk_action_new ("Tsp::thunar-shares-admin",
- _("Manage shared folders..."),
- _("Add, edit and remove shared folders"),
- NULL);
+ action = gtk_action_new ("Tsp::thunar-shares-admin",
+ _("Manage shared folders..."),
+ _("Add, edit and remove shared folders"),
+ NULL);
- g_object_set (G_OBJECT (action),
- "icon-name", "gnome-fs-share",
- NULL);
+ g_object_set (G_OBJECT (action), "icon-name", "gnome-fs-share", NULL);
- closure = g_cclosure_new_object_swap (
- G_CALLBACK (tsp_provider_prefs_activated), G_OBJECT (window));
+ closure = g_cclosure_new_object_swap (
+ G_CALLBACK (tsp_provider_prefs_activated), G_OBJECT (window));
- g_signal_connect_closure (G_OBJECT (action), "activate", closure, TRUE);
+ g_signal_connect_closure (G_OBJECT (action), "activate", closure, TRUE);
- return g_list_prepend (NULL, action);
+ return g_list_prepend (NULL, action);
}
static void
tsp_provider_prefs_activated (GtkWindow *window)
{
- GtkWidget *dialog;
-
- dialog = tsp_admin_manager_new (window);
-
- gtk_widget_show (dialog);
+ GtkWidget *dialog;
+
+ dialog = tsp_admin_manager_new (window);
+
+ gtk_widget_show (dialog);
}
More information about the Goodies-commits
mailing list