aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-shell-searchbar.c
diff options
context:
space:
mode:
Diffstat (limited to 'shell/e-shell-searchbar.c')
-rw-r--r--shell/e-shell-searchbar.c154
1 files changed, 104 insertions, 50 deletions
diff --git a/shell/e-shell-searchbar.c b/shell/e-shell-searchbar.c
index 272ba0e906..940bd9fd6b 100644
--- a/shell/e-shell-searchbar.c
+++ b/shell/e-shell-searchbar.c
@@ -19,6 +19,12 @@
*
*/
+/**
+ * SECTION: e-shell-searchbar
+ * @short_description: quick search interface
+ * @include: shell/e-shell-searchbar.h
+ **/
+
#include "e-shell-searchbar.h"
#include <config.h>
@@ -26,6 +32,7 @@
#include "e-util/e-util.h"
#include "e-util/e-binding.h"
+#include "e-util/e-extensible.h"
#include "widgets/misc/e-action-combo-box.h"
#include "widgets/misc/e-hinted-entry.h"
@@ -60,8 +67,9 @@ struct _EShellSearchbarPrivate {
/* State Key File */
gchar *state_group;
+ guint express_mode : 1;
guint filter_visible : 1;
- guint label_visible : 1;
+ guint labels_visible : 1;
guint search_visible : 1;
guint scope_visible : 1;
guint state_dirty : 1;
@@ -69,9 +77,10 @@ struct _EShellSearchbarPrivate {
enum {
PROP_0,
+ PROP_EXPRESS_MODE,
PROP_FILTER_COMBO_BOX,
PROP_FILTER_VISIBLE,
- PROP_LABEL_VISIBLE,
+ PROP_LABELS_VISIBLE,
PROP_SEARCH_HINT,
PROP_SEARCH_OPTION,
PROP_SEARCH_TEXT,
@@ -82,7 +91,9 @@ enum {
PROP_STATE_GROUP
};
-static gpointer parent_class;
+G_DEFINE_TYPE_WITH_CODE (
+ EShellSearchbar, e_shell_searchbar, GTK_TYPE_BOX,
+ G_IMPLEMENT_INTERFACE (E_TYPE_EXTENSIBLE, NULL))
static void
shell_searchbar_save_search_filter (EShellSearchbar *searchbar)
@@ -463,14 +474,20 @@ shell_searchbar_set_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_EXPRESS_MODE:
+ e_shell_searchbar_set_express_mode (
+ E_SHELL_SEARCHBAR (object),
+ g_value_get_boolean (value));
+ return;
+
case PROP_FILTER_VISIBLE:
e_shell_searchbar_set_filter_visible (
E_SHELL_SEARCHBAR (object),
g_value_get_boolean (value));
return;
- case PROP_LABEL_VISIBLE:
- e_shell_searchbar_set_label_visible (
+ case PROP_LABELS_VISIBLE:
+ e_shell_searchbar_set_labels_visible (
E_SHELL_SEARCHBAR (object),
g_value_get_boolean (value));
return;
@@ -528,15 +545,21 @@ shell_searchbar_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_EXPRESS_MODE:
+ g_value_set_boolean (
+ value, e_shell_searchbar_get_express_mode (
+ E_SHELL_SEARCHBAR (object)));
+ return;
+
case PROP_FILTER_COMBO_BOX:
g_value_set_object (
value, e_shell_searchbar_get_filter_combo_box (
E_SHELL_SEARCHBAR (object)));
return;
- case PROP_LABEL_VISIBLE:
+ case PROP_LABELS_VISIBLE:
g_value_set_boolean (
- value, e_shell_searchbar_get_label_visible (
+ value, e_shell_searchbar_get_labels_visible (
E_SHELL_SEARCHBAR (object)));
return;
@@ -620,7 +643,7 @@ shell_searchbar_dispose (GObject *object)
}
/* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (parent_class)->dispose (object);
+ G_OBJECT_CLASS (e_shell_searchbar_parent_class)->dispose (object);
}
static void
@@ -693,13 +716,15 @@ shell_searchbar_constructed (GObject *object)
widget = GTK_WIDGET (searchbar);
gtk_size_group_add_widget (size_group, widget);
+
+ e_extensible_load_extensions (E_EXTENSIBLE (object));
}
static void
shell_searchbar_map (GtkWidget *widget)
{
/* Chain up to parent's map() method. */
- GTK_WIDGET_CLASS (parent_class)->map (widget);
+ GTK_WIDGET_CLASS (e_shell_searchbar_parent_class)->map (widget);
/* Load state after constructed() so we don't derail
* subclass initialization. We wait until map() so we
@@ -708,12 +733,11 @@ shell_searchbar_map (GtkWidget *widget)
}
static void
-shell_searchbar_class_init (EShellSearchbarClass *class)
+e_shell_searchbar_class_init (EShellSearchbarClass *class)
{
GObjectClass *object_class;
GtkWidgetClass *widget_class;
- parent_class = g_type_class_peek_parent (class);
g_type_class_add_private (class, sizeof (EShellSearchbarPrivate));
object_class = G_OBJECT_CLASS (class);
@@ -727,6 +751,17 @@ shell_searchbar_class_init (EShellSearchbarClass *class)
g_object_class_install_property (
object_class,
+ PROP_EXPRESS_MODE,
+ g_param_spec_boolean (
+ "express-mode",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (
+ object_class,
PROP_FILTER_COMBO_BOX,
g_param_spec_object (
"filter-combo-box",
@@ -737,9 +772,9 @@ shell_searchbar_class_init (EShellSearchbarClass *class)
g_object_class_install_property (
object_class,
- PROP_LABEL_VISIBLE,
+ PROP_LABELS_VISIBLE,
g_param_spec_boolean (
- "label-visible",
+ "labels-visible",
NULL,
NULL,
TRUE,
@@ -853,7 +888,7 @@ shell_searchbar_class_init (EShellSearchbarClass *class)
}
static void
-shell_searchbar_init (EShellSearchbar *searchbar)
+e_shell_searchbar_init (EShellSearchbar *searchbar)
{
GtkBox *box;
GtkLabel *label;
@@ -884,6 +919,10 @@ shell_searchbar_init (EShellSearchbar *searchbar)
gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
gtk_widget_show (widget);
+ e_binding_new (
+ searchbar, "labels-visible",
+ widget, "visible");
+
label = GTK_LABEL (widget);
widget = e_action_combo_box_new ();
@@ -911,11 +950,12 @@ shell_searchbar_init (EShellSearchbar *searchbar)
gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
gtk_widget_show (widget);
- label = GTK_LABEL (widget);
e_binding_new (
- searchbar, "label-visible",
+ searchbar, "labels-visible",
widget, "visible");
+ label = GTK_LABEL (widget);
+
widget = e_hinted_entry_new ();
gtk_label_set_mnemonic_widget (label, widget);
gtk_box_pack_start (box, widget, TRUE, TRUE, 0);
@@ -989,32 +1029,6 @@ shell_searchbar_init (EShellSearchbar *searchbar)
G_CONNECT_AFTER | G_CONNECT_SWAPPED);
}
-GType
-e_shell_searchbar_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0)) {
- static const GTypeInfo type_info = {
- sizeof (EShellSearchbarClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) shell_searchbar_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class_data */
- sizeof (EShellSearchbar),
- 0, /* n_preallocs */
- (GInstanceInitFunc) shell_searchbar_init,
- NULL /* value_table */
- };
-
- type = g_type_register_static (
- GTK_TYPE_BOX, "EShellSearchbar", &type_info, 0);
- }
-
- return type;
-}
-
/**
* e_shell_searchbar_new:
* @shell_view: an #EShellView
@@ -1048,6 +1062,31 @@ e_shell_searchbar_get_shell_view (EShellSearchbar *searchbar)
return E_SHELL_VIEW (searchbar->priv->shell_view);
}
+gboolean
+e_shell_searchbar_get_express_mode (EShellSearchbar *searchbar)
+{
+ g_return_val_if_fail (E_IS_SHELL_SEARCHBAR (searchbar), FALSE);
+
+ return searchbar->priv->express_mode;
+}
+
+void
+e_shell_searchbar_set_express_mode (EShellSearchbar *searchbar,
+ gboolean express_mode)
+{
+ g_return_if_fail (E_IS_SHELL_SEARCHBAR (searchbar));
+
+ searchbar->priv->express_mode = express_mode;
+
+ /* Emit "notify" on all the properties we override. */
+ g_object_freeze_notify (G_OBJECT (searchbar));
+ g_object_notify (G_OBJECT (searchbar), "express-mode");
+ g_object_notify (G_OBJECT (searchbar), "labels-visible");
+ g_object_notify (G_OBJECT (searchbar), "filter-visible");
+ g_object_notify (G_OBJECT (searchbar), "scope-visible");
+ g_object_thaw_notify (G_OBJECT (searchbar));
+}
+
EActionComboBox *
e_shell_searchbar_get_filter_combo_box (EShellSearchbar *searchbar)
{
@@ -1057,22 +1096,26 @@ e_shell_searchbar_get_filter_combo_box (EShellSearchbar *searchbar)
}
gboolean
-e_shell_searchbar_get_label_visible (EShellSearchbar *searchbar)
+e_shell_searchbar_get_labels_visible (EShellSearchbar *searchbar)
{
g_return_val_if_fail (E_IS_SHELL_SEARCHBAR (searchbar), FALSE);
- return searchbar->priv->label_visible;
+ /* Express mode overrides this. */
+ if (e_shell_searchbar_get_express_mode (searchbar))
+ return FALSE;
+
+ return searchbar->priv->labels_visible;
}
void
-e_shell_searchbar_set_label_visible (EShellSearchbar *searchbar,
- gboolean label_visible)
+e_shell_searchbar_set_labels_visible (EShellSearchbar *searchbar,
+ gboolean labels_visible)
{
g_return_if_fail (E_IS_SHELL_SEARCHBAR (searchbar));
- searchbar->priv->label_visible = label_visible;
+ searchbar->priv->labels_visible = labels_visible;
- g_object_notify (G_OBJECT (searchbar), "label-visible");
+ g_object_notify (G_OBJECT (searchbar), "labels-visible");
}
gboolean
@@ -1080,6 +1123,10 @@ e_shell_searchbar_get_filter_visible (EShellSearchbar *searchbar)
{
g_return_val_if_fail (E_IS_SHELL_SEARCHBAR (searchbar), FALSE);
+ /* Express mode overrides this. */
+ if (e_shell_searchbar_get_express_mode (searchbar))
+ return FALSE;
+
return searchbar->priv->filter_visible;
}
@@ -1220,6 +1267,10 @@ e_shell_searchbar_get_scope_visible (EShellSearchbar *searchbar)
{
g_return_val_if_fail (E_IS_SHELL_SEARCHBAR (searchbar), FALSE);
+ /* Express mode overrides this. */
+ if (e_shell_searchbar_get_express_mode (searchbar))
+ return FALSE;
+
return searchbar->priv->scope_visible;
}
@@ -1273,6 +1324,7 @@ e_shell_searchbar_load_state (EShellSearchbar *searchbar)
GKeyFile *key_file;
GtkAction *action;
GtkWidget *widget;
+ gboolean express_mode;
const gchar *search_text;
const gchar *state_group;
const gchar *key;
@@ -1288,6 +1340,8 @@ e_shell_searchbar_load_state (EShellSearchbar *searchbar)
key_file = e_shell_view_get_state_key_file (shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
+ express_mode = e_shell_searchbar_get_express_mode (searchbar);
+
/* Changing the combo boxes triggers searches, so block
* the search action until the state is fully restored. */
action = E_SHELL_WINDOW_ACTION_SEARCH_QUICK (shell_window);
@@ -1299,7 +1353,7 @@ e_shell_searchbar_load_state (EShellSearchbar *searchbar)
key = STATE_KEY_SEARCH_FILTER;
string = g_key_file_get_string (key_file, state_group, key, NULL);
- if (string != NULL && *string != '\0')
+ if (string != NULL && *string != '\0' && !express_mode)
action = e_shell_window_get_action (shell_window, string);
else
action = NULL;
@@ -1344,7 +1398,7 @@ e_shell_searchbar_load_state (EShellSearchbar *searchbar)
key = STATE_KEY_SEARCH_SCOPE;
string = g_key_file_get_string (key_file, state_group, key, NULL);
- if (string != NULL && *string != '\0')
+ if (string != NULL && *string != '\0' && !express_mode)
action = e_shell_window_get_action (shell_window, string);
else
action = NULL;