changeset 2379:cacaf7ace3a5

[gaim-migrate @ 2392] reorganization of some functions. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Fri, 28 Sep 2001 01:25:02 +0000
parents dfaf5d9d433e
children 6f83c22d9e70
files src/aim.c src/conversation.c src/convo.h src/dialogs.c src/gaim.h src/gaimrc.c src/util.c
diffstat 7 files changed, 214 insertions(+), 224 deletions(-) [+]
line wrap: on
line diff
--- a/src/aim.c	Thu Sep 27 23:58:48 2001 +0000
+++ b/src/aim.c	Fri Sep 28 01:25:02 2001 +0000
@@ -413,6 +413,23 @@
 }
 #endif
 
+static void set_first_user(char *name)
+{
+	struct aim_user *u;
+
+	u = find_user(name, -1);
+
+	if (!u) {		/* new user */
+		u = g_new0(struct aim_user, 1);
+		g_snprintf(u->username, sizeof(u->username), "%s", name);
+		u->protocol = DEFAULT_PROTO;
+		aim_users = g_list_prepend(aim_users, u);
+	} else {		/* user already exists */
+		aim_users = g_list_remove(aim_users, u);
+		aim_users = g_list_prepend(aim_users, u);
+	}
+	save_prefs();
+}
 
 int main(int argc, char *argv[])
 {
--- a/src/conversation.c	Thu Sep 27 23:58:48 2001 +0000
+++ b/src/conversation.c	Fri Sep 28 01:25:02 2001 +0000
@@ -1823,6 +1823,38 @@
 	update_checkbox(cnv);
 }
 
+int set_dispstyle(int chat)
+{
+	int dispstyle;
+
+	if (chat) {
+		switch (chat_options & (OPT_CHAT_BUTTON_TEXT | OPT_CHAT_BUTTON_XPM)) {
+		case OPT_CHAT_BUTTON_TEXT:
+			dispstyle = 1;
+			break;
+		case OPT_CHAT_BUTTON_XPM:
+			dispstyle = 0;
+			break;
+		default:	/* both or neither */
+			dispstyle = 2;
+			break;
+		}
+	} else {
+		switch (im_options & (OPT_IM_BUTTON_TEXT | OPT_IM_BUTTON_XPM)) {
+		case OPT_IM_BUTTON_TEXT:
+			dispstyle = 1;
+			break;
+		case OPT_IM_BUTTON_XPM:
+			dispstyle = 0;
+			break;
+		default:	/* both or neither */
+			dispstyle = 2;
+			break;
+		}
+	}
+	return dispstyle;
+}
+
 void update_convo_add_button(struct conversation *c)
 {
 	int dispstyle = set_dispstyle(0);
--- a/src/convo.h	Thu Sep 27 23:58:48 2001 +0000
+++ b/src/convo.h	Fri Sep 28 01:25:02 2001 +0000
@@ -48,6 +48,7 @@
 extern void add_callback(GtkWidget *, struct conversation *);
 
 /* now both */
+extern int set_dispstyle (int);
 extern void info_callback(GtkWidget *, struct conversation *);
 extern void do_bold(GtkWidget *, GtkWidget *);
 extern void do_italic(GtkWidget *, GtkWidget *);
--- a/src/dialogs.c	Thu Sep 27 23:58:48 2001 +0000
+++ b/src/dialogs.c	Fri Sep 28 01:25:02 2001 +0000
@@ -68,6 +68,8 @@
 #include "pixmaps/wink.xpm"
 #include "pixmaps/yell.xpm"
 
+#include "pixmaps/aimicon.xpm"
+
 #include "pixmaps/aol_icon.xpm"
 #include "pixmaps/free_icon.xpm"
 #include "pixmaps/dt_icon.xpm"
@@ -4085,3 +4087,128 @@
 }
 
 #endif /* USE_PERL */
