| 184 static gboolean color_is_visible(GdkColor foreground, GdkColor background, int color_contrast, int brightness_contrast); |
184 static gboolean color_is_visible(GdkColor foreground, GdkColor background, int color_contrast, int brightness_contrast); |
| 185 static void pidgin_conv_update_fields(PurpleConversation *conv, PidginConvFields fields); |
185 static void pidgin_conv_update_fields(PurpleConversation *conv, PidginConvFields fields); |
| 186 static void focus_out_from_menubar(GtkWidget *wid, PidginWindow *win); |
186 static void focus_out_from_menubar(GtkWidget *wid, PidginWindow *win); |
| 187 static void pidgin_conv_tab_pack(PidginWindow *win, PidginConversation *gtkconv); |
187 static void pidgin_conv_tab_pack(PidginWindow *win, PidginConversation *gtkconv); |
| 188 static gboolean infopane_press_cb(GtkWidget *widget, GdkEventButton *e, PidginConversation *conv); |
188 static gboolean infopane_press_cb(GtkWidget *widget, GdkEventButton *e, PidginConversation *conv); |
| |
189 static gboolean alias_double_click_cb(GtkWidget *widget, GdkEventButton *event, PidginConversation *gtkconv); |
| 189 |
190 |
| 190 static void pidgin_conv_set_position_size(PidginWindow *win, int x, int y, |
191 static void pidgin_conv_set_position_size(PidginWindow *win, int x, int y, |
| 191 int width, int height); |
192 int width, int height); |
| 192 |
193 |
| 193 static GdkColor *get_nick_color(PidginConversation *gtkconv, const char *name) { |
194 static GdkColor *get_nick_color(PidginConversation *gtkconv, const char *name) { |
| 4383 rend = gtk_cell_renderer_text_new(); |
4383 rend = gtk_cell_renderer_text_new(); |
| 4384 g_object_set(rend, |
4384 g_object_set(rend, |
| 4385 "foreground-set", TRUE, |
4385 "foreground-set", TRUE, |
| 4386 "weight-set", TRUE, |
4386 "weight-set", TRUE, |
| 4387 NULL); |
4387 NULL); |
| |
4388 g_object_set(G_OBJECT(rend), "editable", TRUE, NULL); |
| |
4389 |
| 4388 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
4390 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
| 4389 "text", CHAT_USERS_ALIAS_COLUMN, |
4391 "text", CHAT_USERS_ALIAS_COLUMN, |
| 4390 "foreground-gdk", CHAT_USERS_COLOR_COLUMN, |
4392 "foreground-gdk", CHAT_USERS_COLOR_COLUMN, |
| 4391 "weight", CHAT_USERS_WEIGHT_COLUMN, |
4393 "weight", CHAT_USERS_WEIGHT_COLUMN, |
| 4392 NULL); |
4394 NULL); |
| 6311 markup = pidgin_blist_get_name_markup(buddy, FALSE, FALSE); |
6313 markup = pidgin_blist_get_name_markup(buddy, FALSE, FALSE); |
| 6312 } else { |
6314 } else { |
| 6313 markup = title; |
6315 markup = title; |
| 6314 } |
6316 } |
| 6315 } else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { |
6317 } else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { |
| 6316 PurpleConvChat *chat = PURPLE_CONV_CHAT(conv); |
6318 const char *topic = gtk_entry_get_text(GTK_ENTRY(gtkconv->u.chat->topic_text)); |
| 6317 const char *topic = purple_conv_chat_get_topic(chat); |
|
| 6318 char *esc = topic ? g_markup_escape_text(topic, -1) : NULL; |
6319 char *esc = topic ? g_markup_escape_text(topic, -1) : NULL; |
| 6319 markup = g_strdup_printf("%s%s<span color='%s' size='smaller'>%s</span>", |
6320 markup = g_strdup_printf("%s%s<span color='%s' size='smaller'>%s</span>", |
| 6320 purple_conversation_get_title(conv), |
6321 purple_conversation_get_title(conv), |
| 6321 esc ? "\n" : "", |
6322 esc && *esc ? "\n" : "", |
| 6322 pidgin_get_dim_grey_string(gtkconv->infopane), |
6323 pidgin_get_dim_grey_string(gtkconv->infopane), |
| 6323 esc ? esc : ""); |
6324 esc ? esc : ""); |
| 6324 g_free(esc); |
6325 g_free(esc); |
| 6325 } |
6326 } |
| 6326 gtk_list_store_set(gtkconv->infopane_model, &(gtkconv->infopane_iter), |
6327 gtk_list_store_set(gtkconv->infopane_model, &(gtkconv->infopane_iter), |
| 6327 CONV_TEXT_COLUMN, markup, -1); |
6328 CONV_TEXT_COLUMN, markup, -1); |
| |
6329 /* XXX seanegan Why do I have to do this? */ |
| |
6330 gtk_widget_queue_draw(gtkconv->infopane); |
| 6328 |
6331 |
| 6329 if (title != markup) |
6332 if (title != markup) |
| 6330 g_free(markup); |
6333 g_free(markup); |
| 6331 |
6334 |
| 6332 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) |
6335 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) |
| 7759 */ |
7762 */ |
| 7760 |
7763 |
| 7761 static gboolean |
7764 static gboolean |
| 7762 infopane_press_cb(GtkWidget *widget, GdkEventButton *e, PidginConversation *gtkconv) |
7765 infopane_press_cb(GtkWidget *widget, GdkEventButton *e, PidginConversation *gtkconv) |
| 7763 { |
7766 { |
| |
7767 if (e->type == GDK_2BUTTON_PRESS && e->button == 1) { |
| |
7768 if (alias_double_click_cb(widget, e, gtkconv)) |
| |
7769 return TRUE; |
| |
7770 } |
| |
7771 |
| 7764 if (e->type != GDK_BUTTON_PRESS) |
7772 if (e->type != GDK_BUTTON_PRESS) |
| 7765 return FALSE; |
7773 return FALSE; |
| 7766 |
7774 |
| 7767 if (e->button == 3) { |
7775 if (e->button == 3) { |
| 7768 /* Right click was pressed. Popup the Send To menu. */ |
7776 /* Right click was pressed. Popup the Send To menu. */ |
| 8140 static void |
8148 static void |
| 8141 remove_edit_entry(PidginConversation *gtkconv, GtkWidget *entry) |
8149 remove_edit_entry(PidginConversation *gtkconv, GtkWidget *entry) |
| 8142 { |
8150 { |
| 8143 g_signal_handlers_disconnect_matched(G_OBJECT(entry), G_SIGNAL_MATCH_DATA, |
8151 g_signal_handlers_disconnect_matched(G_OBJECT(entry), G_SIGNAL_MATCH_DATA, |
| 8144 0, 0, NULL, NULL, gtkconv); |
8152 0, 0, NULL, NULL, gtkconv); |
| 8145 gtk_widget_show(gtkconv->tab_label); |
8153 gtk_widget_show(gtkconv->infopane); |
| 8146 gtk_widget_grab_focus(gtkconv->entry); |
8154 gtk_widget_grab_focus(gtkconv->entry); |
| 8147 gtk_widget_destroy(entry); |
8155 gtk_widget_destroy(entry); |
| 8148 } |
8156 } |
| 8149 |
8157 |
| 8150 static gboolean |
8158 static gboolean |
| 8187 purple_blist_alias_buddy(buddy, |
8195 purple_blist_alias_buddy(buddy, |
| 8188 gtk_entry_get_text(entry)); |
8196 gtk_entry_get_text(entry)); |
| 8189 } |
8197 } |
| 8190 serv_alias_buddy(buddy); |
8198 serv_alias_buddy(buddy); |
| 8191 } else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { |
8199 } else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { |
| 8192 PurpleChat *chat; |
8200 gtk_entry_set_text(GTK_ENTRY(gtkconv->u.chat->topic_text), gtk_entry_get_text(entry)); |
| 8193 |
8201 topic_callback(NULL, gtkconv); |
| 8194 chat = purple_blist_find_chat(account, name); |
|
| 8195 if (chat != NULL) { |
|
| 8196 purple_blist_alias_chat(chat, |
|
| 8197 gtk_entry_get_text(entry)); |
|
| 8198 } |
|
| 8199 } |
8202 } |
| 8200 remove_edit_entry(user_data, GTK_WIDGET(entry)); |
8203 remove_edit_entry(user_data, GTK_WIDGET(entry)); |
| 8201 } |
8204 } |
| 8202 |
8205 |
| 8203 static gboolean |
8206 static gboolean |
| 8204 alias_double_click_cb(GtkNotebook *notebook, GdkEventButton *event, PidginConversation *gtkconv) |
8207 alias_double_click_cb(GtkWidget *widget, GdkEventButton *event, PidginConversation *gtkconv) |
| 8205 { |
8208 { |
| 8206 GtkWidget *entry = NULL; |
8209 GtkWidget *entry = NULL; |
| |
8210 PurpleConversation *conv = gtkconv->active_conv; |
| |
8211 const char *text = NULL; |
| 8207 |
8212 |
| 8208 if (event->button != 1 || event->type != GDK_2BUTTON_PRESS) { |
8213 if (event->button != 1 || event->type != GDK_2BUTTON_PRESS) { |
| 8209 return FALSE; |
8214 return FALSE; |
| 8210 } |
8215 } |
| 8211 |
8216 |
| 8215 } |
8220 } |
| 8216 |
8221 |
| 8217 if (!purple_account_is_connected(gtkconv->active_conv->account)) { |
8222 if (!purple_account_is_connected(gtkconv->active_conv->account)) { |
| 8218 /* Do not allow aliasing someone on a disconnected account. */ |
8223 /* Do not allow aliasing someone on a disconnected account. */ |
| 8219 return FALSE; |
8224 return FALSE; |
| |
8225 } |
| |
8226 |
| |
8227 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { |
| |
8228 PurpleBuddy *buddy = purple_find_buddy(gtkconv->active_conv->account, gtkconv->active_conv->name); |
| |
8229 if (!buddy) |
| |
8230 return FALSE; |
| |
8231 text = purple_buddy_get_contact_alias(buddy); |
| |
8232 } else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { |
| |
8233 text = purple_conv_chat_get_topic(PURPLE_CONV_CHAT(conv)); |
| 8220 } |
8234 } |
| 8221 |
8235 |
| 8222 /* alias label */ |
8236 /* alias label */ |
| 8223 entry = gtk_entry_new(); |
8237 entry = gtk_entry_new(); |
| 8224 gtk_entry_set_has_frame(GTK_ENTRY(entry), FALSE); |
8238 gtk_entry_set_has_frame(GTK_ENTRY(entry), FALSE); |
| 8225 gtk_entry_set_width_chars(GTK_ENTRY(entry), 10); |
8239 gtk_entry_set_width_chars(GTK_ENTRY(entry), 10); |
| 8226 #if GTK_CHECK_VERSION(2,4,0) |
8240 #if GTK_CHECK_VERSION(2,4,0) |
| 8227 gtk_entry_set_alignment(GTK_ENTRY(entry), 0.5); |
8241 gtk_entry_set_alignment(GTK_ENTRY(entry), 0.5); |
| 8228 #endif |
8242 #endif |
| 8229 |
8243 |
| 8230 gtk_box_pack_start(GTK_BOX(gtkconv->tabby), entry, TRUE, TRUE, 0); |
8244 gtk_box_pack_start(GTK_BOX(gtkconv->infopane_hbox), entry, TRUE, TRUE, 0); |
| 8231 /* after the tab label */ |
8245 /* after the tab label */ |
| 8232 gtk_box_reorder_child(GTK_BOX(gtkconv->tabby), entry, 2); |
8246 gtk_box_reorder_child(GTK_BOX(gtkconv->infopane_hbox), entry, 0); |
| 8233 |
8247 |
| 8234 g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(alias_cb), gtkconv); |
8248 g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(alias_cb), gtkconv); |
| 8235 g_signal_connect(G_OBJECT(entry), "focus-out-event", G_CALLBACK(alias_focus_cb), gtkconv); |
8249 g_signal_connect(G_OBJECT(entry), "focus-out-event", G_CALLBACK(alias_focus_cb), gtkconv); |
| 8236 g_signal_connect(G_OBJECT(entry), "key-press-event", G_CALLBACK(alias_key_press_cb), gtkconv); |
8250 g_signal_connect(G_OBJECT(entry), "key-press-event", G_CALLBACK(alias_key_press_cb), gtkconv); |
| 8237 gtk_entry_set_text(GTK_ENTRY(entry), |
8251 |
| 8238 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); |
8252 |
| |
8253 |
| |
8254 gtk_entry_set_text(GTK_ENTRY(entry), text); |
| 8239 gtk_widget_show(entry); |
8255 gtk_widget_show(entry); |
| 8240 gtk_widget_hide(gtkconv->tab_label); |
8256 gtk_widget_hide(gtkconv->infopane); |
| 8241 gtk_widget_grab_focus(entry); |
8257 gtk_widget_grab_focus(entry); |
| 8242 |
8258 |
| 8243 return FALSE; |
8259 return FALSE; |
| 8244 } |
8260 } |
| 8245 |
8261 |