Commit 1e2379aa authored by Victor Ananjevsky's avatar Victor Ananjevsky

add mime option to icon mode in yad-tools

parent e14b20dd
...@@ -45,5 +45,8 @@ Use specified icon size. Default is 24. ...@@ -45,5 +45,8 @@ Use specified icon size. Default is 24.
\fB\-t\fR, \fB\-\-type\fR=\fITYPE\fP \fB\-t\fR, \fB\-\-type\fR=\fITYPE\fP
Obtain icon size from one of predefined GTK+ types. \fITYPE\fP is one of the following \fImenu\fP, \fIbutton\fP, \fIsmall_toolbar\fP, \fIlarge_toolbar\fP, \fIdnd\fP or \fIdialog\fP, Obtain icon size from one of predefined GTK+ types. \fITYPE\fP is one of the following \fImenu\fP, \fIbutton\fP, \fIsmall_toolbar\fP, \fIlarge_toolbar\fP, \fIdnd\fP or \fIdialog\fP,
.TP .TP
\fB\-m\fR, \fB\-\-mime\fP
Get generic icon name for specified mime type.
.TP
\fB\-\-theme\fR=\fITHEME\fP \fB\-\-theme\fR=\fITHEME\fP
Use specified icon theme instead of default. Use specified icon theme instead of default.
...@@ -7,7 +7,7 @@ msgid "" ...@@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: YAD\n" "Project-Id-Version: YAD\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-04-11 15:46+0300\n" "POT-Creation-Date: 2022-04-12 08:06+0300\n"
"PO-Revision-Date: 2021-11-28 19:00+0200\n" "PO-Revision-Date: 2021-11-28 19:00+0200\n"
"Last-Translator: Victor Ananjevsky <ananasik@gmail.com>\n" "Last-Translator: Victor Ananjevsky <ananasik@gmail.com>\n"
"Language-Team: \n" "Language-Team: \n"
...@@ -329,7 +329,7 @@ msgstr "Задати вирівнювання тексту діалогу (left, ...@@ -329,7 +329,7 @@ msgstr "Задати вирівнювання тексту діалогу (left,
#: ../src/option.c:462 ../src/option.c:472 ../src/option.c:518 #: ../src/option.c:462 ../src/option.c:472 ../src/option.c:518
#: ../src/option.c:550 ../src/option.c:562 ../src/option.c:572 #: ../src/option.c:550 ../src/option.c:562 ../src/option.c:572
#: ../src/option.c:586 ../src/option.c:647 ../src/option.c:698 #: ../src/option.c:586 ../src/option.c:647 ../src/option.c:698
#: ../src/option.c:725 ../src/option.c:727 ../src/tools.c:80 #: ../src/option.c:725 ../src/option.c:727 ../src/tools.c:82
msgid "TYPE" msgid "TYPE"
msgstr "ТИП" msgstr "ТИП"
...@@ -346,7 +346,7 @@ msgid "Use specified icon theme instead of default" ...@@ -346,7 +346,7 @@ msgid "Use specified icon theme instead of default"
msgstr "Використовувати вказану тему піктограм замість стандартної" msgstr "Використовувати вказану тему піктограм замість стандартної"
#: ../src/option.c:119 ../src/option.c:676 ../src/browser.c:217 #: ../src/option.c:119 ../src/option.c:676 ../src/browser.c:217
#: ../src/tools.c:81 #: ../src/tools.c:83
msgid "THEME" msgid "THEME"
msgstr "ТЕМА" msgstr "ТЕМА"
...@@ -968,7 +968,7 @@ msgid "Force using specified icon size" ...@@ -968,7 +968,7 @@ msgid "Force using specified icon size"
msgstr "Примусово використовувати визначений розмір піктограми" msgstr "Примусово використовувати визначений розмір піктограми"
#: ../src/option.c:431 ../src/option.c:541 ../src/option.c:649 #: ../src/option.c:431 ../src/option.c:541 ../src/option.c:649
#: ../src/tools.c:79 #: ../src/tools.c:81
msgid "SIZE" msgid "SIZE"
msgstr "РОЗМІР" msgstr "РОЗМІР"
...@@ -1490,7 +1490,7 @@ msgstr "Додати фільтр для зображень" ...@@ -1490,7 +1490,7 @@ msgstr "Додати фільтр для зображень"
msgid "[NAME]" msgid "[NAME]"
msgstr "[ІМ'Я]" msgstr "[ІМ'Я]"
#: ../src/option.c:719 ../src/tools.c:59 #: ../src/option.c:719 ../src/tools.c:60
msgid "Print version" msgid "Print version"
msgstr "Вивести версію" msgstr "Вивести версію"
...@@ -2085,87 +2085,91 @@ msgstr "Категорія" ...@@ -2085,87 +2085,91 @@ msgstr "Категорія"
msgid "Icons" msgid "Icons"
msgstr "Піктограми" msgstr "Піктограми"
#: ../src/tools.c:61 #: ../src/tools.c:62
msgid "Show list of spell languages" msgid "Show list of spell languages"
msgstr "Відобразити перелік мов для перевірки правопису" msgstr "Відобразити перелік мов для перевірки правопису"
#: ../src/tools.c:64 #: ../src/tools.c:65
msgid "Show list of GtkSourceView themes" msgid "Show list of GtkSourceView themes"
msgstr "Відобразити перелік тем для GtkSourceView" msgstr "Відобразити перелік тем для GtkSourceView"
#: ../src/tools.c:66 #: ../src/tools.c:67
msgid "STRING ..." msgid "STRING ..."
msgstr "РЯДОК ..." msgstr "РЯДОК ..."
#: ../src/tools.c:71 #: ../src/tools.c:72
msgid "Pango fonts description tools" msgid "Pango fonts description tools"
msgstr "Конвертація опису шрифта" msgstr "Конвертація опису шрифта"
#: ../src/tools.c:72 #: ../src/tools.c:73
msgid "Print font name in xft format" msgid "Print font name in xft format"
msgstr "Вивести назву шрифта у форматі xft" msgstr "Вивести назву шрифта у форматі xft"
#: ../src/tools.c:73 #: ../src/tools.c:74
msgid "Print font name in pango format" msgid "Print font name in pango format"
msgstr "Вивести назву шрифта у форматі pango" msgstr "Вивести назву шрифта у форматі pango"
#: ../src/tools.c:78 #: ../src/tools.c:79
msgid "Icon tools" msgid "Icon tools"
msgstr "Інструменти піктограм" msgstr "Інструменти піктограм"
#: ../src/tools.c:79 #: ../src/tools.c:80
msgid "Get icon name for mime type"
msgstr "Отримати ім'я піктограми для даного типу mime"
#: ../src/tools.c:81
msgid "Use specified icon size" msgid "Use specified icon size"
msgstr "Використовувати визначений розмір піктограми" msgstr "Використовувати визначений розмір піктограми"
#: ../src/tools.c:80 #: ../src/tools.c:82
msgid "Get icon size from GtkIconSize type" msgid "Get icon size from GtkIconSize type"
msgstr "Отримати розмір піктограми з типу GtkIconSize" msgstr "Отримати розмір піктограми з типу GtkIconSize"
#: ../src/tools.c:81 #: ../src/tools.c:83
msgid "Use icon theme" msgid "Use icon theme"
msgstr "Використовувати вказану тему піктограм" msgstr "Використовувати вказану тему піктограм"
#: ../src/tools.c:160 #: ../src/tools.c:162
#, c-format #, c-format
msgid "no font specified\n" msgid "no font specified\n"
msgstr "шрифт не вказано\n" msgstr "шрифт не вказано\n"
#: ../src/tools.c:168 #: ../src/tools.c:170
#, c-format #, c-format
msgid "cannot get font description for for string \"%s\"\n" msgid "cannot get font description for for string \"%s\"\n"
msgstr "неможливо отримати опис шрифта із рядка \"%s\"\n" msgstr "неможливо отримати опис шрифта із рядка \"%s\"\n"
#: ../src/tools.c:270 #: ../src/tools.c:272
#, c-format #, c-format
msgid "no icon specified\n" msgid "no icon specified\n"
msgstr "піктограму не визначено\n" msgstr "піктограму не визначено\n"
#: ../src/tools.c:352 #: ../src/tools.c:362
msgid "- yad miscellaneous tools" msgid "- yad miscellaneous tools"
msgstr "- додаткові інструменти yad" msgstr "- додаткові інструменти yad"
#: ../src/tools.c:355 #: ../src/tools.c:365
msgid "PFD mode" msgid "PFD mode"
msgstr "Режим PFD" msgstr "Режим PFD"
#: ../src/tools.c:355 #: ../src/tools.c:365
msgid "Show pfd mode options" msgid "Show pfd mode options"
msgstr "Показувати параметри режиму pfd" msgstr "Показувати параметри режиму pfd"
#: ../src/tools.c:360 #: ../src/tools.c:370
msgid "Icon mode" msgid "Icon mode"
msgstr "Перегляд піктограм" msgstr "Перегляд піктограм"
#: ../src/tools.c:360 #: ../src/tools.c:370
msgid "Show icon mode options" msgid "Show icon mode options"
msgstr "Показувати параметри для Перегляду піктограм" msgstr "Показувати параметри для Перегляду піктограм"
#: ../src/tools.c:367 #: ../src/tools.c:377
#, c-format #, c-format
msgid "option parsing failed: %s\n" msgid "option parsing failed: %s\n"
msgstr "збій при розборі аргументів: %s\n" msgstr "збій при розборі аргументів: %s\n"
#: ../src/tools.c:391 #: ../src/tools.c:401
#, c-format #, c-format
msgid "no mode specified\n" msgid "no mode specified\n"
msgstr "режим не вказано\n" msgstr "режим не вказано\n"
......
...@@ -42,6 +42,7 @@ static FontType font_type = XFT_SPEC; ...@@ -42,6 +42,7 @@ static FontType font_type = XFT_SPEC;
static gboolean pfd_mode = FALSE; static gboolean pfd_mode = FALSE;
static gboolean icon_mode = FALSE; static gboolean icon_mode = FALSE;
static gboolean mime = FALSE;
static gboolean ver = FALSE; static gboolean ver = FALSE;
#ifdef HAVE_SPELL #ifdef HAVE_SPELL
static gboolean langs_mode = FALSE; static gboolean langs_mode = FALSE;
...@@ -76,6 +77,7 @@ static GOptionEntry pfd_ents[] = { ...@@ -76,6 +77,7 @@ static GOptionEntry pfd_ents[] = {
static GOptionEntry icon_ents[] = { static GOptionEntry icon_ents[] = {
{ "icon", 'i', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &icon_mode, N_("Icon tools"), NULL }, { "icon", 'i', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &icon_mode, N_("Icon tools"), NULL },
{ "mime", 'm', 0, G_OPTION_ARG_NONE, &mime, N_("Get icon name for mime type"), NULL },
{ "size", 's', 0, G_OPTION_ARG_INT, &icon_size, N_("Use specified icon size"), N_("SIZE") }, { "size", 's', 0, G_OPTION_ARG_INT, &icon_size, N_("Use specified icon size"), N_("SIZE") },
{ "type", 't', 0, G_OPTION_ARG_CALLBACK, set_size_type, N_("Get icon size from GtkIconSize type"), N_("TYPE") }, { "type", 't', 0, G_OPTION_ARG_CALLBACK, set_size_type, N_("Get icon size from GtkIconSize type"), N_("TYPE") },
{ "theme", 0, 0, G_OPTION_ARG_STRING, &icon_theme_name, N_("Use icon theme"), N_("THEME") }, { "theme", 0, 0, G_OPTION_ARG_STRING, &icon_theme_name, N_("Use icon theme"), N_("THEME") },
...@@ -263,7 +265,7 @@ run_icon_mode () ...@@ -263,7 +265,7 @@ run_icon_mode ()
{ {
GtkIconTheme *theme; GtkIconTheme *theme;
GtkIconInfo *ii; GtkIconInfo *ii;
const gchar *filename; gchar *output = NULL;
if (!args || !args[0]) if (!args || !args[0])
{ {
...@@ -279,13 +281,21 @@ run_icon_mode () ...@@ -279,13 +281,21 @@ run_icon_mode ()
else else
theme = gtk_icon_theme_get_default (); theme = gtk_icon_theme_get_default ();
ii = gtk_icon_theme_lookup_icon (theme, args[0], icon_size, 0); if (mime)
if (ii == NULL) {
return 1; gchar *ctype = g_content_type_from_mime_type (args[0]);
output = g_content_type_get_generic_icon_name (ctype);
filename = gtk_icon_info_get_filename (ii); }
if (filename) else
g_print ("%s\n", filename); {
ii = gtk_icon_theme_lookup_icon (theme, args[0], icon_size, 0);
if (ii == NULL)
return 1;
output = (gchar *) gtk_icon_info_get_filename (ii);
}
if (output)
g_print ("%s\n", output);
else else
return 1; return 1;
......
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