[gtk+/filechooser-recent-folders-2-24: 3/7] gtkfilechooserbutton.c update to 3.0



commit 0bbee739d31d2e80bcdc7d4393fe9635ac866a11
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Jul 12 13:32:41 2011 -0500

    gtkfilechooserbutton.c update to 3.0

 gtk/gtkfilechooserbutton.c |  133 ++++++++++++++++++++++----------------------
 1 files changed, 67 insertions(+), 66 deletions(-)
---
diff --git a/gtk/gtkfilechooserbutton.c b/gtk/gtkfilechooserbutton.c
index 7b68276..b6eed01 100644
--- a/gtk/gtkfilechooserbutton.c
+++ b/gtk/gtkfilechooserbutton.c
@@ -61,7 +61,7 @@
 
 #define GTK_FILE_CHOOSER_BUTTON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_FILE_CHOOSER_BUTTON, GtkFileChooserButtonPrivate))
 
-#define DEFAULT_TITLE		N_("Select A File")
+#define DEFAULT_TITLE		N_("Select a File")
 #define DESKTOP_DISPLAY_NAME	N_("Desktop")
 #define FALLBACK_DISPLAY_NAME	N_("(None)")
 #define FALLBACK_ICON_NAME	"stock_unknown"
@@ -460,7 +460,8 @@ gtk_file_chooser_button_init (GtkFileChooserButton *button)
   priv->label = gtk_label_new (_(FALLBACK_DISPLAY_NAME));
   gtk_label_set_ellipsize (GTK_LABEL (priv->label), PANGO_ELLIPSIZE_END);
   gtk_misc_set_alignment (GTK_MISC (priv->label), 0.0, 0.5);
-  gtk_container_add (GTK_CONTAINER (box), priv->label);
+  gtk_box_pack_start (GTK_BOX (box), priv->label, TRUE, TRUE, 0);
+  //gtk_container_add (GTK_CONTAINER (box), priv->label);
   gtk_widget_show (priv->label);
 
   sep = gtk_vseparator_new ();
@@ -662,7 +663,7 @@ gtk_file_chooser_button_constructor (GType                  type,
 
       gtk_file_chooser_button_set_title (button, _(DEFAULT_TITLE));
     }
-  else if (!GTK_WINDOW (priv->dialog)->title)
+  else if (!gtk_window_get_title (GTK_WINDOW (priv->dialog)))
     {
       gtk_file_chooser_button_set_title (button, _(DEFAULT_TITLE));
     }
@@ -1058,7 +1059,7 @@ gtk_file_chooser_button_drag_data_received (GtkWidget	     *widget,
 										 data, type,
 										 drag_time);
 
-  if (widget == NULL || context == NULL || data == NULL || data->length < 0)
+  if (widget == NULL || context == NULL || data == NULL || gtk_selection_data_get_length (data) < 0)
     return;
 
   switch (type)
