[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Ayttm-commits] CVS: ayttm/src about.c,1.7,1.8 chat_room.c,1.7,1.8 chat_
From: |
Colin Leroy <address@hidden> |
Subject: |
[Ayttm-commits] CVS: ayttm/src about.c,1.7,1.8 chat_room.c,1.7,1.8 chat_window.c,1.10,1.11 main.c,1.5,1.6 smileys.c,1.4,1.5 smileys.h,1.1.1.1,1.2 |
Date: |
Wed, 08 Jan 2003 20:02:56 -0500 |
Update of /cvsroot/ayttm/ayttm/src
In directory subversions:/tmp/cvs-serv15998/src
Modified Files:
about.c chat_room.c chat_window.c main.c smileys.c smileys.h
Log Message:
cleaning 2
Index: about.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/about.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- about.c 8 Jan 2003 20:03:56 -0000 1.7
+++ about.c 9 Jan 2003 01:02:54 -0000 1.8
@@ -126,7 +126,6 @@
GtkStyle *style = NULL;
GdkPixmap *pm = NULL;
GdkBitmap *bm = NULL;
- int i = 0;
const char *versionStr = "Yattm " VERSION "\n" __DATE__;
Index: chat_room.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/chat_room.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- chat_room.c 8 Jan 2003 20:50:09 -0000 1.7
+++ chat_room.c 9 Jan 2003 01:02:54 -0000 1.8
@@ -21,7 +21,7 @@
static GList * get_contacts( eb_chat_room * room );
-static void send_message( GtkWidget * widget, gpointer data )
+static void send_cr_message( GtkWidget * widget, gpointer data )
{
eb_chat_room * ecr = (eb_chat_room *)data;
@@ -45,123 +45,6 @@
cr->sound_enabled = FALSE;
}
-static void insert_cr_smiley (GtkWidget * widget, eb_chat_room *cr)
-{
- gint pos=0;
- if(GTK_EDITABLE(cr->entry) && GTK_EDITABLE(cr->entry)->current_pos)
- pos=GTK_EDITABLE(cr->entry)->current_pos;
- gtk_editable_insert_text(GTK_EDITABLE (cr->entry),
- gtk_widget_get_name(widget),
- strlen(gtk_widget_get_name(widget)),
- &pos);
- gtk_editable_set_position(GTK_EDITABLE(cr->entry),
- pos);
- gtk_widget_destroy(cr->smiley_window);
- cr->smiley_window = NULL;
-}
-
-static void show_cr_smileys_callback(GtkWidget *widget, gpointer d)
-{
- eb_chat_room *data = (eb_chat_room*) d;
- GList *smileys = NULL;
- protocol_smiley * msmiley = NULL;
- GtkWidget * smileys_table = NULL;
- GtkWidget * button = NULL;
- GtkWidget *iconwid;
- GdkPixmap *icon;
- GdkBitmap *mask;
- GList *done = NULL;
- int len = 0, real_len = 0, x=-1, y=0;
- int win_w=0, win_h=0, w, h;
- gint win_x, win_y;
- if(data->smiley_window != NULL) {
- /* close popup */
- gtk_widget_destroy(data->smiley_window);
- data->smiley_window = NULL;
- return;
- }
-
- if (data && data->chat_room_account && RUN_SERVICE(data->chat_room_account))
- smileys = RUN_SERVICE(data->chat_room_account)->get_smileys();
- else
- return;
- len = g_list_length(smileys);
- smileys_table = gtk_table_new(5,len/5 +((len%5==0)?1:2),TRUE);
- for(;smileys;smileys=g_list_next(smileys)) {
- GList * l;
- gboolean already_done = FALSE;
- smiley * dsmile = NULL;
- msmiley = (smileys->data);
- for(l=done; l; l=g_list_next(l)) {
- if(!strcmp((char*)l->data, msmiley->name)) {
- already_done = TRUE;
- break;
- }
- }
-
- if(already_done)
- continue;
-
- done = g_list_append(done, msmiley->name);
-
- dsmile = get_smiley_by_name(msmiley->name);
- if(dsmile != NULL) {
- icon = gdk_pixmap_create_from_xpm_d(data->window->window, &mask,
NULL, dsmile->pixmap);
- iconwid = gtk_pixmap_new(icon, mask);
- sscanf (dsmile->pixmap [0], "%d %d", &w, &h);
- if(x<5) {
- x++;
- if(y==0) win_h+=h+2;
- }
- if(x==5) {
- y++;
- x=0;
- if(x==0) win_w+=w+2;
- }
- gtk_widget_show(iconwid);
- button = gtk_button_new();
- gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
- gtk_container_add(GTK_CONTAINER(button), iconwid);
- gtk_widget_show(button);
- gtk_widget_set_name(button,msmiley->text);
- gtk_signal_connect (GTK_OBJECT (button), "clicked",
- GTK_SIGNAL_FUNC (insert_cr_smiley), data);
- gtk_table_attach(GTK_TABLE(smileys_table),
- button,
- y,y+1,
- x,x+1,
- GTK_FILL, GTK_FILL, 0, 0);
- real_len++;
- }
- }
-
- g_list_free(done);
- done = NULL;
- gtk_table_resize(GTK_TABLE(smileys_table), 5,real_len/5
+((real_len%5==0)?0:1));
-
- data->smiley_window = gtk_window_new(GTK_WINDOW_DIALOG);
- gtk_window_set_modal(GTK_WINDOW(data->smiley_window), FALSE);
- gtk_window_set_wmclass(GTK_WINDOW(data->smiley_window), "yattm-chat",
"Yattm");
- gtk_window_set_title(GTK_WINDOW(data->smiley_window), "Smileys");
- gtk_window_set_policy(GTK_WINDOW(data->smiley_window), FALSE, FALSE, FALSE);
- gtk_widget_realize(data->smiley_window);
-
- gtk_widget_show(data->smiley_window);
-
- gtk_container_add(GTK_CONTAINER(data->smiley_window), smileys_table);
- gtk_widget_show(smileys_table);
-
- /* move the window a bit after the cursor and in the screen */
- gdk_window_get_pointer (NULL, &win_x, &win_y, NULL);
- win_x += 5; win_y += 5;
- while ((win_x)+win_w > gdk_screen_width() - 30)
- win_x -= 20;
- while ((win_y)+win_h > gdk_screen_height() - 30)
- win_y -= 20;
- gdk_window_move_resize(data->smiley_window->window, win_x, win_y, win_w,
win_h);
-
-}
-
static GList * chat_service_list()
{
GList * list = NULL;
@@ -487,13 +370,10 @@
void eb_chat_room_buddy_arrive( eb_chat_room * room, gchar * alias, gchar *
handle )
{
eb_chat_room_buddy * ecrb = g_new0(eb_chat_room_buddy, 1 );
- gchar *tmp;
- gchar buff[2048];
- tmp = g_strdup_printf("%s (%s)", alias, handle);
- g_snprintf(buff, 2048, _("<i>%s has joined the chat</i>"), tmp);
- g_free(tmp);
- eb_chat_room_show_3rdperson(room, buff);
-
+ gchar *buf;
+ buf = g_strdup_printf(_("<i>%s (%s) has joined the chat</i>"), alias,
handle);
+ eb_chat_room_show_3rdperson(room, buf);
+ g_free(buf);
strcpy( ecrb->alias, alias);
strcpy( ecrb->handle, handle );
@@ -507,11 +387,12 @@
{
GList * node = find_chat_room_buddy(room, handle);
- gchar buff[2048];
- g_snprintf(buff, 2048, _("<i>%s has left the chat</i>"), handle);
- eb_chat_room_show_3rdperson(room, buff);
+ gchar *buf;
+ buf = g_strdup_printf(_("<i>%s has left the chat</i>"), handle);
+ eb_chat_room_show_3rdperson(room, buf);
+ g_free(buf);
- if(node)
+ if(node && room->fellows)
{
eb_chat_room_buddy * ecrb = node->data;
room->fellows = g_list_remove_link(room->fellows, node);
@@ -654,7 +535,7 @@
chat_room->entry = gtk_entry_new();
gtk_signal_connect(GTK_OBJECT(chat_room->entry), "activate",
- GTK_SIGNAL_FUNC(send_message),
chat_room );
+
GTK_SIGNAL_FUNC(send_cr_message), chat_room );
/*
@@ -716,6 +597,9 @@
/* smileys */
if(do_smiley == 1) {
+ smiley_callback_data * scd = g_new0(smiley_callback_data,1);
+ scd->c_room = chat_room;
+ scd->c_window = NULL;
icon = gdk_pixmap_create_from_xpm_d(chat_room->window->window,
&mask, NULL, smiley_button_xpm);
iconwid = gtk_pixmap_new(icon, mask);
@@ -725,8 +609,8 @@
_("Insert Smiley"),
_("Smiley"),
iconwid,
-
GTK_SIGNAL_FUNC(show_cr_smileys_callback),
- chat_room);
+
GTK_SIGNAL_FUNC(show_smileys_cb),
+ scd);
/*Create the separator for the toolbar*/
gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
@@ -784,7 +668,7 @@
_("Send Message"),
"send",
iconwid,
- GTK_SIGNAL_FUNC(send_message),
+ GTK_SIGNAL_FUNC(send_cr_message),
chat_room);
icon = gdk_pixmap_create_from_xpm_d(chat_room->window->window, &mask,
NULL, cancel_xpm);
Index: chat_window.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/chat_window.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- chat_window.c 4 Jan 2003 13:59:27 -0000 1.10
+++ chat_window.c 9 Jan 2003 01:02:54 -0000 1.11
@@ -599,122 +599,6 @@
eb_view_log(data->contact);
}
-static void insert_smiley (GtkWidget * widget, chat_window * cw)
-{
- gint pos=0;
- GET_CHAT_WINDOW(cw);
- if(GTK_EDITABLE(cw->entry) && GTK_EDITABLE(cw->entry)->current_pos)
- pos=GTK_EDITABLE(cw->entry)->current_pos;
- gtk_editable_insert_text(GTK_EDITABLE (cw->entry),
- gtk_widget_get_name(widget),
- strlen(gtk_widget_get_name(widget)),
- &pos);
- gtk_widget_destroy(cw->smiley_window);
- cw->smiley_window = NULL;
-}
-
-static void show_smileys_callback(GtkWidget *widget, gpointer d)
-{
- chat_window *data = (chat_window*) d;
- GList *smileys = NULL;
- protocol_smiley * msmiley = NULL;
- GtkWidget * smileys_table = NULL;
- GtkWidget * button = NULL;
- GtkWidget *iconwid;
- GdkPixmap *icon;
- GdkBitmap *mask;
- GList *done = NULL;
- int len = 0, real_len = 0, x=-1, y=0;
- int win_w=0, win_h=0, w, h;
- gint win_x, win_y;
- if(data->smiley_window != NULL) {
- /* close popup */
- gtk_widget_destroy(data->smiley_window);
- data->smiley_window = NULL;
- return;
- }
-
- if (data && data->local_user && RUN_SERVICE(data->local_user))
- smileys = RUN_SERVICE(data->local_user)->get_smileys();
- else
- return;
- len = g_list_length(smileys);
- smileys_table = gtk_table_new(5,len/5 +((len%5==0)?1:2),TRUE);
- for(;smileys;smileys=g_list_next(smileys)) {
- GList * l;
- gboolean already_done = FALSE;
- smiley * dsmile = NULL;
- msmiley = (smileys->data);
- for(l=done; l; l=g_list_next(l)) {
- if(!strcmp((char*)l->data, msmiley->name)) {
- already_done = TRUE;
- break;
- }
- }
-
- if(already_done)
- continue;
-
- done = g_list_append(done, msmiley->name);
-
- dsmile = get_smiley_by_name(msmiley->name);
- if(dsmile != NULL) {
- icon = gdk_pixmap_create_from_xpm_d(data->window->window, &mask,
NULL, dsmile->pixmap);
- iconwid = gtk_pixmap_new(icon, mask);
- sscanf (dsmile->pixmap [0], "%d %d", &w, &h);
- if(x<5) {
- x++;
- if(y==0) win_h+=h+2;
- }
- if(x==5) {
- y++;
- x=0;
- if(x==0) win_w+=w+2;
- }
- gtk_widget_show(iconwid);
- button = gtk_button_new();
- gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
- gtk_container_add(GTK_CONTAINER(button), iconwid);
- gtk_widget_show(button);
- gtk_widget_set_name(button,msmiley->text);
- gtk_signal_connect (GTK_OBJECT (button), "clicked",
- GTK_SIGNAL_FUNC (insert_smiley), data);
- gtk_table_attach(GTK_TABLE(smileys_table),
- button,
- y,y+1,
- x,x+1,
- GTK_FILL, GTK_FILL, 0, 0);
- real_len++;
- }
- }
-
- g_list_free(done);
- done = NULL;
- gtk_table_resize(GTK_TABLE(smileys_table), 5,real_len/5
+((real_len%5==0)?0:1));
-
- data->smiley_window = gtk_window_new(GTK_WINDOW_DIALOG);
- gtk_window_set_modal(GTK_WINDOW(data->smiley_window), FALSE);
- gtk_window_set_wmclass(GTK_WINDOW(data->smiley_window), "yattm-chat",
"Yattm");
- gtk_window_set_title(GTK_WINDOW(data->smiley_window), "Smileys");
- gtk_window_set_policy(GTK_WINDOW(data->smiley_window), FALSE, FALSE, FALSE);
- gtk_widget_realize(data->smiley_window);
-
- gtk_widget_show(data->smiley_window);
-
- gtk_container_add(GTK_CONTAINER(data->smiley_window), smileys_table);
- gtk_widget_show(smileys_table);
-
- /* move the window a bit after the cursor and in the screen */
- gdk_window_get_pointer (NULL, &win_x, &win_y, NULL);
- win_x += 5; win_y += 5;
- while ((win_x)+win_w > gdk_screen_width() - 30)
- win_x -= 20;
- while ((win_y)+win_h > gdk_screen_height() - 30)
- win_y -= 20;
- gdk_window_move_resize(data->smiley_window->window, win_x, win_y, win_w,
win_h);
-
-}
-
/*This is the callback for ignoring a user*/
static void ignore_dialog_callback (GtkWidget *widget, gpointer userdata)
@@ -1342,6 +1226,9 @@
chat_window *tab_cw;
GtkPositionType pos;
GtkWidget *contact_label;
+ smiley_callback_data * scd = g_new0(smiley_callback_data,1);
+ scd->c_window = NULL;
+ scd->c_room = NULL;
if (do_ignore_unknown)
{
@@ -1685,13 +1572,14 @@
icon = gdk_pixmap_create_from_xpm_d(cw->window->window, &mask, NULL,
smiley_button_xpm);
iconwid = gtk_pixmap_new(icon, mask);
gtk_widget_show(iconwid);
+ scd->c_window = cw;
cw->smiley_button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
_("Smiley"),
_("Insert Smiley"),
_("Smiley"),
iconwid,
-
GTK_SIGNAL_FUNC(show_smileys_callback),
- cw);
+
GTK_SIGNAL_FUNC(show_smileys_cb),
+ scd);
/*Create the separator for the toolbar*/
gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
Index: main.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/main.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- main.c 5 Jan 2003 08:32:16 -0000 1.5
+++ main.c 9 Jan 2003 01:02:54 -0000 1.6
@@ -55,6 +55,7 @@
#include "smileys.h"
#include "libproxy/libproxy.h"
#include "console_session.h"
+#include "prefs.h"
#include <locale.h>
Index: smileys.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/smileys.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- smileys.c 8 Jan 2003 18:52:28 -0000 1.4
+++ smileys.c 9 Jan 2003 01:02:54 -0000 1.5
@@ -282,3 +282,163 @@
}
return NULL;
}
+
+void insert_smiley_cb (GtkWidget * widget, smiley_callback_data *data)
+{
+ GtkEditable *entry = NULL;
+ int pos;
+ if (data->c_room)
+ entry = GTK_EDITABLE(data->c_room->entry);
+ else if (data->c_window)
+ entry = GTK_EDITABLE(data->c_window->entry);
+ else {
+ eb_debug(DBG_CORE, "smiley_callback_data has no chat* !\n");
+ return;
+ }
+
+ if(entry && entry->current_pos)
+ pos=entry->current_pos;
+ gtk_editable_insert_text(entry,
+ gtk_widget_get_name(widget),
+ strlen(gtk_widget_get_name(widget)),
+ &pos);
+ gtk_editable_set_position(entry,
+ pos);
+ if (data->c_room && data->c_room->smiley_window) {
+ gtk_widget_destroy(data->c_room->smiley_window);
+ data->c_room->smiley_window = NULL;
+ } else if (data->c_window && data->c_window->smiley_window) {
+ gtk_widget_destroy(data->c_window->smiley_window);
+ data->c_window->smiley_window = NULL;
+ }
+ else
+ eb_debug(DBG_CORE, "smiley_window is null * !\n");
+}
+
+void show_smileys_cb (GtkWidget *widget, smiley_callback_data *data) {
+ eb_local_account *account;
+ GList *smileys = NULL;
+ protocol_smiley * msmiley = NULL;
+ GtkWidget * smileys_table = NULL;
+ GtkWidget * button = NULL;
+ GtkWidget *iconwid;
+ GdkPixmap *icon;
+ GdkBitmap *mask;
+ GtkWidget *smiley_window;
+ GList *done = NULL;
+ int len = 0, real_len = 0, x=-1, y=0;
+ int win_w=0, win_h=0, w, h;
+ int win_x, win_y;
+
+ /* close popup if open */
+ if (data->c_room && data->c_room->smiley_window) {
+ gtk_widget_destroy(data->c_room->smiley_window);
+ data->c_room->smiley_window = NULL;
+ return;
+ } else if (data->c_window && data->c_window->smiley_window) {
+ gtk_widget_destroy(data->c_window->smiley_window);
+ data->c_window->smiley_window = NULL;
+ return;
+ }
+
+ if (data && data->c_room)
+ account = data->c_room->chat_room_account;
+ else if (data && data->c_window)
+ account = data->c_window->local_user;
+ else {
+ eb_debug(DBG_CORE, "no chat* in data !\n");
+ return;
+ }
+
+ if (account && RUN_SERVICE(account))
+ smileys = RUN_SERVICE(account)->get_smileys();
+ else
+ return;
+ len = g_list_length(smileys);
+ smileys_table = gtk_table_new(5,len/5 +((len%5==0)?1:2),TRUE);
+ for(;smileys;smileys=g_list_next(smileys)) {
+ GList * l;
+ gboolean already_done = FALSE;
+ smiley * dsmile = NULL;
+ msmiley = (smileys->data);
+ for(l=done; l; l=g_list_next(l)) {
+ if(!strcmp((char*)l->data, msmiley->name)) {
+ already_done = TRUE;
+ break;
+ }
+ }
+
+ if(already_done)
+ continue;
+
+ done = g_list_append(done, msmiley->name);
+
+ dsmile = get_smiley_by_name(msmiley->name);
+ if(dsmile != NULL) {
+ GtkWidget *parent = NULL;
+ if (data && data->c_room)
+ parent = data->c_room->window;
+ else if (data && data->c_window)
+ parent = data->c_window->window;
+ icon = gdk_pixmap_create_from_xpm_d(parent->window,
&mask, NULL, dsmile->pixmap);
+ iconwid = gtk_pixmap_new(icon, mask);
+ sscanf (dsmile->pixmap [0], "%d %d", &w, &h);
+ if(x<5) {
+ x++;
+ if(y==0)
+ win_h+=h+2;
+ }
+ if(x==5) {
+ y++;
+ x=0;
+ if(x==0)
+ win_w+=w+2;
+ }
+ gtk_widget_show(iconwid);
+ button = gtk_button_new();
+ gtk_button_set_relief(GTK_BUTTON(button),
GTK_RELIEF_NONE);
+ gtk_container_add(GTK_CONTAINER(button), iconwid);
+ gtk_widget_show(button);
+ gtk_widget_set_name(button,msmiley->text);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (insert_smiley_cb), data);
+ gtk_table_attach(GTK_TABLE(smileys_table),
+ button,
+ y,y+1,
+ x,x+1,
+ GTK_FILL, GTK_FILL, 0, 0);
+ real_len++;
+ }
+ }
+
+ g_list_free(done);
+ done = NULL;
+ gtk_table_resize(GTK_TABLE(smileys_table), 5,real_len/5
+((real_len%5==0)?0:1));
+
+ smiley_window = gtk_window_new(GTK_WINDOW_DIALOG);
+ gtk_window_set_modal(GTK_WINDOW(smiley_window), FALSE);
+ gtk_window_set_wmclass(GTK_WINDOW(smiley_window), "yattm-chat",
"Yattm");
+ gtk_window_set_title(GTK_WINDOW(smiley_window), "Smileys");
+ gtk_window_set_policy(GTK_WINDOW(smiley_window), FALSE, FALSE, FALSE);
+ gtk_widget_realize(smiley_window);
+
+ gtk_widget_show(smiley_window);
+
+ gtk_container_add(GTK_CONTAINER(smiley_window), smileys_table);
+ gtk_widget_show(smileys_table);
+
+ /* move the window a bit after the cursor and in the screen */
+ gdk_window_get_pointer (NULL, &win_x, &win_y, NULL);
+ win_x += 5; win_y += 5;
+ while ((win_x)+win_w > gdk_screen_width() - 30)
+ win_x -= 20;
+ while ((win_y)+win_h > gdk_screen_height() - 30)
+ win_y -= 20;
+ gdk_window_move_resize(smiley_window->window, win_x, win_y, win_w,
win_h);
+
+ if (data && data->c_room)
+ data->c_room->smiley_window = smiley_window;
+ else if (data && data->c_window)
+ data->c_window->smiley_window = smiley_window;
+
+}
Index: smileys.h
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/smileys.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- smileys.h 23 Dec 2002 22:05:39 -0000 1.1.1.1
+++ smileys.h 9 Jan 2003 01:02:54 -0000 1.2
@@ -1,6 +1,8 @@
-#ifndef _SMILEYS_
-#define _SMILEYS_
+#ifndef __SMILEYS_H_
+#define __SMILEYS_H_
+#include "chat_window.h"
+#include "chat_room.h"
struct protocol_smiley_struct
{
@@ -42,6 +44,19 @@
GList * eb_smileys(void);
smiley * get_smiley_by_name(char * name);
+
+typedef struct _smiley_callback_data smiley_callback_data;
+
+struct _smiley_callback_data
+{
+ eb_chat_room *c_room;
+ chat_window *c_window;
+};
+
+void insert_smiley_cb (GtkWidget * widget, smiley_callback_data *data);
+void show_smileys_cb (GtkWidget *widget, smiley_callback_data *data);
+
+
extern int do_smiley;
#ifdef __cplusplus
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Ayttm-commits] CVS: ayttm/src about.c,1.7,1.8 chat_room.c,1.7,1.8 chat_window.c,1.10,1.11 main.c,1.5,1.6 smileys.c,1.4,1.5 smileys.h,1.1.1.1,1.2,
Colin Leroy <address@hidden> <=