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>
26 #include <libempathy/empathy-utils.h>
28 #include "empathy-debug-dialog.h"
30 G_DEFINE_TYPE (EmpathyDebugDialog, empathy_debug_dialog,
49 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyDebugDialog)
57 } EmpathyDebugDialogPriv;
60 debug_dialog_constructor (GType type,
61 guint n_construct_params,
62 GObjectConstructParam *construct_params)
65 EmpathyDebugDialogPriv *priv;
70 GtkCellRenderer *renderer;
71 GtkWidget *scrolled_win;
76 object = G_OBJECT_CLASS (empathy_debug_dialog_parent_class)->constructor
77 (type, n_construct_params, construct_params);
78 priv = GET_PRIV (object);
80 gtk_window_set_title (GTK_WINDOW (object), _("Debug Window"));
81 gtk_window_set_default_size (GTK_WINDOW (object), 800, 400);
82 gtk_window_set_transient_for (GTK_WINDOW (object), priv->parent);
84 vbox = GTK_DIALOG (object)->vbox;
86 toolbar = gtk_toolbar_new ();
87 gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH_HORIZ);
88 gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), TRUE);
89 gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_SMALL_TOOLBAR);
90 gtk_widget_show (toolbar);
92 gtk_box_pack_start (GTK_BOX (vbox), toolbar, FALSE, FALSE, 0);
95 item = gtk_tool_button_new_from_stock (GTK_STOCK_SAVE);
96 gtk_widget_show (GTK_WIDGET (item));
97 gtk_tool_item_set_is_important (GTK_TOOL_ITEM (item), TRUE);
98 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
101 item = gtk_tool_button_new_from_stock (GTK_STOCK_CLEAR);
102 gtk_widget_show (GTK_WIDGET (item));
103 gtk_tool_item_set_is_important (GTK_TOOL_ITEM (item), TRUE);
104 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
106 item = gtk_separator_tool_item_new ();
107 gtk_widget_show (GTK_WIDGET (item));
108 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
111 image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_PAUSE, GTK_ICON_SIZE_MENU);
112 gtk_widget_show (image);
113 item = gtk_toggle_tool_button_new ();
114 gtk_widget_show (GTK_WIDGET (item));
115 gtk_tool_item_set_is_important (GTK_TOOL_ITEM (item), TRUE);
116 gtk_tool_button_set_label (GTK_TOOL_BUTTON (item), _("Pause"));
117 gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (item), image);
118 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
120 item = gtk_separator_tool_item_new ();
121 gtk_widget_show (GTK_WIDGET (item));
122 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
125 item = gtk_tool_item_new ();
126 gtk_widget_show (GTK_WIDGET (item));
127 gtk_container_add (GTK_CONTAINER (item), gtk_label_new (_("Level ")));
128 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
130 priv->filter = gtk_combo_box_new_text ();
131 gtk_widget_show (priv->filter);
133 item = gtk_tool_item_new ();
134 gtk_widget_show (GTK_WIDGET (item));
135 gtk_container_add (GTK_CONTAINER (item), priv->filter);
136 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
138 gtk_combo_box_append_text (GTK_COMBO_BOX (priv->filter), _("All"));
139 gtk_combo_box_append_text (GTK_COMBO_BOX (priv->filter), _("Debug"));
140 gtk_combo_box_append_text (GTK_COMBO_BOX (priv->filter), _("Info"));
141 gtk_combo_box_append_text (GTK_COMBO_BOX (priv->filter), _("Message"));
142 gtk_combo_box_append_text (GTK_COMBO_BOX (priv->filter), _("Warning"));
143 gtk_combo_box_append_text (GTK_COMBO_BOX (priv->filter), _("Critical"));
144 gtk_combo_box_append_text (GTK_COMBO_BOX (priv->filter), _("Error"));
146 gtk_combo_box_set_active (GTK_COMBO_BOX (priv->filter), 0);
147 gtk_widget_show (GTK_WIDGET (priv->filter));
150 priv->view = gtk_tree_view_new ();
152 renderer = gtk_cell_renderer_text_new ();
154 gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->view),
155 -1, _("Time"), renderer, "text", COL_TIMESTAMP, NULL);
156 gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->view),
157 -1, _("Domain"), renderer, "text", COL_DOMAIN, NULL);
158 gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->view),
159 -1, _("Category"), renderer, "text", COL_CATEGORY, NULL);
160 gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->view),
161 -1, _("Level"), renderer, "text", COL_LEVEL, NULL);
162 gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->view),
163 -1, _("Message"), renderer, "text", COL_MESSAGE, NULL);
165 priv->store = gtk_list_store_new (NUM_COLS, G_TYPE_DOUBLE,
166 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
168 gtk_list_store_append (priv->store, &iter);
169 gtk_list_store_set (priv->store, &iter,
171 COL_DOMAIN, "domain",
172 COL_CATEGORY, "category",
174 COL_MESSAGE, "message",
177 gtk_tree_view_set_model (GTK_TREE_VIEW (priv->view),
178 GTK_TREE_MODEL (priv->store));
180 scrolled_win = gtk_scrolled_window_new (NULL, NULL);
181 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
182 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
184 gtk_widget_show (priv->view);
185 gtk_container_add (GTK_CONTAINER (scrolled_win), priv->view);
187 gtk_widget_show (scrolled_win);
188 gtk_box_pack_start (GTK_BOX (vbox), scrolled_win, TRUE, TRUE, 0);
190 gtk_widget_show (GTK_WIDGET (object));
196 empathy_debug_dialog_init (EmpathyDebugDialog *empathy_debug_dialog)
198 EmpathyDebugDialogPriv *priv =
199 G_TYPE_INSTANCE_GET_PRIVATE (empathy_debug_dialog,
200 EMPATHY_TYPE_DEBUG_DIALOG, EmpathyDebugDialogPriv);
202 empathy_debug_dialog->priv = priv;
204 priv->dispose_run = FALSE;
208 debug_dialog_set_property (GObject *object,
213 EmpathyDebugDialogPriv *priv = GET_PRIV (object);
218 priv->parent = GTK_WINDOW (g_value_dup_object (value));
221 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
227 debug_dialog_get_property (GObject *object,
232 EmpathyDebugDialogPriv *priv = GET_PRIV (object);
237 g_value_set_object (value, priv->parent);
240 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
246 debug_dialog_dispose (GObject *object)
248 EmpathyDebugDialog *selector = EMPATHY_DEBUG_DIALOG (object);
249 EmpathyDebugDialogPriv *priv = GET_PRIV (selector);
251 if (priv->dispose_run)
254 priv->dispose_run = TRUE;
257 g_object_unref (priv->parent);
260 g_object_unref (priv->store);
262 (G_OBJECT_CLASS (empathy_debug_dialog_parent_class)->dispose) (object);
266 empathy_debug_dialog_class_init (EmpathyDebugDialogClass *klass)
268 GObjectClass *object_class = G_OBJECT_CLASS (klass);
269 object_class->constructor = debug_dialog_constructor;
270 object_class->dispose = debug_dialog_dispose;
271 object_class->set_property = debug_dialog_set_property;
272 object_class->get_property = debug_dialog_get_property;
273 g_type_class_add_private (klass, sizeof (EmpathyDebugDialogPriv));
275 g_object_class_install_property (object_class, PROP_PARENT,
276 g_param_spec_object ("parent", "parent", "parent",
277 GTK_TYPE_WINDOW, G_PARAM_CONSTRUCT_ONLY |
278 G_PARAM_READWRITE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
284 empathy_debug_dialog_new (GtkWindow *parent)
286 return GTK_WIDGET (g_object_new (EMPATHY_TYPE_DEBUG_DIALOG,
287 "parent", parent, NULL));