gtkfilechooserbutton.c update to 3.0

This commit is contained in:
Federico Mena Quintero 2011-07-12 13:32:41 -05:00
parent eec3cec225
commit 0bbee739d3

View File

@ -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;
{
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);
}
base_file = _gtk_file_system_volume_get_root (volume);
if (base_file && g_file_equal (base_file, file))
{
GdkPixbuf *pixbuf;
if (base_file)
g_object_unref (base_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);
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), pixbuf);
if (pixbuf)
g_object_unref (pixbuf);
}
_gtk_file_system_volume_unref (volume);
if (base_file)
g_object_unref (base_file);
if (label_text)
goto out;
}
_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;
{
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);
}
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);