xed-file-browser-utils.c: Clean up code style
This commit is contained in:
parent
44f60af7a7
commit
14cc619751
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* xed-file-bookmarks-store.c - Xed plugin providing easy file access
|
* xed-file-browser-utils.c - Xed plugin providing easy file access
|
||||||
* from the sidepanel
|
* from the sidepanel
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 - Jesse van den Kieboom <jesse@icecrew.nl>
|
* Copyright (C) 2006 - Jesse van den Kieboom <jesse@icecrew.nl>
|
||||||
|
@ -30,18 +30,15 @@ process_icon_pixbuf (GdkPixbuf * pixbuf,
|
||||||
{
|
{
|
||||||
GdkPixbuf *scale;
|
GdkPixbuf *scale;
|
||||||
|
|
||||||
if (error != NULL) {
|
if (error != NULL)
|
||||||
g_warning ("Could not load theme icon %s: %s",
|
{
|
||||||
name,
|
g_warning ("Could not load theme icon %s: %s", name, error->message);
|
||||||
error->message);
|
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pixbuf && gdk_pixbuf_get_width (pixbuf) > size) {
|
if (pixbuf && gdk_pixbuf_get_width (pixbuf) > size)
|
||||||
scale = gdk_pixbuf_scale_simple (pixbuf,
|
{
|
||||||
size,
|
scale = gdk_pixbuf_scale_simple (pixbuf, size, size, GDK_INTERP_BILINEAR);
|
||||||
size,
|
|
||||||
GDK_INTERP_BILINEAR);
|
|
||||||
g_object_unref (pixbuf);
|
g_object_unref (pixbuf);
|
||||||
pixbuf = scale;
|
pixbuf = scale;
|
||||||
}
|
}
|
||||||
|
@ -59,11 +56,7 @@ xed_file_browser_utils_pixbuf_from_theme (gchar const * name,
|
||||||
|
|
||||||
gtk_icon_size_lookup (size, &width, NULL);
|
gtk_icon_size_lookup (size, &width, NULL);
|
||||||
|
|
||||||
pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
|
pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), name, width, 0, &error);
|
||||||
name,
|
|
||||||
width,
|
|
||||||
0,
|
|
||||||
&error);
|
|
||||||
|
|
||||||
pixbuf = process_icon_pixbuf (pixbuf, name, width, error);
|
pixbuf = process_icon_pixbuf (pixbuf, name, width, error);
|
||||||
|
|
||||||
|
@ -80,18 +73,19 @@ xed_file_browser_utils_pixbuf_from_icon (GIcon * icon,
|
||||||
gint width;
|
gint width;
|
||||||
|
|
||||||
if (!icon)
|
if (!icon)
|
||||||
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
theme = gtk_icon_theme_get_default ();
|
theme = gtk_icon_theme_get_default ();
|
||||||
gtk_icon_size_lookup (size, &width, NULL);
|
gtk_icon_size_lookup (size, &width, NULL);
|
||||||
|
|
||||||
info = gtk_icon_theme_lookup_by_gicon (theme,
|
info = gtk_icon_theme_lookup_by_gicon (theme, icon, width, GTK_ICON_LOOKUP_USE_BUILTIN);
|
||||||
icon,
|
|
||||||
width,
|
|
||||||
GTK_ICON_LOOKUP_USE_BUILTIN);
|
|
||||||
|
|
||||||
if (!info)
|
if (!info)
|
||||||
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
ret = gtk_icon_info_load_icon (info, NULL);
|
ret = gtk_icon_info_load_icon (info, NULL);
|
||||||
gtk_icon_info_free (info);
|
gtk_icon_info_free (info);
|
||||||
|
@ -107,18 +101,18 @@ xed_file_browser_utils_pixbuf_from_file (GFile * file,
|
||||||
GFileInfo *info;
|
GFileInfo *info;
|
||||||
GdkPixbuf *ret = NULL;
|
GdkPixbuf *ret = NULL;
|
||||||
|
|
||||||
info = g_file_query_info (file,
|
info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_ICON, G_FILE_QUERY_INFO_NONE, NULL, NULL);
|
||||||
G_FILE_ATTRIBUTE_STANDARD_ICON,
|
|
||||||
G_FILE_QUERY_INFO_NONE,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
if (!info)
|
if (!info)
|
||||||
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
icon = g_file_info_get_icon (info);
|
icon = g_file_info_get_icon (info);
|
||||||
if (icon != NULL)
|
if (icon != NULL)
|
||||||
|
{
|
||||||
ret = xed_file_browser_utils_pixbuf_from_icon (icon, size);
|
ret = xed_file_browser_utils_pixbuf_from_icon (icon, size);
|
||||||
|
}
|
||||||
|
|
||||||
g_object_unref (info);
|
g_object_unref (info);
|
||||||
|
|
||||||
|
@ -150,36 +144,32 @@ xed_file_browser_utils_confirmation_dialog (XedWindow * window,
|
||||||
GTK_BUTTONS_NONE, "%s", message);
|
GTK_BUTTONS_NONE, "%s", message);
|
||||||
|
|
||||||
if (secondary)
|
if (secondary)
|
||||||
gtk_message_dialog_format_secondary_text
|
{
|
||||||
(GTK_MESSAGE_DIALOG (dlg), "%s", secondary);
|
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dlg), "%s", secondary);
|
||||||
|
}
|
||||||
|
|
||||||
/* Add a cancel button */
|
/* Add a cancel button */
|
||||||
button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
|
button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
|
||||||
gtk_widget_show (button);
|
gtk_widget_show (button);
|
||||||
|
|
||||||
gtk_widget_set_can_default (button, TRUE);
|
gtk_widget_set_can_default (button, TRUE);
|
||||||
gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
|
gtk_dialog_add_action_widget (GTK_DIALOG (dlg), button, GTK_RESPONSE_CANCEL);
|
||||||
button,
|
|
||||||
GTK_RESPONSE_CANCEL);
|
|
||||||
|
|
||||||
/* Add custom button */
|
/* Add custom button */
|
||||||
button = gtk_button_new_from_stock (button_stock);
|
button = gtk_button_new_from_stock (button_stock);
|
||||||
|
|
||||||
if (button_label) {
|
if (button_label)
|
||||||
|
{
|
||||||
gtk_button_set_use_stock (GTK_BUTTON (button), FALSE);
|
gtk_button_set_use_stock (GTK_BUTTON (button), FALSE);
|
||||||
gtk_button_set_label (GTK_BUTTON (button), button_label);
|
gtk_button_set_label (GTK_BUTTON (button), button_label);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_widget_show (button);
|
gtk_widget_show (button);
|
||||||
gtk_widget_set_can_default (button, TRUE);
|
gtk_widget_set_can_default (button, TRUE);
|
||||||
gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
|
gtk_dialog_add_action_widget (GTK_DIALOG (dlg), button, GTK_RESPONSE_OK);
|
||||||
button,
|
|
||||||
GTK_RESPONSE_OK);
|
|
||||||
|
|
||||||
ret = gtk_dialog_run (GTK_DIALOG (dlg));
|
ret = gtk_dialog_run (GTK_DIALOG (dlg));
|
||||||
gtk_widget_destroy (dlg);
|
gtk_widget_destroy (dlg);
|
||||||
|
|
||||||
return (ret == GTK_RESPONSE_OK);
|
return (ret == GTK_RESPONSE_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ex:ts=8:noet:
|
|
||||||
|
|
Loading…
Reference in New Issue