Commit 6b2d263d authored by Victor Ananjevsky's avatar Victor Ananjevsky

add icon field type to form dialog

parent 8d5a53ed
......@@ -537,6 +537,8 @@ Add field to form. Type may be \fIH\fP, \fIRO\fP, \fINUM\fP, \fICHK\fP, \fICB\fP
.br
\fBAPP\fP - application selection button. Input value for this field is mime-type. Output value - executable for selected application.
.br
\fBICON\fP - icon field. Like average entry field but has two icons. Left shows current icon and right is clickable and calls \fIyad-con-browser\fP for choosing icon.
.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.
......@@ -1330,4 +1332,4 @@ AM_PATH_YAD([MINIMUM-VERSION],\\
\fBYad\fP was written by Victor Ananjevsky <ananasik@gmail.com>. Yad icon created by Bogdan Lisovich.
.SH SEE ALSO
\fBgdialog\fP(1), \fBdialog\fP(1), \fBzenity\fP(1)
\fBgdialog\fP(1), \fBdialog\fP(1), \fBzenity\fP(1), \fByad-tools\fP(1)
......@@ -71,6 +71,7 @@ expand_action (gchar * cmd)
case YAD_FIELD_MFILE:
case YAD_FIELD_MDIR:
case YAD_FIELD_DATE:
case YAD_FIELD_ICON:
buf = escape_char ((gchar *) gtk_entry_get_text (GTK_ENTRY (g_slist_nth_data (fields, num))), '"');
arg = g_shell_quote (buf ? buf : "");
g_free (buf);
......@@ -195,6 +196,7 @@ set_field_value (guint num, gchar *value)
case YAD_FIELD_FILE_SAVE:
case YAD_FIELD_DIR_CREATE:
case YAD_FIELD_DATE:
case YAD_FIELD_ICON:
gtk_entry_set_text (GTK_ENTRY (w), value);
break;
......@@ -641,6 +643,44 @@ link_clicked_cb (GtkLinkButton *btn, gpointer data)
return TRUE;
}
static void
select_icon_cb (GtkEntry *e, GtkEntryIconPosition pos, GdkEventButton *ev, gpointer d)
{
gchar *ib;
if (ev->button !=1 || pos != GTK_ENTRY_ICON_SECONDARY)
return;
ib = g_find_program_in_path ("yad-icon-browser");
if (ib)
{
gint exit;
gchar *cmd;
gchar *out = NULL;
cmd = g_strdup_printf ("%s -i", ib);
g_free (ib);
exit = run_command_sync (cmd, &out);
g_free (cmd);
if (exit == 0)
{
strip_new_line (out);
gtk_entry_set_text (e, out);
g_free (out);
}
}
}
static void
set_icon_cb (GtkEntry *e, gpointer d)
{
const gchar *icon = gtk_entry_get_text (e);
if (icon && *icon)
gtk_entry_set_icon_from_icon_name (e, GTK_ENTRY_ICON_PRIMARY, icon);
}
static gboolean
handle_stdin (GIOChannel * ch, GIOCondition cond, gpointer data)
{
......@@ -799,6 +839,7 @@ form_create_widget (GtkWidget * dlg)
case YAD_FIELD_HIDDEN:
case YAD_FIELD_READ_ONLY:
case YAD_FIELD_COMPLETE:
case YAD_FIELD_ICON:
e = gtk_entry_new ();
gtk_widget_set_name (e, "yad-form-entry");
if (fld->tip)
......@@ -831,6 +872,13 @@ form_create_widget (GtkWidget * dlg)
g_object_unref (m);
g_object_unref (c);
}
else if (fld->type == YAD_FIELD_ICON)
{
gtk_entry_set_icon_from_icon_name (GTK_ENTRY (e), GTK_ENTRY_ICON_PRIMARY, "image-missing");
gtk_entry_set_icon_from_icon_name (GTK_ENTRY (e), GTK_ENTRY_ICON_SECONDARY, "insert-image");
g_signal_connect (G_OBJECT (e), "changed", G_CALLBACK (set_icon_cb), NULL);
g_signal_connect (G_OBJECT (e), "icon-press", G_CALLBACK (select_icon_cb), NULL);
}
gtk_label_set_mnemonic_widget (GTK_LABEL (l), e);
fields = g_slist_append (fields, e);
......@@ -1267,6 +1315,7 @@ form_print_field (guint fn)
case YAD_FIELD_FILE_SAVE:
case YAD_FIELD_DIR_CREATE:
case YAD_FIELD_DATE:
case YAD_FIELD_ICON:
if (options.common_data.quoted_output)
{
buf = g_shell_quote (gtk_entry_get_text (GTK_ENTRY (g_slist_nth_data (fields, fn))));
......
......@@ -851,6 +851,8 @@ add_field (const gchar * option_name, const gchar * value, gpointer data, GError
fld->type = YAD_FIELD_FONT;
else if (strcasecmp (fstr[1], "APP") == 0)
fld->type = YAD_FIELD_APP;
else if (strcasecmp (fstr[1], "ICON") == 0)
fld->type = YAD_FIELD_ICON;
else if (strcasecmp (fstr[1], "CLR") == 0)
fld->type = YAD_FIELD_COLOR;
else if (strcasecmp (fstr[1], "MFL") == 0)
......
......@@ -120,6 +120,7 @@ typedef enum {
YAD_FIELD_MDIR,
YAD_FIELD_FONT,
YAD_FIELD_APP,
YAD_FIELD_ICON,
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