annotate finch/libgnt/gntws.c @ 17699:97802d3f3f1f

Forgot these...
author Richard Nelson <wabz@pidgin.im>
date Fri, 27 Apr 2007 12:56:59 +0000
parents
children 596c970076df
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17699
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
1 #include <gmodule.h>
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
2
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
3 #include "gntbox.h"
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
4 #include "gntws.h"
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
5 #include "gntwm.h"
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
6 #include "gntwidget.h"
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
7
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
8 static void
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
9 widget_hide(gpointer data, gpointer nodes)
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
10 {
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
11 GntWidget *widget = GNT_WIDGET(data);
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
12 GntNode *node = g_hash_table_lookup(nodes, widget);
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
13 hide_panel(node->panel);
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
14 }
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
15
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
16 static void
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
17 widget_show(gpointer data, gpointer nodes)
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
18 {
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
19 GntNode *node = g_hash_table_lookup(nodes, data);
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
20 GNT_WIDGET_UNSET_FLAGS(GNT_WIDGET(data), GNT_WIDGET_INVISIBLE);
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
21 if (node) {
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
22 show_panel(node->panel);
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
23 gnt_wm_copy_win(GNT_WIDGET(data), node);
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
24 }
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
25 }
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
26
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
27 void
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
28 gnt_ws_draw_taskbar(GntWS *ws, gboolean reposition)
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
29 {
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
30 static WINDOW *taskbar = NULL;
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
31 GList *iter;
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
32 int n, width = 0;
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
33 int i;
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
34
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
35 if (taskbar == NULL) {
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
36 taskbar = newwin(1, getmaxx(stdscr), getmaxy(stdscr) - 1, 0);
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
37 } else if (reposition) {
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
38 int Y_MAX = getmaxy(stdscr) - 1;
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
39 mvwin(taskbar, Y_MAX, 0);
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
40 }
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
41
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
42 wbkgdset(taskbar, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL));
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
43 werase(taskbar);
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
44
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
45 n = g_list_length(ws->list);
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
46 if (n)
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
47 width = getmaxx(stdscr) / n;
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
48
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
49 for (i = 0, iter = ws->list; iter; iter = iter->next, i++) {
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
50 GntWidget *w = iter->data;
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
51 int color;
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
52 const char *title;
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
53
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
54 if (w == ws->ordered->data) {
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
55 /* This is the current window in focus */
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
56 color = GNT_COLOR_TITLE;
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
57 } else if (GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_URGENT)) {
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
58 /* This is a window with the URGENT hint set */
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
59 color = GNT_COLOR_URGENT;
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
60 } else {
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
61 color = GNT_COLOR_NORMAL;
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
62 }
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
63 wbkgdset(taskbar, '\0' | COLOR_PAIR(color));
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
64 if (iter->next)
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
65 mvwhline(taskbar, 0, width * i, ' ' | COLOR_PAIR(color), width);
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
66 else
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
67 mvwhline(taskbar, 0, width * i, ' ' | COLOR_PAIR(color), getmaxx(stdscr) - width * i);
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
68 title = GNT_BOX(w)->title;
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
69 mvwprintw(taskbar, 0, width * i, "%s", title ? title : "<gnt>");
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
70 if (i)
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
71 mvwaddch(taskbar, 0, width *i - 1, ACS_VLINE | A_STANDOUT | COLOR_PAIR(GNT_COLOR_NORMAL));
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
72 }
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
73 wrefresh(taskbar);
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
74 }
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
75
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
76 static void
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
77 gnt_ws_init(GTypeInstance *instance, gpointer class)
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
78 {
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
79 GntWS *ws = GNT_WS(instance);
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
80 ws->list = NULL;
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
81 ws->ordered = NULL;
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
82 ws->name = NULL;
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
83 }
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
84
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
85 void gnt_ws_add_widget(GntWS *ws, GntWidget* wid)
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
86 {
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
87 ws->list = g_list_append(ws->list, wid);
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
88 ws->ordered = g_list_prepend(ws->ordered, wid);
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
89 }
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
90
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
91 void gnt_ws_remove_widget(GntWS *ws, GntWidget* wid)
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
92 {
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
93 ws->list = g_list_remove(ws->list, wid);
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
94 ws->ordered = g_list_remove(ws->ordered, wid);
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
95 }
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
96
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
97 void
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
98 gnt_ws_set_name(GntWS *ws, const gchar *name)
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
99 {
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
100 g_free(ws->name);
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
101 ws->name = g_strdup(name);
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
102 }
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
103
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
104 void
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
105 gnt_ws_hide(GntWS *ws, GHashTable *nodes)
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
106 {
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
107 g_list_foreach(ws->ordered, widget_hide, nodes);
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
108 }
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
109
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
110 void gnt_ws_widget_hide(GntWidget *widget, GHashTable *nodes) {
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
111 widget_hide(widget, nodes);
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
112 }
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
113
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
114 void gnt_ws_widget_show(GntWidget *widget, GHashTable *nodes) {
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
115 widget_show(widget, nodes);
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
116 }
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
117
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
118 void
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
119 gnt_ws_show(GntWS *ws, GHashTable *nodes)
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
120 {
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
121 GList *l;
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
122 for (l = g_list_last(ws->ordered); l; l = g_list_previous(l))
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
123 widget_show(l->data, nodes);
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
124 }
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
125
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
126 GType
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
127 gnt_ws_get_gtype(void)
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
128 {
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
129 static GType type = 0;
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
130
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
131 if(type == 0) {
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
132 static const GTypeInfo info = {
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
133 sizeof(GntWSClass),
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
134 NULL, /* base_init */
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
135 NULL, /* base_finalize */
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
136 NULL,
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
137 /*(GClassInitFunc)gnt_ws_class_init,*/
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
138 NULL,
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
139 NULL, /* class_data */
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
140 sizeof(GntWS),
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
141 0, /* n_preallocs */
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
142 gnt_ws_init, /* instance_init */
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
143 NULL /* value_table */
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
144 };
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
145
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
146 type = g_type_register_static(GNT_TYPE_BINDABLE,
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
147 "GntWS",
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
148 &info, 0);
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
149 }
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
150
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
151 return type;
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
152 }
97802d3f3f1f Forgot these...
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
153