Mercurial > pidgin.yaz
changeset 18979:7072971dfc44
propagate from branch 'im.pidgin.pidgin' (head 89468df5d1cdb033902c9f7e41cfdf3a348d97bc)
to branch 'im.pidgin.soc.2007.certmgr' (head 387ac29f9b6921a2d117aa9fe5d290bd46439ac1)
author | William Ehlhardt <williamehlhardt@gmail.com> |
---|---|
date | Fri, 29 Jun 2007 20:01:33 +0000 |
parents | a421561f12d7 (current diff) 700b642631bc (diff) |
children | 1cc1c9b06bbf |
files | |
diffstat | 18 files changed, 451 insertions(+), 49 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/notify-signals.dox Fri Jun 29 04:25:54 2007 +0000 +++ b/doc/notify-signals.dox Fri Jun 29 20:01:33 2007 +0000 @@ -1,4 +1,4 @@ -/** @page conversation-signals Notification Signals +/** @page notify-signals Notification Signals @signals @signal displaying-userinfo
--- a/finch/libgnt/Makefile.am Fri Jun 29 04:25:54 2007 +0000 +++ b/finch/libgnt/Makefile.am Fri Jun 29 20:01:33 2007 +0000 @@ -26,6 +26,7 @@ gntmenu.c \ gntmenuitem.c \ gntmenuitemcheck.c \ + gntslider.c \ gntstyle.c \ gnttextview.c \ gnttree.c \ @@ -53,6 +54,7 @@ gntmenu.h \ gntmenuitem.h \ gntmenuitemcheck.h \ + gntslider.h \ gntstyle.h \ gnttextview.h \ gnttree.h \
--- a/finch/libgnt/gntlabel.c Fri Jun 29 04:25:54 2007 +0000 +++ b/finch/libgnt/gntlabel.c Fri Jun 29 20:01:33 2007 +0000 @@ -138,8 +138,7 @@ if (GNT_WIDGET(label)->window) { - gnt_widget_hide(GNT_WIDGET(label)); - gnt_label_size_request(GNT_WIDGET(label)); + werase(GNT_WIDGET(label)->window); gnt_widget_draw(GNT_WIDGET(label)); } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/finch/libgnt/gntslider.c Fri Jun 29 20:01:33 2007 +0000 @@ -0,0 +1,277 @@ +/** + * GNT - The GLib Ncurses Toolkit + * + * GNT is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * source distribution. + * + * This library 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 + */ + +#include "gntcolors.h" +#include "gntkeys.h" +#include "gntslider.h" +#include "gntstyle.h" + +enum +{ + SIG_VALUE_CHANGED, + SIGS, +}; + +static guint signals[SIGS] = { 0 }; + +static GntWidgetClass *parent_class = NULL; + +/* returns TRUE if the value was changed */ +static gboolean +sanitize_value(GntSlider *slider) +{ + if (slider->current < slider->min) + slider->current = slider->min; + else if (slider->current > slider->max) + slider->current = slider->max; + else + return FALSE; + return TRUE; +} + +static void +redraw_slider(GntSlider *slider) +{ + GntWidget *widget = GNT_WIDGET(slider); + if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_MAPPED)) + gnt_widget_draw(widget); +} + +static void +slider_value_changed(GntSlider *slider) +{ + g_signal_emit(slider, signals[SIG_VALUE_CHANGED], 0, slider->current); +} + +static void +gnt_slider_draw(GntWidget *widget) +{ + GntSlider *slider = GNT_SLIDER(widget); + int attr = 0; + int position, size = 0; + + if (slider->vertical) + size = widget->priv.height; + else + size = widget->priv.width; + + if (gnt_widget_has_focus(widget)) + attr |= GNT_COLOR_HIGHLIGHT; + else + attr |= GNT_COLOR_HIGHLIGHT_D; + + if (slider->max != slider->min) + position = ((size - 1) * (slider->current - slider->min)) / (slider->max - slider->min); + else + position = 0; + if (slider->vertical) { + mvwvline(widget->window, size-position, 0, ACS_VLINE | COLOR_PAIR(GNT_COLOR_NORMAL) | A_BOLD, + position); + mvwvline(widget->window, 0, 0, ACS_VLINE | COLOR_PAIR(GNT_COLOR_NORMAL), + size-position); + } else { + mvwhline(widget->window, 0, 0, ACS_HLINE | COLOR_PAIR(GNT_COLOR_NORMAL) | A_BOLD, + position); + mvwhline(widget->window, 0, position, ACS_HLINE | COLOR_PAIR(GNT_COLOR_NORMAL), + size - position); + } + + mvwaddch(widget->window, + slider->vertical ? (size - position - 1) : 0, + slider->vertical ? 0 : position, + ACS_CKBOARD | COLOR_PAIR(attr)); +} + +static void +gnt_slider_size_request(GntWidget *widget) +{ + if (GNT_SLIDER(widget)->vertical) { + widget->priv.width = 1; + widget->priv.height = 5; + } else { + widget->priv.width = 5; + widget->priv.height = 1; + } +} + +static void +gnt_slider_map(GntWidget *widget) +{ + if (widget->priv.width == 0 || widget->priv.height == 0) + gnt_widget_size_request(widget); + GNTDEBUG; +} + +static gboolean +step_back(GntBindable *bindable, GList *null) +{ + GntSlider *slider = GNT_SLIDER(bindable); + if (slider->current <= slider->min) + return FALSE; + gnt_slider_advance_step(slider, -1); + return TRUE; +} + +static gboolean +step_forward(GntBindable *bindable, GList *list) +{ + GntSlider *slider = GNT_SLIDER(bindable); + if (slider->current >= slider->max) + return FALSE; + gnt_slider_advance_step(slider, 1); + return TRUE; +} + +static void +gnt_slider_class_init(GntSliderClass *klass) +{ + GntBindableClass *bindable = GNT_BINDABLE_CLASS(klass); + parent_class = GNT_WIDGET_CLASS(klass); + parent_class->draw = gnt_slider_draw; + parent_class->map = gnt_slider_map; + parent_class->size_request = gnt_slider_size_request; + + klass->changed = NULL; + + signals[SIG_VALUE_CHANGED] = + g_signal_new("changed", + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET(GntSliderClass, changed), + NULL, NULL, + g_cclosure_marshal_VOID__INT, + G_TYPE_NONE, 1, G_TYPE_INT); + + gnt_bindable_class_register_action(bindable, "step-backward", step_back, GNT_KEY_LEFT, NULL); + gnt_bindable_register_binding(bindable, "step-backward", GNT_KEY_DOWN, NULL); + gnt_bindable_class_register_action(bindable, "step-forward", step_forward, GNT_KEY_RIGHT, NULL); + gnt_bindable_register_binding(bindable, "step-forward", GNT_KEY_UP, NULL); + + /* XXX: how would home/end work? */ + + gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass)); +} + +static void +gnt_slider_init(GTypeInstance *instance, gpointer class) +{ + GntWidget *widget = GNT_WIDGET(instance); + GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_NO_SHADOW | GNT_WIDGET_NO_BORDER | GNT_WIDGET_CAN_TAKE_FOCUS); + widget->priv.minw = 1; + widget->priv.minh = 1; + GNTDEBUG; +} + +/****************************************************************************** + * GntSlider API + *****************************************************************************/ +GType +gnt_slider_get_gtype(void) +{ + static GType type = 0; + + if(type == 0) + { + static const GTypeInfo info = { + sizeof(GntSliderClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc)gnt_slider_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(GntSlider), + 0, /* n_preallocs */ + gnt_slider_init, /* instance_init */ + NULL /* value_table */ + }; + + type = g_type_register_static(GNT_TYPE_WIDGET, + "GntSlider", + &info, 0); + } + + return type; +} + +GntWidget *gnt_slider_new(gboolean vertical, int max, int min) +{ + GntWidget *widget = g_object_new(GNT_TYPE_SLIDER, NULL); + GntSlider *slider = GNT_SLIDER(widget); + + slider->vertical = vertical; + + if (vertical) { + GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_GROW_Y); + } else { + GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_GROW_X); + } + + gnt_slider_set_range(slider, max, min); + slider->step = 1; + + return widget; +} + +void gnt_slider_set_value(GntSlider *slider, int value) +{ + if (slider->current == value) + return; + slider->current = value; + sanitize_value(slider); + redraw_slider(slider); + slider_value_changed(slider); +} + +int gnt_slider_advance_step(GntSlider *slider, int steps) +{ + slider->current += steps * slider->step; + sanitize_value(slider); + redraw_slider(slider); + slider_value_changed(slider); + return slider->current; +} + +void gnt_slider_set_step(GntSlider *slider, int step) +{ + slider->step = step; +} + +void gnt_slider_set_range(GntSlider *slider, int max, int min) +{ + slider->max = MAX(max, min); + slider->min = MIN(max, min); + sanitize_value(slider); +} + +static void +update_label(GntSlider *slider, int current_value, GntLabel *label) +{ + char value[256]; + g_snprintf(value, sizeof(value), "%d/%d", current_value, slider->max); + gnt_label_set_text(label, value); +} + +void gnt_slider_reflect_label(GntSlider *slider, GntLabel *label) +{ + g_signal_connect(G_OBJECT(slider), "changed", G_CALLBACK(update_label), label); +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/finch/libgnt/gntslider.h Fri Jun 29 20:01:33 2007 +0000 @@ -0,0 +1,139 @@ +/** + * @file gntslider.h Slider API + * @ingroup gnt + */ +/* + * GNT - The GLib Ncurses Toolkit + * + * GNT is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * source distribution. + * + * This library 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 + */ + +#ifndef GNT_SLIDER_H +#define GNT_SLIDER_H + +#include "gntwidget.h" +#include "gnt.h" +#include "gntlabel.h" + +#define GNT_TYPE_SLIDER (gnt_slider_get_gtype()) +#define GNT_SLIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_SLIDER, GntSlider)) +#define GNT_SLIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_SLIDER, GntSliderClass)) +#define GNT_IS_SLIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_SLIDER)) +#define GNT_IS_SLIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_SLIDER)) +#define GNT_SLIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_SLIDER, GntSliderClass)) + +#define GNT_SLIDER_FLAGS(obj) (GNT_SLIDER(obj)->priv.flags) +#define GNT_SLIDER_SET_FLAGS(obj, flags) (GNT_SLIDER_FLAGS(obj) |= flags) +#define GNT_SLIDER_UNSET_FLAGS(obj, flags) (GNT_SLIDER_FLAGS(obj) &= ~(flags)) + +typedef struct _GntSlider GntSlider; +typedef struct _GntSliderPriv GntSliderPriv; +typedef struct _GntSliderClass GntSliderClass; + +struct _GntSlider +{ + GntWidget parent; + + gboolean vertical; + + int max; /* maximum value */ + int min; /* minimum value */ + int step; /* amount to change at each step */ + int current; /* current value */ +}; + +struct _GntSliderClass +{ + GntWidgetClass parent; + + void (*changed)(GntSlider *slider, int); + void (*gnt_reserved1)(void); + void (*gnt_reserved2)(void); + void (*gnt_reserved3)(void); + void (*gnt_reserved4)(void); +}; + +G_BEGIN_DECLS + +/** + * @return The GType for GntSlider + */ +GType gnt_slider_get_gtype(void); + +#define gnt_hslider_new(max, min) gnt_slider_new(FALSE, max, min) +#define gnt_vslider_new(max, min) gnt_slider_new(TRUE, max, min) + +/** + * Create a new slider. + * + * @param orient A vertical slider is created if @c TRUE, otherwise the slider is horizontal. + * @param max The maximum value for the slider + * @param min The minimum value for the slider + * + * @return The newly created slider + */ +GntWidget * gnt_slider_new(gboolean orient, int max, int min); + +/** + * Set the range of the slider. + * + * @param slider The slider + * @param max The maximum value + * @param min The minimum value + */ +void gnt_slider_set_range(GntSlider *slider, int max, int min); + +/** + * Sets the amount of change at each step. + * + * @param slider The slider + * @param step The amount for each ste + */ +void gnt_slider_set_step(GntSlider *slider, int step); + +/** + * Advance the slider forward or backward. + * + * @param slider The slider + * @param steps The number of amounts to change, positive to change + * forward, negative to change backward + * + * @return The value of the slider after the change + */ +int gnt_slider_advance_step(GntSlider *slider, int steps); + +/** + * Set the current value for the slider. + * + * @param slider The slider + * @param value The current value + */ +void gnt_slider_set_value(GntSlider *slider, int value); + +/** + * Update a label with the value of the slider whenever the value changes. + * + * @param slider The slider + * @param label The label to update + */ +void gnt_slider_reflect_label(GntSlider *slider, GntLabel *label); + +G_END_DECLS + +#endif /* GNT_SLIDER_H */
--- a/libpurple/blist.h Fri Jun 29 04:25:54 2007 +0000 +++ b/libpurple/blist.h Fri Jun 29 20:01:33 2007 +0000 @@ -21,6 +21,8 @@ * 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 + * + * @see @ref blist-signals */ #ifndef _PURPLE_BLIST_H_ #define _PURPLE_BLIST_H_
--- a/libpurple/cipher.h Fri Jun 29 04:25:54 2007 +0000 +++ b/libpurple/cipher.h Fri Jun 29 20:01:33 2007 +0000 @@ -21,6 +21,8 @@ * 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 + * + * @see @ref cipher-signals */ #ifndef PURPLE_CIPHER_H #define PURPLE_CIPHER_H
--- a/libpurple/core.h Fri Jun 29 04:25:54 2007 +0000 +++ b/libpurple/core.h Fri Jun 29 20:01:33 2007 +0000 @@ -20,6 +20,8 @@ * 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 + * + * @see @ref core-signals */ #ifndef _PURPLE_CORE_H_ #define _PURPLE_CORE_H_
--- a/libpurple/dbus-server.h Fri Jun 29 04:25:54 2007 +0000 +++ b/libpurple/dbus-server.h Fri Jun 29 20:01:33 2007 +0000 @@ -22,6 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + * @see @ref dbus-server-signals */ #ifndef _PURPLE_DBUS_SERVER_H_
--- a/libpurple/imgstore.c Fri Jun 29 04:25:54 2007 +0000 +++ b/libpurple/imgstore.c Fri Jun 29 20:01:33 2007 +0000 @@ -55,8 +55,8 @@ { PurpleStoredImage *img; - g_return_val_if_fail(data != NULL, 0); - g_return_val_if_fail(size > 0, 0); + g_return_val_if_fail(data != NULL, NULL); + g_return_val_if_fail(size > 0, NULL); img = g_new(PurpleStoredImage, 1); PURPLE_DBUS_REGISTER_POINTER(img, PurpleStoredImage); @@ -73,11 +73,13 @@ purple_imgstore_add_with_id(gpointer data, size_t size, const char *filename) { PurpleStoredImage *img = purple_imgstore_add(data, size, filename); - img->id = ++nextid; + if (img) { + img->id = ++nextid; - g_hash_table_insert(imgstore, &(img->id), img); + g_hash_table_insert(imgstore, &(img->id), img); + } - return img->id; + return (img ? img->id : 0); } PurpleStoredImage *purple_imgstore_find_by_id(int id) {
--- a/libpurple/imgstore.h Fri Jun 29 04:25:54 2007 +0000 +++ b/libpurple/imgstore.h Fri Jun 29 20:01:33 2007 +0000 @@ -22,6 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + * @see @ref imgstore-signals */ #ifndef _PURPLE_IMGSTORE_H_ #define _PURPLE_IMGSTORE_H_
--- a/libpurple/log.h Fri Jun 29 04:25:54 2007 +0000 +++ b/libpurple/log.h Fri Jun 29 20:01:33 2007 +0000 @@ -21,6 +21,8 @@ * 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 + * + * @see @ref log-signals */ #ifndef _PURPLE_LOG_H_ #define _PURPLE_LOG_H_
--- a/libpurple/notify.h Fri Jun 29 04:25:54 2007 +0000 +++ b/libpurple/notify.h Fri Jun 29 20:01:33 2007 +0000 @@ -21,6 +21,8 @@ * 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 + * + * @see @ref notify-signals */ #ifndef _PURPLE_NOTIFY_H_ #define _PURPLE_NOTIFY_H_
--- a/libpurple/plugin.h Fri Jun 29 04:25:54 2007 +0000 +++ b/libpurple/plugin.h Fri Jun 29 20:01:33 2007 +0000 @@ -21,6 +21,10 @@ * 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 + * + * @see @ref plugin-signals + * @see @ref plugin-ids + * @see @ref plugin-i18n */ #ifndef _PURPLE_PLUGIN_H_ #define _PURPLE_PLUGIN_H_
--- a/libpurple/protocols/yahoo/yahoochat.c Fri Jun 29 04:25:54 2007 +0000 +++ b/libpurple/protocols/yahoo/yahoochat.c Fri Jun 29 20:01:33 2007 +0000 @@ -785,44 +785,6 @@ g_free(eroom); } -/* borrowed from gtkconv.c */ -static gboolean -meify(char *message, size_t len) -{ - /* - * Read /me-ify: If the message (post-HTML) starts with /me, - * remove the "/me " part of it (including that space) and return TRUE. - */ - char *c; - gboolean inside_html = 0; - - /* Umm.. this would be very bad if this happens. */ - g_return_val_if_fail(message != NULL, FALSE); - - if (len == -1) - len = strlen(message); - - for (c = message; *c != '\0'; c++, len--) { - if (inside_html) { - if (*c == '>') - inside_html = FALSE; - } - else { - if (*c == '<') - inside_html = TRUE; - else - break; - } - } - - if (*c != '\0' && !g_ascii_strncasecmp(c, "/me ", 4)) { - memmove(c, c + 4, len - 3); - return TRUE; - } - - return FALSE; -} - static int yahoo_chat_send(PurpleConnection *gc, const char *dn, const char *room, const char *what, PurpleMessageFlags flags) { struct yahoo_data *yd = gc->proto_data; @@ -839,7 +801,7 @@ msg1 = g_strdup(what); - if (meify(msg1, -1)) + if (purple_message_meify(msg1, -1)) me = 1; msg2 = yahoo_html_to_codes(msg1);
--- a/libpurple/savedstatuses.h Fri Jun 29 04:25:54 2007 +0000 +++ b/libpurple/savedstatuses.h Fri Jun 29 20:01:33 2007 +0000 @@ -21,6 +21,8 @@ * 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 + * + * @see @ref savedstatus-signals */ #ifndef _PURPLE_SAVEDSTATUSES_H_ #define _PURPLE_SAVEDSTATUSES_H_
--- a/libpurple/sound.h Fri Jun 29 04:25:54 2007 +0000 +++ b/libpurple/sound.h Fri Jun 29 20:01:33 2007 +0000 @@ -21,6 +21,8 @@ * 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 + * + * @see @ref sound-signals */ #ifndef _PURPLE_SOUND_H_ #define _PURPLE_SOUND_H_
--- a/libpurple/util.h Fri Jun 29 04:25:54 2007 +0000 +++ b/libpurple/util.h Fri Jun 29 20:01:33 2007 +0000 @@ -1105,12 +1105,13 @@ void purple_print_utf8_to_console(FILE *filestream, char *message); /** - * Checks for messages starting with "/me " + * Checks for messages starting (post-HTML) with "/me ", including the space. * * @param message The message to check * @param len The message length, or -1 * - * @return TRUE if it starts with /me, and it has been removed, otherwise FALSE + * @return TRUE if it starts with "/me ", and it has been removed, otherwise + * FALSE */ gboolean purple_message_meify(char *message, size_t len);