[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Ayttm-commits] CVS: ayttm/src chat_window.c,1.38,1.39 chat_window.h,1.
From: |
Colin Leroy <address@hidden> |
Subject: |
[Ayttm-commits] CVS: ayttm/src chat_window.c,1.38,1.39 chat_window.h,1.8,1.9 crash.c,1.11,1.12 |
Date: |
Tue, 28 Jan 2003 04:27:08 -0500 |
Update of /cvsroot/ayttm/ayttm/src
In directory subversions:/tmp/cvs-serv13733/src
Modified Files:
chat_window.c chat_window.h crash.c
Log Message:
begin grouping gtk things together (duh, what a work :-/)
Index: chat_window.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/chat_window.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- chat_window.c 28 Jan 2003 08:08:55 -0000 1.38
+++ chat_window.c 28 Jan 2003 09:27:05 -0000 1.39
@@ -169,12 +169,23 @@
#endif /* HAVE_ICONV_H */
-static void set_tab_red(GtkNotebook *notebook, GtkWidget *child)
+static void set_tab_red(struct contact *ct)
{
GtkStyle *style;
GdkColor color;
+ GtkWidget *notebook = NULL;
+ GtkWidget *child = NULL;
+ GtkWidget *label = NULL;
- GtkWidget *label = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook),
child);
+ if (!ct || !ct->chatwindow)
+ return;
+ notebook = ct->chatwindow->notebook;
+ child = ct->chatwindow->notebook_child;
+
+ if (!notebook || !child)
+ return;
+
+ label = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), child);
gtk_widget_realize(label);
@@ -191,12 +202,24 @@
gtk_widget_set_style(label, style);
}
-static void set_tab_normal(GtkNotebook *notebook, GtkWidget *child)
+static void set_tab_normal(struct contact *ct)
{
GtkStyle *style;
GdkColor color;
- GtkWidget *label = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook),
child);
+ GtkWidget *notebook = NULL;
+ GtkWidget *child = NULL;
+ GtkWidget *label = NULL;
+
+ if (!ct || !ct->chatwindow)
+ return;
+ notebook = ct->chatwindow->notebook;
+ child = ct->chatwindow->notebook_child;
+
+ if (!notebook || !child)
+ return;
+
+ label = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), child);
gtk_widget_realize(label);
color.red = 0;
@@ -216,7 +239,7 @@
static void end_conversation(chat_window* cw)
{
LList * node;
- GList * node2;
+ LList * node2;
/* cw->window=NULL; */
@@ -243,7 +266,7 @@
node2->data=NULL;
}
- g_list_free(cw->history);
+ l_list_free(cw->history);
/*
* if we are logging conversations, time stamp when the conversation
@@ -294,12 +317,23 @@
end_conversation(cw);
}
-static void close_tab_callback(GtkWidget *button, gpointer userdata)
+static void remove_tab(struct contact *ct)
{
- chat_window *cw = (chat_window*)userdata;
- GtkWidget *window = cw->window;
- GtkWidget *notebook = cw->notebook;
- gint tab_number;
+ GtkWidget *window = ct->chatwindow->window;
+ GtkWidget *notebook = ct->chatwindow->notebook;
+ int tab_number;
+
+ tab_number = gtk_notebook_page_num (GTK_NOTEBOOK(notebook),
ct->chatwindow->notebook_child);
+ gtk_notebook_remove_page(GTK_NOTEBOOK(notebook), tab_number);
+
+ if (gtk_notebook_get_number_pages(GTK_NOTEBOOK(notebook)) == 0) {
+ gtk_widget_destroy(window);
+ }
+}
+
+static void remove_smiley_window(struct contact *ct)
+{
+ chat_window *cw = ct->chatwindow;
GET_CHAT_WINDOW(cw);
if(cw->smiley_window != NULL && cw->smiley_window->window != NULL) {
@@ -307,34 +341,15 @@
gtk_widget_destroy(cw->smiley_window);
cw->smiley_window = NULL;
}
- cw = (chat_window*)userdata;
-
- /* we got called to kill the tab, so find out which tab number
- we need to kill */
- tab_number = gtk_notebook_page_num(GTK_NOTEBOOK(notebook),
- cw->notebook_child);
-
- gtk_notebook_remove_page(GTK_NOTEBOOK(notebook), tab_number);
-
- /*
- * WARNING: AT THIS POINT IN TIME cw IS NO LONGER AVAILABLE
- * end_conversation calls a g_free on cw
- * gtk_notebook_remove_page triggers the destroy signal on the vbox
- * (which calls end_conversation via destroy_event)
- */
+
+}
- /*
- * Question: Now, as soon as the last page from the notebook gets
- * removed the window disappears, and I didn't find a call to destroy
- * it so... i've left in this destroy.. but I really don't know if it
- * is needed...
- */
+static void close_tab_callback(GtkWidget *button, gpointer userdata)
+{
+ chat_window *cw = (chat_window*)userdata;
- if (gtk_notebook_get_number_pages(GTK_NOTEBOOK(notebook)) == 0) {
- /* we just delete the last conversation, no point in having
the window */
- /* around... note that this also causes end_conversation to be
called... */
- gtk_widget_destroy(window);
- }
+ remove_smiley_window(cw->contact);
+ remove_tab (cw->contact);
}
static void add_unknown_callback(GtkWidget * add_button, gpointer userdata)
@@ -366,6 +381,29 @@
add_unknown_account_window_new(cw->preferred);
}
+static char *cw_get_message(chat_window *cw)
+{
+ return gtk_editable_get_chars(GTK_EDITABLE (cw->entry), 0, -1);
+}
+
+static int cw_set_message(chat_window *cw, char *msg)
+{
+ int p=0;
+ gtk_editable_insert_text(GTK_EDITABLE (cw->entry), msg, strlen(msg),
&p);
+ return p;
+
+}
+
+static void cw_reset_message(chat_window *cw)
+{
+ gtk_editable_delete_text(GTK_EDITABLE (cw->entry), 0, -1);
+}
+
+static void cw_put_message(chat_window *cw, char *text, int fore, int back,
int font)
+{
+ gtk_eb_html_add(EXT_GTK_TEXT(cw->chat), text, fore, back, font);
+}
+
void send_message(GtkWidget *widget, gpointer d)
{
chat_window * data = (chat_window*)d;
@@ -394,9 +432,9 @@
if(data->contact->send_offline &&
can_offline_message(data->contact)) {
data->preferred = can_offline_message(data->contact);
} else {
- gtk_eb_html_add(EXT_GTK_TEXT(data->chat), "<hr>",
0,0,0);
- gtk_eb_html_add(EXT_GTK_TEXT(data->chat), "<b>Cannot
send message - user is offline.</b>", 0, 0, 0);
- gtk_eb_html_add(EXT_GTK_TEXT(data->chat), "<hr>",
0,0,0);
+ cw_put_message(data, "<hr>",0,0,0);
+ cw_put_message(data, "<b>Cannot send message - user is
offline.</b>",0,0,0);
+ cw_put_message(data, "<hr>",0,0,0);
return;
}
}
@@ -417,14 +455,14 @@
eb_update_window_title(data, FALSE);
- text = gtk_editable_get_chars(GTK_EDITABLE (data->entry), 0, -1);
+ text = cw_get_message(data);
if(strlen(text) == 0)
return;
if(data->this_msg_in_history) {
- GList * node=NULL;
- GList * node2=NULL;
+ LList * node=NULL;
+ LList * node2=NULL;
for(node=data->history; node!=NULL ; node=node->next)
node2=node;
@@ -432,7 +470,7 @@
node2->data=strdup(text);
data->this_msg_in_history=0;
} else {
- data->history=g_list_append(data->history, strdup(text));
+ data->history=l_list_append(data->history, strdup(text));
data->hist_pos=NULL;
}
@@ -506,10 +544,9 @@
g_snprintf(buff, BUF_SIZE, "<FONT COLOR=\"#0000ff\"><B>%s:
</B></FONT>", buff2);
- gtk_eb_html_add(EXT_GTK_TEXT(data->chat), buff, 1, 0, 0);
- gtk_eb_html_add(EXT_GTK_TEXT(data->chat), link_message,
- iGetLocalPref("do_ignore_back"), iGetLocalPref("do_ignore_fore"),
iGetLocalPref("do_ignore_font"));
- gtk_eb_html_add(EXT_GTK_TEXT(data->chat), "<br>", 0, 0, 0);
+ cw_put_message(data, buff, 1, 0, 0);
+ cw_put_message(data, link_message, iGetLocalPref("do_ignore_back"),
iGetLocalPref("do_ignore_fore"), iGetLocalPref("do_ignore_font"));
+ cw_put_message(data, "<br>", 0, 0, 0);
/* If an away message had been sent to this person, reset the away
message tracker */
/* It's probably faster to just do the assignment all the time--the test
@@ -523,7 +560,7 @@
if ( iGetLocalPref("do_logging") )
eb_log_message(data, buff, link_message);
- gtk_editable_delete_text(GTK_EDITABLE (data->entry), 0, -1);
+ cw_reset_message(data);
g_free(link_message);
g_free(text);
@@ -533,7 +570,7 @@
/* no more icons in the tabs */
/* gtk_widget_hide(data->talk_pixmap); */
/* printf("chat icon is off... \n"); */
- set_tab_normal(GTK_NOTEBOOK(data->notebook),
data->notebook_child);
+ set_tab_normal(data->contact);
}
}
@@ -551,10 +588,9 @@
/*This is the callback for ignoring a user*/
-static void ignore_dialog_callback (GtkWidget *widget, gpointer userdata)
+static void ignore_dialog_callback (gpointer userdata, int response)
{
struct contact *c = (struct contact *)userdata;
- int response = (int)gtk_object_get_user_data(GTK_OBJECT(widget));
if (response) {
move_contact(_("Ignore"), c);
@@ -572,7 +608,7 @@
g_snprintf(buff, BUF_SIZE, _("Do you really want to ignore %s?\n"),
cw->contact->nick);
- do_dialog(buff, _("Ignore Contact"), ignore_dialog_callback,
cw->contact);
+ eb_do_dialog(buff, _("Ignore Contact"), ignore_dialog_callback,
cw->contact);
g_free(buff);
}
@@ -584,9 +620,9 @@
GET_CHAT_WINDOW(data);
if ( data->contact->online == 0 ) {
- gtk_eb_html_add(EXT_GTK_TEXT(data->chat), "<hr>", 0,0,0);
- gtk_eb_html_add(EXT_GTK_TEXT(data->chat), "<b>Cannot send
message - user is offline.</b>", 0, 0, 0);
- gtk_eb_html_add(EXT_GTK_TEXT(data->chat), "<hr>", 0,0,0);
+ cw_put_message(data, "<hr>", 0,0,0);
+ cw_put_message(data, "<b>Cannot send message - user is
offline.</b>", 0, 0, 0);
+ cw_put_message(data, "<hr>", 0,0,0);
return;
}
@@ -596,25 +632,27 @@
}
/*These are the callback for setting the sound*/
-
-static void set_sound_on_toggle(GtkWidget * sound_button, gpointer userdata)
+static void set_sound_callback(GtkWidget * sound_button, gpointer userdata);
+static void cw_set_sound_active(chat_window *cw, int active)
{
- chat_window * cw = (chat_window *)userdata;
+ cw->sound_enabled = active;
+ gtk_signal_handler_block_by_func(GTK_OBJECT(cw->sound_button),
+ set_sound_callback, cw);
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(cw->sound_button),
active);
+ gtk_signal_handler_unblock_by_func(GTK_OBJECT(cw->sound_button),
+ set_sound_callback, cw);
+}
- /*Set the sound_enable variable depending on the toggle button*/
- cw->sound_enabled = GTK_TOGGLE_BUTTON (sound_button)->active;
+static int cw_get_sound_active(chat_window *cw)
+{
+ return cw->sound_enabled;
}
-static void set_sound_on_click(GtkWidget * button, gpointer userdata)
+static void set_sound_callback(GtkWidget * sound_button, gpointer userdata)
{
chat_window * cw = (chat_window *)userdata;
- gboolean new_state = FALSE;
GET_CHAT_WINDOW(cw);
-
- new_state = !cw->sound_enabled;
-
- cw->sound_enabled = new_state;
- gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(cw->sound_button),
new_state);
+ cw_set_sound_active(cw, !cw_get_sound_active(cw));
}
/*This is the callback for closing the window*/
@@ -625,23 +663,27 @@
gtk_widget_destroy(cw->window);
}
-static void allow_offline_on_toggle (GtkWidget *allow_button, gpointer
userdata)
-{
- chat_window * cw = (chat_window *)userdata;
+static void allow_offline_callback(GtkWidget * offline_button, gpointer
userdata);
+static void cw_set_offline_active(chat_window *cw, int active)
+{
+ cw->contact->send_offline = active;
+ gtk_signal_handler_block_by_func(GTK_OBJECT(cw->offline_button),
+ allow_offline_callback, cw);
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(cw->offline_button),
active);
+ gtk_signal_handler_unblock_by_func(GTK_OBJECT(cw->offline_button),
+ allow_offline_callback, cw);
+}
- /*set send_offline based upon toggle button*/
- cw->contact->send_offline = GTK_TOGGLE_BUTTON (allow_button)->active;
+static int cw_get_offline_active(chat_window *cw)
+{
+ return cw->contact->send_offline;
}
-static void allow_offline_on_click (GtkWidget * button, gpointer userdata)
+static void allow_offline_callback(GtkWidget * offline_button, gpointer
userdata)
{
chat_window * cw = (chat_window *)userdata;
- gboolean new_state = FALSE;
GET_CHAT_WINDOW(cw);
-
- new_state = !cw->contact->send_offline;
- cw->contact->send_offline = new_state;
- gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(cw->allow_button),
new_state);
+ cw_set_offline_active(cw, !cw_get_offline_active(cw));
}
static void change_local_account_on_click (GtkWidget * button, gpointer
userdata)
@@ -750,7 +792,7 @@
if(can_offline_message(cw->contact)) {
button = gtk_menu_item_new_with_label(_("Offline
Messaging"));
gtk_signal_connect(GTK_OBJECT(button), "activate",
- GTK_SIGNAL_FUNC(allow_offline_on_click),
cw);
+ GTK_SIGNAL_FUNC(allow_offline_callback),
cw);
gtk_menu_append(GTK_MENU(menu), button);
gtk_widget_show(button);
}
@@ -768,7 +810,7 @@
button = gtk_menu_item_new_with_label(_("Enable
Sounds"));
gtk_signal_connect(GTK_OBJECT(button), "activate",
- GTK_SIGNAL_FUNC(set_sound_on_click), cw);
+ GTK_SIGNAL_FUNC(set_sound_callback), cw);
gtk_menu_append(GTK_MENU(menu), button);
gtk_widget_show(button);
@@ -900,30 +942,31 @@
if(cw->hist_pos==NULL) {
char * s;
- GList * node;
+ LList * node;
- s= gtk_editable_get_chars(GTK_EDITABLE (cw->entry), 0,
-1);
+ s= cw_get_message(cw);
for(node=cw->history; node!=NULL ; node=node->next)
cw->hist_pos=node;
if(strlen(s)>0) {
- cw->history=g_list_append(cw->history,
strdup(s));
+ cw->history=l_list_append(cw->history,
strdup(s));
g_free(s);
cw->this_msg_in_history=1;
}
} else {
cw->hist_pos=cw->hist_pos->prev;
if(cw->hist_pos==NULL) {
- GList * node;
+ LList * node;
eb_debug(DBG_CORE,"history Wrapped!\n");
for(node=cw->history; node!=NULL ;
node=node->next)
cw->hist_pos=node;
}
}
- gtk_editable_delete_text(GTK_EDITABLE (cw->entry), 0, -1);
- gtk_editable_insert_text(GTK_EDITABLE (cw->entry),
cw->hist_pos->data, strlen(cw->hist_pos->data), &p);
+ cw_reset_message(cw);
+ cw_set_message(cw, cw->hist_pos->data);
+
} else if (event->keyval == GDK_Down) {
gint p=0;
@@ -932,10 +975,10 @@
cw->hist_pos=cw->hist_pos->next;
if(cw->hist_pos==NULL)
- gtk_editable_delete_text(GTK_EDITABLE (cw->entry), 0,
-1);
+ cw_reset_message(cw);
else {
- gtk_editable_delete_text(GTK_EDITABLE (cw->entry), 0,
-1);
- gtk_editable_insert_text(GTK_EDITABLE (cw->entry),
cw->hist_pos->data, strlen(cw->hist_pos->data), &p);
+ cw_reset_message(cw);
+ cw_set_message(cw, cw->hist_pos->data);
}
} else if (cw->notebook != NULL) /* only change tabs if this window is
tabbed */ {
/*
@@ -977,7 +1020,7 @@
/* notebook tab... */
c = (struct contact*)l2->data;
if (c->chatwindow && c->chatwindow->notebook_child ==
page->child) {
-
set_tab_normal(GTK_NOTEBOOK(c->chatwindow->notebook),
c->chatwindow->notebook_child);
+ set_tab_normal(c);
gtk_widget_grab_focus(c->chatwindow->entry);
eb_update_window_title_to_tab (page_num, FALSE);
}
@@ -1157,7 +1200,7 @@
remote_contact->chatwindow->notebook_child);
int current_num =
gtk_notebook_get_current_page(GTK_NOTEBOOK(remote_contact->chatwindow->notebook));
if (remote_num != current_num)
-
set_tab_red(GTK_NOTEBOOK(remote_contact->chatwindow->notebook),
remote_contact->chatwindow->notebook_child);
+ set_tab_red(remote_contact);
} else {
gdk_window_raise(remote_contact->chatwindow->window->window);
@@ -1276,8 +1319,7 @@
(remote_contact->chatwindow->notebook),
remote_contact->chatwindow->notebook_child);
- set_tab_normal (GTK_NOTEBOOK
(remote_contact->chatwindow->notebook),
- remote_contact->chatwindow->notebook_child);
+ set_tab_normal (remote_contact);
gtk_notebook_set_page (GTK_NOTEBOOK
(remote_contact->chatwindow->notebook),
page_num);
@@ -1317,8 +1359,7 @@
int page_num =
gtk_notebook_page_num(GTK_NOTEBOOK(remote_contact->chatwindow->notebook),
remote_contact->chatwindow->notebook_child);
-
set_tab_normal(GTK_NOTEBOOK(remote_contact->chatwindow->notebook),
- remote_contact->chatwindow->notebook_child);
+ set_tab_normal(remote_contact);
gtk_notebook_set_page(GTK_NOTEBOOK(remote_contact->chatwindow->notebook),
page_num);
} else {
@@ -1839,7 +1880,7 @@
if(can_offline_message(cw->contact)) {
button = gtk_menu_item_new_with_label(_("Offline Messaging"));
gtk_signal_connect(GTK_OBJECT(button), "activate",
- GTK_SIGNAL_FUNC(allow_offline_on_click),
+ GTK_SIGNAL_FUNC(allow_offline_callback),
cw);
gtk_widget_add_accelerator(button, "activate", accel_group,
GDK_o, GDK_CONTROL_MASK,
@@ -1855,7 +1896,7 @@
button = gtk_menu_item_new_with_label(_("Enable Sounds"));
gtk_signal_connect(GTK_OBJECT(button), "activate",
- GTK_SIGNAL_FUNC(set_sound_on_click),
+ GTK_SIGNAL_FUNC(set_sound_callback),
cw);
gtk_widget_add_accelerator(button, "activate", accel_group,
GDK_s, GDK_CONTROL_MASK,
@@ -1947,17 +1988,17 @@
if(can_offline_message(remote)) {
ICON_CREATE(icon, iconwid, tb_edit_xpm);
- cw->allow_button =
gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
+ cw->offline_button =
gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
GTK_TOOLBAR_CHILD_TOGGLEBUTTON,
NULL,
_("Allow"),
_("Allow Offline
Messaging CTRL+O"),
_("Allow"),
iconwid,
-
GTK_SIGNAL_FUNC(allow_offline_on_toggle),
+
GTK_SIGNAL_FUNC(allow_offline_callback),
cw);
gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
-
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(cw->allow_button), FALSE);
+
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(cw->offline_button), FALSE);
}
/* smileys */
@@ -1979,7 +2020,7 @@
_("Enable Sounds CTRL+S"),
_("Sound"),
iconwid,
-
GTK_SIGNAL_FUNC(set_sound_on_toggle),
+
GTK_SIGNAL_FUNC(set_sound_callback),
cw);
/* Toggle the sound button based on preferences */
Index: chat_window.h
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/chat_window.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- chat_window.h 20 Jan 2003 20:33:18 -0000 1.8
+++ chat_window.h 28 Jan 2003 09:27:05 -0000 1.9
@@ -33,16 +33,17 @@
#include "contact.h"
#include "account.h"
#include "log_window.h"
+#include "llist.h"
typedef struct _chat_window
{
- GtkWidget * window;
- GtkWidget * chat;
- GtkWidget * entry;
+ GtkWidget *window;
+ GtkWidget *chat;
+ GtkWidget *entry;
GtkWidget *smiley_button;
GtkWidget *smiley_window;
GtkWidget *sound_button;
- GtkWidget *allow_button;
+ GtkWidget *offline_button;
GtkWidget *status_label;
gboolean sound_enabled;
@@ -58,8 +59,8 @@
gboolean log_started;
time_t next_typing_send;
- GList * history;
- GList * hist_pos;
+ LList * history;
+ LList * hist_pos;
gint this_msg_in_history;
/* Set to FALSE on init, TRUE when away msg first sent,
Index: crash.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/crash.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- crash.c 27 Jan 2003 09:00:35 -0000 1.11
+++ crash.c 28 Jan 2003 09:27:05 -0000 1.12
@@ -91,7 +91,6 @@
sigset_t mask;
if (!is_crash_dialog_allowed()) return;
-
sigemptyset(&mask);
#ifdef SIGSEGV
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Ayttm-commits] CVS: ayttm/src chat_window.c,1.38,1.39 chat_window.h,1.8,1.9 crash.c,1.11,1.12,
Colin Leroy <address@hidden> <=
- Prev by Date:
[Ayttm-commits] CVS: ayttm ChangeLog,1.233,1.234 configure.in,1.229,1.230
- Next by Date:
[Ayttm-commits] CVS: ayttm/src/gtk about.c,NONE,1.1 about.h,NONE,1.1
- Previous by thread:
[Ayttm-commits] CVS: ayttm ChangeLog,1.233,1.234 configure.in,1.229,1.230
- Next by thread:
[Ayttm-commits] CVS: ayttm/src/gtk about.c,NONE,1.1 about.h,NONE,1.1
- Index(es):