gtk+ r22156 - in trunk: . gtk



Author: federico
Date: Wed Jan 21 03:16:46 2009
New Revision: 22156
URL: http://svn.gnome.org/viewvc/gtk+?rev=22156&view=rev

Log:
Add a local_only property to GtkFileChooserEntry
	Patch by Carlos Garnacho <carlos imendio com> - add a local_only
	property to GtkFileChooserEntry:

	* gtk/gtkfilechooserentry.c (struct _GtkFileChooserEntry): Add a
	local_only field.
	(_gtk_file_chooser_entry_init): Default to local_only being true.
	(start_explicit_completion): Don't allow completion of non-native
	files if local_only is turned on.
	(start_loading_current_folder): Don't start loading non-native
	folders if local_only is turned on.
	(_gtk_file_chooser_entry_set_local_only): New function.
	(_gtk_file_chooser_entry_get_local_only): New function.

	* gtk/gtkfilechooserentry.h (_gtk_file_chooser_entry_set_local_only,
	_gtk_file_chooser_entry_get_local_only): New prototypes.

	* gtk/gtkfilechooserdefault.c (set_local_only): Set the local_only
	property on the entry.

Signed-off-by: Federico Mena Quintero <federico novell com>

Modified:
   trunk/ChangeLog
   trunk/gtk/gtkfilechooserdefault.c
   trunk/gtk/gtkfilechooserentry.c
   trunk/gtk/gtkfilechooserentry.h

Modified: trunk/gtk/gtkfilechooserdefault.c
==============================================================================
--- trunk/gtk/gtkfilechooserdefault.c	(original)
+++ trunk/gtk/gtkfilechooserdefault.c	Wed Jan 21 03:16:46 2009
@@ -5334,6 +5334,8 @@
     {
       impl->local_only = local_only;
 
+      _gtk_file_chooser_entry_set_local_only (GTK_FILE_CHOOSER_ENTRY (impl->location_entry), local_only);
+
       if (impl->shortcuts_model && impl->file_system)
 	{
 	  shortcuts_add_volumes (impl);

Modified: trunk/gtk/gtkfilechooserentry.c
==============================================================================
--- trunk/gtk/gtkfilechooserentry.c	(original)
+++ trunk/gtk/gtkfilechooserentry.c	Wed Jan 21 03:16:46 2009
@@ -79,6 +79,7 @@
   guint has_completion : 1;
   guint in_change      : 1;
   guint eat_tabs       : 1;
+  guint local_only     : 1;
 };
 
 enum
@@ -194,6 +195,8 @@
   GtkEntryCompletion *comp;
   GtkCellRenderer *cell;
 
+  chooser_entry->local_only = TRUE;
+
   g_object_set (chooser_entry, "truncate-multiline", TRUE, NULL);
 
   comp = gtk_entry_completion_new ();
@@ -1107,6 +1110,16 @@
       return;
     }
 
+  if (chooser_entry->local_only
+      && !g_file_is_native (chooser_entry->current_folder_file))
+    {
+      beep (chooser_entry);
+      pop_up_completion_feedback (chooser_entry, _("Only local files can be selected"));
+
+      chooser_entry->load_complete_action = LOAD_COMPLETE_NOTHING;
+      return;
+    }
+
   if (chooser_entry->current_folder
       && _gtk_folder_is_finished_loading (chooser_entry->current_folder))
     {
@@ -1366,6 +1379,10 @@
       chooser_entry->file_system == NULL)
     return;
 
+  if (chooser_entry->local_only
+      && !g_file_is_native (chooser_entry->current_folder_file))
+    return;
+
   g_assert (chooser_entry->current_folder == NULL);
   g_assert (chooser_entry->load_folder_cancellable == NULL);
 
@@ -1826,3 +1843,16 @@
   gtk_editable_select_region (GTK_EDITABLE (chooser_entry), 0, (gint) len);
 }
 
+void
+_gtk_file_chooser_entry_set_local_only (GtkFileChooserEntry *chooser_entry,
+                                        gboolean             local_only)
+{
+  chooser_entry->local_only = local_only;
+  clear_completions (chooser_entry);
+}
+
+gboolean
+_gtk_file_chooser_entry_get_local_only (GtkFileChooserEntry *chooser_entry)
+{
+  return chooser_entry->local_only;
+}

Modified: trunk/gtk/gtkfilechooserentry.h
==============================================================================
--- trunk/gtk/gtkfilechooserentry.h	(original)
+++ trunk/gtk/gtkfilechooserentry.h	Wed Jan 21 03:16:46 2009
@@ -48,6 +48,9 @@
 gboolean           _gtk_file_chooser_entry_get_is_folder      (GtkFileChooserEntry *chooser_entry,
 							       GFile               *file);
 void               _gtk_file_chooser_entry_select_filename    (GtkFileChooserEntry *chooser_entry);
+void               _gtk_file_chooser_entry_set_local_only     (GtkFileChooserEntry *chooser_entry,
+                                                               gboolean             local_only);
+gboolean           _gtk_file_chooser_entry_get_local_only     (GtkFileChooserEntry *chooser_entry);
 
 G_END_DECLS
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]