Mercurial > pidgin.yaz
annotate finch/libgnt/gntwindow.c @ 18053:891f22c7e884
merge of 'e82c41f34ce5f7439b2f2971139efaf6ef7a54ff'
and 'f024502a953161972f4fac58e80c288007ebd5fb'
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Wed, 06 Jun 2007 16:00:27 +0000 |
parents | 1cedd520cd18 |
children | 08776fc5c06f |
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 { | |
30 SIGS = 1, | |
31 }; | |
32 | |
33 static GntBoxClass *parent_class = NULL; | |
34 | |
35 static void (*org_destroy)(GntWidget *widget); | |
36 | |
37 static gboolean | |
38 show_menu(GntBindable *bind, GList *null) | |
39 { | |
40 GntWindow *win = GNT_WINDOW(bind); | |
41 if (win->menu) { | |
42 gnt_screen_menu_show(win->menu); | |
43 return TRUE; | |
44 } | |
45 return FALSE; | |
46 } | |
47 | |
48 static void | |
49 gnt_window_destroy(GntWidget *widget) | |
50 { | |
51 GntWindow *window = GNT_WINDOW(widget); | |
52 if (window->menu) | |
53 gnt_widget_destroy(GNT_WIDGET(window->menu)); | |
54 org_destroy(widget); | |
55 } | |
56 | |
57 static void | |
58 gnt_window_class_init(GntWindowClass *klass) | |
59 { | |
60 GntBindableClass *bindable = GNT_BINDABLE_CLASS(klass); | |
61 GntWidgetClass *wid_class = GNT_WIDGET_CLASS(klass); | |
62 parent_class = GNT_BOX_CLASS(klass); | |
63 | |
64 org_destroy = wid_class->destroy; | |
65 wid_class->destroy = gnt_window_destroy; | |
66 | |
67 gnt_bindable_class_register_action(bindable, "show-menu", show_menu, | |
68 GNT_KEY_CTRL_O, NULL); | |
69 gnt_bindable_register_binding(bindable, "show-menu", GNT_KEY_F10, NULL); | |
70 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), bindable); | |
71 | |
72 GNTDEBUG; | |
73 } | |
74 | |
75 static void | |
76 gnt_window_init(GTypeInstance *instance, gpointer class) | |
77 { | |
78 GntWidget *widget = GNT_WIDGET(instance); | |
79 GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW); | |
80 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_CAN_TAKE_FOCUS); | |
81 GNTDEBUG; | |
82 } | |
83 | |
84 /****************************************************************************** | |
85 * GntWindow API | |
86 *****************************************************************************/ | |
87 GType | |
88 gnt_window_get_gtype(void) | |
89 { | |
90 static GType type = 0; | |
91 | |
92 if(type == 0) | |
93 { | |
94 static const GTypeInfo info = { | |
95 sizeof(GntWindowClass), | |
96 NULL, /* base_init */ | |
97 NULL, /* base_finalize */ | |
98 (GClassInitFunc)gnt_window_class_init, | |
99 NULL, /* class_finalize */ | |
100 NULL, /* class_data */ | |
101 sizeof(GntWindow), | |
102 0, /* n_preallocs */ | |
103 gnt_window_init, /* instance_init */ | |
104 NULL /* value_table */ | |
105 }; | |
106 | |
107 type = g_type_register_static(GNT_TYPE_BOX, | |
108 "GntWindow", | |
109 &info, 0); | |
110 } | |
111 | |
112 return type; | |
113 } | |
114 | |
115 GntWidget *gnt_window_new() | |
116 { | |
117 GntWidget *widget = g_object_new(GNT_TYPE_WINDOW, NULL); | |
118 | |
119 return widget; | |
120 } | |
121 | |
122 GntWidget *gnt_window_box_new(gboolean homo, gboolean vert) | |
123 { | |
124 GntWidget *wid = gnt_window_new(); | |
125 GntBox *box = GNT_BOX(wid); | |
126 | |
127 box->homogeneous = homo; | |
128 box->vertical = vert; | |
129 box->alignment = vert ? GNT_ALIGN_LEFT : GNT_ALIGN_MID; | |
130 | |
131 return wid; | |
132 } | |
133 | |
134 void gnt_window_set_menu(GntWindow *window, GntMenu *menu) | |
135 { | |
136 /* If a menu already existed, then destroy that first. */ | |
137 if (window->menu) | |
138 gnt_widget_destroy(GNT_WIDGET(window->menu)); | |
139 window->menu = menu; | |
140 } | |
141 |