477
477
* Since 0.2.9 the following hints are also supported:
478
478
* "languages": the widget will be particularly suitable for choosing
479
479
* multiple language codes, ie. "de,en_GB".
480
* Since 0.3.6 the following hints are also supported:
481
* "address": the widget will be particularly suitable for typing
482
* a valid URI or IP address and highlight errors.
481
484
* Any other values for @hint are silently ignored.
742
745
gchar* notify_property;
744
widget = gtk_entry_new ();
747
if (_hint == I_("address"))
748
widget = katze_uri_entry_new (NULL);
750
widget = gtk_entry_new ();
745
751
g_object_get (object, property, &string, NULL);
747
753
string = g_strdup (G_PARAM_SPEC_STRING (pspec)->default_value);
1559
1565
GTK_STOCK_FILE, GTK_ICON_SIZE_MENU, NULL);
1569
katze_uri_entry_changed_cb (GtkWidget* entry,
1570
GtkWidget* other_widget)
1572
const gchar* uri = gtk_entry_get_text (GTK_ENTRY (entry));
1573
gboolean valid = g_str_has_prefix (uri, "http://")
1574
|| g_str_has_prefix (uri, "https://")
1575
|| g_str_has_prefix (uri, "file://")
1576
|| g_str_has_prefix (uri, "data:")
1577
|| g_str_has_prefix (uri, "about:")
1578
|| g_str_has_prefix (uri, "javascript:");
1581
GdkColor bg_color = { 0 };
1582
GdkColor fg_color = { 0 };
1583
gdk_color_parse ("#ef7070", &bg_color);
1584
gdk_color_parse ("#000", &fg_color);
1585
gtk_widget_modify_base (entry, GTK_STATE_NORMAL, &bg_color);
1586
gtk_widget_modify_text (entry, GTK_STATE_NORMAL, &fg_color);
1590
gtk_widget_modify_base (entry, GTK_STATE_NORMAL, NULL);
1591
gtk_widget_modify_text (entry, GTK_STATE_NORMAL, NULL);
1594
if (other_widget != NULL)
1595
gtk_widget_set_sensitive (other_widget, *uri && valid);
1599
* katze_uri_entry_new:
1600
* @other_widget: a #GtkWidget, or %NULL
1602
* Creates an entry that validates the typed URI.
1604
* If @other_widget is given, it will become insensitive if
1605
* the input is not a valid URI.
1607
* Returns: a #GtkEntry
1612
katze_uri_entry_new (GtkWidget* other_widget)
1614
GtkWidget* entry = gtk_entry_new ();
1615
g_signal_connect (entry, "changed",
1616
G_CALLBACK (katze_uri_entry_changed_cb), other_widget);