Mercurial > pidgin
comparison finch/gntdebug.c @ 20672:c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
| author | Richard Nelson <wabz@pidgin.im> |
|---|---|
| date | Fri, 28 Sep 2007 02:24:08 +0000 |
| parents | 6bf32c9e15a7 |
| children | 39e07c9ae0d7 |
comparison
equal
deleted
inserted
replaced
| 20671:4dd60add6a7c | 20672:c8d4fe2cd0d7 |
|---|---|
| 26 #include <gnt.h> | 26 #include <gnt.h> |
| 27 #include <gntbox.h> | 27 #include <gntbox.h> |
| 28 #include <gntbutton.h> | 28 #include <gntbutton.h> |
| 29 #include <gntcheckbox.h> | 29 #include <gntcheckbox.h> |
| 30 #include <gntentry.h> | 30 #include <gntentry.h> |
| 31 #include <gntfilesel.h> | |
| 31 #include <gntlabel.h> | 32 #include <gntlabel.h> |
| 32 #include <gntline.h> | 33 #include <gntline.h> |
| 33 #include <gnttextview.h> | 34 #include <gnttextview.h> |
| 34 | 35 |
| 35 #include "gntdebug.h" | 36 #include "gntdebug.h" |
| 36 #include "finch.h" | 37 #include "finch.h" |
| 38 #include "notify.h" | |
| 37 #include "util.h" | 39 #include "util.h" |
| 38 | 40 |
| 39 #include <stdio.h> | 41 #include <stdio.h> |
| 40 #include <string.h> | 42 #include <string.h> |
| 41 | 43 |
| 218 int id = g_timeout_add(1000, for_real, entry); | 220 int id = g_timeout_add(1000, for_real, entry); |
| 219 g_object_set_data_full(G_OBJECT(entry), "update-filter", GINT_TO_POINTER(id), | 221 g_object_set_data_full(G_OBJECT(entry), "update-filter", GINT_TO_POINTER(id), |
| 220 (GDestroyNotify)g_source_remove); | 222 (GDestroyNotify)g_source_remove); |
| 221 } | 223 } |
| 222 | 224 |
| 225 static void | |
| 226 file_save(GntFileSel *fs, const char *path, const char *file, GntTextView *tv) | |
| 227 { | |
| 228 FILE *fp; | |
| 229 | |
| 230 if ((fp = g_fopen(path, "w+")) == NULL) { | |
| 231 purple_notify_error(NULL, NULL, _("Unable to open file."), NULL); | |
| 232 return; | |
| 233 } | |
| 234 | |
| 235 fprintf(fp, "Finch Debug Log : %s\n", purple_date_format_full(NULL)); | |
| 236 fprintf(fp, tv->string->str); | |
| 237 fclose(fp); | |
| 238 gnt_widget_destroy(GNT_WIDGET(fs)); | |
| 239 } | |
| 240 | |
| 241 static void | |
| 242 file_cancel(GntWidget *w, GntFileSel *fs) | |
| 243 { | |
| 244 gnt_widget_destroy(GNT_WIDGET(fs)); | |
| 245 } | |
| 246 | |
| 247 static void | |
| 248 save_debug_win(GntWidget *w, GntTextView *tv) | |
| 249 { | |
| 250 GntWidget *window = gnt_file_sel_new(); | |
| 251 GntFileSel *sel = GNT_FILE_SEL(window); | |
| 252 gnt_file_sel_set_current_location(sel, purple_home_dir()); | |
| 253 gnt_file_sel_set_suggested_filename(sel, "debug.txt"); | |
| 254 g_signal_connect(G_OBJECT(sel), "file_selected", G_CALLBACK(file_save), tv); | |
| 255 g_signal_connect(G_OBJECT(sel->cancel), "activate", G_CALLBACK(file_cancel), sel); | |
| 256 gnt_widget_show(window); | |
| 257 } | |
| 258 | |
| 223 void finch_debug_window_show() | 259 void finch_debug_window_show() |
| 224 { | 260 { |
| 225 GntWidget *wid, *box; | 261 GntWidget *wid, *box, *label; |
| 226 | 262 |
| 227 debug.paused = FALSE; | 263 debug.paused = FALSE; |
| 228 if (debug.window) { | 264 if (debug.window) { |
| 229 gnt_window_present(debug.window); | 265 gnt_window_present(debug.window); |
| 230 return; | 266 return; |
| 256 wid = gnt_button_new(_("Clear")); | 292 wid = gnt_button_new(_("Clear")); |
| 257 g_signal_connect(G_OBJECT(wid), "activate", G_CALLBACK(clear_debug_win), debug.tview); | 293 g_signal_connect(G_OBJECT(wid), "activate", G_CALLBACK(clear_debug_win), debug.tview); |
| 258 GNT_WIDGET_SET_FLAGS(wid, GNT_WIDGET_GROW_Y); | 294 GNT_WIDGET_SET_FLAGS(wid, GNT_WIDGET_GROW_Y); |
| 259 gnt_box_add_widget(GNT_BOX(box), wid); | 295 gnt_box_add_widget(GNT_BOX(box), wid); |
| 260 | 296 |
| 297 wid = gnt_button_new(_("Save")); | |
| 298 g_signal_connect(G_OBJECT(wid), "activate", G_CALLBACK(save_debug_win), debug.tview); | |
| 299 GNT_WIDGET_SET_FLAGS(wid, GNT_WIDGET_GROW_Y); | |
| 300 gnt_box_add_widget(GNT_BOX(box), wid); | |
| 301 | |
| 261 debug.search = gnt_entry_new(purple_prefs_get_string(PREF_ROOT "/filter")); | 302 debug.search = gnt_entry_new(purple_prefs_get_string(PREF_ROOT "/filter")); |
| 262 gnt_box_add_widget(GNT_BOX(box), gnt_label_new(_("Filter: "))); | 303 label = gnt_label_new(_("Filter:")); |
| 304 GNT_WIDGET_UNSET_FLAGS(label, GNT_WIDGET_GROW_X); | |
| 305 gnt_box_add_widget(GNT_BOX(box), label); | |
| 263 gnt_box_add_widget(GNT_BOX(box), debug.search); | 306 gnt_box_add_widget(GNT_BOX(box), debug.search); |
| 264 g_signal_connect(G_OBJECT(debug.search), "text_changed", G_CALLBACK(update_filter_string), NULL); | 307 g_signal_connect(G_OBJECT(debug.search), "text_changed", G_CALLBACK(update_filter_string), NULL); |
| 265 | 308 |
| 266 wid = gnt_check_box_new(_("Pause")); | 309 wid = gnt_check_box_new(_("Pause")); |
| 267 g_signal_connect(G_OBJECT(wid), "toggled", G_CALLBACK(toggle_pause), NULL); | 310 g_signal_connect(G_OBJECT(wid), "toggled", G_CALLBACK(toggle_pause), NULL); |
