pidgin/gtkprefs.c

changeset 27449
ebd2e0ae2e3a
parent 27445
b8bbf88abd0f
child 27450
acf9ce9edb4a
equal deleted inserted replaced
27448:c687c6f42374 27449:ebd2e0ae2e3a
612 /* init all the theme variables so that the themes can be sorted later and used by pref pages */ 612 /* init all the theme variables so that the themes can be sorted later and used by pref pages */
613 static void 613 static void
614 prefs_themes_init() 614 prefs_themes_init()
615 { 615 {
616 prefs_sound_themes = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING); 616 prefs_sound_themes = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
617 617
618 prefs_blist_themes = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING); 618 prefs_blist_themes = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
619 619
620 prefs_status_icon_themes = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING); 620 prefs_status_icon_themes = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
621 } 621 }
622 622
623 static PurpleTheme * 623 static PurpleTheme *
624 prefs_theme_find_theme(const gchar *path, const gchar *type) 624 prefs_theme_find_theme(const gchar *path, const gchar *type)
625 { 625 {
626 PurpleTheme *theme = purple_theme_manager_load_theme(path, type); 626 PurpleTheme *theme = purple_theme_manager_load_theme(path, type);
627 GDir *dir = g_dir_open(path, 0, NULL); 627 GDir *dir = g_dir_open(path, 0, NULL);
628 const gchar *next; 628 const gchar *next;
629 629
640 640
641 return theme; 641 return theme;
642 } 642 }
643 643
644 /* installs a theme, info is freed by function */ 644 /* installs a theme, info is freed by function */
645 static void 645 static void
646 theme_install_theme(char *path, struct theme_info *info) { 646 theme_install_theme(char *path, struct theme_info *info) {
647 #ifndef _WIN32 647 #ifndef _WIN32
648 gchar *command; 648 gchar *command;
649 #endif 649 #endif
650 gchar *destdir, *tail, *type, *original_name; 650 gchar *destdir, *tail, *type, *original_name;
651 GtkTreeRowReference *theme_rowref; 651 GtkTreeRowReference *theme_rowref;
652 gboolean is_smiley_theme, is_archive; 652 gboolean is_smiley_theme, is_archive;
653 PurpleTheme *theme = NULL; 653 PurpleTheme *theme = NULL;
654 654
655 if (info == NULL) 655 if (info == NULL)
656 return; 656 return;
657 657
658 original_name = info->original_name; 658 original_name = info->original_name;
659 type = info->type; 659 type = info->type;
660 660
704 } 704 }
705 #else 705 #else
706 if(!winpidgin_gz_untar(path, destdir)) { 706 if(!winpidgin_gz_untar(path, destdir)) {
707 g_free(destdir); 707 g_free(destdir);
708 g_free(type); 708 g_free(type);
709 g_free(original_name); 709 g_free(original_name);
710 return; 710 return;
711 } 711 }
712 #endif 712 #endif
713 } 713 }
714 714
715 if (is_smiley_theme) { 715 if (is_smiley_theme) {
716 /* just extract the folder to the smiley directory */ 716 /* just extract the folder to the smiley directory */
717 theme_rowref = theme_refresh_theme_list(); 717 theme_rowref = theme_refresh_theme_list();
718 718
728 } else if (is_archive) { 728 } else if (is_archive) {
729 theme = prefs_theme_find_theme(destdir, type); 729 theme = prefs_theme_find_theme(destdir, type);
730 730
731 if (PURPLE_IS_THEME(theme)) { 731 if (PURPLE_IS_THEME(theme)) {
732 /* create the location for the theme */ 732 /* create the location for the theme */
733 gchar *theme_dest = g_build_filename(purple_user_dir(), "themes", 733 gchar *theme_dest = g_build_filename(purple_user_dir(), "themes",
734 purple_theme_get_name(theme), 734 purple_theme_get_name(theme),
735 "purple", type, NULL); 735 "purple", type, NULL);
736 736
737 if (!g_file_test(theme_dest, G_FILE_TEST_IS_DIR)) 737 if (!g_file_test(theme_dest, G_FILE_TEST_IS_DIR))
738 g_mkdir_with_parents(theme_dest, 0700); 738 g_mkdir_with_parents(theme_dest, 0700);
739 739
740 g_free(theme_dest); 740 g_free(theme_dest);
741 theme_dest = g_build_filename(purple_user_dir(), "themes", 741 theme_dest = g_build_filename(purple_user_dir(), "themes",
742 purple_theme_get_name(theme), 742 purple_theme_get_name(theme),
743 "purple", type, NULL); 743 "purple", type, NULL);
744 744
745 /* move the entire directory to new location */ 745 /* move the entire directory to new location */
746 g_rename(purple_theme_get_dir(theme), theme_dest); 746 g_rename(purple_theme_get_dir(theme), theme_dest);
758 } 758 }
759 759
760 } else { /* just a single file so copy it to a new temp directory and attempt to load it*/ 760 } else { /* just a single file so copy it to a new temp directory and attempt to load it*/
761 GFile *source, *destination; 761 GFile *source, *destination;
762 gchar *temp_path, *temp_file; 762 gchar *temp_path, *temp_file;
763 763
764 source = g_file_new_for_path(path); 764 source = g_file_new_for_path(path);
765 765
766 temp_path = g_build_filename(purple_user_dir(), "themes", "temp", "sub_folder", NULL); 766 temp_path = g_build_filename(purple_user_dir(), "themes", "temp", "sub_folder", NULL);
767 767
768 if (original_name != NULL) { 768 if (original_name != NULL) {
780 const gchar *source_name = g_file_info_get_content_type(file_info); 780 const gchar *source_name = g_file_info_get_content_type(file_info);
781 781
782 temp_file = g_build_filename(temp_path, source_name, NULL); 782 temp_file = g_build_filename(temp_path, source_name, NULL);
783 783
784 g_object_unref(file_info); 784 g_object_unref(file_info);
785 } 785 }
786 786
787 destination = g_file_new_for_path(temp_file); 787 destination = g_file_new_for_path(temp_file);
788 788
789 if (!g_file_test(temp_path, G_FILE_TEST_IS_DIR)) 789 if (!g_file_test(temp_path, G_FILE_TEST_IS_DIR))
790 g_mkdir_with_parents(temp_path, 0700); 790 g_mkdir_with_parents(temp_path, 0700);
791 791
792 g_file_copy(source, destination, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, NULL); 792 g_file_copy(source, destination, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, NULL);
793 793
794 g_object_unref(source); 794 g_object_unref(source);
795 g_object_unref(destination); 795 g_object_unref(destination);
796 796
797 /* find the theme, could be in subfolder */ 797 /* find the theme, could be in subfolder */
798 theme = prefs_theme_find_theme(temp_path, type); 798 theme = prefs_theme_find_theme(temp_path, type);
799 799
800 if (PURPLE_IS_THEME(theme)) { 800 if (PURPLE_IS_THEME(theme)) {
801 gchar *theme_dest = g_build_filename(purple_user_dir(), "themes", 801 gchar *theme_dest = g_build_filename(purple_user_dir(), "themes",
802 purple_theme_get_name(theme), 802 purple_theme_get_name(theme),
803 "purple", type, NULL); 803 "purple", type, NULL);
804 804
805 if(!g_file_test(theme_dest, G_FILE_TEST_IS_DIR)) 805 if(!g_file_test(theme_dest, G_FILE_TEST_IS_DIR))
806 g_mkdir_with_parents(theme_dest, 0700); 806 g_mkdir_with_parents(theme_dest, 0700);
807 807
808 g_rename(purple_theme_get_dir(theme), theme_dest); 808 g_rename(purple_theme_get_dir(theme), theme_dest);
809 809
810 g_free(theme_dest); 810 g_free(theme_dest);
811 g_object_unref(theme); 811 g_object_unref(theme);
819 819
820 g_free(temp_file); 820 g_free(temp_file);
821 g_free(temp_path); 821 g_free(temp_path);
822 } 822 }
823 823
824 g_free(type); 824 g_free(type);
825 g_free(original_name); 825 g_free(original_name);
826 g_free(destdir); 826 g_free(destdir);
827 } 827 }
828 828
829 static void 829 static void
864 /* Well, it looks like the drag event was cool. 864 /* Well, it looks like the drag event was cool.
865 * Let's do something with it */ 865 * Let's do something with it */
866 gchar *temp; 866 gchar *temp;
867 struct theme_info *info = g_new0(struct theme_info, 1); 867 struct theme_info *info = g_new0(struct theme_info, 1);
868 info->type = g_strdup((gchar *)user_data); 868 info->type = g_strdup((gchar *)user_data);
869 info->extension = g_strdup(g_strrstr(name,".")); 869 info->extension = g_strdup(g_strrstr(name,"."));
870 temp = g_strrstr(name, "/"); 870 temp = g_strrstr(name, "/");
871 info->original_name = temp ? g_strdup(++temp) : NULL; 871 info->original_name = temp ? g_strdup(++temp) : NULL;
872 872
873 if (!g_ascii_strncasecmp(name, "file://", 7)) { 873 if (!g_ascii_strncasecmp(name, "file://", 7)) {
874 GError *converr = NULL; 874 GError *converr = NULL;
875 gchar *tmp; 875 gchar *tmp;
901 g_free(tmp); 901 g_free(tmp);
902 } 902 }
903 903
904 gtk_drag_finish(dc, TRUE, FALSE, t); 904 gtk_drag_finish(dc, TRUE, FALSE, t);
905 } 905 }
906 906
907 gtk_drag_finish(dc, FALSE, FALSE, t); 907 gtk_drag_finish(dc, FALSE, FALSE, t);
908 } 908 }
909 909
910 /* builds a theme combo box from a list store with colums: icon preview, markup, theme name */ 910 /* builds a theme combo box from a list store with colums: icon preview, markup, theme name */
911 static GtkWidget * 911 static GtkWidget *
1012 { 1012 {
1013 struct theme_info *info = g_new0(struct theme_info, 1); 1013 struct theme_info *info = g_new0(struct theme_info, 1);
1014 info->type = g_strdup("smiley"); 1014 info->type = g_strdup("smiley");
1015 info->extension = NULL; 1015 info->extension = NULL;
1016 info->original_name = NULL; 1016 info->original_name = NULL;
1017 1017
1018 theme_install_theme(theme_file_name, info) ; 1018 theme_install_theme(theme_file_name, info) ;
1019 1019
1020 g_free(info); 1020 g_free(info);
1021 } 1021 }
1022 1022
1364 gchar *name = NULL; 1364 gchar *name = NULL;
1365 1365
1366 if(gtk_combo_box_get_active_iter(combo_box, &iter)) { 1366 if(gtk_combo_box_get_active_iter(combo_box, &iter)) {
1367 1367
1368 gtk_tree_model_get(GTK_TREE_MODEL(prefs_blist_themes), &iter, 2, &name, -1); 1368 gtk_tree_model_get(GTK_TREE_MODEL(prefs_blist_themes), &iter, 2, &name, -1);
1369 1369
1370 if(!name || !g_str_equal(name, "")) 1370 if(!name || !g_str_equal(name, ""))
1371 theme = PIDGIN_BLIST_THEME(purple_theme_manager_find_theme(name, "blist")); 1371 theme = PIDGIN_BLIST_THEME(purple_theme_manager_find_theme(name, "blist"));
1372 1372
1373 g_free(name); 1373 g_free(name);
1374 1374
1375 pidgin_blist_set_theme(theme); 1375 pidgin_blist_set_theme(theme);
1376 } 1376 }
1377 } 1377 }
1388 1388
1389 gtk_tree_model_get(GTK_TREE_MODEL(prefs_status_icon_themes), &iter, 2, &name, -1); 1389 gtk_tree_model_get(GTK_TREE_MODEL(prefs_status_icon_themes), &iter, 2, &name, -1);
1390 1390
1391 if(!name || !g_str_equal(name, "")) 1391 if(!name || !g_str_equal(name, ""))
1392 theme = PIDGIN_STATUS_ICON_THEME(purple_theme_manager_find_theme(name, "status-icon")); 1392 theme = PIDGIN_STATUS_ICON_THEME(purple_theme_manager_find_theme(name, "status-icon"));
1393 1393
1394 g_free(name); 1394 g_free(name);
1395 1395
1396 pidgin_stock_load_status_icon_theme(theme); 1396 pidgin_stock_load_status_icon_theme(theme);
1397 } 1397 }
1398 } 1398 }
1413 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); 1413 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
1414 1414
1415 /* Buddy List Themes */ 1415 /* Buddy List Themes */
1416 vbox = pidgin_make_frame(ret, _("Buddy List Theme")); 1416 vbox = pidgin_make_frame(ret, _("Buddy List Theme"));
1417 1417
1418 prefs_blist_themes_combo_box = prefs_build_theme_combo_box(prefs_blist_themes, 1418 prefs_blist_themes_combo_box = prefs_build_theme_combo_box(prefs_blist_themes,
1419 purple_prefs_get_string(PIDGIN_PREFS_ROOT "/blist/theme"), 1419 purple_prefs_get_string(PIDGIN_PREFS_ROOT "/blist/theme"),
1420 "blist"); 1420 "blist");
1421 1421
1422 gtk_box_pack_start(GTK_BOX (vbox), prefs_blist_themes_combo_box, FALSE, FALSE, 0); 1422 gtk_box_pack_start(GTK_BOX (vbox), prefs_blist_themes_combo_box, FALSE, FALSE, 0);
1423 g_signal_connect(G_OBJECT(prefs_blist_themes_combo_box), "changed", (GCallback)prefs_set_blist_theme_cb, NULL); 1423 g_signal_connect(G_OBJECT(prefs_blist_themes_combo_box), "changed", (GCallback)prefs_set_blist_theme_cb, NULL);
1424 1424
1425 /* Status Icon Themes */ 1425 /* Status Icon Themes */
1426 prefs_status_themes_combo_box = prefs_build_theme_combo_box(prefs_status_icon_themes, 1426 prefs_status_themes_combo_box = prefs_build_theme_combo_box(prefs_status_icon_themes,
1427 purple_prefs_get_string(PIDGIN_PREFS_ROOT "/status/icon-theme"), 1427 purple_prefs_get_string(PIDGIN_PREFS_ROOT "/status/icon-theme"),
1428 "icon"); 1428 "icon");
1429 1429
1430 gtk_box_pack_start(GTK_BOX (vbox), prefs_status_themes_combo_box, FALSE, FALSE, 0); 1430 gtk_box_pack_start(GTK_BOX (vbox), prefs_status_themes_combo_box, FALSE, FALSE, 0);
1431 g_signal_connect(G_OBJECT(prefs_status_themes_combo_box), "changed", (GCallback)prefs_set_status_icon_theme_cb, NULL); 1431 g_signal_connect(G_OBJECT(prefs_status_themes_combo_box), "changed", (GCallback)prefs_set_status_icon_theme_cb, NULL);
1432 1432
1633 * and a green background when the IP address is valid. 1633 * and a green background when the IP address is valid.
1634 */ 1634 */
1635 purple_network_set_public_ip(gtk_entry_get_text(entry)); 1635 purple_network_set_public_ip(gtk_entry_get_text(entry));
1636 } 1636 }
1637 1637
1638 static gboolean network_stun_server_changed_cb(GtkWidget *widget, 1638 static gboolean network_stun_server_changed_cb(GtkWidget *widget,
1639 GdkEventFocus *event, gpointer data) 1639 GdkEventFocus *event, gpointer data)
1640 { 1640 {
1641 GtkEntry *entry = GTK_ENTRY(widget); 1641 GtkEntry *entry = GTK_ENTRY(widget);
1642 purple_prefs_set_string("/purple/network/stun_server", 1642 purple_prefs_set_string("/purple/network/stun_server",
1643 gtk_entry_get_text(entry)); 1643 gtk_entry_get_text(entry));
1644 purple_network_set_stun_server(gtk_entry_get_text(entry)); 1644 purple_network_set_stun_server(gtk_entry_get_text(entry));
1645 1645
1646 return FALSE; 1646 return FALSE;
1647 } 1647 }
1648 1648
1649 static gboolean network_turn_server_changed_cb(GtkWidget *widget, 1649 static gboolean network_turn_server_changed_cb(GtkWidget *widget,
1650 GdkEventFocus *event, gpointer data) 1650 GdkEventFocus *event, gpointer data)
1651 { 1651 {
1652 GtkEntry *entry = GTK_ENTRY(widget); 1652 GtkEntry *entry = GTK_ENTRY(widget);
1653 purple_prefs_set_string("/purple/network/turn_server", 1653 purple_prefs_set_string("/purple/network/turn_server",
1654 gtk_entry_get_text(entry)); 1654 gtk_entry_get_text(entry));
1655 purple_network_set_turn_server(gtk_entry_get_text(entry)); 1655 purple_network_set_turn_server(gtk_entry_get_text(entry));
1656 1656
1657 return FALSE; 1657 return FALSE;
1658 } 1658 }
1659 1659
1660 static void 1660 static void
1661 proxy_changed_cb(const char *name, PurplePrefType type, 1661 proxy_changed_cb(const char *name, PurplePrefType type,
1825 hbox = pidgin_add_widget_to_vbox(GTK_BOX(vbox), "_TURN server:", 1825 hbox = pidgin_add_widget_to_vbox(GTK_BOX(vbox), "_TURN server:",
1826 sg, entry, TRUE, NULL); 1826 sg, entry, TRUE, NULL);
1827 1827
1828 pidgin_prefs_labeled_spin_button(hbox, _("_Port:"), 1828 pidgin_prefs_labeled_spin_button(hbox, _("_Port:"),
1829 "/purple/network/turn_port", 0, 65535, NULL); 1829 "/purple/network/turn_port", 0, 65535, NULL);
1830 hbox = pidgin_prefs_labeled_entry(vbox, "_Username:", 1830 hbox = pidgin_prefs_labeled_entry(vbox, "_Username:",
1831 "/purple/network/turn_username", sg); 1831 "/purple/network/turn_username", sg);
1832 pidgin_prefs_labeled_password(hbox, "_Password:", 1832 pidgin_prefs_labeled_password(hbox, "_Password:",
1833 "/purple/network/turn_password", NULL); 1833 "/purple/network/turn_password", NULL);
1834 1834
1835 if (purple_running_gnome()) { 1835 if (purple_running_gnome()) {
2514 TRUE, 0, GTK_PACK_START); 2514 TRUE, 0, GTK_PACK_START);
2515 gtk_box_set_child_packing(GTK_BOX(vbox->parent->parent->parent), 2515 gtk_box_set_child_packing(GTK_BOX(vbox->parent->parent->parent),
2516 vbox->parent->parent, TRUE, TRUE, 0, GTK_PACK_START); 2516 vbox->parent->parent, TRUE, TRUE, 0, GTK_PACK_START);
2517 2517
2518 /* SOUND THEMES */ 2518 /* SOUND THEMES */
2519 prefs_sound_themes_combo_box = prefs_build_theme_combo_box(prefs_sound_themes, 2519 prefs_sound_themes_combo_box = prefs_build_theme_combo_box(prefs_sound_themes,
2520 purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/theme"), 2520 purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/theme"),
2521 "sound"); 2521 "sound");
2522 2522
2523 2523
2524 gtk_box_pack_start(GTK_BOX (vbox), prefs_sound_themes_combo_box, FALSE, FALSE, 0); 2524 gtk_box_pack_start(GTK_BOX (vbox), prefs_sound_themes_combo_box, FALSE, FALSE, 0);

mercurial