Mercurial > pidgin.yaz
annotate finch/libgnt/gntws.c @ 18420:e2b8b17fc62c
Allow storing non-string binary data in tree columns.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Tue, 03 Jul 2007 04:47:24 +0000 |
parents | 93c5c785a811 |
children | e16d097c5739 |
rev | line source |
---|---|
16415 | 1 #include <gmodule.h> |
2 | |
3 #include "gntbox.h" | |
16731
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
4 #include "gntwidget.h" |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
5 #include "gntwindow.h" |
16415 | 6 #include "gntwm.h" |
16731
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
7 #include "gntws.h" |
16415 | 8 |
9 static void | |
10 widget_hide(gpointer data, gpointer nodes) | |
11 { | |
12 GntWidget *widget = GNT_WIDGET(data); | |
13 GntNode *node = g_hash_table_lookup(nodes, widget); | |
16731
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
14 if (GNT_IS_WINDOW(widget)) |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
15 gnt_window_workspace_hiding(GNT_WINDOW(widget)); |
16415 | 16 hide_panel(node->panel); |
17 } | |
18 | |
19 static void | |
20 widget_show(gpointer data, gpointer nodes) | |
21 { | |
22 GntNode *node = g_hash_table_lookup(nodes, data); | |
23 GNT_WIDGET_UNSET_FLAGS(GNT_WIDGET(data), GNT_WIDGET_INVISIBLE); | |
24 if (node) { | |
25 show_panel(node->panel); | |
26 gnt_wm_copy_win(GNT_WIDGET(data), node); | |
27 } | |
28 } | |
29 | |
30 void | |
31 gnt_ws_draw_taskbar(GntWS *ws, gboolean reposition) | |
32 { | |
33 static WINDOW *taskbar = NULL; | |
34 GList *iter; | |
35 int n, width = 0; | |
36 int i; | |
37 | |
38 if (taskbar == NULL) { | |
39 taskbar = newwin(1, getmaxx(stdscr), getmaxy(stdscr) - 1, 0); | |
40 } else if (reposition) { | |
41 int Y_MAX = getmaxy(stdscr) - 1; | |
42 mvwin(taskbar, Y_MAX, 0); | |
43 } | |
44 | |
45 wbkgdset(taskbar, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL)); | |
46 werase(taskbar); | |
47 | |
48 n = g_list_length(ws->list); | |
49 if (n) | |
50 width = getmaxx(stdscr) / n; | |
51 | |
52 for (i = 0, iter = ws->list; iter; iter = iter->next, i++) { | |
53 GntWidget *w = iter->data; | |
54 int color; | |
55 const char *title; | |
56 | |
57 if (w == ws->ordered->data) { | |
58 /* This is the current window in focus */ | |
59 color = GNT_COLOR_TITLE; | |
60 } else if (GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_URGENT)) { | |
61 /* This is a window with the URGENT hint set */ | |
62 color = GNT_COLOR_URGENT; | |
63 } else { | |
64 color = GNT_COLOR_NORMAL; | |
65 } | |
66 wbkgdset(taskbar, '\0' | COLOR_PAIR(color)); | |
67 if (iter->next) | |
68 mvwhline(taskbar, 0, width * i, ' ' | COLOR_PAIR(color), width); | |
69 else | |
70 mvwhline(taskbar, 0, width * i, ' ' | COLOR_PAIR(color), getmaxx(stdscr) - width * i); | |
71 title = GNT_BOX(w)->title; | |
72 mvwprintw(taskbar, 0, width * i, "%s", title ? title : "<gnt>"); | |
73 if (i) | |
74 mvwaddch(taskbar, 0, width *i - 1, ACS_VLINE | A_STANDOUT | COLOR_PAIR(GNT_COLOR_NORMAL)); | |
75 } | |
76 wrefresh(taskbar); | |
77 } | |
78 | |
79 static void | |
80 gnt_ws_init(GTypeInstance *instance, gpointer class) | |
81 { | |
82 GntWS *ws = GNT_WS(instance); | |
83 ws->list = NULL; | |
84 ws->ordered = NULL; | |
85 ws->name = NULL; | |
86 } | |
87 | |
88 void gnt_ws_add_widget(GntWS *ws, GntWidget* wid) | |
89 { | |
18223
5023ad94ebc9
Notify a window when it loses focus because another window was moved to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18075
diff
changeset
|
90 GntWidget *oldfocus; |
5023ad94ebc9
Notify a window when it loses focus because another window was moved to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18075
diff
changeset
|
91 oldfocus = ws->ordered ? ws->ordered->data : NULL; |
16415 | 92 ws->list = g_list_append(ws->list, wid); |
93 ws->ordered = g_list_prepend(ws->ordered, wid); | |
18223
5023ad94ebc9
Notify a window when it loses focus because another window was moved to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18075
diff
changeset
|
94 if (oldfocus) |
5023ad94ebc9
Notify a window when it loses focus because another window was moved to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18075
diff
changeset
|
95 gnt_widget_set_focus(oldfocus, FALSE); |
16415 | 96 } |
97 | |
98 void gnt_ws_remove_widget(GntWS *ws, GntWidget* wid) | |
99 { | |
100 ws->list = g_list_remove(ws->list, wid); | |
101 ws->ordered = g_list_remove(ws->ordered, wid); | |
102 } | |
103 | |
104 void | |
105 gnt_ws_set_name(GntWS *ws, const gchar *name) | |
106 { | |
107 g_free(ws->name); | |
108 ws->name = g_strdup(name); | |
109 } | |
110 | |
111 void | |
112 gnt_ws_hide(GntWS *ws, GHashTable *nodes) | |
113 { | |
114 g_list_foreach(ws->ordered, widget_hide, nodes); | |
115 } | |
116 | |
18416
93c5c785a811
Fix some focus issues.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18223
diff
changeset
|
117 void gnt_ws_widget_hide(GntWidget *widget, GHashTable *nodes) |
93c5c785a811
Fix some focus issues.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18223
diff
changeset
|
118 { |
16415 | 119 widget_hide(widget, nodes); |
120 } | |
121 | |
18416
93c5c785a811
Fix some focus issues.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18223
diff
changeset
|
122 void gnt_ws_widget_show(GntWidget *widget, GHashTable *nodes) |
93c5c785a811
Fix some focus issues.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18223
diff
changeset
|
123 { |
16415 | 124 widget_show(widget, nodes); |
125 } | |
126 | |
127 void | |
128 gnt_ws_show(GntWS *ws, GHashTable *nodes) | |
129 { | |
130 GList *l; | |
131 for (l = g_list_last(ws->ordered); l; l = g_list_previous(l)) | |
132 widget_show(l->data, nodes); | |
133 } | |
134 | |
135 GType | |
136 gnt_ws_get_gtype(void) | |
137 { | |
138 static GType type = 0; | |
139 | |
140 if(type == 0) { | |
141 static const GTypeInfo info = { | |
142 sizeof(GntWSClass), | |
143 NULL, /* base_init */ | |
144 NULL, /* base_finalize */ | |
145 NULL, | |
146 /*(GClassInitFunc)gnt_ws_class_init,*/ | |
147 NULL, | |
148 NULL, /* class_data */ | |
149 sizeof(GntWS), | |
150 0, /* n_preallocs */ | |
151 gnt_ws_init, /* instance_init */ | |
152 NULL /* value_table */ | |
153 }; | |
154 | |
155 type = g_type_register_static(GNT_TYPE_BINDABLE, | |
156 "GntWS", | |
157 &info, 0); | |
158 } | |
159 | |
160 return type; | |
161 } | |
162 | |
18075
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16731
diff
changeset
|
163 GntWS *gnt_ws_new(const char *name) |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16731
diff
changeset
|
164 { |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16731
diff
changeset
|
165 GntWS *ws = GNT_WS(g_object_new(GNT_TYPE_WS, NULL)); |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16731
diff
changeset
|
166 ws->name = g_strdup(name ? name : "(noname)"); |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16731
diff
changeset
|
167 return ws; |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16731
diff
changeset
|
168 } |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16731
diff
changeset
|
169 |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16415
diff
changeset
|
170 const char * gnt_ws_get_name(GntWS *ws) |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16415
diff
changeset
|
171 { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16415
diff
changeset
|
172 return ws->name; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16415
diff
changeset
|
173 } |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16415
diff
changeset
|
174 |