Mercurial > pidgin
comparison finch/libgnt/wms/irssi.c @ 17991:386047fb178b
Draw a separator line between the buddylist and the conversation windows.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 02 Jun 2007 06:39:02 +0000 |
parents | 1bccb9641ef3 |
children | 08e93462f189 |
comparison
equal
deleted
inserted
replaced
17990:8ca45d6a1281 | 17991:386047fb178b |
---|---|
33 GType irssi_get_gtype(void); | 33 GType irssi_get_gtype(void); |
34 void gntwm_init(GntWM **wm); | 34 void gntwm_init(GntWM **wm); |
35 | 35 |
36 static void (*org_new_window)(GntWM *wm, GntWidget *win); | 36 static void (*org_new_window)(GntWM *wm, GntWidget *win); |
37 | 37 |
38 static GntWidget * | 38 /* This is changed whenever the buddylist is opened/closed or resized. */ |
39 find_widget(GntWM *wm, const char *wname) | 39 static int buddylistwidth; |
40 | |
41 static gboolean | |
42 is_budddylist(GntWidget *win) | |
40 { | 43 { |
41 const GList *iter = wm->list; | 44 const char *name = gnt_widget_get_name(win); |
42 for (; iter; iter = iter->next) { | 45 if (name && strcmp(name, "buddylist") == 0) |
43 GntWidget *widget = iter->data; | 46 return TRUE; |
44 const char *name = gnt_widget_get_name(widget); | 47 return FALSE; |
45 if (name && strcmp(name, wname) == 0) { | |
46 return widget; | |
47 } | |
48 } | |
49 return NULL; | |
50 } | 48 } |
51 | 49 |
52 static void | 50 static void |
53 remove_border_set_position_size(GntWM *wm, GntWidget *win, int x, int y, int w, int h) | 51 remove_border_set_position_size(GntWM *wm, GntWidget *win, int x, int y, int w, int h) |
54 { | 52 { |
62 | 60 |
63 static void | 61 static void |
64 irssi_new_window(GntWM *wm, GntWidget *win) | 62 irssi_new_window(GntWM *wm, GntWidget *win) |
65 { | 63 { |
66 const char *name; | 64 const char *name; |
67 int bw; | |
68 GntWidget *blist; | |
69 | 65 |
70 name = gnt_widget_get_name(win); | 66 name = gnt_widget_get_name(win); |
71 if (!name || strcmp(name, "conversation-window")) { | 67 if (!name || strcmp(name, "conversation-window")) { |
72 if (!GNT_IS_MENU(win) && !GNT_WIDGET_IS_FLAG_SET(win, GNT_WIDGET_TRANSIENT)) { | 68 if (!GNT_IS_MENU(win) && !GNT_WIDGET_IS_FLAG_SET(win, GNT_WIDGET_TRANSIENT)) { |
73 if ((!name || strcmp(name, "buddylist"))) { | 69 if ((!name || strcmp(name, "buddylist"))) { |
77 y = (getmaxy(stdscr) - h) / 2; | 73 y = (getmaxy(stdscr) - h) / 2; |
78 gnt_widget_set_position(win, x, y); | 74 gnt_widget_set_position(win, x, y); |
79 mvwin(win->window, y, x); | 75 mvwin(win->window, y, x); |
80 } else { | 76 } else { |
81 remove_border_set_position_size(wm, win, 0, 0, -1, getmaxy(stdscr) - 1); | 77 remove_border_set_position_size(wm, win, 0, 0, -1, getmaxy(stdscr) - 1); |
78 gnt_widget_get_size(win, &buddylistwidth, NULL); | |
79 mvwvline(stdscr, 0, buddylistwidth, ACS_VLINE | COLOR_PAIR(GNT_COLOR_NORMAL), getmaxy(stdscr) - 1); | |
80 buddylistwidth++; | |
82 } | 81 } |
83 } | 82 } |
84 org_new_window(wm, win); | 83 org_new_window(wm, win); |
85 return; | 84 return; |
86 } | 85 } |
87 | 86 |
88 blist = find_widget(wm, "buddylist"); | 87 /* The window we have here is a conversation window. */ |
89 if (blist) { | 88 remove_border_set_position_size(wm, win, buddylistwidth, 0, |
90 gnt_widget_get_size(blist, &bw, NULL); | 89 getmaxx(stdscr) - buddylistwidth, getmaxy(stdscr) - 1); |
91 bw++; | 90 org_new_window(wm, win); |
92 } else { | 91 } |
93 bw = 0; | |
94 } | |
95 | 92 |
96 /* The window we have here is a conversation window. */ | 93 static void |
97 remove_border_set_position_size(wm, win, bw, 0, getmaxx(stdscr) - bw, getmaxy(stdscr) - 1); | 94 irssi_window_resized(GntWM *wm, GntNode *node) |
98 org_new_window(wm, win); | 95 { |
96 if (!is_budddylist(node->me)) | |
97 return; | |
98 | |
99 if (buddylistwidth) | |
100 mvwvline(stdscr, 0, buddylistwidth - 1, | |
101 ' ' | COLOR_PAIR(GNT_COLOR_NORMAL), getmaxy(stdscr) - 1); | |
102 gnt_widget_get_size(node->me, &buddylistwidth, NULL); | |
103 mvwvline(stdscr, 0, buddylistwidth, ACS_VLINE | COLOR_PAIR(GNT_COLOR_NORMAL), getmaxy(stdscr) - 1); | |
104 buddylistwidth++; | |
105 } | |
106 | |
107 static gboolean | |
108 irssi_close_window(GntWM *wm, GntWidget *win) | |
109 { | |
110 if (is_budddylist(win)) | |
111 buddylistwidth = 0; | |
112 return FALSE; | |
99 } | 113 } |
100 | 114 |
101 static void | 115 static void |
102 irssi_class_init(IrssiClass *klass) | 116 irssi_class_init(IrssiClass *klass) |
103 { | 117 { |
104 GntWMClass *pclass = GNT_WM_CLASS(klass); | 118 GntWMClass *pclass = GNT_WM_CLASS(klass); |
105 | 119 |
106 org_new_window = pclass->new_window; | 120 org_new_window = pclass->new_window; |
107 | 121 |
108 pclass->new_window = irssi_new_window; | 122 pclass->new_window = irssi_new_window; |
123 pclass->window_resized = irssi_window_resized; | |
124 pclass->close_window = irssi_close_window; | |
109 | 125 |
110 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass)); | 126 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass)); |
111 GNTDEBUG; | 127 GNTDEBUG; |
112 } | 128 } |
113 | 129 |
114 void gntwm_init(GntWM **wm) | 130 void gntwm_init(GntWM **wm) |
115 { | 131 { |
132 buddylistwidth = 0; | |
116 *wm = g_object_new(TYPE_IRSSI, NULL); | 133 *wm = g_object_new(TYPE_IRSSI, NULL); |
117 } | 134 } |
118 | 135 |
119 GType irssi_get_gtype(void) | 136 GType irssi_get_gtype(void) |
120 { | 137 { |