コード例 #1
0
ファイル: chat.c プロジェクト: brenttsai1148/linphone-android
GtkWidget* linphone_gtk_init_chatroom(LinphoneChatRoom *cr, const LinphoneAddress *with){
	GtkWidget *chat_view=linphone_gtk_create_widget("main","chatroom_frame");
	GtkWidget *main_window=linphone_gtk_get_main_window();
	GtkNotebook *notebook=(GtkNotebook *)linphone_gtk_get_widget(main_window,"viewswitch");
	GtkWidget *text=linphone_gtk_get_widget(chat_view,"textview");
	GdkColor color;
	GdkColor colorb;
	int idx;
	GtkWidget *button;
	GtkWidget *entry;
	MSList *messages;
	GHashTable *table;
	char *with_str;

	color.red = 32512;
  	color.green = 32512;
  	color.blue = 32512;
	colorb.red = 56832;
  	colorb.green = 60928;
  	colorb.blue = 61952;

	with_str=linphone_address_as_string_uri_only(with);
	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text),GTK_WRAP_WORD_CHAR);
	gtk_text_view_set_editable(GTK_TEXT_VIEW(text),FALSE);
	gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text),FALSE);
	gtk_notebook_append_page(notebook,chat_view,create_tab_chat_header(cr,with));
	idx = gtk_notebook_page_num(notebook, chat_view);
	gtk_notebook_set_current_page(notebook, idx);
	gtk_widget_show(chat_view);
	table=g_hash_table_new_full(g_direct_hash,g_direct_equal,NULL,NULL);
	g_object_set_data(G_OBJECT(chat_view),"cr",cr);
	g_object_set_data(G_OBJECT(chat_view),"from_message",NULL);
	g_object_set_data(G_OBJECT(chat_view),"table",table);
	gtk_text_buffer_create_tag(gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)),
	                        "right","justification", GTK_JUSTIFY_RIGHT,NULL);
	gtk_text_buffer_create_tag(gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)),
	                        "left","justification", GTK_JUSTIFY_LEFT,NULL);
	gtk_text_buffer_create_tag(gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)),
	                       	    "bold","weight", PANGO_WEIGHT_BOLD,NULL);
	gtk_text_buffer_create_tag(gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)),
								"italic","style", PANGO_STYLE_ITALIC,NULL);
	gtk_text_buffer_create_tag(gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)),
	                           	"small","size",9*PANGO_SCALE,NULL);
	gtk_text_buffer_create_tag(gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)),
	                           	"font_grey","foreground-gdk",&color,NULL);
	gtk_text_buffer_create_tag(gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)),
	                           	"margin","indent",10,NULL);
	gtk_text_buffer_create_tag(gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)),
	                           	"bg","paragraph-background-gdk",&colorb,NULL);
	messages = linphone_chat_room_get_history(cr,NB_MSG_HIST);
	display_history_message(chat_view,messages,with);
	button = linphone_gtk_get_widget(chat_view,"send");
	g_signal_connect_swapped(G_OBJECT(button),"clicked",(GCallback)linphone_gtk_send_text,NULL);
	entry = linphone_gtk_get_widget(chat_view,"text_entry");
	g_signal_connect_swapped(G_OBJECT(entry),"activate",(GCallback)linphone_gtk_send_text,NULL);
	g_signal_connect_swapped(G_OBJECT(entry),"changed",(GCallback)linphone_gtk_compose_text,NULL);
	g_signal_connect(G_OBJECT(notebook),"switch_page",(GCallback)linphone_gtk_notebook_tab_select,NULL);
	ms_free(with_str);
	return chat_view;
}
コード例 #2
0
ファイル: chat.c プロジェクト: mjpak0109/linphone
GtkWidget* linphone_gtk_init_chatroom(LinphoneChatRoom *cr, const LinphoneAddress *with){
	GtkWidget *chat_view=linphone_gtk_create_widget("chatroom_frame");
	GtkWidget *main_window=linphone_gtk_get_main_window();
	GtkNotebook *notebook=(GtkNotebook *)linphone_gtk_get_widget(main_window,"viewswitch");
	GtkWidget *text=linphone_gtk_get_widget(chat_view,"textview");
	GdkColor color_grey = {0, 32512, 32512, 32512};
	GdkColor color_light_grey = {0, 56832, 60928, 61952};
	GdkColor color_black = {0};
	int idx;
	GtkWidget *button;
	GtkWidget *entry = linphone_gtk_get_widget(chat_view,"text_entry");
	MSList *messages;
	GHashTable *table;
	GtkTextTag *tmp_tag;
	GtkWidget *link_ctx_menu = gtk_menu_new();
	GtkWidget *link_ctx_menu_copy_item = gtk_menu_item_new_with_label(_("Copy"));

	gtk_notebook_append_page(notebook,chat_view,create_tab_chat_header(cr,with));
	idx = gtk_notebook_page_num(notebook, chat_view);
	gtk_notebook_set_current_page(notebook, idx);
	gtk_widget_show(chat_view);
	table=g_hash_table_new_full(g_direct_hash,g_direct_equal,NULL,NULL);
	g_object_set_data(G_OBJECT(chat_view),"cr",cr);
	g_object_set_data(G_OBJECT(chat_view),"from_message",NULL);
	g_object_set_data(G_OBJECT(chat_view),"table",table);

	gtk_text_buffer_create_tag(
		gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)),
		"me",
		"foreground_gdk", &color_black,
		"paragraph-background-gdk", &color_light_grey,
		NULL);

	gtk_text_buffer_create_tag(
		gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)),
		"from",
		"weight", PANGO_WEIGHT_BOLD,
		NULL);

	gtk_text_buffer_create_tag(
		gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)),
		"body",
		"indent", 10,
		NULL);

	gtk_text_buffer_create_tag(
		gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)),
		"status",
		"size-points", 9.0,
		"foreground_gdk", &color_grey,
		"style", PANGO_STYLE_ITALIC,
		"justification", GTK_JUSTIFY_RIGHT,
		NULL);

	tmp_tag = gtk_text_buffer_create_tag(
		gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)),
		"link",
		"underline", PANGO_UNDERLINE_SINGLE,
		"foreground_gdk", _linphone_gtk_chatroom_get_link_color(chat_view),
		NULL);
	g_signal_connect(G_OBJECT(tmp_tag), "event", G_CALLBACK(link_event_handler), NULL);
	g_signal_connect(G_OBJECT(text), "event", G_CALLBACK(chatroom_event), NULL);
	gtk_menu_shell_append(GTK_MENU_SHELL(link_ctx_menu), link_ctx_menu_copy_item);
	g_signal_connect(G_OBJECT(link_ctx_menu_copy_item), "activate", G_CALLBACK(copy_uri_into_clipboard_handler), NULL);
	gtk_widget_show_all(link_ctx_menu);
	g_object_set_data_full(G_OBJECT(text), "link_ctx_menu", link_ctx_menu, g_object_unref);
	g_object_ref_sink(G_OBJECT(link_ctx_menu));

	messages = linphone_chat_room_get_history(cr,NB_MSG_HIST);
	display_history_message(chat_view,messages,with);
	button = linphone_gtk_get_widget(chat_view,"send");
	g_signal_connect_swapped(G_OBJECT(button),"clicked",(GCallback)linphone_gtk_send_text,NULL);

	g_signal_connect_swapped(G_OBJECT(entry),"activate",(GCallback)linphone_gtk_send_text,NULL);
	g_signal_connect_swapped(G_OBJECT(entry),"changed",(GCallback)linphone_gtk_compose_text,NULL);
	g_signal_connect(G_OBJECT(notebook),"switch_page",(GCallback)linphone_gtk_notebook_tab_select,NULL);
	return chat_view;
}