Mercurial > pidgin.yaz
comparison pidgin/gtkconv.c @ 27724:26f55eb6ab59
propagate from branch 'im.pidgin.pidgin' (head 1cb036aecbbe359226e69874379d39ce74c8daf6)
to branch 'im.pidgin.pidgin.yaz' (head 99515d90725804d37c9baeec606e2f4e2ec5a61f)
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Wed, 19 Sep 2007 08:27:28 +0000 |
parents | 16f887f25044 af320e03fa63 |
children | d1ed74d50a9c |
comparison
equal
deleted
inserted
replaced
20541:a9022965162b | 27724:26f55eb6ab59 |
---|---|
109 #define MIN_COLOR_CONTRAST 200 | 109 #define MIN_COLOR_CONTRAST 200 |
110 | 110 |
111 #define NUM_NICK_COLORS 220 | 111 #define NUM_NICK_COLORS 220 |
112 static GdkColor *nick_colors = NULL; | 112 static GdkColor *nick_colors = NULL; |
113 static guint nbr_nick_colors; | 113 static guint nbr_nick_colors; |
114 | |
115 /* yaz. If you want to use shortcut keys that may conflict with | |
116 inputmethods, change this to 1. */ | |
117 #define ENABLE_SHORTCUT 0 | |
114 | 118 |
115 typedef struct { | 119 typedef struct { |
116 GtkWidget *window; | 120 GtkWidget *window; |
117 | 121 |
118 GtkWidget *entry; | 122 GtkWidget *entry; |
2945 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, | 2949 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, |
2946 0, "<StockItem>", PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW }, | 2950 0, "<StockItem>", PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW }, |
2947 | 2951 |
2948 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>", NULL }, | 2952 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>", NULL }, |
2949 | 2953 |
2954 #if ENABLE_SHORTCUT | |
2950 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, | 2955 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, |
2951 "<StockItem>", GTK_STOCK_FIND }, | 2956 "<StockItem>", GTK_STOCK_FIND }, |
2957 #else | |
2958 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, | |
2959 "<Item>" }, | |
2960 #endif | |
2952 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, "<Item>", NULL }, | 2961 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, "<Item>", NULL }, |
2953 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, | 2962 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, |
2954 "<StockItem>", GTK_STOCK_SAVE_AS }, | 2963 "<StockItem>", GTK_STOCK_SAVE_AS }, |
2964 #if ENABLE_SHORTCUT | |
2955 { N_("/Conversation/Clea_r Scrollback"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR }, | 2965 { N_("/Conversation/Clea_r Scrollback"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR }, |
2956 | 2966 #else |
2967 { N_("/Conversation/Clea_r Scrollback"), NULL, menu_clear_cb, 0, "<Item>" }, | |
2968 #endif | |
2957 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>", NULL }, | 2969 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>", NULL }, |
2958 | 2970 |
2959 { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", PIDGIN_STOCK_TOOLBAR_SEND_FILE }, | 2971 { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", PIDGIN_STOCK_TOOLBAR_SEND_FILE }, |
2960 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, | 2972 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, |
2961 0, "<Item>", NULL }, | 2973 0, "<Item>", NULL }, |
2974 #if ENABLE_SHORTCUT | |
2962 { N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0, | 2975 { N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0, |
2963 "<StockItem>", PIDGIN_STOCK_TOOLBAR_USER_INFO }, | 2976 "<StockItem>", PIDGIN_STOCK_TOOLBAR_USER_INFO }, |
2977 #else | |
2978 { N_("/Conversation/_Get Info"), NULL, menu_get_info_cb, 0, | |
2979 "<StockItem>", PIDGIN_STOCK_TOOLBAR_USER_INFO }, | |
2980 #endif | |
2964 { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, | 2981 { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, |
2965 "<Item>", NULL }, | 2982 "<Item>", NULL }, |
2966 { N_("/Conversation/M_ore"), NULL, NULL, 0, "<Branch>", NULL }, | 2983 { N_("/Conversation/M_ore"), NULL, NULL, 0, "<Branch>", NULL }, |
2967 | 2984 |
2968 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>", NULL }, | 2985 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>", NULL }, |
3632 | 3649 |
3633 if (win->menu.send_to != NULL) | 3650 if (win->menu.send_to != NULL) |
3634 gtk_widget_destroy(win->menu.send_to); | 3651 gtk_widget_destroy(win->menu.send_to); |
3635 | 3652 |
3636 /* Build the Send To menu */ | 3653 /* Build the Send To menu */ |
3654 | |
3655 #if ENABLE_SHORTCUT | |
3637 win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("_Send To")); | 3656 win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("_Send To")); |
3657 #else | |
3658 win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("Send To")); //to free Alt-s. intentional. --yaz | |
3659 #endif | |
3638 gtk_widget_show(win->menu.send_to); | 3660 gtk_widget_show(win->menu.send_to); |
3639 | 3661 |
3640 menu = gtk_menu_new(); | 3662 menu = gtk_menu_new(); |
3641 gtk_menu_shell_insert(GTK_MENU_SHELL(win->menu.menubar), | 3663 gtk_menu_shell_insert(GTK_MENU_SHELL(win->menu.menubar), |
3642 win->menu.send_to, 2); | 3664 win->menu.send_to, 2); |
4105 PurplePluginProtocolInfo *prpl_info = NULL; | 4127 PurplePluginProtocolInfo *prpl_info = NULL; |
4106 PurpleConnection *gc; | 4128 PurpleConnection *gc; |
4107 PurpleConversation *conv = gtkconv->active_conv; | 4129 PurpleConversation *conv = gtkconv->active_conv; |
4108 PidginChatPane *gtkchat; | 4130 PidginChatPane *gtkchat; |
4109 char *new_topic; | 4131 char *new_topic; |
4110 const char *current_topic; | 4132 // const char *current_topic; |
4133 char dummy[] = "No Topic"; | |
4134 char *current_topic = NULL; | |
4111 | 4135 |
4112 gc = purple_conversation_get_gc(conv); | 4136 gc = purple_conversation_get_gc(conv); |
4113 | 4137 |
4114 if(!gc || !(prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl))) | 4138 if(!gc || !(prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl))) |
4115 return; | 4139 return; |
4118 return; | 4142 return; |
4119 | 4143 |
4120 gtkconv = PIDGIN_CONVERSATION(conv); | 4144 gtkconv = PIDGIN_CONVERSATION(conv); |
4121 gtkchat = gtkconv->u.chat; | 4145 gtkchat = gtkconv->u.chat; |
4122 new_topic = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text))); | 4146 new_topic = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text))); |
4147 // purple_debug_info("yaz gtkconv", "new_topic=%s\n", new_topic); | |
4123 current_topic = purple_conv_chat_get_topic(PURPLE_CONV_CHAT(conv)); | 4148 current_topic = purple_conv_chat_get_topic(PURPLE_CONV_CHAT(conv)); |
4149 | |
4150 if(!current_topic) | |
4151 current_topic = dummy; | |
4152 // purple_debug_info("yaz gtkconv", "current_topic=%s\n", current_topic); | |
4124 | 4153 |
4125 if(current_topic && !g_utf8_collate(new_topic, current_topic)){ | 4154 if(current_topic && !g_utf8_collate(new_topic, current_topic)){ |
4126 g_free(new_topic); | 4155 g_free(new_topic); |
4127 return; | 4156 return; |
4128 } | 4157 } |
6492 | 6521 |
6493 if ((fields & PIDGIN_CONV_COLORIZE_TITLE) || | 6522 if ((fields & PIDGIN_CONV_COLORIZE_TITLE) || |
6494 (fields & PIDGIN_CONV_SET_TITLE) || | 6523 (fields & PIDGIN_CONV_SET_TITLE) || |
6495 (fields & PIDGIN_CONV_TOPIC)) | 6524 (fields & PIDGIN_CONV_TOPIC)) |
6496 { | 6525 { |
6497 char *title; | 6526 char *title, *title_tmp; |
6498 PurpleConvIm *im = NULL; | 6527 PurpleConvIm *im = NULL; |
6499 PurpleAccount *account = purple_conversation_get_account(conv); | 6528 PurpleAccount *account = purple_conversation_get_account(conv); |
6500 PurpleBuddy *buddy = NULL; | 6529 PurpleBuddy *buddy = NULL; |
6501 PurplePresence *p = NULL; | 6530 PurplePresence *p = NULL; |
6502 char *markup = NULL; | 6531 char *markup = NULL; |
6503 AtkObject *accessibility_obj; | 6532 AtkObject *accessibility_obj; |
6533 gboolean ellipsis = FALSE; | |
6504 /* I think this is a little longer than it needs to be but I'm lazy. */ | 6534 /* I think this is a little longer than it needs to be but I'm lazy. */ |
6505 char *style; | 6535 char *style; |
6506 | 6536 |
6507 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) | 6537 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) |
6508 im = PURPLE_CONV_IM(conv); | 6538 im = PURPLE_CONV_IM(conv); |
6564 style = "color=\"#888a85\" weight=\"bold\""; | 6594 style = "color=\"#888a85\" weight=\"bold\""; |
6565 } else { | 6595 } else { |
6566 style = ""; | 6596 style = ""; |
6567 } | 6597 } |
6568 | 6598 |
6599 // nosuke's tab width patch | |
6600 if ((purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/tab_side") == (GTK_POS_LEFT|8) | |
6601 || purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/tab_side") == (GTK_POS_RIGHT|8)) | |
6602 && purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/trim_vertical_tabs")) | |
6603 ellipsis = TRUE; | |
6604 | |
6605 if (ellipsis) | |
6606 title_tmp = pidgin_gtk_ellipsis_text(gtkconv->tab_label, title, 60, "..."); | |
6607 else | |
6608 title_tmp = title; | |
6609 | |
6610 | |
6569 if (*style != '\0') | 6611 if (*style != '\0') |
6570 { | 6612 { |
6571 char *html_title,*label; | 6613 char *html_title,*label; |
6572 | 6614 |
6573 html_title = g_markup_escape_text(title, -1); | 6615 html_title = g_markup_escape_text(title_tmp, -1); |
6574 label = g_strdup_printf("<span %s>%s</span>", | 6616 label = g_strdup_printf("<span %s>%s</span>", |
6575 style, html_title); | 6617 style, html_title); |
6576 g_free(html_title); | 6618 g_free(html_title); |
6577 gtk_label_set_markup(GTK_LABEL(gtkconv->tab_label), label); | 6619 gtk_label_set_markup(GTK_LABEL(gtkconv->tab_label), label); |
6578 g_free(label); | 6620 g_free(label); |
6579 } | 6621 } |
6580 else | 6622 else |
6581 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); | 6623 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title_tmp); |
6582 | 6624 |
6583 if (pidgin_conv_window_is_active_conversation(conv)) | 6625 if (pidgin_conv_window_is_active_conversation(conv)) |
6584 update_typing_icon(gtkconv); | 6626 update_typing_icon(gtkconv); |
6585 | 6627 |
6586 gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title); | 6628 gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title); |
6946 } | 6988 } |
6947 | 6989 |
6948 return page_num; | 6990 return page_num; |
6949 } | 6991 } |
6950 | 6992 |
6993 //nosuke | |
6994 static void | |
6995 trim_vertical_tabs_pref_cb(const char *name, PurplePrefType type, | |
6996 gconstpointer value, gpointer data) | |
6997 { | |
6998 GList *l; | |
6999 PurpleConversation *conv; | |
7000 | |
7001 for (l = purple_get_conversations(); l != NULL; l = l->next) { | |
7002 conv = (PurpleConversation *)l->data; | |
7003 | |
7004 if (!PIDGIN_IS_PIDGIN_CONVERSATION(conv)) | |
7005 continue; | |
7006 | |
7007 pidgin_conv_update_fields(conv, PIDGIN_CONV_SET_TITLE); | |
7008 } | |
7009 } | |
7010 | |
6951 static void | 7011 static void |
6952 close_on_tabs_pref_cb(const char *name, PurplePrefType type, | 7012 close_on_tabs_pref_cb(const char *name, PurplePrefType type, |
6953 gconstpointer value, gpointer data) | 7013 gconstpointer value, gpointer data) |
6954 { | 7014 { |
6955 GList *l; | 7015 GList *l; |
7015 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(gtkwin->notebook), pos&~8); | 7075 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(gtkwin->notebook), pos&~8); |
7016 for (gtkconvs = gtkwin->gtkconvs; gtkconvs != NULL; gtkconvs = gtkconvs->next) { | 7076 for (gtkconvs = gtkwin->gtkconvs; gtkconvs != NULL; gtkconvs = gtkconvs->next) { |
7017 pidgin_conv_tab_pack(gtkwin, gtkconvs->data); | 7077 pidgin_conv_tab_pack(gtkwin, gtkconvs->data); |
7018 } | 7078 } |
7019 } | 7079 } |
7080 trim_vertical_tabs_pref_cb(name, type, value, data); | |
7020 } | 7081 } |
7021 | 7082 |
7022 static void | 7083 static void |
7023 show_timestamps_pref_cb(const char *name, PurplePrefType type, | 7084 show_timestamps_pref_cb(const char *name, PurplePrefType type, |
7024 gconstpointer value, gpointer data) | 7085 gconstpointer value, gpointer data) |
7445 | 7506 |
7446 /* Conversations */ | 7507 /* Conversations */ |
7447 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/conversations"); | 7508 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/conversations"); |
7448 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/use_smooth_scrolling", TRUE); | 7509 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/use_smooth_scrolling", TRUE); |
7449 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/close_on_tabs", TRUE); | 7510 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/close_on_tabs", TRUE); |
7511 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/trim_vertical_tabs", FALSE); | |
7450 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/send_bold", FALSE); | 7512 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/send_bold", FALSE); |
7451 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/send_italic", FALSE); | 7513 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/send_italic", FALSE); |
7452 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline", FALSE); | 7514 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline", FALSE); |
7453 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/spellcheck", TRUE); | 7515 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/spellcheck", TRUE); |
7454 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/show_incoming_formatting", TRUE); | 7516 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/show_incoming_formatting", TRUE); |
7498 #endif | 7560 #endif |
7499 | 7561 |
7500 /* Connect callbacks. */ | 7562 /* Connect callbacks. */ |
7501 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/close_on_tabs", | 7563 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/close_on_tabs", |
7502 close_on_tabs_pref_cb, NULL); | 7564 close_on_tabs_pref_cb, NULL); |
7565 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/trim_vertical_tabs", | |
7566 trim_vertical_tabs_pref_cb, NULL); | |
7503 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/show_timestamps", | 7567 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/show_timestamps", |
7504 show_timestamps_pref_cb, NULL); | 7568 show_timestamps_pref_cb, NULL); |
7505 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar", | 7569 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar", |
7506 show_formatting_toolbar_pref_cb, NULL); | 7570 show_formatting_toolbar_pref_cb, NULL); |
7507 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/spellcheck", | 7571 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/spellcheck", |