Mercurial > pidgin
changeset 3391:412d1035d666
[gaim-migrate @ 3410]
Pluginzed the ticker. the ticker will load itself if the old ticker option
was set.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Sun, 11 Aug 2002 06:42:17 +0000 |
parents | a5d356cba156 |
children | 5a5df7968b6e |
files | ChangeLog configure.ac configure.in plugins/Makefile.am plugins/ticker/.cvsignore plugins/ticker/Makefile.am plugins/ticker/gtkticker.c plugins/ticker/gtkticker.h plugins/ticker/ticker.c src/Makefile.am src/aim.c src/buddy.c src/gaim.h src/gaimrc.c src/multi.c src/prefs.c src/ui.h |
diffstat | 17 files changed, 1177 insertions(+), 60 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sat Aug 10 02:42:55 2002 +0000 +++ b/ChangeLog Sun Aug 11 06:42:17 2002 +0000 @@ -33,6 +33,7 @@ * TOC no longer compiles statically by default--use OSCAR * ICQ plugin no longer gets built--use OSCAR * Added support for gettext 0.11.x. + * Buddy Ticker made a plugin. version 0.59 (06/24/2002): * Hungarian translation added (Thanks, Sutto Zoltan)
--- a/configure.ac Sat Aug 10 02:42:55 2002 +0000 +++ b/configure.ac Sun Aug 11 06:42:17 2002 +0000 @@ -432,6 +432,7 @@ pixmaps/protocols/msn/Makefile pixmaps/protocols/yahoo/Makefile plugins/Makefile + plugins/ticker/Makefile po/Makefile.in sounds/Makefile src/Makefile
--- a/configure.in Sat Aug 10 02:42:55 2002 +0000 +++ b/configure.in Sun Aug 11 06:42:17 2002 +0000 @@ -429,6 +429,7 @@ pixmaps/protocols/msn/Makefile pixmaps/protocols/yahoo/Makefile plugins/Makefile + plugins/Makefile po/Makefile.in sounds/Makefile src/Makefile
--- a/plugins/Makefile.am Sat Aug 10 02:42:55 2002 +0000 +++ b/plugins/Makefile.am Sun Aug 11 06:42:17 2002 +0000 @@ -1,3 +1,5 @@ +SUBDIRS = ticker + CFLAGS += -I\$(top_srcdir) -I\$(top_srcdir)/src -DVERSION=\"$(VERSION)\" SUFFIXES = .c .so .c.so:
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/ticker/.cvsignore Sun Aug 11 06:42:17 2002 +0000 @@ -0,0 +1,3 @@ +Makefile +Makefile.in +.libs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/ticker/Makefile.am Sun Aug 11 06:42:17 2002 +0000 @@ -0,0 +1,25 @@ +CFLAGS += -I\$(top_srcdir) -I\$(top_srcdir)/src -DVERSION=\"$(VERSION)\" +plugindir = $(libdir)/gaim + +if PLUGINS + +tickersources = ticker.c gtkticker.so + +all: + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c gtkticker.c -o tmpgtkticker.lo $(PLUGIN_CFLAGS) + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c ticker.c -o tmpticker.lo $(PLUGIN_CFLAGS) + $(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o libtmpticker.la -rpath $(plugindir) tmpgtkticker.lo tmpticker.lo $(LIBS) $(LDFLAGS) -module -avoid-version $(PLUGIN_LIBS) + @rm -f tmpticker.lo tmpgtkticker.lo tmpticker.o tmpgtkticker.o libtmpgtkticker.la libticker.la + @cp .libs/libtmpticker.so* ticker.so + @rm -f .libs/libtmpticker.* + +clean distclean: + rm -rf $(plugin_DATA) .libs + +install: + cp ticker.so $(plugindir) + + +endif + +EXTRA_DIST = ticker.c gtkticker.c gtkticker.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/ticker/gtkticker.c Sun Aug 11 06:42:17 2002 +0000 @@ -0,0 +1,614 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* + * GtkTicker Copyright 2000 Syd Logan + */ + +#include "gtkticker.h" +#include <gtk/gtk.h> + +static void gtk_ticker_compute_offsets (GtkTicker *ticker); +static void gtk_ticker_class_init (GtkTickerClass *klass); +static void gtk_ticker_init (GtkTicker *ticker); +static void gtk_ticker_map (GtkWidget *widget); +static void gtk_ticker_realize (GtkWidget *widget); +static void gtk_ticker_size_request (GtkWidget *widget, + GtkRequisition *requisition); +static void gtk_ticker_size_allocate (GtkWidget *widget, + GtkAllocation *allocation); +static void gtk_ticker_paint (GtkWidget *widget, + GdkRectangle *area); +static void gtk_ticker_draw (GtkWidget *widget, + GdkRectangle *area); +static gint gtk_ticker_expose (GtkWidget *widget, + GdkEventExpose *event); +static void gtk_ticker_add_real (GtkContainer *container, + GtkWidget *widget); +static void gtk_ticker_remove_real (GtkContainer *container, + GtkWidget *widget); +static void gtk_ticker_forall (GtkContainer *container, + gboolean include_internals, + GtkCallback callback, + gpointer callback_data); +static GtkType gtk_ticker_child_type (GtkContainer *container); + + +static GtkContainerClass *parent_class = NULL; + + +GtkType +gtk_ticker_get_type (void) +{ + static GtkType ticker_type = 0; + + if (!ticker_type) + { + static const GtkTypeInfo ticker_info = + { + "GtkTicker", + sizeof (GtkTicker), + sizeof (GtkTickerClass), + (GtkClassInitFunc) gtk_ticker_class_init, + (GtkObjectInitFunc) gtk_ticker_init, + /* reserved_1 */ NULL, + /* reserved_2 */ NULL, + (GtkClassInitFunc) NULL, + }; + + ticker_type = gtk_type_unique (GTK_TYPE_CONTAINER, &ticker_info); + } + + return ticker_type; +} + +static void +gtk_ticker_class_init (GtkTickerClass *class) +{ + GtkObjectClass *object_class; + GtkWidgetClass *widget_class; + GtkContainerClass *container_class; + + object_class = (GtkObjectClass*) class; + widget_class = (GtkWidgetClass*) class; + container_class = (GtkContainerClass*) class; + + parent_class = gtk_type_class (GTK_TYPE_CONTAINER); + + widget_class->map = gtk_ticker_map; + widget_class->realize = gtk_ticker_realize; + widget_class->size_request = gtk_ticker_size_request; + widget_class->size_allocate = gtk_ticker_size_allocate; +#if ! GTK_CHECK_VERSION(1,3,0) + widget_class->draw = gtk_ticker_draw; +#endif + widget_class->expose_event = gtk_ticker_expose; + + container_class->add = gtk_ticker_add_real; + container_class->remove = gtk_ticker_remove_real; + container_class->forall = gtk_ticker_forall; + container_class->child_type = gtk_ticker_child_type; +} + +static GtkType +gtk_ticker_child_type (GtkContainer *container) +{ + return GTK_TYPE_WIDGET; +} + +static void +gtk_ticker_init (GtkTicker *ticker) +{ + GTK_WIDGET_UNSET_FLAGS (ticker, GTK_NO_WINDOW); + + ticker->interval = (guint) 200; + ticker->scootch = (guint) 2; + ticker->children = NULL; + ticker->timer = 0; + ticker->dirty = TRUE; +} + +GtkWidget* +gtk_ticker_new (void) +{ + GtkTicker *ticker; + + ticker = gtk_type_new (GTK_TYPE_TICKER); + return GTK_WIDGET (ticker); +} + +static void +gtk_ticker_put (GtkTicker *ticker, + GtkWidget *widget) +{ + GtkTickerChild *child_info; + + g_return_if_fail (ticker != NULL); + g_return_if_fail (GTK_IS_TICKER (ticker)); + g_return_if_fail (widget != NULL); + + child_info = g_new(GtkTickerChild, 1); + child_info->widget = widget; + child_info->x = 0; + + gtk_widget_set_parent(widget, GTK_WIDGET (ticker)); + + ticker->children = g_list_append (ticker->children, child_info); + + if (GTK_WIDGET_REALIZED (ticker)) + gtk_widget_realize (widget); + + if (GTK_WIDGET_VISIBLE (ticker) && GTK_WIDGET_VISIBLE (widget)) + { + if (GTK_WIDGET_MAPPED (ticker)) + gtk_widget_map (widget); + + gtk_widget_queue_resize (GTK_WIDGET (ticker)); + } +} + +void +gtk_ticker_set_interval (GtkTicker *ticker, gint interval ) +{ + g_return_if_fail (ticker != NULL); + g_return_if_fail (GTK_IS_TICKER (ticker)); + + if ( interval < 0 ) + interval = 200; + ticker->interval = interval; + +} + +guint +gtk_ticker_get_interval (GtkTicker *ticker ) +{ + g_return_val_if_fail (ticker != NULL, -1); + g_return_val_if_fail (GTK_IS_TICKER (ticker), -1); + + return ticker->interval; +} + +void +gtk_ticker_set_scootch (GtkTicker *ticker, gint scootch ) +{ + g_return_if_fail (ticker != NULL); + g_return_if_fail (GTK_IS_TICKER (ticker)); + + if ( scootch <= 0 ) + scootch = 2; + ticker->scootch = scootch; + ticker->dirty = TRUE; +} + +guint +gtk_ticker_get_scootch (GtkTicker *ticker ) +{ + g_return_val_if_fail (ticker != NULL, -1); + g_return_val_if_fail (GTK_IS_TICKER (ticker), -1); + + return ticker->scootch; +} + +void +gtk_ticker_set_spacing (GtkTicker *ticker, gint spacing ) +{ + g_return_if_fail (ticker != NULL); + g_return_if_fail (GTK_IS_TICKER (ticker)); + + if ( spacing < 0 ) + spacing = 0; + ticker->spacing = spacing; + ticker->dirty = TRUE; + +} + +static int +ticker_timeout( gpointer data ) +{ + GtkTicker *ticker = (GtkTicker *) data; + + if (GTK_WIDGET_VISIBLE (ticker)) + gtk_widget_queue_resize (GTK_WIDGET (ticker)); + + return( TRUE ); +} + +void +gtk_ticker_start_scroll(GtkTicker *ticker) +{ + g_return_if_fail (ticker != NULL); + g_return_if_fail (GTK_IS_TICKER (ticker)); + if ( ticker->timer != 0 ) + return; + ticker->timer = gtk_timeout_add(ticker->interval, + ticker_timeout, ticker); +} + +void +gtk_ticker_stop_scroll(GtkTicker *ticker) +{ + g_return_if_fail (ticker != NULL); + g_return_if_fail (GTK_IS_TICKER (ticker)); + if ( ticker->timer == 0 ) + return; + gtk_timeout_remove( ticker->timer ); + ticker->timer = 0; + +} + +guint +gtk_ticker_get_spacing (GtkTicker *ticker ) +{ + g_return_val_if_fail (ticker != NULL, -1); + g_return_val_if_fail (GTK_IS_TICKER (ticker), -1); + + return ticker->spacing; +} + +static void +gtk_ticker_map (GtkWidget *widget) +{ + GtkTicker *ticker; + GtkTickerChild *child; + GList *children; + + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_TICKER (widget)); + + GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED); + ticker = GTK_TICKER (widget); + + children = ticker->children; + while (children) + { + child = children->data; + children = children->next; + + if (GTK_WIDGET_VISIBLE (child->widget) && + !GTK_WIDGET_MAPPED (child->widget)) + gtk_widget_map (child->widget); + } + + gdk_window_show (widget->window); +} + +static void +gtk_ticker_realize (GtkWidget *widget) +{ + GdkWindowAttr attributes; + gint attributes_mask; + + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_TICKER (widget)); + + GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); + + attributes.window_type = GDK_WINDOW_CHILD; + attributes.x = widget->allocation.x; + attributes.y = widget->allocation.y; + attributes.width = widget->allocation.width; + attributes.height = widget->allocation.height; + attributes.wclass = GDK_INPUT_OUTPUT; + attributes.visual = gtk_widget_get_visual (widget); + attributes.colormap = gtk_widget_get_colormap (widget); + attributes.event_mask = gtk_widget_get_events (widget); + attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK; + + attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; + + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), + &attributes, attributes_mask); + gdk_window_set_user_data (widget->window, widget); + + widget->style = gtk_style_attach (widget->style, widget->window); + gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); +} + +static void +gtk_ticker_size_request (GtkWidget *widget, + GtkRequisition *requisition) +{ + GtkTicker *ticker; + GtkTickerChild *child; + GList *children; + GtkRequisition child_requisition; + + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_TICKER (widget)); + g_return_if_fail (requisition != NULL); + + ticker = GTK_TICKER (widget); + requisition->width = 0; + requisition->height = 0; + + children = ticker->children; + while (children) + { + child = children->data; + children = children->next; + + if (GTK_WIDGET_VISIBLE (child->widget)) + { + gtk_widget_size_request (child->widget, &child_requisition); + + requisition->height = MAX (requisition->height, + child_requisition.height); + requisition->width += child_requisition.width + ticker->spacing; + } + } + if ( requisition->width > ticker->spacing ) + requisition->width -= ticker->spacing; + + requisition->height += GTK_CONTAINER (ticker)->border_width * 2; + requisition->width += GTK_CONTAINER (ticker)->border_width * 2; +} + +static void +gtk_ticker_compute_offsets (GtkTicker *ticker) +{ + GtkTickerChild *child; + GtkRequisition child_requisition; + GList *children; + guint16 border_width; + + g_return_if_fail (ticker != NULL); + g_return_if_fail (GTK_IS_TICKER(ticker)); + + border_width = GTK_CONTAINER (ticker)->border_width; + + ticker->width = GTK_WIDGET(ticker)->allocation.width; + ticker->total = 0; + children = ticker->children; + while (children) { + child = children->data; + + child->x = 0; + if (GTK_WIDGET_VISIBLE (child->widget)) { + gtk_widget_get_child_requisition (child->widget, &child_requisition); + child->offset = ticker->total; + ticker->total += + child_requisition.width + border_width + ticker->spacing; + } + children = children->next; + } + ticker->dirty = FALSE; +} + +static void +gtk_ticker_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) +{ + GtkTicker *ticker; + GtkTickerChild *child; + GtkAllocation child_allocation; + GtkRequisition child_requisition; + GList *children; + guint16 border_width; + + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_TICKER(widget)); + g_return_if_fail (allocation != NULL); + + ticker = GTK_TICKER (widget); + + if ( GTK_WIDGET(ticker)->allocation.width != ticker->width ) + ticker->dirty = TRUE; + + if ( ticker->dirty == TRUE ) { + gtk_ticker_compute_offsets( ticker ); + } + + widget->allocation = *allocation; + if (GTK_WIDGET_REALIZED (widget)) + gdk_window_move_resize (widget->window, + allocation->x, + allocation->y, + allocation->width, + allocation->height); + + border_width = GTK_CONTAINER (ticker)->border_width; + + children = ticker->children; + while (children) + { + child = children->data; + child->x -= ticker->scootch; + + if (GTK_WIDGET_VISIBLE (child->widget)) { + gtk_widget_get_child_requisition (child->widget, &child_requisition); + child_allocation.width = child_requisition.width; + child_allocation.x = child->offset + border_width + child->x; + if ( ( child_allocation.x + child_allocation.width ) < GTK_WIDGET(ticker)->allocation.x ) { + if ( ticker->total >= GTK_WIDGET(ticker)->allocation.width ) { + child->x += GTK_WIDGET(ticker)->allocation.x + GTK_WIDGET(ticker)->allocation.width + ( ticker->total - ( GTK_WIDGET(ticker)->allocation.x + GTK_WIDGET(ticker)->allocation.width ) ); + } + else { + child->x += GTK_WIDGET(ticker)->allocation.x + GTK_WIDGET(ticker)->allocation.width; + } + } + child_allocation.y = border_width; + child_allocation.height = child_requisition.height; + gtk_widget_size_allocate (child->widget, &child_allocation); + } + children = children->next; + } +} + +static void +gtk_ticker_paint (GtkWidget *widget, + GdkRectangle *area) +{ + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_TICKER (widget)); + g_return_if_fail (area != NULL); + + if (GTK_WIDGET_DRAWABLE (widget)) + gdk_window_clear_area (widget->window, 0, 0, widget->allocation.width, + widget->allocation.height); +} + +static void +gtk_ticker_draw (GtkWidget *widget, + GdkRectangle *area) +{ + GtkTicker *ticker; + GtkTickerChild *child; + GList *children; + + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_TICKER (widget)); + + if (GTK_WIDGET_DRAWABLE (widget)) + { + ticker = GTK_TICKER (widget); + gtk_ticker_paint (widget, area); + + children = ticker->children; + while (children) + { + child = children->data; + children = children->next; + gtk_widget_draw (child->widget, NULL); + } + } +} + +static gint +gtk_ticker_expose (GtkWidget *widget, GdkEventExpose *event) +{ + GtkTicker *ticker; + GtkTickerChild *child; + GdkEventExpose child_event; + GList *children; + + g_return_val_if_fail (widget != NULL, FALSE); + g_return_val_if_fail (GTK_IS_TICKER (widget), FALSE); + g_return_val_if_fail (event != NULL, FALSE); + + if (GTK_WIDGET_DRAWABLE (widget)) + { + ticker = GTK_TICKER (widget); + + child_event = *event; + + children = ticker->children; + while (children) + { + child = children->data; + children = children->next; + + if (GTK_WIDGET_NO_WINDOW (child->widget) && + gtk_widget_intersect (child->widget, &event->area, + &child_event.area)) + gtk_widget_event (child->widget, (GdkEvent*) &child_event); + } + } + + return FALSE; +} + +void +gtk_ticker_add(GtkTicker *ticker, GtkWidget *widget) +{ + gtk_ticker_add_real( GTK_CONTAINER( ticker ), widget ); + ticker->dirty = TRUE; +} + +void +gtk_ticker_remove(GtkTicker *ticker, GtkWidget *widget) +{ + gtk_ticker_remove_real( GTK_CONTAINER( ticker ), widget ); + ticker->dirty = TRUE; +} + +static void +gtk_ticker_add_real(GtkContainer *container, + GtkWidget *widget) +{ + g_return_if_fail (container != NULL); + g_return_if_fail (GTK_IS_TICKER (container)); + g_return_if_fail (widget != NULL); + + gtk_ticker_put(GTK_TICKER (container), widget); +} + +static void +gtk_ticker_remove_real(GtkContainer *container, + GtkWidget *widget) +{ + GtkTicker *ticker; + GtkTickerChild *child; + GList *children; + + g_return_if_fail (container != NULL); + g_return_if_fail (GTK_IS_TICKER (container)); + g_return_if_fail (widget != NULL); + + ticker = GTK_TICKER (container); + + children = ticker->children; + while (children) + { + child = children->data; + + if (child->widget == widget) + { + gboolean was_visible = GTK_WIDGET_VISIBLE (widget); + + gtk_widget_unparent (widget); + + ticker->children = g_list_remove_link (ticker->children, children); + g_list_free (children); + g_free (child); + + if (was_visible && GTK_WIDGET_VISIBLE (container)) + gtk_widget_queue_resize (GTK_WIDGET (container)); + + break; + } + + children = children->next; + } +} + +static void +gtk_ticker_forall (GtkContainer *container, + gboolean include_internals, + GtkCallback callback, + gpointer callback_data) +{ + GtkTicker *ticker; + GtkTickerChild *child; + GList *children; + + g_return_if_fail (container != NULL); + g_return_if_fail (GTK_IS_TICKER (container)); + g_return_if_fail (callback != NULL); + + ticker = GTK_TICKER (container); + + children = ticker->children; + while (children) + { + child = children->data; + children = children->next; + + (* callback) (child->widget, callback_data); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/ticker/gtkticker.h Sun Aug 11 06:42:17 2002 +0000 @@ -0,0 +1,99 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* + * Copyright 2000 Syd Logan + */ + +#ifndef __GTK_TICKER_H__ +#define __GTK_TICKER_H__ + + +#include <gdk/gdk.h> +#include <gtk/gtkcontainer.h> +#include <gtk/gtkmain.h> + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define GTK_TYPE_TICKER (gtk_ticker_get_type ()) +#define GTK_TICKER(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_TICKER, GtkTicker)) +#define GTK_TICKER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_TICKER, GtkTickerClass)) +#define GTK_IS_TICKER(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_TICKER)) +#define GTK_IS_TICKER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TICKER)) + + +typedef struct _GtkTicker GtkTicker; +typedef struct _GtkTickerClass GtkTickerClass; +typedef struct _GtkTickerChild GtkTickerChild; + +/* XXX children move from right to left, should be able to go other way */ + +struct _GtkTicker +{ + GtkContainer container; + guint interval; /* how often to scootch */ + guint spacing; /* inter-child horizontal spacing */ + guint scootch; /* how many pixels to move each scootch */ + gint timer; /* timer object */ + guint total; /* total width of widgets */ + guint width; /* width of containing window */ + gboolean dirty; + GList *children; +}; + +struct _GtkTickerClass +{ + GtkContainerClass parent_class; +}; + +struct _GtkTickerChild +{ + GtkWidget *widget; + gint x; /* current position */ + gint offset; /* offset in list */ +}; + + +GtkType gtk_ticker_get_type (void); +GtkWidget* gtk_ticker_new (void); +void gtk_ticker_add (GtkTicker *ticker, + GtkWidget *widget); +void gtk_ticker_remove (GtkTicker *ticker, + GtkWidget *widget); +void gtk_ticker_set_interval (GtkTicker *ticker, + gint interval); +guint gtk_ticker_get_interval (GtkTicker *ticker); +void gtk_ticker_set_spacing (GtkTicker *ticker, + gint spacing); +guint gtk_ticker_get_spacing (GtkTicker *ticker); +void gtk_ticker_set_scootch (GtkTicker *ticker, + gint scootch); +guint gtk_ticker_get_scootch (GtkTicker *ticker); +void gtk_ticker_start_scroll (GtkTicker *ticker); +void gtk_ticker_stop_scroll (GtkTicker *ticker); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __GTK_TICKER_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/ticker/ticker.c Sun Aug 11 06:42:17 2002 +0000 @@ -0,0 +1,420 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* + * ticker.c -- Syd Logan, Summer 2000 + * pluginized- Sean Egan, Summer 2002 + */ + +#define GAIM_PLUGINS + +#include <gtk/gtk.h> +#include "gtkticker.h" +#include <string.h> +#include <stdlib.h> +#include "gaim.h" +#include "prpl.h" +#include "pixmaps/no_icon.xpm" + +static GtkWidget *tickerwindow = NULL; +static GtkWidget *ticker; +static GModule *handle; + +typedef struct { + char buddy[ 128 ]; + char alias[ 388 ]; + GtkWidget *hbox; + GtkWidget *ebox; + GtkWidget *label; + GtkWidget *pix; +} TickerData; + +GList *tickerbuds = (GList *) NULL; +gboolean userclose = FALSE; +GtkWidget *msgw; + +void BuddyTickerDestroyWindow( GtkWidget *window ); +void BuddyTickerCreateWindow( void ); +void BuddyTickerAddUser( char *name, char *alias, GdkPixmap *pm, GdkBitmap *bm ); +void BuddyTickerRemoveUser( char *name ); +void BuddyTickerSetPixmap( char *name, GdkPixmap *pm, GdkBitmap *bm ); +void BuddyTickerClearList( void ); +void BuddyTickerSignOff( void ); +GList * BuddyTickerFindUser( char *name ); +int BuddyTickerMessageRemove( gpointer data ); +void BuddyTickerShow(); + +void +BuddyTickerDestroyWindow( GtkWidget *window ) +{ + BuddyTickerClearList(); + gtk_ticker_stop_scroll( GTK_TICKER( ticker ) ); + gtk_widget_destroy( window ); + ticker = tickerwindow = (GtkWidget *) NULL; + userclose = TRUE; +} + +static char *msg = "Welcome to Gaim " VERSION ", brought to you by Rob Flynn (maintainer), Eric Warmenhoven, Mark Spencer, Jeramey Crawford, Jim Duchek, Syd Logan, and Sean Egan"; + +void +BuddyTickerCreateWindow() +{ + + if ( tickerwindow != (GtkWidget *) NULL ) + return; + debug_printf("Making ticker\n"); + tickerwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_signal_connect (GTK_OBJECT(tickerwindow), "destroy", + GTK_SIGNAL_FUNC (BuddyTickerDestroyWindow), "WM destroy"); + gtk_window_set_title (GTK_WINDOW(tickerwindow), "Gaim - Buddy Ticker"); + gtk_window_set_wmclass (GTK_WINDOW(tickerwindow), + "ticker", "Gaim"); + gtk_widget_realize(tickerwindow); + aol_icon(tickerwindow->window); + + ticker = gtk_ticker_new(); + if (!ticker) + return; + gtk_ticker_set_spacing( GTK_TICKER( ticker ), 20 ); + gtk_widget_set_usize( ticker, 500, -1 ); + gtk_container_add( GTK_CONTAINER( tickerwindow ), ticker ); + gtk_ticker_set_interval( GTK_TICKER( ticker ), 500 ); + gtk_ticker_set_scootch( GTK_TICKER( ticker ), 10 ); + /* Damned egotists + msgw = gtk_label_new( msg ); + gtk_ticker_add( GTK_TICKER( ticker ), msgw ); + */ + gtk_ticker_start_scroll( GTK_TICKER( ticker ) ); + + gtk_timeout_add( 60000, BuddyTickerMessageRemove, (gpointer) NULL ); + + gtk_widget_show_all (ticker); + +} + +gint +ButtonPressCallback( GtkWidget *widget, GdkEvent *event, gpointer callback_data ) +{ + TickerData *p = (TickerData *) callback_data; + struct conversation *conv = new_conversation(p->buddy); + + return TRUE; +} + +void +BuddyTickerAddUser( char *name, char *alias, GdkPixmap *pm, GdkBitmap *bm ) +{ + TickerData *p; + GList *q; + + if ( userclose == TRUE ) + return; + + debug_printf("Adding %s\n", name); + + BuddyTickerCreateWindow(); + if (!ticker) + return; + + q = (GList *) BuddyTickerFindUser( name ); + if ( q != (GList *) NULL ) + return; + + p = (TickerData *) malloc( sizeof( TickerData ) ); + p->hbox = (GtkWidget *) NULL; + p->label = (GtkWidget *) NULL; + p->pix = (GtkWidget *) NULL; + strcpy( p->buddy, name ); + strcpy( p->alias, alias); + tickerbuds = g_list_append( tickerbuds, p ); + + p->hbox = gtk_hbox_new( FALSE, 0 ); + gtk_ticker_add( GTK_TICKER( ticker ), p->hbox ); + gtk_widget_show_all( p->hbox ); + + BuddyTickerSetPixmap( name, pm, bm ); + + p->ebox = gtk_event_box_new(); + + /* click detection */ + + gtk_widget_set_events (p->ebox, GDK_BUTTON_PRESS_MASK); + gtk_signal_connect (GTK_OBJECT (p->ebox), "button_press_event", + GTK_SIGNAL_FUNC(ButtonPressCallback), (gpointer) p); + + gtk_box_pack_start_defaults( GTK_BOX( p->hbox ), p->ebox ); + gtk_widget_show( p->ebox ); + + if (im_options & OPT_IM_ALIAS_TAB) + p->label = gtk_label_new( alias ); + else + p->label = gtk_label_new( name ); + gtk_container_add( GTK_CONTAINER(p->ebox), p->label ); + + gtk_widget_show( p->label ); + + gtk_widget_show( tickerwindow ); +} + +void +BuddyTickerRemoveUser( char *name ) +{ + GList *p = (GList *) BuddyTickerFindUser( name ); + TickerData *data; + + if ( !p ) + return; + + data = (TickerData *) p->data; + + if ( userclose == TRUE ) + return; + if ( data ) { + gtk_ticker_remove( GTK_TICKER( ticker ), data->hbox ); + tickerbuds = g_list_remove( tickerbuds, data ); + free( data ); + } +} + +void +BuddyTickerSetPixmap( char *name, GdkPixmap *pm, GdkBitmap *bm ) +{ + GList *p; + TickerData *data; + + if ( userclose == TRUE ) + return; + p = (GList *) BuddyTickerFindUser( name ); + if ( p ) + data = (TickerData *) p->data; + else + return; + if ( data->pix == (GtkWidget *) NULL ) { + data->pix = gtk_pixmap_new( pm, bm ); + gtk_box_pack_start_defaults( GTK_BOX( data->hbox ), data->pix ); + } else { + gtk_widget_hide( data->pix ); + gtk_pixmap_set(GTK_PIXMAP(data->pix), pm, bm); + } + gtk_widget_show( data->pix ); +} + +void +BuddyTickerSetAlias( char *name, char *alias) { + GList *p; + TickerData *data; + + if ( userclose == TRUE ) + return; + p = (GList *) BuddyTickerFindUser( name ); + if ( p ) + data = (TickerData *) p->data; + else + return; + if (alias) { + g_snprintf(data->alias, sizeof(data->alias), alias); + + if (im_options & OPT_IM_ALIAS_TAB) + gtk_label_set_text(GTK_LABEL(data->label), alias); + } +} + +GList * +BuddyTickerFindUser( char *name ) +{ + GList *p = tickerbuds; + + while ( p ) { + TickerData *q = (TickerData *) p->data; + if ( !strcmp( name, q->buddy ) ) + return( p ); + p = p->next; + } + return (GList *) NULL; +} + +void +BuddyTickerSetNames() +{ + GList *p = tickerbuds; + while ( p ) { + TickerData *q = (TickerData *) p->data; + if (im_options & OPT_IM_ALIAS_TAB) + gtk_label_set_text(GTK_LABEL(q->label), q->alias); + else + gtk_label_set_text(GTK_LABEL(q->label), q->buddy); + p = p->next; + } +} + +int +BuddyTickerMessageRemove( gpointer data ) +{ + if ( userclose == TRUE ) + return FALSE; + if ( tickerwindow == NULL ) + return FALSE; + gtk_ticker_remove( GTK_TICKER( ticker ), msgw ); + return FALSE; +} + +int +BuddyTickerLogonTimeout( gpointer data ) +{ + return FALSE; +} + +int +BuddyTickerLogoutTimeout( gpointer data ) +{ + char *name = (char *) data; + + if ( userclose == TRUE ) + return FALSE; + BuddyTickerRemoveUser( name ); + + return FALSE; +} + +void +BuddyTickerSignoff( void ) +{ + GList *p = tickerbuds; + TickerData *q; + + while ( p ) { + q = (TickerData *) p->data; + if ( q ) + BuddyTickerRemoveUser( q->buddy ); + p = tickerbuds; + } + userclose = FALSE; + if ( tickerwindow ) + gtk_widget_hide( tickerwindow ); +} + +void +BuddyTickerClearList( void ) +{ + GList *p = tickerbuds; + + while ( p ) + p = g_list_remove( p, p->data ); + tickerbuds = (GList *) NULL; +} + +void BuddyTickerShow() +{ + GdkPixmap *pm; + GdkBitmap *bm; + struct gaim_connection *gc; + struct group *g; + struct buddy *b; + GSList *gcons, *grps, *buds; + char **xpm; + + for( gcons = connections; gcons; gcons = gcons->next ) { + gc = (struct gaim_connection *)gcons->data; + for( grps = gc->groups; grps; grps = grps->next ) { + g = (struct group *)grps->data; + for( buds = g->members; buds; buds = buds->next ) { + b = (struct buddy *)buds->data; + if( b->present ) { + xpm = NULL; + if (gc->prpl->list_icon) + xpm = gc->prpl->list_icon(b->uc); + if (xpm == NULL) + xpm = (char **)no_icon_xpm; + pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, NULL, xpm); + BuddyTickerAddUser( b->name, b->show, pm, bm ); + gdk_pixmap_unref(pm); + if (bm) + gdk_bitmap_unref(bm); + } + } + } + } +} + +void signon_cb(struct gaim_connection *gc, char *who) { + struct buddy *b = find_buddy(gc, who); + char **xpm = NULL; + + GdkPixmap *pm; + GdkBitmap *bm; + + if (gc->prpl->list_icon) + xpm = gc->prpl->list_icon(b->uc); + if (xpm == NULL) + xpm = (char **)no_icon_xpm; + pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, NULL, xpm); + + BuddyTickerAddUser(who, b->show, pm, bm); + gdk_pixmap_unref(pm); + if (bm) + gdk_bitmap_unref(bm); +} + +void signoff_cb(struct gaim_connection *gc) { + if (!connections->next) { + gtk_widget_destroy(tickerwindow); + tickerwindow = NULL; + ticker = NULL; + } +} + +void buddy_signoff_cb(struct gaim_connection *gc, char *who) { + BuddyTickerRemoveUser(who); +} + +void away_cb(struct gaim_connection *gc, char *who) { + struct buddy *b = find_buddy(gc, who); + char **xpm = NULL; + + GdkPixmap *pm; + GdkBitmap *bm; + + if (gc->prpl->list_icon) + xpm = gc->prpl->list_icon(b->uc); + if (xpm == NULL) + xpm = (char **)no_icon_xpm; + pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, NULL, xpm); + BuddyTickerSetPixmap(who, pm, bm); + gdk_pixmap_unref(pm); + if (bm) + gdk_bitmap_unref(bm); +} + +char *gaim_plugin_init(GModule *h) { + handle = h; + + gaim_signal_connect(h, event_buddy_signon, signon_cb, NULL); + gaim_signal_connect(h, event_signoff, signoff_cb, NULL); + gaim_signal_connect(h, event_buddy_signoff, buddy_signoff_cb, NULL); + gaim_signal_connect(h, event_buddy_away, away_cb, NULL); + gaim_signal_connect(h, event_buddy_back, away_cb, NULL); + + if (connections) + BuddyTickerShow(); + return NULL; +} + +void gaim_plugin_remove() { + gtk_widget_destroy(tickerwindow); +}
--- a/src/Makefile.am Sat Aug 10 02:42:55 2002 +0000 +++ b/src/Makefile.am Sun Aug 11 06:42:17 2002 +0000 @@ -15,7 +15,6 @@ gaimrc.c \ gtkimhtml.c \ gtkspell.c \ - gtkticker.c \ html.c \ idle.c \ list.c \ @@ -29,7 +28,6 @@ prpl.c \ server.c \ sound.c \ - ticker.c \ util.c gaim_applet_DEPENDENCIES = @LIBOBJS@ $(STATIC_LINK_LIBS) gaim_applet_LDFLAGS = -export-dynamic @@ -49,7 +47,6 @@ gaimrc.c \ gtkimhtml.c \ gtkspell.c \ - gtkticker.c \ html.c \ idle.c \ list.c \ @@ -63,7 +60,6 @@ prpl.c \ server.c \ sound.c \ - ticker.c \ util.c gaim_DEPENDENCIES = @LIBOBJS@ $(STATIC_LINK_LIBS) gaim_LDFLAGS = -export-dynamic @@ -84,7 +80,6 @@ getopt1.c \ gtkimhtml.h \ gtkspell.h \ - gtkticker.h \ md5.h \ multi.h \ prpl.h \
--- a/src/aim.c Sat Aug 10 02:42:55 2002 +0000 +++ b/src/aim.c Sun Aug 11 06:42:17 2002 +0000 @@ -57,7 +57,6 @@ #include <signal.h> #endif #include "locale.h" -#include "gtkticker.h" #include "gtkspell.h" #ifndef USE_APPLET #include <getopt.h> @@ -83,8 +82,6 @@ char *opt_rcfile_arg = NULL; int opt_debug = 0; -void BuddyTickerCreateWindow(void); - #if HAVE_SIGNAL_H /* * Lists of signals we wish to catch and those we wish to ignore.
--- a/src/buddy.c Sat Aug 10 02:42:55 2002 +0000 +++ b/src/buddy.c Sun Aug 11 06:42:17 2002 +0000 @@ -94,9 +94,6 @@ GtkWidget *bpmenu; GtkWidget *buddies; -void BuddyTickerLogonTimeout(gpointer data); -void BuddyTickerLogoutTimeout(gpointer data); - typedef struct _GtkTreePixmaps GtkTreePixmaps; @@ -303,8 +300,6 @@ } update_num_group(gs); } else { - if (misc_options & OPT_MISC_BUDDY_TICKER) - BuddyTickerSetAlias(b->name, b->show); gtk_label_set_text(GTK_LABEL(bs->label), b->show); update_idle_time(bs); } @@ -589,19 +584,6 @@ show_log(NULL); } -void pressed_ticker(char *buddy) -{ - struct conversation *c; - - c = find_conversation(buddy); - - if (c != NULL) { - gdk_window_show(c->window->window); - } else { - c = new_conversation(buddy); - } -} - void pressed_alias_bs(GtkWidget *widget, struct buddy_show *bs) { alias_dialog_bud(find_buddy(bs->connlist->data, bs->name)); @@ -2110,8 +2092,6 @@ gtk_widget_show(b->pix); if (!(blist_options & OPT_BLIST_SHOW_PIXMAPS)) gtk_widget_hide(b->pix); - if (misc_options & OPT_MISC_BUDDY_TICKER) - BuddyTickerSetPixmap(b->name, pm, bm); gdk_pixmap_unref(pm); gdk_bitmap_unref(bm); gtk_timeout_remove(b->log_timer); @@ -2346,10 +2326,6 @@ gtk_widget_hide(bs->pix); gtk_pixmap_set(GTK_PIXMAP(bs->pix), pm, bm); gtk_widget_show(bs->pix); - if (misc_options & OPT_MISC_BUDDY_TICKER) { - BuddyTickerAddUser(b->name, b->show, pm, bm); - gtk_timeout_add(10000, (GtkFunction)BuddyTickerLogonTimeout, b->name); - } gdk_pixmap_unref(pm); gdk_bitmap_unref(bm); b->present = 2; @@ -2385,8 +2361,6 @@ gtk_widget_show(bs->pix); if (!(blist_options & OPT_BLIST_SHOW_PIXMAPS)) gtk_widget_hide(bs->pix); - if (misc_options & OPT_MISC_BUDDY_TICKER) - BuddyTickerSetPixmap(b->name, pm, bm); gdk_pixmap_unref(pm); gdk_bitmap_unref(bm); } @@ -2415,10 +2389,6 @@ gtk_widget_hide(bs->pix); gtk_pixmap_set(GTK_PIXMAP(bs->pix), pm, bm); gtk_widget_show(bs->pix); - if (misc_options & OPT_MISC_BUDDY_TICKER) { - BuddyTickerSetPixmap(b->name, pm, bm); - gtk_timeout_add(10000, (GtkFunction)BuddyTickerLogoutTimeout, b->name); - } gdk_pixmap_unref(pm); gdk_bitmap_unref(bm); if ((bs->sound != 1) && (im_options & OPT_IM_LOGON)) {
--- a/src/gaim.h Sat Aug 10 02:42:55 2002 +0000 +++ b/src/gaim.h Sun Aug 11 06:42:17 2002 +0000 @@ -179,7 +179,7 @@ extern guint misc_options; #define OPT_MISC_DEBUG 0x00000001 #define OPT_MISC_BROWSER_POPUP 0x00000002 -#define OPT_MISC_BUDDY_TICKER 0x00000004 +#define OPT_MISC_BUDDY_TICKER 0x00000004 #define OPT_MISC_COOL_LOOK 0x00000008 #define OPT_MISC_STEALTH_TYPING 0x00000010
--- a/src/gaimrc.c Sat Aug 10 02:42:55 2002 +0000 +++ b/src/gaimrc.c Sun Aug 11 06:42:17 2002 +0000 @@ -683,7 +683,6 @@ { /* OPT_DISP_IGNORE_COLOUR */ 0x00000020, &convo_options, OPT_CONVO_IGNORE_COLOUR }, { /* OPT_DISP_SHOW_LOGON */ 0x00000040, &im_options, OPT_IM_LOGON }, { /* OPT_DISP_SHOW_SMILEY */ 0x00000100, &convo_options, OPT_CONVO_SHOW_SMILEY }, -{ /* OPT_DISP_SHOW_BUDDYTICKER */ 0x00000200, &misc_options, OPT_MISC_BUDDY_TICKER }, { /* OPT_DISP_COOL_LOOK */ 0x00000400, &misc_options, OPT_MISC_COOL_LOOK }, { /* OPT_DISP_CHAT_LOGON */ 0x00000800, &chat_options, OPT_CHAT_LOGON }, { /* OPT_DISP_NO_BUTTONS */ 0x00002000, &blist_options, OPT_BLIST_NO_BUTTONS }, @@ -828,6 +827,13 @@ if (!away_resend) away_resend = 120; + + if (misc_options & OPT_MISC_BUDDY_TICKER) { + char *tickerplugin = g_build_filename(LIBDIR, "ticker.so", NULL); + load_plugin(tickerplugin); + g_free(tickerplugin); + misc_options &= ~OPT_MISC_BUDDY_TICKER; + } } static void gaimrc_write_options(FILE *f)
--- a/src/multi.c Sat Aug 10 02:42:55 2002 +0000 +++ b/src/multi.c Sun Aug 11 06:42:17 2002 +0000 @@ -1482,8 +1482,6 @@ #else show_login(); #endif /* USE_APPLET */ - if (misc_options & OPT_MISC_BUDDY_TICKER) - BuddyTickerSignoff(); } struct aim_user *new_user(const char *name, int proto, int opts)
--- a/src/prefs.c Sat Aug 10 02:42:55 2002 +0000 +++ b/src/prefs.c Sun Aug 11 06:42:17 2002 +0000 @@ -151,8 +151,6 @@ static void set_sound_options(); static void set_away_options(); -extern void BuddyTickerShow(); - #define PROXYHOST 0 #define PROXYPORT 1 #define PROXYTYPE 2 @@ -276,7 +274,6 @@ /* These shouldn't have to wait for user to click OK or APPLY or whatnot */ /* They really shouldn't be in preferences at all */ - gaim_button(_("Show Buddy Ticker"), &misc_options, OPT_MISC_BUDDY_TICKER, vbox); debugbutton = gaim_button(_("Show Debug Window"), &misc_options, OPT_MISC_DEBUG, vbox); gtk_widget_show (vbox); @@ -1967,9 +1964,6 @@ if (option == OPT_MISC_DEBUG) show_debug(); - if (option == OPT_MISC_BUDDY_TICKER) - BuddyTickerShow(); - save_prefs(); } @@ -2119,9 +2113,9 @@ gtk_box_pack_start(GTK_BOX(page), button, FALSE, FALSE, 0); gtk_object_set_user_data(GTK_OBJECT(button), options); - /* So that the ticker and debug window happen immediately - * I don't think they should be "preferences," anyway. */ - if (options == &misc_options && (option == OPT_MISC_DEBUG || option == OPT_MISC_BUDDY_TICKER)) + /* So that the debug window happens immediately + * I don't think it should be "preferences," anyway. */ + if (options == &misc_options && option == OPT_MISC_DEBUG) gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_misc_option), (int *)option); else
--- a/src/ui.h Sat Aug 10 02:42:55 2002 +0000 +++ b/src/ui.h Sun Aug 11 06:42:17 2002 +0000 @@ -517,13 +517,4 @@ extern void play_sound(int); extern void play_file(char *); -/* Fucntions in ticker.c */ -void SetTickerPrefs(); -void BuddyTickerSignOff(); -void BuddyTickerAddUser(char *, char *, GdkPixmap *, GdkBitmap *); -void BuddyTickerSetPixmap(char *, GdkPixmap *, GdkBitmap *); -void BuddyTickerSetAlias(char *, char *); -void BuddyTickerSetNames(); -void BuddyTickerSignoff(); - #endif /* _UI_H_ */