Mercurial > pidgin
comparison finch/libgnt/gntwm.c @ 26162:0a19fa42f8ce
propagate from branch 'im.pidgin.pidgin' (head eeaad582dcb34b6753c78371c4aa03af92b095f5)
to branch 'im.pidgin.soc.2008.yahoo' (head 182668e30410a6c12e970fad010f219ee6b59e73)
author | Sulabh Mahajan <sulabh@soc.pidgin.im> |
---|---|
date | Tue, 20 Jan 2009 17:44:36 +0000 |
parents | ea28a7b9113c |
children | 9bd43d30d49a |
comparison
equal
deleted
inserted
replaced
26161:90ffe6f71fa9 | 26162:0a19fa42f8ce |
---|---|
24 | 24 |
25 #ifdef USE_PYTHON | 25 #ifdef USE_PYTHON |
26 #include <Python.h> | 26 #include <Python.h> |
27 #else | 27 #else |
28 #define _GNU_SOURCE | 28 #define _GNU_SOURCE |
29 #if (defined(__APPLE__) || defined(__unix__)) && !defined(__FreeBSD__) | 29 #if (defined(__APPLE__) || defined(__unix__)) && !defined(__FreeBSD__) && !defined(__OpenBSD__) |
30 #define _XOPEN_SOURCE_EXTENDED | 30 #define _XOPEN_SOURCE_EXTENDED |
31 #endif | 31 #endif |
32 #endif | 32 #endif |
33 | 33 |
34 #include <glib.h> | 34 #include <glib.h> |
43 #include <ctype.h> | 43 #include <ctype.h> |
44 #include <gmodule.h> | 44 #include <gmodule.h> |
45 #include <stdlib.h> | 45 #include <stdlib.h> |
46 #include <string.h> | 46 #include <string.h> |
47 #include <time.h> | 47 #include <time.h> |
48 | |
49 #include "gntinternal.h" | |
50 #undef GNT_LOG_DOMAIN | |
51 #define GNT_LOG_DOMAIN "WM" | |
48 | 52 |
49 #include "gntwm.h" | 53 #include "gntwm.h" |
50 #include "gntstyle.h" | 54 #include "gntstyle.h" |
51 #include "gntmarshal.h" | 55 #include "gntmarshal.h" |
52 #include "gnt.h" | 56 #include "gnt.h" |
199 GList *iter; | 203 GList *iter; |
200 static GntWidget *message = NULL; | 204 static GntWidget *message = NULL; |
201 GString *text = g_string_new("act: "); | 205 GString *text = g_string_new("act: "); |
202 if (message) | 206 if (message) |
203 gnt_widget_destroy(message); | 207 gnt_widget_destroy(message); |
204 if (g_list_length(act) == 0) | 208 if (!act) |
205 return; | 209 return; |
206 for (iter = act; iter; iter = iter->next) { | 210 for (iter = act; iter; iter = iter->next) { |
207 GntWS *ws = iter->data; | 211 GntWS *ws = iter->data; |
208 g_string_append_printf(text, "%s, ", gnt_ws_get_name(ws)); | 212 g_string_append_printf(text, "%s, ", gnt_ws_get_name(ws)); |
209 } | 213 } |
323 GError *error = NULL; | 327 GError *error = NULL; |
324 char **keys; | 328 char **keys; |
325 gsize nk; | 329 gsize nk; |
326 | 330 |
327 if (!g_key_file_load_from_file(gfile, filename, G_KEY_FILE_NONE, &error)) { | 331 if (!g_key_file_load_from_file(gfile, filename, G_KEY_FILE_NONE, &error)) { |
328 g_printerr("GntWM: %s\n", error->message); | 332 gnt_warning("%s", error->message); |
329 g_error_free(error); | 333 g_error_free(error); |
330 g_free(filename); | 334 g_free(filename); |
331 return; | 335 return; |
332 } | 336 } |
333 | 337 |
334 keys = g_key_file_get_keys(gfile, "positions", &nk, &error); | 338 keys = g_key_file_get_keys(gfile, "positions", &nk, &error); |
335 if (error) { | 339 if (error) { |
336 g_printerr("GntWM: %s\n", error->message); | 340 gnt_warning("%s", error->message); |
337 g_error_free(error); | 341 g_error_free(error); |
338 error = NULL; | 342 error = NULL; |
339 } else { | 343 } else { |
340 while (nk--) { | 344 while (nk--) { |
341 char *title = keys[nk]; | 345 char *title = keys[nk]; |
347 GntPosition *p = g_new0(GntPosition, 1); | 351 GntPosition *p = g_new0(GntPosition, 1); |
348 p->x = x; | 352 p->x = x; |
349 p->y = y; | 353 p->y = y; |
350 g_hash_table_replace(wm->positions, g_strdup(title + 1), p); | 354 g_hash_table_replace(wm->positions, g_strdup(title + 1), p); |
351 } else { | 355 } else { |
352 g_printerr("GntWM: Invalid number of arguments for positioing a window.\n"); | 356 gnt_warning("Invalid number of arguments (%d) for positioning a window.", l); |
353 } | 357 } |
354 g_strfreev(coords); | 358 g_strfreev(coords); |
355 } | 359 } |
356 g_strfreev(keys); | 360 g_strfreev(keys); |
357 } | 361 } |
925 list_actions(GntBindable *bindable, GList *null) | 929 list_actions(GntBindable *bindable, GList *null) |
926 { | 930 { |
927 GntWidget *tree, *win; | 931 GntWidget *tree, *win; |
928 GList *iter; | 932 GList *iter; |
929 GntWM *wm = GNT_WM(bindable); | 933 GntWM *wm = GNT_WM(bindable); |
934 int n; | |
930 if (wm->_list.window || wm->menu) | 935 if (wm->_list.window || wm->menu) |
931 return TRUE; | 936 return TRUE; |
932 | 937 |
933 if (wm->acts == NULL) | 938 if (wm->acts == NULL) |
934 return TRUE; | 939 return TRUE; |
948 GntAction *action = iter->data; | 953 GntAction *action = iter->data; |
949 gnt_tree_add_row_last(GNT_TREE(tree), action, | 954 gnt_tree_add_row_last(GNT_TREE(tree), action, |
950 gnt_tree_create_row(GNT_TREE(tree), action->label), NULL); | 955 gnt_tree_create_row(GNT_TREE(tree), action->label), NULL); |
951 } | 956 } |
952 g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(action_list_activate), wm); | 957 g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(action_list_activate), wm); |
953 gnt_widget_set_size(tree, 0, g_list_length(wm->acts)); | 958 n = g_list_length(wm->acts); |
954 gnt_widget_set_position(win, 0, getmaxy(stdscr) - 3 - g_list_length(wm->acts)); | 959 gnt_widget_set_size(tree, 0, n); |
960 gnt_widget_set_position(win, 0, getmaxy(stdscr) - 3 - n); | |
955 | 961 |
956 gnt_widget_show(win); | 962 gnt_widget_show(win); |
957 return TRUE; | 963 return TRUE; |
958 } | 964 } |
959 | 965 |
2091 | 2097 |
2092 filename = g_build_filename(g_get_home_dir(), ".gntpositions", NULL); | 2098 filename = g_build_filename(g_get_home_dir(), ".gntpositions", NULL); |
2093 | 2099 |
2094 file = fopen(filename, "wb"); | 2100 file = fopen(filename, "wb"); |
2095 if (file == NULL) { | 2101 if (file == NULL) { |
2096 g_printerr("GntWM: error opening file to save positions\n"); | 2102 gnt_warning("error opening file (%s) to save positions", filename); |
2097 } else { | 2103 } else { |
2098 fprintf(file, "[positions]\n"); | 2104 fprintf(file, "[positions]\n"); |
2099 g_hash_table_foreach(wm->positions, write_gdi, file); | 2105 g_hash_table_foreach(wm->positions, write_gdi, file); |
2100 fclose(file); | 2106 fclose(file); |
2101 } | 2107 } |