]> Pileus Git - ~andy/gtk/commitdiff
added 'Desktop' to the list of volumes. We don't have any more untranlated
authorJonathan Blandford <jrb@gnome.org>
Wed, 10 Mar 2004 06:20:48 +0000 (06:20 +0000)
committerJonathan Blandford <jrb@src.gnome.org>
Wed, 10 Mar 2004 06:20:48 +0000 (06:20 +0000)
Wed Mar 10 01:17:40 2004  Jonathan Blandford  <jrb@gnome.org>

        * gtk/gtkpathbar.c: added 'Desktop' to the list of volumes.  We
        don't have any more untranlated strings in the dialog.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkpathbar.c
gtk/gtkpathbar.h

index 380ffce6818da790f77df085ed71b0b853963652..9f68ceaef7c889f1e3baf1ac96de3d4da3e9ee9c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Mar 10 01:17:40 2004  Jonathan Blandford  <jrb@gnome.org>
+
+       * gtk/gtkpathbar.c: added 'Desktop' to the list of volumes.  We
+       don't have any more untranlated strings in the dialog.
+
 Wed Mar 10 00:24:24 2004  Jonathan Blandford  <jrb@gnome.org>
 
        * gtk/gtkfilechooserdefault.c (error_dialog): use uri instead of
index 380ffce6818da790f77df085ed71b0b853963652..9f68ceaef7c889f1e3baf1ac96de3d4da3e9ee9c 100644 (file)
@@ -1,3 +1,8 @@
+Wed Mar 10 01:17:40 2004  Jonathan Blandford  <jrb@gnome.org>
+
+       * gtk/gtkpathbar.c: added 'Desktop' to the list of volumes.  We
+       don't have any more untranlated strings in the dialog.
+
 Wed Mar 10 00:24:24 2004  Jonathan Blandford  <jrb@gnome.org>
 
        * gtk/gtkfilechooserdefault.c (error_dialog): use uri instead of
index 380ffce6818da790f77df085ed71b0b853963652..9f68ceaef7c889f1e3baf1ac96de3d4da3e9ee9c 100644 (file)
@@ -1,3 +1,8 @@
+Wed Mar 10 01:17:40 2004  Jonathan Blandford  <jrb@gnome.org>
+
+       * gtk/gtkpathbar.c: added 'Desktop' to the list of volumes.  We
+       don't have any more untranlated strings in the dialog.
+
 Wed Mar 10 00:24:24 2004  Jonathan Blandford  <jrb@gnome.org>
 
        * gtk/gtkfilechooserdefault.c (error_dialog): use uri instead of
index 380ffce6818da790f77df085ed71b0b853963652..9f68ceaef7c889f1e3baf1ac96de3d4da3e9ee9c 100644 (file)
@@ -1,3 +1,8 @@
+Wed Mar 10 01:17:40 2004  Jonathan Blandford  <jrb@gnome.org>
+
+       * gtk/gtkpathbar.c: added 'Desktop' to the list of volumes.  We
+       don't have any more untranlated strings in the dialog.
+
 Wed Mar 10 00:24:24 2004  Jonathan Blandford  <jrb@gnome.org>
 
        * gtk/gtkfilechooserdefault.c (error_dialog): use uri instead of
index 380ffce6818da790f77df085ed71b0b853963652..9f68ceaef7c889f1e3baf1ac96de3d4da3e9ee9c 100644 (file)
@@ -1,3 +1,8 @@
+Wed Mar 10 01:17:40 2004  Jonathan Blandford  <jrb@gnome.org>
+
+       * gtk/gtkpathbar.c: added 'Desktop' to the list of volumes.  We
+       don't have any more untranlated strings in the dialog.
+
 Wed Mar 10 00:24:24 2004  Jonathan Blandford  <jrb@gnome.org>
 
        * gtk/gtkfilechooserdefault.c (error_dialog): use uri instead of
index eb5ef37fca4fa751a21d8e2c2c231b1a92bfe3b6..e87ec9d3d18288a6e6d1cf374b2484aeb7b3b1f6 100644 (file)
@@ -38,6 +38,7 @@ typedef enum {
   NORMAL_BUTTON,
   ROOT_BUTTON,
   HOME_BUTTON,
+  DESKTOP_BUTTON
 } ButtonType;
 
 #define BUTTON_DATA(x) ((ButtonData *)(x))
@@ -157,14 +158,20 @@ gtk_path_bar_finalize (GObject *object)
 
   path_bar = GTK_PATH_BAR (object);
   g_list_free (path_bar->button_list);
-  if (path_bar->home_path)
-    gtk_file_path_free (path_bar->home_path);
   if (path_bar->root_path)
     gtk_file_path_free (path_bar->root_path);
-  if (path_bar->home_icon)
-    g_object_unref (path_bar->home_icon);
+  if (path_bar->home_path)
+    gtk_file_path_free (path_bar->home_path);
+  if (path_bar->desktop_path)
+    gtk_file_path_free (path_bar->desktop_path);
+
   if (path_bar->root_icon)
     g_object_unref (path_bar->root_icon);
+  if (path_bar->home_icon)
+    g_object_unref (path_bar->home_icon);
+  if (path_bar->desktop_icon)
+    g_object_unref (path_bar->desktop_icon);
+
   if (path_bar->file_system)
     g_object_unref (path_bar->file_system);
 
