aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-05-27 01:09:33 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-05-27 01:09:33 +0800
commitc9ec8c3f4dce2b02c91268529977770364ef87fe (patch)
treed574f2be1b5438407e59e2fead1321766c9bbc83 /widgets/misc
parent6fec6bf39467dd32625847be1b021a7e5bc94d76 (diff)
parent96538878911586a9e9ca26b81e1916c04e538980 (diff)
downloadgsoc2013-evolution-c9ec8c3f4dce2b02c91268529977770364ef87fe.tar
gsoc2013-evolution-c9ec8c3f4dce2b02c91268529977770364ef87fe.tar.gz
gsoc2013-evolution-c9ec8c3f4dce2b02c91268529977770364ef87fe.tar.bz2
gsoc2013-evolution-c9ec8c3f4dce2b02c91268529977770364ef87fe.tar.lz
gsoc2013-evolution-c9ec8c3f4dce2b02c91268529977770364ef87fe.tar.xz
gsoc2013-evolution-c9ec8c3f4dce2b02c91268529977770364ef87fe.tar.zst
gsoc2013-evolution-c9ec8c3f4dce2b02c91268529977770364ef87fe.zip
Merge branch 'express2'
Diffstat (limited to 'widgets/misc')
-rw-r--r--widgets/misc/e-account-combo-box.c22
-rw-r--r--widgets/misc/e-account-combo-box.h2
-rw-r--r--widgets/misc/e-preferences-window.c90
-rw-r--r--widgets/misc/e-preferences-window.h2
-rw-r--r--widgets/misc/e-web-view.c10
5 files changed, 122 insertions, 4 deletions
diff --git a/widgets/misc/e-account-combo-box.c b/widgets/misc/e-account-combo-box.c
index 43c7fb87a9..7d34a29bfe 100644
--- a/widgets/misc/e-account-combo-box.c
+++ b/widgets/misc/e-account-combo-box.c
@@ -40,6 +40,7 @@ enum {
struct _EAccountComboBoxPrivate {
EAccountList *account_list;
GHashTable *index;
+ gint num_displayed_accounts;
};
static gpointer parent_class;
@@ -149,6 +150,8 @@ account_combo_box_refresh_cb (EAccountList *account_list,
GList *list = NULL;
GList *iter;
+ combo_box->priv->num_displayed_accounts = 0;
+
store = gtk_list_store_new (2, G_TYPE_STRING, E_TYPE_ACCOUNT);
model = GTK_TREE_MODEL (store);
index = combo_box->priv->index;
@@ -181,6 +184,7 @@ account_combo_box_refresh_cb (EAccountList *account_list,
gchar *string;
account = iter->data;
+ combo_box->priv->num_displayed_accounts++;
/* Show the account name for duplicate email addresses. */
if (account_combo_box_has_dupes (list, account->id->address))
@@ -513,3 +517,21 @@ e_account_combo_box_set_active_name (EAccountComboBox *combo_box,
return e_account_combo_box_set_active (combo_box, account);
}
+
+/**
+ * e_account_combo_box_count_displayed_accounts:
+ * @combo_box: an #EAccountComboBox
+ *
+ * Counts the number of accounts that are displayed in the @combo_box. This may not
+ * be the actual number of accounts that are configured, as some of those accounts
+ * may be disabled by the user.
+ *
+ * Return value: number of active and valid accounts as shown in the @combo_box.
+ */
+gint
+e_account_combo_box_count_displayed_accounts (EAccountComboBox *combo_box)
+{
+ g_return_val_if_fail (E_IS_ACCOUNT_COMBO_BOX (combo_box), -1);
+
+ return combo_box->priv->num_displayed_accounts;
+}
diff --git a/widgets/misc/e-account-combo-box.h b/widgets/misc/e-account-combo-box.h
index 3c442f1a29..b624c9b17e 100644
--- a/widgets/misc/e-account-combo-box.h
+++ b/widgets/misc/e-account-combo-box.h
@@ -78,6 +78,8 @@ gboolean e_account_combo_box_set_active_name
(EAccountComboBox *combo_box,
const gchar *account_name);
+gint e_account_combo_box_count_displayed_accounts (EAccountComboBox *combo_box);
+
G_END_DECLS
#endif /* E_ACCOUNT_COMBO_BOX_H */
diff --git a/widgets/misc/e-preferences-window.c b/widgets/misc/e-preferences-window.c
index 27caa80e80..6b38b682f2 100644
--- a/widgets/misc/e-preferences-window.c
+++ b/widgets/misc/e-preferences-window.c
@@ -33,11 +33,17 @@
struct _EPreferencesWindowPrivate {
GtkWidget *icon_view;
+ GtkWidget *scroll;
GtkWidget *notebook;
GHashTable *index;
+
+ GtkListStore *store;
+ GtkTreeModelFilter *filter;
+ const gchar *filter_view;
};
enum {
+ COLUMN_ID, /* G_TYPE_STRING */
COLUMN_TEXT, /* G_TYPE_STRING */
COLUMN_PIXBUF, /* GDK_TYPE_PIXBUF */
COLUMN_PAGE, /* G_TYPE_INT */
@@ -102,7 +108,7 @@ preferences_window_selection_changed_cb (EPreferencesWindow *window)
if (list == NULL)
return;
- model = gtk_icon_view_get_model (icon_view);
+ model = GTK_TREE_MODEL (window->priv->store);
gtk_tree_model_get_iter (model, &iter, list->data);
gtk_tree_model_get (model, &iter, COLUMN_PAGE, &page, -1);
@@ -190,6 +196,40 @@ preferences_window_class_init (EPreferencesWindowClass *class)
widget_class->show = preferences_window_show;
}
+static gboolean
+filter_view (GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer data)
+{
+ EPreferencesWindow *window = (EPreferencesWindow *)data;
+ gchar *str;
+ gboolean visible = FALSE;
+
+ if (!window->priv->filter_view)
+ return TRUE;
+
+ gtk_tree_model_get (model, iter, COLUMN_ID, &str, -1);
+ if (strncmp(window->priv->filter_view, "mail", 4) == 0) {
+ /* Show everything except calendar */
+ if (str && (strncmp (str, "cal", 3) == 0))
+ visible = FALSE;
+ else
+ visible = TRUE;
+ } else if (strncmp(window->priv->filter_view, "cal", 3) == 0) {
+ /* Show only calendar and nothing else */
+ if (str && (strncmp (str, "cal", 3) != 0))
+ visible = FALSE;
+ else
+ visible = TRUE;
+
+ } else /* In any other case, show everything */
+ visible = TRUE;
+
+ g_free (str);
+
+ return visible;
+}
+
static void
preferences_window_init (EPreferencesWindow *window)
{
@@ -209,11 +249,19 @@ preferences_window_init (EPreferencesWindow *window)
window->priv = E_PREFERENCES_WINDOW_GET_PRIVATE (window);
window->priv->index = index;
+ window->priv->filter_view = NULL;
store = gtk_list_store_new (
- 4, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_INT, G_TYPE_INT);
+ 5, G_TYPE_STRING, G_TYPE_STRING,
+ GDK_TYPE_PIXBUF, G_TYPE_INT, G_TYPE_INT);
gtk_tree_sortable_set_sort_column_id (
GTK_TREE_SORTABLE (store), COLUMN_SORT, GTK_SORT_ASCENDING);
+ window->priv->store = store;
+
+ window->priv->filter = (GtkTreeModelFilter *)
+ gtk_tree_model_filter_new (GTK_TREE_MODEL (store), NULL);
+ gtk_tree_model_filter_set_visible_func (
+ window->priv->filter, filter_view, window, NULL);
title = _("Evolution Preferences");
gtk_window_set_title (GTK_WINDOW (window), title);
@@ -243,11 +291,12 @@ preferences_window_init (EPreferencesWindow *window)
gtk_scrolled_window_set_shadow_type (
GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, TRUE, 0);
+ window->priv->scroll = widget;
gtk_widget_show (widget);
container = widget;
- widget = gtk_icon_view_new_with_model (GTK_TREE_MODEL (store));
+ widget = gtk_icon_view_new_with_model (GTK_TREE_MODEL (window->priv->filter));
gtk_icon_view_set_columns (GTK_ICON_VIEW (widget), 1);
gtk_icon_view_set_text_column (GTK_ICON_VIEW (widget), COLUMN_TEXT);
gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (widget), COLUMN_PIXBUF);
@@ -359,13 +408,14 @@ e_preferences_window_add_page (EPreferencesWindow *window,
notebook = GTK_NOTEBOOK (window->priv->notebook);
page = gtk_notebook_get_n_pages (notebook);
- model = gtk_icon_view_get_model (icon_view);
+ model = GTK_TREE_MODEL (window->priv->store);
pixbuf = preferences_window_load_pixbuf (icon_name);
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
gtk_list_store_set (
GTK_LIST_STORE (model), &iter,
+ COLUMN_ID, page_name,
COLUMN_TEXT, caption, COLUMN_PIXBUF, pixbuf,
COLUMN_PAGE, page, COLUMN_SORT, sort_order, -1);
@@ -405,3 +455,35 @@ e_preferences_window_show_page (EPreferencesWindow *window,
gtk_icon_view_scroll_to_path (icon_view, path, FALSE, 0.0, 0.0);
gtk_tree_path_free (path);
}
+
+void
+e_preferences_window_filter_page (EPreferencesWindow *window,
+ const gchar *page_name)
+{
+ GtkTreeRowReference *reference;
+ GtkIconView *icon_view;
+ GtkTreePath *path;
+
+ g_return_if_fail (E_IS_PREFERENCES_WINDOW (window));
+ g_return_if_fail (page_name != NULL);
+
+ icon_view = GTK_ICON_VIEW (window->priv->icon_view);
+ reference = g_hash_table_lookup (window->priv->index, page_name);
+ g_return_if_fail (reference != NULL);
+
+ path = gtk_tree_row_reference_get_path (reference);
+ gtk_icon_view_select_path (icon_view, path);
+ gtk_icon_view_scroll_to_path (icon_view, path, FALSE, 0.0, 0.0);
+ gtk_tree_path_free (path);
+
+ window->priv->filter_view = page_name;
+ gtk_tree_model_filter_refilter (window->priv->filter);
+
+ /* XXX: We need a better solution to hide the icon view when
+ * there is just one entry */
+ if (strncmp(page_name, "cal", 3) == 0) {
+ gtk_widget_hide (window->priv->scroll);
+ } else
+ gtk_widget_show (window->priv->scroll);
+}
+
diff --git a/widgets/misc/e-preferences-window.h b/widgets/misc/e-preferences-window.h
index 4944a89e58..00b51b85e1 100644
--- a/widgets/misc/e-preferences-window.h
+++ b/widgets/misc/e-preferences-window.h
@@ -68,6 +68,8 @@ void e_preferences_window_add_page (EPreferencesWindow *window,
gint sort_order);
void e_preferences_window_show_page (EPreferencesWindow *window,
const gchar *page_name);
+void e_preferences_window_filter_page(EPreferencesWindow *window,
+ const gchar *page_name);
G_END_DECLS
diff --git a/widgets/misc/e-web-view.c b/widgets/misc/e-web-view.c
index 71eb1acd34..8e1878869e 100644
--- a/widgets/misc/e-web-view.c
+++ b/widgets/misc/e-web-view.c
@@ -895,6 +895,16 @@ web_view_load_string (EWebView *web_view,
}
static void
+web_view_load_string (EWebView *web_view,
+ const gchar *string)
+{
+ if (string != NULL && *string != '\0')
+ gtk_html_load_from_string (GTK_HTML (web_view), string, -1);
+ else
+ e_web_view_clear (web_view);
+}
+
+static void
web_view_copy_clipboard (EWebView *web_view)
{
gtk_html_command (GTK_HTML (web_view), "copy");