]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkfilesystem.c
Silently return NULL if the widget is not realized. (#316023, Guillaume
[~andy/gtk] / gtk / gtkfilesystem.c
index cd2b072257f24afc24bdb0e9230197188bbee779..268bfad1dd7f3c28e91739a92a32770534eff018 100644 (file)
@@ -22,7 +22,9 @@
 #include <gmodule.h>
 #include "gtkfilesystem.h"
 #include "gtkicontheme.h"
-#include "gtkmain.h"
+#include "gtkmodules.h"
+#include "gtkintl.h"
+#include "gtkalias.h"
 
 #include <string.h>
 
@@ -58,7 +60,7 @@ gtk_file_info_get_type (void)
   static GType our_type = 0;
   
   if (our_type == 0)
-    our_type = g_boxed_type_register_static ("GtkFileInfo",
+    our_type = g_boxed_type_register_static (I_("GtkFileInfo"),
                                             (GBoxedCopyFunc) gtk_file_info_copy,
                                             (GBoxedFreeFunc) gtk_file_info_free);
 
@@ -118,9 +120,9 @@ gtk_file_info_get_display_name (const GtkFileInfo *info)
  * gtk_file_info_get_display_key:
  * @info: a #GtkFileInfo
  * 
- * Returns results of g_utf8_collate_key() on the display name
- * for @info. This is useful when sorting a bunch of #GtkFileInfo
- * structures since the collate key will be only computed once.
+ * Returns for the collation key for the display name for @info. 
+ * This is useful when sorting a bunch of #GtkFileInfo structures 
+ * since the collate key will be only computed once.
  * 
  * Return value: The collate key for the display name, or %NULL
  *   if the display name hasn't been set.
@@ -134,7 +136,7 @@ gtk_file_info_get_display_key (const GtkFileInfo *info)
     {
       /* Since info->display_key is only a cache, we cast off the const
        */
-      ((GtkFileInfo *)info)->display_key = g_utf8_collate_key (info->display_name, -1);
+      ((GtkFileInfo *)info)->display_key = g_utf8_collate_key_for_filename (info->display_name, -1);
     }
        
   return info->display_key;
@@ -268,7 +270,7 @@ gtk_file_system_get_type (void)
       };
 
       file_system_type = g_type_register_static (G_TYPE_INTERFACE,
-                                                "GtkFileSystem",
+                                                I_("GtkFileSystem"),
                                                 &file_system_info, 0);
 
       g_type_interface_add_prerequisite (file_system_type, G_TYPE_OBJECT);
@@ -286,14 +288,14 @@ gtk_file_system_base_init (gpointer g_class)
     {
       GType iface_type = G_TYPE_FROM_INTERFACE (g_class);
 
-      g_signal_new ("volumes-changed",
+      g_signal_new (I_("volumes-changed"),
                    iface_type,
                    G_SIGNAL_RUN_LAST,
                    G_STRUCT_OFFSET (GtkFileSystemIface, volumes_changed),
                    NULL, NULL,
                    g_cclosure_marshal_VOID__VOID,
                    G_TYPE_NONE, 0);
-      g_signal_new ("bookmarks-changed",
+      g_signal_new (I_("bookmarks-changed"),
                    iface_type,
                    G_SIGNAL_RUN_LAST,
                    G_STRUCT_OFFSET (GtkFileSystemIface, bookmarks_changed),
@@ -592,9 +594,9 @@ gtk_file_system_parse (GtkFileSystem     *file_system,
 
   g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), FALSE);
   g_return_val_if_fail (base_path != NULL, FALSE);
+  g_return_val_if_fail (str != NULL, FALSE);
   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
-
   result = GTK_FILE_SYSTEM_GET_IFACE (file_system)->parse (file_system, base_path, str,
                                                           &tmp_folder, &tmp_file_part,
                                                           error);
@@ -771,6 +773,59 @@ gtk_file_system_list_bookmarks (GtkFileSystem *file_system)
   return GTK_FILE_SYSTEM_GET_IFACE (file_system)->list_bookmarks (file_system);
 }
 
+/**
+ * gtk_file_system_get_bookmark_label:
+ * @file_system: a #GtkFileSystem
+ * @path: path of the bookmark 
+ *
+ * Gets the label to display for a bookmark, or %NULL.
+ *
+ * Returns: the label for the bookmark @path
+ *
+ * Since: 2.8
+ */
+gchar *
+gtk_file_system_get_bookmark_label (GtkFileSystem     *file_system,
+                                   const GtkFilePath *path)
+{
+  GtkFileSystemIface *iface;
+
+  g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
+  g_return_val_if_fail (path != NULL, FALSE);
+
+  iface = GTK_FILE_SYSTEM_GET_IFACE (file_system);
+  if (iface->get_bookmark_label)
+    return iface->get_bookmark_label (file_system, path);
+
+  return NULL;
+}
+
+/**
+ * gtk_file_system_set_bookmark_label:
+ * @file_system: a #GtkFileSystem
+ * @path: path of the bookmark 
+ * @label: the label for the bookmark, or %NULL to display
+ *   the path itself
+ *
+ * Sets the label to display for a bookmark.
+ *
+ * Since: 2.8
+ */
+void
+gtk_file_system_set_bookmark_label (GtkFileSystem     *file_system,
+                                   const GtkFilePath *path,
+                                   const gchar       *label)
+{
+  GtkFileSystemIface *iface;
+
+  g_return_if_fail (GTK_IS_FILE_SYSTEM (file_system));
+  g_return_if_fail (path != NULL);
+
+  iface = GTK_FILE_SYSTEM_GET_IFACE (file_system);
+  if (iface->set_bookmark_label)
+    iface->set_bookmark_label (file_system, path, label);
+}
+
 /*****************************************
  *             GtkFileFolder             *
  *****************************************/
@@ -789,7 +844,7 @@ gtk_file_folder_get_type (void)
       };
 
       file_folder_type = g_type_register_static (G_TYPE_INTERFACE,
-                                                "GtkFileFolder",
+                                                I_("GtkFileFolder"),
                                                 &file_folder_info, 0);
       
       g_type_interface_add_prerequisite (file_folder_type, G_TYPE_OBJECT);
@@ -807,14 +862,14 @@ gtk_file_folder_base_init (gpointer g_class)
     {
       GType iface_type = G_TYPE_FROM_INTERFACE (g_class);
 
-      g_signal_new ("deleted",
+      g_signal_new (I_("deleted"),
                    iface_type,
                    G_SIGNAL_RUN_LAST,
                    G_STRUCT_OFFSET (GtkFileFolderIface, deleted),
                    NULL, NULL,
                    g_cclosure_marshal_VOID__VOID,
                    G_TYPE_NONE, 0);
-      g_signal_new ("files-added",
+      g_signal_new (I_("files-added"),
                    iface_type,
                    G_SIGNAL_RUN_LAST,
                    G_STRUCT_OFFSET (GtkFileFolderIface, files_added),
@@ -822,7 +877,7 @@ gtk_file_folder_base_init (gpointer g_class)
                    g_cclosure_marshal_VOID__POINTER,
                    G_TYPE_NONE, 1,
                    G_TYPE_POINTER);
-      g_signal_new ("files-changed",
+      g_signal_new (I_("files-changed"),
                    iface_type,
                    G_SIGNAL_RUN_LAST,
                    G_STRUCT_OFFSET (GtkFileFolderIface, files_changed),
@@ -830,7 +885,7 @@ gtk_file_folder_base_init (gpointer g_class)
                    g_cclosure_marshal_VOID__POINTER,
                    G_TYPE_NONE, 1,
                    G_TYPE_POINTER);
-      g_signal_new ("files-removed",
+      g_signal_new (I_("files-removed"),
                    iface_type,
                    G_SIGNAL_RUN_LAST,
                    G_STRUCT_OFFSET (GtkFileFolderIface, files_removed),
@@ -838,6 +893,13 @@ gtk_file_folder_base_init (gpointer g_class)
                    g_cclosure_marshal_VOID__POINTER,
                    G_TYPE_NONE, 1,
                    G_TYPE_POINTER);
+      g_signal_new (I_("finished-loading"),
+                   iface_type,
+                   G_SIGNAL_RUN_LAST,
+                   G_STRUCT_OFFSET (GtkFileFolderIface, finished_loading),
+                   NULL, NULL,
+                   g_cclosure_marshal_VOID__VOID,
+                   G_TYPE_NONE, 0);
 
       initialized = TRUE;
     }
@@ -876,6 +938,20 @@ gtk_file_folder_get_info (GtkFileFolder     *folder,
   return GTK_FILE_FOLDER_GET_IFACE (folder)->get_info (folder, path, error);
 }
 
+gboolean
+gtk_file_folder_is_finished_loading (GtkFileFolder *folder)
+{
+  GtkFileFolderIface *iface;
+
+  g_return_val_if_fail (GTK_IS_FILE_FOLDER (folder), TRUE);
+
+  iface = GTK_FILE_FOLDER_GET_IFACE (folder);
+  if (!iface->is_finished_loading)
+    return TRUE;
+  else
+    return iface->is_finished_loading (folder);
+}
+
 
 /*****************************************
  *         GtkFilePath modules           *
@@ -886,7 +962,7 @@ gtk_file_folder_get_info (GtkFileFolder     *folder,
 static gpointer
 gtk_file_path_real_copy (gpointer boxed)
 {
-  return gtk_file_path_new_dup (gtk_file_path_get_string ((GtkFilePath *) boxed));
+  return gtk_file_path_copy ((GtkFilePath *) boxed);
 }
 
 static void
@@ -901,7 +977,7 @@ gtk_file_path_get_type (void)
   static GType our_type = 0;
   
   if (our_type == 0)
-    our_type = g_boxed_type_register_static ("GtkFilePath",
+    our_type = g_boxed_type_register_static (I_("GtkFilePath"),
                                             (GBoxedCopyFunc) gtk_file_path_real_copy,
                                             (GBoxedFreeFunc) gtk_file_path_real_free);
 
@@ -987,8 +1063,8 @@ struct _GtkFileSystemModuleClass
   GTypeModuleClass parent_class;
 };
 
-G_DEFINE_TYPE (GtkFileSystemModule, gtk_file_system_module, G_TYPE_TYPE_MODULE);
-#define GTK_TYPE_FILE_SYSTEM_MODULE       (gtk_file_system_module_get_type ())
+G_DEFINE_TYPE (GtkFileSystemModule, _gtk_file_system_module, G_TYPE_TYPE_MODULE);
+#define GTK_TYPE_FILE_SYSTEM_MODULE       (_gtk_file_system_module_get_type ())
 #define GTK_FILE_SYSTEM_MODULE(module)   (G_TYPE_CHECK_INSTANCE_CAST ((module), GTK_TYPE_FILE_SYSTEM_MODULE, GtkFileSystemModule))
 
 
@@ -1052,11 +1128,11 @@ gtk_file_system_module_finalize (GObject *object)
 
   g_free (module->path);
 
-  G_OBJECT_CLASS (gtk_file_system_module_parent_class)->finalize (object);
+  G_OBJECT_CLASS (_gtk_file_system_module_parent_class)->finalize (object);
 }
 
 static void
-gtk_file_system_module_class_init (GtkFileSystemModuleClass *class)
+_gtk_file_system_module_class_init (GtkFileSystemModuleClass *class)
 {
   GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (class);
   GObjectClass *gobject_class = G_OBJECT_CLASS (class);
@@ -1068,7 +1144,7 @@ gtk_file_system_module_class_init (GtkFileSystemModuleClass *class)
 }
 
 static void
-gtk_file_system_module_init (GtkFileSystemModule *fs_module)
+_gtk_file_system_module_init (GtkFileSystemModule *fs_module)
 {
 }
 
@@ -1128,4 +1204,5 @@ _gtk_file_system_create (const char *file_system_name)
   return fs;
 }
 
-
+#define __GTK_FILE_SYSTEM_C__
+#include "gtkaliasdef.c"