comparison src/prefs.c @ 5211:0241d6b6702d

[gaim-migrate @ 5581] Wrote a new debugging API, and of course core/ui split it. Debug statements can now have debug levels and categories, for future filtering of stuff, and color highlighting. It's nifty, m'kay? committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sat, 26 Apr 2003 06:46:08 +0000
parents fefad67de2c7
children 1a53330dfd34
comparison
equal deleted inserted replaced
5210:39bb2a35f8d9 5211:0241d6b6702d
70 void set_default_away(GtkWidget *, gpointer); 70 void set_default_away(GtkWidget *, gpointer);
71 #ifndef _WIN32 71 #ifndef _WIN32
72 static gboolean program_is_valid(const char *); 72 static gboolean program_is_valid(const char *);
73 #endif 73 #endif
74 74
75 struct debug_window *dw = NULL;
76 GtkWidget *prefs = NULL; 75 GtkWidget *prefs = NULL;
77 GtkWidget *debugbutton = NULL; 76 GtkWidget *debugbutton = NULL;
78 static int notebook_page = 0; 77 static int notebook_page = 0;
79 static GtkTreeIter plugin_iter; 78 static GtkTreeIter plugin_iter;
80 79
343 GError *converr = NULL; 342 GError *converr = NULL;
344 gchar *tmp; 343 gchar *tmp;
345 /* It looks like we're dealing with a local file. Let's 344 /* It looks like we're dealing with a local file. Let's
346 * just untar it in the right place */ 345 * just untar it in the right place */
347 if(!(tmp = g_filename_from_uri(name, NULL, &converr))) { 346 if(!(tmp = g_filename_from_uri(name, NULL, &converr))) {
348 debug_printf("%s\n", converr ? converr->message : "g_filename_from_uri error"); 347 gaim_debug(GAIM_DEBUG_ERROR, "theme dnd", "%s\n",
348 (converr ? converr->message :
349 "g_filename_from_uri error"));
349 return; 350 return;
350 } 351 }
351 theme_install_theme(tmp, NULL); 352 theme_install_theme(tmp, NULL);
352 g_free(tmp); 353 g_free(tmp);
353 } else if (!g_ascii_strncasecmp(name, "http://", 7)) { 354 } else if (!g_ascii_strncasecmp(name, "http://", 7)) {
1936 1937
1937 gtk_tree_view_expand_all (GTK_TREE_VIEW(tree_v)); 1938 gtk_tree_view_expand_all (GTK_TREE_VIEW(tree_v));
1938 gtk_widget_show(prefs); 1939 gtk_widget_show(prefs);
1939 } 1940 }
1940 1941
1941 static gint debug_delete(GtkWidget *w, GdkEvent *event, void *dummy)
1942 {
1943 if (debugbutton)
1944 gtk_button_clicked(GTK_BUTTON(debugbutton));
1945 if (misc_options & OPT_MISC_DEBUG) {
1946 misc_options ^= OPT_MISC_DEBUG;
1947 }
1948 g_free(dw);
1949 dw = NULL;
1950 save_prefs();
1951 return FALSE;
1952 }
1953
1954 static void build_debug()
1955 {
1956 GtkWidget *sw;
1957 GtkTextBuffer *buffer;
1958 GtkTextIter end;
1959
1960 if (!dw)
1961 dw = g_new0(struct debug_window, 1);
1962
1963 GAIM_DIALOG(dw->window);
1964 gtk_window_set_default_size(GTK_WINDOW(dw->window), 500, 200);
1965 gtk_window_set_role(GTK_WINDOW(dw->window), "debug");
1966 gtk_window_set_title(GTK_WINDOW(dw->window), _("Debug Window"));
1967 g_signal_connect(G_OBJECT(dw->window), "delete_event", G_CALLBACK(debug_delete), NULL);
1968
1969 sw = gtk_scrolled_window_new(NULL, NULL);
1970 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
1971 GTK_POLICY_NEVER,
1972 GTK_POLICY_ALWAYS);
1973
1974 dw->entry = gtk_text_view_new();
1975 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(dw->entry), FALSE);
1976 gtk_text_view_set_editable(GTK_TEXT_VIEW(dw->entry), FALSE);
1977 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(dw->entry), GTK_WRAP_WORD_CHAR);
1978
1979 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(dw->entry));
1980 gtk_text_buffer_get_end_iter(buffer, &end);
1981 gtk_text_buffer_create_mark(buffer, "end", &end, FALSE);
1982
1983 gtk_container_add(GTK_CONTAINER(sw), dw->entry);
1984 gtk_container_add(GTK_CONTAINER(dw->window), sw);
1985 gtk_widget_show_all(dw->window);
1986 }
1987
1988 void show_debug()
1989 {
1990 if ((misc_options & OPT_MISC_DEBUG)) {
1991 if (!dw || !dw->window)
1992 build_debug();
1993 gtk_widget_show(dw->window);
1994 } else {
1995 if (!dw)
1996 return;
1997 gtk_widget_destroy(dw->window);
1998 dw->window = NULL;
1999 }
2000 }
2001
2002 void toggle_debug()
2003 {
2004 misc_options ^= OPT_MISC_DEBUG;
2005 show_debug();
2006 save_prefs();
2007 }
2008
2009 void debug_printf(char *fmt, ...)
2010 {
2011 va_list ap;
2012 gchar *s;
2013
2014 va_start(ap, fmt);
2015 s = g_strdup_vprintf(fmt, ap);
2016 va_end(ap);
2017
2018 if (misc_options & OPT_MISC_DEBUG && dw) {
2019 GtkTextBuffer *buffer;
2020 GtkTextMark *endmark;
2021 GtkTextIter end;
2022
2023 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(dw->entry));
2024 endmark = gtk_text_buffer_get_mark(buffer, "end");
2025 gtk_text_buffer_get_iter_at_mark(buffer, &end, endmark);
2026 gtk_text_buffer_insert(buffer, &end, s, -1);
2027 gtk_text_view_scroll_mark_onscreen(GTK_TEXT_VIEW(dw->entry), endmark);
2028 }
2029 if (opt_debug)
2030 g_print("%s", s);
2031 g_free(s);
2032 }
2033
2034 void set_option(GtkWidget *w, int *option) 1942 void set_option(GtkWidget *w, int *option)
2035 { 1943 {
2036 *option = !(*option); 1944 *option = !(*option);
2037 } 1945 }
2038 1946
2039 static void set_misc_option(GtkWidget *w, int option) 1947 static void set_misc_option(GtkWidget *w, int option)
2040 { 1948 {
2041 misc_options ^= option; 1949 misc_options ^= option;
2042 1950
2043 if (option == OPT_MISC_DEBUG) 1951 if (option == OPT_MISC_DEBUG) {
2044 show_debug(); 1952 if ((misc_options & OPT_MISC_DEBUG))
1953 gaim_gtk_debug_window_show();
1954 else
1955 gaim_gtk_debug_window_hide();
1956 }
2045 else if(option == OPT_MISC_USE_SERVER_ALIAS) { 1957 else if(option == OPT_MISC_USE_SERVER_ALIAS) {
2046 /* XXX blist reset the aliases here */ 1958 /* XXX blist reset the aliases here */
2047 gaim_conversation_foreach(gaim_conversation_autoset_title); 1959 gaim_conversation_foreach(gaim_conversation_autoset_title);
2048 } 1960 }
2049 } 1961 }
2177 (int *)option); 2089 (int *)option);
2178 } else if (options == &away_options) { 2090 } else if (options == &away_options) {
2179 g_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(set_away_option), 2091 g_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(set_away_option),
2180 (int *)option); 2092 (int *)option);
2181 } else { 2093 } else {
2182 debug_printf("gaim_button: \"%s\" has no signal handler attached to it!\n", text); 2094 gaim_debug(GAIM_DEBUG_WARNING, "gaim_button",
2095 "\"%s\" has no signal handler attached to it!\n", text);
2183 } 2096 }
2184 gtk_widget_show(button); 2097 gtk_widget_show(button);
2185 2098
2186 return button; 2099 return button;
2187 } 2100 }
2302 if (program == NULL || *program == '\0') { 2215 if (program == NULL || *program == '\0') {
2303 return FALSE; 2216 return FALSE;
2304 } 2217 }
2305 2218
2306 if (!g_shell_parse_argv(program, NULL, &argv, &error)) { 2219 if (!g_shell_parse_argv(program, NULL, &argv, &error)) {
2307 debug_printf("Could not parse program '%s': ", error->message); 2220 gaim_debug(GAIM_DEBUG_ERROR, "program_is_valid",
2221 "Could not parse program '%s': %s\n",
2222 program, error->message);
2308 g_error_free(error); 2223 g_error_free(error);
2309 return FALSE; 2224 return FALSE;
2310 } 2225 }
2311 2226
2312 if (argv == NULL) { 2227 if (argv == NULL) {
2370 2285
2371 if (clear != -1) { 2286 if (clear != -1) {
2372 *option = *option & ~clear; 2287 *option = *option & ~clear;
2373 *option = *option | opt; 2288 *option = *option | opt;
2374 } else { 2289 } else {
2375 debug_printf("HELLO %d\n", opt); 2290 gaim_debug(GAIM_DEBUG_MISC, "dropdown_set", "HELLO %d\n", opt);
2376 *option = opt; 2291 *option = opt;
2377 } 2292 }
2378 2293
2379 if (option == (int*)&global_proxy_info.proxytype) { 2294 if (option == (int*)&global_proxy_info.proxytype) {
2380 if (opt == PROXY_NONE) 2295 if (opt == PROXY_NONE)