pidgin/gtkdebug.c

changeset 38376
d27109ba6626
parent 38045
6e8b223df524
child 38377
88e5bd05a57c
equal deleted inserted replaced
38363:876661dc1375 38376:d27109ba6626
38 38
39 #include <gdk/gdkkeysyms.h> 39 #include <gdk/gdkkeysyms.h>
40 40
41 #include "gtk3compat.h" 41 #include "gtk3compat.h"
42 42
43 #include "gtkdebug.html.h" 43 #include "gtkdebug.gresource.h"
44 44
45 typedef struct 45 typedef struct
46 { 46 {
47 GtkWidget *window; 47 GtkWidget *window;
48 GtkWidget *text; 48 GtkWidget *text;
407 } 407 }
408 408
409 static DebugWindow * 409 static DebugWindow *
410 debug_window_new(void) 410 debug_window_new(void)
411 { 411 {
412 GError *error;
412 DebugWindow *win; 413 DebugWindow *win;
414 GResource *resource;
415 GBytes *resource_bytes;
413 GtkWidget *vbox; 416 GtkWidget *vbox;
414 GtkWidget *toolbar; 417 GtkWidget *toolbar;
415 GtkWidget *frame; 418 GtkWidget *frame;
416 gint width, height; 419 gint width, height;
417 void *handle; 420 void *handle;
584 587
585 /* Add the gtkwebview */ 588 /* Add the gtkwebview */
586 frame = pidgin_create_webview(FALSE, &win->text, NULL); 589 frame = pidgin_create_webview(FALSE, &win->text, NULL);
587 pidgin_webview_set_format_functions(PIDGIN_WEBVIEW(win->text), 590 pidgin_webview_set_format_functions(PIDGIN_WEBVIEW(win->text),
588 PIDGIN_WEBVIEW_ALL ^ PIDGIN_WEBVIEW_SMILEY ^ PIDGIN_WEBVIEW_IMAGE); 591 PIDGIN_WEBVIEW_ALL ^ PIDGIN_WEBVIEW_SMILEY ^ PIDGIN_WEBVIEW_IMAGE);
589 pidgin_webview_load_html_string(PIDGIN_WEBVIEW(win->text), gtkdebug_html); 592 resource = gtkdebug_get_resource();
593 error = NULL;
594 resource_bytes = g_resource_lookup_data(resource,
595 "/im/pidgin/Pidgin/gtkdebug.html",
596 G_RESOURCE_LOOKUP_FLAGS_NONE,
597 &error);
598 if (G_UNLIKELY(resource_bytes == NULL || error != NULL)) {
599 gchar *msg = g_strdup_printf("Unable to load debug window HTML: %s\n",
600 error ? error->message : "Unknown error");
601 g_clear_error(&error);
602 pidgin_webview_load_html_string(PIDGIN_WEBVIEW(win->text), msg);
603 g_free(msg);
604 } else {
605 gconstpointer gtkdebug_html;
606 gtkdebug_html = g_bytes_get_data(resource_bytes, NULL);
607 pidgin_webview_load_html_string(PIDGIN_WEBVIEW(win->text),
608 gtkdebug_html);
609 }
610 g_bytes_unref(resource_bytes);
590 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); 611 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
591 gtk_widget_show(frame); 612 gtk_widget_show(frame);
592 613
593 clear_cb(NULL, win); 614 clear_cb(NULL, win);
594 615

mercurial