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++)
323 gtk_list_store_append (priv->cms, &iter);
324 gtk_list_store_set (priv->cms, &iter,
326 COL_CM_BUS, names[i],
330 gtk_combo_box_set_active (GTK_COMBO_BOX (priv->cm_chooser), 0);
333 debug_dialog_cm_chooser_changed_cb (
334 GTK_COMBO_BOX (priv->cm_chooser), debug_dialog);
338 debug_dialog_fill_cm_chooser (EmpathyDebugDialog *debug_dialog)
341 GError *error = NULL;
343 dbus = tp_dbus_daemon_dup (&error);
347 DEBUG ("Failed to dup dbus daemon: %s", error->message);
348 g_error_free (error);
352 tp_list_connection_names (dbus, debug_dialog_list_connection_names_cb,
353 debug_dialog, NULL, NULL);
355 g_object_unref (dbus);
359 debug_dialog_pause_toggled_cb (GtkToggleToolButton *pause,
360 EmpathyDebugDialog *debug_dialog)
362 EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog);
364 priv->paused = gtk_toggle_tool_button_get_active (pause);
366 debug_dialog_set_enabled (debug_dialog, !priv->paused);
370 debug_dialog_visible_func (GtkTreeModel *model,
374 EmpathyDebugDialog *debug_dialog = (EmpathyDebugDialog *) user_data;
375 EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog);
376 guint filter_value, level;
377 GtkTreeModel *filter_model;
378 GtkTreeIter filter_iter;
380 filter_model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->filter));
381 gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->filter),
384 gtk_tree_model_get (model, iter, COL_DEBUG_LEVEL_VALUE, &level, -1);
385 gtk_tree_model_get (filter_model, &filter_iter,
386 COL_LEVEL_VALUE, &filter_value, -1);
388 if (level <= filter_value)
395 debug_dialog_filter_changed_cb (GtkComboBox *filter,
396 EmpathyDebugDialog *debug_dialog)
398 EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog);
400 gtk_tree_model_filter_refilter (
401 GTK_TREE_MODEL_FILTER (priv->store_filter));
405 debug_dialog_clear_clicked_cb (GtkToolButton *clear_button,
406 EmpathyDebugDialog *debug_dialog)
408 EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog);
410 gtk_list_store_clear (priv->store);
414 debug_dialog_menu_copy_activate_cb (GtkMenuItem *menu_item,
415 EmpathyDebugDialog *debug_dialog)
417 EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog);
419 GtkTreeViewColumn *focus_column;
422 GtkClipboard *clipboard;
424 gtk_tree_view_get_cursor (GTK_TREE_VIEW (priv->view),
425 &path, &focus_column);
429 DEBUG ("No row is in focus");
433 gtk_tree_model_get_iter (priv->store_filter, &iter, path);
435 gtk_tree_model_get (priv->store_filter, &iter,
436 COL_DEBUG_MESSAGE, &message,
439 if (EMP_STR_EMPTY (message))
441 DEBUG ("Log message is empty");
445 clipboard = gtk_clipboard_get_for_display (
446 gtk_widget_get_display (GTK_WIDGET (menu_item)),
447 GDK_SELECTION_CLIPBOARD);
449 gtk_clipboard_set_text (clipboard, message, -1);
456 EmpathyDebugDialog *debug_dialog;
462 debug_dialog_show_menu (gpointer user_data)
464 MenuPopupData *data = (MenuPopupData *) user_data;
465 GtkWidget *menu, *item;
468 menu = gtk_menu_new ();
469 shell = GTK_MENU_SHELL (menu);
471 item = gtk_image_menu_item_new_from_stock (GTK_STOCK_COPY, NULL);
473 g_signal_connect (item, "activate",
474 G_CALLBACK (debug_dialog_menu_copy_activate_cb), data->debug_dialog);
476 gtk_menu_shell_append (shell, item);
477 gtk_widget_show (item);
479 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
480 data->button, data->time);
482 g_slice_free (MenuPopupData, user_data);
488 debug_dialog_button_press_event_cb (GtkTreeView *view,
489 GdkEventButton *event,
492 /* A mouse button was pressed on the tree view. */
494 if (event->button == 3)
496 /* The tree view was right-clicked. (3 == third mouse button) */
498 data = g_slice_new0 (MenuPopupData);
499 data->debug_dialog = user_data;
500 data->button = event->button;
501 data->time = event->time;
502 g_idle_add (debug_dialog_show_menu, data);
509 debug_dialog_store_filter_foreach (GtkTreeModel *model,
514 GFileOutputStream *output_stream = (GFileOutputStream *) user_data;
515 gchar *domain, *category, *message, *level_str, *level_upper;
518 GError *error = NULL;
519 gboolean out = FALSE;
521 gtk_tree_model_get (model, iter,
522 COL_DEBUG_TIMESTAMP, ×tamp,
523 COL_DEBUG_DOMAIN, &domain,
524 COL_DEBUG_CATEGORY, &category,
525 COL_DEBUG_LEVEL_STRING, &level_str,
526 COL_DEBUG_MESSAGE, &message,
529 level_upper = g_ascii_strup (level_str, -1);
531 line = g_strdup_printf ("%s%s%s-%s: %e: %s\n",
532 domain, EMP_STR_EMPTY (category) ? "" : "/",
533 category, level_upper, timestamp, message);
535 g_output_stream_write (G_OUTPUT_STREAM (output_stream), line,
536 strlen (line), NULL, &error);
540 DEBUG ("Failed to write to file: %s", error->message);
541 g_error_free (error);
546 g_free (level_upper);
556 debug_dialog_save_file_chooser_response_cb (GtkDialog *dialog,
558 EmpathyDebugDialog *debug_dialog)
560 EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog);
561 gchar *filename = NULL;
563 GFileOutputStream *output_stream = NULL;
564 GError *error = NULL;
566 if (response_id != GTK_RESPONSE_ACCEPT)
569 filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
571 DEBUG ("Saving log as %s", filename);
573 gfile = g_file_new_for_path (filename);
574 output_stream = g_file_replace (gfile, NULL, FALSE,
575 G_FILE_CREATE_NONE, NULL, &error);
579 DEBUG ("Failed to open file for writing: %s", error->message);
580 g_error_free (error);
584 gtk_tree_model_foreach (priv->store_filter,
585 debug_dialog_store_filter_foreach, output_stream);
589 g_object_unref (gfile);
591 if (output_stream != NULL)
592 g_object_unref (output_stream);
594 if (filename != NULL)
597 gtk_widget_destroy (GTK_WIDGET (dialog));
601 debug_dialog_save_clicked_cb (GtkToolButton *tool_button,
602 EmpathyDebugDialog *debug_dialog)
604 GtkWidget *file_chooser;
606 file_chooser = gtk_file_chooser_dialog_new (_("Save"),
607 GTK_WINDOW (debug_dialog), GTK_FILE_CHOOSER_ACTION_SAVE,
608 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
609 GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
612 gtk_window_set_modal (GTK_WINDOW (file_chooser), TRUE);
613 gtk_file_chooser_set_do_overwrite_confirmation (
614 GTK_FILE_CHOOSER (file_chooser), TRUE);
616 g_signal_connect (file_chooser, "response",
617 G_CALLBACK (debug_dialog_save_file_chooser_response_cb),
620 gtk_widget_show (file_chooser);
624 debug_dialog_constructor (GType type,
625 guint n_construct_params,
626 GObjectConstructParam *construct_params)
629 EmpathyDebugDialogPriv *priv;
635 GtkCellRenderer *renderer;
636 GtkWidget *scrolled_win;
637 GtkListStore *level_store;
640 object = G_OBJECT_CLASS (empathy_debug_dialog_parent_class)->constructor
641 (type, n_construct_params, construct_params);
642 priv = GET_PRIV (object);
644 gtk_window_set_title (GTK_WINDOW (object), _("Debug Window"));
645 gtk_window_set_default_size (GTK_WINDOW (object), 800, 400);
646 gtk_window_set_transient_for (GTK_WINDOW (object), priv->parent);
648 vbox = GTK_DIALOG (object)->vbox;
650 toolbar = gtk_toolbar_new ();
651 gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH_HORIZ);
652 gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), TRUE);
653 gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar),
654 GTK_ICON_SIZE_SMALL_TOOLBAR);
655 gtk_widget_show (toolbar);
657 gtk_box_pack_start (GTK_BOX (vbox), toolbar, FALSE, FALSE, 0);
660 priv->cm_chooser = gtk_combo_box_new_text ();
661 priv->cms = gtk_list_store_new (NUM_COLS_CM, G_TYPE_STRING, G_TYPE_STRING);
662 gtk_combo_box_set_model (GTK_COMBO_BOX (priv->cm_chooser),
663 GTK_TREE_MODEL (priv->cms));
664 gtk_widget_show (priv->cm_chooser);
666 item = gtk_tool_item_new ();
667 gtk_widget_show (GTK_WIDGET (item));
668 gtk_container_add (GTK_CONTAINER (item), priv->cm_chooser);
669 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
670 debug_dialog_fill_cm_chooser (EMPATHY_DEBUG_DIALOG (object));
671 g_signal_connect (priv->cm_chooser, "changed",
672 G_CALLBACK (debug_dialog_cm_chooser_changed_cb), object);
673 gtk_widget_show (GTK_WIDGET (priv->cm_chooser));
675 item = gtk_separator_tool_item_new ();
676 gtk_widget_show (GTK_WIDGET (item));
677 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
680 item = gtk_tool_button_new_from_stock (GTK_STOCK_SAVE);
681 g_signal_connect (item, "clicked",
682 G_CALLBACK (debug_dialog_save_clicked_cb), object);
683 gtk_widget_show (GTK_WIDGET (item));
684 gtk_tool_item_set_is_important (GTK_TOOL_ITEM (item), TRUE);
685 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
688 item = gtk_tool_button_new_from_stock (GTK_STOCK_CLEAR);
689 g_signal_connect (item, "clicked",
690 G_CALLBACK (debug_dialog_clear_clicked_cb), object);
691 gtk_widget_show (GTK_WIDGET (item));
692 gtk_tool_item_set_is_important (GTK_TOOL_ITEM (item), TRUE);
693 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
695 item = gtk_separator_tool_item_new ();
696 gtk_widget_show (GTK_WIDGET (item));
697 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
700 priv->paused = FALSE;
701 image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_PAUSE,
703 gtk_widget_show (image);
704 item = gtk_toggle_tool_button_new ();
705 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (item),
707 g_signal_connect (item, "toggled",
708 G_CALLBACK (debug_dialog_pause_toggled_cb), object);
709 gtk_widget_show (GTK_WIDGET (item));
710 gtk_tool_item_set_is_important (GTK_TOOL_ITEM (item), TRUE);
711 gtk_tool_button_set_label (GTK_TOOL_BUTTON (item), _("Pause"));
712 gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (item), image);
713 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
715 item = gtk_separator_tool_item_new ();
716 gtk_widget_show (GTK_WIDGET (item));
717 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
720 item = gtk_tool_item_new ();
721 gtk_widget_show (GTK_WIDGET (item));
722 label = gtk_label_new (_("Level "));
723 gtk_widget_show (label);
724 gtk_container_add (GTK_CONTAINER (item), label);
725 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
727 priv->filter = gtk_combo_box_new_text ();
728 gtk_widget_show (priv->filter);
730 item = gtk_tool_item_new ();
731 gtk_widget_show (GTK_WIDGET (item));
732 gtk_container_add (GTK_CONTAINER (item), priv->filter);
733 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
735 level_store = gtk_list_store_new (NUM_COLS_LEVEL,
736 G_TYPE_STRING, G_TYPE_UINT);
737 gtk_combo_box_set_model (GTK_COMBO_BOX (priv->filter),
738 GTK_TREE_MODEL (level_store));
740 gtk_list_store_append (level_store, &iter);
741 gtk_list_store_set (level_store, &iter,
742 COL_LEVEL_NAME, _("Debug"),
743 COL_LEVEL_VALUE, EMP_DEBUG_LEVEL_DEBUG,
746 gtk_list_store_append (level_store, &iter);
747 gtk_list_store_set (level_store, &iter,
748 COL_LEVEL_NAME, _("Info"),
749 COL_LEVEL_VALUE, EMP_DEBUG_LEVEL_INFO,
752 gtk_list_store_append (level_store, &iter);
753 gtk_list_store_set (level_store, &iter,
754 COL_LEVEL_NAME, _("Message"),
755 COL_LEVEL_VALUE, EMP_DEBUG_LEVEL_MESSAGE,
758 gtk_list_store_append (level_store, &iter);
759 gtk_list_store_set (level_store, &iter,
760 COL_LEVEL_NAME, _("Warning"),
761 COL_LEVEL_VALUE, EMP_DEBUG_LEVEL_WARNING,
764 gtk_list_store_append (level_store, &iter);
765 gtk_list_store_set (level_store, &iter,
766 COL_LEVEL_NAME, _("Critical"),
767 COL_LEVEL_VALUE, EMP_DEBUG_LEVEL_CRITICAL,
770 gtk_list_store_append (level_store, &iter);
771 gtk_list_store_set (level_store, &iter,
772 COL_LEVEL_NAME, _("Error"),
773 COL_LEVEL_VALUE, EMP_DEBUG_LEVEL_ERROR,
776 gtk_combo_box_set_active (GTK_COMBO_BOX (priv->filter), 0);
777 g_signal_connect (priv->filter, "changed",
778 G_CALLBACK (debug_dialog_filter_changed_cb), object);
781 priv->view = gtk_tree_view_new ();
782 gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (priv->view), TRUE);
784 g_signal_connect (priv->view, "button-press-event",
785 G_CALLBACK (debug_dialog_button_press_event_cb), object);
787 renderer = gtk_cell_renderer_text_new ();
788 g_object_set (renderer, "yalign", 0, NULL);
790 gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->view),
791 -1, _("Time"), renderer, "text", COL_DEBUG_TIMESTAMP, NULL);
792 gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->view),
793 -1, _("Domain"), renderer, "text", COL_DEBUG_DOMAIN, NULL);
794 gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->view),
795 -1, _("Category"), renderer, "text", COL_DEBUG_CATEGORY, NULL);
796 gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->view),
797 -1, _("Level"), renderer, "text", COL_DEBUG_LEVEL_STRING, NULL);
799 renderer = gtk_cell_renderer_text_new ();
800 g_object_set (renderer, "family", "Monospace", NULL);
801 gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->view),
802 -1, _("Message"), renderer, "text", COL_DEBUG_MESSAGE, NULL);
804 priv->store = gtk_list_store_new (NUM_DEBUG_COLS, G_TYPE_DOUBLE,
805 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
808 priv->store_filter = gtk_tree_model_filter_new (
809 GTK_TREE_MODEL (priv->store), NULL);
811 gtk_tree_model_filter_set_visible_func (
812 GTK_TREE_MODEL_FILTER (priv->store_filter),
813 debug_dialog_visible_func, object, NULL);
815 gtk_tree_view_set_model (GTK_TREE_VIEW (priv->view), priv->store_filter);
817 /* Scrolled window */
818 scrolled_win = gtk_scrolled_window_new (NULL, NULL);
819 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
820 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
822 gtk_widget_show (priv->view);
823 gtk_container_add (GTK_CONTAINER (scrolled_win), priv->view);
825 gtk_widget_show (scrolled_win);
826 gtk_box_pack_start (GTK_BOX (vbox), scrolled_win, TRUE, TRUE, 0);
828 gtk_widget_show (GTK_WIDGET (object));
834 empathy_debug_dialog_init (EmpathyDebugDialog *empathy_debug_dialog)
836 EmpathyDebugDialogPriv *priv =
837 G_TYPE_INSTANCE_GET_PRIVATE (empathy_debug_dialog,
838 EMPATHY_TYPE_DEBUG_DIALOG, EmpathyDebugDialogPriv);
840 empathy_debug_dialog->priv = priv;
842 priv->dispose_run = FALSE;
846 debug_dialog_set_property (GObject *object,
851 EmpathyDebugDialogPriv *priv = GET_PRIV (object);
856 priv->parent = GTK_WINDOW (g_value_dup_object (value));
859 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
865 debug_dialog_get_property (GObject *object,
870 EmpathyDebugDialogPriv *priv = GET_PRIV (object);
875 g_value_set_object (value, priv->parent);
878 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
884 debug_dialog_dispose (GObject *object)
886 EmpathyDebugDialog *selector = EMPATHY_DEBUG_DIALOG (object);
887 EmpathyDebugDialogPriv *priv = GET_PRIV (selector);
889 if (priv->dispose_run)
892 priv->dispose_run = TRUE;
894 if (priv->parent != NULL)
895 g_object_unref (priv->parent);
897 if (priv->store != NULL)
898 g_object_unref (priv->store);
900 if (priv->proxy != NULL)
902 debug_dialog_set_enabled (EMPATHY_DEBUG_DIALOG (object), FALSE);
903 g_object_unref (priv->proxy);
906 if (priv->signal_connection != NULL)
907 tp_proxy_signal_connection_disconnect (priv->signal_connection);
909 if (priv->cms != NULL)
910 g_object_unref (priv->cms);
912 (G_OBJECT_CLASS (empathy_debug_dialog_parent_class)->dispose) (object);
916 empathy_debug_dialog_class_init (EmpathyDebugDialogClass *klass)
918 GObjectClass *object_class = G_OBJECT_CLASS (klass);
919 object_class->constructor = debug_dialog_constructor;
920 object_class->dispose = debug_dialog_dispose;
921 object_class->set_property = debug_dialog_set_property;
922 object_class->get_property = debug_dialog_get_property;
923 g_type_class_add_private (klass, sizeof (EmpathyDebugDialogPriv));
925 g_object_class_install_property (object_class, PROP_PARENT,
926 g_param_spec_object ("parent", "parent", "parent",
927 GTK_TYPE_WINDOW, G_PARAM_CONSTRUCT_ONLY |
928 G_PARAM_READWRITE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
934 empathy_debug_dialog_new (GtkWindow *parent)
936 g_return_val_if_fail (GTK_IS_WINDOW (parent), NULL);
938 return GTK_WIDGET (g_object_new (EMPATHY_TYPE_DEBUG_DIALOG,
939 "parent", parent, NULL));