Commit 5a34fae4 authored by Victor Ananjevsky's avatar Victor Ananjevsky

add app field type to form dialog

parent 32e5ff4a
......@@ -452,7 +452,7 @@ Output data will be in shell-style quotes.
.SS Form options
.TP
.B \-\-field=\fILABEL[:TYPE]\fP
Add field to form. Type may be \fIH\fP, \fIRO\fP, \fINUM\fP, \fICHK\fP, \fICB\fP, \fICBE\fP, \fICE\fP, \fIFL\fP, \fISFL\fP, \fIDIR\fP, \fICDIR\fP, \fIFN\fP, \fIMFL\fP, \fIMDIR\fP, \fIDT\fP, \fISCL\fP, \fICLR\fP, \fIBTN\fP, \fIFBTN\fP, \fILBL\fP or \fITXT\fP.
Add field to form. Type may be \fIH\fP, \fIRO\fP, \fINUM\fP, \fICHK\fP, \fICB\fP, \fICBE\fP, \fICE\fP, \fIFL\fP, \fISFL\fP, \fIDIR\fP, \fICDIR\fP, \fIFN\fP, \fIMFL\fP, \fIMDIR\fP, \fIDT\fP, \fISCL\fP, \fIAPP\fP, \fICLR\fP, \fIBTN\fP, \fIFBTN\fP, \fILBL\fP or \fITXT\fP.
.br
\fBH\fP - hidden field type. All characters are displayed as the invisible char.
.br
......@@ -486,6 +486,8 @@ Add field to form. Type may be \fIH\fP, \fIRO\fP, \fINUM\fP, \fICHK\fP, \fICB\fP
.br
\fBSCL\fP - scale field. Value of this field in a range 0..100.
.br
\fBAPP\fP - application selection button. Input value for this field is mime-type. Output value - executable for selected application.
.br
\fBCLR\fP - color selection button. Output values for this field generates in the same manner as for color dialog.
.br
\fBBTN\fP - button field. Label may be in form text in a form \fILABEL[!ICON[!TOOLTIP]]\fP where `!' is an item separator. \fILABEL\fP is a text of button label or yad stock id. \fIICON\fP is a buttons icon (stock id or file name). \fITOOLTIP\fP is an optional text for popup help string. Initial value is a command which is running when button is clicked. A special sympols \fI%N\fP in command are replaced by value of field \fIN\fP. If command starts with \fI@\fP, the output of command will be parsed and lines started with number and colon will be treats as a new field values.
......@@ -1122,6 +1124,7 @@ yad-form-combo@GtkComboBox@Combo field in form
yad-form-edit-combo@GtkComboBoxEntry@Editable combo field in form
yad-form-file@GtkFileChooserButton@File or directory field in form
yad-form-font@GtkFontChooserButton@Font field in form
yad-form-app@GtkAppChooserButton@Application field in form
yad-form-color@GtkColorChooserButton@Color field in form
yad-form-label@GtkLabel@Label field in form
yad-form-scale@GtkScale@Scale widget in form
......
......@@ -19,7 +19,6 @@
#include <ctype.h>
#include <stdlib.h>
#include <glib/gprintf.h>
#include "yad.h"
......@@ -101,6 +100,14 @@ expand_action (gchar * cmd)
case YAD_FIELD_FONT:
arg = g_shell_quote (gtk_font_chooser_get_font (GTK_FONT_CHOOSER (g_slist_nth_data (fields, num))));
break;
case YAD_FIELD_APP:
{
GList *wl = gtk_container_get_children (GTK_CONTAINER (g_slist_nth_data (fields, num)));
GAppInfo *info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (wl->data));
arg = g_shell_quote (g_app_info_get_executable (info));
g_object_unref (info);
break;
}
case YAD_FIELD_COLOR:
{
GdkRGBA c;
......@@ -306,6 +313,30 @@ set_field_value (guint num, gchar * value)
gtk_range_set_value (GTK_RANGE (w), atoi (value));
break;
case YAD_FIELD_APP:
{
GtkWidget *b;
GList *wl;
for (wl = gtk_container_get_children (GTK_CONTAINER (w)); wl; wl = wl->next)
{
GtkWidget *cw = GTK_WIDGET (wl->data);
gtk_container_remove (GTK_CONTAINER (w), cw);
gtk_widget_destroy (cw);
}
printf ("set value %s for app field\n");
if (value && value[0])
b = gtk_app_chooser_button_new (value);
else
b = gtk_app_chooser_button_new ("text/plain");
gtk_widget_set_name (b, "yad-form-app");
gtk_box_pack_start (GTK_BOX (w), b, TRUE, TRUE, 0);
gtk_widget_show_all (w);
break;
}
case YAD_FIELD_COLOR:
{
GdkRGBA c;
......@@ -849,6 +880,14 @@ form_create_widget (GtkWidget * dlg)
fields = g_slist_append (fields, e);
break;
case YAD_FIELD_APP:
e = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_grid_attach (GTK_GRID (tbl), e, 1 + col * 2, row, 1, 1);
gtk_widget_set_hexpand (e, TRUE);
gtk_label_set_mnemonic_widget (GTK_LABEL (l), e);
fields = g_slist_append (fields, e);
break;
case YAD_FIELD_COLOR:
e = gtk_color_button_new ();
gtk_widget_set_name (e, "yad-form-color");
......@@ -1112,6 +1151,35 @@ form_print_field (guint fn)
g_free (fname);
break;
}
case YAD_FIELD_APP:
{
gchar *exec;
GAppInfo *info = NULL;
GList *wl = gtk_container_get_children (GTK_CONTAINER (g_slist_nth_data (fields, fn)));
if (wl)
{
info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (wl->data));
if (info)
exec = (gchar *) g_app_info_get_executable (info);
else
exec = "";
}
else
exec = "";
if (options.common_data.quoted_output)
{
buf = g_shell_quote (exec);
g_printf ("%s%s", buf, options.common_data.separator);
g_free (buf);
}
else
g_printf ("%s%s", exec, options.common_data.separator);
if (info)
g_object_unref (info);
break;
}
case YAD_FIELD_COLOR:
{
gchar *cs;
......
......@@ -802,6 +802,8 @@ add_field (const gchar * option_name, const gchar * value, gpointer data, GError
fld->type = YAD_FIELD_DIR_CREATE;
else if (strcasecmp (fstr[1], "FN") == 0)
fld->type = YAD_FIELD_FONT;
else if (strcasecmp (fstr[1], "APP") == 0)
fld->type = YAD_FIELD_APP;
else if (strcasecmp (fstr[1], "CLR") == 0)
fld->type = YAD_FIELD_COLOR;
else if (strcasecmp (fstr[1], "MFL") == 0)
......
......@@ -104,6 +104,7 @@ typedef enum {
YAD_FIELD_DIR_CREATE,
YAD_FIELD_MDIR,
YAD_FIELD_FONT,
YAD_FIELD_APP,
YAD_FIELD_COLOR,
YAD_FIELD_DATE,
YAD_FIELD_SCALE,
......
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