Mercurial > pidgin
comparison src/gtkprefs.c @ 8928:755d7f8907c6
[gaim-migrate @ 9698]
" This patch creates a custom sort function that will
sort the "none" theme, if found, at the top of the
Smiley Themes list. Luke and I thought it was good
idea to do so.
I also had to add just the theme name to the tree list
since the other field had the name, author, and
description all marked up, which would be stupid to try
and sort. This way I can just look for "none"" --Don Seiler
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Fri, 14 May 2004 05:04:28 +0000 |
parents | 5dd21fa59de3 |
children | 4e59af6cc8de |
comparison
equal
deleted
inserted
replaced
8927:5dd21fa59de3 | 8928:755d7f8907c6 |
---|---|
460 | 460 |
461 gtk_list_store_set(smiley_theme_store, &iter, | 461 gtk_list_store_set(smiley_theme_store, &iter, |
462 0, pixbuf, | 462 0, pixbuf, |
463 1, description, | 463 1, description, |
464 2, theme->path, | 464 2, theme->path, |
465 3, theme->name, | |
465 -1); | 466 -1); |
466 | 467 |
467 if (pixbuf != NULL) | 468 if (pixbuf != NULL) |
468 g_object_unref(G_OBJECT(pixbuf)); | 469 g_object_unref(G_OBJECT(pixbuf)); |
469 | 470 |
584 } | 585 } |
585 | 586 |
586 gtk_drag_finish(dc, FALSE, FALSE, t); | 587 gtk_drag_finish(dc, FALSE, FALSE, t); |
587 } | 588 } |
588 | 589 |
590 /* Does same as normal sort, except "none" is sorted first */ | |
591 gint gaim_sort_smileys (GtkTreeModel *model, | |
592 GtkTreeIter *a, | |
593 GtkTreeIter *b, | |
594 gpointer userdata) | |
595 { | |
596 gaim_debug_info("gaim_sort_smileys","entered\n"); | |
597 gint ret = 0; | |
598 gchar *name1, *name2; | |
599 | |
600 gtk_tree_model_get(model, a, 3, &name1, -1); | |
601 gtk_tree_model_get(model, b, 3, &name2, -1); | |
602 | |
603 if (name1 == NULL || name2 == NULL) { | |
604 if (!(name1 == NULL && name2 == NULL)) | |
605 ret = (name1 == NULL) ? -1: 1; | |
606 } else if (!g_ascii_strcasecmp(name1, "none")) { | |
607 /* Sort name1 first */ | |
608 ret = -1; | |
609 } else if (!g_ascii_strcasecmp(name2, "none")) { | |
610 /* Sort name2 first */ | |
611 ret = 1; | |
612 } else { | |
613 /* Neither string is "none", default to normal sort */ | |
614 ret = g_utf8_collate(name1,name2); | |
615 } | |
616 | |
617 gaim_debug_info("gaim_sort_smileys","leaving\n"); | |
618 return ret; | |
619 } | |
620 | |
589 GtkWidget *theme_page() { | 621 GtkWidget *theme_page() { |
590 GtkWidget *ret; | 622 GtkWidget *ret; |
591 GtkWidget *sw; | 623 GtkWidget *sw; |
592 GtkWidget *view; | 624 GtkWidget *view; |
593 GtkCellRenderer *rend; | 625 GtkCellRenderer *rend; |
612 sw = gtk_scrolled_window_new(NULL,NULL); | 644 sw = gtk_scrolled_window_new(NULL,NULL); |
613 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | 645 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); |
614 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); | 646 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
615 | 647 |
616 gtk_box_pack_start(GTK_BOX(ret), sw, TRUE, TRUE, 0); | 648 gtk_box_pack_start(GTK_BOX(ret), sw, TRUE, TRUE, 0); |
617 smiley_theme_store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING); | 649 smiley_theme_store = gtk_list_store_new (4, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); |
618 | 650 |
619 path = theme_refresh_theme_list(); | 651 path = theme_refresh_theme_list(); |
620 | 652 |
621 view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(smiley_theme_store)); | 653 view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(smiley_theme_store)); |
622 | 654 |
630 | 662 |
631 if(path) { | 663 if(path) { |
632 gtk_tree_selection_select_path(sel, path); | 664 gtk_tree_selection_select_path(sel, path); |
633 gtk_tree_path_free(path); | 665 gtk_tree_path_free(path); |
634 } | 666 } |
667 | |
668 /* Custom sort so "none" theme is at top of list */ | |
669 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(smiley_theme_store), | |
670 3, gaim_sort_smileys, NULL, NULL); | |
671 | |
635 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(smiley_theme_store), | 672 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(smiley_theme_store), |
636 1, GTK_SORT_ASCENDING); | 673 3, GTK_SORT_ASCENDING); |
637 | 674 |
638 col = gtk_tree_view_column_new_with_attributes (_("Icon"), | 675 col = gtk_tree_view_column_new_with_attributes (_("Icon"), |
639 rend, | 676 rend, |
640 "pixbuf", 0, | 677 "pixbuf", 0, |
641 NULL); | 678 NULL); |