comparison pidgin/gtkimhtmltoolbar.c @ 27755:9a60b9fab0ea

propagate from branch 'im.pidgin.pidgin' (head d50f362e369f486aaf9a95a0d79ec0632743f07d) to branch 'im.pidgin.pidgin.yaz' (head 85b37cd20a00067af5a2da2760336b0c1016ef47)
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Mon, 07 Jan 2008 03:40:27 +0000
parents 6b74c3255901 07eb63fa0bdb
children e9cf897bd873
comparison
equal deleted inserted replaced
27754:754a82f1371b 27755:9a60b9fab0ea
97 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(large))) 97 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(large)))
98 gtk_imhtml_font_grow(GTK_IMHTML(toolbar->imhtml)); 98 gtk_imhtml_font_grow(GTK_IMHTML(toolbar->imhtml));
99 gtk_widget_grab_focus(toolbar->imhtml); 99 gtk_widget_grab_focus(toolbar->imhtml);
100 } 100 }
101 101
102 static void 102 static gboolean
103 destroy_toolbar_font(GtkWidget *widget, GdkEvent *event, 103 destroy_toolbar_font(GtkWidget *widget, GdkEvent *event,
104 GtkIMHtmlToolbar *toolbar) 104 GtkIMHtmlToolbar *toolbar)
105 { 105 {
106 if (widget != NULL) 106 if (widget != NULL)
107 gtk_imhtml_toggle_fontface(GTK_IMHTML(toolbar->imhtml), ""); 107 gtk_imhtml_toggle_fontface(GTK_IMHTML(toolbar->imhtml), "");
109 if (toolbar->font_dialog != NULL) 109 if (toolbar->font_dialog != NULL)
110 { 110 {
111 gtk_widget_destroy(toolbar->font_dialog); 111 gtk_widget_destroy(toolbar->font_dialog);
112 toolbar->font_dialog = NULL; 112 toolbar->font_dialog = NULL;
113 } 113 }
114 return FALSE;
114 } 115 }
115 116
116 static void 117 static void
117 realize_toolbar_font(GtkWidget *widget, GtkIMHtmlToolbar *toolbar) 118 realize_toolbar_font(GtkWidget *widget, GtkIMHtmlToolbar *toolbar)
118 { 119 {
189 cancel_toolbar_font(font, toolbar); 190 cancel_toolbar_font(font, toolbar);
190 } 191 }
191 gtk_widget_grab_focus(toolbar->imhtml); 192 gtk_widget_grab_focus(toolbar->imhtml);
192 } 193 }
193 194
194 static void 195 static gboolean
195 destroy_toolbar_fgcolor(GtkWidget *widget, GdkEvent *event, 196 destroy_toolbar_fgcolor(GtkWidget *widget, GdkEvent *event,
196 GtkIMHtmlToolbar *toolbar) 197 GtkIMHtmlToolbar *toolbar)
197 { 198 {
198 if (widget != NULL) 199 if (widget != NULL)
199 gtk_imhtml_toggle_forecolor(GTK_IMHTML(toolbar->imhtml), ""); 200 gtk_imhtml_toggle_forecolor(GTK_IMHTML(toolbar->imhtml), "");
201 if (toolbar->fgcolor_dialog != NULL) 202 if (toolbar->fgcolor_dialog != NULL)
202 { 203 {
203 gtk_widget_destroy(toolbar->fgcolor_dialog); 204 gtk_widget_destroy(toolbar->fgcolor_dialog);
204 toolbar->fgcolor_dialog = NULL; 205 toolbar->fgcolor_dialog = NULL;
205 } 206 }
207 return FALSE;
206 } 208 }
207 209
208 static void cancel_toolbar_fgcolor(GtkWidget *widget, 210 static void cancel_toolbar_fgcolor(GtkWidget *widget,
209 GtkIMHtmlToolbar *toolbar) 211 GtkIMHtmlToolbar *toolbar)
210 { 212 {
261 cancel_toolbar_fgcolor(color, toolbar); 263 cancel_toolbar_fgcolor(color, toolbar);
262 } 264 }
263 gtk_widget_grab_focus(toolbar->imhtml); 265 gtk_widget_grab_focus(toolbar->imhtml);
264 } 266 }
265 267
266 static void 268 static gboolean
267 destroy_toolbar_bgcolor(GtkWidget *widget, GdkEvent *event, 269 destroy_toolbar_bgcolor(GtkWidget *widget, GdkEvent *event,
268 GtkIMHtmlToolbar *toolbar) 270 GtkIMHtmlToolbar *toolbar)
269 { 271 {
270 if (widget != NULL) { 272 if (widget != NULL) {
271 if (gtk_text_buffer_get_selection_bounds(GTK_IMHTML(toolbar->imhtml)->text_buffer, NULL, NULL)) 273 if (gtk_text_buffer_get_selection_bounds(GTK_IMHTML(toolbar->imhtml)->text_buffer, NULL, NULL))
277 if (toolbar->bgcolor_dialog != NULL) 279 if (toolbar->bgcolor_dialog != NULL)
278 { 280 {
279 gtk_widget_destroy(toolbar->bgcolor_dialog); 281 gtk_widget_destroy(toolbar->bgcolor_dialog);
280 toolbar->bgcolor_dialog = NULL; 282 toolbar->bgcolor_dialog = NULL;
281 } 283 }
284 return FALSE;
282 } 285 }
283 286
284 static void 287 static void
285 cancel_toolbar_bgcolor(GtkWidget *widget, GtkIMHtmlToolbar *toolbar) 288 cancel_toolbar_bgcolor(GtkWidget *widget, GtkIMHtmlToolbar *toolbar)
286 { 289 {
465 int id; 468 int id;
466 GtkTextIter iter; 469 GtkTextIter iter;
467 GtkTextMark *ins; 470 GtkTextMark *ins;
468 471
469 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ 472 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */
470 if (response != GTK_RESPONSE_ACCEPT) { 473 if (response != GTK_RESPONSE_ACCEPT)
471 #else /* FILECHOOSER */ 474 #else /* FILECHOOSER */
472 if (response != GTK_RESPONSE_OK) { 475 if (response != GTK_RESPONSE_OK)
473 #endif /* FILECHOOSER */ 476 #endif /* FILECHOOSER */
477 {
474 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE); 478 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE);
475 return; 479 return;
476 } 480 }
477 481
478 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ 482 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */
572 gtk_widget_destroy(toolbar->smiley_dialog); 576 gtk_widget_destroy(toolbar->smiley_dialog);
573 toolbar->smiley_dialog = NULL; 577 toolbar->smiley_dialog = NULL;
574 } 578 }
575 } 579 }
576 580
577 static void 581 static gboolean
578 close_smiley_dialog(GtkWidget *widget, GdkEvent *event, 582 close_smiley_dialog(GtkWidget *widget, GdkEvent *event,
579 GtkIMHtmlToolbar *toolbar) 583 GtkIMHtmlToolbar *toolbar)
580 { 584 {
581 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->smiley), FALSE); 585 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->smiley), FALSE);
586 return FALSE;
582 } 587 }
583 588
584 589
585 static void 590 static void
586 insert_smiley_text(GtkWidget *widget, GtkIMHtmlToolbar *toolbar) 591 insert_smiley_text(GtkWidget *widget, GtkIMHtmlToolbar *toolbar)
702 unique_smileys = g_slist_append(unique_smileys, smiley); 707 unique_smileys = g_slist_append(unique_smileys, smiley);
703 } 708 }
704 smileys = smileys->next; 709 smileys = smileys->next;
705 } 710 }
706 711
707 PIDGIN_DIALOG(dialog); 712 dialog = pidgin_create_dialog(_("Smile!"), 0, "smiley_dialog", FALSE);
708 713
709 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
710 gtk_window_set_role(GTK_WINDOW(dialog), "smiley_dialog");
711 gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE); 714 gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE);
712 715
713 if (unique_smileys != NULL) { 716 if (unique_smileys != NULL) {
714 struct smiley_button_list *ls, *it, *it_tmp; 717 struct smiley_button_list *ls, *it, *it_tmp;
715 GtkWidget *line; 718 GtkWidget *line;
762 gtk_widget_add_events(dialog, GDK_KEY_PRESS_MASK | GDK_BUTTON_PRESS_MASK); 765 gtk_widget_add_events(dialog, GDK_KEY_PRESS_MASK | GDK_BUTTON_PRESS_MASK);
763 g_signal_connect(G_OBJECT(dialog), "button-press-event", (GCallback)smiley_dialog_input_cb, toolbar); 766 g_signal_connect(G_OBJECT(dialog), "button-press-event", (GCallback)smiley_dialog_input_cb, toolbar);
764 } 767 }
765 768
766 g_signal_connect(G_OBJECT(dialog), "key-press-event", (GCallback)smiley_dialog_input_cb, toolbar); 769 g_signal_connect(G_OBJECT(dialog), "key-press-event", (GCallback)smiley_dialog_input_cb, toolbar);
767 gtk_container_add(GTK_CONTAINER(dialog), smiley_table); 770 gtk_container_add(GTK_CONTAINER(pidgin_dialog_get_vbox(GTK_DIALOG(dialog))), smiley_table);
768 771
769 gtk_widget_show(smiley_table); 772 gtk_widget_show(smiley_table);
770
771 gtk_container_set_border_width(GTK_CONTAINER(dialog), 5);
772 773
773 /* connect signals */ 774 /* connect signals */
774 g_signal_connect(G_OBJECT(dialog), "delete_event", 775 g_signal_connect(G_OBJECT(dialog), "delete_event",
775 G_CALLBACK(close_smiley_dialog), toolbar); 776 G_CALLBACK(close_smiley_dialog), toolbar);
776 777
777 /* show everything */ 778 /* show everything */
778 gtk_window_set_title(GTK_WINDOW(dialog), _("Smile!"));
779 gtk_widget_show_all(dialog); 779 gtk_widget_show_all(dialog);
780 gtk_window_set_transient_for(GTK_WINDOW(dialog), 780 gtk_window_set_transient_for(GTK_WINDOW(dialog),
781 GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(toolbar)))); 781 GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(toolbar))));
782 #ifdef _WIN32 782 #ifdef _WIN32
783 winpidgin_ensure_onscreen(dialog); 783 winpidgin_ensure_onscreen(dialog);
1094 {"", NULL, NULL, NULL}, 1094 {"", NULL, NULL, NULL},
1095 {PIDGIN_STOCK_TOOLBAR_TEXT_LARGER, do_big, &toolbar->larger_size, _("Increase Font Size")}, 1095 {PIDGIN_STOCK_TOOLBAR_TEXT_LARGER, do_big, &toolbar->larger_size, _("Increase Font Size")},
1096 {PIDGIN_STOCK_TOOLBAR_TEXT_SMALLER, do_small, &toolbar->smaller_size, _("Decrease Font Size")}, 1096 {PIDGIN_STOCK_TOOLBAR_TEXT_SMALLER, do_small, &toolbar->smaller_size, _("Decrease Font Size")},
1097 {"", NULL, NULL, NULL}, 1097 {"", NULL, NULL, NULL},
1098 {PIDGIN_STOCK_TOOLBAR_FONT_FACE, toggle_font, &toolbar->font, _("Font Face")}, 1098 {PIDGIN_STOCK_TOOLBAR_FONT_FACE, toggle_font, &toolbar->font, _("Font Face")},
1099 {PIDGIN_STOCK_TOOLBAR_FGCOLOR, toggle_bg_color, &toolbar->bgcolor, _("Background Color")}, 1099 {PIDGIN_STOCK_TOOLBAR_BGCOLOR, toggle_bg_color, &toolbar->bgcolor, _("Background Color")},
1100 {PIDGIN_STOCK_TOOLBAR_BGCOLOR, toggle_fg_color, &toolbar->fgcolor, _("Foreground Color")}, 1100 {PIDGIN_STOCK_TOOLBAR_FGCOLOR, toggle_fg_color, &toolbar->fgcolor, _("Foreground Color")},
1101 {"", NULL, NULL, NULL}, 1101 {"", NULL, NULL, NULL},
1102 {PIDGIN_STOCK_CLEAR, clear_formatting_cb, &toolbar->clear, _("Reset Formatting")}, 1102 {PIDGIN_STOCK_CLEAR, clear_formatting_cb, &toolbar->clear, _("Reset Formatting")},
1103 {"", NULL, NULL, NULL}, 1103 {"", NULL, NULL, NULL},
1104 {PIDGIN_STOCK_TOOLBAR_INSERT_LINK, insert_link_cb, &toolbar->link, _("Insert Link")}, 1104 {PIDGIN_STOCK_TOOLBAR_INSERT_LINK, insert_link_cb, &toolbar->link, _("Insert Link")},
1105 {PIDGIN_STOCK_TOOLBAR_INSERT_IMAGE, insert_image_cb, &toolbar->image, _("Insert IM Image")}, 1105 {PIDGIN_STOCK_TOOLBAR_INSERT_IMAGE, insert_image_cb, &toolbar->image, _("Insert IM Image")},