Mercurial > pidgin
comparison console/libgnt/wms/s.c @ 14343:0387a167f342
[gaim-migrate @ 17044]
A WM can now act on keystrokes. As an example, the sample WM will toggle
the buddylist on pressing Alt+b.
Mouse clicking and scrolling is now supported in most/all widgets.
To use a WM, you need to add "wm=/path/to/wm.so" under [general] in ~/.gntrc.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 26 Aug 2006 12:54:39 +0000 |
parents | b1b76fb9c739 |
children | 665b814f8fd7 |
comparison
equal
deleted
inserted
replaced
14342:12156328fb4f | 14343:0387a167f342 |
---|---|
1 #include "gntbox.h" | 1 #include "gntbox.h" |
2 #include "gntwm.h" | 2 #include "gntwm.h" |
3 | 3 |
4 #include "gntblist.h" | |
5 | |
4 #include <string.h> | 6 #include <string.h> |
7 | |
8 static GntWM *gwm; | |
5 | 9 |
6 static PANEL * | 10 static PANEL * |
7 s_new_window(GntWidget *win) | 11 s_new_window(GntWidget *win) |
8 { | 12 { |
9 int x, y, w, h; | 13 int x, y, w, h; |
29 | 33 |
30 gnt_widget_set_position(win, x, y); | 34 gnt_widget_set_position(win, x, y); |
31 mvwin(win->window, y, x); | 35 mvwin(win->window, y, x); |
32 | 36 |
33 gnt_widget_set_size(win, w, h); | 37 gnt_widget_set_size(win, w, h); |
38 gnt_widget_draw(win); | |
34 } else if (name && strcmp(name, "conversation-window") == 0) { | 39 } else if (name && strcmp(name, "conversation-window") == 0) { |
35 /* Put the conversation windows to the far-right */ | 40 /* Put the conversation windows to the far-right */ |
36 x = maxx - w; | 41 x = maxx - w; |
37 y = 0; | 42 y = 0; |
38 gnt_widget_set_position(win, x, y); | 43 gnt_widget_set_position(win, x, y); |
39 mvwin(win->window, y, x); | 44 mvwin(win->window, y, x); |
45 gnt_widget_draw(win); | |
40 } else if (!GNT_WIDGET_IS_FLAG_SET(win, GNT_WIDGET_TRANSIENT)) { | 46 } else if (!GNT_WIDGET_IS_FLAG_SET(win, GNT_WIDGET_TRANSIENT)) { |
41 /* In the middle of the screen */ | 47 /* In the middle of the screen */ |
42 x = (maxx - w) / 2; | 48 x = (maxx - w) / 2; |
43 y = (maxy - h) / 2; | 49 y = (maxy - h) / 2; |
44 | 50 |
47 } | 53 } |
48 | 54 |
49 return new_panel(win->window); | 55 return new_panel(win->window); |
50 } | 56 } |
51 | 57 |
58 static GntWidget * | |
59 find_widget(const char *wname) | |
60 { | |
61 const GList *iter = gwm->window_list(); | |
62 for (; iter; iter = iter->next) { | |
63 GntWidget *widget = iter->data; | |
64 const char *name = gnt_widget_get_name(widget); | |
65 if (name && strcmp(name, wname) == 0) { | |
66 return widget; | |
67 } | |
68 } | |
69 return NULL; | |
70 } | |
71 | |
72 static const char* | |
73 s_key_pressed(const char *key) | |
74 { | |
75 /* Alt+b to toggle the buddylist */ | |
76 if (key[0] == 27 && key[1] == 'b' && key[2] == '\0') { | |
77 GntWidget *w = find_widget("buddylist"); | |
78 if (w == NULL) { | |
79 gg_blist_show(); | |
80 w = find_widget("buddylist"); | |
81 gwm->give_focus(w); | |
82 } else { | |
83 gnt_widget_destroy(w); | |
84 } | |
85 return NULL; | |
86 } | |
87 return key; | |
88 } | |
89 | |
52 void gntwm_init(GntWM *wm) | 90 void gntwm_init(GntWM *wm) |
53 { | 91 { |
92 gwm = wm; | |
54 wm->new_window = s_new_window; | 93 wm->new_window = s_new_window; |
94 wm->key_pressed = s_key_pressed; | |
55 } | 95 } |
56 | 96 |