Mercurial > pidgin.yaz
annotate finch/libgnt/gntwindow.c @ 19140:7a5025b8698c
propagate from branch 'im.pidgin.pidgin' (head 007693114b23cd2711c1cb9030a148e2f63de8c8)
to branch 'im.pidgin.soc.2007.finchfeat' (head e338ac75e7034d8253e0e6b928940c27c2dcf5f0)
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 07 Jul 2007 00:41:03 +0000 |
parents | 08776fc5c06f |
children | 44b4e8bd759b |
rev | line source |
---|---|
18049
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15818
diff
changeset
|
1 /** |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15818
diff
changeset
|
2 * GNT - The GLib Ncurses Toolkit |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15818
diff
changeset
|
3 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15818
diff
changeset
|
4 * GNT is the legal property of its developers, whose names are too numerous |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15818
diff
changeset
|
5 * to list here. Please refer to the COPYRIGHT file distributed with this |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15818
diff
changeset
|
6 * source distribution. |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15818
diff
changeset
|
7 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15818
diff
changeset
|
8 * This library is free software; you can redistribute it and/or modify |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15818
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15818
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15818
diff
changeset
|
11 * (at your option) any later version. |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15818
diff
changeset
|
12 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15818
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15818
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15818
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15818
diff
changeset
|
16 * GNU General Public License for more details. |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15818
diff
changeset
|
17 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15818
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15818
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15818
diff
changeset
|
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15818
diff
changeset
|
21 */ |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15818
diff
changeset
|
22 |
15818 | 23 #include "gntstyle.h" |
24 #include "gntwindow.h" | |
25 | |
26 #include <string.h> | |
27 | |
28 enum | |
29 { | |
16731
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
30 SIG_WORKSPACE_HIDE, |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
31 SIG_WORKSPACE_SHOW, |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
32 SIGS, |
15818 | 33 }; |
34 | |
16731
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
35 static guint signals[SIGS] = { 0 }; |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
36 |
15818 | 37 static GntBoxClass *parent_class = NULL; |
38 | |
39 static void (*org_destroy)(GntWidget *widget); | |
40 | |
41 static gboolean | |
42 show_menu(GntBindable *bind, GList *null) | |
43 { | |
44 GntWindow *win = GNT_WINDOW(bind); | |
45 if (win->menu) { | |
46 gnt_screen_menu_show(win->menu); | |
47 return TRUE; | |
48 } | |
49 return FALSE; | |
50 } | |
51 | |
52 static void | |
53 gnt_window_destroy(GntWidget *widget) | |
54 { | |
55 GntWindow *window = GNT_WINDOW(widget); | |
56 if (window->menu) | |
57 gnt_widget_destroy(GNT_WIDGET(window->menu)); | |
58 org_destroy(widget); | |
59 } | |
60 | |
61 static void | |
62 gnt_window_class_init(GntWindowClass *klass) | |
63 { | |
64 GntBindableClass *bindable = GNT_BINDABLE_CLASS(klass); | |
65 GntWidgetClass *wid_class = GNT_WIDGET_CLASS(klass); | |
66 parent_class = GNT_BOX_CLASS(klass); | |
67 | |
68 org_destroy = wid_class->destroy; | |
69 wid_class->destroy = gnt_window_destroy; | |
70 | |
16731
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
71 signals[SIG_WORKSPACE_HIDE] = |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
72 g_signal_new("workspace-hidden", |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
73 G_TYPE_FROM_CLASS(klass), |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
74 G_SIGNAL_RUN_LAST, |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
75 0, |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
76 NULL, NULL, |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
77 g_cclosure_marshal_VOID__VOID, |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
78 G_TYPE_NONE, 0); |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
79 |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
80 signals[SIG_WORKSPACE_SHOW] = |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
81 g_signal_new("workspace-shown", |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
82 G_TYPE_FROM_CLASS(klass), |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
83 G_SIGNAL_RUN_LAST, |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
84 0, |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
85 NULL, NULL, |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
86 g_cclosure_marshal_VOID__VOID, |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
87 G_TYPE_NONE, 0); |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
88 |
15818 | 89 gnt_bindable_class_register_action(bindable, "show-menu", show_menu, |
90 GNT_KEY_CTRL_O, NULL); | |
91 gnt_bindable_register_binding(bindable, "show-menu", GNT_KEY_F10, NULL); | |
92 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), bindable); | |
93 | |
94 GNTDEBUG; | |
95 } | |
96 | |
97 static void | |
98 gnt_window_init(GTypeInstance *instance, gpointer class) | |
99 { | |
100 GntWidget *widget = GNT_WIDGET(instance); | |
101 GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW); | |
102 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_CAN_TAKE_FOCUS); | |
103 GNTDEBUG; | |
104 } | |
105 | |
106 /****************************************************************************** | |
107 * GntWindow API | |
108 *****************************************************************************/ | |
109 GType | |
110 gnt_window_get_gtype(void) | |
111 { | |
112 static GType type = 0; | |
113 | |
114 if(type == 0) | |
115 { | |
116 static const GTypeInfo info = { | |
117 sizeof(GntWindowClass), | |
118 NULL, /* base_init */ | |
119 NULL, /* base_finalize */ | |
120 (GClassInitFunc)gnt_window_class_init, | |
121 NULL, /* class_finalize */ | |
122 NULL, /* class_data */ | |
123 sizeof(GntWindow), | |
124 0, /* n_preallocs */ | |
125 gnt_window_init, /* instance_init */ | |
126 NULL /* value_table */ | |
127 }; | |
128 | |
129 type = g_type_register_static(GNT_TYPE_BOX, | |
130 "GntWindow", | |
131 &info, 0); | |
132 } | |
133 | |
134 return type; | |
135 } | |
136 | |
137 GntWidget *gnt_window_new() | |
138 { | |
139 GntWidget *widget = g_object_new(GNT_TYPE_WINDOW, NULL); | |
140 | |
141 return widget; | |
142 } | |
143 | |
144 GntWidget *gnt_window_box_new(gboolean homo, gboolean vert) | |
145 { | |
146 GntWidget *wid = gnt_window_new(); | |
147 GntBox *box = GNT_BOX(wid); | |
148 | |
149 box->homogeneous = homo; | |
150 box->vertical = vert; | |
151 box->alignment = vert ? GNT_ALIGN_LEFT : GNT_ALIGN_MID; | |
152 | |
153 return wid; | |
154 } | |
155 | |
16731
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
156 void |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
157 gnt_window_workspace_hiding(GntWindow *window) |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
158 { |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
159 if (window->menu) |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
160 gnt_widget_hide(GNT_WIDGET(window->menu)); |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
161 g_signal_emit(window, signals[SIG_WORKSPACE_HIDE], 0); |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
162 } |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
163 |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
164 void |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
165 gnt_window_workspace_showing(GntWindow *window) |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
166 { |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
167 g_signal_emit(window, signals[SIG_WORKSPACE_SHOW], 0); |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
168 } |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
15818
diff
changeset
|
169 |
15818 | 170 void gnt_window_set_menu(GntWindow *window, GntMenu *menu) |
171 { | |
172 /* If a menu already existed, then destroy that first. */ | |
173 if (window->menu) | |
174 gnt_widget_destroy(GNT_WIDGET(window->menu)); | |
175 window->menu = menu; | |
176 } | |
177 |