changeset 300:b32c83750104

[gaim-migrate @ 310] Pressing enter to send in buddy chats works again, and the CONFIG stuff works a little bit better, I hope. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Thu, 01 Jun 2000 03:06:27 +0000
parents a018ad7fef59
children f905caee43ca
files src/buddy_chat.c src/dialogs.c src/toc.c
diffstat 3 files changed, 51 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/src/buddy_chat.c	Thu Jun 01 01:43:01 2000 +0000
+++ b/src/buddy_chat.c	Thu Jun 01 03:06:27 2000 +0000
@@ -27,6 +27,7 @@
 #include <gtk/gtk.h>
 #include "gaim.h"
 #include "gtkhtml.h"
+#include <gdk/gdkkeysyms.h>
 
 static GtkWidget *joinchat;
 static GtkWidget *entry;
@@ -325,6 +326,25 @@
 }
 
 
+static gboolean chat_keypress_callback(GtkWidget *entry, GdkEventKey *event, struct buddy_chat *b)
+{
+	int pos;
+	if (event->keyval == GDK_Return) {
+		if (!(event->state & GDK_SHIFT_MASK)) {
+			gtk_signal_emit_by_name(GTK_OBJECT(entry), "activate", b);
+			gtk_signal_emit_stop_by_name(GTK_OBJECT(entry), "key_press_event");
+		} else {
+			gtk_signal_emit_stop_by_name(GTK_OBJECT(entry), "keypress_event");
+			pos = gtk_editable_get_position(GTK_EDITABLE(entry));
+			gtk_editable_insert_text(GTK_EDITABLE(entry), "\n", 1, &pos);
+		}
+	}
+
+	return TRUE;
+
+}
+
+
 void update_chat_list(struct buddy_chat *b)
 {
         GtkWidget *list_item;
@@ -506,6 +526,7 @@
 	/* Hack something so we know have an entry click event */
 
 	gtk_signal_connect(GTK_OBJECT(chatentry), "activate", GTK_SIGNAL_FUNC(send_callback),b);
+	gtk_signal_connect(GTK_OBJECT(chatentry), "key_press_event", GTK_SIGNAL_FUNC(chat_keypress_callback), b);
         /* Text box */
 
         sw = gtk_scrolled_window_new (NULL, NULL);
--- a/src/dialogs.c	Thu Jun 01 01:43:01 2000 +0000
+++ b/src/dialogs.c	Thu Jun 01 03:06:27 2000 +0000
@@ -1418,6 +1418,7 @@
         build_permit_tree();
 
         serv_save_config();
+	do_export(0, 0);
 
         destroy_dialog(NULL, p->window);
 }
--- a/src/toc.c	Thu Jun 01 01:43:01 2000 +0000
+++ b/src/toc.c	Thu Jun 01 03:06:27 2000 +0000
@@ -138,24 +138,24 @@
 
 	g_snprintf(buf, sizeof(buf), "Retrieving config...");
 	set_login_progress(5, buf);
-        if ((config=toc_wait_config()) == NULL) {
-		hide_login_progress("No Configuration");
-		set_state(STATE_OFFLINE);
-		return -1;
+	config = toc_wait_config();
 
-	}
-
-        
 #ifdef USE_APPLET
 	make_buddy();
 	if (general_options & OPT_GEN_APP_BUDDY_SHOW) {
                 gnome_buddy_show();
-                parse_toc_buddy_list(config, 0);
+		if (config != NULL)
+			parse_toc_buddy_list(config, 0);
+		else
+			do_import(0, 0);
 		createOnlinePopup();
                 set_applet_draw_open();
         } else {
                 gnome_buddy_hide();
-                parse_toc_buddy_list(config, 0);
+		if (config != NULL)
+			parse_toc_buddy_list(config, 0);
+		else
+			do_import(0, 0);
                 set_applet_draw_closed();
         }
 
@@ -165,7 +165,10 @@
 #else
         gtk_widget_hide(mainwindow);
 	show_buddy_list();
-        parse_toc_buddy_list(config, 0);
+	if (config != NULL)
+		parse_toc_buddy_list(config, 0);
+	else
+		do_import(0, 0);
         refresh_buddy_window();
 #endif
         
@@ -438,6 +441,8 @@
 		
                 serv_got_update(c, logged, evil, signon, time_idle, type);
 
+	} else if (!strcasecmp(c, "CONFIG")) {
+		/* do we want to load the buddy list again here? */
 	} else if (!strcasecmp(c, "ERROR")) {
 		c = strtok(NULL,":");
 		show_error_dialog(c);
@@ -789,25 +794,27 @@
 	/* Waits for configuration packet, returning the contents of the packet */
 	static char buf[BUF_LEN];
 	int res;
-        res = wait_reply(buf, sizeof(buf));
+	res = wait_reply(buf, sizeof(buf));
 	if (res < 0)
 		return NULL;
-/* Apparently, the toc_config is optional.  *VERY* Optional 
-	if (state != STATE_CONFIG) {
-        sprintf(debug_buff , "State should be %d, but is %d instead\n",STATE_CONFIG, state);
-		debug_print(debug_buff);
- 
-		return NULL;
-	}
+/* Apparently, the toc_config is optional.  *VERY* Optional
 */
+	if (state != STATE_CONFIG) {
+		res = 0;
+	} else {
+		res = 1;
+	}
 	/* At this point, it's time to setup automatic handling of incoming packets */
-        state = STATE_ONLINE;
+	state = STATE_ONLINE;
 #ifdef _WIN32
-        win32_r = gtk_timeout_add(1000, (GtkFunction)win32_read, NULL);
+	win32_r = gtk_timeout_add(1000, (GtkFunction)win32_read, NULL);
 #else
-        inpa = gdk_input_add(toc_fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, toc_callback, NULL);
+	inpa = gdk_input_add(toc_fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, toc_callback, NULL);
 #endif
-	return buf;
+	if (res)
+		return buf;
+	else
+		return NULL;
 }
 
 #endif /* USE_OSCAR */