From 73f71bde0e7e256ac5636e7d0f4693aa83e67a56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Sun, 17 Dec 2006 03:06:15 +0000 Subject: embed/ephy-encodings.c embed/ephy-favicon-cache.c embed/ephy-history.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2006-12-17 Björn Lindqvist * 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. --- ChangeLog | 16 +++ embed/ephy-encodings.c | 29 +++--- embed/ephy-favicon-cache.c | 65 +++++------- embed/ephy-history.c | 144 +++++++++------------------ embed/mozilla/GlobalHistory.cpp | 11 +-- lib/ephy-state.c | 183 +++++++++++++--------------------- lib/widgets/ephy-node-view.c | 10 +- src/bookmarks/ephy-bookmarks.c | 214 +++++++++++++++++----------------------- src/ephy-tab.c | 20 ++-- 9 files changed, 270 insertions(+), 422 deletions(-) diff --git a/ChangeLog b/ChangeLog index c3b6cd502..11060d369 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2006-12-17 Björn Lindqvist + + * 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. + 2006-12-15 Christian Persch * embed/mozilla/ContentHandler.cpp: 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 * 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; } diff --git a/lib/ephy-state.c b/lib/ephy-state.c index 4b3e47e46..0e4d15c3c 100644 --- a/lib/ephy-state.c +++ b/lib/ephy-state.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * Copyright © 2001 Matthew Mueller * Copyright © 2002 Jorn Baayen @@ -192,6 +193,28 @@ ephy_state_window_set_position (GtkWidget *window, EphyNode *node) } } +static void +ephy_state_save_unmaximized_size (EphyNode *node, int width, int height) +{ + ephy_node_set_property_int (node, EPHY_NODE_STATE_PROP_WIDTH, + width); + ephy_node_set_property_int (node, EPHY_NODE_STATE_PROP_HEIGHT, + height); + ephy_node_set_property_boolean (node, EPHY_NODE_STATE_PROP_SIZE, + TRUE); +} + +static void +ephy_state_save_position (EphyNode *node, int x, int y) +{ + ephy_node_set_property_int (node, EPHY_NODE_STATE_PROP_POSITION_X, + x); + ephy_node_set_property_int (node, EPHY_NODE_STATE_PROP_POSITION_Y, + y); + ephy_node_set_property_boolean (node, EPHY_NODE_STATE_PROP_POSITION, + TRUE); +} + static void ephy_state_window_save_size (GtkWidget *window, EphyNode *node) @@ -199,7 +222,6 @@ ephy_state_window_save_size (GtkWidget *window, EphyNode *node) int width, height; gboolean maximize; GdkWindowState state; - GValue value = { 0, }; state = gdk_window_get_state (GTK_WIDGET (window)->window); maximize = ((state & GDK_WINDOW_STATE_MAXIMIZED) > 0); @@ -209,30 +231,12 @@ ephy_state_window_save_size (GtkWidget *window, EphyNode *node) if (!maximize) { - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, width); - ephy_node_set_property (node, EPHY_NODE_STATE_PROP_WIDTH, - &value); - g_value_unset (&value); - - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, height); - ephy_node_set_property (node, EPHY_NODE_STATE_PROP_HEIGHT, - &value); - g_value_unset (&value); - - g_value_init (&value, G_TYPE_BOOLEAN); - g_value_set_boolean (&value, TRUE); - ephy_node_set_property (node, EPHY_NODE_STATE_PROP_SIZE, - &value); - g_value_unset (&value); + ephy_state_save_unmaximized_size (node, width, height); } - - g_value_init (&value, G_TYPE_BOOLEAN); - g_value_set_boolean (&value, maximize); - ephy_node_set_property (node, EPHY_NODE_STATE_PROP_MAXIMIZE, - &value); - g_value_unset (&value); + + ephy_node_set_property_boolean (node, + EPHY_NODE_STATE_PROP_MAXIMIZE, + maximize); } static void @@ -241,7 +245,6 @@ ephy_state_window_save_position (GtkWidget *window, EphyNode *node) int x,y; gboolean maximize; GdkWindowState state; - GValue value = { 0, }; state = gdk_window_get_state (GTK_WIDGET (window)->window); maximize = ((state & GDK_WINDOW_STATE_MAXIMIZED) > 0); @@ -250,24 +253,7 @@ ephy_state_window_save_position (GtkWidget *window, EphyNode *node) if (!maximize) { gtk_window_get_position (GTK_WINDOW (window), &x, &y); - - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, x); - ephy_node_set_property (node, EPHY_NODE_STATE_PROP_POSITION_X, - &value); - g_value_unset (&value); - - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, y); - ephy_node_set_property (node, EPHY_NODE_STATE_PROP_POSITION_Y, - &value); - g_value_unset (&value); - - g_value_init (&value, G_TYPE_BOOLEAN); - g_value_set_boolean (&value, TRUE); - ephy_node_set_property (node, EPHY_NODE_STATE_PROP_POSITION, - &value); - g_value_unset (&value); + ephy_state_save_position (node, x, y); } } @@ -327,44 +313,29 @@ create_window_node (const char *name, EphyStateWindowFlags flags) { EphyNode *node; - GValue value = { 0, }; node = ephy_node_new (states_db); ephy_node_add_child (states, node); - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, name); - ephy_node_set_property (node, EPHY_NODE_STATE_PROP_NAME, - &value); - g_value_unset (&value); - - g_value_init (&value, G_TYPE_BOOLEAN); - g_value_set_boolean (&value, maximize); - ephy_node_set_property (node, EPHY_NODE_STATE_PROP_MAXIMIZE, - &value); - g_value_unset (&value); + ephy_node_set_property_string (node, EPHY_NODE_STATE_PROP_NAME, + name); + ephy_node_set_property_boolean (node, EPHY_NODE_STATE_PROP_MAXIMIZE, + maximize); if (flags & EPHY_STATE_WINDOW_SAVE_SIZE) { - g_value_init (&value, G_TYPE_BOOLEAN); - g_value_set_boolean (&value, TRUE); - ephy_node_set_property (node, EPHY_NODE_STATE_PROP_SIZE, - &value); - g_value_unset (&value); - - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, default_width); - ephy_node_set_property (node, EPHY_NODE_STATE_PROP_WIDTH, - &value); - g_value_unset (&value); - - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, default_height); - ephy_node_set_property (node, EPHY_NODE_STATE_PROP_HEIGHT, - &value); - g_value_unset (&value); + ephy_state_save_unmaximized_size (node, + default_width, + default_height); } + if (flags & EPHY_STATE_WINDOW_SAVE_POSITION) + { + /* Constants for now, these should be default_width + and default_height. */ + ephy_state_save_position (node, 0, 0); + } + return node; } @@ -404,16 +375,10 @@ paned_sync_position_cb (GtkWidget *paned, EphyNode *node) { int width; - GValue value = { 0, }; width = gtk_paned_get_position (GTK_PANED (paned)); - - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, width); - ephy_node_set_property (node, EPHY_NODE_STATE_PROP_WIDTH, - &value); - g_value_unset (&value); - + ephy_node_set_property_int (node, EPHY_NODE_STATE_PROP_WIDTH, + width); return FALSE; } @@ -430,22 +395,15 @@ ephy_state_add_paned (GtkWidget *paned, node = find_by_name (name); if (node == NULL) { - GValue value = { 0, }; - node = ephy_node_new (states_db); ephy_node_add_child (states, node); - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, name); - ephy_node_set_property (node, EPHY_NODE_STATE_PROP_NAME, - &value); - g_value_unset (&value); - - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, default_width); - ephy_node_set_property (node, EPHY_NODE_STATE_PROP_WIDTH, - &value); - g_value_unset (&value); + ephy_node_set_property_string (node, + EPHY_NODE_STATE_PROP_NAME, + name); + ephy_node_set_property_int (node, + EPHY_NODE_STATE_PROP_WIDTH, + default_width); } width = ephy_node_get_property_int (node, EPHY_NODE_STATE_PROP_WIDTH); @@ -460,12 +418,12 @@ sync_expander_cb (GtkExpander *expander, GParamSpec *pspec, EphyNode *node) { - GValue value = { 0, }; + gboolean is_expanded; - g_value_init (&value, G_TYPE_BOOLEAN); - g_value_set_boolean (&value, gtk_expander_get_expanded (expander)); - ephy_node_set_property (node, EPHY_NODE_STATE_PROP_ACTIVE, &value); - g_value_unset (&value); + is_expanded = gtk_expander_get_expanded (expander); + ephy_node_set_property_boolean (node, + EPHY_NODE_STATE_PROP_ACTIVE, + is_expanded); } static void @@ -473,12 +431,12 @@ sync_toggle_cb (GtkToggleButton *toggle, GParamSpec *pspec, EphyNode *node) { - GValue value = { 0, }; + gboolean is_active; - g_value_init (&value, G_TYPE_BOOLEAN); - g_value_set_boolean (&value, gtk_toggle_button_get_active (toggle)); - ephy_node_set_property (node, EPHY_NODE_STATE_PROP_ACTIVE, &value); - g_value_unset (&value); + is_active = gtk_toggle_button_get_active (toggle); + ephy_node_set_property_boolean (node, + EPHY_NODE_STATE_PROP_ACTIVE, + is_active); } void @@ -494,22 +452,15 @@ ephy_state_add_expander (GtkWidget *widget, node = find_by_name (name); if (node == NULL) { - GValue value = { 0, }; - node = ephy_node_new (states_db); ephy_node_add_child (states, node); - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, name); - ephy_node_set_property (node, EPHY_NODE_STATE_PROP_NAME, - &value); - g_value_unset (&value); - - g_value_init (&value, G_TYPE_BOOLEAN); - g_value_set_boolean (&value, default_state); - ephy_node_set_property - (node, EPHY_NODE_STATE_PROP_ACTIVE, &value); - g_value_unset (&value); + ephy_node_set_property_string (node, + EPHY_NODE_STATE_PROP_NAME, + name); + ephy_node_set_property_boolean (node, + EPHY_NODE_STATE_PROP_ACTIVE, + default_state); } active = ephy_node_get_property_boolean diff --git a/lib/widgets/ephy-node-view.c b/lib/widgets/ephy-node-view.c index 43bdfcc3a..b94867cf3 100644 --- a/lib/widgets/ephy-node-view.c +++ b/lib/widgets/ephy-node-view.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * Copyright © 2002 Jorn Baayen * @@ -959,7 +960,6 @@ cell_renderer_edited (GtkCellRendererText *cell, const char *new_text, EphyNodeView *view) { - GValue value = { 0, }; GtkTreePath *path; GtkTreeIter iter, iter2; EphyNode *node; @@ -978,12 +978,8 @@ cell_renderer_edited (GtkCellRendererText *cell, (GTK_TREE_MODEL_FILTER (view->priv->filtermodel), &iter, &iter2); node = ephy_tree_model_node_node_from_iter (view->priv->nodemodel, &iter); - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, new_text); - ephy_node_set_property (node, - view->priv->editable_property, - &value); - g_value_unset (&value); + ephy_node_set_property_string (node, view->priv->editable_property, + new_text); gtk_tree_path_free (path); diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c index 9196a271c..51c234627 100644 --- a/src/bookmarks/ephy-bookmarks.c +++ b/src/bookmarks/ephy-bookmarks.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * Copyright © 2002-2004 Marco Pesenti Gritti * Copyright © 2003, 2004 Christian Persch @@ -440,7 +441,7 @@ update_bookmark_response_cb (GtkWidget *dialog, { to_uri = (char *) g_object_steal_data (G_OBJECT (dialog), UPDATE_URI_DATA_KEY); - + g_value_init (&value, G_TYPE_STRING); g_value_take_string (&value, to_uri); ephy_node_set_property (bookmark, EPHY_NODE_BMK_PROP_LOCATION, @@ -537,7 +538,6 @@ ephy_setup_history_notifiers (EphyBookmarks *eb) static void update_bookmark_keywords (EphyBookmarks *eb, EphyNode *bookmark) { - GValue value = { 0, }; GPtrArray *children; int i; GString *list; @@ -577,11 +577,8 @@ update_bookmark_keywords (EphyBookmarks *eb, EphyNode *bookmark) normalized_keywords = g_utf8_normalize (list->str, -1, G_NORMALIZE_ALL); case_normalized_keywords = g_utf8_casefold (normalized_keywords, -1); - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, case_normalized_keywords); - ephy_node_set_property (bookmark, EPHY_NODE_BMK_PROP_KEYWORDS, - &value); - g_value_unset (&value); + ephy_node_set_property_string (bookmark, EPHY_NODE_BMK_PROP_KEYWORDS, + case_normalized_keywords); g_string_free (list, TRUE); g_free (normalized_keywords); @@ -955,15 +952,13 @@ browse_cb (GnomeVFSDNSSDBrowseHandle *handle, g_value_unset (&value); /* FIXME: limit length! */ - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, service->name); - ephy_node_set_property (node, EPHY_NODE_BMK_PROP_TITLE, &value); - g_value_unset (&value); + ephy_node_set_property_string (node, + EPHY_NODE_BMK_PROP_TITLE, + service->name); - g_value_init (&value, G_TYPE_BOOLEAN); - g_value_set_boolean (&value, TRUE); - ephy_node_set_property (node, EPHY_NODE_BMK_PROP_IMMUTABLE, &value); - g_value_unset (&value); + ephy_node_set_property_boolean (node, + EPHY_NODE_BMK_PROP_IMMUTABLE, + TRUE); ephy_node_db_set_immutable (priv->db, was_immutable); } @@ -1051,9 +1046,36 @@ ephy_local_bookmarks_stop (EphyBookmarks *bookmarks) static void ephy_bookmarks_init (EphyBookmarks *eb) { - GValue value = { 0, }; EphyNodeDb *db; + /* Translators: The text before the "|" is context to help you + * decide on the correct translation. You MUST OMIT it in the + * translated string. */ + /* Translators: this topic contains all bookmarks */ + const char *bk_all = Q_("bookmarks|All"); + + /* Translators: The text before the "|" is context to help you + * decide on the correct translation. You MUST OMIT it in the + * translated string. */ + /* Translators: this topic contains the most used bookmarks */ + const char *bk_most_visited = Q_("bookmarks|Most Visited"); + + /* Translators: The text before the "|" is context to help you + * decide on the correct translation. You MUST OMIT it in the + * translated string. */ + /* Translators: this topic contains the not categorized + bookmarks */ + const char *bk_not_categorized = Q_("bookmarks|Not Categorized"); + +#ifdef ENABLE_ZEROCONF + /* Translators: The text before the "|" is context to help you + * decide on the correct translation. You MUST OMIT it in the + * translated string. */ + /* Translators: this is an automatic topic containing local + * websites bookmarks autodiscovered with zeroconf. */ + const char *bk_local_sites = Q_("bookmarks|Local Sites"); +#endif + eb->priv = EPHY_BOOKMARKS_GET_PRIVATE (eb); db = ephy_node_db_new (EPHY_NODE_DB_BOOKMARKS); @@ -1068,15 +1090,10 @@ ephy_bookmarks_init (EphyBookmarks *eb) /* Bookmarks */ eb->priv->bookmarks = ephy_node_new_with_id (db, BOOKMARKS_NODE_ID); - g_value_init (&value, G_TYPE_STRING); - /* Translators: The text before the "|" is context to help you decide on - * the correct translation. You MUST OMIT it in the translated string. */ - /* Translators: this topic contains all bookmarks */ - g_value_set_string (&value, Q_("bookmarks|All")); - ephy_node_set_property (eb->priv->bookmarks, - EPHY_NODE_KEYWORD_PROP_NAME, - &value); - g_value_unset (&value); + + ephy_node_set_property_string (eb->priv->bookmarks, + EPHY_NODE_KEYWORD_PROP_NAME, + bk_all); ephy_node_signal_connect_object (eb->priv->bookmarks, EPHY_NODE_CHILD_REMOVED, (EphyNodeCallback) bookmarks_removed_cb, @@ -1088,12 +1105,10 @@ ephy_bookmarks_init (EphyBookmarks *eb) /* Keywords */ eb->priv->keywords = ephy_node_new_with_id (db, KEYWORDS_NODE_ID); - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, EPHY_NODE_ALL_PRIORITY); - ephy_node_set_property (eb->priv->bookmarks, - EPHY_NODE_KEYWORD_PROP_PRIORITY, - &value); - g_value_unset (&value); + ephy_node_set_property_int (eb->priv->bookmarks, + EPHY_NODE_KEYWORD_PROP_PRIORITY, + EPHY_NODE_ALL_PRIORITY); + ephy_node_signal_connect_object (eb->priv->keywords, EPHY_NODE_CHILD_REMOVED, (EphyNodeCallback) topics_removed_cb, @@ -1104,40 +1119,29 @@ ephy_bookmarks_init (EphyBookmarks *eb) /* Favorites */ eb->priv->favorites = ephy_node_new_with_id (db, FAVORITES_NODE_ID); - g_value_init (&value, G_TYPE_STRING); - /* Translators: The text before the "|" is context to help you decide on - * the correct translation. You MUST OMIT it in the translated string. */ - /* Translators: this topic contains the most used bookmarks */ - g_value_set_string (&value, Q_("bookmarks|Most Visited")); - ephy_node_set_property (eb->priv->favorites, - EPHY_NODE_KEYWORD_PROP_NAME, - &value); - g_value_unset (&value); - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, EPHY_NODE_SPECIAL_PRIORITY); - ephy_node_set_property (eb->priv->favorites, - EPHY_NODE_KEYWORD_PROP_PRIORITY, - &value); - g_value_unset (&value); + + + ephy_node_set_property_string (eb->priv->favorites, + EPHY_NODE_KEYWORD_PROP_NAME, + bk_most_visited); + + ephy_node_set_property_int (eb->priv->favorites, + EPHY_NODE_KEYWORD_PROP_PRIORITY, + EPHY_NODE_SPECIAL_PRIORITY); ephy_node_add_child (eb->priv->keywords, eb->priv->favorites); /* Not categorized */ eb->priv->notcategorized = ephy_node_new_with_id (db, BMKS_NOTCATEGORIZED_NODE_ID); - g_value_init (&value, G_TYPE_STRING); - /* Translators: The text before the "|" is context to help you decide on - * the correct translation. You MUST OMIT it in the translated string. */ - /* Translators: this topic contains the not categorized bookmarks */ - g_value_set_string (&value, Q_("bookmarks|Not Categorized")); - ephy_node_set_property (eb->priv->notcategorized, - EPHY_NODE_KEYWORD_PROP_NAME, - &value); - g_value_unset (&value); - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, EPHY_NODE_SPECIAL_PRIORITY); - ephy_node_set_property (eb->priv->notcategorized, - EPHY_NODE_KEYWORD_PROP_PRIORITY, - &value); - g_value_unset (&value); + + + ephy_node_set_property_string (eb->priv->notcategorized, + EPHY_NODE_KEYWORD_PROP_NAME, + bk_not_categorized); + + ephy_node_set_property_int (eb->priv->notcategorized, + EPHY_NODE_KEYWORD_PROP_PRIORITY, + EPHY_NODE_SPECIAL_PRIORITY); + ephy_node_add_child (eb->priv->keywords, eb->priv->notcategorized); #ifdef ENABLE_ZEROCONF @@ -1147,22 +1151,14 @@ ephy_bookmarks_init (EphyBookmarks *eb) /* don't allow drags to this topic */ ephy_node_set_is_drag_dest (eb->priv->local, FALSE); - g_value_init (&value, G_TYPE_STRING); - /* Translators: The text before the "|" is context to help you decide on - * the correct translation. You MUST OMIT it in the translated string. */ - /* Translators: this is an automatic topic containing local websites bookmarks - * autodiscovered with zeroconf. */ - g_value_set_string (&value, Q_("bookmarks|Local Sites")); - ephy_node_set_property (eb->priv->local, - EPHY_NODE_KEYWORD_PROP_NAME, - &value); - g_value_unset (&value); - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, EPHY_NODE_SPECIAL_PRIORITY); - ephy_node_set_property (eb->priv->local, - EPHY_NODE_KEYWORD_PROP_PRIORITY, - &value); - g_value_unset (&value); + + ephy_node_set_property_string (eb->priv->local, + EPHY_NODE_KEYWORD_PROP_NAME, + bk_local_sites); + ephy_node_set_property_int (eb->priv->local, + EPHY_NODE_KEYWORD_PROP_PRIORITY, + EPHY_NODE_SPECIAL_PRIORITY); + ephy_node_add_child (eb->priv->keywords, eb->priv->local); ephy_local_bookmarks_init (eb); #endif /* ENABLE_ZEROCONF */ @@ -1302,26 +1298,19 @@ ephy_bookmarks_add (EphyBookmarks *eb, { EphyHistory *history; EphyNode *bm; - GValue value = { 0, }; bm = ephy_node_new (eb->priv->db); if (bm == NULL) return NULL; if (url == NULL) return NULL; - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, url); - ephy_node_set_property (bm, EPHY_NODE_BMK_PROP_LOCATION, &value); - g_value_unset (&value); - + ephy_node_set_property_string (bm, EPHY_NODE_BMK_PROP_LOCATION, url); + if (title == NULL || title[0] == '\0') { title = _("Untitled"); - } - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, title); - ephy_node_set_property (bm, EPHY_NODE_BMK_PROP_TITLE, &value); - g_value_unset (&value); + } + ephy_node_set_property_string (bm, EPHY_NODE_BMK_PROP_TITLE, title); history = EPHY_HISTORY (ephy_embed_shell_get_global_history (embed_shell)); if (history != NULL) @@ -1329,11 +1318,8 @@ ephy_bookmarks_add (EphyBookmarks *eb, const char *icon = ephy_history_get_icon (history, url); if (icon != NULL) { - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, icon); - ephy_node_set_property (bm, EPHY_NODE_BMK_PROP_ICON, - &value); - g_value_unset (&value); + ephy_node_set_property_string + (bm, EPHY_NODE_BMK_PROP_ICON, icon); } } @@ -1353,13 +1339,8 @@ ephy_bookmarks_set_address (EphyBookmarks *eb, EphyNode *bookmark, const char *address) { - GValue value = { 0, }; - - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, address); - ephy_node_set_property (bookmark, EPHY_NODE_BMK_PROP_LOCATION, - &value); - g_value_unset (&value); + ephy_node_set_property_string (bookmark, EPHY_NODE_BMK_PROP_LOCATION, + address); update_has_smart_address (eb, bookmark, address); } @@ -1479,18 +1460,13 @@ ephy_bookmarks_set_icon (EphyBookmarks *eb, const char *icon) { EphyNode *node; - GValue value = { 0, }; g_return_if_fail (icon != NULL); node = ephy_bookmarks_find_bookmark (eb, url); if (node == NULL) return; - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, icon); - ephy_node_set_property (node, EPHY_NODE_BMK_PROP_ICON, - &value); - g_value_unset (&value); + ephy_node_set_property_string (node, EPHY_NODE_BMK_PROP_ICON, icon); } @@ -1500,18 +1476,14 @@ ephy_bookmarks_set_usericon (EphyBookmarks *eb, const char *icon) { EphyNode *node; - GValue value = { 0, }; g_return_if_fail (icon != NULL); node = ephy_bookmarks_find_bookmark (eb, url); if (node == NULL) return; - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, icon); - ephy_node_set_property (node, EPHY_NODE_BMK_PROP_USERICON, - &value); - g_value_unset (&value); + ephy_node_set_property_string (node, EPHY_NODE_BMK_PROP_USERICON, + icon); } @@ -1652,24 +1624,16 @@ ephy_bookmarks_add_keyword (EphyBookmarks *eb, const char *name) { EphyNode *key; - GValue value = { 0, }; key = ephy_node_new (eb->priv->db); if (key == NULL) return NULL; - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, name); - ephy_node_set_property (key, EPHY_NODE_KEYWORD_PROP_NAME, - &value); - g_value_unset (&value); - - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, EPHY_NODE_NORMAL_PRIORITY); - ephy_node_set_property (key, EPHY_NODE_KEYWORD_PROP_PRIORITY, - &value); - g_value_unset (&value); - + ephy_node_set_property_string (key, EPHY_NODE_KEYWORD_PROP_NAME, + name); + ephy_node_set_property_int (key, EPHY_NODE_KEYWORD_PROP_PRIORITY, + EPHY_NODE_NORMAL_PRIORITY); + ephy_node_add_child (eb->priv->keywords, key); return key; diff --git a/src/ephy-tab.c b/src/ephy-tab.c index f66c7135f..ed5cca59f 100644 --- a/src/ephy-tab.c +++ b/src/ephy-tab.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * Copyright © 2000-2003 Marco Pesenti Gritti * Copyright © 2003, 2004, 2005 Christian Persch @@ -1616,7 +1617,6 @@ ephy_tab_zoom_changed_cb (EphyEmbed *embed, float zoom, EphyTab *tab) { EphyHistory *history; EphyNode *host; - GValue value = { 0, }; history = EPHY_HISTORY (ephy_embed_shell_get_global_history (embed_shell)); host = ephy_history_get_host (history, address); @@ -1626,12 +1626,9 @@ ephy_tab_zoom_changed_cb (EphyEmbed *embed, float zoom, EphyTab *tab) float zoom; zoom = ephy_embed_get_zoom (embed); - - g_value_init (&value, G_TYPE_FLOAT); - g_value_set_float (&value, zoom); - ephy_node_set_property - (host, EPHY_NODE_HOST_PROP_ZOOM, &value); - g_value_unset (&value); + ephy_node_set_property_float (host, + EPHY_NODE_HOST_PROP_ZOOM, + zoom); } } @@ -2257,10 +2254,11 @@ ephy_tab_get_navigation_flags (EphyTab *tab) * ephy_tab_get_status_message: * @tab: an #EphyTab * - * Returns the message displayed in @tab's #EphyWindow's #EphyStatusbar. If the - * user is hovering the mouse over a hyperlink, this function will return the - * same value as ephy_tab_get_link_message(). Otherwise, it will return a - * network status message, or NULL. + * Returns the message displayed in @tab's #EphyWindow's + * #EphyStatusbar. If the user is hovering the mouse over a hyperlink, + * this function will return the same value as + * ephy_tab_get_link_message(). Otherwise, it will return a network + * status message, or NULL. * * The message returned has a limited lifetime, and so should be copied with * g_strdup() if it must be stored. -- cgit v1.2.3