@@ -619,9 +626,11 @@ static GdkPixbuf *
 get_button_image (GtkPathBar *path_bar,
                  ButtonType  button_type)
 {
-  if (button_type == ROOT_BUTTON)
+  GtkFileSystemVolume *volume;
+
+  switch (button_type)
     {
-      GtkFileSystemVolume *volume;
+    case ROOT_BUTTON:
 
       if (path_bar->root_icon != NULL)
        return path_bar->root_icon;
@@ -638,9 +647,7 @@ get_button_image (GtkPathBar *path_bar,
       gtk_file_system_volume_free (path_bar->file_system, volume);
 
       return path_bar->root_icon;
-    }
-  else if (button_type == HOME_BUTTON)
-    {
+    case HOME_BUTTON:
       if (path_bar->home_icon != NULL)
        return path_bar->home_icon;
 
@@ -649,6 +656,17 @@ get_button_image (GtkPathBar *path_bar,
                                                         GTK_WIDGET (path_bar),
                                                         ICON_SIZE, NULL);
       return path_bar->home_icon;
+    case DESKTOP_BUTTON:
+      if (path_bar->desktop_icon != NULL)
+       return path_bar->desktop_icon;
+
+      path_bar->desktop_icon = gtk_file_system_render_icon (path_bar->file_system,
+                                                           path_bar->desktop_path,
+                                                           GTK_WIDGET (path_bar),
+                                                           ICON_SIZE, NULL);
+      return path_bar->desktop_icon;
+    default:
+      return NULL;
     }
   
   return NULL;
@@ -671,6 +689,8 @@ update_button_appearance (GtkPathBar *path_bar,
 
   if (button_data->type == HOME_BUTTON)
     dir_name = _("Home");
+  else if (button_data->type == DESKTOP_BUTTON)
+    dir_name = _("Desktop");
   else
     dir_name = button_data->dir_name;
 
@@ -705,6 +725,20 @@ update_button_appearance (GtkPathBar *path_bar,
     }
 }
 
+static ButtonType
+find_button_type (GtkPathBar  *path_bar,
+                 GtkFilePath *path)
+{
+  if (! gtk_file_path_compare (path, path_bar->root_path))
+    return ROOT_BUTTON;
+  if (! gtk_file_path_compare (path, path_bar->home_path))
+    return HOME_BUTTON;
+  if (! gtk_file_path_compare (path, path_bar->desktop_path))
+    return DESKTOP_BUTTON;
+
+ return NORMAL_BUTTON;
+}
+
 static ButtonData *
 make_directory_button (GtkPathBar  *path_bar,
                       const char  *dir_name,
@@ -717,12 +751,7 @@ make_directory_button (GtkPathBar  *path_bar,
   /* Is it a special button? */
   button_data = g_new0 (ButtonData, 1);
 
-  button_data->type = NORMAL_BUTTON;
-  if (! gtk_file_path_compare (path, path_bar->root_path))
-    button_data->type = ROOT_BUTTON;
-  if (! gtk_file_path_compare (path, path_bar->home_path))
-    button_data->type = HOME_BUTTON;
-
+  button_data->type = find_button_type (path_bar, path);
   button_data->button = gtk_toggle_button_new ();
 
   switch (button_data->type)
@@ -733,6 +762,7 @@ make_directory_button (GtkPathBar  *path_bar,
       button_data->label = NULL;
       break;
     case HOME_BUTTON:
+    case DESKTOP_BUTTON:
       button_data->image = gtk_image_new ();
       button_data->label = gtk_label_new (NULL);
       child = gtk_hbox_new (FALSE, 2);
@@ -740,12 +770,10 @@ make_directory_button (GtkPathBar  *path_bar,
       gtk_box_pack_start (GTK_BOX (child), button_data->label, FALSE, FALSE, 0);
       break;
     case NORMAL_BUTTON:
+    default:
       button_data->label = gtk_label_new (NULL);
       child = button_data->label;
       button_data->image = NULL;
-      break;
-    default:
-      g_assert_not_reached ();
     }
 
   button_data->dir_name = g_strdup (dir_name);
@@ -759,9 +787,8 @@ make_directory_button (GtkPathBar  *path_bar,
   g_signal_connect (button_data->button, "clicked",
                    G_CALLBACK (button_clicked_cb),
                    button_data);
-  g_object_set_data_full (G_OBJECT (button_data->button),
-                         "gtk-path-bar-button-data",
-                         button_data, button_data_free);
+  g_object_weak_ref (G_OBJECT (button_data->button),
+                    (GWeakNotify) button_data_free, button_data);
 
   return button_data;
 }
@@ -917,6 +944,8 @@ _gtk_path_bar_set_file_system (GtkPathBar    *path_bar,
                               GtkFileSystem *file_system)
 {
   const char *home;
+  char *desktop;
+
   g_return_if_fail (GTK_IS_PATH_BAR (path_bar));
 
   g_assert (path_bar->file_system == NULL);
@@ -924,6 +953,8 @@ _gtk_path_bar_set_file_system (GtkPathBar    *path_bar,
   path_bar->file_system = g_object_ref (file_system);
 
   home = g_get_home_dir ();
+  desktop = g_build_filename (home, "Desktop", NULL);
   path_bar->home_path = gtk_file_system_filename_to_path (path_bar->file_system, home);
+  path_bar->desktop_path = gtk_file_system_filename_to_path (path_bar->file_system, desktop);
   path_bar->root_path = gtk_file_system_filename_to_path (path_bar->file_system, "/");
 }
index d82a07b5246680dc465323fe59a22c5ef7575bc2..18164b5ac87c5733f25302d2d7de433b9636b854 100644 (file)
@@ -43,8 +43,11 @@ struct _GtkPathBar
   GtkFileSystem *file_system;
   GtkFilePath *root_path;
   GtkFilePath *home_path;
-  GdkPixbuf *home_icon;
+  GtkFilePath *desktop_path;
+
   GdkPixbuf *root_icon;
+  GdkPixbuf *home_icon;
+  GdkPixbuf *desktop_icon;
 
   GList *button_list;
   GList *first_scrolled_button;