248
252
else if (value != custom_value && GTK_IS_ENTRY (child))
254
g_signal_handlers_block_by_func (
255
button, proxy_combo_box_changed_cb, object);
250
256
/* Force the combo to change the item again */
251
257
gtk_widget_destroy (child);
252
258
gtk_combo_box_set_active (button, value + 1);
253
259
gtk_combo_box_set_active (button, value);
260
g_signal_handlers_unblock_by_func (
261
button, proxy_combo_box_changed_cb, object);
466
474
* "custom-PROPERTY": the last value of an enumeration will be the "custom"
467
475
* value, where the user may enter text freely, which then updates
468
476
* the property PROPERTY instead. This applies only to enumerations.
477
* Since 0.2.9 the following hints are also supported:
478
* "languages": the widget will be particularly suitable for choosing
479
* multiple language codes, ie. "de,en_GB".
470
481
* Any other values for @hint are silently ignored.
504
515
type = G_PARAM_SPEC_TYPE (pspec);
505
516
nick = g_param_spec_get_nick (pspec);
506
517
_hint = g_intern_string (hint);
507
if (_hint == g_intern_string ("blurb"))
518
if (_hint == I_("blurb"))
508
519
nick = g_param_spec_get_blurb (pspec);
510
521
if (type == G_TYPE_PARAM_BOOLEAN)
513
524
gboolean toggled = katze_object_get_boolean (object, property);
515
526
#ifdef HAVE_HILDON_2_2
516
if (_hint != g_intern_string ("toggle"))
527
if (_hint != I_("toggle"))
518
529
widget = hildon_check_button_new (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH);
519
530
gtk_button_set_label (GTK_BUTTON (widget), gettext (nick));
525
536
widget = gtk_check_button_new ();
526
if (_hint == g_intern_string ("toggle"))
537
if (_hint == I_("toggle"))
527
538
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (widget), FALSE);
529
540
gtk_button_set_label (GTK_BUTTON (widget), gettext (nick));
538
549
G_CALLBACK (proxy_widget_boolean_destroy_cb), object);
539
550
g_free (notify_property);
541
else if (type == G_TYPE_PARAM_STRING && _hint == g_intern_string ("file"))
552
else if (type == G_TYPE_PARAM_STRING && _hint == I_("file"))
543
554
string = katze_object_get_string (object, property);
553
564
g_signal_connect (widget, "selection-changed",
554
565
G_CALLBACK (proxy_file_file_set_cb), object);
556
else if (type == G_TYPE_PARAM_STRING && _hint == g_intern_string ("folder"))
567
else if (type == G_TYPE_PARAM_STRING && _hint == I_("folder"))
558
569
string = katze_object_get_string (object, property);
567
578
g_signal_connect (widget, "selection-changed",
568
579
G_CALLBACK (proxy_folder_file_set_cb), object);
570
else if (type == G_TYPE_PARAM_STRING && _hint == g_intern_string ("uri"))
581
else if (type == G_TYPE_PARAM_STRING && _hint == I_("uri"))
572
583
string = katze_object_get_string (object, property);
586
597
G_CALLBACK (proxy_uri_file_set_cb), object);
589
else if (type == G_TYPE_PARAM_STRING && (_hint == g_intern_string ("font")
590
|| _hint == g_intern_string ("font-monospace")))
600
else if (type == G_TYPE_PARAM_STRING && (_hint == I_("font")
601
|| _hint == I_("font-monospace")))
592
603
GtkComboBox* combo;
593
604
gint n_families, i;
594
605
PangoContext* context;
595
606
PangoFontFamily** families;
596
gboolean monospace = _hint == g_intern_string ("font-monospace");
607
gboolean monospace = _hint == I_("font-monospace");
597
608
string = katze_object_get_string (object, property);
599
610
widget = gtk_combo_box_new_text ();
658
671
if (!g_strcmp0 (string, ""))
659
672
katze_assign (string, NULL);
674
gtk_list_store_insert_with_values (model, &iter_none, 0,
675
0, NULL, 1, NULL, 2, _("None"), 3, icon_width, -1);
663
GtkTreeIter iter_none;
667
gtk_list_store_insert_with_values (model, &iter_none, 0,
668
0, NULL, 1, NULL, 2, _("None"), 3, icon_width, -1);
670
681
while ((info = g_list_nth_data (apps, i++)))
686
697
g_free (icon_name);
689
703
info = g_app_info_create_from_commandline ("",
690
704
"", G_APP_INFO_CREATE_NONE, NULL);
691
705
gtk_list_store_insert_with_values (model, NULL, G_MAXINT,
720
734
gtk_combo_box_set_active_iter (combo, &iter_none);
724
737
g_signal_connect (widget, "changed",
725
738
G_CALLBACK (proxy_combo_box_apps_changed_cb), object);
732
745
g_object_get (object, property, &string, NULL);
734
747
string = g_strdup (G_PARAM_SPEC_STRING (pspec)->default_value);
748
if (!(string && *string) && _hint == I_("languages"))
750
gchar* lang = g_strjoinv (",", (gchar**)g_get_language_names ());
751
if (g_str_has_suffix (lang, ",C"))
753
string = g_strndup (lang, strlen (lang) - 2);
735
759
gtk_entry_set_text (GTK_ENTRY (widget), string ? string : "");
736
760
g_signal_connect (widget, "activate",
737
761
G_CALLBACK (proxy_entry_activate_cb), object);
1522
1546
g_free (checksum);
1523
1547
path = g_build_filename (g_get_user_cache_dir (), PACKAGE_NAME,
1524
1548
"icons", filename, NULL);
1525
1550
if ((icon = gdk_pixbuf_new_from_file_at_size (path, 16, 16, NULL)))
1534
1559
GTK_STOCK_FILE, GTK_ICON_SIZE_MENU, NULL);
1539
* @str: a non-NULL UTF-8 string
1541
* Computes a string without case and decomposited so
1542
* it can be used for comparison.
1544
* Return value: a normalized string
1549
katze_collfold (const gchar* str)
1551
GString* result = g_string_new (NULL);
1552
const gchar* p = str;
1556
gunichar ch = g_unichar_tolower (g_utf8_get_char (p));
1558
gunichar* sch = g_unicode_canonical_decomposition (ch, &len);
1561
g_string_append_unichar (result, sch[i++]);
1563
p = g_utf8_next_char (p);
1566
return g_string_free (result, FALSE);
1570
* katze_utf8_stristr:
1571
* @haystack: a non-NULL UTF-8 string
1572
* @needle: a normalized non-NULL UTF-8 string
1574
* Determines whether @needle is in @haystack, disregarding
1575
* differences in case.
1577
* Return value: %TRUE if @needle is found in @haystack
1582
katze_utf8_stristr (const gchar* haystack,
1583
const gchar* needle)
1585
#if 0 /* 0,000159 seconds */
1586
/* Too slow for use in completion */
1587
gchar* nhaystack = g_utf8_normalize (haystack, -1, G_NORMALIZE_DEFAULT);
1588
const gchar *p = nhaystack;
1589
gsize len = strlen (needle);
1594
for (i = 0; i < len; i++)
1595
if (g_unichar_tolower (g_utf8_get_char (p + i))
1596
!= g_unichar_tolower (g_utf8_get_char (needle + i)))
1603
p = g_utf8_next_char (p);
1608
#else /* 0,000044 seconds */
1609
/* No unicode matching */
1610
const gchar *p = haystack;
1611
gsize len = strlen (needle);
1616
for (i = 0; i < len; i++)
1617
if (g_ascii_tolower (p[i]) != g_ascii_tolower (needle[i]))