annotate console/libgnt/gntwm.c @ 15130:6d015bcd8d1d

[gaim-migrate @ 17916] MSN only does PNG committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Thu, 07 Dec 2006 14:08:45 +0000
parents d08d7b7375c7
children 2409a2508650
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1 #define _GNU_SOURCE
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
2 #if defined(__APPLE__)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
3 #define _XOPEN_SOURCE_EXTENDED
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
4 #endif
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
5
14904
0512fddbaaf2 [gaim-migrate @ 17676]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14900
diff changeset
6 #include "config.h"
0512fddbaaf2 [gaim-migrate @ 17676]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14900
diff changeset
7
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
8 #include "gntwm.h"
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
9 #include "gntstyle.h"
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
10 #include "gntmarshal.h"
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
11 #include "gnt.h"
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
12 #include "gntbox.h"
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
13 #include "gntmenu.h"
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
14 #include "gnttextview.h"
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
15 #include "gnttree.h"
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
16 #include "gntutils.h"
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
17
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
18 #include <ctype.h>
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
19 #include <stdlib.h>
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
20 #include <string.h>
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
21
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
22 enum
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
23 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
24 SIG_NEW_WIN,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
25 SIG_DECORATE_WIN,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
26 SIG_CLOSE_WIN,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
27 SIG_CONFIRM_RESIZE,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
28 SIG_RESIZED,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
29 SIG_CONFIRM_MOVE,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
30 SIG_MOVED,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
31 SIG_UPDATE_WIN,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
32 SIG_GIVE_FOCUS,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
33 SIG_KEY_PRESS,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
34 SIG_MOUSE_CLICK,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
35 SIGS
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
36 };
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
37
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
38 static guint signals[SIGS] = { 0 };
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
39 static void gnt_wm_new_window_real(GntWM *wm, GntWidget *widget);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
40 static void gnt_wm_win_resized(GntWM *wm, GntNode *node);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
41 static void gnt_wm_win_moved(GntWM *wm, GntNode *node);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
42 static void gnt_wm_give_focus(GntWM *wm, GntWidget *widget);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
43 static void update_window_in_list(GntWM *wm, GntWidget *wid);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
44
15067
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
45 static gboolean write_already(gpointer data);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
46 static int write_timeout;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
47
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
48 static GList *
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
49 g_list_bring_to_front(GList *list, gpointer data)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
50 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
51 list = g_list_remove(list, data);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
52 list = g_list_prepend(list, data);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
53 return list;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
54 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
55
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
56 static void
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
57 free_node(gpointer data)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
58 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
59 GntNode *node = data;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
60 hide_panel(node->panel);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
61 del_panel(node->panel);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
62 g_free(node);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
63 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
64
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
65 static void
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
66 draw_taskbar(GntWM *wm, gboolean reposition)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
67 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
68 static WINDOW *taskbar = NULL;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
69 GList *iter;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
70 int n, width = 0;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
71 int i;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
72
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
73 if (taskbar == NULL) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
74 taskbar = newwin(1, getmaxx(stdscr), getmaxy(stdscr) - 1, 0);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
75 } else if (reposition) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
76 int Y_MAX = getmaxy(stdscr) - 1;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
77 mvwin(taskbar, Y_MAX, 0);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
78 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
79
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
80 wbkgdset(taskbar, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL));
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
81 werase(taskbar);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
82
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
83 n = g_list_length(wm->list);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
84 if (n)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
85 width = getmaxx(stdscr) / n;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
86
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
87 for (i = 0, iter = wm->list; iter; iter = iter->next, i++)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
88 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
89 GntWidget *w = iter->data;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
90 int color;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
91 const char *title;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
92
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
93 if (w == wm->ordered->data) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
94 /* This is the current window in focus */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
95 color = GNT_COLOR_TITLE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
96 } else if (GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_URGENT)) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
97 /* This is a window with the URGENT hint set */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
98 color = GNT_COLOR_URGENT;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
99 } else {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
100 color = GNT_COLOR_NORMAL;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
101 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
102 wbkgdset(taskbar, '\0' | COLOR_PAIR(color));
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
103 mvwhline(taskbar, 0, width * i, ' ' | COLOR_PAIR(color), width);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
104 title = GNT_BOX(w)->title;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
105 mvwprintw(taskbar, 0, width * i, "%s", title ? title : "<gnt>");
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
106 if (i)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
107 mvwaddch(taskbar, 0, width *i - 1, ACS_VLINE | A_STANDOUT | COLOR_PAIR(GNT_COLOR_NORMAL));
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
108
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
109 update_window_in_list(wm, w);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
110 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
111
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
112 wrefresh(taskbar);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
113 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
114 static gboolean
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
115 update_screen(GntWM *wm)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
116 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
117 if (wm->menu) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
118 GntMenu *top = wm->menu;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
119 while (top) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
120 GntNode *node = g_hash_table_lookup(wm->nodes, top);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
121 if (node)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
122 top_panel(node->panel);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
123 top = top->submenu;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
124 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
125 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
126 update_panels();
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
127 doupdate();
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
128 return TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
129 }
15067
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
130
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
131 static gboolean
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
132 sanitize_position(GntWidget *widget, int *x, int *y)
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
133 {
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
134 int X_MAX = getmaxx(stdscr);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
135 int Y_MAX = getmaxy(stdscr) - 1;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
136 int w, h;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
137 int nx, ny;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
138 gboolean changed = FALSE;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
139
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
140 gnt_widget_get_size(widget, &w, &h);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
141 if (x) {
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
142 if (*x + w > X_MAX) {
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
143 nx = MAX(0, X_MAX - w);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
144 if (nx != *x) {
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
145 *x = nx;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
146 changed = TRUE;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
147 }
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
148 }
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
149 }
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
150 if (y) {
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
151 if (*y + h > Y_MAX) {
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
152 ny = MAX(0, Y_MAX - h);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
153 if (ny != *y) {
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
154 *y = ny;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
155 changed = TRUE;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
156 }
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
157 }
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
158 }
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
159 return changed;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
160 }
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
161
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
162 static void
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
163 refresh_node(GntWidget *widget, GntNode *node, gpointer null)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
164 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
165 int x, y, w, h;
15067
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
166 int nw, nh;
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
167
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
168 int X_MAX = getmaxx(stdscr);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
169 int Y_MAX = getmaxy(stdscr) - 1;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
170
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
171 gnt_widget_get_position(widget, &x, &y);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
172 gnt_widget_get_size(widget, &w, &h);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
173
15067
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
174 if (sanitize_position(widget, &x, &y))
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
175 gnt_screen_move_widget(widget, x, y);
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
176
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
177 nw = MIN(w, X_MAX);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
178 nh = MIN(h, Y_MAX);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
179 if (nw != w || nh != h)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
180 gnt_screen_resize_widget(widget, nw, nh);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
181 }
15067
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
182
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
183 static void
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
184 read_window_positions(GntWM *wm)
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
185 {
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
186 #if GLIB_CHECK_VERSION(2,6,0)
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
187 GKeyFile *gfile = g_key_file_new();
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
188 char *filename = g_build_filename(g_get_home_dir(), ".gntpositions", NULL);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
189 GError *error = NULL;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
190 char **keys;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
191 int nk;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
192
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
193 if (!g_key_file_load_from_file(gfile, filename, G_KEY_FILE_NONE, &error)) {
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
194 g_printerr("GntWM: %s\n", error->message);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
195 g_error_free(error);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
196 g_free(filename);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
197 return;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
198 }
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
199
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
200 keys = g_key_file_get_keys(gfile, "positions", &nk, &error);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
201 if (error) {
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
202 g_printerr("GntWM: %s\n", error->message);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
203 g_error_free(error);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
204 error = NULL;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
205 } else {
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
206 while (nk--) {
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
207 char *title = keys[nk];
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
208 int l;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
209 char **coords = g_key_file_get_string_list(gfile, "positions", title, &l, NULL);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
210 if (l == 2) {
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
211 int x = atoi(coords[0]);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
212 int y = atoi(coords[1]);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
213 GntPosition *p = g_new0(GntPosition, 1);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
214 p->x = x;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
215 p->y = y;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
216 g_hash_table_replace(wm->positions, g_strdup(title + 1), p);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
217 } else {
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
218 g_printerr("GntWM: Invalid number of arguments for positioing a window.\n");
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
219 }
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
220 g_strfreev(coords);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
221 }
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
222 g_strfreev(keys);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
223 }
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
224
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
225 g_free(filename);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
226 #endif
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
227 }
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
228
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
229 static void
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
230 gnt_wm_init(GTypeInstance *instance, gpointer class)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
231 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
232 GntWM *wm = GNT_WM(instance);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
233 wm->list = NULL;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
234 wm->ordered = NULL;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
235 wm->event_stack = FALSE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
236 wm->windows = NULL;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
237 wm->actions = NULL;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
238 wm->nodes = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, free_node);
15067
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
239 wm->positions = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
240 if (gnt_style_get_bool(GNT_STYLE_REMPOS, TRUE))
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
241 read_window_positions(wm);
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
242 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
243
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
244 static void
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
245 switch_window(GntWM *wm, int direction)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
246 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
247 GntWidget *w = NULL, *wid = NULL;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
248 int pos;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
249
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
250 if (wm->_list.window || wm->menu)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
251 return;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
252
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
253 if (!wm->ordered || !wm->ordered->next)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
254 return;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
255
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
256 w = wm->ordered->data;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
257 pos = g_list_index(wm->list, w);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
258 pos += direction;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
259
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
260 if (pos < 0)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
261 wid = g_list_last(wm->list)->data;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
262 else if (pos >= g_list_length(wm->list))
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
263 wid = wm->list->data;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
264 else if (pos >= 0)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
265 wid = g_list_nth_data(wm->list, pos);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
266
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
267 wm->ordered = g_list_bring_to_front(wm->ordered, wid);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
268
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
269 gnt_wm_raise_window(wm, wm->ordered->data);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
270
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
271 if (w != wid) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
272 gnt_widget_set_focus(w, FALSE);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
273 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
274 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
275
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
276 static gboolean
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
277 window_next(GntBindable *bindable, GList *null)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
278 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
279 GntWM *wm = GNT_WM(bindable);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
280 switch_window(wm, 1);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
281 return TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
282 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
283
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
284 static gboolean
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
285 window_prev(GntBindable *bindable, GList *null)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
286 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
287 GntWM *wm = GNT_WM(bindable);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
288 switch_window(wm, -1);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
289 return TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
290 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
291
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
292 static gboolean
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
293 switch_window_n(GntBindable *bind, GList *list)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
294 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
295 GntWM *wm = GNT_WM(bind);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
296 GntWidget *w = NULL;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
297 GList *l;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
298 int n;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
299
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
300 if (!wm->ordered || !list)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
301 return TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
302
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
303 n = GPOINTER_TO_INT(list->data);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
304
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
305 w = wm->ordered->data;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
306
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
307 if ((l = g_list_nth(wm->list, n)) != NULL)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
308 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
309 gnt_wm_raise_window(wm, l->data);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
310 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
311
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
312 if (l && w != l->data)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
313 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
314 gnt_widget_set_focus(w, FALSE);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
315 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
316 return TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
317 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
318 static gboolean
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
319 window_close(GntBindable *bindable, GList *null)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
320 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
321 GntWM *wm = GNT_WM(bindable);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
322
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
323 if (wm->_list.window)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
324 return TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
325
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
326 if (wm->ordered) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
327 gnt_widget_destroy(wm->ordered->data);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
328 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
329
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
330 return TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
331 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
332
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
333 static void
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
334 destroy__list(GntWidget *widget, GntWM *wm)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
335 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
336 wm->_list.window = NULL;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
337 wm->_list.tree = NULL;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
338 wm->windows = NULL;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
339 wm->actions = NULL;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
340 update_screen(wm);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
341 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
342
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
343 static void
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
344 setup__list(GntWM *wm)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
345 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
346 GntWidget *tree, *win;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
347 win = wm->_list.window = gnt_box_new(FALSE, FALSE);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
348 gnt_box_set_toplevel(GNT_BOX(win), TRUE);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
349 gnt_box_set_pad(GNT_BOX(win), 0);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
350 GNT_WIDGET_SET_FLAGS(win, GNT_WIDGET_TRANSIENT);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
351
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
352 tree = wm->_list.tree = gnt_tree_new();
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
353 gnt_box_add_widget(GNT_BOX(win), tree);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
354
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
355 g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(destroy__list), wm);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
356 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
357
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
358 static void
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
359 window_list_activate(GntTree *tree, GntWM *wm)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
360 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
361 GntWidget *widget = gnt_tree_get_selection_data(GNT_TREE(tree));
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
362
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
363 if (!wm->ordered || !widget)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
364 return;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
365
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
366 gnt_widget_destroy(wm->_list.window);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
367 gnt_wm_raise_window(wm, widget);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
368 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
369
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
370 static gboolean
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
371 window_list(GntBindable *bindable, GList *null)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
372 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
373 GntWM *wm = GNT_WM(bindable);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
374 GntWidget *tree, *win;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
375 GList *iter;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
376
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
377 if (wm->_list.window || wm->menu)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
378 return TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
379
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
380 if (!wm->ordered)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
381 return TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
382
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
383 setup__list(wm);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
384 wm->windows = &wm->_list;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
385
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
386 win = wm->windows->window;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
387 tree = wm->windows->tree;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
388
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
389 gnt_box_set_title(GNT_BOX(win), "Window List");
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
390
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
391 for (iter = wm->list; iter; iter = iter->next) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
392 GntBox *box = GNT_BOX(iter->data);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
393
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
394 gnt_tree_add_row_last(GNT_TREE(tree), box,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
395 gnt_tree_create_row(GNT_TREE(tree), box->title), NULL);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
396 update_window_in_list(wm, GNT_WIDGET(box));
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
397 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
398
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
399 gnt_tree_set_selected(GNT_TREE(tree), wm->ordered->data);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
400 g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(window_list_activate), wm);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
401
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
402 gnt_tree_set_col_width(GNT_TREE(tree), 0, getmaxx(stdscr) / 3);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
403 gnt_widget_set_size(tree, 0, getmaxy(stdscr) / 2);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
404 gnt_widget_set_position(win, getmaxx(stdscr) / 3, getmaxy(stdscr) / 4);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
405
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
406 gnt_widget_show(win);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
407 return TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
408 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
409
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
410 static gboolean
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
411 dump_screen(GntBindable *bindable, GList *null)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
412 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
413 int x, y;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
414 chtype old = 0, now = 0;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
415 FILE *file = fopen("dump.html", "w");
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
416
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
417 fprintf(file, "<pre>");
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
418 for (y = 0; y < getmaxy(stdscr); y++) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
419 for (x = 0; x < getmaxx(stdscr); x++) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
420 char ch;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
421 now = mvwinch(curscr, y, x);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
422 ch = now & A_CHARTEXT;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
423 now ^= ch;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
424
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
425 #define CHECK(attr, start, end) \
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
426 do \
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
427 { \
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
428 if (now & attr) \
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
429 { \
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
430 if (!(old & attr)) \
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
431 fprintf(file, start); \
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
432 } \
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
433 else if (old & attr) \
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
434 { \
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
435 fprintf(file, end); \
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
436 } \
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
437 } while (0)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
438
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
439 CHECK(A_BOLD, "<b>", "</b>");
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
440 CHECK(A_UNDERLINE, "<u>", "</u>");
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
441 CHECK(A_BLINK, "<blink>", "</blink>");
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
442
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
443 if ((now & A_COLOR) != (old & A_COLOR) ||
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
444 (now & A_REVERSE) != (old & A_REVERSE))
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
445 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
446 int ret;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
447 short fgp, bgp, r, g, b;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
448 struct
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
449 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
450 int r, g, b;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
451 } fg, bg;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
452
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
453 ret = pair_content(PAIR_NUMBER(now & A_COLOR), &fgp, &bgp);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
454 if (fgp == -1)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
455 fgp = COLOR_BLACK;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
456 if (bgp == -1)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
457 bgp = COLOR_WHITE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
458 if (now & A_REVERSE)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
459 fgp ^= bgp ^= fgp ^= bgp; /* *wink* */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
460 ret = color_content(fgp, &r, &g, &b);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
461 fg.r = r; fg.b = b; fg.g = g;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
462 ret = color_content(bgp, &r, &g, &b);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
463 bg.r = r; bg.b = b; bg.g = g;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
464 #define ADJUST(x) (x = x * 255 / 1000)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
465 ADJUST(fg.r);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
466 ADJUST(fg.g);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
467 ADJUST(fg.b);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
468 ADJUST(bg.r);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
469 ADJUST(bg.b);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
470 ADJUST(bg.g);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
471
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
472 if (x) fprintf(file, "</span>");
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
473 fprintf(file, "<span style=\"background:#%02x%02x%02x;color:#%02x%02x%02x\">",
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
474 bg.r, bg.g, bg.b, fg.r, fg.g, fg.b);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
475 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
476 if (now & A_ALTCHARSET)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
477 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
478 switch (ch)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
479 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
480 case 'q':
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
481 ch = '-'; break;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
482 case 't':
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
483 case 'u':
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
484 case 'x':
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
485 ch = '|'; break;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
486 case 'v':
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
487 case 'w':
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
488 case 'l':
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
489 case 'm':
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
490 case 'k':
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
491 case 'j':
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
492 case 'n':
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
493 ch = '+'; break;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
494 case '-':
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
495 ch = '^'; break;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
496 case '.':
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
497 ch = 'v'; break;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
498 case 'a':
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
499 ch = '#'; break;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
500 default:
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
501 ch = ' '; break;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
502 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
503 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
504 if (ch == '&')
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
505 fprintf(file, "&amp;");
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
506 else if (ch == '<')
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
507 fprintf(file, "&lt;");
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
508 else if (ch == '>')
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
509 fprintf(file, "&gt;");
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
510 else
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
511 fprintf(file, "%c", ch);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
512 old = now;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
513 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
514 fprintf(file, "</span>\n");
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
515 old = 0;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
516 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
517 fprintf(file, "</pre>");
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
518 fclose(file);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
519 return TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
520 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
521
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
522 static void
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
523 shift_window(GntWM *wm, GntWidget *widget, int dir)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
524 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
525 GList *all = wm->list;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
526 GList *list = g_list_find(all, widget);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
527 int length, pos;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
528 if (!list)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
529 return;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
530
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
531 length = g_list_length(all);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
532 pos = g_list_position(all, list);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
533
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
534 pos += dir;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
535 if (dir > 0)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
536 pos++;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
537
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
538 if (pos < 0)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
539 pos = length;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
540 else if (pos > length)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
541 pos = 0;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
542
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
543 all = g_list_insert(all, widget, pos);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
544 all = g_list_delete_link(all, list);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
545 wm->list = all;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
546 draw_taskbar(wm, FALSE);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
547 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
548
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
549 static gboolean
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
550 shift_left(GntBindable *bindable, GList *null)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
551 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
552 GntWM *wm = GNT_WM(bindable);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
553 if (wm->_list.window)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
554 return TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
555
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
556 shift_window(wm, wm->ordered->data, -1);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
557 return TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
558 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
559
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
560 static gboolean
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
561 shift_right(GntBindable *bindable, GList *null)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
562 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
563 GntWM *wm = GNT_WM(bindable);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
564 if (wm->_list.window)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
565 return TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
566
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
567 shift_window(wm, wm->ordered->data, 1);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
568 return TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
569 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
570
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
571 static void
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
572 action_list_activate(GntTree *tree, GntWM *wm)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
573 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
574 GntAction *action = gnt_tree_get_selection_data(tree);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
575 action->callback();
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
576 gnt_widget_destroy(wm->_list.window);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
577 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
578
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
579 static int
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
580 compare_action(gconstpointer p1, gconstpointer p2)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
581 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
582 const GntAction *a1 = p1;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
583 const GntAction *a2 = p2;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
584
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
585 return g_utf8_collate(a1->label, a2->label);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
586 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
587
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
588 static gboolean
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
589 list_actions(GntBindable *bindable, GList *null)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
590 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
591 GntWidget *tree, *win;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
592 GList *iter;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
593 GntWM *wm = GNT_WM(bindable);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
594 if (wm->_list.window || wm->menu)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
595 return TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
596
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
597 if (wm->acts == NULL)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
598 return TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
599
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
600 setup__list(wm);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
601 wm->actions = &wm->_list;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
602
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
603 win = wm->actions->window;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
604 tree = wm->actions->tree;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
605
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
606 gnt_box_set_title(GNT_BOX(win), "Actions");
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
607 GNT_WIDGET_SET_FLAGS(tree, GNT_WIDGET_NO_BORDER);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
608 /* XXX: Do we really want this? */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
609 gnt_tree_set_compare_func(GNT_TREE(tree), compare_action);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
610
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
611 for (iter = wm->acts; iter; iter = iter->next) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
612 GntAction *action = iter->data;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
613 gnt_tree_add_row_last(GNT_TREE(tree), action,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
614 gnt_tree_create_row(GNT_TREE(tree), action->label), NULL);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
615 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
616 g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(action_list_activate), wm);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
617 gnt_widget_set_size(tree, 0, g_list_length(wm->acts));
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
618 gnt_widget_set_position(win, 0, getmaxy(stdscr) - 3 - g_list_length(wm->acts));
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
619
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
620 gnt_widget_show(win);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
621 return TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
622 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
623
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
624 #ifndef NO_WIDECHAR
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
625 static int
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
626 widestringwidth(wchar_t *wide)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
627 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
628 int len, ret;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
629 char *string;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
630
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
631 len = wcstombs(NULL, wide, 0) + 1;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
632 string = g_new0(char, len);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
633 wcstombs(string, wide, len);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
634 ret = gnt_util_onscreen_width(string, NULL);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
635 g_free(string);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
636 return ret;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
637 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
638 #endif
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
639
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
640 /* Returns the onscreen width of the character at the position */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
641 static int
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
642 reverse_char(WINDOW *d, int y, int x, gboolean set)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
643 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
644 #define DECIDE(ch) (set ? ((ch) | A_REVERSE) : ((ch) & ~A_REVERSE))
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
645
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
646 #ifdef NO_WIDECHAR
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
647 chtype ch;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
648 ch = mvwinch(d, y, x);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
649 mvwaddch(d, y, x, DECIDE(ch));
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
650 return 1;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
651 #else
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
652 cchar_t ch;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
653 int wc = 1;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
654 if (mvwin_wch(d, y, x, &ch) == OK) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
655 wc = widestringwidth(ch.chars);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
656 ch.attr = DECIDE(ch.attr);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
657 ch.attr &= WA_ATTRIBUTES; /* XXX: This is a workaround for a bug */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
658 mvwadd_wch(d, y, x, &ch);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
659 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
660
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
661 return wc;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
662 #endif
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
663 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
664
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
665 static void
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
666 window_reverse(GntWidget *win, gboolean set)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
667 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
668 int i;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
669 int w, h;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
670 WINDOW *d;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
671
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
672 if (GNT_WIDGET_IS_FLAG_SET(win, GNT_WIDGET_NO_BORDER))
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
673 return;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
674
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
675 d = win->window;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
676 gnt_widget_get_size(win, &w, &h);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
677
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
678 if (gnt_widget_has_shadow(win)) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
679 --w;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
680 --h;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
681 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
682
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
683 /* the top and bottom */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
684 for (i = 0; i < w; i += reverse_char(d, 0, i, set));
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
685 for (i = 0; i < w; i += reverse_char(d, h-1, i, set));
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
686
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
687 /* the left and right */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
688 for (i = 0; i < h; i += reverse_char(d, i, 0, set));
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
689 for (i = 0; i < h; i += reverse_char(d, i, w-1, set));
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
690
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
691 wrefresh(win->window);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
692 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
693
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
694 static gboolean
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
695 start_move(GntBindable *bindable, GList *null)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
696 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
697 GntWM *wm = GNT_WM(bindable);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
698 if (wm->_list.window || wm->menu)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
699 return TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
700 if (!wm->ordered)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
701 return TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
702
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
703 wm->mode = GNT_KP_MODE_MOVE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
704 window_reverse(GNT_WIDGET(wm->ordered->data), TRUE);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
705
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
706 return TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
707 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
708
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
709 static gboolean
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
710 start_resize(GntBindable *bindable, GList *null)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
711 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
712 GntWM *wm = GNT_WM(bindable);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
713 if (wm->_list.window || wm->menu)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
714 return TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
715 if (!wm->ordered)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
716 return TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
717
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
718 wm->mode = GNT_KP_MODE_RESIZE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
719 window_reverse(GNT_WIDGET(wm->ordered->data), TRUE);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
720
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
721 return TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
722 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
723
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
724 static gboolean
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
725 wm_quit(GntBindable *bindable, GList *list)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
726 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
727 GntWM *wm = GNT_WM(bindable);
15067
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
728 if (write_timeout)
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
729 write_already(wm);
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
730 g_main_loop_quit(wm->loop);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
731 return TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
732 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
733
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
734 static gboolean
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
735 return_true(GntWM *wm, GntWidget *w, int *a, int *b)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
736 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
737 return TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
738 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
739
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
740 static gboolean
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
741 refresh_screen(GntBindable *bindable, GList *null)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
742 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
743 GntWM *wm = GNT_WM(bindable);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
744
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
745 endwin();
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
746 refresh();
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
747
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
748 g_hash_table_foreach(wm->nodes, (GHFunc)refresh_node, NULL);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
749 update_screen(wm);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
750 draw_taskbar(wm, TRUE);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
751
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
752 return FALSE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
753 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
754
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
755 static void
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
756 gnt_wm_class_init(GntWMClass *klass)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
757 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
758 klass->new_window = gnt_wm_new_window_real;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
759 klass->decorate_window = NULL;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
760 klass->close_window = NULL;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
761 klass->window_resize_confirm = return_true;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
762 klass->window_resized = gnt_wm_win_resized;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
763 klass->window_move_confirm = return_true;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
764 klass->window_moved = gnt_wm_win_moved;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
765 klass->window_update = NULL;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
766 klass->key_pressed = NULL;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
767 klass->mouse_clicked = NULL;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
768 klass->give_focus = gnt_wm_give_focus;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
769
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
770 signals[SIG_NEW_WIN] =
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
771 g_signal_new("new_win",
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
772 G_TYPE_FROM_CLASS(klass),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
773 G_SIGNAL_RUN_LAST,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
774 G_STRUCT_OFFSET(GntWMClass, new_window),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
775 NULL, NULL,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
776 g_cclosure_marshal_VOID__POINTER,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
777 G_TYPE_NONE, 1, G_TYPE_POINTER);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
778 signals[SIG_DECORATE_WIN] =
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
779 g_signal_new("decorate_win",
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
780 G_TYPE_FROM_CLASS(klass),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
781 G_SIGNAL_RUN_LAST,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
782 G_STRUCT_OFFSET(GntWMClass, decorate_window),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
783 NULL, NULL,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
784 g_cclosure_marshal_VOID__POINTER,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
785 G_TYPE_NONE, 1, G_TYPE_POINTER);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
786 signals[SIG_CLOSE_WIN] =
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
787 g_signal_new("close_win",
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
788 G_TYPE_FROM_CLASS(klass),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
789 G_SIGNAL_RUN_LAST,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
790 G_STRUCT_OFFSET(GntWMClass, close_window),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
791 NULL, NULL,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
792 g_cclosure_marshal_VOID__POINTER,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
793 G_TYPE_NONE, 1, G_TYPE_POINTER);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
794 signals[SIG_CONFIRM_RESIZE] =
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
795 g_signal_new("confirm_resize",
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
796 G_TYPE_FROM_CLASS(klass),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
797 G_SIGNAL_RUN_LAST,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
798 G_STRUCT_OFFSET(GntWMClass, window_resize_confirm),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
799 gnt_boolean_handled_accumulator, NULL,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
800 gnt_closure_marshal_BOOLEAN__POINTER_POINTER_POINTER,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
801 G_TYPE_BOOLEAN, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
802
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
803 signals[SIG_CONFIRM_MOVE] =
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
804 g_signal_new("confirm_move",
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
805 G_TYPE_FROM_CLASS(klass),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
806 G_SIGNAL_RUN_LAST,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
807 G_STRUCT_OFFSET(GntWMClass, window_move_confirm),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
808 gnt_boolean_handled_accumulator, NULL,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
809 gnt_closure_marshal_BOOLEAN__POINTER_POINTER_POINTER,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
810 G_TYPE_BOOLEAN, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
811
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
812 signals[SIG_RESIZED] =
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
813 g_signal_new("window_resized",
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
814 G_TYPE_FROM_CLASS(klass),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
815 G_SIGNAL_RUN_LAST,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
816 G_STRUCT_OFFSET(GntWMClass, window_resized),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
817 NULL, NULL,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
818 g_cclosure_marshal_VOID__POINTER,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
819 G_TYPE_NONE, 1, G_TYPE_POINTER);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
820 signals[SIG_MOVED] =
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
821 g_signal_new("window_moved",
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
822 G_TYPE_FROM_CLASS(klass),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
823 G_SIGNAL_RUN_LAST,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
824 G_STRUCT_OFFSET(GntWMClass, window_moved),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
825 NULL, NULL,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
826 g_cclosure_marshal_VOID__POINTER,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
827 G_TYPE_NONE, 1, G_TYPE_POINTER);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
828 signals[SIG_UPDATE_WIN] =
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
829 g_signal_new("window_update",
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
830 G_TYPE_FROM_CLASS(klass),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
831 G_SIGNAL_RUN_LAST,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
832 G_STRUCT_OFFSET(GntWMClass, window_update),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
833 NULL, NULL,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
834 g_cclosure_marshal_VOID__POINTER,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
835 G_TYPE_NONE, 1, G_TYPE_POINTER);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
836
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
837 signals[SIG_GIVE_FOCUS] =
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
838 g_signal_new("give_focus",
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
839 G_TYPE_FROM_CLASS(klass),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
840 G_SIGNAL_RUN_LAST,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
841 G_STRUCT_OFFSET(GntWMClass, give_focus),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
842 NULL, NULL,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
843 g_cclosure_marshal_VOID__POINTER,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
844 G_TYPE_NONE, 1, G_TYPE_POINTER);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
845
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
846 signals[SIG_MOUSE_CLICK] =
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
847 g_signal_new("mouse_clicked",
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
848 G_TYPE_FROM_CLASS(klass),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
849 G_SIGNAL_RUN_LAST,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
850 G_STRUCT_OFFSET(GntWMClass, mouse_clicked),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
851 gnt_boolean_handled_accumulator, NULL,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
852 gnt_closure_marshal_BOOLEAN__INT_INT_INT_POINTER,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
853 G_TYPE_BOOLEAN, 4, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_POINTER);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
854
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
855 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-next", window_next,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
856 "\033" "n", NULL);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
857 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-prev", window_prev,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
858 "\033" "p", NULL);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
859 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-close", window_close,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
860 "\033" "c", NULL);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
861 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-list", window_list,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
862 "\033" "w", NULL);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
863 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "dump-screen", dump_screen,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
864 "\033" "d", NULL);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
865 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "shift-left", shift_left,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
866 "\033" ",", NULL);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
867 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "shift-right", shift_right,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
868 "\033" ".", NULL);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
869 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "action-list", list_actions,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
870 "\033" "a", NULL);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
871 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "start-move", start_move,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
872 "\033" "m", NULL);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
873 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "start-resize", start_resize,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
874 "\033" "r", NULL);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
875 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "wm-quit", wm_quit,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
876 "\033" "q", NULL);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
877 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "refresh-screen", refresh_screen,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
878 "\033" "l", NULL);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
879 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "switch-window-n", switch_window_n,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
880 NULL, NULL);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
881
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
882 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass));
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
883 GNTDEBUG;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
884 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
885
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
886 /******************************************************************************
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
887 * GntWM API
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
888 *****************************************************************************/
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
889 GType
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
890 gnt_wm_get_gtype(void)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
891 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
892 static GType type = 0;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
893
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
894 if(type == 0) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
895 static const GTypeInfo info = {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
896 sizeof(GntWMClass),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
897 NULL, /* base_init */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
898 NULL, /* base_finalize */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
899 (GClassInitFunc)gnt_wm_class_init,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
900 NULL,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
901 NULL, /* class_data */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
902 sizeof(GntWM),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
903 0, /* n_preallocs */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
904 gnt_wm_init, /* instance_init */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
905 };
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
906
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
907 type = g_type_register_static(GNT_TYPE_BINDABLE,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
908 "GntWM",
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
909 &info, 0);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
910 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
911
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
912 return type;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
913 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
914 static void
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
915 update_window_in_list(GntWM *wm, GntWidget *wid)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
916 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
917 GntTextFormatFlags flag = 0;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
918
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
919 if (wm->windows == NULL)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
920 return;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
921
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
922 if (wid == wm->ordered->data)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
923 flag |= GNT_TEXT_FLAG_DIM;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
924 else if (GNT_WIDGET_IS_FLAG_SET(wid, GNT_WIDGET_URGENT))
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
925 flag |= GNT_TEXT_FLAG_BOLD;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
926
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
927 gnt_tree_set_row_flags(GNT_TREE(wm->windows->tree), wid, flag);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
928 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
929
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
930 static void
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
931 gnt_wm_new_window_real(GntWM *wm, GntWidget *widget)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
932 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
933 GntNode *node;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
934 gboolean transient = FALSE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
935
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
936 if (widget->window == NULL)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
937 return;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
938
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
939 node = g_new0(GntNode, 1);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
940 node->me = widget;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
941
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
942 g_hash_table_replace(wm->nodes, widget, node);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
943
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
944 refresh_node(widget, node, NULL);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
945
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
946 transient = !!GNT_WIDGET_IS_FLAG_SET(node->me, GNT_WIDGET_TRANSIENT);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
947
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
948 node->panel = new_panel(node->me->window);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
949 set_panel_userptr(node->panel, node);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
950
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
951 if (!transient) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
952 if (node->me != wm->_list.window) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
953 GntWidget *w = NULL;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
954
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
955 if (wm->ordered)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
956 w = wm->ordered->data;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
957
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
958 wm->list = g_list_append(wm->list, widget);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
959
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
960 if (wm->event_stack)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
961 wm->ordered = g_list_prepend(wm->ordered, widget);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
962 else
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
963 wm->ordered = g_list_append(wm->ordered, widget);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
964
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
965 gnt_widget_set_focus(widget, TRUE);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
966 if (w)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
967 gnt_widget_set_focus(w, FALSE);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
968 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
969
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
970 if (wm->event_stack || node->me == wm->_list.window) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
971 gnt_wm_raise_window(wm, node->me);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
972 } else {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
973 bottom_panel(node->panel); /* New windows should not grab focus */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
974 gnt_widget_set_urgent(node->me);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
975 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
976 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
977 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
978
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
979 void gnt_wm_new_window(GntWM *wm, GntWidget *widget)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
980 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
981 while (widget->parent)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
982 widget = widget->parent;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
983
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
984 if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_INVISIBLE) ||
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
985 g_hash_table_lookup(wm->nodes, widget)) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
986 update_screen(wm);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
987 return;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
988 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
989
15067
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
990 if (GNT_IS_BOX(widget)) {
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
991 const char *title = GNT_BOX(widget)->title;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
992 GntPosition *p = NULL;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
993 if (title && (p = g_hash_table_lookup(wm->positions, title)) != NULL) {
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
994 sanitize_position(widget, &p->x, &p->y);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
995 gnt_widget_set_position(widget, p->x, p->y);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
996 mvwin(widget->window, p->y, p->x);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
997 }
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
998 }
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
999
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1000 g_signal_emit(wm, signals[SIG_NEW_WIN], 0, widget);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1001 g_signal_emit(wm, signals[SIG_DECORATE_WIN], 0, widget);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1002
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1003 if (wm->windows && !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_TRANSIENT)) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1004 if ((GNT_IS_BOX(widget) && GNT_BOX(widget)->title) && wm->_list.window != widget
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1005 && GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_CAN_TAKE_FOCUS)) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1006 gnt_tree_add_row_last(GNT_TREE(wm->windows->tree), widget,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1007 gnt_tree_create_row(GNT_TREE(wm->windows->tree), GNT_BOX(widget)->title),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1008 NULL);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1009 update_window_in_list(wm, widget);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1010 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1011 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1012
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1013 update_screen(wm);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1014 draw_taskbar(wm, FALSE);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1015 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1016
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1017 void gnt_wm_window_decorate(GntWM *wm, GntWidget *widget)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1018 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1019 g_signal_emit(wm, signals[SIG_DECORATE_WIN], 0, widget);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1020 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1021
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1022 void gnt_wm_window_close(GntWM *wm, GntWidget *widget)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1023 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1024 GntNode *node;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1025 int pos;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1026
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1027 if ((node = g_hash_table_lookup(wm->nodes, widget)) == NULL)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1028 return;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1029
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1030 g_signal_emit(wm, signals[SIG_CLOSE_WIN], 0, widget);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1031 g_hash_table_remove(wm->nodes, widget);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1032
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1033 if (wm->windows) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1034 gnt_tree_remove(GNT_TREE(wm->windows->tree), widget);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1035 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1036
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1037 pos = g_list_index(wm->list, widget);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1038
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1039 if (pos != -1) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1040 wm->list = g_list_remove(wm->list, widget);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1041 wm->ordered = g_list_remove(wm->ordered, widget);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1042
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1043 if (wm->ordered)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1044 gnt_wm_raise_window(wm, wm->ordered->data);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1045 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1046
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1047 update_screen(wm);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1048 draw_taskbar(wm, FALSE);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1049 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1050
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1051 void gnt_wm_process_input(GntWM *wm, const char *keys)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1052 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1053 keys = gnt_bindable_remap_keys(GNT_BINDABLE(wm), keys);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1054
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1055 if (gnt_bindable_perform_action_key(GNT_BINDABLE(wm), keys))
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1056 return;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1057
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1058 /* Do some manual checking */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1059 if (wm->ordered && wm->mode != GNT_KP_MODE_NORMAL) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1060 int xmin = 0, ymin = 0, xmax = getmaxx(stdscr), ymax = getmaxy(stdscr) - 1;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1061 int x, y, w, h;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1062 GntWidget *widget = GNT_WIDGET(wm->ordered->data);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1063 int ox, oy, ow, oh;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1064
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1065 gnt_widget_get_position(widget, &x, &y);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1066 gnt_widget_get_size(widget, &w, &h);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1067 ox = x; oy = y;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1068 ow = w; oh = h;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1069
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1070 if (wm->mode == GNT_KP_MODE_MOVE) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1071 if (strcmp(keys, GNT_KEY_LEFT) == 0) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1072 if (x > xmin)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1073 x--;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1074 } else if (strcmp(keys, GNT_KEY_RIGHT) == 0) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1075 if (x + w < xmax)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1076 x++;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1077 } else if (strcmp(keys, GNT_KEY_UP) == 0) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1078 if (y > ymin)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1079 y--;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1080 } else if (strcmp(keys, GNT_KEY_DOWN) == 0) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1081 if (y + h < ymax)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1082 y++;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1083 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1084 if (ox != x || oy != y) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1085 gnt_screen_move_widget(widget, x, y);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1086 window_reverse(widget, TRUE);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1087 return;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1088 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1089 } else if (wm->mode == GNT_KP_MODE_RESIZE) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1090 if (strcmp(keys, GNT_KEY_LEFT) == 0) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1091 w--;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1092 } else if (strcmp(keys, GNT_KEY_RIGHT) == 0) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1093 if (x + w < xmax)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1094 w++;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1095 } else if (strcmp(keys, GNT_KEY_UP) == 0) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1096 h--;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1097 } else if (strcmp(keys, GNT_KEY_DOWN) == 0) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1098 if (y + h < ymax)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1099 h++;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1100 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1101 if (oh != h || ow != w) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1102 gnt_screen_resize_widget(widget, w, h);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1103 window_reverse(widget, TRUE);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1104 return;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1105 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1106 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1107 if (strcmp(keys, "\r") == 0 || strcmp(keys, "\033") == 0) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1108 window_reverse(widget, FALSE);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1109 wm->mode = GNT_KP_MODE_NORMAL;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1110 }
14958
c9c1ce4a70b6 [gaim-migrate @ 17737]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14904
diff changeset
1111 return;
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1112 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1113
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1114 wm->event_stack = TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1115
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1116 /* Escape to close the window-list or action-list window */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1117 if (strcmp(keys, "\033") == 0) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1118 if (wm->_list.window) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1119 gnt_widget_destroy(wm->_list.window);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1120 wm->event_stack = FALSE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1121 return;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1122 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1123 } else if (keys[0] == '\033' && isdigit(keys[1]) && keys[2] == '\0') {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1124 /* Alt+x for quick switch */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1125 int n = *(keys + 1) - '0';
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1126 GList *list = NULL;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1127
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1128 if (n == 0)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1129 n = 10;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1130
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1131 list = g_list_append(list, GINT_TO_POINTER(n - 1));
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1132 switch_window_n(GNT_BINDABLE(wm), list);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1133 g_list_free(list);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1134 return;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1135 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1136
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1137 if (wm->menu)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1138 gnt_widget_key_pressed(GNT_WIDGET(wm->menu), keys);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1139 else if (wm->_list.window)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1140 gnt_widget_key_pressed(wm->_list.window, keys);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1141 else if (wm->ordered)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1142 gnt_widget_key_pressed(GNT_WIDGET(wm->ordered->data), keys);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1143 wm->event_stack = FALSE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1144 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1145
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1146 static void
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1147 gnt_wm_win_resized(GntWM *wm, GntNode *node)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1148 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1149 refresh_node(node->me, node, NULL);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1150 replace_panel(node->panel, node->me->window);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1151 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1152
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1153 static void
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1154 gnt_wm_win_moved(GntWM *wm, GntNode *node)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1155 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1156 refresh_node(node->me, node, NULL);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1157 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1158
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1159 void gnt_wm_resize_window(GntWM *wm, GntWidget *widget, int width, int height)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1160 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1161 gboolean ret = TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1162 GntNode *node;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1163
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1164 while (widget->parent)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1165 widget = widget->parent;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1166 node = g_hash_table_lookup(wm->nodes, widget);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1167 if (!node)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1168 return;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1169
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1170 g_signal_emit(wm, signals[SIG_CONFIRM_RESIZE], 0, widget, &width, &height, &ret);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1171 if (!ret)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1172 return; /* resize is not permitted */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1173 hide_panel(node->panel);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1174 gnt_widget_set_size(widget, width, height);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1175 gnt_widget_draw(widget);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1176
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1177 g_signal_emit(wm, signals[SIG_RESIZED], 0, node);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1178
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1179 show_panel(node->panel);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1180 update_screen(wm);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1181 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1182
15067
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1183 static void
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1184 write_gdi(gpointer key, gpointer value, gpointer data)
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1185 {
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1186 GntPosition *p = value;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1187 fprintf(data, ".%s = %d;%d\n", key, p->x, p->y);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1188 }
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1189
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1190 static gboolean
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1191 write_already(gpointer data)
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1192 {
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1193 GntWM *wm = data;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1194 FILE *file;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1195 char *filename;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1196
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1197 filename = g_build_filename(g_get_home_dir(), ".gntpositions", NULL);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1198
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1199 file = fopen(filename, "wb");
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1200 if (file == NULL) {
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1201 g_printerr("GntWM: error opening file to save positions\n");
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1202 } else {
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1203 fprintf(file, "[positions]\n");
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1204 g_hash_table_foreach(wm->positions, write_gdi, file);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1205 fclose(file);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1206 }
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1207
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1208 g_free(filename);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1209 g_source_remove(write_timeout);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1210 write_timeout = 0;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1211 return FALSE;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1212 }
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1213
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1214 static void
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1215 write_positions_to_file(GntWM *wm)
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1216 {
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1217 if (write_timeout) {
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1218 g_source_remove(write_timeout);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1219 }
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1220 write_timeout = g_timeout_add(10000, write_already, wm);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1221 }
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1222
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1223 void gnt_wm_move_window(GntWM *wm, GntWidget *widget, int x, int y)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1224 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1225 gboolean ret = TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1226 GntNode *node;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1227
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1228 while (widget->parent)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1229 widget = widget->parent;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1230 node = g_hash_table_lookup(wm->nodes, widget);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1231 if (!node)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1232 return;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1233
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1234 g_signal_emit(wm, signals[SIG_CONFIRM_MOVE], 0, widget, &x, &y, &ret);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1235 if (!ret)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1236 return; /* resize is not permitted */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1237
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1238 gnt_widget_set_position(widget, x, y);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1239 move_panel(node->panel, y, x);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1240
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1241 g_signal_emit(wm, signals[SIG_MOVED], 0, node);
15067
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1242 if (gnt_style_get_bool(GNT_STYLE_REMPOS, TRUE) && GNT_IS_BOX(widget)) {
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1243 const char *title = GNT_BOX(widget)->title;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1244 if (title) {
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1245 GntPosition *p = g_new0(GntPosition, 1);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1246 GntWidget *wid = node->me;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1247 p->x = wid->priv.x;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1248 p->y = wid->priv.y;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1249 g_hash_table_replace(wm->positions, g_strdup(title), p);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1250 write_positions_to_file(wm);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1251 }
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14958
diff changeset
1252 }
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1253
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1254 update_screen(wm);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1255 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1256
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1257 static void
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1258 gnt_wm_give_focus(GntWM *wm, GntWidget *widget)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1259 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1260 GntNode *node = g_hash_table_lookup(wm->nodes, widget);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1261
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1262 if (!node)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1263 return;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1264
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1265 if (widget != wm->_list.window && !GNT_IS_MENU(widget) &&
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1266 wm->ordered->data != widget) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1267 GntWidget *w = wm->ordered->data;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1268 wm->ordered = g_list_bring_to_front(wm->ordered, widget);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1269 gnt_widget_set_focus(w, FALSE);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1270 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1271
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1272 gnt_widget_set_focus(widget, TRUE);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1273 GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_URGENT);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1274 gnt_widget_draw(widget);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1275 top_panel(node->panel);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1276
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1277 if (wm->_list.window) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1278 GntNode *nd = g_hash_table_lookup(wm->nodes, wm->_list.window);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1279 top_panel(nd->panel);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1280 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1281 update_screen(wm);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1282 draw_taskbar(wm, FALSE);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1283 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1284
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1285 void gnt_wm_update_window(GntWM *wm, GntWidget *widget)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1286 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1287 GntNode *node;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1288
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1289 while (widget->parent)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1290 widget = widget->parent;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1291 if (!GNT_IS_MENU(widget))
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1292 gnt_box_sync_children(GNT_BOX(widget));
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1293
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1294 node = g_hash_table_lookup(wm->nodes, widget);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1295 if (node == NULL) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1296 gnt_wm_new_window(wm, widget);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1297 } else
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1298 g_signal_emit(wm, signals[SIG_UPDATE_WIN], 0, node);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1299
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1300 update_screen(wm);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1301 draw_taskbar(wm, FALSE);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1302 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1303
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1304 gboolean gnt_wm_process_click(GntWM *wm, GntMouseEvent event, int x, int y, GntWidget *widget)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1305 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1306 gboolean ret = TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1307 g_signal_emit(wm, signals[SIG_MOUSE_CLICK], 0, event, x, y, widget, &ret);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1308 return ret;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1309 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1310
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1311 void gnt_wm_raise_window(GntWM *wm, GntWidget *widget)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1312 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1313 g_signal_emit(wm, signals[SIG_GIVE_FOCUS], 0, widget);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1314 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1315