Mercurial > pidgin
view finch/libgnt/gntlabel.c @ 17148:9a649a04fd74
When the /pidgin/debug/enabled pref is toggled, wait until the next
iteration through the event loop before drawing or hiding the window.
This fixes the bug where we lost the width and height prefs for the
debug window because of the following sequence of event
1. Init gtkdebug window, set default width and height
2. Read in pref for /pidgin/debug/enabled and show debug window using
default width and height
3. Read in pref for /pidgin/debug/width and height, but it's too
late! The window has already been drawn using the default
width and height!
This is a pretty minor thing, but it was bugging me. I don't like
having to always make the debug window bigger when I start Pidgin.
The downside of this change is that we won't see as much debug output
in the window when starting Pidgin.
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 22 May 2007 07:08:57 +0000 |
parents | 0e3a8505ebbe |
children | 8410511f4dbb |
line wrap: on
line source
#include "gntlabel.h" #include "gntutils.h" #include <string.h> enum { SIGS = 1, }; static GntWidgetClass *parent_class = NULL; static void gnt_label_destroy(GntWidget *widget) { GntLabel *label = GNT_LABEL(widget); g_free(label->text); } static void gnt_label_draw(GntWidget *widget) { GntLabel *label = GNT_LABEL(widget); chtype flag = gnt_text_format_flag_to_chtype(label->flags); wbkgdset(widget->window, '\0' | flag); mvwaddstr(widget->window, 0, 0, label->text); GNTDEBUG; } static void gnt_label_size_request(GntWidget *widget) { GntLabel *label = GNT_LABEL(widget); gnt_util_get_text_bound(label->text, &widget->priv.width, &widget->priv.height); } static void gnt_label_class_init(GntLabelClass *klass) { parent_class = GNT_WIDGET_CLASS(klass); parent_class->destroy = gnt_label_destroy; parent_class->draw = gnt_label_draw; parent_class->map = NULL; parent_class->size_request = gnt_label_size_request; GNTDEBUG; } static void gnt_label_init(GTypeInstance *instance, gpointer class) { GntWidget *widget = GNT_WIDGET(instance); GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_GROW_X); widget->priv.minw = 3; widget->priv.minh = 1; GNTDEBUG; } /****************************************************************************** * GntLabel API *****************************************************************************/ GType gnt_label_get_gtype(void) { static GType type = 0; if(type == 0) { static const GTypeInfo info = { sizeof(GntLabelClass), NULL, /* base_init */ NULL, /* base_finalize */ (GClassInitFunc)gnt_label_class_init, NULL, /* class_finalize */ NULL, /* class_data */ sizeof(GntLabel), 0, /* n_preallocs */ gnt_label_init, /* instance_init */ NULL /* value_table */ }; type = g_type_register_static(GNT_TYPE_WIDGET, "GntLabel", &info, 0); } return type; } GntWidget *gnt_label_new(const char *text) { return gnt_label_new_with_format(text, 0); } GntWidget *gnt_label_new_with_format(const char *text, GntTextFormatFlags flags) { GntWidget *widget = g_object_new(GNT_TYPE_LABEL, NULL); GntLabel *label = GNT_LABEL(widget); label->text = gnt_util_onscreen_fit_string(text, -1); label->flags = flags; gnt_widget_set_take_focus(widget, FALSE); GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW); return widget; } void gnt_label_set_text(GntLabel *label, const char *text) { g_free(label->text); label->text = gnt_util_onscreen_fit_string(text, -1); if (GNT_WIDGET(label)->window) { gnt_widget_hide(GNT_WIDGET(label)); gnt_label_size_request(GNT_WIDGET(label)); gnt_widget_draw(GNT_WIDGET(label)); } }