Mercurial > pidgin
annotate finch/libgnt/gntws.c @ 18193:09eb621782bc
explicit merge of 'f2eb358baf2c72cb37b6b9bcb4c036e44e0bcc2b'
and '2344c84a6e70c374b19936a127462d2f19c0139c'
author | Ka-Hing Cheung <khc@hxbc.us> |
---|---|
date | Tue, 19 Jun 2007 17:17:57 +0000 |
parents | 34e011c8ed2b |
children | 5023ad94ebc9 |
rev | line source |
---|---|
17699 | 1 #include <gmodule.h> |
2 | |
3 #include "gntbox.h" | |
17707
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
17702
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:
17702
diff
changeset
|
5 #include "gntwindow.h" |
17699 | 6 #include "gntwm.h" |
17707
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
17702
diff
changeset
|
7 #include "gntws.h" |
17699 | 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); | |
17707
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
17702
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:
17702
diff
changeset
|
15 gnt_window_workspace_hiding(GNT_WINDOW(widget)); |
17699 | 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 { | |
90 ws->list = g_list_append(ws->list, wid); | |
91 ws->ordered = g_list_prepend(ws->ordered, wid); | |
92 } | |
93 | |
94 void gnt_ws_remove_widget(GntWS *ws, GntWidget* wid) | |
95 { | |
96 ws->list = g_list_remove(ws->list, wid); | |
97 ws->ordered = g_list_remove(ws->ordered, wid); | |
98 } | |
99 | |
100 void | |
101 gnt_ws_set_name(GntWS *ws, const gchar *name) | |
102 { | |
103 g_free(ws->name); | |
104 ws->name = g_strdup(name); | |
105 } | |
106 | |
107 void | |
108 gnt_ws_hide(GntWS *ws, GHashTable *nodes) | |
109 { | |
110 g_list_foreach(ws->ordered, widget_hide, nodes); | |
111 } | |
112 | |
113 void gnt_ws_widget_hide(GntWidget *widget, GHashTable *nodes) { | |
114 widget_hide(widget, nodes); | |
115 } | |
116 | |
117 void gnt_ws_widget_show(GntWidget *widget, GHashTable *nodes) { | |
118 widget_show(widget, nodes); | |
119 } | |
120 | |
121 void | |
122 gnt_ws_show(GntWS *ws, GHashTable *nodes) | |
123 { | |
124 GList *l; | |
125 for (l = g_list_last(ws->ordered); l; l = g_list_previous(l)) | |
126 widget_show(l->data, nodes); | |
127 } | |
128 | |
129 GType | |
130 gnt_ws_get_gtype(void) | |
131 { | |
132 static GType type = 0; | |
133 | |
134 if(type == 0) { | |
135 static const GTypeInfo info = { | |
136 sizeof(GntWSClass), | |
137 NULL, /* base_init */ | |
138 NULL, /* base_finalize */ | |
139 NULL, | |
140 /*(GClassInitFunc)gnt_ws_class_init,*/ | |
141 NULL, | |
142 NULL, /* class_data */ | |
143 sizeof(GntWS), | |
144 0, /* n_preallocs */ | |
145 gnt_ws_init, /* instance_init */ | |
146 NULL /* value_table */ | |
147 }; | |
148 | |
149 type = g_type_register_static(GNT_TYPE_BINDABLE, | |
150 "GntWS", | |
151 &info, 0); | |
152 } | |
153 | |
154 return type; | |
155 } | |
156 | |
18075
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17707
diff
changeset
|
157 GntWS *gnt_ws_new(const char *name) |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17707
diff
changeset
|
158 { |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17707
diff
changeset
|
159 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:
17707
diff
changeset
|
160 ws->name = g_strdup(name ? name : "(noname)"); |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17707
diff
changeset
|
161 return ws; |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17707
diff
changeset
|
162 } |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17707
diff
changeset
|
163 |
17702
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17699
diff
changeset
|
164 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:
17699
diff
changeset
|
165 { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17699
diff
changeset
|
166 return ws->name; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17699
diff
changeset
|
167 } |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17699
diff
changeset
|
168 |