[epiphany] ephy-completion-model: Make it possible not to use formatting markup
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] ephy-completion-model: Make it possible not to use formatting markup
- Date: Mon, 21 Sep 2015 23:38:28 +0000 (UTC)
commit 68fe7cd0ae0cc965c122fc7b1ef0e2f6089c49d2
Author: Claudio Saavedra <csaavedra igalia com>
Date: Mon Sep 21 18:50:42 2015 +0300
ephy-completion-model: Make it possible not to use formatting markup
Since the completion model is used in the search provider as well,
which doesn't need the markup and also doesn't initialize GTK+,
we need to ensure that the completion model can still be used
without it.
Definitely not the best approach but safe enough for .0 release.
https://bugzilla.gnome.org/show_bug.cgi?id=755341
src/ephy-completion-model.c | 33 +++++++++++++++++++++++++++------
src/ephy-completion-model.h | 3 ++-
src/ephy-location-controller.c | 2 +-
src/ephy-search-provider.c | 2 +-
tests/ephy-completion-model-test.c | 4 ++--
5 files changed, 33 insertions(+), 11 deletions(-)
---
diff --git a/src/ephy-completion-model.c b/src/ephy-completion-model.c
index c74d566..c9ee421 100644
--- a/src/ephy-completion-model.c
+++ b/src/ephy-completion-model.c
@@ -33,7 +33,8 @@
enum {
PROP_0,
PROP_HISTORY_SERVICE,
- PROP_BOOKMARKS
+ PROP_BOOKMARKS,
+ PROP_USE_MARKUP
};
G_DEFINE_TYPE (EphyCompletionModel, ephy_completion_model, GTK_TYPE_LIST_STORE)
@@ -47,6 +48,8 @@ struct _EphyCompletionModelPrivate {
EphyNode *bookmarks;
EphyNode *smart_bookmarks;
GSList *search_terms;
+
+ gboolean use_markup;
};
static void
@@ -86,8 +89,11 @@ ephy_completion_model_set_property (GObject *object, guint property_id, const GV
self->priv->bookmarks = ephy_bookmarks_get_bookmarks (bookmarks);
self->priv->smart_bookmarks = ephy_bookmarks_get_smart_bookmarks (bookmarks);
+ }
+ break;
+ case PROP_USE_MARKUP:
+ self->priv->use_markup = g_value_get_boolean (value);
break;
- }
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (self, property_id, pspec);
break;
@@ -134,6 +140,14 @@ ephy_completion_model_class_init (EphyCompletionModelClass *klass)
"The bookmarks",
G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE |
G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+ g_object_class_install_property (object_class,
+ PROP_USE_MARKUP,
+ g_param_spec_boolean ("use-markup",
+ "Whether we should be using markup",
+ "Whether we should be using markup",
+ TRUE,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE |
G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+
g_type_class_add_private (object_class, sizeof (EphyCompletionModelPrivate));
}
@@ -270,7 +284,11 @@ set_row_in_model (EphyCompletionModel *model, int position, PotentialRow *row, c
database = webkit_web_context_get_favicon_database (ephy_embed_shell_get_web_context (shell));
- text = get_row_text (row->location, row->title, subtitle_color);
+ if (model->priv->use_markup)
+ text = get_row_text (row->location, row->title, subtitle_color);
+ else
+ text = g_strdup (row->title);
+
gtk_list_store_insert_with_values (GTK_LIST_STORE (model), &iter, position,
EPHY_COMPLETION_TEXT_COL, text ? text : "",
EPHY_COMPLETION_URL_COL, row->location,
@@ -322,14 +340,15 @@ replace_rows_in_model (EphyCompletionModel *model, GSList *new_rows)
/* This is by far the simplest way of doing, and yet it gives
* basically the same result than the other methods... */
int i;
- gchar *subtitle_color;
+ gchar *subtitle_color = NULL;
gtk_list_store_clear (GTK_LIST_STORE (model));
if (!new_rows)
return;
- subtitle_color = get_text_column_subtitle_color ();
+ if (model->priv->use_markup)
+ subtitle_color = get_text_column_subtitle_color ();
for (i = 0; new_rows != NULL; i++) {
PotentialRow *row = (PotentialRow*)new_rows->data;
@@ -651,7 +670,8 @@ ephy_completion_model_update_for_string (EphyCompletionModel *model,
EphyCompletionModel *
ephy_completion_model_new (EphyHistoryService *history_service,
- EphyBookmarks *bookmarks)
+ EphyBookmarks *bookmarks,
+ gboolean use_markup)
{
g_return_val_if_fail (EPHY_IS_HISTORY_SERVICE (history_service), NULL);
g_return_val_if_fail (EPHY_IS_BOOKMARKS (bookmarks), NULL);
@@ -659,5 +679,6 @@ ephy_completion_model_new (EphyHistoryService *history_service,
return g_object_new (EPHY_TYPE_COMPLETION_MODEL,
"history-service", history_service,
"bookmarks", bookmarks,
+ "use-markup", use_markup,
NULL);
}
diff --git a/src/ephy-completion-model.h b/src/ephy-completion-model.h
index 4fb7afe..5637a0a 100644
--- a/src/ephy-completion-model.h
+++ b/src/ephy-completion-model.h
@@ -68,7 +68,8 @@ typedef struct
GType ephy_completion_model_get_type (void);
EphyCompletionModel *ephy_completion_model_new (EphyHistoryService *history_service,
- EphyBookmarks *bookmarks);
+ EphyBookmarks *bookmarks,
+ gboolean use_markup);
void ephy_completion_model_update_for_string (EphyCompletionModel *model,
const char *string,
diff --git a/src/ephy-location-controller.c b/src/ephy-location-controller.c
index b39e0ee..61575ef 100644
--- a/src/ephy-location-controller.c
+++ b/src/ephy-location-controller.c
@@ -438,7 +438,7 @@ ephy_location_controller_constructed (GObject *object)
history_service = EPHY_HISTORY_SERVICE (ephy_embed_shell_get_global_history_service
(ephy_embed_shell_get_default ()));
bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());
- model = ephy_completion_model_new (history_service, bookmarks);
+ model = ephy_completion_model_new (history_service, bookmarks, TRUE);
ephy_location_entry_set_completion (priv->location_entry,
GTK_TREE_MODEL (model),
EPHY_COMPLETION_TEXT_COL,
diff --git a/src/ephy-search-provider.c b/src/ephy-search-provider.c
index e478ca6..cdc802c 100644
--- a/src/ephy-search-provider.c
+++ b/src/ephy-search-provider.c
@@ -367,7 +367,7 @@ ephy_search_provider_init (EphySearchProvider *self)
filename = g_build_filename (ephy_dot_dir (), EPHY_HISTORY_FILE, NULL);
self->history_service = ephy_history_service_new (filename, TRUE);
self->bookmarks = ephy_bookmarks_new ();
- self->model = ephy_completion_model_new (self->history_service, self->bookmarks);
+ self->model = ephy_completion_model_new (self->history_service, self->bookmarks, FALSE);
g_free (filename);
self->cancellable = g_cancellable_new ();
diff --git a/tests/ephy-completion-model-test.c b/tests/ephy-completion-model-test.c
index 672d19a..55c02b4 100644
--- a/tests/ephy-completion-model-test.c
+++ b/tests/ephy-completion-model-test.c
@@ -32,7 +32,7 @@ test_ephy_completion_model_create (void)
{
EphyCompletionModel *model;
model = ephy_completion_model_new (EPHY_HISTORY_SERVICE (ephy_embed_shell_get_global_history_service
(ephy_embed_shell_get_default ())),
- ephy_shell_get_bookmarks (ephy_shell_get_default ()));
+ ephy_shell_get_bookmarks (ephy_shell_get_default ()), TRUE);
g_assert (model);
g_object_unref (model);
}
@@ -58,7 +58,7 @@ test_ephy_completion_model_update_empty (void)
GMainLoop *loop = NULL;
model = ephy_completion_model_new (EPHY_HISTORY_SERVICE (ephy_embed_shell_get_global_history_service
(ephy_embed_shell_get_default ())),
- ephy_shell_get_bookmarks (ephy_shell_get_default ()));
+ ephy_shell_get_bookmarks (ephy_shell_get_default ()), TRUE);
g_assert (model);
loop = g_main_loop_new (NULL, FALSE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]