Commit 2707dfe0 authored by Victor Ananjevsky's avatar Victor Ananjevsky

initially add link type field in form dialog

parent 96c38db4
...@@ -498,6 +498,8 @@ A quoting style for value when \fIsh -c\fP is used \- a single quotes around com ...@@ -498,6 +498,8 @@ A quoting style for value when \fIsh -c\fP is used \- a single quotes around com
.br .br
\fBFBTN\fP - same as button field, but with full relief of a button. \fBFBTN\fP - same as button field, but with full relief of a button.
.br .br
\fBLINK\fP - link button field.
.br
\fBLBL\fP - text label. If field name is empty, horizontal separator line will be shown. \fBLBL\fP - text label. If field name is empty, horizontal separator line will be shown.
.br .br
\fBTXT\fP - multiline text entry. This field is always occupy all of form width. \fBTXT\fP - multiline text entry. This field is always occupy all of form width.
......
...@@ -100,6 +100,9 @@ expand_action (gchar * cmd) ...@@ -100,6 +100,9 @@ expand_action (gchar * cmd)
case YAD_FIELD_FONT: case YAD_FIELD_FONT:
arg = g_shell_quote (gtk_font_chooser_get_font (GTK_FONT_CHOOSER (g_slist_nth_data (fields, num)))); arg = g_shell_quote (gtk_font_chooser_get_font (GTK_FONT_CHOOSER (g_slist_nth_data (fields, num))));
break; break;
case YAD_FIELD_LINK:
arg = g_shell_quote (gtk_link_button_get_uri (GTK_LINK_BUTTON (g_slist_nth_data (fields, num))));
break;
case YAD_FIELD_APP: case YAD_FIELD_APP:
{ {
GList *wl = gtk_container_get_children (GTK_CONTAINER (g_slist_nth_data (fields, num))); GList *wl = gtk_container_get_children (GTK_CONTAINER (g_slist_nth_data (fields, num)));
...@@ -348,6 +351,10 @@ set_field_value (guint num, gchar * value) ...@@ -348,6 +351,10 @@ set_field_value (guint num, gchar * value)
g_object_set_data_full (G_OBJECT (w), "cmd", g_strdup (value), g_free); g_object_set_data_full (G_OBJECT (w), "cmd", g_strdup (value), g_free);
break; break;
case YAD_FIELD_LINK:
gtk_link_button_set_uri (GTK_LINK_BUTTON (w), value);
break;
case YAD_FIELD_TEXT: case YAD_FIELD_TEXT:
{ {
GtkTextBuffer *tb = gtk_text_view_get_buffer (GTK_TEXT_VIEW (w)); GtkTextBuffer *tb = gtk_text_view_get_buffer (GTK_TEXT_VIEW (w));
...@@ -745,7 +752,8 @@ form_create_widget (GtkWidget * dlg) ...@@ -745,7 +752,8 @@ form_create_widget (GtkWidget * dlg)
/* add field label */ /* add field label */
l = NULL; l = NULL;
if (fld->type != YAD_FIELD_CHECK && fld->type != YAD_FIELD_BUTTON && if (fld->type != YAD_FIELD_CHECK && fld->type != YAD_FIELD_BUTTON &&
fld->type != YAD_FIELD_FULL_BUTTON && fld->type != YAD_FIELD_LABEL && fld->type != YAD_FIELD_TEXT) fld->type != YAD_FIELD_FULL_BUTTON && fld->type != YAD_FIELD_LINK &&
fld->type != YAD_FIELD_LABEL && fld->type != YAD_FIELD_TEXT)
{ {
gchar *buf = g_strcompress (fld->name); gchar *buf = g_strcompress (fld->name);
l = gtk_label_new (NULL); l = gtk_label_new (NULL);
...@@ -958,6 +966,16 @@ form_create_widget (GtkWidget * dlg) ...@@ -958,6 +966,16 @@ form_create_widget (GtkWidget * dlg)
fields = g_slist_append (fields, e); fields = g_slist_append (fields, e);
break; break;
case YAD_FIELD_LINK:
{
gchar *buf = g_strcompress (fld->name);
e = gtk_link_button_new_with_label ("", buf);
gtk_widget_set_name (e, "yad-form-link");
gtk_grid_attach (GTK_GRID (tbl), e, col * 2, row, 2, 1);
gtk_widget_set_hexpand (e, TRUE);
fields = g_slist_append (fields, e);
}
case YAD_FIELD_LABEL: case YAD_FIELD_LABEL:
if (fld->name[0]) if (fld->name[0])
{ {
...@@ -1205,6 +1223,17 @@ form_print_field (guint fn) ...@@ -1205,6 +1223,17 @@ form_print_field (guint fn)
g_printf ("%d%s", (gint) gtk_range_get_value (GTK_RANGE (g_slist_nth_data (fields, fn))), g_printf ("%d%s", (gint) gtk_range_get_value (GTK_RANGE (g_slist_nth_data (fields, fn))),
options.common_data.separator); options.common_data.separator);
break; break;
case YAD_FIELD_LINK:
if (options.common_data.quoted_output)
{
buf = g_shell_quote (gtk_link_button_get_uri (GTK_LINK_BUTTON (g_slist_nth_data (fields, fn))));
g_printf ("%s%s", buf, options.common_data.separator);
g_free (buf);
}
else
g_printf ("%s%s", gtk_link_button_get_uri (GTK_LINK_BUTTON (g_slist_nth_data (fields, fn))),
options.common_data.separator);
break;
case YAD_FIELD_BUTTON: case YAD_FIELD_BUTTON:
case YAD_FIELD_FULL_BUTTON: case YAD_FIELD_FULL_BUTTON:
case YAD_FIELD_LABEL: case YAD_FIELD_LABEL:
......
...@@ -807,6 +807,8 @@ add_field (const gchar * option_name, const gchar * value, gpointer data, GError ...@@ -807,6 +807,8 @@ add_field (const gchar * option_name, const gchar * value, gpointer data, GError
fld->type = YAD_FIELD_BUTTON; fld->type = YAD_FIELD_BUTTON;
else if (strcasecmp (fstr[1], "FBTN") == 0) else if (strcasecmp (fstr[1], "FBTN") == 0)
fld->type = YAD_FIELD_FULL_BUTTON; fld->type = YAD_FIELD_FULL_BUTTON;
else if (strcasecmp (fstr[1], "LINK") == 0)
fld->type = YAD_FIELD_LINK;
else if (strcasecmp (fstr[1], "LBL") == 0) else if (strcasecmp (fstr[1], "LBL") == 0)
fld->type = YAD_FIELD_LABEL; fld->type = YAD_FIELD_LABEL;
else if (strcasecmp (fstr[1], "TXT") == 0) else if (strcasecmp (fstr[1], "TXT") == 0)
......
...@@ -117,6 +117,7 @@ typedef enum { ...@@ -117,6 +117,7 @@ typedef enum {
YAD_FIELD_SCALE, YAD_FIELD_SCALE,
YAD_FIELD_BUTTON, YAD_FIELD_BUTTON,
YAD_FIELD_FULL_BUTTON, YAD_FIELD_FULL_BUTTON,
YAD_FIELD_LINK,
YAD_FIELD_LABEL, YAD_FIELD_LABEL,
YAD_FIELD_TEXT YAD_FIELD_TEXT
} YadFieldType; } YadFieldType;
......
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