232
rb_pixbuf_new_from_stock (const char *stock_id, GtkIconSize size)
238
dummy = gtk_image_new ();
240
pixbuf = gtk_widget_render_icon (dummy, stock_id, size, NULL);
242
if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_LTR)
245
mirror = gdk_pixbuf_copy (pixbuf);
246
gdk_pixbuf_unref (pixbuf);
251
totem_pixbuf_mirror (mirror);
274
rb_gtk_action_popup_menu (GtkUIManager *uimanager, const char *path)
278
menu = gtk_ui_manager_get_widget (uimanager, path);
279
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 3,
280
gtk_get_current_event_time ());
284
get_mount_points (void)
286
GnomeVFSVolumeMonitor *monitor;
289
GList *mount_points = NULL;
291
monitor = gnome_vfs_get_volume_monitor ();
292
/* FIXME: should also get the list of connected drivers (network
295
volumes = gnome_vfs_volume_monitor_get_mounted_volumes (monitor);
297
for (it = volumes; it != NULL; it = it->next) {
299
GnomeVFSVolume *volume;
301
volume = GNOME_VFS_VOLUME (it->data);
302
uri = gnome_vfs_volume_get_activation_uri (volume);
303
g_assert (uri != NULL);
304
mount_points = g_list_prepend (mount_points, uri);
307
g_list_foreach (volumes, (GFunc)gnome_vfs_volume_ref, NULL);
308
g_list_free (volumes);
315
rb_uri_get_mount_point (const char *uri)
317
GList *mount_points = get_mount_points ();
319
gchar *mount_point = NULL;
321
for (it = mount_points; it != NULL; it = it->next) {
322
if (g_str_has_prefix (uri, it->data)) {
323
if ((mount_point == NULL) || (strlen (mount_point) < strlen (it->data))) {
324
g_free (mount_point);
325
mount_point = g_strdup (it->data);
329
g_list_foreach (mount_points, (GFunc)g_free, NULL);
330
g_list_free (mount_points);
336
rb_uri_is_mounted (const char *uri)
338
GList *mount_points = get_mount_points ();
340
gboolean found = FALSE;
342
if ((uri == NULL) || (*uri == '\0')) {
346
for (it = mount_points; it != NULL; it = it->next) {
347
if (strcmp (it->data, uri) == 0) {
352
g_list_foreach (mount_points, (GFunc)g_free, NULL);
353
g_list_free (mount_points);
355
/* if (found == FALSE) {
356
g_print ("%s not mounted\n", uri);
363
rb_is_main_thread (void)
365
if (g_thread_supported()) {
366
return GPOINTER_TO_UINT(g_private_get (private_is_primary_thread)) == 1;
374
rb_threads_init (void)
376
private_is_primary_thread = g_private_new (NULL);
377
g_private_set (private_is_primary_thread, GUINT_TO_POINTER (1));
379
/* not really necessary, but in case it does something besides
380
* set up lock functions some day..
386
rb_string_split_words (const gchar *string)
388
/*return g_slist_prepend (NULL, g_strdup (string));*/
390
GSList *words, *current;
391
gunichar *unicode, *cur_write, *cur_read;
393
gint i, wordcount = 1;
394
gboolean new_word = TRUE;
396
g_return_val_if_fail (string != NULL, NULL);
398
cur_write = cur_read = unicode = g_utf8_to_ucs4_fast (string, -1, NULL);
400
/* we may fail here, we expect valid utf-8 */
401
g_return_val_if_fail (unicode != NULL, NULL);
403
words = g_slist_prepend (NULL, unicode);
405
/* now normalize this text */
407
switch (g_unichar_type (*cur_read)) {
408
case G_UNICODE_UNASSIGNED:
409
g_warning ("unassigned unicode character type found");
411
case G_UNICODE_CONTROL:
412
case G_UNICODE_FORMAT:
413
case G_UNICODE_PRIVATE_USE:
415
case G_UNICODE_SURROGATE:
416
case G_UNICODE_LINE_SEPARATOR:
417
case G_UNICODE_PARAGRAPH_SEPARATOR:
418
case G_UNICODE_SPACE_SEPARATOR:
419
/* remove these and start a new word */
421
/* end current word if it isn't ended yet */
427
case G_UNICODE_COMBINING_MARK:
428
case G_UNICODE_ENCLOSING_MARK:
429
case G_UNICODE_NON_SPACING_MARK:
430
case G_UNICODE_CONNECT_PUNCTUATION:
431
case G_UNICODE_DASH_PUNCTUATION:
432
case G_UNICODE_CLOSE_PUNCTUATION:
433
case G_UNICODE_FINAL_PUNCTUATION:
434
case G_UNICODE_INITIAL_PUNCTUATION:
435
case G_UNICODE_OTHER_PUNCTUATION:
436
case G_UNICODE_OPEN_PUNCTUATION:
439
case G_UNICODE_LOWERCASE_LETTER:
440
case G_UNICODE_MODIFIER_LETTER:
441
case G_UNICODE_OTHER_LETTER:
442
case G_UNICODE_TITLECASE_LETTER:
443
case G_UNICODE_UPPERCASE_LETTER:
444
case G_UNICODE_DECIMAL_NUMBER:
445
case G_UNICODE_LETTER_NUMBER:
446
case G_UNICODE_OTHER_NUMBER:
447
case G_UNICODE_CURRENCY_SYMBOL:
448
case G_UNICODE_MODIFIER_SYMBOL:
449
case G_UNICODE_MATH_SYMBOL:
450
case G_UNICODE_OTHER_SYMBOL:
451
/* keep these unchanged */
452
*cur_write = *cur_read;
454
if (cur_write != unicode) {/* first insert has been done above */
455
words = g_slist_prepend (words, cur_write);
463
g_warning ("unknown unicode character type found");
473
ret = g_new (gchar *, wordcount + 1);
475
for (i = wordcount - 1; i >= 0; i--) {
476
ret[i] = g_ucs4_to_utf8 (current->data, -1, NULL, NULL, NULL);
477
current = g_slist_next (current);
479
ret[wordcount] = NULL;
481
g_slist_free (words);
488
rb_search_fold (const char *original)
491
gunichar *unicode, *cur;
493
g_return_val_if_fail (original != NULL, NULL);
495
/* old behaviour is equivalent to: return g_utf8_casefold (original, -1); */
497
string = g_string_new (NULL);
498
unicode = g_utf8_to_ucs4_fast (original, -1, NULL);
500
for (cur = unicode; *cur != 0; cur++) {
501
switch (g_unichar_type (*cur)) {
502
case G_UNICODE_COMBINING_MARK:
503
case G_UNICODE_ENCLOSING_MARK:
504
case G_UNICODE_NON_SPACING_MARK:
505
case G_UNICODE_CONNECT_PUNCTUATION:
506
case G_UNICODE_DASH_PUNCTUATION:
507
case G_UNICODE_CLOSE_PUNCTUATION:
508
case G_UNICODE_FINAL_PUNCTUATION:
509
case G_UNICODE_INITIAL_PUNCTUATION:
510
case G_UNICODE_OTHER_PUNCTUATION:
511
case G_UNICODE_OPEN_PUNCTUATION:
515
case G_UNICODE_LOWERCASE_LETTER:
516
case G_UNICODE_MODIFIER_LETTER:
517
case G_UNICODE_OTHER_LETTER:
518
case G_UNICODE_TITLECASE_LETTER:
519
case G_UNICODE_UPPERCASE_LETTER:
520
/* convert to lower case */
521
*cur = g_unichar_tolower (*cur);
522
/* ... and fall through */\
523
case G_UNICODE_DECIMAL_NUMBER:
524
case G_UNICODE_LETTER_NUMBER:
525
case G_UNICODE_OTHER_NUMBER:
526
/* should be keep symbols? */
527
case G_UNICODE_CURRENCY_SYMBOL:
528
case G_UNICODE_MODIFIER_SYMBOL:
529
case G_UNICODE_MATH_SYMBOL:
530
case G_UNICODE_OTHER_SYMBOL:
531
g_string_append_unichar (string, *cur);
534
case G_UNICODE_UNASSIGNED:
535
g_warning ("unassigned unicode character type found");
540
g_string_append_unichar (string, *cur);
546
return g_string_free (string, FALSE);