Re: UI for message-formatting

Alagunambi Welkin <[email protected]> Wed, 4 Nov 2009 12:01:59 -0500
Newsgroups gmane.network.instant-messaging.ayttm.user
Message-ID <[email protected]>
hi,

> working code would help understand what you're trying to put across.

here is patch for ayttm-0.6.1

<patch>

diff -Nur ori/ayttm-0.6.1/src/chat_window.c work/ayttm-0.6.1/src/chat_window.c
--- ori/ayttm-0.6.1/src/chat_window.c	2009-10-16 06:30:52.000000000 -0400
+++ work/ayttm-0.6.1/src/chat_window.c	2009-11-04 15:47:26.000000000 -0500
@@ -69,6 +69,7 @@

 #include "pixmaps/tb_volume.xpm"
 #include "pixmaps/invite_btn.xpm"
+#include "pixmaps/txt_format.xpm"

 #define BUF_SIZE 1024		/* Maximum message length */
 #ifndef NAME_MAX
@@ -745,6 +746,89 @@
 	g_free(buff);
 }

+static void bold_format(GtkWidget *bold_button, gpointer userdata)
+{
+	ay_do_info("Bold Format", "Bold need to be implemented");
+}
+
+static void italic_format(GtkWidget *italic_format, gpointer userdata)
+{
+	ay_do_info("Italic Format", "Italic need to be implemented");
+}
+
+static void underline_format(GtkWidget *underline_format, gpointer userdata)
+{
+	ay_do_info("Underline Format", "Underline need to be implemented");
+}
+
+static void color_format(GtkWidget *color_button, gpointer userdata)
+{
+	GtkWidget *color_format = NULL;
+
+	color_format = gtk_color_selection_dialog_new("Color Selection");
+	gtk_widget_show(color_format);
+}
+
+static void message_format(GtkWidget *format_button, gpointer userdata)
+{
+	chat_window *cw = (chat_window *)userdata;
+	message_format_callback_data *mf = (chat_window *)userdata;
+
+	if(mf->ch_window && mf->ch_window->mf_menu) {
+		gtk_widget_destroy(mf->ch_window->mf_menu);
+		mf->ch_window->mf_menu = NULL;
+		return;
+	}
+
+	unsigned short int row = 3;
+	unsigned short int col = 1;
+	int win_x = NULL;
+	int win_y = NULL;
+	
+	GtkWidget *bold_button = NULL;
+	GtkWidget *italic_button = NULL;
+	GtkWidget *underline_button = NULL;
+
+	GtkWidget *mf_table = NULL;
+	GtkWidget *mf_menu = NULL;
+
+	mf_table = gtk_table_new(row, col, TRUE);
+	
+	bold_button = gtk_button_new_with_label("Bold");	
+	g_signal_connect(bold_button, "clicked", G_CALLBACK(bold_format), cw);
+	gtk_table_attach_defaults(mf_table, bold_button, 0, 1, 0, 1);
+
+	italic_button = gtk_button_new_with_label("Italic");	
+	g_signal_connect(italic_button, "clicked", G_CALLBACK(italic_format), cw);
+	gtk_table_attach_defaults(mf_table, italic_button, 0, 1, 1, 2);
+	
+	underline_button = gtk_button_new_with_label("Underline");	
+	g_signal_connect(underline_button, "clicked",
G_CALLBACK(underline_format), cw);
+	gtk_table_attach_defaults(mf_table, underline_button, 0, 1, 2, 3);
+
+	mf_menu = gtk_window_new(GTK_WINDOW_POPUP);
+	gtk_window_set_modal(GTK_WINDOW(mf_menu), FALSE);
+	gtk_window_set_title(GTK_WINDOW(mf_menu), "Message Format");
+	gtk_window_set_resizable(GTK_WINDOW(mf_menu), FALSE);
+	gtk_widget_realize(mf_menu);
+	
+	gtk_container_add(GTK_CONTAINER(mf_menu), mf_table);
+	
+	gdk_window_get_pointer(NULL, &win_x, &win_y, NULL);
+	win_x += 5;
+	win_y += 5;
+	while ((win_x) + 10 > gdk_screen_width() - 30)
+		win_x -= 20;
+	while ((win_y) + 20 > gdk_screen_height() - 30)
+		win_y -= 20;
+	gtk_window_move(GTK_WINDOW(mf_menu), win_x, win_y);
+
+	if (mf && mf->ch_window)
+		mf->ch_window->mf_menu = mf_menu;
+
+	gtk_widget_show_all(mf_menu);
+}
+
 /* This is the callback for file x-fer*/
 static void send_file(GtkWidget *sendf_button, gpointer userdata)
 {
@@ -1017,6 +1101,20 @@
 		gtk_menu_shell_append(GTK_MENU_SHELL(menu), button);
 		gtk_widget_show(button);

+		/* Text Format */
+		button = gtk_menu_item_new_with_label(_("Text Format"));
+		g_signal_connect(button, "activate",
+			G_CALLBACK(message_format), cw);
+		gtk_menu_shell_append(GTK_MENU_SHELL(menu), button);
+		gtk_widget_show(button);
+
+		/* Color Selection */
+		button = gtk_check_menu_item_new_with_label(_("Color Format"));
+		g_signal_connect(button, "activate",
+			G_CALLBACK(color_format), cw);
+		gtk_menu_shell_append(GTK_MENU_SHELL(menu), button);
+		gtk_widget_show(button);
+
 		/* Send message Section */
 		button = gtk_menu_item_new_with_label(_("Send Message"));
 		g_signal_connect(button, "activate", G_CALLBACK(send_message),
@@ -2268,6 +2366,8 @@
 	GtkWidget *add_button;
 	GtkWidget *sendf_button;
 	GtkWidget *send_button;
+	GtkWidget *format_button;
+	GtkWidget *color_button;
 	GtkWidget *view_log_button;
 	GtkWidget *print_button;
 	GtkWidget *close_button;
@@ -2330,7 +2430,7 @@

 	gtk_container_add(GTK_CONTAINER(scrollwindow), cw->chat);
 	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwindow),
-		GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
+		GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
 	gtk_widget_show(scrollwindow);

 	/* Create the bar for resizing chat/window box */
@@ -2566,6 +2666,24 @@

 	TOOLBAR_APPEND_SPACE(TRUE);

+	/* This is the text format button */
+	ICON_CREATE_XPM(icon, iconwid, txt_format_xpm);
+	TOOLBAR_APPEND(format_button, _("Message Format"), iconwid,
+		message_format, cw);
+	gtk_widget_add_accelerator(format_button, "clicked", accel_group, GDK_f,
+		GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
+
+	TOOLBAR_APPEND_SPACE(TRUE);
+
+	/* This is the color format button */
+	ICON_CREATE_XPM(icon, iconwid, txt_format_xpm);
+	TOOLBAR_APPEND(color_button, _("Color Format"), iconwid,
+		color_format, cw);
+	gtk_widget_add_accelerator(color_button, "clicked", accel_group, GDK_f,
+		GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
+
+	TOOLBAR_APPEND_SPACE(TRUE);
+
 	/* This is the send button */
 	ICON_CREATE(iconwid, GTK_STOCK_OK);
 	TOOLBAR_APPEND(send_button, _("Send Message CTRL+R"), iconwid,
diff -Nur ori/ayttm-0.6.1/src/chat_window.h work/ayttm-0.6.1/src/chat_window.h
--- ori/ayttm-0.6.1/src/chat_window.h	2009-10-16 05:04:36.000000000 -0400
+++ work/ayttm-0.6.1/src/chat_window.h	2009-11-04 15:30:44.000000000 -0500
@@ -43,6 +43,7 @@
 	GtkWidget *entry;
 	GtkWidget *smiley_button;
 	GtkWidget *smiley_window;
+	GtkWidget *mf_menu;
 	GtkWidget *sound_button;
 	GtkWidget *offline_button;
 	GtkWidget *status_label;
@@ -155,4 +156,10 @@

 void ay_set_chat_encoding(GtkWidget *widget, void *data);

+typedef struct _message_format_callback_data message_format_callback_data;
+
+struct _message_format_callback_data {
+	chat_window *ch_window;
+};
+
 #endif
diff -Nur ori/ayttm-0.6.1/pixmaps/txt_format.xpm
work/ayttm-0.6.1/pixmaps/txt_format.xpm
--- ori/ayttm-0.6.1/pixmaps/txt_format.xpm	1969-12-31 19:00:00.000000000 -0500
+++ work/ayttm-0.6.1/pixmaps/txt_format.xpm	2009-10-30 17:32:11.000000000 -0400
@@ -0,0 +1,30 @@
+/* XPM */
+static char * txt_format_xpm[] = {
+"24 24 3 1",
+" 	c None",
+".	c #000000",
+"+	c #FDFF09",
+"                        ",
+"                        ",
+"                        ",
+"                        ",
+" ...................... ",
+" .++++++++++++++++++++. ",
+" .++++++++++++++++++++. ",
+" .++......++++......++. ",
+" ....    .++++.    .... ",
+"         .++++.         ",
+"         .++++.         ",
+"         .++++.         ",
+"         .++++.         ",
+"         .++++.         ",
+"         .++++.         ",
+"         .++++.         ",
+"         .++++.         ",
+"         .++++.         ",
+"        ..++++..        ",
+"        .++++++.        ",
+"        ........        ",
+"                        ",
+"                        ",
+"                        "};

</patch>


Please correct me if I am wrong.

Thanks ;-)
Alagunambi Welkin

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july

_______________________________________________
Ayttm-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ayttm-users
we_message_format_outline.patch (text/x-patch, 6.9 KB)
diff -Nur ori/ayttm-0.6.1/src/chat_window.c work/ayttm-0.6.1/src/chat_window.c
--- ori/ayttm-0.6.1/src/chat_window.c	2009-10-16 06:30:52.000000000 -0400
+++ work/ayttm-0.6.1/src/chat_window.c	2009-11-04 15:47:26.000000000 -0500
@@ -69,6 +69,7 @@
 
 #include "pixmaps/tb_volume.xpm"
 #include "pixmaps/invite_btn.xpm"
+#include "pixmaps/txt_format.xpm"
 
 #define BUF_SIZE 1024		/* Maximum message length */
 #ifndef NAME_MAX
@@ -745,6 +746,89 @@
 	g_free(buff);
 }
 
+static void bold_format(GtkWidget *bold_button, gpointer userdata)
+{
+	ay_do_info("Bold Format", "Bold need to be implemented");
+}
+
+static void italic_format(GtkWidget *italic_format, gpointer userdata)
+{
+	ay_do_info("Italic Format", "Italic need to be implemented");
+}
+
+static void underline_format(GtkWidget *underline_format, gpointer userdata)
+{
+	ay_do_info("Underline Format", "Underline need to be implemented");
+}
+
+static void color_format(GtkWidget *color_button, gpointer userdata)
+{
+	GtkWidget *color_format = NULL;
+
+	color_format = gtk_color_selection_dialog_new("Color Selection");
+	gtk_widget_show(color_format);
+}
+
+static void message_format(GtkWidget *format_button, gpointer userdata)
+{
+	chat_window *cw = (chat_window *)userdata;
+	message_format_callback_data *mf = (chat_window *)userdata;
+
+	if(mf->ch_window && mf->ch_window->mf_menu) {
+		gtk_widget_destroy(mf->ch_window->mf_menu);
+		mf->ch_window->mf_menu = NULL;
+		return;
+	}
+
+	unsigned short int row = 3;
+	unsigned short int col = 1;
+	int win_x = NULL;
+	int win_y = NULL;
+	
+	GtkWidget *bold_button = NULL;
+	GtkWidget *italic_button = NULL;
+	GtkWidget *underline_button = NULL;
+
+	GtkWidget *mf_table = NULL;
+	GtkWidget *mf_menu = NULL;
+
+	mf_table = gtk_table_new(row, col, TRUE);
+	
+	bold_button = gtk_button_new_with_label("Bold");	
+	g_signal_connect(bold_button, "clicked", G_CALLBACK(bold_format), cw);
+	gtk_table_attach_defaults(mf_table, bold_button, 0, 1, 0, 1);
+
+	italic_button = gtk_button_new_with_label("Italic");	
+	g_signal_connect(italic_button, "clicked", G_CALLBACK(italic_format), cw);
+	gtk_table_attach_defaults(mf_table, italic_button, 0, 1, 1, 2);
+	
+	underline_button = gtk_button_new_with_label("Underline");	
+	g_signal_connect(underline_button, "clicked", G_CALLBACK(underline_format), cw);
+	gtk_table_attach_defaults(mf_table, underline_button, 0, 1, 2, 3);
+
+	mf_menu = gtk_window_new(GTK_WINDOW_POPUP);
+	gtk_window_set_modal(GTK_WINDOW(mf_menu), FALSE);
+	gtk_window_set_title(GTK_WINDOW(mf_menu), "Message Format");
+	gtk_window_set_resizable(GTK_WINDOW(mf_menu), FALSE);
+	gtk_widget_realize(mf_menu);
+	
+	gtk_container_add(GTK_CONTAINER(mf_menu), mf_table);
+	
+	gdk_window_get_pointer(NULL, &win_x, &win_y, NULL);
+	win_x += 5;
+	win_y += 5;
+	while ((win_x) + 10 > gdk_screen_width() - 30)
+		win_x -= 20;
+	while ((win_y) + 20 > gdk_screen_height() - 30)
+		win_y -= 20;
+	gtk_window_move(GTK_WINDOW(mf_menu), win_x, win_y);
+
+	if (mf && mf->ch_window)
+		mf->ch_window->mf_menu = mf_menu;
+
+	gtk_widget_show_all(mf_menu);
+}
+
 /* This is the callback for file x-fer*/
 static void send_file(GtkWidget *sendf_button, gpointer userdata)
 {
@@ -1017,6 +1101,20 @@
 		gtk_menu_shell_append(GTK_MENU_SHELL(menu), button);
 		gtk_widget_show(button);
 
+		/* Text Format */
+		button = gtk_menu_item_new_with_label(_("Text Format"));
+		g_signal_connect(button, "activate",
+			G_CALLBACK(message_format), cw);
+		gtk_menu_shell_append(GTK_MENU_SHELL(menu), button);
+		gtk_widget_show(button);
+
+		/* Color Selection */
+		button = gtk_check_menu_item_new_with_label(_("Color Format"));
+		g_signal_connect(button, "activate",
+			G_CALLBACK(color_format), cw);
+		gtk_menu_shell_append(GTK_MENU_SHELL(menu), button);
+		gtk_widget_show(button);
+
 		/* Send message Section */
 		button = gtk_menu_item_new_with_label(_("Send Message"));
 		g_signal_connect(button, "activate", G_CALLBACK(send_message),
@@ -2268,6 +2366,8 @@
 	GtkWidget *add_button;
 	GtkWidget *sendf_button;
 	GtkWidget *send_button;
+	GtkWidget *format_button;
+	GtkWidget *color_button;
 	GtkWidget *view_log_button;
 	GtkWidget *print_button;
 	GtkWidget *close_button;
@@ -2330,7 +2430,7 @@
 
 	gtk_container_add(GTK_CONTAINER(scrollwindow), cw->chat);
 	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwindow),
-		GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
+		GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
 	gtk_widget_show(scrollwindow);
 
 	/* Create the bar for resizing chat/window box */
@@ -2566,6 +2666,24 @@
 
 	TOOLBAR_APPEND_SPACE(TRUE);
 
+	/* This is the text format button */
+	ICON_CREATE_XPM(icon, iconwid, txt_format_xpm);
+	TOOLBAR_APPEND(format_button, _("Message Format"), iconwid,
+		message_format, cw);
+	gtk_widget_add_accelerator(format_button, "clicked", accel_group, GDK_f,
+		GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
+
+	TOOLBAR_APPEND_SPACE(TRUE);
+
+	/* This is the color format button */
+	ICON_CREATE_XPM(icon, iconwid, txt_format_xpm);
+	TOOLBAR_APPEND(color_button, _("Color Format"), iconwid,
+		color_format, cw);
+	gtk_widget_add_accelerator(color_button, "clicked", accel_group, GDK_f,
+		GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
+
+	TOOLBAR_APPEND_SPACE(TRUE);
+
 	/* This is the send button */
 	ICON_CREATE(iconwid, GTK_STOCK_OK);
 	TOOLBAR_APPEND(send_button, _("Send Message CTRL+R"), iconwid,
diff -Nur ori/ayttm-0.6.1/src/chat_window.h work/ayttm-0.6.1/src/chat_window.h
--- ori/ayttm-0.6.1/src/chat_window.h	2009-10-16 05:04:36.000000000 -0400
+++ work/ayttm-0.6.1/src/chat_window.h	2009-11-04 15:30:44.000000000 -0500
@@ -43,6 +43,7 @@
 	GtkWidget *entry;
 	GtkWidget *smiley_button;
 	GtkWidget *smiley_window;
+	GtkWidget *mf_menu;
 	GtkWidget *sound_button;
 	GtkWidget *offline_button;
 	GtkWidget *status_label;
@@ -155,4 +156,10 @@
 
 void ay_set_chat_encoding(GtkWidget *widget, void *data);
 
+typedef struct _message_format_callback_data message_format_callback_data;
+
+struct _message_format_callback_data {
+	chat_window *ch_window;
+};
+
 #endif
diff -Nur ori/ayttm-0.6.1/pixmaps/txt_format.xpm work/ayttm-0.6.1/pixmaps/txt_format.xpm
--- ori/ayttm-0.6.1/pixmaps/txt_format.xpm	1969-12-31 19:00:00.000000000 -0500
+++ work/ayttm-0.6.1/pixmaps/txt_format.xpm	2009-10-30 17:32:11.000000000 -0400
@@ -0,0 +1,30 @@
+/* XPM */
+static char * txt_format_xpm[] = {
+"24 24 3 1",
+" 	c None",
+".	c #000000",
+"+	c #FDFF09",
+"                        ",
+"                        ",
+"                        ",
+"                        ",
+" ...................... ",
+" .++++++++++++++++++++. ",
+" .++++++++++++++++++++. ",
+" .++......++++......++. ",
+" ....    .++++.    .... ",
+"         .++++.         ",
+"         .++++.         ",
+"         .++++.         ",
+"         .++++.         ",
+"         .++++.         ",
+"         .++++.         ",
+"         .++++.         ",
+"         .++++.         ",
+"         .++++.         ",
+"        ..++++..        ",
+"        .++++++.        ",
+"        ........        ",
+"                        ",
+"                        ",
+"                        "};