comparison pidgin/gtkutils.c @ 15501:d75099d2567e

gaim_gtk to pidgin. I hope
author Sean Egan <seanegan@gmail.com>
date Sat, 03 Feb 2007 07:23:11 +0000
parents 154b8d8643a2
children 311315e979f7
comparison
equal deleted inserted replaced
15500:45ecefd0ce3a 15501:d75099d2567e
93 g_return_if_fail(GTK_IS_IMHTML(imhtml)); 93 g_return_if_fail(GTK_IS_IMHTML(imhtml));
94 94
95 g_signal_connect(G_OBJECT(imhtml), "url_clicked", 95 g_signal_connect(G_OBJECT(imhtml), "url_clicked",
96 G_CALLBACK(url_clicked_cb), NULL); 96 G_CALLBACK(url_clicked_cb), NULL);
97 97
98 gaim_gtkthemes_smiley_themeize(imhtml); 98 pidginthemes_smiley_themeize(imhtml);
99 99
100 gtk_imhtml_set_funcs(GTK_IMHTML(imhtml), &gtkimhtml_cbs); 100 gtk_imhtml_set_funcs(GTK_IMHTML(imhtml), &gtkimhtml_cbs);
101 101
102 /* Use the GNOME "document" font, if applicable */ 102 /* Use the GNOME "document" font, if applicable */
103 if (gaim_running_gnome()) { 103 if (gaim_running_gnome()) {
120 } 120 }
121 } 121 }
122 } 122 }
123 123
124 GtkWidget * 124 GtkWidget *
125 gaim_gtk_create_imhtml(gboolean editable, GtkWidget **imhtml_ret, GtkWidget **toolbar_ret, GtkWidget **sw_ret) 125 pidgin_create_imhtml(gboolean editable, GtkWidget **imhtml_ret, GtkWidget **toolbar_ret, GtkWidget **sw_ret)
126 { 126 {
127 GtkWidget *frame; 127 GtkWidget *frame;
128 GtkWidget *imhtml; 128 GtkWidget *imhtml;
129 GtkWidget *sep; 129 GtkWidget *sep;
130 GtkWidget *sw; 130 GtkWidget *sw;
160 gtk_imhtml_set_editable(GTK_IMHTML(imhtml), editable); 160 gtk_imhtml_set_editable(GTK_IMHTML(imhtml), editable);
161 gtk_imhtml_set_format_functions(GTK_IMHTML(imhtml), GTK_IMHTML_ALL ^ GTK_IMHTML_IMAGE); 161 gtk_imhtml_set_format_functions(GTK_IMHTML(imhtml), GTK_IMHTML_ALL ^ GTK_IMHTML_IMAGE);
162 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(imhtml), GTK_WRAP_WORD_CHAR); 162 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(imhtml), GTK_WRAP_WORD_CHAR);
163 #ifdef USE_GTKSPELL 163 #ifdef USE_GTKSPELL
164 if (editable && gaim_prefs_get_bool("/gaim/gtk/conversations/spellcheck")) 164 if (editable && gaim_prefs_get_bool("/gaim/gtk/conversations/spellcheck"))
165 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(imhtml)); 165 pidgin_setup_gtkspell(GTK_TEXT_VIEW(imhtml));
166 #endif 166 #endif
167 gtk_widget_show(imhtml); 167 gtk_widget_show(imhtml);
168 168
169 if (editable) { 169 if (editable) {
170 gtk_imhtmltoolbar_attach(GTK_IMHTMLTOOLBAR(toolbar), imhtml); 170 gtk_imhtmltoolbar_attach(GTK_IMHTMLTOOLBAR(toolbar), imhtml);
185 185
186 return frame; 186 return frame;
187 } 187 }
188 188
189 void 189 void
190 gaim_gtk_set_sensitive_if_input(GtkWidget *entry, GtkWidget *dialog) 190 pidgin_set_sensitive_if_input(GtkWidget *entry, GtkWidget *dialog)
191 { 191 {
192 const char *text = gtk_entry_get_text(GTK_ENTRY(entry)); 192 const char *text = gtk_entry_get_text(GTK_ENTRY(entry));
193 gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_OK, 193 gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_OK,
194 (*text != '\0')); 194 (*text != '\0'));
195 } 195 }
196 196
197 void 197 void
198 gaim_gtk_toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle) 198 pidgin_toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle)
199 { 199 {
200 gboolean sensitivity; 200 gboolean sensitivity;
201 201
202 if (to_toggle == NULL) 202 if (to_toggle == NULL)
203 return; 203 return;
206 206
207 gtk_widget_set_sensitive(to_toggle, !sensitivity); 207 gtk_widget_set_sensitive(to_toggle, !sensitivity);
208 } 208 }
209 209
210 void 210 void
211 gaim_gtk_toggle_sensitive_array(GtkWidget *w, GPtrArray *data) 211 pidgin_toggle_sensitive_array(GtkWidget *w, GPtrArray *data)
212 { 212 {
213 gboolean sensitivity; 213 gboolean sensitivity;
214 gpointer element; 214 gpointer element;
215 int i; 215 int i;
216 216
224 gtk_widget_set_sensitive(element, !sensitivity); 224 gtk_widget_set_sensitive(element, !sensitivity);
225 } 225 }
226 } 226 }
227 227
228 void 228 void
229 gaim_gtk_toggle_showhide(GtkWidget *widget, GtkWidget *to_toggle) 229 pidgin_toggle_showhide(GtkWidget *widget, GtkWidget *to_toggle)
230 { 230 {
231 if (to_toggle == NULL) 231 if (to_toggle == NULL)
232 return; 232 return;
233 233
234 if (GTK_WIDGET_VISIBLE(to_toggle)) 234 if (GTK_WIDGET_VISIBLE(to_toggle))
393 393
394 return menuitem; 394 return menuitem;
395 } 395 }
396 396
397 GtkWidget * 397 GtkWidget *
398 gaim_gtk_make_frame(GtkWidget *parent, const char *title) 398 pidgin_make_frame(GtkWidget *parent, const char *title)
399 { 399 {
400 GtkWidget *vbox, *label, *hbox; 400 GtkWidget *vbox, *label, *hbox;
401 char *labeltitle; 401 char *labeltitle;
402 402
403 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); 403 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE);
448 ((void (*)(GtkWidget *, const char *, gpointer))cb)(item, protocol, 448 ((void (*)(GtkWidget *, const char *, gpointer))cb)(item, protocol,
449 user_data); 449 user_data);
450 } 450 }
451 451
452 GtkWidget * 452 GtkWidget *
453 gaim_gtk_protocol_option_menu_new(const char *id, GCallback cb, 453 pidgin_protocol_option_menu_new(const char *id, GCallback cb,
454 gpointer user_data) 454 gpointer user_data)
455 { 455 {
456 GaimPluginProtocolInfo *prpl_info; 456 GaimPluginProtocolInfo *prpl_info;
457 GaimPlugin *plugin; 457 GaimPlugin *plugin;
458 GtkWidget *hbox; 458 GtkWidget *hbox;
545 545
546 return optmenu; 546 return optmenu;
547 } 547 }
548 548
549 GaimAccount * 549 GaimAccount *
550 gaim_gtk_account_option_menu_get_selected(GtkWidget *optmenu) 550 pidgin_account_option_menu_get_selected(GtkWidget *optmenu)
551 { 551 {
552 GtkWidget *menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); 552 GtkWidget *menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu));
553 GtkWidget *item = gtk_menu_get_active(GTK_MENU(menu)); 553 GtkWidget *item = gtk_menu_get_active(GTK_MENU(menu));
554 return g_object_get_data(G_OBJECT(item), "account"); 554 return g_object_get_data(G_OBJECT(item), "account");
555 } 555 }
743 743
744 return FALSE; 744 return FALSE;
745 } 745 }
746 746
747 void 747 void
748 gaim_gtk_account_option_menu_set_selected(GtkWidget *optmenu, GaimAccount *account) 748 pidgin_account_option_menu_set_selected(GtkWidget *optmenu, GaimAccount *account)
749 { 749 {
750 GtkWidget *menu; 750 GtkWidget *menu;
751 GtkWidget *item; 751 GtkWidget *item;
752 gboolean show_all; 752 gboolean show_all;
753 GaimAccount *curaccount; 753 GaimAccount *curaccount;
770 770
771 create_account_menu(optmenu, account, filter_func, show_all); 771 create_account_menu(optmenu, account, filter_func, show_all);
772 } 772 }
773 773
774 GtkWidget * 774 GtkWidget *
775 gaim_gtk_account_option_menu_new(GaimAccount *default_account, 775 pidgin_account_option_menu_new(GaimAccount *default_account,
776 gboolean show_all, GCallback cb, 776 gboolean show_all, GCallback cb,
777 GaimFilterAccountFunc filter_func, 777 GaimFilterAccountFunc filter_func,
778 gpointer user_data) 778 gpointer user_data)
779 { 779 {
780 GtkWidget *optmenu; 780 GtkWidget *optmenu;
815 815
816 return optmenu; 816 return optmenu;
817 } 817 }
818 818
819 gboolean 819 gboolean
820 gaim_gtk_check_if_dir(const char *path, GtkFileSelection *filesel) 820 pidgin_check_if_dir(const char *path, GtkFileSelection *filesel)
821 { 821 {
822 char *dirname; 822 char *dirname;
823 823
824 if (g_file_test(path, G_FILE_TEST_IS_DIR)) { 824 if (g_file_test(path, G_FILE_TEST_IS_DIR)) {
825 /* append a / if needed */ 825 /* append a / if needed */
835 835
836 return FALSE; 836 return FALSE;
837 } 837 }
838 838
839 void 839 void
840 gaim_gtk_setup_gtkspell(GtkTextView *textview) 840 pidgin_setup_gtkspell(GtkTextView *textview)
841 { 841 {
842 #ifdef USE_GTKSPELL 842 #ifdef USE_GTKSPELL
843 GError *error = NULL; 843 GError *error = NULL;
844 char *locale = NULL; 844 char *locale = NULL;
845 845
854 } 854 }
855 #endif /* USE_GTKSPELL */ 855 #endif /* USE_GTKSPELL */
856 } 856 }
857 857
858 void 858 void
859 gaim_gtk_save_accels_cb(GtkAccelGroup *accel_group, guint arg1, 859 pidgin_save_accels_cb(GtkAccelGroup *accel_group, guint arg1,
860 GdkModifierType arg2, GClosure *arg3, 860 GdkModifierType arg2, GClosure *arg3,
861 gpointer data) 861 gpointer data)
862 { 862 {
863 gaim_debug(GAIM_DEBUG_MISC, "accels", 863 gaim_debug(GAIM_DEBUG_MISC, "accels",
864 "accel changed, scheduling save.\n"); 864 "accel changed, scheduling save.\n");
865 865
866 if (!accels_save_timer) 866 if (!accels_save_timer)
867 accels_save_timer = g_timeout_add(5000, gaim_gtk_save_accels, 867 accels_save_timer = g_timeout_add(5000, pidgin_save_accels,
868 NULL); 868 NULL);
869 } 869 }
870 870
871 gboolean 871 gboolean
872 gaim_gtk_save_accels(gpointer data) 872 pidgin_save_accels(gpointer data)
873 { 873 {
874 char *filename = NULL; 874 char *filename = NULL;
875 875
876 filename = g_build_filename(gaim_user_dir(), G_DIR_SEPARATOR_S, 876 filename = g_build_filename(gaim_user_dir(), G_DIR_SEPARATOR_S,
877 "accels", NULL); 877 "accels", NULL);
882 accels_save_timer = 0; 882 accels_save_timer = 0;
883 return FALSE; 883 return FALSE;
884 } 884 }
885 885
886 void 886 void
887 gaim_gtk_load_accels() 887 pidgin_load_accels()
888 { 888 {
889 char *filename = NULL; 889 char *filename = NULL;
890 890
891 filename = g_build_filename(gaim_user_dir(), G_DIR_SEPARATOR_S, 891 filename = g_build_filename(gaim_user_dir(), G_DIR_SEPARATOR_S,
892 "accels", NULL); 892 "accels", NULL);
893 gtk_accel_map_load(filename); 893 gtk_accel_map_load(filename);
894 g_free(filename); 894 g_free(filename);
895 } 895 }
896 896
897 gboolean 897 gboolean
898 gaim_gtk_parse_x_im_contact(const char *msg, gboolean all_accounts, 898 pidgin_parse_x_im_contact(const char *msg, gboolean all_accounts,
899 GaimAccount **ret_account, char **ret_protocol, 899 GaimAccount **ret_account, char **ret_protocol,
900 char **ret_username, char **ret_alias) 900 char **ret_username, char **ret_alias)
901 { 901 {
902 char *protocol = NULL; 902 char *protocol = NULL;
903 char *username = NULL; 903 char *username = NULL;
1113 g_object_unref (relation); 1113 g_object_unref (relation);
1114 } 1114 }
1115 1115
1116 #if GTK_CHECK_VERSION(2,2,0) 1116 #if GTK_CHECK_VERSION(2,2,0)
1117 static void 1117 static void
1118 gaim_gtk_menu_position_func(GtkMenu *menu, 1118 pidgin_menu_position_func(GtkMenu *menu,
1119 gint *x, 1119 gint *x,
1120 gint *y, 1120 gint *y,
1121 gboolean *push_in, 1121 gboolean *push_in,
1122 gpointer data) 1122 gpointer data)
1123 { 1123 {
1264 } 1264 }
1265 1265
1266 #endif 1266 #endif
1267 1267
1268 void 1268 void
1269 gaim_gtk_treeview_popup_menu_position_func(GtkMenu *menu, 1269 pidgin_treeview_popup_menu_position_func(GtkMenu *menu,
1270 gint *x, 1270 gint *x,
1271 gint *y, 1271 gint *y,
1272 gboolean *push_in, 1272 gboolean *push_in,
1273 gpointer data) 1273 gpointer data)
1274 { 1274 {
1284 gtk_tree_view_get_cell_area (tv, path, col, &rect); 1284 gtk_tree_view_get_cell_area (tv, path, col, &rect);
1285 1285
1286 *x += rect.x+rect.width; 1286 *x += rect.x+rect.width;
1287 *y += rect.y+rect.height+ythickness; 1287 *y += rect.y+rect.height+ythickness;
1288 #if GTK_CHECK_VERSION(2,2,0) 1288 #if GTK_CHECK_VERSION(2,2,0)
1289 gaim_gtk_menu_position_func (menu, x, y, push_in, data); 1289 pidgin_menu_position_func (menu, x, y, push_in, data);
1290 #endif 1290 #endif
1291 } 1291 }
1292 1292
1293 enum { 1293 enum {
1294 DND_FILE_TRANSFER, 1294 DND_FILE_TRANSFER,
1307 char *filedata; 1307 char *filedata;
1308 size_t size; 1308 size_t size;
1309 struct stat st; 1309 struct stat st;
1310 GError *err = NULL; 1310 GError *err = NULL;
1311 GaimConversation *conv; 1311 GaimConversation *conv;
1312 GaimGtkConversation *gtkconv; 1312 PidginConversation *gtkconv;
1313 GtkTextIter iter; 1313 GtkTextIter iter;
1314 int id; 1314 int id;
1315 switch (choice) { 1315 switch (choice) {
1316 case DND_BUDDY_ICON: 1316 case DND_BUDDY_ICON:
1317 if (g_stat(data->filename, &st)) { 1317 if (g_stat(data->filename, &st)) {
1325 g_free(str); 1325 g_free(str);
1326 1326
1327 return; 1327 return;
1328 } 1328 }
1329 1329
1330 gaim_gtk_set_custom_buddy_icon(data->account, data->who, data->filename); 1330 pidgin_set_custom_buddy_icon(data->account, data->who, data->filename);
1331 break; 1331 break;
1332 case DND_FILE_TRANSFER: 1332 case DND_FILE_TRANSFER:
1333 serv_send_file(gaim_account_get_connection(data->account), data->who, data->filename); 1333 serv_send_file(gaim_account_get_connection(data->account), data->who, data->filename);
1334 break; 1334 break;
1335 case DND_IM_IMAGE: 1335 case DND_IM_IMAGE:
1336 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, data->account, data->who); 1336 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, data->account, data->who);
1337 gtkconv = GAIM_GTK_CONVERSATION(conv); 1337 gtkconv = PIDGIN_CONVERSATION(conv);
1338 1338
1339 if (!g_file_get_contents(data->filename, &filedata, &size, 1339 if (!g_file_get_contents(data->filename, &filedata, &size,
1340 &err)) { 1340 &err)) {
1341 char *str; 1341 char *str;
1342 1342
1501 itemname = gaim_desktop_item_get_string(item, "Name"); 1501 itemname = gaim_desktop_item_get_string(item, "Name");
1502 1502
1503 dtype = gaim_desktop_item_get_entry_type(item); 1503 dtype = gaim_desktop_item_get_entry_type(item);
1504 switch (dtype) { 1504 switch (dtype) {
1505 GaimConversation *conv; 1505 GaimConversation *conv;
1506 GaimGtkConversation *gtkconv; 1506 PidginConversation *gtkconv;
1507 1507
1508 case GAIM_DESKTOP_ITEM_TYPE_LINK: 1508 case GAIM_DESKTOP_ITEM_TYPE_LINK:
1509 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, who); 1509 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, who);
1510 gtkconv = GAIM_GTK_CONVERSATION(conv); 1510 gtkconv = PIDGIN_CONVERSATION(conv);
1511 gtk_imhtml_insert_link(GTK_IMHTML(gtkconv->entry), 1511 gtk_imhtml_insert_link(GTK_IMHTML(gtkconv->entry),
1512 gtk_text_buffer_get_insert(GTK_IMHTML(gtkconv->entry)->text_buffer), 1512 gtk_text_buffer_get_insert(GTK_IMHTML(gtkconv->entry)->text_buffer),
1513 gaim_desktop_item_get_string(item, "URL"), itemname); 1513 gaim_desktop_item_get_string(item, "URL"), itemname);
1514 break; 1514 break;
1515 default: 1515 default:
1533 g_free(filename); 1533 g_free(filename);
1534 } 1534 }
1535 g_list_free(files); 1535 g_list_free(files);
1536 } 1536 }
1537 1537
1538 void gaim_gtk_buddy_icon_get_scale_size(GdkPixbuf *buf, GaimBuddyIconSpec *spec, GaimIconScaleRules rules, int *width, int *height) 1538 void pidgin_buddy_icon_get_scale_size(GdkPixbuf *buf, GaimBuddyIconSpec *spec, GaimIconScaleRules rules, int *width, int *height)
1539 { 1539 {
1540 *width = gdk_pixbuf_get_width(buf); 1540 *width = gdk_pixbuf_get_width(buf);
1541 *height = gdk_pixbuf_get_height(buf); 1541 *height = gdk_pixbuf_get_height(buf);
1542 1542
1543 if ((spec == NULL) || !(spec->scale_rules & rules)) 1543 if ((spec == NULL) || !(spec->scale_rules & rules))
1551 if(*height > 100) 1551 if(*height > 100)
1552 *height = 100; 1552 *height = 100;
1553 } 1553 }
1554 1554
1555 GdkPixbuf * 1555 GdkPixbuf *
1556 gaim_gtk_create_prpl_icon(GaimAccount *account, PidginPrplIconSize size) 1556 pidgin_create_prpl_icon(GaimAccount *account, PidginPrplIconSize size)
1557 { 1557 {
1558 GaimPlugin *prpl; 1558 GaimPlugin *prpl;
1559 GaimPluginProtocolInfo *prpl_info; 1559 GaimPluginProtocolInfo *prpl_info;
1560 const char *protoname = NULL; 1560 const char *protoname = NULL;
1561 char buf[256]; /* TODO: We should use a define for max file length */ 1561 char buf[256]; /* TODO: We should use a define for max file length */
1642 1642
1643 return pixbuf; 1643 return pixbuf;
1644 } 1644 }
1645 1645
1646 GdkPixbuf * 1646 GdkPixbuf *
1647 gaim_gtk_create_prpl_icon_with_status(GaimAccount *account, GaimStatusType *status_type, double scale_factor) 1647 pidgin_create_prpl_icon_with_status(GaimAccount *account, GaimStatusType *status_type, double scale_factor)
1648 { 1648 {
1649 GdkPixbuf *pixbuf; 1649 GdkPixbuf *pixbuf;
1650 1650
1651 pixbuf = gaim_gtk_create_prpl_icon(account, scale_factor); 1651 pixbuf = pidgin_create_prpl_icon(account, scale_factor);
1652 if (pixbuf == NULL) 1652 if (pixbuf == NULL)
1653 return NULL; 1653 return NULL;
1654 1654
1655 /* 1655 /*
1656 * TODO: Let the prpl pick the emblem on a per status basis, 1656 * TODO: Let the prpl pick the emblem on a per status basis,
1660 return overlay_status_onto_icon(pixbuf, 1660 return overlay_status_onto_icon(pixbuf,
1661 gaim_status_type_get_primitive(status_type)); 1661 gaim_status_type_get_primitive(status_type));
1662 } 1662 }
1663 1663
1664 GdkPixbuf * 1664 GdkPixbuf *
1665 gaim_gtk_create_gaim_icon_with_status(GaimStatusPrimitive primitive, double scale_factor) 1665 pidgin_create_gaim_icon_with_status(GaimStatusPrimitive primitive, double scale_factor)
1666 { 1666 {
1667 gchar *filename; 1667 gchar *filename;
1668 GdkPixbuf *orig, *pixbuf; 1668 GdkPixbuf *orig, *pixbuf;
1669 1669
1670 filename = g_build_filename(DATADIR, "pixmaps", "gaim.png", NULL); 1670 filename = g_build_filename(DATADIR, "pixmaps", "gaim.png", NULL);
1692 if (callback) 1692 if (callback)
1693 callback(object, data); 1693 callback(object, data);
1694 } 1694 }
1695 1695
1696 void 1696 void
1697 gaim_gtk_append_menu_action(GtkWidget *menu, GaimMenuAction *act, 1697 pidgin_append_menu_action(GtkWidget *menu, GaimMenuAction *act,
1698 gpointer object) 1698 gpointer object)
1699 { 1699 {
1700 if (act == NULL) { 1700 if (act == NULL) {
1701 gaim_separator(menu); 1701 gaim_separator(menu);
1702 } else { 1702 } else {
1740 } 1740 }
1741 1741
1742 for (l = act->children; l; l = l->next) { 1742 for (l = act->children; l; l = l->next) {
1743 GaimMenuAction *act = (GaimMenuAction *)l->data; 1743 GaimMenuAction *act = (GaimMenuAction *)l->data;
1744 1744
1745 gaim_gtk_append_menu_action(submenu, act, object); 1745 pidgin_append_menu_action(submenu, act, object);
1746 } 1746 }
1747 g_list_free(act->children); 1747 g_list_free(act->children);
1748 act->children = NULL; 1748 act->children = NULL;
1749 } 1749 }
1750 gaim_menu_action_free(act); 1750 gaim_menu_action_free(act);
1761 GCompletion *completion; 1761 GCompletion *completion;
1762 1762
1763 gboolean completion_started; 1763 gboolean completion_started;
1764 gboolean all; 1764 gboolean all;
1765 1765
1766 } GaimGtkCompletionData; 1766 } PidginCompletionData;
1767 #endif 1767 #endif
1768 1768
1769 #ifndef NEW_STYLE_COMPLETION 1769 #ifndef NEW_STYLE_COMPLETION
1770 static gboolean 1770 static gboolean
1771 completion_entry_event(GtkEditable *entry, GdkEventKey *event, 1771 completion_entry_event(GtkEditable *entry, GdkEventKey *event,
1772 GaimGtkCompletionData *data) 1772 PidginCompletionData *data)
1773 { 1773 {
1774 int pos, end_pos; 1774 int pos, end_pos;
1775 1775
1776 if (event->type == GDK_KEY_PRESS && event->keyval == GDK_Tab) 1776 if (event->type == GDK_KEY_PRESS && event->keyval == GDK_Tab)
1777 { 1777 {
1836 1836
1837 return FALSE; 1837 return FALSE;
1838 } 1838 }
1839 1839
1840 static void 1840 static void
1841 destroy_completion_data(GtkWidget *w, GaimGtkCompletionData *data) 1841 destroy_completion_data(GtkWidget *w, PidginCompletionData *data)
1842 { 1842 {
1843 g_list_foreach(data->completion->items, (GFunc)g_free, NULL); 1843 g_list_foreach(data->completion->items, (GFunc)g_free, NULL);
1844 g_completion_free(data->completion); 1844 g_completion_free(data->completion);
1845 1845
1846 g_free(data); 1846 g_free(data);
1901 return TRUE; 1901 return TRUE;
1902 1902
1903 if (optmenu != NULL) { 1903 if (optmenu != NULL) {
1904 GList *items; 1904 GList *items;
1905 guint index = 0; 1905 guint index = 0;
1906 gaim_gtk_account_option_menu_set_selected(optmenu, account); 1906 pidgin_account_option_menu_set_selected(optmenu, account);
1907 items = GTK_MENU_SHELL(gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)))->children; 1907 items = GTK_MENU_SHELL(gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)))->children;
1908 1908
1909 do { 1909 do {
1910 if (account == g_object_get_data(G_OBJECT(items->data), "account")) { 1910 if (account == g_object_get_data(G_OBJECT(items->data), "account")) {
1911 /* Set the account in the GUI. */ 1911 /* Set the account in the GUI. */
2059 g_hash_table_foreach(sets, (GHFunc)get_log_set_name, &set_hash_data); 2059 g_hash_table_foreach(sets, (GHFunc)get_log_set_name, &set_hash_data);
2060 g_hash_table_destroy(sets); 2060 g_hash_table_destroy(sets);
2061 } 2061 }
2062 #else 2062 #else
2063 static void 2063 static void
2064 add_completion_list(GaimGtkCompletionData *data) 2064 add_completion_list(PidginCompletionData *data)
2065 { 2065 {
2066 GaimBlistNode *gnode, *cnode, *bnode; 2066 GaimBlistNode *gnode, *cnode, *bnode;
2067 GCompletion *completion; 2067 GCompletion *completion;
2068 GList *item = g_list_append(NULL, NULL); 2068 GList *item = g_list_append(NULL, NULL);
2069 GHashTable *sets; 2069 GHashTable *sets;
2120 { 2120 {
2121 add_completion_list(data); 2121 add_completion_list(data);
2122 } 2122 }
2123 2123
2124 void 2124 void
2125 gaim_gtk_setup_screenname_autocomplete(GtkWidget *entry, GtkWidget *accountopt, gboolean all) 2125 pidgin_setup_screenname_autocomplete(GtkWidget *entry, GtkWidget *accountopt, gboolean all)
2126 { 2126 {
2127 gpointer cb_data = NULL; 2127 gpointer cb_data = NULL;
2128 2128
2129 #ifdef NEW_STYLE_COMPLETION 2129 #ifdef NEW_STYLE_COMPLETION
2130 /* Store the displayed completion value, the screenname, the UTF-8 normalized & casefolded screenname, 2130 /* Store the displayed completion value, the screenname, the UTF-8 normalized & casefolded screenname,
2159 g_object_unref(store); 2159 g_object_unref(store);
2160 2160
2161 gtk_entry_completion_set_text_column(completion, 0); 2161 gtk_entry_completion_set_text_column(completion, 0);
2162 2162
2163 #else /* !NEW_STYLE_COMPLETION */ 2163 #else /* !NEW_STYLE_COMPLETION */
2164 GaimGtkCompletionData *data; 2164 PidginCompletionData *data;
2165 2165
2166 data = g_new0(GaimGtkCompletionData, 1); 2166 data = g_new0(PidginCompletionData, 1);
2167 2167
2168 data->completion = g_completion_new(NULL); 2168 data->completion = g_completion_new(NULL);
2169 data->all = all; 2169 data->all = all;
2170 2170
2171 g_completion_set_compare(data->completion, g_ascii_strncasecmp); 2171 g_completion_set_compare(data->completion, g_ascii_strncasecmp);
2194 GAIM_CALLBACK(repopulate_autocomplete), cb_data); 2194 GAIM_CALLBACK(repopulate_autocomplete), cb_data);
2195 2195
2196 g_signal_connect(G_OBJECT(entry), "destroy", G_CALLBACK(screenname_autocomplete_destroyed_cb), NULL); 2196 g_signal_connect(G_OBJECT(entry), "destroy", G_CALLBACK(screenname_autocomplete_destroyed_cb), NULL);
2197 } 2197 }
2198 2198
2199 void gaim_gtk_set_cursor(GtkWidget *widget, GdkCursorType cursor_type) 2199 void pidgin_set_cursor(GtkWidget *widget, GdkCursorType cursor_type)
2200 { 2200 {
2201 GdkCursor *cursor; 2201 GdkCursor *cursor;
2202 2202
2203 g_return_if_fail(widget != NULL); 2203 g_return_if_fail(widget != NULL);
2204 if (widget->window == NULL) 2204 if (widget->window == NULL)
2213 #else 2213 #else
2214 gdk_flush(); 2214 gdk_flush();
2215 #endif 2215 #endif
2216 } 2216 }
2217 2217
2218 void gaim_gtk_clear_cursor(GtkWidget *widget) 2218 void pidgin_clear_cursor(GtkWidget *widget)
2219 { 2219 {
2220 g_return_if_fail(widget != NULL); 2220 g_return_if_fail(widget != NULL);
2221 if (widget->window == NULL) 2221 if (widget->window == NULL)
2222 return; 2222 return;
2223 2223
2281 2281
2282 filename = g_strdup(gtk_file_selection_get_filename( 2282 filename = g_strdup(gtk_file_selection_get_filename(
2283 GTK_FILE_SELECTION(dialog->icon_filesel))); 2283 GTK_FILE_SELECTION(dialog->icon_filesel)));
2284 2284
2285 /* If they typed in a directory, change there */ 2285 /* If they typed in a directory, change there */
2286 if (gaim_gtk_check_if_dir(filename, 2286 if (pidgin_check_if_dir(filename,
2287 GTK_FILE_SELECTION(dialog->icon_filesel))) 2287 GTK_FILE_SELECTION(dialog->icon_filesel)))
2288 { 2288 {
2289 g_free(filename); 2289 g_free(filename);
2290 return; 2290 return;
2291 } 2291 }
2369 g_free(size); 2369 g_free(size);
2370 g_free(markup); 2370 g_free(markup);
2371 } 2371 }
2372 2372
2373 2373
2374 GtkWidget *gaim_gtk_buddy_icon_chooser_new(GtkWindow *parent, void(*callback)(const char *, gpointer), gpointer data) { 2374 GtkWidget *pidgin_buddy_icon_chooser_new(GtkWindow *parent, void(*callback)(const char *, gpointer), gpointer data) {
2375 struct _icon_chooser *dialog = g_new0(struct _icon_chooser, 1); 2375 struct _icon_chooser *dialog = g_new0(struct _icon_chooser, 1);
2376 2376
2377 #if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ 2377 #if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */
2378 GtkWidget *hbox; 2378 GtkWidget *hbox;
2379 GtkWidget *tv; 2379 GtkWidget *tv;
2465 return FALSE; 2465 return FALSE;
2466 } 2466 }
2467 #endif 2467 #endif
2468 2468
2469 char * 2469 char *
2470 gaim_gtk_convert_buddy_icon(GaimPlugin *plugin, const char *path) 2470 pidgin_convert_buddy_icon(GaimPlugin *plugin, const char *path)
2471 { 2471 {
2472 GaimPluginProtocolInfo *prpl_info; 2472 GaimPluginProtocolInfo *prpl_info;
2473 #if GTK_CHECK_VERSION(2,2,0) 2473 #if GTK_CHECK_VERSION(2,2,0)
2474 char **prpl_formats; 2474 char **prpl_formats;
2475 int width, height; 2475 int width, height;
2823 2823
2824 return pixbuf; 2824 return pixbuf;
2825 } 2825 }
2826 #endif /* ! Gtk 2.6.0 */ 2826 #endif /* ! Gtk 2.6.0 */
2827 2827
2828 void gaim_gtk_set_custom_buddy_icon(GaimAccount *account, const char *who, const char *filename) 2828 void pidgin_set_custom_buddy_icon(GaimAccount *account, const char *who, const char *filename)
2829 { 2829 {
2830 GaimConversation *conv; 2830 GaimConversation *conv;
2831 GaimBuddy *buddy; 2831 GaimBuddy *buddy;
2832 GaimBlistNode *node; 2832 GaimBlistNode *node;
2833 char *path = NULL; 2833 char *path = NULL;
2848 } 2848 }
2849 2849
2850 if (filename) { 2850 if (filename) {
2851 char *newfile; 2851 char *newfile;
2852 2852
2853 newfile = gaim_gtk_convert_buddy_icon(gaim_find_prpl(gaim_account_get_protocol_id(account)), 2853 newfile = pidgin_convert_buddy_icon(gaim_find_prpl(gaim_account_get_protocol_id(account)),
2854 filename); 2854 filename);
2855 path = gaim_buddy_icons_get_full_path(newfile); 2855 path = gaim_buddy_icons_get_full_path(newfile);
2856 g_free(newfile); 2856 g_free(newfile);
2857 } 2857 }
2858 2858
2867 /* Update the buddylist */ 2867 /* Update the buddylist */
2868 if (buddy) 2868 if (buddy)
2869 gaim_blist_update_buddy_icon(buddy); 2869 gaim_blist_update_buddy_icon(buddy);
2870 } 2870 }
2871 2871
2872 char *gaim_gtk_make_pretty_arrows(const char *str) 2872 char *pidgin_make_pretty_arrows(const char *str)
2873 { 2873 {
2874 char *ret; 2874 char *ret;
2875 char **split = g_strsplit(str, "->", -1); 2875 char **split = g_strsplit(str, "->", -1);
2876 ret = g_strjoinv("\342\207\250", split); 2876 ret = g_strjoinv("\342\207\250", split);
2877 g_strfreev(split); 2877 g_strfreev(split);
2882 g_strfreev(split); 2882 g_strfreev(split);
2883 2883
2884 return ret; 2884 return ret;
2885 } 2885 }
2886 2886
2887 void gaim_gtk_set_urgent(GtkWindow *window, gboolean urgent) 2887 void pidgin_set_urgent(GtkWindow *window, gboolean urgent)
2888 { 2888 {
2889 #if GTK_CHECK_VERSION(2,8,0) 2889 #if GTK_CHECK_VERSION(2,8,0)
2890 gtk_window_set_urgency_hint(window, urgent); 2890 gtk_window_set_urgency_hint(window, urgent);
2891 #elif defined _WIN32 2891 #elif defined _WIN32
2892 gtkwgaim_window_flash(window, urgent); 2892 gtkwgaim_window_flash(window, urgent);
2916 } 2916 }
2917 2917
2918 GSList *minidialogs = NULL; 2918 GSList *minidialogs = NULL;
2919 2919
2920 static void * 2920 static void *
2921 gaim_gtk_utils_get_handle() 2921 pidgin_utils_get_handle()
2922 { 2922 {
2923 static int handle; 2923 static int handle;
2924 2924
2925 return &handle; 2925 return &handle;
2926 } 2926 }
2938 static void alert_killed_cb(GtkWidget *widget) 2938 static void alert_killed_cb(GtkWidget *widget)
2939 { 2939 {
2940 minidialogs = g_slist_remove(minidialogs, widget); 2940 minidialogs = g_slist_remove(minidialogs, widget);
2941 } 2941 }
2942 2942
2943 void *gaim_gtk_make_mini_dialog(GaimConnection *gc, const char *icon_name, 2943 void *pidgin_make_mini_dialog(GaimConnection *gc, const char *icon_name,
2944 const char *primary, const char *secondary, 2944 const char *primary, const char *secondary,
2945 void *user_data, ...) 2945 void *user_data, ...)
2946 { 2946 {
2947 GtkWidget *vbox; 2947 GtkWidget *vbox;
2948 GtkWidget *hbox; 2948 GtkWidget *hbox;
2969 g_signal_connect(G_OBJECT(vbox), "destroy", G_CALLBACK(alert_killed_cb), NULL); 2969 g_signal_connect(G_OBJECT(vbox), "destroy", G_CALLBACK(alert_killed_cb), NULL);
2970 2970
2971 if (first_call) { 2971 if (first_call) {
2972 first_call = FALSE; 2972 first_call = FALSE;
2973 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", 2973 gaim_signal_connect(gaim_connections_get_handle(), "signed-off",
2974 gaim_gtk_utils_get_handle(), 2974 pidgin_utils_get_handle(),
2975 GAIM_CALLBACK(connection_signed_off_cb), NULL); 2975 GAIM_CALLBACK(connection_signed_off_cb), NULL);
2976 } 2976 }
2977 2977
2978 hbox = gtk_hbox_new(FALSE, 0); 2978 hbox = gtk_hbox_new(FALSE, 0);
2979 gtk_container_add(GTK_CONTAINER(vbox), hbox); 2979 gtk_container_add(GTK_CONTAINER(vbox), hbox);
3037 * "name" column of the buddy list (because the GtkTreeModel does not 3037 * "name" column of the buddy list (because the GtkTreeModel does not
3038 * contain the screen name in a non-markedup format). But the alternative 3038 * contain the screen name in a non-markedup format). But the alternative
3039 * is to add an extra column to the GtkTreeModel. And this function is 3039 * is to add an extra column to the GtkTreeModel. And this function is
3040 * used rarely, so it shouldn't matter TOO much. 3040 * used rarely, so it shouldn't matter TOO much.
3041 */ 3041 */
3042 gboolean gaim_gtk_tree_view_search_equal_func(GtkTreeModel *model, gint column, 3042 gboolean pidgin_tree_view_search_equal_func(GtkTreeModel *model, gint column,
3043 const gchar *key, GtkTreeIter *iter, gpointer data) 3043 const gchar *key, GtkTreeIter *iter, gpointer data)
3044 { 3044 {
3045 gchar *enteredstring; 3045 gchar *enteredstring;
3046 gchar *tmp; 3046 gchar *tmp;
3047 gchar *withmarkup; 3047 gchar *withmarkup;