diff options
author | Björn Lindqvist <bjourne@gmail.com> | 2006-12-17 11:06:15 +0800 |
---|---|---|
committer | Björn Lindqvist <bjornl@src.gnome.org> | 2006-12-17 11:06:15 +0800 |
commit | 73f71bde0e7e256ac5636e7d0f4693aa83e67a56 (patch) | |
tree | ef89ba03eafbd73a71984fe210b7d12b295b9592 /embed | |
parent | 66ccfb8ffa2b566a31151da92ba5aa0881153d15 (diff) | |
download | gsoc2013-epiphany-73f71bde0e7e256ac5636e7d0f4693aa83e67a56.tar gsoc2013-epiphany-73f71bde0e7e256ac5636e7d0f4693aa83e67a56.tar.gz gsoc2013-epiphany-73f71bde0e7e256ac5636e7d0f4693aa83e67a56.tar.bz2 gsoc2013-epiphany-73f71bde0e7e256ac5636e7d0f4693aa83e67a56.tar.lz gsoc2013-epiphany-73f71bde0e7e256ac5636e7d0f4693aa83e67a56.tar.xz gsoc2013-epiphany-73f71bde0e7e256ac5636e7d0f4693aa83e67a56.tar.zst gsoc2013-epiphany-73f71bde0e7e256ac5636e7d0f4693aa83e67a56.zip |
embed/ephy-encodings.c embed/ephy-favicon-cache.c embed/ephy-history.c
2006-12-17 Björn Lindqvist <bjourne@gmail.com>
* embed/ephy-encodings.c
* embed/ephy-favicon-cache.c
* embed/ephy-history.c
* embed/mozilla/GlobalHistory.cpp
* lib/ephy-state.c
* lib/widgets/ephy-node-view.c
* src/ephy-tab.c
* src/bookmarks/ephy-bookmarks.c
Refactor lots of code by using the function
ephy_node_set_property_XXX() instead of
ephy_node_set_property(). Also, add emacs mode headers to touched
files. Bug #381546.
Diffstat (limited to 'embed')
-rw-r--r-- | embed/ephy-encodings.c | 29 | ||||
-rw-r--r-- | embed/ephy-favicon-cache.c | 65 | ||||
-rw-r--r-- | embed/ephy-history.c | 144 | ||||
-rw-r--r-- | embed/mozilla/GlobalHistory.cpp | 11 |
4 files changed, 86 insertions, 163 deletions
diff --git a/embed/ephy-encodings.c b/embed/ephy-encodings.c index d253959be..0d95c9dad 100644 --- a/embed/ephy-encodings.c +++ b/embed/ephy-encodings.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * Copyright © 2003 Marco Pesenti Gritti * Copyright © 2003 Christian Persch @@ -291,10 +292,8 @@ add_encoding (EphyEncodings *encodings, node = ephy_node_new (encodings->priv->db); - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, title); - ephy_node_set_property (node, EPHY_NODE_ENCODING_PROP_TITLE, &value); - g_value_unset (&value); + ephy_node_set_property_string (node, EPHY_NODE_ENCODING_PROP_TITLE, + title); elided = elide_underscores (title); normalised = g_utf8_normalize (elided, -1, G_NORMALIZE_DEFAULT); @@ -311,20 +310,16 @@ add_encoding (EphyEncodings *encodings, ephy_node_set_property (node, EPHY_NODE_ENCODING_PROP_TITLE_ELIDED, &value); g_value_unset (&value); - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, code); - ephy_node_set_property (node, EPHY_NODE_ENCODING_PROP_ENCODING, &value); - g_value_unset (&value); + ephy_node_set_property_string (node, EPHY_NODE_ENCODING_PROP_ENCODING, + code); - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, groups); - ephy_node_set_property (node, EPHY_NODE_ENCODING_PROP_LANGUAGE_GROUPS, &value); - g_value_unset (&value); - - g_value_init (&value, G_TYPE_BOOLEAN); - g_value_set_boolean (&value, is_autodetector); - ephy_node_set_property (node, EPHY_NODE_ENCODING_PROP_IS_AUTODETECTOR, &value); - g_value_unset (&value); + ephy_node_set_property_int (node, + EPHY_NODE_ENCODING_PROP_LANGUAGE_GROUPS, + groups); + + ephy_node_set_property_boolean (node, + EPHY_NODE_ENCODING_PROP_IS_AUTODETECTOR, + is_autodetector); /* now insert the node in our structure */ ephy_node_add_child (encodings->priv->root, node); diff --git a/embed/ephy-favicon-cache.c b/embed/ephy-favicon-cache.c index 01b242d07..5d6d62fe3 100644 --- a/embed/ephy-favicon-cache.c +++ b/embed/ephy-favicon-cache.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * Copyright © 2002 Jorn Baayen <jorn@nl.linux.org> * Copyright © 2003-2004 Marco Pesenti Gritti @@ -590,11 +591,11 @@ ephy_favicon_cache_get (EphyFaviconCache *cache, time_t now; PixbufCacheEntry *entry; EphyNode *icon; - GValue value = { 0, }; char *pix_file; GdkPixbuf *pixbuf = NULL; guint checklevel = NEEDS_MASK; int width, height; + int favicon_checked; if (url == NULL) return NULL; @@ -629,23 +630,15 @@ ephy_favicon_cache_get (EphyFaviconCache *cache, filename = gnome_thumbnail_md5 (url); icon = ephy_node_new (cache->priv->db); - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, url); - ephy_node_set_property (icon, EPHY_NODE_FAVICON_PROP_URL, - &value); - g_value_unset (&value); - - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, filename); - ephy_node_set_property (icon, EPHY_NODE_FAVICON_PROP_FILENAME, - &value); - g_value_unset (&value); - - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, (int) NEEDS_MASK & ~NEEDS_RENAME); - ephy_node_set_property (icon, EPHY_NODE_FAVICON_PROP_CHECKED, - &value); - g_value_unset (&value); + ephy_node_set_property_string (icon, + EPHY_NODE_FAVICON_PROP_URL, + url); + ephy_node_set_property_string (icon, + EPHY_NODE_FAVICON_PROP_FILENAME, + filename); + ephy_node_set_property_int (icon, + EPHY_NODE_FAVICON_PROP_CHECKED, + (int) NEEDS_MASK & ~NEEDS_RENAME); /* This will also add an entry to the icons hash */ ephy_node_add_child (priv->icons, icon); @@ -663,11 +656,8 @@ ephy_favicon_cache_get (EphyFaviconCache *cache, icon = entry->node; /* update timestamp */ - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, now); - ephy_node_set_property (icon, EPHY_NODE_FAVICON_PROP_LAST_USED, - &value); - g_value_unset (&value); + ephy_node_set_property_int (icon, EPHY_NODE_FAVICON_PROP_LAST_USED, + now); priv->dirty = TRUE; @@ -690,17 +680,18 @@ ephy_favicon_cache_get (EphyFaviconCache *cache, } /* Check for supported icon types */ - if (ephy_node_get_property (icon, EPHY_NODE_FAVICON_PROP_CHECKED, &value) && - G_VALUE_HOLDS (&value, G_TYPE_INT)) + favicon_checked = ephy_node_get_property_int + (icon, EPHY_NODE_FAVICON_PROP_CHECKED); + if (favicon_checked != -1) { - checklevel = (guint) g_value_get_int (&value); - g_value_unset (&value); + checklevel = (guint) favicon_checked; } /* First, update the filename */ if (checklevel & NEEDS_RENAME) { char *new_pix_file, *urlhash; + GValue value = { 0, }; urlhash = gnome_thumbnail_md5 (url); new_pix_file = g_build_filename (cache->priv->directory, urlhash, NULL); @@ -717,10 +708,9 @@ ephy_favicon_cache_get (EphyFaviconCache *cache, pix_file = new_pix_file; checklevel &= ~NEEDS_RENAME; - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, (int) checklevel); - ephy_node_set_property (icon, EPHY_NODE_FAVICON_PROP_CHECKED, &value); - g_value_unset (&value); + ephy_node_set_property_int (icon, + EPHY_NODE_FAVICON_PROP_CHECKED, + (int) checklevel); } /* Now check the type. We renamed the file above, so gnome-vfs does NOT @@ -790,16 +780,13 @@ ephy_favicon_cache_get (EphyFaviconCache *cache, /* gnome_vfs_unlink (pix_file); */ } - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, (int) checklevel); - ephy_node_set_property (icon, EPHY_NODE_FAVICON_PROP_CHECKED, &value); - g_value_unset (&value); + ephy_node_set_property_int (icon, + EPHY_NODE_FAVICON_PROP_CHECKED, + (int) checklevel); /* epiphany 1.6 compat */ - g_value_init (&value, G_TYPE_BOOLEAN); - g_value_set_boolean (&value, valid); - ephy_node_set_property (icon, EPHY_NODE_FAVICON_PROP_CHECKOLD, &value); - g_value_unset (&value); + ephy_node_set_property_boolean + (icon, EPHY_NODE_FAVICON_PROP_CHECKOLD, valid); } /* if it still needs the check, mime type couldn't be checked. Deny! */ diff --git a/embed/ephy-history.c b/embed/ephy-history.c index b017281bb..494c1e00d 100644 --- a/embed/ephy-history.c +++ b/embed/ephy-history.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * Copyright © 2002, 2003 Marco Pesenti Gritti * @@ -427,13 +428,9 @@ update_host_on_child_remove (EphyNode *node) if (host_last_visit != new_host_last_visit) { - GValue value = { 0, }; - - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, new_host_last_visit); - ephy_node_set_property (node, EPHY_NODE_PAGE_PROP_LAST_VISIT, - &value); - g_value_unset (&value); + ephy_node_set_property_int (node, + EPHY_NODE_PAGE_PROP_LAST_VISIT, + new_host_last_visit); } } @@ -533,8 +530,8 @@ disable_history_notifier (GConfClient *client, static void ephy_history_init (EphyHistory *eb) { - GValue value = { 0, }; EphyNodeDb *db; + const char *all = _("All"); eb->priv = EPHY_HISTORY_GET_PRIVATE (eb); eb->priv->update_hosts_idle = 0; @@ -554,21 +551,18 @@ ephy_history_init (EphyHistory *eb) /* Pages */ eb->priv->pages = ephy_node_new_with_id (db, PAGES_NODE_ID); - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, _("All")); - ephy_node_set_property (eb->priv->pages, - EPHY_NODE_PAGE_PROP_LOCATION, - &value); - ephy_node_set_property (eb->priv->pages, - EPHY_NODE_PAGE_PROP_TITLE, - &value); - g_value_unset (&value); - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, EPHY_NODE_ALL_PRIORITY); - ephy_node_set_property (eb->priv->pages, - EPHY_NODE_PAGE_PROP_PRIORITY, - &value); - g_value_unset (&value); + + ephy_node_set_property_string (eb->priv->pages, + EPHY_NODE_PAGE_PROP_LOCATION, + all); + ephy_node_set_property_string (eb->priv->pages, + EPHY_NODE_PAGE_PROP_TITLE, + all); + + ephy_node_set_property_int (eb->priv->pages, + EPHY_NODE_PAGE_PROP_PRIORITY, + EPHY_NODE_ALL_PRIORITY); + ephy_node_signal_connect_object (eb->priv->pages, EPHY_NODE_CHILD_ADDED, (EphyNodeCallback) pages_added_cb, @@ -664,7 +658,6 @@ ephy_history_host_visited (EphyHistory *eh, EphyNode *host, GTime now) { - GValue value = { 0, }; int visits; LOG ("Host visited"); @@ -674,17 +667,9 @@ ephy_history_host_visited (EphyHistory *eh, if (visits < 0) visits = 0; visits++; - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, visits); - ephy_node_set_property (host, EPHY_NODE_PAGE_PROP_VISITS, - &value); - g_value_unset (&value); - - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, now); - ephy_node_set_property (host, EPHY_NODE_PAGE_PROP_LAST_VISIT, - &value); - g_value_unset (&value); + ephy_node_set_property_int (host, EPHY_NODE_PAGE_PROP_VISITS, visits); + ephy_node_set_property_int (host, EPHY_NODE_PAGE_PROP_LAST_VISIT, + now); } static EphyNode * @@ -694,7 +679,6 @@ internal_get_host (EphyHistory *eh, const char *url, gboolean create) EphyNode *host = NULL; const char *host_name = NULL; GList *host_locations = NULL, *l; - GValue value = { 0, }; const char *scheme = NULL; GTime now; @@ -771,25 +755,15 @@ internal_get_host (EphyHistory *eh, const char *url, gboolean create) EPHY_NODE_DESTROY, (EphyNodeCallback) remove_pages_from_host_cb, G_OBJECT (eh)); - - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, host_name); - ephy_node_set_property (host, EPHY_NODE_PAGE_PROP_TITLE, - &value); - g_value_unset (&value); - - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, (char *)host_locations->data); - ephy_node_set_property (host, EPHY_NODE_PAGE_PROP_LOCATION, - &value); - g_value_unset (&value); - - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, now); - ephy_node_set_property (host, EPHY_NODE_PAGE_PROP_FIRST_VISIT, - &value); - g_value_unset (&value); - + ephy_node_set_property_string (host, + EPHY_NODE_PAGE_PROP_TITLE, + host_name); + ephy_node_set_property_string (host, + EPHY_NODE_PAGE_PROP_LOCATION, + (char *)host_locations->data); + ephy_node_set_property_int (host, + EPHY_NODE_PAGE_PROP_FIRST_VISIT, + now); ephy_node_add_child (eh->priv->hosts, host); } @@ -829,7 +803,6 @@ ephy_history_add_host (EphyHistory *eh, EphyNode *page) static void ephy_history_visited (EphyHistory *eh, EphyNode *node) { - GValue value = { 0, }; GTime now; int visits; const char *url; @@ -847,22 +820,14 @@ ephy_history_visited (EphyHistory *eh, EphyNode *node) if (visits < 0) visits = 0; visits++; - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, visits); - ephy_node_set_property (node, EPHY_NODE_PAGE_PROP_VISITS, - &value); - g_value_unset (&value); - - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, now); - ephy_node_set_property (node, EPHY_NODE_PAGE_PROP_LAST_VISIT, - &value); + ephy_node_set_property_int (node, EPHY_NODE_PAGE_PROP_VISITS, visits); + ephy_node_set_property_int (node, EPHY_NODE_PAGE_PROP_LAST_VISIT, + now); if (visits == 1) { - ephy_node_set_property - (node, EPHY_NODE_PAGE_PROP_FIRST_VISIT, &value); + ephy_node_set_property_int + (node, EPHY_NODE_PAGE_PROP_FIRST_VISIT, now); } - g_value_unset (&value); host_id = ephy_node_get_property_int (node, EPHY_NODE_PAGE_PROP_HOST_ID); if (host_id >= 0) @@ -914,7 +879,6 @@ impl_add_page (EphyHistory *eb, gboolean toplevel) { EphyNode *bm, *node, *host; - GValue value = { 0, }; gulong flags = 0; if (eb->priv->enabled == FALSE) @@ -931,31 +895,20 @@ impl_add_page (EphyHistory *eb, bm = ephy_node_new (eb->priv->db); - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, url); - ephy_node_set_property (bm, EPHY_NODE_PAGE_PROP_LOCATION, - &value); - ephy_node_set_property (bm, EPHY_NODE_PAGE_PROP_TITLE, - &value); - g_value_unset (&value); + ephy_node_set_property_string (bm, EPHY_NODE_PAGE_PROP_LOCATION, url); + ephy_node_set_property_string (bm, EPHY_NODE_PAGE_PROP_TITLE, url); if (redirect) flags |= REDIRECT_FLAG; if (toplevel) flags |= TOPLEVEL_FLAG; /* EphyNode SUCKS! */ - g_value_init (&value, G_TYPE_LONG); - g_value_set_long (&value, (long) flags); - ephy_node_set_property (bm, EPHY_NODE_PAGE_PROP_EXTRA_FLAGS, - &value); - g_value_unset (&value); + ephy_node_set_property_long (bm, EPHY_NODE_PAGE_PROP_EXTRA_FLAGS, + flags); host = ephy_history_add_host (eb, bm); - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, ephy_node_get_id (host)); - ephy_node_set_property (bm, EPHY_NODE_PAGE_PROP_HOST_ID, - &value); - g_value_unset (&value); + ephy_node_set_property_int (bm, EPHY_NODE_PAGE_PROP_HOST_ID, + ephy_node_get_id (host)); ephy_history_visited (eb, bm); @@ -989,7 +942,6 @@ ephy_history_set_page_title (EphyHistory *gh, const char *title) { EphyNode *node; - GValue value = { 0, }; LOG ("Set page title"); @@ -998,11 +950,8 @@ ephy_history_set_page_title (EphyHistory *gh, node = ephy_history_get_page (gh, url); if (node == NULL) return; - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, title); - ephy_node_set_property - (node, EPHY_NODE_PAGE_PROP_TITLE, &value); - g_value_unset (&value); + ephy_node_set_property_string (node, EPHY_NODE_PAGE_PROP_TITLE, + title); } const char* @@ -1037,13 +986,8 @@ ephy_history_set_icon (EphyHistory *gh, host = g_hash_table_lookup (gh->priv->hosts_hash, url); if (host) { - GValue value = { 0, }; - - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, icon); - ephy_node_set_property - (host, EPHY_NODE_PAGE_PROP_ICON, &value); - g_value_unset (&value); + ephy_node_set_property_string (host, EPHY_NODE_PAGE_PROP_ICON, + icon); } } diff --git a/embed/mozilla/GlobalHistory.cpp b/embed/mozilla/GlobalHistory.cpp index 7064b5112..73dc56f2e 100644 --- a/embed/mozilla/GlobalHistory.cpp +++ b/embed/mozilla/GlobalHistory.cpp @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * Copyright © 2001, 2004 Philip Langdale * Copyright © 2004 Christian Persch @@ -196,13 +197,9 @@ MozGlobalHistory::SetURIGeckoFlags(nsIURI *aURI, EphyNode *page = ephy_history_get_page (mGlobalHistory, spec.get()); if (page != NULL) { - GValue value = { 0, }; - - g_value_init (&value, G_TYPE_LONG); - g_value_set_long (&value, (long) (gulong) aFlags); - ephy_node_set_property (page, EPHY_NODE_PAGE_PROP_GECKO_FLAGS, &value); - g_value_unset (&value); - + ephy_node_set_property_long (page, + EPHY_NODE_PAGE_PROP_GECKO_FLAGS, + aFlags); return NS_OK; } |