[maemo-commits] [maemo-commits] r15483 - in projects/haf/trunk/hildon-fm: . hildon-fm

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Thu Apr 24 12:57:42 EEST 2008
Author: marivoll
Date: 2008-04-24 12:57:41 +0300 (Thu, 24 Apr 2008)
New Revision: 15483

Modified:
   projects/haf/trunk/hildon-fm/ChangeLog
   projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-details-dialog.c
Log:
	Show information banner when tapping a insensitive read-only
	checkbox.

	* hildon-fm/hildon-file-details-dialog.c (can_change_permissions)
	(guess_change_permissions_result): Renamed former to latter.
	Return result code instead of boolean success flag.
	(permissions_insensitive_press): New.
	(hildon_file_details_dialog_init): Connect it.
	(hildon_file_details_dialog_set_file_iter): Remember result code
	for permission changes for permissions_insensitive_press.


Modified: projects/haf/trunk/hildon-fm/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-fm/ChangeLog	2008-04-24 09:56:45 UTC (rev 15482)
+++ projects/haf/trunk/hildon-fm/ChangeLog	2008-04-24 09:57:41 UTC (rev 15483)
@@ -1,3 +1,16 @@
+2008-04-24  Marius Vollmer  <marius.vollmer at nokia.com>
+
+	Show information banner when tapping a insensitive read-only
+	checkbox.
+
+	* hildon-fm/hildon-file-details-dialog.c (can_change_permissions)
+	(guess_change_permissions_result): Renamed former to latter.
+	Return result code instead of boolean success flag.
+	(permissions_insensitive_press): New.
+	(hildon_file_details_dialog_init): Connect it.
+	(hildon_file_details_dialog_set_file_iter): Remember result code
+	of permission changes for permissions_insensitive_press.
+
 2008-04-24  Kimmo Hämäläinen  <kimmo.hamalainen at nokia.com>
 
 	* hildon-fm/hildon-file-system-smb.c

Modified: projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-details-dialog.c
===================================================================
--- projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-details-dialog.c	2008-04-24 09:56:45 UTC (rev 15482)
+++ projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-details-dialog.c	2008-04-24 09:57:41 UTC (rev 15483)
@@ -71,6 +71,8 @@
     GtkWidget *ok_button;
     GtkWidget *scroll;
 
+    GnomeVFSResult change_permissions_result;
+
     GtkTreeRowReference *active_file;
     gboolean checkbox_original_state;
     gulong toggle_handler;
@@ -147,20 +149,21 @@
   return result;
 }
 
-static gboolean can_change_permissions (const gchar *uri)
+static GnomeVFSResult guess_change_permissions_result (const gchar *uri)
 {
   GnomeVFSFileInfo *info;
-  gboolean result = FALSE;
+  gboolean result;
 
   /* Get information about file */
   info = gnome_vfs_file_info_new ();
-  if ((gnome_vfs_get_file_info (uri, info, GNOME_VFS_FILE_INFO_DEFAULT)
-       == GNOME_VFS_OK)
-      && (info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS))
+  result = gnome_vfs_get_file_info (uri, info, GNOME_VFS_FILE_INFO_DEFAULT);
+  if (result == GNOME_VFS_OK)
     {
-      result = (gnome_vfs_set_file_info (uri, info,
-					 GNOME_VFS_SET_FILE_INFO_PERMISSIONS)
-		== GNOME_VFS_OK);
+      if (info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS)
+	result = gnome_vfs_set_file_info (uri, info,
+					  GNOME_VFS_SET_FILE_INFO_PERMISSIONS);
+      else
+	result = GNOME_VFS_ERROR_GENERIC;
     }
 
   gnome_vfs_file_info_unref(info);
@@ -266,6 +269,16 @@
 }
 
 static void
+permissions_insensitive_press (GtkWidget *widget, gpointer data)
+{
+  HildonFileDetailsDialog* self = HILDON_FILE_DETAILS_DIALOG (data);
+  const char *msg 
+    = gnome_vfs_result_to_string (self->priv->change_permissions_result);
+
+  hildon_banner_show_information (GTK_WIDGET (self), NULL, msg);
+}
+
+static void
 hildon_file_details_dialog_class_init(HildonFileDetailsDialogClass * klass)
 {
     GObjectClass *gobject_class;
@@ -382,6 +395,8 @@
     priv->file_date = g_object_new(GTK_TYPE_LABEL,"xalign", 0.0f, NULL);
     priv->file_time = g_object_new(GTK_TYPE_LABEL, "xalign", 0.0f, NULL);
     priv->file_readonly = gtk_check_button_new();
+    g_signal_connect (priv->file_readonly, "insensitive-press",
+		      G_CALLBACK (permissions_insensitive_press), self);
 
     hbox_type = gtk_hbox_new (FALSE, HILDON_MARGIN_DEFAULT);
     hbox_location = gtk_hbox_new(FALSE, HILDON_MARGIN_DEFAULT);
@@ -885,10 +900,11 @@
   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(self->priv->file_readonly),
 			       location_readonly || !write_access(uri));
 
+  self->priv->change_permissions_result =
+    guess_change_permissions_result (uri);
   gtk_widget_set_sensitive(self->priv->file_readonly,
-			   (!location_readonly
-			    && can_change_permissions (uri)));
-
+			   (self->priv->change_permissions_result
+			    == GNOME_VFS_OK));
   self->priv->checkbox_original_state = gtk_toggle_button_get_active(
         GTK_TOGGLE_BUTTON(self->priv->file_readonly));
 


More information about the maemo-commits mailing list