pidgin/purple-plugin-pack

Parents 3c3735666531
Children 95a956cba531
remove stocker as the aol servers it used have been taken down
--- a/meson.build Sun Mar 01 18:39:32 2020 -0600
+++ b/meson.build Sun Mar 01 18:43:49 2020 -0600
@@ -199,7 +199,6 @@
subdir('splitter')
#subdir('stress')
subdir('sslinfo')
-subdir('stocker')
subdir('switchspell')
subdir('timelog')
subdir('translate')
--- a/stocker/README.md Sun Mar 01 18:39:32 2020 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-# Stocker
-
-status: incomplete
-dependencies: pidgin
-authors: Gary Kramlich
-introduced: 1.0beta1
-notes: This plugin partially works but is buggy and in need of TLC.
-
-Adds a stock ticker similar to the one in the Windows AIM client to the bottom of the buddy list.
-
--- a/stocker/gtkticker.c Sun Mar 01 18:39:32 2020 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,513 +0,0 @@
-/* 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., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02111-1301, 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_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;
-
-
-GType gtk_ticker_get_type (void)
-{
- static GType ticker_type = 0;
-
- ticker_type = g_type_from_name("GtkTicker");
-
- if (ticker_type == 0)
- {
- static const GTypeInfo ticker_info =
- {
- sizeof(GtkTickerClass),
- NULL,
- NULL,
- (GClassInitFunc) gtk_ticker_class_init,
- NULL,
- NULL,
- sizeof(GtkTicker),
- 0,
- (GInstanceInitFunc) gtk_ticker_init
- };
-
- ticker_type = g_type_register_static (GTK_TYPE_CONTAINER, "GtkTicker",
- &ticker_info, 0);
- }
-
- /* kludge to re-initialise the class if it's already registered */
- else if (parent_class == NULL) {
- gtk_ticker_class_init((GtkTickerClass *)g_type_class_peek(ticker_type));
- }
-
- return ticker_type;
-}
-
-static void gtk_ticker_finalize(GObject *object) {
- gtk_ticker_stop_scroll(GTK_TICKER(object));
-
- G_OBJECT_CLASS(parent_class)->finalize(object);
-}
-
-static void gtk_ticker_class_init (GtkTickerClass *class)
-{
- GObjectClass *gobject_class;
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
-
- gobject_class = (GObjectClass*) class;
- widget_class = (GtkWidgetClass*) class;
- container_class = (GtkContainerClass*) class;
-
- parent_class = gtk_type_class (GTK_TYPE_CONTAINER);
-
- gobject_class->finalize = gtk_ticker_finalize;
-
- 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;
-
- 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)
-{
- return GTK_WIDGET(g_object_new(GTK_TYPE_TICKER, NULL));
-}
-
-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 = g_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;
- g_source_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;
- }
-}
-
-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);
- }
-}
-
--- a/stocker/gtkticker.h Sun Mar 01 18:39:32 2020 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-/* 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., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02111-1301, 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 */
- gint spacing; /* inter-child horizontal spacing */
- guint scootch; /* how many pixels to move each scootch */
- gint timer; /* timer object */
- gint total; /* total width of widgets */
- gint 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__ */
--- a/stocker/meson.build Sun Mar 01 18:39:32 2020 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-if TYPES.contains('incomplete') and PIDGIN.found()
- stocker = shared_module('stocker',
- 'stocker.c',
- 'stocker_prefs.c',
- 'gtkticker.c',
- dependencies : [PIDGIN, GTK],
- name_prefix : '',
- install : true,
- install_dir : PIDGIN_LIBDIR)
- PP_PIDGIN_BUILD += 'stocker'
-endif
--- a/stocker/stocker.c Sun Mar 01 18:39:32 2020 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,412 +0,0 @@
-/*
- * Stocker - Adds a stock ticker to the buddy list
- * Copyright (C) 2005-2008 Gary Kramlich <grim@reaperworld.com>
- *
- * 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., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02111-1301, USA.
- */
-
-/* If you can't figure out what this line is for, DON'T TOUCH IT. */
-#include "../common/pp_internal.h"
-
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-
-#include <gtkplugin.h>
-#include <gtkprefs.h>
-#include <gtkblist.h>
-#include <gtkutils.h>
-#include <prefs.h>
-
-#include "gtkticker.h"
-#include "stocker_prefs.h"
-
-#define URL_REQUEST "http://quotewebvip-m01.blue.aol.com/?action=aim&syms=%s&fields=nspg"
-
-#define CHANGE_INCREASE "<span color=\"green3\">%+0.04g</span>"
-#define CHANGE_DECREASE "<span color=\"red\">%+0.04g</span>"
-#define CHANGE_NONE "%0.04g"
-
-/******************************************************************************
- * structs
- *****************************************************************************/
-#define STOCKER_QUOTE(obj) ((StockerQuote *)(obj))
-
-typedef struct {
- gchar *symbol;
-
- GtkWidget *label;
-
- guint ref;
-} StockerQuote;
-
-/******************************************************************************
- * globals
- *****************************************************************************/
-static GtkWidget *ticker = NULL;
-static GHashTable *quotes = NULL;
-static guint quotes_id = 0, interval_id = 0, interval_timer = 0;
-
-/******************************************************************************
- * Quote stuff
- *****************************************************************************/
-static StockerQuote *
-stocker_quote_new(const gchar *symbol) {
- StockerQuote *ret = g_new0(StockerQuote, 1);
- gchar *label = NULL;
-
- ret->symbol = g_strdup(symbol);
-
- label = g_strdup_printf("%s (refreshing)", symbol);
- ret->label = gtk_label_new(label);
- g_free(label);
-
- gtk_ticker_add(GTK_TICKER(ticker), ret->label);
- gtk_widget_show(ret->label);
-
- ret->ref = 1;
-
- return ret;
-}
-
-static void
-stocker_quote_ref(StockerQuote *quote) {
- quote->ref++;
-}
-
-static void
-stocker_quote_unref(StockerQuote *quote) {
- quote->ref--;
-
- if(quote->ref != 0)
- return;
-
- g_free(quote->symbol);
-
- gtk_widget_destroy(quote->label);
-
- g_free(quote);
-
- quote = NULL;
-}
-
-static void
-stocker_quote_update(StockerQuote *quote, const gchar *name, gdouble current,
- gdouble change)
-{
- GString *str = g_string_sized_new(512);
-
- g_string_append_printf(str,
- "<span weight=\"bold\">%s</span> "
- "<span size=\"small\">(%s)</span> $%g ",
- name, quote->symbol, current);
- if(change < 0.0)
- g_string_append_printf(str, CHANGE_DECREASE, change);
- else if(change > 0.0)
- g_string_append_printf(str, CHANGE_INCREASE, change);
- else
- g_string_append_printf(str, CHANGE_NONE, change);
-
- gtk_label_set_markup(GTK_LABEL(quote->label), str->str);
-
- g_string_free(str, TRUE);
-}
-
-/******************************************************************************
- * main stuff
- *****************************************************************************/
-static void
-stocker_refresh_url_cb(PurpleUtilFetchUrlData *url_data, gpointer data,
- const gchar *text, gsize len, const gchar *errmsg)
-{
- const gchar *p = text;
- gchar *t;
-
- while((p = g_strstr_len(p, strlen(p), "DATA="))) {
- const gchar *name = NULL, *symbol = NULL;
- gdouble current = 0.0, change = 0.0;
-
- /* move paste the data text */
- p += 5;
-
- /* find the name */
- t = strchr(p, ';');
- *t = '\0';
- name = p;
-
- /* find the symbol */
- p = t + 1;
- t = strchr(p, ';');
- *t = '\0';
- symbol = p;
-
- /* find the current price */
- p = t + 1;
- t = strchr(p, ';');
- *t = '\0';
- current = atof(p);
-
- /* find the change */
- p = t + 1;
- t = strchr(p, '\r');
- *t = '\0';
- change = atof(p);
-
- /* now move p to the EOL */
- p = t + 1;
-
- if(symbol) {
- StockerQuote *quote = g_hash_table_lookup(quotes, symbol);
-
- if(quote) {
- stocker_quote_update(quote, name, current, change);
- }
- }
- }
-}
-
-static void
-stocker_refresh_helper(gpointer k, gpointer v, gpointer d) {
- GString *str = (GString *)d;
- gchar *symbol = (gchar *)k;
-
- g_string_append_printf(str, "%s%s",
- (str->len > 0) ? "," : "",
- symbol);
-}
-
-static void
-stocker_refresh(void) {
- GString *syms = g_string_sized_new(64);
- gchar *url = NULL;
-
- g_hash_table_foreach(quotes, stocker_refresh_helper, syms);
-
- url = g_strdup_printf(URL_REQUEST, syms->str);
- g_string_free(syms, TRUE);
-
- purple_util_fetch_url(url, TRUE, "purple", TRUE,
- stocker_refresh_url_cb,
- NULL);
- g_free(url);
-}
-
-static gboolean
-stocker_create() {
- PurpleBuddyList *blist;
- PidginBuddyList *gtkblist;
-
- if(GTK_IS_WIDGET(ticker))
- gtk_widget_destroy(ticker);
-
- blist = purple_get_blist();
- if(!blist)
- return FALSE;
-
- gtkblist = PIDGIN_BLIST(blist);
-
- ticker = gtk_ticker_new();
- gtk_box_pack_start(GTK_BOX(gtkblist->vbox), ticker, FALSE, FALSE, 0);
- gtk_ticker_set_spacing(GTK_TICKER(ticker), 16);
- gtk_ticker_start_scroll(GTK_TICKER(ticker));
- gtk_widget_show_all(ticker);
-
- return TRUE;
-}
-
-static void
-stocker_blist_created(PurpleBuddyList *blist, gpointer data) {
- stocker_create();
-}
-
-static void
-stocker_quotes_refresh(GList *symbols) {
- StockerQuote *quote = NULL;
- GHashTable *new_quotes = NULL, *temp = NULL;
- GList *l = NULL;
-
- /* this is a bit more complicated than I'd like, but we need a way to be
- * able to remove quotes that we don't know by name. So we create a new
- * hashtable, copy all the existing quotes over to it, add the new ones,
- * then delete the old table and use the new one.
- */
-
- new_quotes = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
- (GDestroyNotify)stocker_quote_unref);
-
- for(l = symbols; l; l = l->next) {
- gchar *symbol = l->data;
-
- /* sanity check to make sure we have a symbol */
- if(!symbol)
- continue;
-
- /* look for a quote */
- quote = g_hash_table_lookup(quotes, symbol);
-
- if(quote) {
- /* ref the quote so it stays alive */
- stocker_quote_ref(quote);
- } else {
- /* this is a new symbol, create a quote for it */
- quote = stocker_quote_new(symbol);
- }
-
- /* insert the quote into the new hashtable */
- g_hash_table_insert(new_quotes, g_strdup(symbol), quote);
- }
-
- /* hold onto the old pointer */
- temp = quotes;
-
- /* update the pointer to the updated list */
- quotes = new_quotes;
-
- /* kill the old table */
- g_hash_table_destroy(temp);
-
- /* refresh everything */
- stocker_refresh();
-}
-
-static void
-stocker_quotes_changed_cb(const gchar *name, PurplePrefType type,
- gconstpointer value, gpointer data)
-{
- stocker_quotes_refresh((GList *)value);
-}
-
-static gboolean
-stocker_refresh_cb(gpointer data) {
- stocker_refresh();
-
- return TRUE;
-}
-
-static void
-stocker_interval_changed_cb(const gchar *name, PurplePrefType type,
- gconstpointer value, gpointer data)
-{
- gint new_time = GPOINTER_TO_INT(value);
-
- /* remove the old timer */
- purple_timeout_remove(interval_timer);
-
- /* add the new one */
- interval_timer = purple_timeout_add_seconds(new_time * 60,
- stocker_refresh_cb, NULL);
-}
-
-/******************************************************************************
- * plugin crap
- *****************************************************************************/
-static gboolean
-stocker_load(PurplePlugin *plugin) {
- void *prefs_handle = purple_prefs_get_handle();
- gint interval;
-
- stocker_create();
-
- quotes = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
- (GDestroyNotify)stocker_quote_unref);
-
- purple_signal_connect(pidgin_blist_get_handle(), "gtkblist-created",
- plugin,
- PURPLE_CALLBACK(stocker_blist_created), NULL);
-
- quotes_id = purple_prefs_connect_callback(prefs_handle, PREF_SYMBOLS,
- stocker_quotes_changed_cb,
- NULL);
- interval_id = purple_prefs_connect_callback(prefs_handle, PREF_INTERVAL,
- stocker_interval_changed_cb,
- NULL);
-
- interval = 60 * purple_prefs_get_int(PREF_INTERVAL);
- interval_timer = purple_timeout_add_seconds(interval, stocker_refresh_cb,
- NULL);
-
- stocker_quotes_refresh(purple_prefs_get_string_list(PREF_SYMBOLS));
-
- stocker_refresh();
-
- return TRUE;
-}
-
-static gboolean
-stocker_unload(PurplePlugin *plugin) {
- return FALSE;
-}
-
-static void
-stocker_destroy(PurplePlugin *plugin) {
- purple_timeout_remove(interval_timer);
-
- if(GTK_IS_WIDGET(ticker))
- gtk_widget_destroy(ticker);
- ticker = NULL;
-}
-
-static PidginPluginUiInfo stocker_ui_info = { stocker_prefs_get_frame };
-
-static PurplePluginInfo stocker_info =
-{
- PURPLE_PLUGIN_MAGIC,
- PURPLE_MAJOR_VERSION,
- PURPLE_MINOR_VERSION,
- PURPLE_PLUGIN_STANDARD,
- PIDGIN_PLUGIN_TYPE,
- 0,
- NULL,
- PURPLE_PRIORITY_DEFAULT,
-
- "gtk-plugin_pack-stocker",
- NULL,
- PP_VERSION,
- NULL,
- NULL,
- "Gary Kramlich <grim@reaperworld.com>",
- PP_WEBSITE,
-
- stocker_load,
- stocker_unload,
- stocker_destroy,
-
- &stocker_ui_info,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL
-};
-
-static void
-stocker_init(PurplePlugin *plugin) {
-#ifdef ENABLE_NLS
- bindtextdomain(GETTEXT_PACKAGE, PP_LOCALEDIR);
- bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
-#endif /* ENABLE_NLS */
-
- stocker_info.name = _("Stocker");
- stocker_info.summary = _("A stock ticker");
- stocker_info.description =
- _("Adds a stock ticker similar to the one in the Windows AIM client to"
- " the bottom of the buddy list.");
-
- stocker_prefs_init();
-}
-
-PURPLE_INIT_PLUGIN(stocker, stocker_init, stocker_info)
--- a/stocker/stocker_prefs.c Sun Mar 01 18:39:32 2020 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,323 +0,0 @@
-/*
- * Stocker - Adds a stock ticker to the buddy list
- * Copyright (C) 2005-2008 Gary Kramlich <grim@reaperworld.com>
- *
- * 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., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02111-1301, USA.
- */
-/* If you can't figure out what this line is for, DON'T TOUCH IT. */
-#include "../common/pp_internal.h"
-
-#include "stocker_prefs.h"
-
-#include <gtkprefs.h>
-#include <gtkutils.h>
-
-/******************************************************************************
- * Structs
- *****************************************************************************/
-#define STOCKER_PREFS(obj) ((StockerPrefs *)(obj))
-
-typedef struct {
- GtkWidget *entry;
- GtkWidget *list;
- GtkListStore *symbols;
-} StockerPrefs;
-
-/******************************************************************************
- * helpers
- *****************************************************************************/
-static void
-stocker_prefs_update_list(StockerPrefs *prefs) {
- GtkTreeIter iter;
- GList *l;
- gchar *symbol;
-
- gtk_list_store_clear(prefs->symbols);
-
- for(l = purple_prefs_get_string_list(PREF_SYMBOLS); l; l = l->next) {
- symbol = (gchar *)l->data;
-
- gtk_list_store_append(prefs->symbols, &iter);
- gtk_list_store_set(prefs->symbols, &iter,
- 0, symbol,
- -1);
- }
-}
-
-static gboolean
-stocker_prefs_apply_helper(GtkTreeModel *model, GtkTreePath *path,
- GtkTreeIter *iter, gpointer data)
-{
- GList **symbols = (GList **)data;
- gchar *symbol;
-
- gtk_tree_model_get(model, iter,
- 0, &symbol,
- -1);
- *symbols = g_list_append(*symbols, symbol);
-
- return FALSE;
-}
-
-static void
-stocker_prefs_apply_cb(GtkButton *button, gpointer data) {
- StockerPrefs *prefs = (StockerPrefs *)data;
- GList *symbols = NULL, *l;
-
- gtk_tree_model_foreach(GTK_TREE_MODEL(prefs->symbols),
- stocker_prefs_apply_helper, &symbols);
-
- purple_prefs_set_string_list(PREF_SYMBOLS, symbols);
-
- for(l = symbols; l; l = l->next)
- g_free(l->data);
- g_list_free(symbols);
-}
-
-static void
-stocker_prefs_add_cb(GtkButton *button, gpointer data) {
- StockerPrefs *prefs = (StockerPrefs *)data;
- GtkTreeIter iter;
- const gchar *symbol;
-
- symbol = gtk_entry_get_text(GTK_ENTRY(prefs->entry));
- if(g_utf8_strlen(symbol, -1) <= 0)
- return;
-
- gtk_list_store_append(prefs->symbols, &iter);
- gtk_list_store_set(prefs->symbols, &iter,
- 0, symbol,
- -1);
- gtk_entry_set_text(GTK_ENTRY(prefs->entry), "");
-}
-
-static void
-stocker_prefs_remove_cb(GtkButton *button, gpointer data) {
- StockerPrefs *prefs = (StockerPrefs *)data;
- GtkTreeSelection *sel;
- GtkTreeIter iter;
- gchar *symbol;
-
- sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(prefs->list));
- if(!gtk_tree_selection_get_selected(sel, NULL, &iter))
- return;
-
- gtk_tree_model_get(GTK_TREE_MODEL(prefs->symbols), &iter,
- 0, &symbol,
- -1);
- gtk_entry_set_text(GTK_ENTRY(prefs->entry), symbol);
- g_free(symbol);
-
- gtk_list_store_remove(prefs->symbols, &iter);
-}
-
-static void
-stocker_prefs_move_up_cb(GtkButton *button, gpointer data) {
- StockerPrefs *prefs = STOCKER_PREFS(data);
- GtkTreeSelection *sel;
- GtkTreeIter siter, diter;
- GtkTreePath *path;
-
- sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(prefs->list));
- if(!gtk_tree_selection_get_selected(sel, NULL, &siter)) {
- return;
- }
-
- path = gtk_tree_model_get_path(GTK_TREE_MODEL(prefs->symbols), &siter);
- if(!path)
- return;
-
- if(!gtk_tree_path_prev(path))
- return;
-
- if(!gtk_tree_model_get_iter(GTK_TREE_MODEL(prefs->symbols), &diter, path))
- {
- gtk_tree_path_free(path);
- return;
- }
-
- gtk_tree_path_free(path);
-
-#if GTK_CHECK_VERSION(2,2,0)
- gtk_list_store_swap(prefs->symbols, &siter, &diter);
-#else
-# warning Someone make me work on gtk < 2.2.0
-#endif
-}
-
-static void
-stocker_prefs_move_down_cb(GtkButton *button, gpointer data) {
- StockerPrefs *prefs = STOCKER_PREFS(data);
- GtkTreeSelection *sel;
- GtkTreeIter siter, diter;
- GtkTreePath *path;
-
- sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(prefs->list));
- if(!gtk_tree_selection_get_selected(sel, NULL, &siter)) {
- return;
- }
-
- path = gtk_tree_model_get_path(GTK_TREE_MODEL(prefs->symbols), &siter);
- if(!path)
- return;
-
- gtk_tree_path_next(path);
-
- if(!gtk_tree_model_get_iter(GTK_TREE_MODEL(prefs->symbols), &diter, path))
- {
- gtk_tree_path_free(path);
- return;
- }
-
- gtk_tree_path_free(path);
-
-#if GTK_CHECK_VERSION(2,2,0)
- gtk_list_store_swap(prefs->symbols, &siter, &diter);
-#else
-# warning Someone make me work on gtk < 2.2.0
-#endif
-}
-
-static void
-stocker_prefs_destroyed(gpointer data) {
- StockerPrefs *prefs = STOCKER_PREFS(data);
-
- g_object_unref(G_OBJECT(prefs->symbols));
-
- g_free(prefs);
-}
-
-/******************************************************************************
- * api
- *****************************************************************************/
-void
-stocker_prefs_init(void) {
- GList *def_syms = NULL;
-
- def_syms = g_list_append(def_syms, "GOOG");
- def_syms = g_list_append(def_syms, "YHOO");
- def_syms = g_list_append(def_syms, "RHT");
- def_syms = g_list_append(def_syms, "VMW");
-
- purple_prefs_add_none(PREF_MY);
- purple_prefs_add_none(PREF_ROOT);
- purple_prefs_add_string_list(PREF_SYMBOLS, def_syms);
- purple_prefs_add_int(PREF_INTERVAL, 30);
- g_list_free(def_syms);
-}
-
-GtkWidget *
-stocker_prefs_get_frame(PurplePlugin *plugin) {
- StockerPrefs *prefs = g_new0(StockerPrefs, 1);
- GtkWidget *ret, *vbox, *hbox, *box, *frame, *sw, *label, *button;
- GtkSizeGroup *sg;
- GtkTreeViewColumn *col;
- GtkCellRenderer *rend;
-
- sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
-
- ret = gtk_vbox_new(FALSE, 4);
- gtk_container_set_border_width(GTK_CONTAINER(ret), 12);
- g_object_set_data_full(G_OBJECT(ret), "prefs", prefs,
- stocker_prefs_destroyed);
-
- /**********************************
- * symbols frame
- *********************************/
- frame = pidgin_make_frame(ret, _("Symbols"));
-
- box = gtk_hbox_new(FALSE, 4);
- gtk_box_pack_start(GTK_BOX(frame), box, FALSE, FALSE, 0);
-
- vbox = gtk_vbox_new(FALSE, 4);
- gtk_box_pack_start(GTK_BOX(box), vbox, FALSE, FALSE, 0);
-
- /* symbol entry */
- hbox = gtk_hbox_new(FALSE, 4);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
-
- label = gtk_label_new(_("Symbol:"));
- gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
- gtk_size_group_add_widget(sg, label);
- gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
-
- prefs->entry = gtk_entry_new();
- gtk_box_pack_start(GTK_BOX(hbox), prefs->entry, FALSE, FALSE, 0);
-
- /* symbols list */
- sw = gtk_scrolled_window_new(NULL, NULL);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
- GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN);
- gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
-
- /* yes we purposely keep a reference.... */
- prefs->symbols = gtk_list_store_new(1, G_TYPE_STRING);
- stocker_prefs_update_list(prefs);
-
- prefs->list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(prefs->symbols));
- gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(prefs->list), FALSE);
- gtk_tree_view_set_reorderable(GTK_TREE_VIEW(prefs->list), TRUE);
- gtk_container_add(GTK_CONTAINER(sw), prefs->list);
-
- rend = gtk_cell_renderer_text_new();
- col = gtk_tree_view_column_new_with_attributes("Symbol", rend,
- "text", 0,
- NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(prefs->list), col);
-
- /* buttons */
- vbox = gtk_vbox_new(FALSE, 4);
- gtk_box_pack_start(GTK_BOX(box), vbox, FALSE, FALSE, 0);
-
- button = gtk_button_new_from_stock(GTK_STOCK_ADD);
- g_signal_connect(G_OBJECT(button), "clicked",
- G_CALLBACK(stocker_prefs_add_cb), prefs);
- gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
-
- button = gtk_button_new_from_stock(GTK_STOCK_REMOVE);
- g_signal_connect(G_OBJECT(button), "clicked",
- G_CALLBACK(stocker_prefs_remove_cb), prefs);
- gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
-
- button = gtk_button_new_from_stock(GTK_STOCK_GO_DOWN);
- g_signal_connect(G_OBJECT(button), "clicked",
- G_CALLBACK(stocker_prefs_move_down_cb), prefs);
- gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
-
- button = gtk_button_new_from_stock(GTK_STOCK_GO_UP);
- g_signal_connect(G_OBJECT(button), "clicked",
- G_CALLBACK(stocker_prefs_move_up_cb), prefs);
- gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
-
- button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
- g_signal_connect(G_OBJECT(button), "clicked",
- G_CALLBACK(stocker_prefs_apply_cb), prefs);
- gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
-
- /**********************************
- * options frame
- *********************************/
- frame = pidgin_make_frame(ret, _("Options"));
-
- pidgin_prefs_labeled_spin_button(frame, "Update interval (minutes):",
- PREF_INTERVAL, 1, 1440, sg);
-
- /* show and return it already! */
- gtk_widget_show_all(ret);
-
- return ret;
-}
--- a/stocker/stocker_prefs.h Sun Mar 01 18:39:32 2020 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-/*
- * Stocker - Adds a stock ticker to the buddy list
- * Copyright (C) 2005-2008 Gary Kramlich <grim@reaperworld.com>
- *
- * 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., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02111-1301, USA.
- */
-#ifndef STOCKER_PREFS_H
-#define STOCKER_PREFS_H
-
-#include <gtk/gtk.h>
-
-#include <plugin.h>
-
-#define PREF_MY "/plugins/gtk/plugin_pack"
-#define PREF_ROOT "/plugins/gtk/plugin_pack/stocker"
-#define PREF_SYMBOLS "/plugins/gtk/plugin_pack/stocker/symbols"
-#define PREF_INTERVAL "/plugins/gtk/plugin_pack/stocker/interval"
-
-G_BEGIN_DECLS
-
-void stocker_prefs_init(void);
-GtkWidget *stocker_prefs_get_frame(PurplePlugin *plugin);
-
-G_END_DECLS
-
-#endif /* STOCKER_PREFS_H */