annotate console/libgnt/gntwidget.c @ 14802:4138063d89c9

[gaim-migrate @ 17567] res_init build fix? committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Mon, 23 Oct 2006 19:05:14 +0000
parents 8a0cfee11af8
children 945936eaa74e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1 /* Stuff brutally ripped from Gflib */
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
2
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
3 #include "gntwidget.h"
14010
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13980
diff changeset
4 #include "gntstyle.h"
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13930
diff changeset
5 #include "gntmarshal.h"
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
6 #include "gnt.h"
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
7
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
8 enum
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
9 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
10 SIG_DESTROY,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
11 SIG_DRAW,
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14432
diff changeset
12 SIG_HIDE,
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
13 SIG_GIVE_FOCUS,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
14 SIG_LOST_FOCUS,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
15 SIG_KEY_PRESSED,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
16 SIG_MAP,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
17 SIG_ACTIVATE,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
18 SIG_EXPOSE,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
19 SIG_SIZE_REQUEST,
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
20 SIG_CONFIRM_SIZE,
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
21 SIG_SIZE_CHANGED,
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
22 SIG_POSITION,
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
23 SIG_CLICKED,
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
24 SIGS
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
25 };
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
26
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
27 static GObjectClass *parent_class = NULL;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
28 static guint signals[SIGS] = { 0 };
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
29
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
30 static void init_widget(GntWidget *widget);
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
31
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
32 static void
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
33 gnt_widget_init(GTypeInstance *instance, gpointer class)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
34 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
35 GntWidget *widget = GNT_WIDGET(instance);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
36 widget->priv.name = NULL;
14432
3ac156db9cb6 [gaim-migrate @ 17146]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
37 GNTDEBUG;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
38 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
39
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
40 static void
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
41 gnt_widget_map(GntWidget *widget)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
42 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
43 /* Get some default size for the widget */
14432
3ac156db9cb6 [gaim-migrate @ 17146]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
44 GNTDEBUG;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
45 g_signal_emit(widget, signals[SIG_MAP], 0);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
46 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_MAPPED);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
47 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
48
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
49 static void
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
50 gnt_widget_dispose(GObject *obj)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
51 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
52 GntWidget *self = GNT_WIDGET(obj);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
53
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
54 if(!(GNT_WIDGET_FLAGS(self) & GNT_WIDGET_DESTROYING)) {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
55 GNT_WIDGET_SET_FLAGS(self, GNT_WIDGET_DESTROYING);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
56
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
57 g_signal_emit(self, signals[SIG_DESTROY], 0);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
58
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
59 GNT_WIDGET_UNSET_FLAGS(self, GNT_WIDGET_DESTROYING);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
60 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
61
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
62 parent_class->dispose(obj);
14432
3ac156db9cb6 [gaim-migrate @ 17146]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
63 GNTDEBUG;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
64 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
65
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
66 static void
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
67 gnt_widget_focus_change(GntWidget *widget)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
68 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
69 if (GNT_WIDGET_FLAGS(widget) & GNT_WIDGET_MAPPED)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
70 gnt_widget_draw(widget);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
71 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
72
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
73 static gboolean
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
74 gnt_widget_dummy_confirm_size(GntWidget *widget, int width, int height)
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
75 {
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
76 if (width < widget->priv.minw || height < widget->priv.minh)
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
77 return FALSE;
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
78 if (widget->priv.width != width && !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_GROW_X))
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
79 return FALSE;
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
80 if (widget->priv.height != height && !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_GROW_Y))
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
81 return FALSE;
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
82 return TRUE;
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
83 }
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
84
14091
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14011
diff changeset
85 static gboolean
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14011
diff changeset
86 gnt_boolean_handled_accumulator(GSignalInvocationHint *ihint,
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14011
diff changeset
87 GValue *return_accu,
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14011
diff changeset
88 const GValue *handler_return,
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14011
diff changeset
89 gpointer dummy)
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14011
diff changeset
90 {
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14011
diff changeset
91 gboolean continue_emission;
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14011
diff changeset
92 gboolean signal_handled;
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14011
diff changeset
93
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14011
diff changeset
94 signal_handled = g_value_get_boolean (handler_return);
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14011
diff changeset
95 g_value_set_boolean (return_accu, signal_handled);
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14011
diff changeset
96 continue_emission = !signal_handled;
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14011
diff changeset
97
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14011
diff changeset
98 return continue_emission;
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14011
diff changeset
99 }
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14011
diff changeset
100
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
101 static void
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
102 gnt_widget_class_init(GntWidgetClass *klass)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
103 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
104 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
105
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
106 parent_class = g_type_class_peek_parent(klass);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
107
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
108 obj_class->dispose = gnt_widget_dispose;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
109
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
110 klass->destroy = gnt_widget_destroy;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
111 klass->show = gnt_widget_show;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
112 klass->draw = gnt_widget_draw;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
113 klass->expose = gnt_widget_expose;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
114 klass->map = gnt_widget_map;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
115 klass->lost_focus = gnt_widget_focus_change;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
116 klass->gained_focus = gnt_widget_focus_change;
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
117 klass->confirm_size = gnt_widget_dummy_confirm_size;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
118
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
119 klass->key_pressed = NULL;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
120 klass->activate = NULL;
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
121 klass->clicked = NULL;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
122
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
123 signals[SIG_DESTROY] =
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
124 g_signal_new("destroy",
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
125 G_TYPE_FROM_CLASS(klass),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
126 G_SIGNAL_RUN_LAST,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
127 G_STRUCT_OFFSET(GntWidgetClass, destroy),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
128 NULL, NULL,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
129 g_cclosure_marshal_VOID__VOID,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
130 G_TYPE_NONE, 0);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
131 signals[SIG_GIVE_FOCUS] =
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
132 g_signal_new("gained-focus",
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
133 G_TYPE_FROM_CLASS(klass),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
134 G_SIGNAL_RUN_LAST,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
135 G_STRUCT_OFFSET(GntWidgetClass, gained_focus),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
136 NULL, NULL,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
137 g_cclosure_marshal_VOID__VOID,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
138 G_TYPE_NONE, 0);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
139 signals[SIG_LOST_FOCUS] =
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
140 g_signal_new("lost-focus",
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
141 G_TYPE_FROM_CLASS(klass),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
142 G_SIGNAL_RUN_LAST,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
143 G_STRUCT_OFFSET(GntWidgetClass, lost_focus),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
144 NULL, NULL,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
145 g_cclosure_marshal_VOID__VOID,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
146 G_TYPE_NONE, 0);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
147 signals[SIG_ACTIVATE] =
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
148 g_signal_new("activate",
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
149 G_TYPE_FROM_CLASS(klass),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
150 G_SIGNAL_RUN_LAST,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
151 G_STRUCT_OFFSET(GntWidgetClass, activate),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
152 NULL, NULL,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
153 g_cclosure_marshal_VOID__VOID,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
154 G_TYPE_NONE, 0);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
155 signals[SIG_MAP] =
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
156 g_signal_new("map",
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
157 G_TYPE_FROM_CLASS(klass),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
158 G_SIGNAL_RUN_LAST,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
159 G_STRUCT_OFFSET(GntWidgetClass, map),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
160 NULL, NULL,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
161 g_cclosure_marshal_VOID__VOID,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
162 G_TYPE_NONE, 0);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
163 signals[SIG_DRAW] =
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
164 g_signal_new("draw",
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
165 G_TYPE_FROM_CLASS(klass),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
166 G_SIGNAL_RUN_LAST,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
167 G_STRUCT_OFFSET(GntWidgetClass, draw),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
168 NULL, NULL,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
169 g_cclosure_marshal_VOID__VOID,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
170 G_TYPE_NONE, 0);
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14432
diff changeset
171 signals[SIG_HIDE] =
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14432
diff changeset
172 g_signal_new("hide",
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14432
diff changeset
173 G_TYPE_FROM_CLASS(klass),
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14432
diff changeset
174 G_SIGNAL_RUN_LAST,
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14432
diff changeset
175 G_STRUCT_OFFSET(GntWidgetClass, hide),
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14432
diff changeset
176 NULL, NULL,
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14432
diff changeset
177 g_cclosure_marshal_VOID__VOID,
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14432
diff changeset
178 G_TYPE_NONE, 0);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
179 signals[SIG_EXPOSE] =
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
180 g_signal_new("expose",
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
181 G_TYPE_FROM_CLASS(klass),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
182 G_SIGNAL_RUN_LAST,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
183 G_STRUCT_OFFSET(GntWidgetClass, expose),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
184 NULL, NULL,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
185 gnt_closure_marshal_VOID__INT_INT_INT_INT,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
186 G_TYPE_NONE, 4, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
187 signals[SIG_POSITION] =
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
188 g_signal_new("position-set",
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
189 G_TYPE_FROM_CLASS(klass),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
190 G_SIGNAL_RUN_LAST,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
191 G_STRUCT_OFFSET(GntWidgetClass, set_position),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
192 NULL, NULL,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
193 gnt_closure_marshal_VOID__INT_INT,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
194 G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
195 signals[SIG_SIZE_REQUEST] =
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
196 g_signal_new("size_request",
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
197 G_TYPE_FROM_CLASS(klass),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
198 G_SIGNAL_RUN_LAST,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
199 G_STRUCT_OFFSET(GntWidgetClass, size_request),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
200 NULL, NULL,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
201 g_cclosure_marshal_VOID__VOID,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
202 G_TYPE_NONE, 0);
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
203 signals[SIG_SIZE_CHANGED] =
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
204 g_signal_new("size_changed",
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
205 G_TYPE_FROM_CLASS(klass),
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
206 G_SIGNAL_RUN_LAST,
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
207 G_STRUCT_OFFSET(GntWidgetClass, size_changed),
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
208 NULL, NULL,
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
209 gnt_closure_marshal_VOID__INT_INT,
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
210 G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
211 signals[SIG_CONFIRM_SIZE] =
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
212 g_signal_new("confirm_size",
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
213 G_TYPE_FROM_CLASS(klass),
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
214 G_SIGNAL_RUN_LAST,
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
215 G_STRUCT_OFFSET(GntWidgetClass, confirm_size),
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
216 NULL, NULL,
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
217 gnt_closure_marshal_BOOLEAN__INT_INT,
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
218 G_TYPE_BOOLEAN, 2, G_TYPE_INT, G_TYPE_INT);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
219 signals[SIG_KEY_PRESSED] =
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
220 g_signal_new("key_pressed",
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
221 G_TYPE_FROM_CLASS(klass),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
222 G_SIGNAL_RUN_LAST,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
223 G_STRUCT_OFFSET(GntWidgetClass, key_pressed),
14091
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14011
diff changeset
224 gnt_boolean_handled_accumulator, NULL,
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
225 gnt_closure_marshal_BOOLEAN__STRING,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
226 G_TYPE_BOOLEAN, 1, G_TYPE_STRING);
14239
a0b1ab181316 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
227
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
228 signals[SIG_CLICKED] =
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
229 g_signal_new("clicked",
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
230 G_TYPE_FROM_CLASS(klass),
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
231 G_SIGNAL_RUN_LAST,
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
232 G_STRUCT_OFFSET(GntWidgetClass, clicked),
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
233 gnt_boolean_handled_accumulator, NULL,
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
234 gnt_closure_marshal_BOOLEAN__INT_INT_INT,
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
235 G_TYPE_BOOLEAN, 3, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT);
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
236
14793
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
237 klass->actions = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
238 (GDestroyNotify)gnt_widget_action_free);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
239 klass->bindings = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
240 (GDestroyNotify)gnt_widget_action_param_free);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
241
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
242 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), klass);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
243
14432
3ac156db9cb6 [gaim-migrate @ 17146]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
244 GNTDEBUG;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
245 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
246
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
247 /******************************************************************************
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
248 * GntWidget API
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
249 *****************************************************************************/
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
250 GType
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
251 gnt_widget_get_gtype(void)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
252 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
253 static GType type = 0;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
254
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
255 if(type == 0) {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
256 static const GTypeInfo info = {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
257 sizeof(GntWidgetClass),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
258 NULL, /* base_init */
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
259 NULL, /* base_finalize */
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
260 (GClassInitFunc)gnt_widget_class_init,
14239
a0b1ab181316 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
261 NULL,
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
262 NULL, /* class_data */
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
263 sizeof(GntWidget),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
264 0, /* n_preallocs */
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
265 gnt_widget_init, /* instance_init */
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
266 };
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
267
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
268 type = g_type_register_static(G_TYPE_OBJECT,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
269 "GntWidget",
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
270 &info, G_TYPE_FLAG_ABSTRACT);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
271 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
272
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
273 return type;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
274 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
275
14239
a0b1ab181316 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
276 static const char *
a0b1ab181316 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
277 gnt_widget_remap_keys(GntWidget *widget, const char *text)
a0b1ab181316 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
278 {
a0b1ab181316 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
279 const char *remap = NULL;
a0b1ab181316 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
280 GType type = G_OBJECT_TYPE(widget);
a0b1ab181316 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
281 GntWidgetClass *klass = GNT_WIDGET_CLASS(G_OBJECT_GET_CLASS(widget));
a0b1ab181316 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
282
a0b1ab181316 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
283 if (klass->remaps == NULL)
a0b1ab181316 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
284 {
a0b1ab181316 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
285 klass->remaps = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
a0b1ab181316 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
286 gnt_styles_get_keyremaps(type, klass->remaps);
a0b1ab181316 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
287 }
a0b1ab181316 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
288
a0b1ab181316 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
289 remap = g_hash_table_lookup(klass->remaps, text);
a0b1ab181316 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
290
a0b1ab181316 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
291 return (remap ? remap : text);
a0b1ab181316 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
292 }
a0b1ab181316 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
293
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
294 static void
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
295 gnt_widget_take_focus(GntWidget *widget)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
296 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
297 gnt_screen_take_focus(widget);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
298 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
299
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
300 void gnt_widget_set_take_focus(GntWidget *widget, gboolean can)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
301 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
302 if (can)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
303 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_CAN_TAKE_FOCUS);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
304 else
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
305 GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_CAN_TAKE_FOCUS);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
306 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
307
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
308 /**
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
309 * gnt_widget_destroy:
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
310 * @obj: The #GntWidget instance.
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
311 *
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
312 * Emits the "destroy" signal notifying all reference holders that they
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
313 * should release @obj.
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
314 */
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
315 void
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
316 gnt_widget_destroy(GntWidget *obj)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
317 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
318 g_return_if_fail(GNT_IS_WIDGET(obj));
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
319
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
320 gnt_widget_hide(obj);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
321 delwin(obj->window);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
322 if(!(GNT_WIDGET_FLAGS(obj) & GNT_WIDGET_DESTROYING))
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
323 g_object_run_dispose(G_OBJECT(obj));
14432
3ac156db9cb6 [gaim-migrate @ 17146]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
324 GNTDEBUG;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
325 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
326
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
327 void
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
328 gnt_widget_show(GntWidget *widget)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
329 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
330 /* Draw the widget and take focus */
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
331 if (GNT_WIDGET_FLAGS(widget) & GNT_WIDGET_CAN_TAKE_FOCUS)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
332 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
333 gnt_widget_take_focus(widget);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
334 }
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
335 gnt_widget_draw(widget);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
336 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
337
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
338 void
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
339 gnt_widget_draw(GntWidget *widget)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
340 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
341 /* Draw the widget */
13878
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
342 if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_DRAWING))
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
343 return;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
344
13878
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
345 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_DRAWING);
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
346 if (!(GNT_WIDGET_FLAGS(widget) & GNT_WIDGET_MAPPED))
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
347 {
13878
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
348 gnt_widget_map(widget);
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
349 gnt_screen_occupy(widget);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
350 }
13878
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
351
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
352 if (widget->window == NULL)
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
353 {
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13916
diff changeset
354 gboolean shadow = TRUE;
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13916
diff changeset
355
14010
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13980
diff changeset
356 if (!gnt_widget_has_shadow(widget))
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13916
diff changeset
357 shadow = FALSE;
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
358
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13916
diff changeset
359 widget->window = newwin(widget->priv.height + shadow, widget->priv.width + shadow,
13878
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
360 widget->priv.y, widget->priv.x);
14292
c111a7e718d0 [gaim-migrate @ 16982]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14239
diff changeset
361 if (widget->window == NULL) /* The size is probably too large for the screen */
c111a7e718d0 [gaim-migrate @ 16982]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14239
diff changeset
362 {
c111a7e718d0 [gaim-migrate @ 16982]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14239
diff changeset
363 int x = widget->priv.x, y = widget->priv.y;
c111a7e718d0 [gaim-migrate @ 16982]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14239
diff changeset
364 int w = widget->priv.width + shadow, h = widget->priv.height + shadow;
c111a7e718d0 [gaim-migrate @ 16982]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14239
diff changeset
365 int maxx, maxy; /* Max-X is cool */
c111a7e718d0 [gaim-migrate @ 16982]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14239
diff changeset
366
c111a7e718d0 [gaim-migrate @ 16982]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14239
diff changeset
367 getmaxyx(stdscr, maxy, maxx);
c111a7e718d0 [gaim-migrate @ 16982]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14239
diff changeset
368
c111a7e718d0 [gaim-migrate @ 16982]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14239
diff changeset
369 if (x + w >= maxx)
c111a7e718d0 [gaim-migrate @ 16982]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14239
diff changeset
370 x = MAX(0, maxx - w);
c111a7e718d0 [gaim-migrate @ 16982]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14239
diff changeset
371 if (y + h >= maxy)
c111a7e718d0 [gaim-migrate @ 16982]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14239
diff changeset
372 y = MAX(0, maxy - h);
c111a7e718d0 [gaim-migrate @ 16982]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14239
diff changeset
373
c111a7e718d0 [gaim-migrate @ 16982]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14239
diff changeset
374 w = MIN(w, maxx);
c111a7e718d0 [gaim-migrate @ 16982]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14239
diff changeset
375 h = MIN(h, maxy);
c111a7e718d0 [gaim-migrate @ 16982]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14239
diff changeset
376
c111a7e718d0 [gaim-migrate @ 16982]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14239
diff changeset
377 widget->priv.x = x;
c111a7e718d0 [gaim-migrate @ 16982]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14239
diff changeset
378 widget->priv.y = y;
c111a7e718d0 [gaim-migrate @ 16982]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14239
diff changeset
379 widget->priv.width = w - shadow;
c111a7e718d0 [gaim-migrate @ 16982]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14239
diff changeset
380 widget->priv.height = h - shadow;
c111a7e718d0 [gaim-migrate @ 16982]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14239
diff changeset
381
c111a7e718d0 [gaim-migrate @ 16982]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14239
diff changeset
382 widget->window = newwin(widget->priv.height + shadow, widget->priv.width + shadow,
c111a7e718d0 [gaim-migrate @ 16982]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14239
diff changeset
383 widget->priv.y, widget->priv.x);
c111a7e718d0 [gaim-migrate @ 16982]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14239
diff changeset
384 }
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
385 init_widget(widget);
13878
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
386 }
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
387
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
388 g_signal_emit(widget, signals[SIG_DRAW], 0);
13878
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
389 gnt_widget_queue_update(widget);
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
390 GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_DRAWING);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
391 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
392
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
393 gboolean
14793
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
394 gnt_widget_perform_action_named(GntWidget *widget, const char *name, ...)
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
395 {
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
396 GType type = G_OBJECT_TYPE(widget);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
397 GntWidgetClass *klass = GNT_WIDGET_CLASS(G_OBJECT_GET_CLASS(widget));
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
398 GList *list = NULL;
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
399 va_list args;
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
400 GntWidgetAction *action;
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
401 void *p;
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
402
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
403 va_start(args, name);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
404 while ((p = va_arg(args, void *)) != NULL)
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
405 list = g_list_append(list, p);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
406 va_end(args);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
407
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
408 action = g_hash_table_lookup(klass->actions, name);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
409 if (action && action->u.action) {
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
410 if (list)
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
411 return action->u.action(widget, list);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
412 else
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
413 return action->u.action_noparam(widget);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
414 }
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
415 return FALSE;
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
416 }
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
417
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
418 static gboolean
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
419 gnt_widget_perform_action(GntWidget *widget, const char *keys)
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
420 {
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
421 GType type = G_OBJECT_TYPE(widget);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
422 GntWidgetClass *klass = GNT_WIDGET_CLASS(G_OBJECT_GET_CLASS(widget));
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
423 GntWidgetActionParam *param = g_hash_table_lookup(klass->bindings, keys);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
424
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
425 if (param && param->action) {
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
426 if (param->list)
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
427 return param->action->u.action(widget, param->list);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
428 else
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
429 return param->action->u.action_noparam(widget);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
430 }
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
431 return FALSE;
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
432 }
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
433
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
434 gboolean
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
435 gnt_widget_key_pressed(GntWidget *widget, const char *keys)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
436 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
437 gboolean ret;
13855
5b288502a382 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
438 if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_CAN_TAKE_FOCUS))
5b288502a382 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
439 return FALSE;
14239
a0b1ab181316 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
440
14793
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
441 if (gnt_widget_perform_action(widget, keys))
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
442 return TRUE;
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
443
14239
a0b1ab181316 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
444 keys = gnt_widget_remap_keys(widget, keys);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
445 g_signal_emit(widget, signals[SIG_KEY_PRESSED], 0, keys, &ret);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
446 return ret;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
447 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
448
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
449 gboolean
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
450 gnt_widget_clicked(GntWidget *widget, GntMouseEvent event, int x, int y)
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
451 {
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
452 gboolean ret;
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
453 g_signal_emit(widget, signals[SIG_CLICKED], 0, event, x, y, &ret);
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
454 return ret;
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
455 }
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
456
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
457 void
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
458 gnt_widget_expose(GntWidget *widget, int x, int y, int width, int height)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
459 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
460 g_signal_emit(widget, signals[SIG_EXPOSE], 0, x, y, width, height);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
461 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
462
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
463 void
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
464 gnt_widget_hide(GntWidget *widget)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
465 {
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14432
diff changeset
466 g_signal_emit(widget, signals[SIG_HIDE], 0);
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
467 wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL));
14298
6e2e9e84b99d [gaim-migrate @ 16988]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14292
diff changeset
468 #if 0
6e2e9e84b99d [gaim-migrate @ 16988]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14292
diff changeset
469 /* XXX: I have no clue why, but this seemed to be necessary. */
14010
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13980
diff changeset
470 if (gnt_widget_has_shadow(widget))
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13916
diff changeset
471 mvwvline(widget->window, 1, widget->priv.width, ' ', widget->priv.height);
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13916
diff changeset
472 #endif
13878
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
473 gnt_screen_release(widget);
13980
c9509bd42d7a [gaim-migrate @ 16542]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
474 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_INVISIBLE);
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
475 GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_MAPPED);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
476 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
477
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
478 void
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
479 gnt_widget_set_position(GntWidget *wid, int x, int y)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
480 {
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
481 g_signal_emit(wid, signals[SIG_POSITION], 0, x, y);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
482 /* XXX: Need to install properties for these and g_object_notify */
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
483 wid->priv.x = x;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
484 wid->priv.y = y;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
485 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
486
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
487 void
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
488 gnt_widget_get_position(GntWidget *wid, int *x, int *y)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
489 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
490 if (x)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
491 *x = wid->priv.x;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
492 if (y)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
493 *y = wid->priv.y;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
494 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
495
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
496 void
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
497 gnt_widget_size_request(GntWidget *widget)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
498 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
499 g_signal_emit(widget, signals[SIG_SIZE_REQUEST], 0);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
500 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
501
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
502 void
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
503 gnt_widget_get_size(GntWidget *wid, int *width, int *height)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
504 {
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13916
diff changeset
505 gboolean shadow = TRUE;
14010
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13980
diff changeset
506 if (!gnt_widget_has_shadow(wid))
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13916
diff changeset
507 shadow = FALSE;
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13916
diff changeset
508
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
509 if (width)
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13916
diff changeset
510 *width = wid->priv.width + shadow;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
511 if (height)
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13916
diff changeset
512 *height = wid->priv.height + shadow;
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13916
diff changeset
513
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
514 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
515
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
516 static void
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
517 init_widget(GntWidget *widget)
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
518 {
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
519 gboolean shadow = TRUE;
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
520
14010
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13980
diff changeset
521 if (!gnt_widget_has_shadow(widget))
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
522 shadow = FALSE;
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
523
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
524 wbkgd(widget->window, COLOR_PAIR(GNT_COLOR_NORMAL));
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
525 werase(widget->window);
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
526
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
527 if (!(GNT_WIDGET_FLAGS(widget) & GNT_WIDGET_NO_BORDER))
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
528 {
14010
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13980
diff changeset
529 /* - This is ugly. */
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13980
diff changeset
530 /* - What's your point? */
14011
735c4e927eb8 [gaim-migrate @ 16603]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
531 mvwvline(widget->window, 0, 0, ACS_VLINE | COLOR_PAIR(GNT_COLOR_NORMAL), widget->priv.height);
735c4e927eb8 [gaim-migrate @ 16603]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
532 mvwvline(widget->window, 0, widget->priv.width - 1,
735c4e927eb8 [gaim-migrate @ 16603]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
533 ACS_VLINE | COLOR_PAIR(GNT_COLOR_NORMAL), widget->priv.height);
735c4e927eb8 [gaim-migrate @ 16603]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
534 mvwhline(widget->window, widget->priv.height - 1, 0,
735c4e927eb8 [gaim-migrate @ 16603]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
535 ACS_HLINE | COLOR_PAIR(GNT_COLOR_NORMAL), widget->priv.width);
735c4e927eb8 [gaim-migrate @ 16603]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
536 mvwhline(widget->window, 0, 0, ACS_HLINE | COLOR_PAIR(GNT_COLOR_NORMAL), widget->priv.width);
735c4e927eb8 [gaim-migrate @ 16603]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
537 mvwaddch(widget->window, 0, 0, ACS_ULCORNER | COLOR_PAIR(GNT_COLOR_NORMAL));
735c4e927eb8 [gaim-migrate @ 16603]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
538 mvwaddch(widget->window, 0, widget->priv.width - 1,
735c4e927eb8 [gaim-migrate @ 16603]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
539 ACS_URCORNER | COLOR_PAIR(GNT_COLOR_NORMAL));
735c4e927eb8 [gaim-migrate @ 16603]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
540 mvwaddch(widget->window, widget->priv.height - 1, 0,
735c4e927eb8 [gaim-migrate @ 16603]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
541 ACS_LLCORNER | COLOR_PAIR(GNT_COLOR_NORMAL));
735c4e927eb8 [gaim-migrate @ 16603]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
542 mvwaddch(widget->window, widget->priv.height - 1, widget->priv.width - 1,
735c4e927eb8 [gaim-migrate @ 16603]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
543 ACS_LRCORNER | COLOR_PAIR(GNT_COLOR_NORMAL));
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
544 }
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
545
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
546 if (shadow)
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
547 {
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
548 wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_SHADOW));
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
549 mvwvline(widget->window, 1, widget->priv.width, ' ', widget->priv.height);
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
550 mvwhline(widget->window, widget->priv.height, 1, ' ', widget->priv.width);
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
551 }
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
552 }
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
553
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
554 gboolean
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
555 gnt_widget_set_size(GntWidget *widget, int width, int height)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
556 {
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
557 gboolean ret = TRUE;
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
558
14010
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13980
diff changeset
559 if (gnt_widget_has_shadow(widget))
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
560 {
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
561 width--;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
562 height--;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
563 }
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
564
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
565 if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_MAPPED))
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
566 {
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
567 ret = gnt_widget_confirm_size(widget, width, height);
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
568 }
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
569
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
570 if (ret)
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
571 {
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
572 gboolean shadow = TRUE;
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
573 int oldw, oldh;
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
574
14010
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13980
diff changeset
575 if (!gnt_widget_has_shadow(widget))
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
576 shadow = FALSE;
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
577
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
578 oldw = widget->priv.width;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
579 oldh = widget->priv.height;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
580
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
581 widget->priv.width = width;
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
582 widget->priv.height = height;
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
583
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
584 g_signal_emit(widget, signals[SIG_SIZE_CHANGED], 0, oldw, oldh);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
585
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
586 if (widget->window)
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
587 {
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
588 wresize(widget->window, height + shadow, width + shadow);
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
589 init_widget(widget);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
590 }
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
591 if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_MAPPED))
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
592 init_widget(widget);
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
593 else
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
594 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_MAPPED);
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
595 }
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
596
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
597 return ret;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
598 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
599
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
600 gboolean
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
601 gnt_widget_set_focus(GntWidget *widget, gboolean set)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
602 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
603 if (!(GNT_WIDGET_FLAGS(widget) & GNT_WIDGET_CAN_TAKE_FOCUS))
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
604 return FALSE;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
605
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
606 if (set && !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_HAS_FOCUS))
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
607 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
608 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_HAS_FOCUS);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
609 g_signal_emit(widget, signals[SIG_GIVE_FOCUS], 0);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
610 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
611 else if (!set)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
612 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
613 GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_HAS_FOCUS);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
614 g_signal_emit(widget, signals[SIG_LOST_FOCUS], 0);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
615 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
616 else
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
617 return FALSE;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
618
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
619 return TRUE;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
620 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
621
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
622 void gnt_widget_set_name(GntWidget *widget, const char *name)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
623 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
624 g_free(widget->priv.name);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
625 widget->priv.name = g_strdup(name);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
626 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
627
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14298
diff changeset
628 const char *gnt_widget_get_name(GntWidget *widget)
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14298
diff changeset
629 {
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14298
diff changeset
630 return widget->priv.name;
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14298
diff changeset
631 }
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14298
diff changeset
632
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
633 void gnt_widget_activate(GntWidget *widget)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
634 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
635 g_signal_emit(widget, signals[SIG_ACTIVATE], 0);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
636 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
637
13878
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
638 static gboolean
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
639 update_queue_callback(gpointer data)
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
640 {
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
641 GntWidget *widget = GNT_WIDGET(data);
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
642
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
643 if (!g_object_get_data(G_OBJECT(widget), "gnt:queue_update"))
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
644 return FALSE;
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
645 gnt_screen_update(widget);
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
646 g_object_set_data(G_OBJECT(widget), "gnt:queue_update", NULL);
13878
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
647 return FALSE;
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
648 }
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
649
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
650 void gnt_widget_queue_update(GntWidget *widget)
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
651 {
13979
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
652 if (widget->window == NULL)
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
653 return;
13878
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
654 while (widget->parent)
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
655 widget = widget->parent;
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
656
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
657 if (!g_object_get_data(G_OBJECT(widget), "gnt:queue_update"))
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
658 {
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
659 int id = g_timeout_add(0, update_queue_callback, widget);
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
660 g_object_set_data_full(G_OBJECT(widget), "gnt:queue_update", GINT_TO_POINTER(id),
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
661 (GDestroyNotify)g_source_remove);
13878
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
662 }
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
663 }
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
664
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
665 gboolean gnt_widget_confirm_size(GntWidget *widget, int width, int height)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
666 {
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
667 gboolean ret = FALSE;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
668 g_signal_emit(widget, signals[SIG_CONFIRM_SIZE], 0, width, height, &ret);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
669 return ret;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
670 }
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
671
13980
c9509bd42d7a [gaim-migrate @ 16542]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
672 void gnt_widget_set_visible(GntWidget *widget, gboolean set)
c9509bd42d7a [gaim-migrate @ 16542]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
673 {
c9509bd42d7a [gaim-migrate @ 16542]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
674 if (set)
c9509bd42d7a [gaim-migrate @ 16542]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
675 GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_INVISIBLE);
c9509bd42d7a [gaim-migrate @ 16542]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
676 else
c9509bd42d7a [gaim-migrate @ 16542]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
677 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_INVISIBLE);
c9509bd42d7a [gaim-migrate @ 16542]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
678 }
c9509bd42d7a [gaim-migrate @ 16542]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
679
14010
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13980
diff changeset
680 gboolean gnt_widget_has_shadow(GntWidget *widget)
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13980
diff changeset
681 {
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13980
diff changeset
682 return (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_SHADOW) &&
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13980
diff changeset
683 gnt_style_get_bool(GNT_STYLE_SHADOW, FALSE));
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13980
diff changeset
684 }
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13980
diff changeset
685
14793
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
686 static void
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
687 register_binding(GntWidgetClass *klass, const char *name, const char *trigger, GList *list)
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
688 {
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
689 GntWidgetActionParam *param;
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
690
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
691 if (name == NULL || *name == '\0') {
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
692 g_hash_table_remove(klass->bindings, (char*)trigger);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
693 return;
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
694 }
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
695
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
696 param = g_new0(GntWidgetActionParam, 1);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
697 param->action = g_hash_table_lookup(klass->actions, name);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
698 param->list = list;
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
699 g_hash_table_replace(klass->bindings, g_strdup(trigger), param);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
700 }
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
701
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
702 void gnt_widget_register_binding(GntWidgetClass *klass, const char *name,
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
703 const char *trigger, ...)
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
704 {
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
705 GList *list = NULL;
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
706 va_list args;
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
707 void *data;
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
708
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
709 va_start(args, trigger);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
710 while ((data = va_arg(args, void *))) {
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
711 list = g_list_append(list, data);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
712 }
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
713 va_end(args);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
714
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
715 register_binding(klass, name, trigger, list);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
716 }
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
717
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
718 void gnt_widget_class_register_action(GntWidgetClass *klass, const char *name,
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
719 GntWidgetActionCallback callback,
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
720 const char *trigger, ...)
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
721 {
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
722 void *data;
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
723 va_list args;
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
724 GntWidgetAction *action = g_new0(GntWidgetAction, 1);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
725 GList *list;
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
726
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
727 action->name = g_strdup(name);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
728 action->u.action = callback;
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
729
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
730 g_hash_table_replace(klass->actions, g_strdup(name), action);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
731
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
732 list = NULL;
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
733 va_start(args, trigger);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
734 while ((data = va_arg(args, void *))) {
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
735 list = g_list_append(list, data);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
736 }
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
737 va_end(args);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
738
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
739 register_binding(klass, name, trigger, list);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
740 }
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
741
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
742 void gnt_widget_action_free(GntWidgetAction *action)
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
743 {
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
744 g_free(action->name);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
745 g_free(action);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
746 }
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
747
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
748 void gnt_widget_action_param_free(GntWidgetActionParam *param)
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
749 {
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
750 g_list_free(param->list); /* XXX: There may be a leak here for string parameters */
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
751 g_free(param);
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
752 }
8a0cfee11af8 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
753