+
+static GdkPixmap *icon_pm = NULL;
+static GdkBitmap *icon_bm = NULL;
+
+void aol_icon(GdkWindow *w)
+{
+#ifndef _WIN32
+	if (icon_pm == NULL) {
+		icon_pm = gdk_pixmap_create_from_xpm_d(w, &icon_bm, NULL, (gchar **)aimicon_xpm);
+	}
+	gdk_window_set_icon(w, NULL, icon_pm, icon_bm);
+	if (mainwindow)
+		gdk_window_set_group(w, mainwindow->window);
+#endif
+}
+
+GtkWidget *picture_button(GtkWidget *window, char *text, char **xpm)
+{
+	GtkWidget *button;
+	GtkWidget *button_box, *button_box_2, *button_box_3;
+	GtkWidget *label;
+	GdkBitmap *mask;
+	GdkPixmap *pm;
+	GtkWidget *pixmap;
+
+	button = gtk_button_new();
+	if (misc_options & OPT_MISC_COOL_LOOK)
+		gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
+
+	button_box = gtk_hbox_new(FALSE, 5);
+	gtk_container_add(GTK_CONTAINER(button), button_box);
+
+	button_box_2 = gtk_hbox_new(FALSE, 0);
+	button_box_3 = gtk_hbox_new(FALSE, 0);
+	gtk_box_pack_start(GTK_BOX(button_box), button_box_2, TRUE, TRUE, 0);
+	gtk_box_pack_start(GTK_BOX(button_box), button_box_3, TRUE, TRUE, 0);
+	pm = gdk_pixmap_create_from_xpm_d(window->window, &mask, NULL, xpm);
+	pixmap = gtk_pixmap_new(pm, mask);
+	gtk_box_pack_end(GTK_BOX(button_box_2), pixmap, FALSE, FALSE, 0);
+
+	if (text) {
+		label = gtk_label_new(text);
+		gtk_box_pack_start(GTK_BOX(button_box_3), label, FALSE, FALSE, 2);
+		gtk_widget_show(label);
+	}
+
+	gtk_widget_show(pixmap);
+	gtk_widget_show(button_box_2);
+	gtk_widget_show(button_box_3);
+	gtk_widget_show(button_box);
+
+/* this causes clipping on lots of buttons with long text */
+/*  gtk_widget_set_usize(button, 75, 30);*/
+	gtk_widget_show(button);
+	gdk_pixmap_unref(pm);
+	gdk_bitmap_unref(mask);
+
+	return button;
+}
+
+static GtkTooltips *button_tips = NULL;
+GtkWidget *picture_button2(GtkWidget *window, char *text, char **xpm, short dispstyle)
+{
+	GtkWidget *button;
+	GtkWidget *button_box, *button_box_2;
+	GdkBitmap *mask;
+	GdkPixmap *pm;
+	GtkWidget *pixmap;
+	GtkWidget *label;
+
+	if (!button_tips)
+		button_tips = gtk_tooltips_new();
+	button = gtk_button_new();
+	if (misc_options & OPT_MISC_COOL_LOOK)
+		gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
+
+	button_box = gtk_hbox_new(FALSE, 0);
+	gtk_container_add(GTK_CONTAINER(button), button_box);
+
+	button_box_2 = gtk_vbox_new(FALSE, 0);
+
+	gtk_box_pack_start(GTK_BOX(button_box), button_box_2, TRUE, TRUE, 0);
+	gtk_widget_show(button_box_2);
+	gtk_widget_show(button_box);
+	if (dispstyle == 2 || dispstyle == 0) {
+		pm = gdk_pixmap_create_from_xpm_d(window->window, &mask, NULL, xpm);
+		pixmap = gtk_pixmap_new(pm, mask);
+		gtk_box_pack_start(GTK_BOX(button_box_2), pixmap, FALSE, FALSE, 0);
+
+		gtk_widget_show(pixmap);
+
+		gdk_pixmap_unref(pm);
+		gdk_bitmap_unref(mask);
+	}
+
+	if (dispstyle == 2 || dispstyle == 1) {
+		label = gtk_label_new(text);
+		gtk_widget_show(label);
+		gtk_box_pack_end(GTK_BOX(button_box_2), label, FALSE, FALSE, 0);
+	}
+
+	gtk_tooltips_set_tip(button_tips, button, text, "Gaim");
+	gtk_widget_show(button);
+	return button;
+}
+
+int file_is_dir(const char *path, GtkWidget *w)
+{
+	struct stat st;
+	char *name;
+
+	if (stat(path, &st) == 0 && S_ISDIR(st.st_mode)) {
+		/* append a / if needed */
+		if (path[strlen(path) - 1] != '/') {
+			name = g_strconcat(path, "/", NULL);
+		} else {
+			name = g_strdup(path);
+		}
+		gtk_file_selection_set_filename(GTK_FILE_SELECTION(w), name);
+		g_free(name);
+		return 1;
+	}
+
+	return 0;
+}
--- a/src/gaim.h	Thu Sep 27 23:58:48 2001 +0000
+++ b/src/gaim.h	Fri Sep 28 01:25:02 2001 +0000
@@ -617,7 +617,6 @@
 
 /* Functions in util.c */
 extern char *normalize(const char *);
-extern char *escape_text2(const char *);
 extern char *tobase64(const char *);
 extern void frombase64(const char *, char **, int *);
 extern gint clean_pid(gpointer);
@@ -635,9 +634,7 @@
 extern void translate_lst (FILE *, char *);
 extern void translate_blt (FILE *, char *);
 extern char *stylize(gchar *, int);
-extern int set_dispstyle (int);
 extern void show_usage (int, char *);
-extern void set_first_user (char *);
 extern int do_auto_login (char *);
 extern int file_is_dir (const char *, GtkWidget *);
 extern char *gaim_user_dir();
--- a/src/gaimrc.c	Thu Sep 27 23:58:48 2001 +0000
+++ b/src/gaimrc.c	Fri Sep 28 01:25:02 2001 +0000
@@ -165,7 +165,7 @@
 	return -1;
 }
 
-void filter_break(char *msg)
+static void filter_break(char *msg)
 {
 	char *c;
 	int mc;
@@ -190,6 +190,40 @@
 	g_free(c);
 }
 
+static char *escape_text2(const char *msg)
+{
+	char *c, *cpy;
+	char *woo;
+	int cnt = 0;
+	/* Assumes you have a buffer able to cary at least BUF_LEN * 2 bytes */
+
+	woo = malloc(strlen(msg) * 4 + 1);
+	cpy = g_strndup(msg, 2048);
+	c = cpy;
+	while (*c) {
+		switch (*c) {
+		case '\n':
+			woo[cnt++] = '<';
+			woo[cnt++] = 'B';
+			woo[cnt++] = 'R';
+			woo[cnt++] = '>';
+			break;
+		case '{':
+		case '}':
+		case '\\':
+		case '"':
+			woo[cnt++] = '\\';
+			/* Fall through */
+		default:
+			woo[cnt++] = *c;
+		}
+		c++;
+	}
+	woo[cnt] = '\0';
+
+	g_free(cpy);
+	return woo;
+}
 
 static void gaimrc_read_away(FILE *f)
 {
--- a/src/util.c	Thu Sep 27 23:58:48 2001 +0000
+++ b/src/util.c	Fri Sep 28 01:25:02 2001 +0000
@@ -31,16 +31,11 @@
 #include <sys/stat.h>
 #include <string.h>
 #include <sys/wait.h>
-#include <gtk/gtk.h>
 #include <ctype.h>
 #include <math.h>
-#include <pixmaps/aimicon.xpm>
 #include "gaim.h"
 #include "prpl.h"
 
-static GdkPixmap *icon_pm = NULL;
-static GdkBitmap *icon_bm = NULL;
-
 char *full_date()
 {
 	char *date;
@@ -473,45 +468,6 @@
 		return open_gaim_log_file("system", &x);
 }
 
-char *escape_text2(const char *msg)
-{
-	char *c, *cpy;
-	char *woo;
-	int cnt = 0;
-	/* Assumes you have a buffer able to cary at least BUF_LEN * 2 bytes */
-	if (strlen(msg) > BUF_LEN) {
-		fprintf(stderr, "Warning:  truncating message to 2048 bytes\n");
-	}
-
-	woo = malloc(strlen(msg) * 4 + 1);
-	cpy = g_strndup(msg, 2048);
-	c = cpy;
-	while (*c) {
-		switch (*c) {
-		case '\n':
-			woo[cnt++] = '<';
-			woo[cnt++] = 'B';
-			woo[cnt++] = 'R';
-			woo[cnt++] = '>';
-			break;
-		case '{':
-		case '}':
-		case '\\':
-		case '"':
-			woo[cnt++] = '\\';
-			/* Fall through */
-		default:
-			woo[cnt++] = *c;
-		}
-		c++;
-	}
-	woo[cnt] = '\0';
-
-	g_free(cpy);
-	return woo;
-}
-
-
 char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" "0123456789+/";
 
 
@@ -681,18 +637,6 @@
 	return FALSE;
 }
 
-void aol_icon(GdkWindow *w)
-{
-#ifndef _WIN32
-	if (icon_pm == NULL) {
-		icon_pm = gdk_pixmap_create_from_xpm_d(w, &icon_bm, NULL, (gchar **)aimicon_xpm);
-	}
-	gdk_window_set_icon(w, NULL, icon_pm, icon_bm);
-	if (mainwindow)
-		gdk_window_set_group(w, mainwindow->window);
-#endif
-}
-
 struct aim_user *find_user(const char *name, int protocol)
 {
 	char *who = g_strdup(normalize(name));
@@ -772,95 +716,6 @@
 	return (cpy);
 }
 
-GtkWidget *picture_button(GtkWidget *window, char *text, char **xpm)
-{
-	GtkWidget *button;
-	GtkWidget *button_box, *button_box_2, *button_box_3;
-	GtkWidget *label;
-	GdkBitmap *mask;
-	GdkPixmap *pm;
-	GtkWidget *pixmap;
-
-	button = gtk_button_new();
-	if (misc_options & OPT_MISC_COOL_LOOK)
-		gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
-
-	button_box = gtk_hbox_new(FALSE, 5);
-	gtk_container_add(GTK_CONTAINER(button), button_box);
-
-	button_box_2 = gtk_hbox_new(FALSE, 0);
-	button_box_3 = gtk_hbox_new(FALSE, 0);
-	gtk_box_pack_start(GTK_BOX(button_box), button_box_2, TRUE, TRUE, 0);
-	gtk_box_pack_start(GTK_BOX(button_box), button_box_3, TRUE, TRUE, 0);
-	pm = gdk_pixmap_create_from_xpm_d(window->window, &mask, NULL, xpm);
-	pixmap = gtk_pixmap_new(pm, mask);
-	gtk_box_pack_end(GTK_BOX(button_box_2), pixmap, FALSE, FALSE, 0);
-
-	if (text) {
-		label = gtk_label_new(text);
-		gtk_box_pack_start(GTK_BOX(button_box_3), label, FALSE, FALSE, 2);
-		gtk_widget_show(label);
-	}
-
-	gtk_widget_show(pixmap);
-	gtk_widget_show(button_box_2);
-	gtk_widget_show(button_box_3);
-	gtk_widget_show(button_box);
-
-/* this causes clipping on lots of buttons with long text */
-/*  gtk_widget_set_usize(button, 75, 30);*/
-	gtk_widget_show(button);
-	gdk_pixmap_unref(pm);
-	gdk_bitmap_unref(mask);
-
-	return button;
-}
-
-static GtkTooltips *button_tips = NULL;
-GtkWidget *picture_button2(GtkWidget *window, char *text, char **xpm, short dispstyle)
-{
-	GtkWidget *button;
-	GtkWidget *button_box, *button_box_2;
-	GdkBitmap *mask;
-	GdkPixmap *pm;
-	GtkWidget *pixmap;
-	GtkWidget *label;
-
-	if (!button_tips)
-		button_tips = gtk_tooltips_new();
-	button = gtk_button_new();
-	if (misc_options & OPT_MISC_COOL_LOOK)
-		gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
-
-	button_box = gtk_hbox_new(FALSE, 0);
-	gtk_container_add(GTK_CONTAINER(button), button_box);
-
-	button_box_2 = gtk_vbox_new(FALSE, 0);
-
-	gtk_box_pack_start(GTK_BOX(button_box), button_box_2, TRUE, TRUE, 0);
-	gtk_widget_show(button_box_2);
-	gtk_widget_show(button_box);
-	if (dispstyle == 2 || dispstyle == 0) {
-		pm = gdk_pixmap_create_from_xpm_d(window->window, &mask, NULL, xpm);
-		pixmap = gtk_pixmap_new(pm, mask);
-		gtk_box_pack_start(GTK_BOX(button_box_2), pixmap, FALSE, FALSE, 0);
-
-		gtk_widget_show(pixmap);
-
-		gdk_pixmap_unref(pm);
-		gdk_bitmap_unref(mask);
-	}
-
-	if (dispstyle == 2 || dispstyle == 1) {
-		label = gtk_label_new(text);
-		gtk_widget_show(label);
-		gtk_box_pack_end(GTK_BOX(button_box_2), label, FALSE, FALSE, 0);
-	}
-
-	gtk_tooltips_set_tip(button_tips, button, text, "Gaim");
-	gtk_widget_show(button);
-	return button;
-}
 
 
 /* remove leading whitespace from a string */
@@ -1044,39 +899,6 @@
 	return buf;
 }
 
-int set_dispstyle(int chat)
-{
-	int dispstyle;
-
-	if (chat) {
-		switch (chat_options & (OPT_CHAT_BUTTON_TEXT | OPT_CHAT_BUTTON_XPM)) {
-		case OPT_CHAT_BUTTON_TEXT:
-			dispstyle = 1;
-			break;
-		case OPT_CHAT_BUTTON_XPM:
-			dispstyle = 0;
-			break;
-		default:	/* both or neither */
-			dispstyle = 2;
-			break;
-		}
-	} else {
-		switch (im_options & (OPT_IM_BUTTON_TEXT | OPT_IM_BUTTON_XPM)) {
-		case OPT_IM_BUTTON_TEXT:
-			dispstyle = 1;
-			break;
-		case OPT_IM_BUTTON_XPM:
-			dispstyle = 0;
-			break;
-		default:	/* both or neither */
-			dispstyle = 2;
-			break;
-		}
-	}
-	return dispstyle;
-}
-
-
 void show_usage(int mode, char *name)
 {
 	switch (mode) {
@@ -1099,25 +921,6 @@
 }
 
 
-void set_first_user(char *name)
-{
-	struct aim_user *u;
-
-	u = find_user(name, -1);
-
-	if (!u) {		/* new user */
-		u = g_new0(struct aim_user, 1);
-		g_snprintf(u->username, sizeof(u->username), "%s", name);
-		u->protocol = DEFAULT_PROTO;
-		aim_users = g_list_prepend(aim_users, u);
-	} else {		/* user already exists */
-		aim_users = g_list_remove(aim_users, u);
-		aim_users = g_list_prepend(aim_users, u);
-	}
-	save_prefs();
-}
-
-
 /* <name> is a comma-separated list of names, or NULL
    if NULL and there is at least one user defined in .gaimrc, try to login.
    if not NULL, parse <name> into separate strings, look up each one in 
@@ -1154,27 +957,6 @@
 	return retval;
 }
 
-
-int file_is_dir(const char *path, GtkWidget *w)
-{
-	struct stat st;
-	char *name;
-
-	if (stat(path, &st) == 0 && S_ISDIR(st.st_mode)) {
-		/* append a / if needed */
-		if (path[strlen(path) - 1] != '/') {
-			name = g_strconcat(path, "/", NULL);
-		} else {
-			name = g_strdup(path);
-		}
-		gtk_file_selection_set_filename(GTK_FILE_SELECTION(w), name);
-		g_free(name);
-		return 1;
-	}
-
-	return 0;
-}
-
 GSList *message_split(char *message, int limit)
 {
 	static GSList *ret = NULL;
@@ -1280,7 +1062,7 @@
 
 	if (mesg == NULL) {
 		/* Use default message */
-		do_away_message((GtkWidget *)NULL, default_away);
+		do_away_message(NULL, default_away);
 	} else {
 		/* Use argument */
 		while (awy) {
@@ -1293,7 +1075,7 @@
 		}
 		if (message == NULL)
 			message = default_away;
-		do_away_message((GtkWidget *)NULL, message);
+		do_away_message(NULL, message);
 	}
 	return;
 }