2 * Copyright (C) 2009 Collabora Ltd.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 * Authors: Jonny Lamb <jonny.lamb@collabora.co.uk>
23 #include <glib/gi18n.h>
27 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
28 #include <libempathy/empathy-debug.h>
29 #include <libempathy/empathy-utils.h>
31 #include <libempathy-gtk/empathy-account-chooser.h>
33 #include <telepathy-glib/dbus.h>
34 #include <telepathy-glib/util.h>
35 #include <telepathy-glib/proxy-subclass.h>
37 #include "extensions/extensions.h"
39 #include "empathy-debug-dialog.h"
41 G_DEFINE_TYPE (EmpathyDebugDialog, empathy_debug_dialog,
52 COL_DEBUG_TIMESTAMP = 0,
55 COL_DEBUG_LEVEL_STRING,
57 COL_DEBUG_LEVEL_VALUE,
75 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyDebugDialog)
81 GtkWidget *cm_chooser;
83 GtkTreeModel *store_filter;
85 TpProxySignalConnection *signal_connection;
89 } EmpathyDebugDialogPriv;
92 log_level_to_string (guint level)
96 case EMP_DEBUG_LEVEL_ERROR:
99 case EMP_DEBUG_LEVEL_CRITICAL:
100 return _("Critical");
102 case EMP_DEBUG_LEVEL_WARNING:
105 case EMP_DEBUG_LEVEL_MESSAGE:
108 case EMP_DEBUG_LEVEL_INFO:
111 case EMP_DEBUG_LEVEL_DEBUG:
115 g_assert_not_reached ();
121 debug_dialog_add_message (EmpathyDebugDialog *debug_dialog,
123 const gchar *domain_category,
125 const gchar *message)
127 EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog);
128 gchar *domain, *category;
132 if (g_strrstr (domain_category, "/"))
134 gchar **parts = g_strsplit (domain_category, "/", 2);
135 domain = g_strdup (parts[0]);
136 category = g_strdup (parts[1]);
141 domain = g_strdup (domain_category);
142 category = g_strdup ("");
145 if (g_str_has_suffix (message, "\n"))
146 string = g_strchomp (g_strdup (message));
148 string = g_strdup (message);
151 gtk_list_store_append (priv->store, &iter);
152 gtk_list_store_set (priv->store, &iter,
153 COL_DEBUG_TIMESTAMP, timestamp,
154 COL_DEBUG_DOMAIN, domain,
155 COL_DEBUG_CATEGORY, category,
156 COL_DEBUG_LEVEL_STRING, log_level_to_string (level),
157 COL_DEBUG_MESSAGE, string,
158 COL_DEBUG_LEVEL_VALUE, level,
167 debug_dialog_new_debug_message_cb (TpProxy *proxy,
171 const gchar *message,
173 GObject *weak_object)
175 EmpathyDebugDialog *debug_dialog = (EmpathyDebugDialog *) user_data;
177 debug_dialog_add_message (debug_dialog, timestamp, domain, level,
182 debug_dialog_set_enabled (EmpathyDebugDialog *debug_dialog,
185 EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog);
188 val = tp_g_value_slice_new_boolean (enabled);
190 tp_cli_dbus_properties_call_set (priv->proxy, -1, EMP_IFACE_DEBUG,
191 "Enabled", val, NULL, NULL, NULL, NULL);
193 tp_g_value_slice_free (val);
197 debug_dialog_get_messages_cb (TpProxy *proxy,
198 const GPtrArray *messages,
201 GObject *weak_object)
203 EmpathyDebugDialog *debug_dialog = (EmpathyDebugDialog *) user_data;
204 EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog);
209 DEBUG ("GetMessages failed: %s", error->message);
213 for (i = 0; i < messages->len; i++)
215 GValueArray *values = g_ptr_array_index (messages, i);
217 debug_dialog_add_message (debug_dialog,
218 g_value_get_double (g_value_array_get_nth (values, 0)),
219 g_value_get_string (g_value_array_get_nth (values, 1)),
220 g_value_get_uint (g_value_array_get_nth (values, 2)),
221 g_value_get_string (g_value_array_get_nth (values, 3)));
224 /* Connect to NewDebugMessage */
225 priv->signal_connection = emp_cli_debug_connect_to_new_debug_message (
226 proxy, debug_dialog_new_debug_message_cb, debug_dialog,
229 /* Set Enabled as appropriate */
230 debug_dialog_set_enabled (debug_dialog, !priv->paused);
234 debug_dialog_cm_chooser_changed_cb (GtkComboBox *cm_chooser,
235 EmpathyDebugDialog *debug_dialog)
237 EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog);
240 GError *error = NULL;
242 TpConnection *connection;
245 if (!gtk_combo_box_get_active_iter (cm_chooser, &iter))
247 DEBUG ("No CM is selected");
251 mc = empathy_mission_control_dup_singleton ();
252 dbus = tp_dbus_daemon_dup (&error);
256 DEBUG ("Failed at duping the dbus daemon: %s", error->message);
260 gtk_tree_model_get (GTK_TREE_MODEL (priv->cms), &iter,
261 COL_CM_BUS, &bus_name, -1);
262 connection = tp_connection_new (dbus, bus_name, DEBUG_OBJECT_PATH, &error);
267 DEBUG ("Getting a new TpConnection failed: %s", error->message);
268 g_error_free (error);
269 g_object_unref (dbus);
274 gtk_list_store_clear (priv->store);
276 /* Disable debug signalling */
277 if (priv->proxy != NULL)
278 debug_dialog_set_enabled (debug_dialog, FALSE);
280 /* Disconnect from previous NewDebugMessage signal */
281 if (priv->signal_connection != NULL)
283 tp_proxy_signal_connection_disconnect (priv->signal_connection);
284 priv->signal_connection = NULL;
287 if (priv->proxy != NULL)
288 g_object_unref (priv->proxy);
290 priv->proxy = TP_PROXY (connection);
292 tp_proxy_add_interface_by_id (priv->proxy, emp_iface_quark_debug ());
294 emp_cli_debug_call_get_messages (priv->proxy, -1,
295 debug_dialog_get_messages_cb, debug_dialog, NULL, NULL);
297 g_object_unref (dbus);
302 debug_dialog_list_connection_names_cb (const gchar * const *names,
304 const gchar * const *cms,
305 const gchar * const *protocols,
308 GObject *weak_object)
310 EmpathyDebugDialog *debug_dialog = (EmpathyDebugDialog *) user_data;
311 EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog);
316 DEBUG ("list_connection_names failed: %s", error->message);
320 for (i = 0; cms[i] != NULL; i++)
324 gboolean found = FALSE;
326 for (j = i + 1; cms[j] != NULL; j++)
328 if (!tp_strdiff (cms[i], cms[j]))
338 gtk_list_store_append (priv->cms, &iter);
339 gtk_list_store_set (priv->cms, &iter,
341 COL_CM_BUS, names[i],
345 gtk_combo_box_set_active (GTK_COMBO_BOX (priv->cm_chooser), 0);
348 debug_dialog_cm_chooser_changed_cb (
349 GTK_COMBO_BOX (priv->cm_chooser), debug_dialog);
353 debug_dialog_fill_cm_chooser (EmpathyDebugDialog *debug_dialog)
356 GError *error = NULL;
358 dbus = tp_dbus_daemon_dup (&error);
362 DEBUG ("Failed to dup dbus daemon: %s", error->message);
363 g_error_free (error);
367 tp_list_connection_names (dbus, debug_dialog_list_connection_names_cb,
368 debug_dialog, NULL, NULL);
370 g_object_unref (dbus);
374 debug_dialog_pause_toggled_cb (GtkToggleToolButton *pause,
375 EmpathyDebugDialog *debug_dialog)
377 EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog);
379 priv->paused = gtk_toggle_tool_button_get_active (pause);
381 debug_dialog_set_enabled (debug_dialog, !priv->paused);
385 debug_dialog_visible_func (GtkTreeModel *model,
389 EmpathyDebugDialog *debug_dialog = (EmpathyDebugDialog *) user_data;
390 EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog);
391 guint filter_value, level;
392 GtkTreeModel *filter_model;
393 GtkTreeIter filter_iter;
395 filter_model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->filter));
396 gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->filter),
399 gtk_tree_model_get (model, iter, COL_DEBUG_LEVEL_VALUE, &level, -1);
400 gtk_tree_model_get (filter_model, &filter_iter,
401 COL_LEVEL_VALUE, &filter_value, -1);
403 if (level <= filter_value)
410 debug_dialog_filter_changed_cb (GtkComboBox *filter,
411 EmpathyDebugDialog *debug_dialog)
413 EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog);
415 gtk_tree_model_filter_refilter (
416 GTK_TREE_MODEL_FILTER (priv->store_filter));
420 debug_dialog_clear_clicked_cb (GtkToolButton *clear_button,
421 EmpathyDebugDialog *debug_dialog)
423 EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog);
425 gtk_list_store_clear (priv->store);
429 debug_dialog_menu_copy_activate_cb (GtkMenuItem *menu_item,
430 EmpathyDebugDialog *debug_dialog)
432 EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog);
434 GtkTreeViewColumn *focus_column;
437 GtkClipboard *clipboard;
439 gtk_tree_view_get_cursor (GTK_TREE_VIEW (priv->view),
440 &path, &focus_column);
444 DEBUG ("No row is in focus");
448 gtk_tree_model_get_iter (priv->store_filter, &iter, path);
450 gtk_tree_model_get (priv->store_filter, &iter,
451 COL_DEBUG_MESSAGE, &message,
454 if (EMP_STR_EMPTY (message))
456 DEBUG ("Log message is empty");
460 clipboard = gtk_clipboard_get_for_display (
461 gtk_widget_get_display (GTK_WIDGET (menu_item)),
462 GDK_SELECTION_CLIPBOARD);
464 gtk_clipboard_set_text (clipboard, message, -1);
471 EmpathyDebugDialog *debug_dialog;
477 debug_dialog_show_menu (gpointer user_data)
479 MenuPopupData *data = (MenuPopupData *) user_data;
480 GtkWidget *menu, *item;
483 menu = gtk_menu_new ();
484 shell = GTK_MENU_SHELL (menu);
486 item = gtk_image_menu_item_new_from_stock (GTK_STOCK_COPY, NULL);
488 g_signal_connect (item, "activate",
489 G_CALLBACK (debug_dialog_menu_copy_activate_cb), data->debug_dialog);
491 gtk_menu_shell_append (shell, item);
492 gtk_widget_show (item);
494 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
495 data->button, data->time);
497 g_slice_free (MenuPopupData, user_data);
503 debug_dialog_button_press_event_cb (GtkTreeView *view,
504 GdkEventButton *event,
507 /* A mouse button was pressed on the tree view. */
509 if (event->button == 3)
511 /* The tree view was right-clicked. (3 == third mouse button) */
513 data = g_slice_new0 (MenuPopupData);
514 data->debug_dialog = user_data;
515 data->button = event->button;
516 data->time = event->time;
517 g_idle_add (debug_dialog_show_menu, data);
524 debug_dialog_store_filter_foreach (GtkTreeModel *model,
529 GFileOutputStream *output_stream = (GFileOutputStream *) user_data;
530 gchar *domain, *category, *message, *level_str, *level_upper;
533 GError *error = NULL;
534 gboolean out = FALSE;
536 gtk_tree_model_get (model, iter,
537 COL_DEBUG_TIMESTAMP, ×tamp,
538 COL_DEBUG_DOMAIN, &domain,
539 COL_DEBUG_CATEGORY, &category,
540 COL_DEBUG_LEVEL_STRING, &level_str,
541 COL_DEBUG_MESSAGE, &message,
544 level_upper = g_ascii_strup (level_str, -1);
546 line = g_strdup_printf ("%s%s%s-%s: %e: %s\n",
547 domain, EMP_STR_EMPTY (category) ? "" : "/",
548 category, level_upper, timestamp, message);
550 g_output_stream_write (G_OUTPUT_STREAM (output_stream), line,
551 strlen (line), NULL, &error);
555 DEBUG ("Failed to write to file: %s", error->message);
556 g_error_free (error);
561 g_free (level_upper);
571 debug_dialog_save_file_chooser_response_cb (GtkDialog *dialog,
573 EmpathyDebugDialog *debug_dialog)
575 EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog);
576 gchar *filename = NULL;
578 GFileOutputStream *output_stream = NULL;
579 GError *error = NULL;
581 if (response_id != GTK_RESPONSE_ACCEPT)
584 filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
586 DEBUG ("Saving log as %s", filename);
588 gfile = g_file_new_for_path (filename);
589 output_stream = g_file_replace (gfile, NULL, FALSE,
590 G_FILE_CREATE_NONE, NULL, &error);
594 DEBUG ("Failed to open file for writing: %s", error->message);
595 g_error_free (error);
599 gtk_tree_model_foreach (priv->store_filter,
600 debug_dialog_store_filter_foreach, output_stream);
604 g_object_unref (gfile);
606 if (output_stream != NULL)
607 g_object_unref (output_stream);
609 if (filename != NULL)
612 gtk_widget_destroy (GTK_WIDGET (dialog));
616 debug_dialog_save_clicked_cb (GtkToolButton *tool_button,
617 EmpathyDebugDialog *debug_dialog)
619 GtkWidget *file_chooser;
621 file_chooser = gtk_file_chooser_dialog_new (_("Save"),
622 GTK_WINDOW (debug_dialog), GTK_FILE_CHOOSER_ACTION_SAVE,
623 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
624 GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
627 gtk_window_set_modal (GTK_WINDOW (file_chooser), TRUE);
628 gtk_file_chooser_set_do_overwrite_confirmation (
629 GTK_FILE_CHOOSER (file_chooser), TRUE);
631 g_signal_connect (file_chooser, "response",
632 G_CALLBACK (debug_dialog_save_file_chooser_response_cb),
635 gtk_widget_show (file_chooser);
639 debug_dialog_constructor (GType type,
640 guint n_construct_params,
641 GObjectConstructParam *construct_params)
644 EmpathyDebugDialogPriv *priv;
650 GtkCellRenderer *renderer;
651 GtkWidget *scrolled_win;
652 GtkListStore *level_store;
655 object = G_OBJECT_CLASS (empathy_debug_dialog_parent_class)->constructor
656 (type, n_construct_params, construct_params);
657 priv = GET_PRIV (object);
659 gtk_window_set_title (GTK_WINDOW (object), _("Debug Window"));
660 gtk_window_set_default_size (GTK_WINDOW (object), 800, 400);
661 gtk_window_set_transient_for (GTK_WINDOW (object), priv->parent);
663 vbox = GTK_DIALOG (object)->vbox;
665 toolbar = gtk_toolbar_new ();
666 gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH_HORIZ);
667 gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), TRUE);
668 gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar),
669 GTK_ICON_SIZE_SMALL_TOOLBAR);
670 gtk_widget_show (toolbar);
672 gtk_box_pack_start (GTK_BOX (vbox), toolbar, FALSE, FALSE, 0);
675 priv->cm_chooser = gtk_combo_box_new_text ();
676 priv->cms = gtk_list_store_new (NUM_COLS_CM, G_TYPE_STRING, G_TYPE_STRING);
677 gtk_combo_box_set_model (GTK_COMBO_BOX (priv->cm_chooser),
678 GTK_TREE_MODEL (priv->cms));
679 gtk_widget_show (priv->cm_chooser);
681 item = gtk_tool_item_new ();
682 gtk_widget_show (GTK_WIDGET (item));
683 gtk_container_add (GTK_CONTAINER (item), priv->cm_chooser);
684 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
685 debug_dialog_fill_cm_chooser (EMPATHY_DEBUG_DIALOG (object));
686 g_signal_connect (priv->cm_chooser, "changed",
687 G_CALLBACK (debug_dialog_cm_chooser_changed_cb), object);
688 gtk_widget_show (GTK_WIDGET (priv->cm_chooser));
690 item = gtk_separator_tool_item_new ();
691 gtk_widget_show (GTK_WIDGET (item));
692 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
695 item = gtk_tool_button_new_from_stock (GTK_STOCK_SAVE);
696 g_signal_connect (item, "clicked",
697 G_CALLBACK (debug_dialog_save_clicked_cb), object);
698 gtk_widget_show (GTK_WIDGET (item));
699 gtk_tool_item_set_is_important (GTK_TOOL_ITEM (item), TRUE);
700 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
703 item = gtk_tool_button_new_from_stock (GTK_STOCK_CLEAR);
704 g_signal_connect (item, "clicked",
705 G_CALLBACK (debug_dialog_clear_clicked_cb), object);
706 gtk_widget_show (GTK_WIDGET (item));
707 gtk_tool_item_set_is_important (GTK_TOOL_ITEM (item), TRUE);
708 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
710 item = gtk_separator_tool_item_new ();
711 gtk_widget_show (GTK_WIDGET (item));
712 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
715 priv->paused = FALSE;
716 image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_PAUSE,
718 gtk_widget_show (image);
719 item = gtk_toggle_tool_button_new ();
720 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (item),
722 g_signal_connect (item, "toggled",
723 G_CALLBACK (debug_dialog_pause_toggled_cb), object);
724 gtk_widget_show (GTK_WIDGET (item));
725 gtk_tool_item_set_is_important (GTK_TOOL_ITEM (item), TRUE);
726 gtk_tool_button_set_label (GTK_TOOL_BUTTON (item), _("Pause"));
727 gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (item), image);
728 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
730 item = gtk_separator_tool_item_new ();
731 gtk_widget_show (GTK_WIDGET (item));
732 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
735 item = gtk_tool_item_new ();
736 gtk_widget_show (GTK_WIDGET (item));
737 label = gtk_label_new (_("Level "));
738 gtk_widget_show (label);
739 gtk_container_add (GTK_CONTAINER (item), label);
740 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
742 priv->filter = gtk_combo_box_new_text ();
743 gtk_widget_show (priv->filter);
745 item = gtk_tool_item_new ();
746 gtk_widget_show (GTK_WIDGET (item));
747 gtk_container_add (GTK_CONTAINER (item), priv->filter);
748 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
750 level_store = gtk_list_store_new (NUM_COLS_LEVEL,
751 G_TYPE_STRING, G_TYPE_UINT);
752 gtk_combo_box_set_model (GTK_COMBO_BOX (priv->filter),
753 GTK_TREE_MODEL (level_store));
755 gtk_list_store_append (level_store, &iter);
756 gtk_list_store_set (level_store, &iter,
757 COL_LEVEL_NAME, _("Debug"),
758 COL_LEVEL_VALUE, EMP_DEBUG_LEVEL_DEBUG,
761 gtk_list_store_append (level_store, &iter);
762 gtk_list_store_set (level_store, &iter,
763 COL_LEVEL_NAME, _("Info"),
764 COL_LEVEL_VALUE, EMP_DEBUG_LEVEL_INFO,
767 gtk_list_store_append (level_store, &iter);
768 gtk_list_store_set (level_store, &iter,
769 COL_LEVEL_NAME, _("Message"),
770 COL_LEVEL_VALUE, EMP_DEBUG_LEVEL_MESSAGE,
773 gtk_list_store_append (level_store, &iter);
774 gtk_list_store_set (level_store, &iter,
775 COL_LEVEL_NAME, _("Warning"),
776 COL_LEVEL_VALUE, EMP_DEBUG_LEVEL_WARNING,
779 gtk_list_store_append (level_store, &iter);
780 gtk_list_store_set (level_store, &iter,
781 COL_LEVEL_NAME, _("Critical"),
782 COL_LEVEL_VALUE, EMP_DEBUG_LEVEL_CRITICAL,
785 gtk_list_store_append (level_store, &iter);
786 gtk_list_store_set (level_store, &iter,
787 COL_LEVEL_NAME, _("Error"),
788 COL_LEVEL_VALUE, EMP_DEBUG_LEVEL_ERROR,
791 gtk_combo_box_set_active (GTK_COMBO_BOX (priv->filter), 0);
792 g_signal_connect (priv->filter, "changed",
793 G_CALLBACK (debug_dialog_filter_changed_cb), object);
796 priv->view = gtk_tree_view_new ();
797 gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (priv->view), TRUE);
799 g_signal_connect (priv->view, "button-press-event",
800 G_CALLBACK (debug_dialog_button_press_event_cb), object);
802 renderer = gtk_cell_renderer_text_new ();
803 g_object_set (renderer, "yalign", 0, NULL);
805 gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->view),
806 -1, _("Time"), renderer, "text", COL_DEBUG_TIMESTAMP, NULL);
807 gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->view),
808 -1, _("Domain"), renderer, "text", COL_DEBUG_DOMAIN, NULL);
809 gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->view),
810 -1, _("Category"), renderer, "text", COL_DEBUG_CATEGORY, NULL);
811 gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->view),
812 -1, _("Level"), renderer, "text", COL_DEBUG_LEVEL_STRING, NULL);
814 renderer = gtk_cell_renderer_text_new ();
815 g_object_set (renderer, "family", "Monospace", NULL);
816 gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->view),
817 -1, _("Message"), renderer, "text", COL_DEBUG_MESSAGE, NULL);
819 priv->store = gtk_list_store_new (NUM_DEBUG_COLS, G_TYPE_DOUBLE,
820 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
823 priv->store_filter = gtk_tree_model_filter_new (
824 GTK_TREE_MODEL (priv->store), NULL);
826 gtk_tree_model_filter_set_visible_func (
827 GTK_TREE_MODEL_FILTER (priv->store_filter),
828 debug_dialog_visible_func, object, NULL);
830 gtk_tree_view_set_model (GTK_TREE_VIEW (priv->view), priv->store_filter);
832 /* Scrolled window */
833 scrolled_win = gtk_scrolled_window_new (NULL, NULL);
834 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
835 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
837 gtk_widget_show (priv->view);
838 gtk_container_add (GTK_CONTAINER (scrolled_win), priv->view);
840 gtk_widget_show (scrolled_win);
841 gtk_box_pack_start (GTK_BOX (vbox), scrolled_win, TRUE, TRUE, 0);
843 gtk_widget_show (GTK_WIDGET (object));
849 empathy_debug_dialog_init (EmpathyDebugDialog *empathy_debug_dialog)
851 EmpathyDebugDialogPriv *priv =
852 G_TYPE_INSTANCE_GET_PRIVATE (empathy_debug_dialog,
853 EMPATHY_TYPE_DEBUG_DIALOG, EmpathyDebugDialogPriv);
855 empathy_debug_dialog->priv = priv;
857 priv->dispose_run = FALSE;
861 debug_dialog_set_property (GObject *object,
866 EmpathyDebugDialogPriv *priv = GET_PRIV (object);
871 priv->parent = GTK_WINDOW (g_value_dup_object (value));
874 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
880 debug_dialog_get_property (GObject *object,
885 EmpathyDebugDialogPriv *priv = GET_PRIV (object);
890 g_value_set_object (value, priv->parent);
893 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
899 debug_dialog_dispose (GObject *object)
901 EmpathyDebugDialog *selector = EMPATHY_DEBUG_DIALOG (object);
902 EmpathyDebugDialogPriv *priv = GET_PRIV (selector);
904 if (priv->dispose_run)
907 priv->dispose_run = TRUE;
909 if (priv->parent != NULL)
910 g_object_unref (priv->parent);
912 if (priv->store != NULL)
913 g_object_unref (priv->store);
915 if (priv->proxy != NULL)
917 debug_dialog_set_enabled (EMPATHY_DEBUG_DIALOG (object), FALSE);
918 g_object_unref (priv->proxy);
921 if (priv->signal_connection != NULL)
922 tp_proxy_signal_connection_disconnect (priv->signal_connection);
924 if (priv->cms != NULL)
925 g_object_unref (priv->cms);
927 (G_OBJECT_CLASS (empathy_debug_dialog_parent_class)->dispose) (object);
931 empathy_debug_dialog_class_init (EmpathyDebugDialogClass *klass)
933 GObjectClass *object_class = G_OBJECT_CLASS (klass);
934 object_class->constructor = debug_dialog_constructor;
935 object_class->dispose = debug_dialog_dispose;
936 object_class->set_property = debug_dialog_set_property;
937 object_class->get_property = debug_dialog_get_property;
938 g_type_class_add_private (klass, sizeof (EmpathyDebugDialogPriv));
940 g_object_class_install_property (object_class, PROP_PARENT,
941 g_param_spec_object ("parent", "parent", "parent",
942 GTK_TYPE_WINDOW, G_PARAM_CONSTRUCT_ONLY |
943 G_PARAM_READWRITE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
949 empathy_debug_dialog_new (GtkWindow *parent)
951 g_return_val_if_fail (GTK_IS_WINDOW (parent), NULL);
953 return GTK_WIDGET (g_object_new (EMPATHY_TYPE_DEBUG_DIALOG,
954 "parent", parent, NULL));