Mercurial > pidgin.yaz
comparison pidgin/gtkconv.c @ 25542:92d8c9b08dab
propagate from branch 'im.pidgin.pidgin' (head 90df17ab44d01f7f8f963d36fefb9eae3ec868cf)
to branch 'im.pidgin.pidgin.yaz' (head ef6f65e1b1b0e5c23f07cf062691dcf6e5ee163c)
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Thu, 23 Aug 2007 06:53:06 +0000 |
parents | cbc08c427db6 411b5a604a17 |
children | 7f8cf35fc99b |
comparison
equal
deleted
inserted
replaced
19368:ec0ef7f0a12d | 25542:92d8c9b08dab |
---|---|
105 #define MIN_COLOR_CONTRAST 200 | 105 #define MIN_COLOR_CONTRAST 200 |
106 | 106 |
107 #define NUM_NICK_COLORS 220 | 107 #define NUM_NICK_COLORS 220 |
108 static GdkColor *nick_colors = NULL; | 108 static GdkColor *nick_colors = NULL; |
109 static guint nbr_nick_colors; | 109 static guint nbr_nick_colors; |
110 | |
111 /* yaz. If you want to use shortcut keys that may conflict with | |
112 inputmethods, change this to 1. */ | |
113 #define ENABLE_SHORTCUT 0 | |
110 | 114 |
111 typedef struct { | 115 typedef struct { |
112 GtkWidget *window; | 116 GtkWidget *window; |
113 | 117 |
114 GtkWidget *entry; | 118 GtkWidget *entry; |
2794 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, | 2798 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, |
2795 0, "<StockItem>", PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW }, | 2799 0, "<StockItem>", PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW }, |
2796 | 2800 |
2797 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>", NULL }, | 2801 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>", NULL }, |
2798 | 2802 |
2803 #if ENABLE_SHORTCUT | |
2799 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, | 2804 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, |
2800 "<StockItem>", GTK_STOCK_FIND }, | 2805 "<StockItem>", GTK_STOCK_FIND }, |
2806 #else | |
2807 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, | |
2808 "<Item>" }, | |
2809 #endif | |
2801 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, "<Item>", NULL }, | 2810 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, "<Item>", NULL }, |
2802 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, | 2811 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, |
2803 "<StockItem>", GTK_STOCK_SAVE_AS }, | 2812 "<StockItem>", GTK_STOCK_SAVE_AS }, |
2813 #if ENABLE_SHORTCUT | |
2804 { N_("/Conversation/Clea_r Scrollback"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR }, | 2814 { N_("/Conversation/Clea_r Scrollback"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR }, |
2805 | 2815 #else |
2816 { N_("/Conversation/Clea_r Scrollback"), NULL, menu_clear_cb, 0, "<Item>" }, | |
2817 #endif | |
2806 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>", NULL }, | 2818 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>", NULL }, |
2807 | 2819 |
2808 { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", PIDGIN_STOCK_TOOLBAR_SEND_FILE }, | 2820 { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", PIDGIN_STOCK_TOOLBAR_SEND_FILE }, |
2809 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, | 2821 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, |
2810 0, "<Item>", NULL }, | 2822 0, "<Item>", NULL }, |
2823 #if ENABLE_SHORTCUT | |
2811 { N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0, | 2824 { N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0, |
2812 "<StockItem>", PIDGIN_STOCK_TOOLBAR_USER_INFO }, | 2825 "<StockItem>", PIDGIN_STOCK_TOOLBAR_USER_INFO }, |
2826 #else | |
2827 { N_("/Conversation/_Get Info"), NULL, menu_get_info_cb, 0, | |
2828 "<StockItem>", PIDGIN_STOCK_TOOLBAR_USER_INFO }, | |
2829 #endif | |
2813 { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, | 2830 { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, |
2814 "<Item>", NULL }, | 2831 "<Item>", NULL }, |
2815 { N_("/Conversation/M_ore"), NULL, NULL, 0, "<Branch>", NULL }, | 2832 { N_("/Conversation/M_ore"), NULL, NULL, 0, "<Branch>", NULL }, |
2816 | 2833 |
2817 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>", NULL }, | 2834 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>", NULL }, |
3513 | 3530 |
3514 if (win->menu.send_to != NULL) | 3531 if (win->menu.send_to != NULL) |
3515 gtk_widget_destroy(win->menu.send_to); | 3532 gtk_widget_destroy(win->menu.send_to); |
3516 | 3533 |
3517 /* Build the Send To menu */ | 3534 /* Build the Send To menu */ |
3535 | |
3536 #if ENABLE_SHORTCUT | |
3518 win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("_Send To")); | 3537 win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("_Send To")); |
3538 #else | |
3539 win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("Send To")); //to free Alt-s. intentional. --yaz | |
3540 #endif | |
3519 gtk_widget_show(win->menu.send_to); | 3541 gtk_widget_show(win->menu.send_to); |
3520 | 3542 |
3521 menu = gtk_menu_new(); | 3543 menu = gtk_menu_new(); |
3522 gtk_menu_shell_insert(GTK_MENU_SHELL(win->menu.menubar), | 3544 gtk_menu_shell_insert(GTK_MENU_SHELL(win->menu.menubar), |
3523 win->menu.send_to, 2); | 3545 win->menu.send_to, 2); |
3987 PurplePluginProtocolInfo *prpl_info = NULL; | 4009 PurplePluginProtocolInfo *prpl_info = NULL; |
3988 PurpleConnection *gc; | 4010 PurpleConnection *gc; |
3989 PurpleConversation *conv = gtkconv->active_conv; | 4011 PurpleConversation *conv = gtkconv->active_conv; |
3990 PidginChatPane *gtkchat; | 4012 PidginChatPane *gtkchat; |
3991 char *new_topic; | 4013 char *new_topic; |
3992 const char *current_topic; | 4014 // const char *current_topic; |
4015 char dummy[] = "No Topic"; | |
4016 char *current_topic = NULL; | |
3993 | 4017 |
3994 gc = purple_conversation_get_gc(conv); | 4018 gc = purple_conversation_get_gc(conv); |
3995 | 4019 |
3996 if(!gc || !(prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl))) | 4020 if(!gc || !(prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl))) |
3997 return; | 4021 return; |
4000 return; | 4024 return; |
4001 | 4025 |
4002 gtkconv = PIDGIN_CONVERSATION(conv); | 4026 gtkconv = PIDGIN_CONVERSATION(conv); |
4003 gtkchat = gtkconv->u.chat; | 4027 gtkchat = gtkconv->u.chat; |
4004 new_topic = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text))); | 4028 new_topic = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text))); |
4029 // purple_debug_info("yaz gtkconv", "new_topic=%s\n", new_topic); | |
4005 current_topic = purple_conv_chat_get_topic(PURPLE_CONV_CHAT(conv)); | 4030 current_topic = purple_conv_chat_get_topic(PURPLE_CONV_CHAT(conv)); |
4031 | |
4032 if(!current_topic) | |
4033 current_topic = dummy; | |
4034 // purple_debug_info("yaz gtkconv", "current_topic=%s\n", current_topic); | |
4006 | 4035 |
4007 if(current_topic && !g_utf8_collate(new_topic, current_topic)){ | 4036 if(current_topic && !g_utf8_collate(new_topic, current_topic)){ |
4008 g_free(new_topic); | 4037 g_free(new_topic); |
4009 return; | 4038 return; |
4010 } | 4039 } |
6269 | 6298 |
6270 if ((fields & PIDGIN_CONV_COLORIZE_TITLE) || | 6299 if ((fields & PIDGIN_CONV_COLORIZE_TITLE) || |
6271 (fields & PIDGIN_CONV_SET_TITLE) || | 6300 (fields & PIDGIN_CONV_SET_TITLE) || |
6272 (fields & PIDGIN_CONV_TOPIC)) | 6301 (fields & PIDGIN_CONV_TOPIC)) |
6273 { | 6302 { |
6274 char *title; | 6303 char *title, *title_tmp; |
6275 PurpleConvIm *im = NULL; | 6304 PurpleConvIm *im = NULL; |
6276 PurpleAccount *account = purple_conversation_get_account(conv); | 6305 PurpleAccount *account = purple_conversation_get_account(conv); |
6277 PurpleBuddy *buddy = NULL; | 6306 PurpleBuddy *buddy = NULL; |
6278 PurplePresence *p = NULL; | 6307 PurplePresence *p = NULL; |
6279 char *markup = NULL; | 6308 char *markup = NULL; |
6280 AtkObject *accessibility_obj; | 6309 AtkObject *accessibility_obj; |
6310 gboolean ellipsis = FALSE; | |
6281 /* I think this is a little longer than it needs to be but I'm lazy. */ | 6311 /* I think this is a little longer than it needs to be but I'm lazy. */ |
6282 char *style; | 6312 char *style; |
6283 | 6313 |
6284 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) | 6314 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) |
6285 im = PURPLE_CONV_IM(conv); | 6315 im = PURPLE_CONV_IM(conv); |
6341 style = "color=\"#888a85\" weight=\"bold\""; | 6371 style = "color=\"#888a85\" weight=\"bold\""; |
6342 } else { | 6372 } else { |
6343 style = ""; | 6373 style = ""; |
6344 } | 6374 } |
6345 | 6375 |
6376 // nosuke's tab width patch | |
6377 if ((purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/tab_side") == (GTK_POS_LEFT|8) | |
6378 || purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/tab_side") == (GTK_POS_RIGHT|8)) | |
6379 && purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/trim_vertical_tabs")) | |
6380 ellipsis = TRUE; | |
6381 | |
6382 if (ellipsis) | |
6383 title_tmp = pidgin_gtk_ellipsis_text(gtkconv->tab_label, title, 60, "..."); | |
6384 else | |
6385 title_tmp = title; | |
6386 | |
6387 | |
6346 if (*style != '\0') | 6388 if (*style != '\0') |
6347 { | 6389 { |
6348 char *html_title,*label; | 6390 char *html_title,*label; |
6349 | 6391 |
6350 html_title = g_markup_escape_text(title, -1); | 6392 html_title = g_markup_escape_text(title_tmp, -1); |
6351 label = g_strdup_printf("<span %s>%s</span>", | 6393 label = g_strdup_printf("<span %s>%s</span>", |
6352 style, html_title); | 6394 style, html_title); |
6353 g_free(html_title); | 6395 g_free(html_title); |
6354 gtk_label_set_markup(GTK_LABEL(gtkconv->tab_label), label); | 6396 gtk_label_set_markup(GTK_LABEL(gtkconv->tab_label), label); |
6355 g_free(label); | 6397 g_free(label); |
6356 } | 6398 } |
6357 else | 6399 else |
6358 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); | 6400 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title_tmp); |
6359 | 6401 |
6360 if (pidgin_conv_window_is_active_conversation(conv)) | 6402 if (pidgin_conv_window_is_active_conversation(conv)) |
6361 update_typing_icon(gtkconv); | 6403 update_typing_icon(gtkconv); |
6362 | 6404 |
6363 gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title); | 6405 gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title); |
6710 } | 6752 } |
6711 | 6753 |
6712 return page_num; | 6754 return page_num; |
6713 } | 6755 } |
6714 | 6756 |
6757 //nosuke | |
6758 static void | |
6759 trim_vertical_tabs_pref_cb(const char *name, PurplePrefType type, | |
6760 gconstpointer value, gpointer data) | |
6761 { | |
6762 GList *l; | |
6763 PurpleConversation *conv; | |
6764 | |
6765 for (l = purple_get_conversations(); l != NULL; l = l->next) { | |
6766 conv = (PurpleConversation *)l->data; | |
6767 | |
6768 if (!PIDGIN_IS_PIDGIN_CONVERSATION(conv)) | |
6769 continue; | |
6770 | |
6771 pidgin_conv_update_fields(conv, PIDGIN_CONV_SET_TITLE); | |
6772 } | |
6773 } | |
6774 | |
6715 static void | 6775 static void |
6716 close_on_tabs_pref_cb(const char *name, PurplePrefType type, | 6776 close_on_tabs_pref_cb(const char *name, PurplePrefType type, |
6717 gconstpointer value, gpointer data) | 6777 gconstpointer value, gpointer data) |
6718 { | 6778 { |
6719 GList *l; | 6779 GList *l; |
6779 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(gtkwin->notebook), pos&~8); | 6839 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(gtkwin->notebook), pos&~8); |
6780 for (gtkconvs = gtkwin->gtkconvs; gtkconvs != NULL; gtkconvs = gtkconvs->next) { | 6840 for (gtkconvs = gtkwin->gtkconvs; gtkconvs != NULL; gtkconvs = gtkconvs->next) { |
6781 pidgin_conv_tab_pack(gtkwin, gtkconvs->data); | 6841 pidgin_conv_tab_pack(gtkwin, gtkconvs->data); |
6782 } | 6842 } |
6783 } | 6843 } |
6844 trim_vertical_tabs_pref_cb(name, type, value, data); | |
6784 } | 6845 } |
6785 | 6846 |
6786 static void | 6847 static void |
6787 show_timestamps_pref_cb(const char *name, PurplePrefType type, | 6848 show_timestamps_pref_cb(const char *name, PurplePrefType type, |
6788 gconstpointer value, gpointer data) | 6849 gconstpointer value, gpointer data) |
7153 | 7214 |
7154 /* Conversations */ | 7215 /* Conversations */ |
7155 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/conversations"); | 7216 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/conversations"); |
7156 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/use_smooth_scrolling", TRUE); | 7217 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/use_smooth_scrolling", TRUE); |
7157 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/close_on_tabs", TRUE); | 7218 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/close_on_tabs", TRUE); |
7219 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/trim_vertical_tabs", FALSE); | |
7158 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/send_bold", FALSE); | 7220 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/send_bold", FALSE); |
7159 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/send_italic", FALSE); | 7221 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/send_italic", FALSE); |
7160 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline", FALSE); | 7222 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline", FALSE); |
7161 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/spellcheck", TRUE); | 7223 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/spellcheck", TRUE); |
7162 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/show_incoming_formatting", TRUE); | 7224 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/show_incoming_formatting", TRUE); |
7205 #endif | 7267 #endif |
7206 | 7268 |
7207 /* Connect callbacks. */ | 7269 /* Connect callbacks. */ |
7208 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/close_on_tabs", | 7270 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/close_on_tabs", |
7209 close_on_tabs_pref_cb, NULL); | 7271 close_on_tabs_pref_cb, NULL); |
7272 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/trim_vertical_tabs", | |
7273 trim_vertical_tabs_pref_cb, NULL); | |
7210 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/show_timestamps", | 7274 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/show_timestamps", |
7211 show_timestamps_pref_cb, NULL); | 7275 show_timestamps_pref_cb, NULL); |
7212 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar", | 7276 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar", |
7213 show_formatting_toolbar_pref_cb, NULL); | 7277 show_formatting_toolbar_pref_cb, NULL); |
7214 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/spellcheck", | 7278 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/spellcheck", |