Commit 6239dcfd authored by Victor Ananjevsky's avatar Victor Ananjevsky

add --icon-size option to icon dialog

parent 5959f512
......@@ -380,6 +380,9 @@ Sending \fIFormFeed\fP character clears iconbox.
.B \-\-item-width
Set items width.
.TP
.B \-\-icon-size
Force using specified icon size. This option doesn't work in compact mode.
.TP
.B \-\-compact
Use compact mode. Icon and name of each item is placed in a single row.
.TP
......
......@@ -45,6 +45,33 @@ typedef struct {
gboolean in_term;
} DEntry;
static GdkPixbuf *
scale_pixbuf (GdkPixbuf *pb)
{
GdkPixbuf *res;
if (!pb)
return NULL;
if (options.common_data.icon_size > 0)
{
guint width, height;
width = gdk_pixbuf_get_width (pb);
height = gdk_pixbuf_get_height (pb);
if (options.common_data.icon_size != width || options.common_data.icon_size != height)
res = gdk_pixbuf_scale_simple (pb, options.common_data.icon_size,
options.common_data.icon_size, GDK_INTERP_BILINEAR);
else
res = g_object_ref (pb);
}
else
res = g_object_ref (pb);
return res;
}
static void
select_cb (GObject * obj, gpointer data)
{
......@@ -148,7 +175,7 @@ handle_stdin (GIOChannel * channel, GIOCondition condition, gpointer data)
do
{
GdkPixbuf *pb;
GdkPixbuf *spb = NULL;
gint status;
do
......@@ -207,15 +234,22 @@ handle_stdin (GIOChannel * channel, GIOCondition condition, gpointer data)
}
case COL_PIXBUF:
if (options.icons_data.compact)
if (*string->str)
pb = get_pixbuf (string->str, YAD_SMALL_ICON);
else
pb = NULL;
{
if (*string->str)
spb = get_pixbuf (string->str, YAD_SMALL_ICON);
}
else
pb = get_pixbuf (string->str, YAD_BIG_ICON);
gtk_list_store_set (GTK_LIST_STORE (model), &iter, column_count, pb, -1);
if (pb)
g_object_unref (pb);
{
GdkPixbuf *pb = get_pixbuf (string->str, YAD_BIG_ICON);
if (pb)
{
spb = scale_pixbuf (pb);
g_object_unref (pb);
}
}
gtk_list_store_set (GTK_LIST_STORE (model), &iter, column_count, spb, -1);
if (spb)
g_object_unref (spb);
break;
case COL_TERM:
gtk_list_store_set (GTK_LIST_STORE (model), &iter, column_count, get_bool_val (string->str), -1);
......@@ -324,7 +358,12 @@ parse_desktop_file (gchar * filename)
if (options.icons_data.compact)
ent->pixbuf = get_pixbuf (icon, YAD_SMALL_ICON);
else
ent->pixbuf = get_pixbuf (icon, YAD_BIG_ICON);
{
GdkPixbuf *pb = get_pixbuf (icon, YAD_BIG_ICON);
ent->pixbuf = scale_pixbuf (pb);
if (pb)
g_object_unref (pb);
}
g_free (icon);
}
}
......
......@@ -111,8 +111,9 @@ set_icon (void)
if (g_file_test (icon, G_FILE_TEST_EXISTS))
{
pixbuf = gdk_pixbuf_new_from_file_at_scale (icon, options.notification_data.icon_size,
options.notification_data.icon_size, TRUE, &err);
gint isize = (options.common_data.icon_size > 0) ? options.common_data.icon_size : 16;
pixbuf = gdk_pixbuf_new_from_file_at_scale (icon, isize, isize, TRUE, &err);
if (err)
{
g_printerr (_("Could not load notification icon '%s': %s\n"), icon, err->message);
......
......@@ -380,6 +380,8 @@ static GOptionEntry icons_options[] = {
N_("Use GenericName field instead of Name for icon label"), NULL },
{ "item-width", 0, 0, G_OPTION_ARG_INT, &options.icons_data.width,
N_("Set the width of dialog items"), NULL },
{ "icon-size", 0, G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_INT, &options.common_data.icon_size,
N_("Force using specified icon size"), N_("SIZE") },
{ "term", 0, 0, G_OPTION_ARG_STRING, &options.icons_data.term,
/* xgettext: no-c-format */
N_("Use specified pattern for launch command in terminal (default: xterm -e %s)"), N_("PATTERN") },
......@@ -502,7 +504,7 @@ static GOptionEntry notification_options[] = {
N_("Disable exit on middle click"), NULL },
{ "hidden", 0, 0, G_OPTION_ARG_NONE, &options.notification_data.hidden,
N_("Doesn't show icon at startup"), NULL },
{ "icon-size", 0, 0, G_OPTION_ARG_INT, &options.notification_data.icon_size,
{ "icon-size", 0, G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_INT, &options.common_data.icon_size,
N_("Set icon size for fully specified icons (default - 16)"), N_("SIZE") },
{ NULL }
};
......@@ -1503,6 +1505,7 @@ yad_options_init (void)
options.common_data.key = -1;
options.common_data.bool_fmt = YAD_BOOL_FMT_UT;
options.common_data.complete = YAD_COMPLETE_SIMPLE;
options.common_data.icon_size = 0;
#if GLIB_CHECK_VERSION(2,30,0)
options.common_data.size_fmt = G_FORMAT_SIZE_DEFAULT;
#endif
......
......@@ -466,6 +466,7 @@ typedef struct {
gboolean show_hidden;
gboolean quoted_output;
gboolean num_output;
gint icon_size;
#if GLIB_CHECK_VERSION(2,30,0)
GFormatSizeFlags size_fmt;
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment