view src/away.c @ 936:311b3f72e7b9

[gaim-migrate @ 946] Sha la la la la la la, mmm, uh huh Was down at the linux expo, starin' at this blue octane, Mr. Flynn strikes up a conversation, with a black haired CS Major. She codes in C while her father hacks, oh, she's suddenly geeky. We all want something geeky, man I wish I was geeky. So come hack in silence down through the morning, sha la la la la la la la, yeah, uhh huh, yeah. Cut up Mark Spencer, show me some of that free software, and pass me a laptop, Mr. Flynn! Believe in me! Help me believe in anything, cuz, I wanna be someone geeky! Mr. Flynn and Me, tell each other linux tales, and we stare at the beautiful penguins, it's lookin' at you, oh no no, it's looking at me. Smiling in the CRT, Mp3's on the stero, when everyone's geeky, you can never be lonely. Well I'm gonna hack a program, syntax highlighting in blue and red and black and grey. All of the beautiful colours are very very meaningingful. Well you know C is my favorite language, I felt so symbolic yesterday. If I knew R. Stallman, I'd buy myself a grey keyboard and hack! Mr. Flynn and me look into the future! We stare at the beautiful Penguins, it's lookin at me, I dont think so, It's looking at me. Hacking in the CRT, I bought myself a grey keyboard, When everbody's geeky, I will never be lonely. I will never be lonely. I'm never gonna be .. loonely. I wanna be a penguin. Eeh -- everybody wanna pass as birds, they all wanna be big big birds, but we got different reasons for that. Believe in me, cuz I don't believe in anything. And I, wanna be someone, geeky, geeky, geeky, yeaaaah! Mr. Flynn and me, storming through the expo, and we stare at the beautiful penguin! It's coming for you, man there's got to be one for me! I wanna be L. Torvalds, Mr. Flynn wishes he was someone just a little more geeky, when everybody loves you, oh son! It's just about as geeky as you can be! Mr. Flynn and me .. starin' at the penguins, when I look at slashdot I wanna see me, staring right back at me. We all wanna be big geeks, but we dont know why and we don't know how .. when everybody loves me I'll be just about as geeky as I can be ... Mr. Flynn and me.. gonna be big geeks. **bows and cheers** Thank You, Thank You. committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Sun, 24 Sep 2000 22:48:54 +0000
parents 2876c40108cd
children 69955d88ab42
line wrap: on
line source

/*
 * gaim
 *
 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
 */

#ifdef HAVE_CONFIG_H
#include "../config.h"
#endif
#ifdef USE_APPLET
#include <gnome.h>
#include <applet-widget.h>
#include "gnome_applet_mgr.h"
#endif /* USE_APPLET */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include <gtk/gtk.h>
#include "gaim.h"
#include "pixmaps/join.xpm"

GtkWidget *imaway=NULL;

GtkWidget *awaymenu = NULL;
struct away_message *awaymessage = NULL;

static void destroy_im_away()
{
	if (imaway)
		gtk_widget_destroy(imaway);
	imaway=NULL;
}

void do_im_back(GtkWidget *w, GtkWidget *x)
{
#ifdef USE_APPLET
	applet_widget_unregister_callback(APPLET_WIDGET(applet),"away");
	set_user_state(online);
	insert_applet_away();
#endif /* USE_APPLET */
	if (imaway) {
		gtk_widget_destroy(imaway);
		imaway=NULL;
        }

        serv_set_away(NULL);
	awaymessage = NULL;
	plugin_event(event_back, 0, 0, 0);
}

void do_away_message(GtkWidget *w, struct away_message *a)
{
	GtkWidget *back;
 	GtkWidget *awaytext;
        GtkWidget *vscrollbar;
	GtkWidget *bbox;
	GtkWidget *vbox;
        GtkWidget *topbox;
        char *buf2;
        char buf[BUF_LONG];
        GList *cnv = conversations;
        struct conversation *c;

	if (!blist)
		return;

#ifdef USE_APPLET
	remove_applet_away();
        applet_widget_register_callback(APPLET_WIDGET(applet),
                                        "away",
                                        _("Back"),
                                        (AppletCallbackFunc) do_im_back,
                                        NULL);				
	set_user_state(away);
#endif

	if (!imaway) {
		imaway = gtk_window_new(GTK_WINDOW_DIALOG);
                gtk_window_set_wmclass(GTK_WINDOW(imaway), "imaway", "Gaim");
		gtk_widget_realize(imaway);
		aol_icon(imaway->window);
		back = picture_button(imaway, _("I'm Back!"), join_xpm);
		bbox = gtk_hbox_new(TRUE, 10);
		topbox = gtk_hbox_new(FALSE, 5);
                vbox = gtk_vbox_new(FALSE, 5);

		awaytext = gtk_text_new(NULL, NULL);
		g_snprintf(buf, sizeof(buf), "%s", a->message);
                vscrollbar = gtk_vscrollbar_new(GTK_TEXT(awaytext)->vadj);
		gtk_widget_show(vscrollbar);
		gtk_widget_set_usize(awaytext, 225, 75);
                gtk_text_set_word_wrap(GTK_TEXT(awaytext), TRUE);
                gtk_widget_show(awaytext);
		gtk_text_freeze(GTK_TEXT(awaytext));
		gtk_text_insert(GTK_TEXT(awaytext), NULL, NULL, NULL, buf, -1);
		gtk_widget_show(awaytext);
                
		if (display_options & OPT_DISP_COOL_LOOK)
			gtk_button_set_relief(GTK_BUTTON(back), GTK_RELIEF_NONE);
		
		/* Put the buttons in the box */
		gtk_box_pack_start(GTK_BOX(bbox), back, TRUE, TRUE, 10);
		
		gtk_box_pack_start(GTK_BOX(topbox), awaytext, FALSE, FALSE, 5);
	
		/* And the boxes in the box */
		gtk_box_pack_start(GTK_BOX(vbox), topbox, TRUE, TRUE, 5);
		gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5);
		
		/* Handle closes right */
		gtk_signal_connect(GTK_OBJECT(imaway), "destroy",
			   GTK_SIGNAL_FUNC(destroy_im_away), imaway);
		gtk_signal_connect(GTK_OBJECT(back), "clicked",
			   GTK_SIGNAL_FUNC(do_im_back), imaway);

		/* Finish up */
		gtk_widget_show(back);
		gtk_widget_show(topbox);
		gtk_widget_show(bbox);
		gtk_widget_show(vbox);
		if (strlen(a->name))
			gtk_window_set_title(GTK_WINDOW(imaway), a->name);
		else
                        gtk_window_set_title(GTK_WINDOW(imaway), _("Gaim - Away!"));
		gtk_window_set_focus(GTK_WINDOW(imaway), back);
		gtk_container_add(GTK_CONTAINER(imaway), vbox);
		awaymessage = a;

        } else {
		destroy_im_away();
		do_away_message(w, a);
		return;
	}

        /* New away message... Clear out the old sent_aways */
        while(cnv) {
                c = (struct conversation *)cnv->data;
                c->sent_away = 0;
                cnv = cnv->next;
        }


        buf2 = g_malloc(strlen(awaymessage->message)*4 + 1);
	strcpy(buf2, awaymessage->message);
        escape_text(buf2);
        serv_set_away(buf2);
        g_free(buf2);
	gtk_widget_show(imaway);
	plugin_event(event_away, 0, 0, 0);
}

void rem_away_mess(GtkWidget *w, struct away_message *a)
{
#ifdef USE_APPLET
	char *awayname;
	awayname = g_malloc(sizeof (*awayname) * (6 + strlen(a->name)));
	awayname[0] = '\0';
	strcat(awayname, "away/");
	strcat(awayname, a->name);
	applet_widget_unregister_callback(APPLET_WIDGET(applet), awayname);
#endif
        away_messages = g_list_remove(away_messages, a);
        g_free(a);
        do_away_menu();
        save_prefs();
}


void do_away_menu()
{
	GtkWidget *menuitem;
	static GtkWidget *remmenu;
	GtkWidget *remitem;
	GtkWidget *label;
	GtkWidget *sep;
	GList *l;
	GtkWidget *list_item;
        GList *awy = away_messages;
        struct away_message *a;

#ifdef USE_APPLET
	remove_applet_away();
	if (imaway)
		applet_widget_register_callback(APPLET_WIDGET(applet),
			"away",
			_("Back"),
			(AppletCallbackFunc)do_im_back,
			NULL);
	else
		insert_applet_away();
#endif

	if (prefs_away_list != NULL) {
                gtk_list_clear_items(GTK_LIST(prefs_away_list), 0, -1);
		while(awy) {
			a = (struct away_message *)awy->data;
			label = gtk_label_new(a->name);
			list_item = gtk_list_item_new();
			gtk_container_add(GTK_CONTAINER(list_item), label);
			gtk_signal_connect(GTK_OBJECT(list_item), "select", GTK_SIGNAL_FUNC(away_list_clicked), a);
/*			gtk_signal_connect(GTK_OBJECT(list_item), "deselect", GTK_SIGNAL_FUNC(away_list_unclicked), a);*/
			gtk_object_set_user_data(GTK_OBJECT(list_item), a);

			gtk_widget_show(label);
			gtk_container_add(GTK_CONTAINER(prefs_away_list), list_item);
			gtk_widget_show(list_item);

			awy = awy->next;
		}
		if (away_messages != NULL)
                        gtk_list_select_item(GTK_LIST(prefs_away_list), 0);
	}
	
	if (!awaymenu) return;
	l = gtk_container_children(GTK_CONTAINER(awaymenu));
	
	while(l) {
		gtk_widget_destroy(GTK_WIDGET(l->data));
		l = l->next;
	}


	remmenu = gtk_menu_new();
	
	

	menuitem = gtk_menu_item_new_with_label(_("New Away Message"));
	gtk_menu_append(GTK_MENU(awaymenu), menuitem);
	gtk_widget_show(menuitem);
	gtk_signal_connect(GTK_OBJECT(menuitem), "activate", GTK_SIGNAL_FUNC(create_away_mess), NULL);


	awy = away_messages;
        while(awy) {
                a = (struct away_message *)awy->data;

		remitem = gtk_menu_item_new_with_label(a->name);
		gtk_menu_append(GTK_MENU(remmenu), remitem);
		gtk_widget_show(remitem);
		gtk_signal_connect(GTK_OBJECT(remitem), "activate", GTK_SIGNAL_FUNC(rem_away_mess), a);

		awy = awy->next;

	}
	
	menuitem = gtk_menu_item_new_with_label(_("Remove Away Message"));
	gtk_menu_append(GTK_MENU(awaymenu), menuitem);
	gtk_widget_show(menuitem);
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), remmenu);
	gtk_widget_show(remmenu);
	

	sep = gtk_hseparator_new();
	menuitem = gtk_menu_item_new();
	gtk_menu_append(GTK_MENU(awaymenu), menuitem);
	gtk_container_add(GTK_CONTAINER(menuitem), sep);
	gtk_widget_set_sensitive(menuitem, FALSE);
	gtk_widget_show(menuitem);
	gtk_widget_show(sep);

	awy = away_messages;
	
	while(awy) {
                a = (struct away_message *)awy->data;
                
		menuitem = gtk_menu_item_new_with_label(a->name);
		gtk_menu_append(GTK_MENU(awaymenu), menuitem);
		gtk_widget_show(menuitem);
		gtk_signal_connect(GTK_OBJECT(menuitem), "activate", GTK_SIGNAL_FUNC(do_away_message), a);

		awy = awy->next;

	}

}