@@ -1774,13 +1775,13 @@ model_add_volumes (GtkFileChooserButton *button,
       volume = l->data;
 
       if (local_only)
-	{
-	  if (_gtk_file_system_volume_is_mounted (volume))
-	    {
-	      GFile *base_file;
+        {
+          if (_gtk_file_system_volume_is_mounted (volume))
+            {
+              GFile *base_file;
 
-	      base_file = _gtk_file_system_volume_get_root (volume);
-	      if (base_file != NULL)
+              base_file = _gtk_file_system_volume_get_root (volume);
+              if (base_file != NULL)
                 {
                   if (!g_file_is_native (base_file))
                     {
@@ -1790,26 +1791,26 @@ model_add_volumes (GtkFileChooserButton *button,
                   else
                     g_object_unref (base_file);
                 }
-	    }
-	}
+            }
+        }
 
       pixbuf = _gtk_file_system_volume_render_icon (volume,
-						    GTK_WIDGET (button),
-						    button->priv->icon_size,
-						    NULL);
+                                                    GTK_WIDGET (button),
+                                                    button->priv->icon_size,
+                                                    NULL);
       display_name = _gtk_file_system_volume_get_display_name (volume);
 
       gtk_list_store_insert (store, &iter, pos);
       gtk_list_store_set (store, &iter,
-			  ICON_COLUMN, pixbuf,
-			  DISPLAY_NAME_COLUMN, display_name,
-			  TYPE_COLUMN, ROW_TYPE_VOLUME,
-			  DATA_COLUMN, _gtk_file_system_volume_ref (volume),
-			  IS_FOLDER_COLUMN, TRUE,
-			  -1);
+                          ICON_COLUMN, pixbuf,
+                          DISPLAY_NAME_COLUMN, display_name,
+                          TYPE_COLUMN, ROW_TYPE_VOLUME,
+                          DATA_COLUMN, _gtk_file_system_volume_ref (volume),
+                          IS_FOLDER_COLUMN, TRUE,
+                          -1);
 
       if (pixbuf)
-	g_object_unref (pixbuf);
+        g_object_unref (pixbuf);
       g_free (display_name);
 
       button->priv->n_volumes++;
@@ -2303,13 +2304,11 @@ static void
 update_label_and_image (GtkFileChooserButton *button)
 {
   GtkFileChooserButtonPrivate *priv = button->priv;
-  GdkPixbuf *pixbuf;
   gchar *label_text;
   GSList *files;
 
   files = gtk_file_chooser_get_files (GTK_FILE_CHOOSER (priv->dialog));
   label_text = NULL;
-  pixbuf = NULL;
 
   if (priv->update_button_cancellable)
     {
@@ -2326,51 +2325,53 @@ update_label_and_image (GtkFileChooserButton *button)
 
       volume = _gtk_file_system_get_volume_for_file (priv->fs, file);
       if (volume)
-	{
-	  GFile *base_file;
-
-	  base_file = _gtk_file_system_volume_get_root (volume);
-	  if (base_file && g_file_equal (base_file, file))
-	    {
-	      label_text = _gtk_file_system_volume_get_display_name (volume);
-	      pixbuf = _gtk_file_system_volume_render_icon (volume,
-							    GTK_WIDGET (button),
-							    priv->icon_size,
-							    NULL);
-	    }
-
-	  if (base_file)
-	    g_object_unref (base_file);
-
-	  _gtk_file_system_volume_unref (volume);
-
-	  if (label_text)
-	    goto out;
-	}
+        {
+          GFile *base_file;
+
+          base_file = _gtk_file_system_volume_get_root (volume);
+          if (base_file && g_file_equal (base_file, file))
+            {
+              GdkPixbuf *pixbuf;
+
+              label_text = _gtk_file_system_volume_get_display_name (volume);
+              pixbuf = _gtk_file_system_volume_render_icon (volume,
+                                                            GTK_WIDGET (button),
+                                                            priv->icon_size,
+                                                            NULL);
+              gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), pixbuf);
+              if (pixbuf)
+                g_object_unref (pixbuf);
+            }
+
+          if (base_file)
+            g_object_unref (base_file);
+
+          _gtk_file_system_volume_unref (volume);
+
+          if (label_text)
+            goto out;
+        }
 
       if (g_file_is_native (file))
-	{
-	  priv->update_button_cancellable =
-	    _gtk_file_system_get_info (priv->fs, file,
-				       "standard::icon,standard::display-name",
-				       update_label_get_info_cb,
-				       g_object_ref (button));
-	}
+        {
+          priv->update_button_cancellable =
+            _gtk_file_system_get_info (priv->fs, file,
+                                       "standard::icon,standard::display-name",
+                                       update_label_get_info_cb,
+                                       g_object_ref (button));
+        }
       else
-	{
-	  GdkPixbuf *pixbuf;
-
-	  label_text = _gtk_file_system_get_bookmark_label (button->priv->fs, file);
-	  
-	  pixbuf = gtk_icon_theme_load_icon (get_icon_theme (GTK_WIDGET (priv->image)), 
-					     "text-x-generic",
-					     priv->icon_size, 0, NULL);
-	  
-	  gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), pixbuf);
-
-	  if (pixbuf)
-	    g_object_unref (pixbuf);
-	}
+        {
+          GdkPixbuf *pixbuf;
+
+          label_text = _gtk_file_system_get_bookmark_label (button->priv->fs, file);
+          pixbuf = gtk_icon_theme_load_icon (get_icon_theme (GTK_WIDGET (priv->image)),
+                                             "text-x-generic",
+                                             priv->icon_size, 0, NULL);
+          gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), pixbuf);
+          if (pixbuf)
+            g_object_unref (pixbuf);
+        }
     }
 out:
   g_slist_foreach (files, (GFunc) g_object_unref, NULL);



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