10 widget_hide(gpointer data
, gpointer nodes
)
12 GntWidget
*widget
= GNT_WIDGET(data
);
13 GntNode
*node
= g_hash_table_lookup(nodes
, widget
);
14 if (GNT_IS_WINDOW(widget
))
15 gnt_window_workspace_hiding(GNT_WINDOW(widget
));
16 hide_panel(node
->panel
);
20 widget_show(gpointer data
, gpointer nodes
)
22 GntNode
*node
= g_hash_table_lookup(nodes
, data
);
23 GNT_WIDGET_UNSET_FLAGS(GNT_WIDGET(data
), GNT_WIDGET_INVISIBLE
);
25 show_panel(node
->panel
);
26 gnt_wm_copy_win(GNT_WIDGET(data
), node
);
31 gnt_ws_draw_taskbar(GntWS
*ws
, gboolean reposition
)
33 static WINDOW
*taskbar
= NULL
;
41 if (taskbar
== NULL
) {
42 taskbar
= newwin(1, getmaxx(stdscr
), getmaxy(stdscr
) - 1, 0);
43 } else if (reposition
) {
44 int Y_MAX
= getmaxy(stdscr
) - 1;
45 mvwin(taskbar
, Y_MAX
, 0);
48 wbkgdset(taskbar
, '\0' | gnt_color_pair(GNT_COLOR_NORMAL
));
51 n
= g_list_length(ws
->list
);
53 width
= getmaxx(stdscr
) / n
;
55 for (i
= 0, iter
= ws
->list
; iter
; iter
= iter
->next
, i
++) {
56 GntWidget
*w
= iter
->data
;
60 if (w
== ws
->ordered
->data
) {
61 /* This is the current window in focus */
62 color
= GNT_COLOR_TITLE
;
63 } else if (GNT_WIDGET_IS_FLAG_SET(w
, GNT_WIDGET_URGENT
)) {
64 /* This is a window with the URGENT hint set */
65 color
= GNT_COLOR_URGENT
;
67 color
= GNT_COLOR_NORMAL
;
69 wbkgdset(taskbar
, '\0' | gnt_color_pair(color
));
71 mvwhline(taskbar
, 0, width
* i
, ' ' | gnt_color_pair(color
), width
);
73 mvwhline(taskbar
, 0, width
* i
, ' ' | gnt_color_pair(color
), getmaxx(stdscr
) - width
* i
);
74 title
= GNT_BOX(w
)->title
;
75 mvwprintw(taskbar
, 0, width
* i
, "%s", title
? title
: "<gnt>");
77 mvwaddch(taskbar
, 0, width
*i
- 1, ACS_VLINE
| A_STANDOUT
| gnt_color_pair(GNT_COLOR_NORMAL
));
83 gnt_ws_init(GTypeInstance
*instance
, gpointer
class)
85 GntWS
*ws
= GNT_WS(instance
);
91 void gnt_ws_add_widget(GntWS
*ws
, GntWidget
* wid
)
94 oldfocus
= ws
->ordered
? ws
->ordered
->data
: NULL
;
95 ws
->list
= g_list_append(ws
->list
, wid
);
96 ws
->ordered
= g_list_prepend(ws
->ordered
, wid
);
98 gnt_widget_set_focus(oldfocus
, FALSE
);
101 void gnt_ws_remove_widget(GntWS
*ws
, GntWidget
* wid
)
103 ws
->list
= g_list_remove(ws
->list
, wid
);
104 ws
->ordered
= g_list_remove(ws
->ordered
, wid
);
108 gnt_ws_set_name(GntWS
*ws
, const gchar
*name
)
111 ws
->name
= g_strdup(name
);
115 gnt_ws_hide(GntWS
*ws
, GHashTable
*nodes
)
117 g_list_foreach(ws
->ordered
, widget_hide
, nodes
);
120 void gnt_ws_widget_hide(GntWidget
*widget
, GHashTable
*nodes
)
122 widget_hide(widget
, nodes
);
125 void gnt_ws_widget_show(GntWidget
*widget
, GHashTable
*nodes
)
127 widget_show(widget
, nodes
);
131 gnt_ws_show(GntWS
*ws
, GHashTable
*nodes
)
134 for (l
= g_list_last(ws
->ordered
); l
; l
= g_list_previous(l
))
135 widget_show(l
->data
, nodes
);
139 gnt_ws_get_gtype(void)
141 static GType type
= 0;
144 static const GTypeInfo info
= {
146 NULL
, /* base_init */
147 NULL
, /* base_finalize */
149 /*(GClassInitFunc)gnt_ws_class_init,*/
151 NULL
, /* class_data */
154 gnt_ws_init
, /* instance_init */
155 NULL
/* value_table */
158 type
= g_type_register_static(GNT_TYPE_BINDABLE
,
166 GntWS
*gnt_ws_new(const char *name
)
168 GntWS
*ws
= GNT_WS(g_object_new(GNT_TYPE_WS
, NULL
));
169 ws
->name
= g_strdup(name
? name
: "(noname)");
173 const char * gnt_ws_get_name(GntWS
*ws
)