aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2008-05-05 08:18:08 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2008-05-05 08:18:08 +0800
commitcdb1c9918875119c87fa6243444b9148cffdba15 (patch)
tree9bb8fbf59048fd80f88ed0655499305e1b9389be /mail
parent915ac7e4026aec67699e24637e35ddf081f8c350 (diff)
downloadgsoc2013-evolution-cdb1c9918875119c87fa6243444b9148cffdba15.tar
gsoc2013-evolution-cdb1c9918875119c87fa6243444b9148cffdba15.tar.gz
gsoc2013-evolution-cdb1c9918875119c87fa6243444b9148cffdba15.tar.bz2
gsoc2013-evolution-cdb1c9918875119c87fa6243444b9148cffdba15.tar.lz
gsoc2013-evolution-cdb1c9918875119c87fa6243444b9148cffdba15.tar.xz
gsoc2013-evolution-cdb1c9918875119c87fa6243444b9148cffdba15.tar.zst
gsoc2013-evolution-cdb1c9918875119c87fa6243444b9148cffdba15.zip
Fix up the Debug Logs window a bit: - Add a Close button. - Fix some
2008-05-04 Matthew Barnes <mbarnes@redhat.com> * mail/mail-component.c (mail_component_show_logger): Fix up the Debug Logs window a bit: - Add a Close button. - Fix some spacing issues (HIG compliance). - Just show the log level icon. Add a tooltip for the icon showing a description of the log level (Error/Warning/Debug). Also, avoid using e-icon-factory. Set the GtkCellRendererPixbuf's "stock-id" and "stock-size" properties instead. - Use GConfBridge to track the user's log level preference. svn path=/trunk/; revision=35466
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog12
-rw-r--r--mail/mail-component.c269
2 files changed, 165 insertions, 116 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 11a39b674c..c36c6d7873 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,15 @@
+2008-05-04 Matthew Barnes <mbarnes@redhat.com>
+
+ * mail-component.c (mail_component_show_logger):
+ Fix up the Debug Logs window a bit:
+ - Add a Close button.
+ - Fix some spacing issues (HIG compliance).
+ - Just show the log level icon. Add a tooltip for the icon showing
+ a description of the log level (Error/Warning/Debug). Also, avoid
+ using e-icon-factory. Set the GtkCellRendererPixbuf's "stock-id"
+ and "stock-size" properties instead.
+ - Use GConfBridge to track the user's log level preference.
+
2008-04-30 Milan Crha <mcrha@redhat.com>
** Fix for bug #528288
diff --git a/mail/mail-component.c b/mail/mail-component.c
index 3a1bfc39f4..8e96477c84 100644
--- a/mail/mail-component.c
+++ b/mail/mail-component.c
@@ -46,13 +46,13 @@
#include "em-folder-selection.h"
#include "em-folder-utils.h"
#include "em-migrate.h"
-#include "e-util/e-icon-factory.h"
#include "misc/e-info-label.h"
#include "e-util/e-util.h"
#include "e-util/e-error.h"
#include "e-util/e-util-private.h"
#include "e-util/e-logger.h"
+#include "e-util/gconf-bridge.h"
#include "em-search-context.h"
#include "mail-config.h"
@@ -1529,12 +1529,12 @@ struct _log_data {
int level;
char *key;
char *text;
- char *icon;
+ char *stock_id;
GdkPixbuf *pbuf;
} ldata [] = {
- { E_LOG_ERROR, N_("Error"), N_("Errors"), "stock_dialog-error" },
- { E_LOG_WARNINGS, N_("Warning"), N_("Warnings and Errors"), "stock_dialog-warning" },
- { E_LOG_DEBUG, N_("Debug"), N_("Error, Warnings and Debug messages"), "stock_dialog-info" }
+ { E_LOG_ERROR, N_("Error"), N_("Errors"), GTK_STOCK_DIALOG_ERROR },
+ { E_LOG_WARNINGS, N_("Warning"), N_("Warnings and Errors"), GTK_STOCK_DIALOG_WARNING },
+ { E_LOG_DEBUG, N_("Debug"), N_("Error, Warnings and Debug messages"), GTK_STOCK_DIALOG_INFO }
};
enum
@@ -1544,33 +1544,54 @@ enum
COL_DATA
};
-static void
-render_pixbuf (GtkTreeViewColumn *column, GtkCellRenderer *renderer,
- GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
+static gboolean
+query_tooltip_cb (GtkTreeView *view,
+ gint x,
+ gint y,
+ gboolean keyboard_mode,
+ GtkTooltip *tooltip)
{
- static gboolean initialised = FALSE;
+ GtkTreeViewColumn *column;
+ GtkTreeModel *model;
+ GtkTreePath *path;
+ GtkTreeIter iter;
gint level;
- int i;
- if (!initialised) {
- for (i=E_LOG_ERROR; i<=E_LOG_DEBUG; i++) {
- ldata[i].pbuf = e_icon_factory_get_icon (ldata[i].icon, E_ICON_SIZE_MENU);
- }
- initialised = TRUE;
- }
-
- gtk_tree_model_get (model, iter, COL_LEVEL, &level, -1);
- g_object_set (renderer, "pixbuf", ldata[level].pbuf, "visible", TRUE, NULL);
+ if (!gtk_tree_view_get_tooltip_context (
+ view, &x, &y, keyboard_mode, NULL, &path, &iter))
+ return FALSE;
+
+ /* Figure out which column we're pointing at. */
+ if (keyboard_mode)
+ gtk_tree_view_get_cursor (view, NULL, &column);
+ else
+ gtk_tree_view_get_path_at_pos (
+ view, x, y, NULL, &column, NULL, NULL);
+
+ /* Restrict the tip area to a single cell. */
+ gtk_tree_view_set_tooltip_cell (view, tooltip, path, column, NULL);
+
+ /* This only works if the tree view is NOT reorderable. */
+ if (column != gtk_tree_view_get_column (view, 0))
+ return FALSE;
+
+ model = gtk_tree_view_get_model (view);
+ gtk_tree_model_get (model, &iter, COL_LEVEL, &level, -1);
+ gtk_tooltip_set_text (tooltip, ldata[level].key);
+
+ return TRUE;
}
static void
-render_level (GtkTreeViewColumn *column, GtkCellRenderer *renderer,
- GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
+render_pixbuf (GtkTreeViewColumn *column, GtkCellRenderer *renderer,
+ GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
{
gint level;
gtk_tree_model_get (model, iter, COL_LEVEL, &level, -1);
- g_object_set (renderer, "text", ldata[level].key, NULL);
+ g_object_set (
+ renderer, "stock-id", ldata[level].stock_id,
+ "stock-size", GTK_ICON_SIZE_MENU, NULL);
}
static void
@@ -1632,119 +1653,135 @@ void
mail_component_show_logger (gpointer top)
{
MailComponent *mc = mail_component_peek ();
- GtkWidget *window, *hbox, *vbox, *spin, *label, *combo, *scrolled;
+ GConfBridge *bridge;
+ GtkWidget *container;
+ GtkWidget *label;
+ GtkWidget *toplevel;
+ GtkWidget *vbox;
+ GtkWidget *widget;
+ GtkWidget *window;
ELogger *logger = mc->priv->logger;
int i;
GtkListStore *store;
GtkCellRenderer *renderer;
- GtkTreeView *treeview;
GtkTreeViewColumn *column;
+ bridge = gconf_bridge_get ();
+ toplevel = gtk_widget_get_toplevel (top);
+
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_transient_for ((GtkWindow *) window, (GtkWindow *) gtk_widget_get_toplevel ((GtkWidget *) top));
- gtk_container_set_border_width ((GtkContainer *) window, 6);
- gtk_window_set_default_size ((GtkWindow *)window, 500, 400);
- gtk_window_set_title ((GtkWindow *) window, _("Debug Logs"));
- vbox = gtk_vbox_new (FALSE, 6);
- hbox = gtk_hbox_new (FALSE, 6);
- gtk_container_add ((GtkContainer *) window, vbox);
- /* Translators: This is the first part of the sentence "Show _errors in the status bar for" - XXX - "second(s)." */
- label = gtk_label_new_with_mnemonic (_("Show _errors in the status bar for"));
- gtk_box_pack_start ((GtkBox *) hbox, label, FALSE, FALSE, 6);
- spin = gtk_spin_button_new_with_range(1.0, 60.0, 1.0);
- gtk_spin_button_set_value ((GtkSpinButton *) spin, (double) mail_config_get_error_timeout ());
- g_signal_connect (spin, "value-changed", G_CALLBACK (spin_value_changed), NULL);
- gtk_label_set_mnemonic_widget ((GtkLabel *) label, spin);
- gtk_box_pack_start ((GtkBox *) hbox, spin, FALSE, FALSE, 6);
- /* Translators: This is the second part of the sentence "Show _errors in the status bar for" - XXX - "second(s)." */
- label = gtk_label_new_with_mnemonic (_("second(s)."));
- gtk_box_pack_start ((GtkBox *) hbox, label, FALSE, FALSE, 6);
- gtk_box_pack_start ((GtkBox *) vbox, hbox, FALSE, FALSE, 6);
-
- combo = gtk_combo_box_new_text ();
- for (i = E_LOG_ERROR; i <=E_LOG_DEBUG; i++)
- gtk_combo_box_append_text (GTK_COMBO_BOX (combo), ldata[i].text);
- gtk_combo_box_set_active ((GtkComboBox *) combo, mail_config_get_error_level ());
-
- hbox = gtk_hbox_new (FALSE, 6);
- label = gtk_label_new_with_mnemonic (_("Log Messages:"));
- gtk_label_set_mnemonic_widget ((GtkLabel *) label, combo);
- gtk_box_pack_start ((GtkBox *) hbox, label, FALSE, FALSE, 6);
- gtk_box_pack_start ((GtkBox *) hbox, combo, FALSE, FALSE, 6);
- gtk_box_pack_start ((GtkBox *) vbox, hbox, FALSE, FALSE, 6);
-
- store = gtk_list_store_new(3, G_TYPE_INT, G_TYPE_LONG, G_TYPE_STRING);
+ gtk_window_set_default_size (GTK_WINDOW (window), 500, 400);
+ gtk_window_set_title (GTK_WINDOW (window), _("Debug Logs"));
+ gtk_window_set_transient_for (
+ GTK_WINDOW (window), GTK_WINDOW (toplevel));
+ gtk_container_set_border_width (GTK_CONTAINER (window), 12);
+
+ vbox = gtk_vbox_new (FALSE, 12);
+ gtk_container_add (GTK_CONTAINER (window), vbox);
+
+ container = gtk_hbox_new (FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (vbox), container, FALSE, FALSE, 0);
+
+ /* Translators: This is the first part of the sentence
+ * "Show _errors in the status bar for" - XXX - "second(s)." */
+ widget = gtk_label_new_with_mnemonic (
+ _("Show _errors in the status bar for"));
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ label = widget;
+
+ widget = gtk_spin_button_new_with_range (1.0, 60.0, 1.0);
+ gtk_spin_button_set_value (
+ GTK_SPIN_BUTTON (widget),
+ (gdouble) mail_config_get_error_timeout ());
+ g_signal_connect (
+ widget, "value-changed",
+ G_CALLBACK (spin_value_changed), NULL);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+
+ /* Translators: This is the second part of the sentence
+ * "Show _errors in the status bar for" - XXX - "second(s)." */
+ widget = gtk_label_new_with_mnemonic (_("second(s)."));
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+
+ container = gtk_hbox_new (FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (vbox), container, FALSE, FALSE, 0);
+
+ widget = gtk_label_new_with_mnemonic (_("Log Messages:"));
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ label = widget;
+
+ widget = gtk_combo_box_new_text ();
+ for (i = E_LOG_ERROR; i <= E_LOG_DEBUG; i++)
+ gtk_combo_box_append_text (
+ GTK_COMBO_BOX (widget), ldata[i].text);
+ gconf_bridge_bind_property (
+ bridge, "/apps/evolution/mail/display/error_level",
+ G_OBJECT (widget), "active");
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+
+ store = gtk_list_store_new (3, G_TYPE_INT, G_TYPE_LONG, G_TYPE_STRING);
e_logger_get_logs (logger, (ELogFunction) append_logs, store);
- if (0)
- {
- GtkTreeIter iter;
- gtk_list_store_append(store, &iter);
- gtk_list_store_set(store, &iter,
- COL_LEVEL, 0,
- COL_TIME, "21/12/07 10:55 PM",
- COL_DATA, "Error Refreshing Folder",
- -1);
- gtk_list_store_append(store, &iter);
- gtk_list_store_set(store, &iter,
- COL_LEVEL, 1,
- COL_TIME, "21/12/07 10:55 PM",
- COL_DATA, "Error refreshing folder",
- -1);
- gtk_list_store_append(store, &iter);
- gtk_list_store_set(store, &iter,
- COL_LEVEL, 2,
- COL_TIME, "21/12/07 10:55 PM",
- COL_DATA, "Error refreshing folder",
- -1);
- }
- gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE (store),
- COL_TIME, GTK_SORT_DESCENDING);
-
-
- treeview = (GtkTreeView *)gtk_tree_view_new();
- gtk_tree_view_set_rules_hint ((GtkTreeView *) treeview, TRUE);
- gtk_tree_view_set_reorderable(GTK_TREE_VIEW(treeview), FALSE);
- gtk_tree_view_set_model(treeview, GTK_TREE_MODEL (store));
- gtk_tree_view_set_search_column(treeview, COL_DATA);
- gtk_tree_view_set_headers_visible(treeview, TRUE);
-
- column = gtk_tree_view_column_new ();
- gtk_tree_view_append_column ((GtkTreeView *) treeview, column);
- renderer = gtk_cell_renderer_pixbuf_new ();
- gtk_tree_view_column_pack_start (column, renderer, FALSE);
- gtk_tree_view_column_set_cell_data_func (column, renderer, render_pixbuf, NULL, NULL);
-
+ gtk_tree_sortable_set_sort_column_id (
+ GTK_TREE_SORTABLE (store), COL_TIME, GTK_SORT_DESCENDING);
+
+ container = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (
+ GTK_SCROLLED_WINDOW (container),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (
+ GTK_SCROLLED_WINDOW (container), GTK_SHADOW_IN);
+ gtk_box_pack_start (GTK_BOX (vbox), container, TRUE, TRUE, 0);
+
+ widget = gtk_tree_view_new();
+ gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (widget), TRUE);
+ gtk_tree_view_set_reorderable (GTK_TREE_VIEW (widget), FALSE);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (widget), GTK_TREE_MODEL (store));
+ gtk_tree_view_set_search_column (GTK_TREE_VIEW (widget), COL_DATA);
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (widget), TRUE);
+ gtk_widget_set_has_tooltip (widget, TRUE);
+ gtk_container_add (GTK_CONTAINER (container), widget);
+
+ g_signal_connect (
+ widget, "query-tooltip",
+ G_CALLBACK (query_tooltip_cb), NULL);
column = gtk_tree_view_column_new ();
- gtk_tree_view_append_column ((GtkTreeView *) treeview, column);
- renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (column, renderer, FALSE);
gtk_tree_view_column_set_title (column, _("Log Level"));
- gtk_tree_view_column_set_cell_data_func (column, renderer, render_level, NULL, NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (widget), column);
+ renderer = gtk_cell_renderer_pixbuf_new ();
+ gtk_tree_view_column_pack_start (column, renderer, TRUE);
+ gtk_tree_view_column_set_cell_data_func (
+ column, renderer, render_pixbuf, NULL, NULL);
column = gtk_tree_view_column_new ();
- gtk_tree_view_append_column ((GtkTreeView *) treeview, column);
- renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_column_set_title (column, _("Time"));
- gtk_tree_view_column_pack_start (column, renderer, FALSE);
- gtk_tree_view_column_set_cell_data_func (column, renderer, render_date, NULL, NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (widget), column);
-
renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_insert_column_with_attributes(treeview,
- -1, _("Messages"),
- renderer, "text", COL_DATA,
- NULL);
-
- scrolled = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled), GTK_SHADOW_IN);
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
+ gtk_tree_view_column_set_cell_data_func (
+ column, renderer, render_date, NULL, NULL);
- gtk_container_add (GTK_CONTAINER (scrolled), (GtkWidget *) treeview);
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_tree_view_insert_column_with_attributes(
+ GTK_TREE_VIEW (widget), -1, _("Messages"),
+ renderer, "text", COL_DATA, NULL);
+
+ container = gtk_hbutton_box_new ();
+ gtk_button_box_set_layout (
+ GTK_BUTTON_BOX (container), GTK_BUTTONBOX_END);
+ gtk_box_pack_start (GTK_BOX (vbox), container, FALSE, FALSE, 0);
+
+ widget = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
+ gtk_widget_set_tooltip_text (widget, _("Close this window"));
+ g_signal_connect_swapped (
+ widget, "clicked",
+ G_CALLBACK (gtk_widget_destroy), window);
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- gtk_box_pack_start ((GtkBox *) vbox, (GtkWidget *) scrolled, TRUE, TRUE, 6);
gtk_widget_show_all (window);
}