diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2003-11-05 07:26:31 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2003-11-05 07:26:31 +0800 |
commit | f2d0b1b1266b3bd92916dc23019af6322d510f77 (patch) | |
tree | 1838153d12e732513d0e2bbe9ceb44bb6a784afd /embed/mozilla | |
parent | 359950ec9266be580ab6bb599e59a05919c7c42a (diff) | |
download | gsoc2013-epiphany-f2d0b1b1266b3bd92916dc23019af6322d510f77.tar gsoc2013-epiphany-f2d0b1b1266b3bd92916dc23019af6322d510f77.tar.gz gsoc2013-epiphany-f2d0b1b1266b3bd92916dc23019af6322d510f77.tar.bz2 gsoc2013-epiphany-f2d0b1b1266b3bd92916dc23019af6322d510f77.tar.lz gsoc2013-epiphany-f2d0b1b1266b3bd92916dc23019af6322d510f77.tar.xz gsoc2013-epiphany-f2d0b1b1266b3bd92916dc23019af6322d510f77.tar.zst gsoc2013-epiphany-f2d0b1b1266b3bd92916dc23019af6322d510f77.zip |
Get rid of gresult type. Use return values instead of out-parameters
2003-11-05 Christian Persch <chpe@cvs.gnome.org>
* embed/Makefile.am:
* embed/ephy-command-manager.c: (ephy_command_manager_do_command),
(ephy_command_manager_get_command_state):
* embed/ephy-command-manager.h:
* embed/ephy-embed-event.c: (ephy_embed_event_get_type),
(ephy_embed_event_class_init), (ephy_embed_event_init),
(ephy_embed_event_finalize), (ephy_embed_event_new),
(ephy_embed_event_get_event_type), (ephy_embed_event_get_coords),
(ephy_embed_event_get_context), (ephy_embed_event_set_property):
* embed/ephy-embed-event.h:
* embed/ephy-embed-persist.c: (ephy_embed_persist_cancel):
* embed/ephy-embed-persist.h:
* embed/ephy-embed-popup-control.c:
(ephy_embed_popup_control_set_event),
(embed_popup_copy_location_cmd), (embed_popup_save_page_as_cmd),
(embed_popup_open_frame_cmd):
* embed/ephy-embed-single.c: (ephy_embed_single_get_type),
(ephy_embed_single_class_init), (ephy_embed_single_clear_cache),
(ephy_embed_single_set_offline_mode),
(ephy_embed_single_load_proxy_autoconf),
(ephy_embed_single_get_font_list),
(ephy_embed_single_list_cookies),
(ephy_embed_single_remove_cookies),
(ephy_embed_single_list_passwords),
(ephy_embed_single_remove_passwords),
(ephy_embed_single_free_cookies),
(ephy_embed_single_free_passwords):
* embed/ephy-embed-single.h:
* embed/ephy-embed-types.h:
* embed/ephy-embed.c: (ephy_embed_get_type),
(ephy_embed_base_init), (ephy_embed_new), (ephy_embed_load_url),
(ephy_embed_stop_load), (ephy_embed_can_go_back),
(ephy_embed_can_go_forward), (ephy_embed_can_go_up),
(ephy_embed_get_go_up_list), (ephy_embed_go_back),
(ephy_embed_go_forward), (ephy_embed_go_up),
(ephy_embed_get_title), (ephy_embed_get_location),
(ephy_embed_reload), (ephy_embed_zoom_set), (ephy_embed_zoom_get),
(ephy_embed_shistory_n_items), (ephy_embed_shistory_get_nth),
(ephy_embed_shistory_get_pos), (ephy_embed_shistory_go_nth),
(ephy_embed_get_security_level), (ephy_embed_find_set_properties),
(ephy_embed_find_next), (ephy_embed_activate),
(ephy_embed_set_encoding), (ephy_embed_get_encoding_info),
(ephy_embed_print), (ephy_embed_print_preview_close),
(ephy_embed_print_preview_n_pages),
(ephy_embed_print_preview_navigate):
* embed/ephy-embed.h:
* embed/ephy-history.c:
* embed/find-dialog.c: (find_dialog_go_next),
(find_dialog_go_prev):
* embed/mozilla/mozilla-embed-persist.cpp:
* embed/mozilla/mozilla-embed-single.cpp:
* embed/mozilla/mozilla-embed.cpp:
* embed/mozilla/mozilla-embed.h:
* lib/Makefile.am:
* lib/ephy-state.c:
* lib/ephy-types.h:
* src/ephy-encoding-dialog.c: (sync_embed_cb), (activate_choice):
* src/ephy-encoding-menu.c: (update_encoding_menu_cb),
(encoding_activate_cb):
* src/ephy-favicon-action.c: (each_url_get_data_binder):
* src/ephy-nautilus-view.c: (gnv_embed_dom_mouse_click_cb),
(gnv_embed_context_menu_cb), (gnv_embed_title_cb),
(gnv_popup_cmd_frame_in_new_window), (gnv_zoomable_zoom_in_cb),
(gnv_zoomable_zoom_out_cb):
* src/ephy-navigation-action.c: (activate_up_menu_item_cb),
(setup_back_or_forward_menu), (setup_up_menu):
* src/ephy-tab.c: (ephy_tab_address_cb),
(ephy_tab_zoom_changed_cb), (ephy_tab_title_cb),
(ephy_tab_dom_mouse_click_cb), (ephy_tab_update_navigation_flags),
(ephy_tab_set_title):
* src/ephy-window.c: (edit_menu_show_cb), (sync_tab_security),
(show_embed_popup), (ephy_window_set_zoom):
* src/pdm-dialog.c: (pdm_dialog_init):
* src/popup-commands.c: (popup_cmd_frame_in_new_tab),
(popup_cmd_frame_in_new_window), (popup_cmd_open_frame):
* src/ppview-toolbar.c: (toolbar_update_sensitivity),
(toolbar_cmd_ppv_goto_last), (clamp_page_limits):
* src/prefs-dialog.c: (setup_font_menu),
(prefs_homepage_current_button_clicked_cb):
* src/session.c: (save_tab):
* src/window-commands.c: (window_cmd_file_send_to),
(window_cmd_file_bookmark_page), (window_cmd_view_page_source):
Get rid of gresult type. Use return values instead of out-parameters
whereever possible, and port all callers.
Diffstat (limited to 'embed/mozilla')
-rw-r--r-- | embed/mozilla/mozilla-embed-persist.cpp | 43 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed-single.cpp | 128 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed.cpp | 548 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed.h | 5 |
4 files changed, 262 insertions, 462 deletions
diff --git a/embed/mozilla/mozilla-embed-persist.cpp b/embed/mozilla/mozilla-embed-persist.cpp index 052aacb76..f2e586294 100644 --- a/embed/mozilla/mozilla-embed-persist.cpp +++ b/embed/mozilla/mozilla-embed-persist.cpp @@ -43,9 +43,9 @@ mozilla_embed_persist_init (MozillaEmbedPersist *ges); static void mozilla_embed_persist_finalize (GObject *object); -static gresult +static gboolean impl_save (EphyEmbedPersist *persist); -static gresult +static void impl_cancel (EphyEmbedPersist *persist); #define MOZILLA_EMBED_PERSIST_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), MOZILLA_TYPE_EMBED_PERSIST, MozillaEmbedPersistPrivate)) @@ -133,21 +133,20 @@ mozilla_embed_persist_cancelled (MozillaEmbedPersist *persist) g_object_unref (persist); } -static gresult +static void impl_cancel (EphyEmbedPersist *persist) { nsCOMPtr<nsIWebBrowserPersist> bpersist = MOZILLA_EMBED_PERSIST (persist)->priv->mPersist; - if (!bpersist) return G_FAILED; - - bpersist->CancelSave (); + if (bpersist) + { + bpersist->CancelSave (); + } g_object_unref (persist); - - return G_OK; } -static gresult +static gboolean impl_save (EphyEmbedPersist *persist) { nsresult rv; @@ -171,14 +170,14 @@ impl_save (EphyEmbedPersist *persist) NULL); g_return_val_if_fail (!(flags & EMBED_PERSIST_COPY_PAGE) - || embed != NULL, G_FAILED); - g_return_val_if_fail (filename != NULL, G_FAILED); + || embed != NULL, FALSE); + g_return_val_if_fail (filename != NULL, FALSE); EphyBrowser *browser = NULL; if (embed) { browser = (EphyBrowser *) mozilla_embed_get_ephy_browser (MOZILLA_EMBED(embed)); - g_return_val_if_fail (browser != NULL, G_FAILED); + g_return_val_if_fail (browser != NULL, FALSE); } /* we must have one of uri or browser */ @@ -186,7 +185,7 @@ impl_save (EphyEmbedPersist *persist) /* Get a temp filename to save to */ nsCOMPtr<nsIProperties> dirService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv)); - if (!dirService) return G_FAILED; + if (!dirService) return FALSE; nsCOMPtr<nsIFile> tmpFile; dirService->Get("TmpD", NS_GET_IID(nsIFile), getter_AddRefs(tmpFile)); static short unsigned int tmpRandom = 0; @@ -207,10 +206,10 @@ impl_save (EphyEmbedPersist *persist) else { rv = browser->GetDocumentUrl (sURI); - if (NS_FAILED(rv)) return G_FAILED; + if (NS_FAILED(rv)) return FALSE; } rv = NS_NewURI(getter_AddRefs(inURI), sURI); - if (NS_FAILED(rv) || !inURI) return G_FAILED; + if (NS_FAILED(rv) || !inURI) return FALSE; /* Get post data */ nsCOMPtr<nsIInputStream> postData; @@ -243,7 +242,7 @@ impl_save (EphyEmbedPersist *persist) { rv = browser->GetTargetDocument (getter_AddRefs(DOMDocument)); } - if (NS_FAILED(rv) || !DOMDocument) return G_FAILED; + if (NS_FAILED(rv) || !DOMDocument) return FALSE; } @@ -259,16 +258,16 @@ impl_save (EphyEmbedPersist *persist) /* Create an header sniffer and do the save */ nsCOMPtr<nsIWebBrowserPersist> webPersist = MOZILLA_EMBED_PERSIST (persist)->priv->mPersist; - if (!webPersist) return G_FAILED; + if (!webPersist) return FALSE; EphyHeaderSniffer* sniffer = new EphyHeaderSniffer (webPersist, MOZILLA_EMBED_PERSIST (persist), tmpFile, inURI, DOMDocument, postData); - if (!sniffer) return G_FAILED; + if (!sniffer) return FALSE; webPersist->SetProgressListener(sniffer); rv = webPersist->SaveURI(inURI, nsnull, nsnull, nsnull, nsnull, tmpFile); - if (NS_FAILED (rv)) return G_FAILED; + if (NS_FAILED (rv)) return FALSE; } else { @@ -276,13 +275,13 @@ impl_save (EphyEmbedPersist *persist) nsCOMPtr<nsILocalFile> destFile; rv = NS_NewNativeLocalFile (nsDependentCString(filename), PR_TRUE, getter_AddRefs(destFile)); - if (NS_FAILED(rv) || !destFile) return G_FAILED; + if (NS_FAILED(rv) || !destFile) return FALSE; rv = InitiateMozillaDownload (DOMDocument, inURI, destFile, nsnull, inURI, MOZILLA_EMBED_PERSIST (persist), postData, pageDescriptor); - if (NS_FAILED (rv)) return G_FAILED; + if (NS_FAILED (rv)) return FALSE; } - return G_OK; + return TRUE; } diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp index fe05a11f6..1dd020a59 100644 --- a/embed/mozilla/mozilla-embed-single.cpp +++ b/embed/mozilla/mozilla-embed-single.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000, 2001, 2002 Marco Pesenti Gritti + * Copyright (C) 2000-2003 Marco Pesenti Gritti * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -72,29 +72,26 @@ mozilla_embed_single_init (MozillaEmbedSingle *ges); static void mozilla_embed_single_finalize (GObject *object); -static gresult +static void impl_clear_cache (EphyEmbedSingle *shell); -static gresult +static void impl_set_offline_mode (EphyEmbedSingle *shell, gboolean offline); -static gresult +static void impl_load_proxy_autoconf (EphyEmbedSingle *shell, const char* url); -static gresult +static GList * impl_get_font_list (EphyEmbedSingle *shell, - const char *langGroup, - GList **fontList); -static gresult -impl_list_cookies (EphyEmbedSingle *shell, - GList **cookies); -static gresult + const char *langGroup); +static GList * +impl_list_cookies (EphyEmbedSingle *shell); +static void impl_remove_cookies (EphyEmbedSingle *shell, GList *cookies); -static gresult +static GList * impl_list_passwords (EphyEmbedSingle *shell, - PasswordType type, - GList **passwords); -static gresult + PasswordType type); +static void impl_remove_passwords (EphyEmbedSingle *shell, GList *passwords, PasswordType type); @@ -531,37 +528,33 @@ mozilla_embed_single_finalize (GObject *object) } } -static gresult +static void impl_clear_cache (EphyEmbedSingle *shell) { nsresult rv; nsCOMPtr<nsICacheService> CacheService = do_GetService (NS_CACHESERVICE_CONTRACTID, &rv); - if (NS_FAILED(rv)) return G_FAILED; - - CacheService->EvictEntries (nsICache::STORE_ANYWHERE); - - return G_OK; + if (NS_SUCCEEDED (rv)) + { + CacheService->EvictEntries (nsICache::STORE_ANYWHERE); + } } -static gresult +static void impl_set_offline_mode (EphyEmbedSingle *shell, gboolean offline) { nsresult rv; nsCOMPtr<nsIIOService> io = do_GetService(NS_IOSERVICE_CONTRACTID, &rv); - if (NS_FAILED(rv)) - return G_FAILED; - - rv = io->SetOffline(offline); - if (NS_SUCCEEDED(rv)) return G_FAILED; - - return G_OK; + if (NS_SUCCEEDED (rv)) + { + io->SetOffline(offline); + } } -static gresult +static void impl_load_proxy_autoconf (EphyEmbedSingle *shell, const char* url) { @@ -570,18 +563,15 @@ impl_load_proxy_autoconf (EphyEmbedSingle *shell, nsCOMPtr<nsIProtocolProxyService> pps = do_GetService ("@mozilla.org/network/protocol-proxy-service;1", &rv); - if (NS_FAILED(rv) || !pps) return G_FAILED; - - rv = pps->ConfigureFromPAC (url); - if (NS_FAILED(rv)) return G_FAILED; - - return G_OK; + if (NS_SUCCEEDED (rv)) + { + pps->ConfigureFromPAC (url); + } } -static gresult +static GList * impl_get_font_list (EphyEmbedSingle *shell, - const char *langGroup, - GList **fontList) + const char *langGroup) { nsresult rv; PRUint32 fontCount; @@ -590,11 +580,11 @@ impl_get_font_list (EphyEmbedSingle *shell, nsCOMPtr<nsIFontEnumerator> mozFontEnumerator; mozFontEnumerator = do_CreateInstance("@mozilla.org/gfx/fontenumerator;1", &rv); - if(NS_FAILED(rv)) return G_FAILED; + if(NS_FAILED(rv)) return NULL; rv = mozFontEnumerator->EnumerateFonts (nsnull, nsnull, &fontCount, &fontArray); - if (NS_FAILED (rv)) return G_FAILED; + if (NS_FAILED (rv)) return NULL; for (PRUint32 i = 0; i < fontCount; i++) { @@ -607,23 +597,21 @@ impl_get_font_list (EphyEmbedSingle *shell, nsMemory::Free (fontArray); - *fontList = g_list_reverse (l); - - return G_OK; + return g_list_reverse (l); } -static gresult -impl_list_cookies (EphyEmbedSingle *shell, - GList **cookies) +static GList * +impl_list_cookies (EphyEmbedSingle *shell) { nsresult result; + GList *cookies = NULL; nsCOMPtr<nsICookieManager> cookieManager = do_CreateInstance (NS_COOKIEMANAGER_CONTRACTID); nsCOMPtr<nsISimpleEnumerator> cookieEnumerator; result = cookieManager->GetEnumerator (getter_AddRefs(cookieEnumerator)); - if (NS_FAILED(result)) return G_FAILED; + if (NS_FAILED(result)) return NULL; PRBool enumResult; for (cookieEnumerator->HasMoreElements(&enumResult) ; @@ -634,7 +622,7 @@ impl_list_cookies (EphyEmbedSingle *shell, nsCOMPtr<nsICookie> nsCookie; result = cookieEnumerator->GetNext (getter_AddRefs(nsCookie)); - if (NS_FAILED(result)) return G_FAILED; + if (NS_FAILED(result)) return NULL; c = g_new0 (CookieInfo, 1); @@ -663,15 +651,13 @@ impl_list_cookies (EphyEmbedSingle *shell, else c->expire = g_strdup_printf ("%s",ctime((time_t*)&dateTime)); - *cookies = g_list_prepend (*cookies, c); + cookies = g_list_prepend (cookies, c); } - *cookies = g_list_reverse (*cookies); - - return G_OK; + return g_list_reverse (cookies); } -static gresult +static void impl_remove_cookies (EphyEmbedSingle *shell, GList *cookies) { @@ -679,9 +665,8 @@ impl_remove_cookies (EphyEmbedSingle *shell, GList *cl; nsCOMPtr<nsICookieManager> cookieManager = do_CreateInstance (NS_COOKIEMANAGER_CONTRACTID); - - for (cl = g_list_first(cookies) ; cl != NULL ; - cl = g_list_next (cl)) + + for (cl = cookies; cl != NULL; cl = cl->next) { CookieInfo *c = (CookieInfo *)cl->data; @@ -689,18 +674,15 @@ impl_remove_cookies (EphyEmbedSingle *shell, nsDependentCString(c->name), nsDependentCString(c->path), PR_FALSE); - if (NS_FAILED(result)) return G_FAILED; }; - - return G_OK; } -static gresult +static GList * impl_list_passwords (EphyEmbedSingle *shell, - PasswordType type, - GList **passwords) + PasswordType type) { nsresult result = NS_ERROR_FAILURE; + GList *passwords = NULL; nsCOMPtr<nsIPasswordManager> passwordManager = do_CreateInstance (NS_PASSWORDMANAGER_CONTRACTID); @@ -711,7 +693,7 @@ impl_list_passwords (EphyEmbedSingle *shell, else if (type == PASSWORD_REJECT) result = passwordManager->GetRejectEnumerator (getter_AddRefs(passwordEnumerator)); - if (NS_FAILED(result)) return G_FAILED; + if (NS_FAILED(result)) return NULL; PRBool enumResult; for (passwordEnumerator->HasMoreElements(&enumResult) ; @@ -721,7 +703,7 @@ impl_list_passwords (EphyEmbedSingle *shell, nsCOMPtr<nsIPassword> nsPassword; result = passwordEnumerator->GetNext (getter_AddRefs(nsPassword)); - if (NS_FAILED(result)) return G_FAILED; + if (NS_FAILED(result)) return NULL; PasswordInfo *p = g_new0 (PasswordInfo, 1); @@ -736,15 +718,13 @@ impl_list_passwords (EphyEmbedSingle *shell, p->username = g_strdup(NS_ConvertUCS2toUTF8(unicodeName).get()); } - *passwords = g_list_prepend (*passwords, p); + passwords = g_list_prepend (passwords, p); } - *passwords = g_list_reverse (*passwords); - - return G_OK; + return g_list_reverse (passwords); } -static gresult +static void impl_remove_passwords (EphyEmbedSingle *shell, GList *passwords, PasswordType type) @@ -752,9 +732,9 @@ impl_remove_passwords (EphyEmbedSingle *shell, nsresult result = NS_ERROR_FAILURE; nsCOMPtr<nsIPasswordManager> passwordManager = do_CreateInstance (NS_PASSWORDMANAGER_CONTRACTID); + GList *l; - for (GList *l = g_list_first(passwords) ; l !=NULL ; - l = g_list_next(l)) + for (l = passwords; l != NULL; l = l->next) { PasswordInfo *p = (PasswordInfo *)l->data; if (type == PASSWORD_PASSWORD) @@ -767,9 +747,5 @@ impl_remove_passwords (EphyEmbedSingle *shell, result = passwordManager->RemoveReject (nsDependentCString(p->host)); }; - - if (NS_FAILED(result)) return G_FAILED; }; - - return G_OK; } diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp index 2d11e32ad..5f73cb0ea 100644 --- a/embed/mozilla/mozilla-embed.cpp +++ b/embed/mozilla/mozilla-embed.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000, 2001, 2002 Marco Pesenti Gritti + * Copyright (C) 2000-2003 Marco Pesenti Gritti * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,15 +18,16 @@ * $Id$ */ +#include "mozilla-embed.h" + #include "ephy-command-manager.h" #include "ephy-string.h" #include "ephy-embed.h" #include "ephy-debug.h" -#include "mozilla-embed.h" + #include "MozillaPrivate.h" #include "EphyBrowser.h" #include "EventContext.h" -#include "ephy-debug.h" #include <gtkmozembed.h> #include <gtkmozembed_internal.h> @@ -41,106 +42,74 @@ #include <nsIPrintOptions.h> #include <nsGfxCIID.h> -static void -mozilla_embed_class_init (MozillaEmbedClass *klass); -static void -mozilla_embed_init (MozillaEmbed *gs); -static void -mozilla_embed_destroy (GtkObject *object); -static void -ephy_embed_init (EphyEmbedClass *embed_class); +static void mozilla_embed_class_init (MozillaEmbedClass *klass); +static void mozilla_embed_init (MozillaEmbed *gs); +static void mozilla_embed_destroy (GtkObject *object); +static void ephy_embed_init (EphyEmbedClass *embed_class); static void -impl_get_capabilities (EphyEmbed *embed, - EmbedCapabilities *caps); -static gresult impl_load_url (EphyEmbed *embed, const char *url); -static gresult +static void impl_stop_load (EphyEmbed *embed); -static gresult +static gboolean impl_can_go_back (EphyEmbed *embed); -static gresult +static gboolean impl_can_go_forward (EphyEmbed *embed); -static gresult +static gboolean impl_can_go_up (EphyEmbed *embed); -static gresult -impl_get_go_up_list (EphyEmbed *embed, GSList **l); -static gresult +static GSList * +impl_get_go_up_list (EphyEmbed *embed); +static void impl_go_back (EphyEmbed *embed); -static gresult +static void impl_go_forward (EphyEmbed *embed); -static gresult +static void impl_go_up (EphyEmbed *embed); -static gresult -impl_render_data (EphyEmbed *embed, - const char *data, - guint32 len, - const char *base_uri, - const char *mime_type); -static gresult -impl_open_stream (EphyEmbed *embed, - const char *base_uri, - const char *mime_type); -static gresult -impl_append_data (EphyEmbed *embed, - const char *data, - guint32 len); -static gresult -impl_close_stream (EphyEmbed *embed); -static gresult -impl_get_title (EphyEmbed *embed, - char **title); -static gresult +static char * +impl_get_title (EphyEmbed *embed); +static char * impl_get_location (EphyEmbed *embed, - gboolean toplevel, - char **location); -static gresult + gboolean toplevel); +static void impl_reload (EphyEmbed *embed, EmbedReloadFlags flags); -static gresult +static void impl_zoom_set (EphyEmbed *embed, float zoom, gboolean reflow); -static gresult -impl_zoom_get (EphyEmbed *embed, - float *zoom); -static gresult -impl_shistory_count (EphyEmbed *embed, - int *count); -static gresult +static float +impl_zoom_get (EphyEmbed *embed); +static int +impl_shistory_n_items (EphyEmbed *embed); +static void impl_shistory_get_nth (EphyEmbed *embed, int nth, gboolean is_relative, char **url, char **title); -static gresult -impl_shistory_get_pos (EphyEmbed *embed, - int *pos); -static gresult +static int +impl_shistory_get_pos (EphyEmbed *embed); +static void impl_shistory_go_nth (EphyEmbed *embed, int nth); -static gresult +static void impl_get_security_level (EphyEmbed *embed, EmbedSecurityLevel *level, char **description); -static gresult +static void impl_set_encoding (EphyEmbed *embed, const char *encoding); -static gresult -impl_get_encoding_info (EphyEmbed *embed, - EphyEncodingInfo **info); -static gresult +static EphyEncodingInfo * +impl_get_encoding_info (EphyEmbed *embed); +static void impl_print (EphyEmbed *embed, EmbedPrintInfo *info); - -static gresult +static void impl_print_preview_close (EphyEmbed *embed); - -static gresult -impl_print_preview_num_pages (EphyEmbed *embed, - gint *retNum); -static gresult +static int +impl_print_preview_n_pages (EphyEmbed *embed); +static void impl_print_preview_navigate (EphyEmbed *embed, EmbedPrintPreviewNavType navType, gint pageNum); @@ -230,29 +199,26 @@ static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID); static GObjectClass *parent_class = NULL; -static gresult +static void impl_manager_do_command (EphyCommandManager *manager, const char *command) { - nsresult result = NS_OK; MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(manager)->priv; - result = mpriv->browser->DoCommand (command); - - return result ? G_OK : G_FAILED; + mpriv->browser->DoCommand (command); } -static gresult +static gboolean impl_manager_get_command_state (EphyCommandManager *manager, - const char *command, - gboolean *enabled) + const char *command) { - nsresult result; MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(manager)->priv; + nsresult result; + PRBool enabled; - result = mpriv->browser->GetCommandState (command, enabled); - - return result ? G_OK : G_FAILED; + result = mpriv->browser->GetCommandState (command, &enabled); + + return NS_SUCCEEDED (result) ? enabled : FALSE; } static void @@ -311,50 +277,41 @@ mozilla_embed_get_type (void) return mozilla_embed_type; } -static gresult +static gboolean impl_find_next (EphyEmbed *embed, gboolean backwards) { - nsresult result = NS_OK; MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv; - + nsresult result; PRBool didFind; result = mpriv->browser->Find (backwards, &didFind); - return didFind ? G_OK : G_FAILED; + return NS_SUCCEEDED (result) ? didFind : FALSE; } -static gresult +static void impl_activate (EphyEmbed *embed) { - g_return_val_if_fail (EPHY_IS_EMBED (embed), G_FAILED); - gtk_widget_grab_focus (GTK_BIN (embed)->child); - - return G_OK; } -static gresult +static void impl_find_set_properties (EphyEmbed *embed, char *search_string, gboolean case_sensitive, gboolean wrap_around) { - nsresult result = NS_OK; MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv; - result = mpriv->browser->FindSetProperties + mpriv->browser->FindSetProperties ((NS_ConvertUTF8toUCS2(search_string)).get(), case_sensitive, wrap_around); - - return result ? G_OK : G_FAILED; } static void ephy_embed_init (EphyEmbedClass *embed_class) { - embed_class->get_capabilities = impl_get_capabilities; embed_class->load_url = impl_load_url; embed_class->stop_load = impl_stop_load; embed_class->can_go_back = impl_can_go_back; @@ -364,16 +321,12 @@ ephy_embed_init (EphyEmbedClass *embed_class) embed_class->go_back = impl_go_back; embed_class->go_forward = impl_go_forward; embed_class->go_up = impl_go_up; - embed_class->render_data = impl_render_data; - embed_class->open_stream = impl_open_stream; - embed_class->append_data = impl_append_data; - embed_class->close_stream = impl_close_stream; embed_class->get_title = impl_get_title; embed_class->get_location = impl_get_location; embed_class->reload = impl_reload; embed_class->zoom_set = impl_zoom_set; embed_class->zoom_get = impl_zoom_get; - embed_class->shistory_count = impl_shistory_count; + embed_class->shistory_n_items = impl_shistory_n_items; embed_class->shistory_get_nth = impl_shistory_get_nth; embed_class->shistory_get_pos = impl_shistory_get_pos; embed_class->shistory_go_nth = impl_shistory_go_nth; @@ -385,7 +338,7 @@ ephy_embed_init (EphyEmbedClass *embed_class) embed_class->get_encoding_info = impl_get_encoding_info; embed_class->print = impl_print; embed_class->print_preview_close = impl_print_preview_close; - embed_class->print_preview_num_pages = impl_print_preview_num_pages; + embed_class->print_preview_n_pages = impl_print_preview_n_pages; embed_class->print_preview_navigate = impl_print_preview_navigate; } @@ -401,7 +354,7 @@ mozilla_embed_realize (GtkWidget *widget) if (NS_FAILED(result)) { - g_warning ("Browser initialization failed"); + g_warning ("EphyBrowser initialization failed for %p\n", widget); } } @@ -415,6 +368,7 @@ mozilla_embed_class_init (MozillaEmbedClass *klass) parent_class = (GObjectClass *) g_type_class_peek_parent (klass); gtk_object_class->destroy = mozilla_embed_destroy; + widget_class->realize = mozilla_embed_realize; g_type_class_add_private (object_class, sizeof(MozillaEmbedPrivate)); @@ -450,9 +404,9 @@ mozilla_embed_connect_signals (MozillaEmbed *embed) /* connect signals */ for (i = 0; signal_connections[i].event != NULL; i++) { - g_signal_connect (G_OBJECT(embed), + g_signal_connect (G_OBJECT (embed), signal_connections[i].event, - G_CALLBACK(signal_connections[i].func), + G_CALLBACK (signal_connections[i].func), embed); } } @@ -460,14 +414,14 @@ mozilla_embed_connect_signals (MozillaEmbed *embed) static void mozilla_embed_destroy (GtkObject *object) { - int i; MozillaEmbed *embed = MOZILLA_EMBED (object); + int i; for (i = 0; signal_connections[i].event != NULL; i++) { g_signal_handlers_disconnect_by_func - (G_OBJECT(object), - (gpointer)signal_connections[i].func, + (G_OBJECT (object), + (gpointer)signal_connections[i].func, (void *)object); } @@ -482,152 +436,108 @@ mozilla_embed_destroy (GtkObject *object) } static void -impl_get_capabilities (EphyEmbed *embed, - EmbedCapabilities *caps) -{ - EmbedCapabilities mozilla_caps; - - mozilla_caps = (EmbedCapabilities) ( - EMBED_CLIPBOARD_CAP | - EMBED_COOKIES_CAP | - EMBED_LINKS_CAP | - EMBED_ZOOM_CAP | - EMBED_PRINT_CAP | - EMBED_FIND_CAP | - EMBED_SECURITY_CAP | - EMBED_ENCODING_CAP | - EMBED_SHISTORY_CAP ); - - *caps = mozilla_caps; -} - -static gresult impl_load_url (EphyEmbed *embed, const char *url) { - gtk_moz_embed_load_url (GTK_MOZ_EMBED(embed), - url); - - return G_OK; + gtk_moz_embed_load_url (GTK_MOZ_EMBED(embed), url); } -static gresult +static void impl_stop_load (EphyEmbed *embed) { gtk_moz_embed_stop_load (GTK_MOZ_EMBED(embed)); - - return G_OK; } -static gresult +static gboolean impl_can_go_back (EphyEmbed *embed) { - if (gtk_moz_embed_can_go_back (GTK_MOZ_EMBED(embed))) - { - return G_OK; - } - else - { - return G_FAILED; - } + return gtk_moz_embed_can_go_back (GTK_MOZ_EMBED(embed)); } -static gresult +static gboolean impl_can_go_forward (EphyEmbed *embed) { - if (gtk_moz_embed_can_go_forward (GTK_MOZ_EMBED(embed))) - { - return G_OK; - } - else - { - return G_FAILED; - } - + return gtk_moz_embed_can_go_forward (GTK_MOZ_EMBED(embed)); } -static gresult +static gboolean impl_can_go_up (EphyEmbed *embed) { - char *location; - char *s; - gresult result; + char *address, *s; + gboolean result; - if (ephy_embed_get_location (embed, TRUE, &location) != G_OK) - return G_FAILED; - g_return_val_if_fail (location != NULL, G_FAILED); - if ((s = mozilla_embed_get_uri_parent (location)) != NULL) + address = ephy_embed_get_location (embed, TRUE); + if (address == NULL) + { + return FALSE; + } + + if ((s = mozilla_embed_get_uri_parent (address)) != NULL) { g_free (s); - result = G_OK; + result = TRUE; } else { - result = G_FAILED; + result = FALSE; } - g_free (location); + g_free (address); return result; } -static gresult -impl_get_go_up_list (EphyEmbed *embed, GSList **l) +static GSList * +impl_get_go_up_list (EphyEmbed *embed) { - char *location; - char *s; - - if (ephy_embed_get_location (embed, TRUE, &location) != G_OK) - return G_FAILED; - g_return_val_if_fail (location != NULL, G_FAILED); + GSList *l = NULL; + char *address, *s; + + address = ephy_embed_get_location (embed, TRUE); + if (address == NULL) + { + return NULL; + } - *l = NULL; - s = location; + s = address; while ((s = mozilla_embed_get_uri_parent (s)) != NULL) { - *l = g_slist_prepend (*l, s); + l = g_slist_prepend (l, s); } - g_free (location); - *l = g_slist_reverse (*l); + g_free (address); - return G_OK; + return g_slist_reverse (l); } -static gresult +static void impl_go_back (EphyEmbed *embed) { gtk_moz_embed_go_back (GTK_MOZ_EMBED(embed)); - - return G_OK; } -static gresult +static void impl_go_forward (EphyEmbed *embed) { gtk_moz_embed_go_forward (GTK_MOZ_EMBED(embed)); - - return G_OK; } -static gresult +static void impl_go_up (EphyEmbed *embed) { char *uri; char *parent_uri; - - ephy_embed_get_location (embed, TRUE, &uri); - g_return_val_if_fail (uri != NULL, G_FAILED); + + uri = ephy_embed_get_location (embed, TRUE); + g_return_if_fail (uri != NULL); parent_uri = mozilla_embed_get_uri_parent (uri); g_free (uri); - g_return_val_if_fail (parent_uri != NULL, G_FAILED); - + g_return_if_fail (parent_uri != NULL); + ephy_embed_load_url (embed, parent_uri); g_free (parent_uri); - - return G_OK; } static char * @@ -676,75 +586,25 @@ mozilla_embed_get_uri_parent (const char *aUri) return !spec.IsEmpty() ? g_strdup(spec.get()) : NULL; } -static gresult -impl_render_data (EphyEmbed *embed, - const char *data, - guint32 len, - const char *base_uri, - const char *mime_type) -{ - gtk_moz_embed_render_data (GTK_MOZ_EMBED(embed), - data, - len, - base_uri, - mime_type); - - return G_OK; -} - -static gresult -impl_open_stream (EphyEmbed *embed, - const char *base_uri, - const char *mime_type) -{ - gtk_moz_embed_open_stream (GTK_MOZ_EMBED(embed), - base_uri, mime_type); - - return G_OK; -} - -static gresult -impl_append_data (EphyEmbed *embed, - const char *data, - guint32 len) -{ - gtk_moz_embed_append_data (GTK_MOZ_EMBED(embed), - data, len); - - return G_OK; -} - -static gresult -impl_close_stream (EphyEmbed *embed) -{ - gtk_moz_embed_close_stream (GTK_MOZ_EMBED(embed)); - - return G_OK; -} - -static gresult -impl_get_title (EphyEmbed *embed, - char **title) +static char * +impl_get_title (EphyEmbed *embed) { nsXPIDLString uTitle; *getter_Copies(uTitle) = gtk_moz_embed_get_title_unichar (GTK_MOZ_EMBED(embed)); - *title = g_strdup (NS_ConvertUCS2toUTF8(uTitle).get()); - - return G_OK; + return g_strdup (NS_ConvertUCS2toUTF8(uTitle).get()); } -static gresult +static char * impl_get_location (EphyEmbed *embed, - gboolean toplevel, - char **location) + gboolean toplevel) { + MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv; char *l; nsresult rv; nsCAutoString url; - MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv; if (toplevel) { @@ -759,14 +619,10 @@ impl_get_location (EphyEmbed *embed, g_strdup (url.get()) : NULL; } - *location = l; - - if (l == NULL) return G_FAILED; - - return G_OK; + return l; } -static gresult +static void impl_reload (EphyEmbed *embed, EmbedReloadFlags flags) { @@ -790,11 +646,9 @@ impl_reload (EphyEmbed *embed, gtk_moz_embed_reload (GTK_MOZ_EMBED(embed), mflags); - - return G_OK; } -static gresult +static void impl_zoom_set (EphyEmbed *embed, float zoom, gboolean reflow) @@ -802,8 +656,10 @@ impl_zoom_set (EphyEmbed *embed, EphyBrowser *browser; nsresult result; + g_return_if_fail (zoom > 0.0); + browser = MOZILLA_EMBED(embed)->priv->browser; - g_return_val_if_fail (browser != NULL, G_FAILED); + g_return_if_fail (browser != NULL); result = browser->SetZoom (zoom, reflow); @@ -811,47 +667,37 @@ impl_zoom_set (EphyEmbed *embed, { g_signal_emit_by_name (embed, "ge_zoom_change", zoom); } - - return NS_SUCCEEDED(result) ? G_OK : G_FAILED; } -static gresult -impl_zoom_get (EphyEmbed *embed, - float *zoom) +static float +impl_zoom_get (EphyEmbed *embed) { - float f; MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv; + float f; nsresult result = mpriv->browser->GetZoom (&f); if (NS_SUCCEEDED (result)) { - *zoom = f; - - return G_OK; - } - else - { - return G_FAILED; + return f; } + + return 1.0; } -static gresult -impl_shistory_count (EphyEmbed *embed, - int *count) +static int +impl_shistory_n_items (EphyEmbed *embed) { - nsresult rv; MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv; - int c, index; - - rv = mpriv->browser->GetSHInfo (&c, &index); + nsresult rv; + int count, index; - *count = c; - - return NS_SUCCEEDED(rv) ? G_OK : G_FAILED; + rv = mpriv->browser->GetSHInfo (&count, &index); + + return NS_SUCCEEDED(rv) ? count : 0; } -static gresult +static void impl_shistory_get_nth (EphyEmbed *embed, int nth, gboolean is_relative, @@ -865,17 +711,7 @@ impl_shistory_get_nth (EphyEmbed *embed, if (is_relative) { - int pos; - - if (ephy_embed_shistory_get_pos - (EPHY_EMBED(embed), &pos) == G_OK) - { - pos += nth; - } - else - { - return G_FAILED; - } + nth += ephy_embed_shistory_get_pos (embed); } rv = mpriv->browser->GetSHUrlAtIndex(nth, url); @@ -887,62 +723,57 @@ impl_shistory_get_nth (EphyEmbed *embed, *aTitle = g_strdup (NS_ConvertUCS2toUTF8(title).get()); nsMemory::Free (title); - - return G_OK; } -static gresult -impl_shistory_get_pos (EphyEmbed *embed, - int *pos) +static int +impl_shistory_get_pos (EphyEmbed *embed) { - nsresult rv; MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv; + nsresult rv; int count, index; - + rv = mpriv->browser->GetSHInfo (&count, &index); - *pos = index; - - return NS_SUCCEEDED(rv) ? G_OK : G_FAILED; + return NS_SUCCEEDED(rv) ? index : 0; } -static gresult +static void impl_shistory_go_nth (EphyEmbed *embed, int nth) { - nsresult rv; MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv; - rv = mpriv->browser->GoToHistoryIndex (nth); - - return NS_SUCCEEDED(rv) ? G_OK : G_FAILED; + mpriv->browser->GoToHistoryIndex (nth); } -static gresult +static void impl_get_security_level (EphyEmbed *embed, EmbedSecurityLevel *level, char **description) { nsresult result; + g_return_if_fail (description != NULL || level != NULL); + *description = NULL; + *level = STATE_IS_UNKNOWN; + nsCOMPtr<nsIChannel> channel; channel = do_QueryInterface (MOZILLA_EMBED(embed)->priv->request, &result); - if (NS_FAILED (result)) return G_FAILED; + if (NS_FAILED (result)) return; nsCOMPtr<nsISupports> info; result = channel->GetSecurityInfo(getter_AddRefs(info)); - if (NS_FAILED (result)) return G_FAILED; + if (NS_FAILED (result)) return; - *description = NULL; if (info) { nsCOMPtr<nsITransportSecurityInfo> secInfo(do_QueryInterface(info)); - if (!secInfo) return G_FAILED; + if (!secInfo) return; nsXPIDLString tooltip; result = secInfo->GetShortSecurityDescription(getter_Copies(tooltip)); - if (NS_FAILED (result)) return G_FAILED; + if (NS_FAILED (result)) return; if (tooltip) { @@ -951,19 +782,18 @@ impl_get_security_level (EphyEmbed *embed, } *level = mozilla_embed_security_level (MOZILLA_EMBED (embed)); - return G_OK; } -static gresult +static void impl_print (EphyEmbed *embed, EmbedPrintInfo *info) { - nsresult result = NS_OK; MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv; + nsresult result; nsCOMPtr<nsIPrintSettings> options; result = mpriv->browser->GetPrintSettings(getter_AddRefs(options)); - if (!NS_SUCCEEDED (result)) return G_FAILED; + if (!NS_SUCCEEDED (result)) return; MozillaCollatePrintSettings(info, options); @@ -973,75 +803,70 @@ impl_print (EphyEmbed *embed, /* Workaround for bug 125984 */ options->SetPrintSilent (PR_FALSE); - - return NS_SUCCEEDED (result) ? G_OK : G_FAILED; } -static gresult +static void impl_print_preview_close (EphyEmbed *embed) { - nsresult result = NS_OK; - EphyBrowser *browser; - - browser = MOZILLA_EMBED(embed)->priv->browser; - g_return_val_if_fail (browser != NULL, G_FAILED); + MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv; - result = browser->PrintPreviewClose(); - return NS_SUCCEEDED(result) ? G_OK : G_FAILED; + mpriv->browser->PrintPreviewClose(); } -static gresult -impl_print_preview_num_pages (EphyEmbed *embed, - gint *retNum) +static int +impl_print_preview_n_pages (EphyEmbed *embed) { - nsresult result = NS_OK; MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv; - - result = mpriv->browser->PrintPreviewNumPages(retNum); - return NS_SUCCEEDED(result) ? G_OK : G_FAILED; + nsresult result; + int num; + + result = mpriv->browser->PrintPreviewNumPages(&num); + + return NS_SUCCEEDED(result) ? num : 0; } -static gresult +static void impl_print_preview_navigate (EphyEmbed *embed, - EmbedPrintPreviewNavType navType, - gint pageNum) + EmbedPrintPreviewNavType type, + int page) { - nsresult result = NS_OK; MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv; + nsresult result; - result = mpriv->browser->PrintPreviewNavigate(navType, pageNum); - return NS_SUCCEEDED(result) ? G_OK : G_FAILED; + result = mpriv->browser->PrintPreviewNavigate(type, page); } -static gresult +static void impl_set_encoding (EphyEmbed *embed, const char *encoding) { - nsresult result; MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv; + nsresult result; result = mpriv->browser->ForceEncoding (encoding); - if (NS_FAILED (result)) return G_FAILED; - + if (NS_FAILED (result)) return; + gtk_moz_embed_reload (GTK_MOZ_EMBED (embed), GTK_MOZ_EMBED_FLAG_RELOADCHARSETCHANGE); - - return NS_SUCCEEDED(result) ? G_OK : G_FAILED; } -static gresult -impl_get_encoding_info (EphyEmbed *embed, - EphyEncodingInfo **info) +static EphyEncodingInfo * +impl_get_encoding_info (EphyEmbed *embed) { - nsresult result; MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv; + nsresult result; + EphyEncodingInfo *info = NULL; - g_return_val_if_fail (info != NULL, G_FAILED); - *info = NULL; + result = mpriv->browser->GetEncodingInfo (&info); - result = mpriv->browser->GetEncodingInfo (info); + if (NS_FAILED (result)) + { + ephy_encoding_info_free (info); + + return NULL; + } - return NS_SUCCEEDED(result) ? G_OK : G_FAILED; + return info; } static void @@ -1168,7 +993,7 @@ mozilla_embed_dom_key_down_cb (GtkMozEmbed *embed, gpointer dom_event, EventContext ctx; ctx.Init (mpriv->browser); rv = ctx.GetKeyEventInfo (ev, info); - if (NS_FAILED (rv)) return G_FAILED; + if (NS_FAILED (rv)) return ret; if (info->keycode == nsIDOMKeyEvent::DOM_VK_F10 && (info->modifier == GDK_SHIFT_MASK || @@ -1217,7 +1042,7 @@ mozilla_embed_dom_mouse_click_cb (GtkMozEmbed *embed, gpointer dom_event, { EphyEmbedEvent *info; EventContext event_context; - gint return_value = 0; + gint return_value = FALSE; nsresult result; MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv; @@ -1277,7 +1102,7 @@ mozilla_embed_dom_mouse_down_cb (GtkMozEmbed *embed, gpointer dom_event, result = event_context.GetMouseEventInfo (static_cast<nsIDOMMouseEvent*>(dom_event), info); if (NS_FAILED (result)) return FALSE; - ephy_embed_event_get_event_type (info, &type); + type = ephy_embed_event_get_event_type (info); nsCOMPtr<nsIDOMDocument> domDoc; result = event_context.GetTargetDocument (getter_AddRefs(domDoc)); @@ -1404,4 +1229,3 @@ mozilla_embed_security_level (MozillaEmbed *membed) } return level; } - diff --git a/embed/mozilla/mozilla-embed.h b/embed/mozilla/mozilla-embed.h index 8412bb5b0..8070ac480 100644 --- a/embed/mozilla/mozilla-embed.h +++ b/embed/mozilla/mozilla-embed.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000, 2001, 2002 Marco Pesenti Gritti + * Copyright (C) 2000-2003 Marco Pesenti Gritti * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,12 +14,13 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ */ #ifndef MOZILLA_EMBED_H #define MOZILLA_EMBED_H -#include "ephy-embed-types.h" #include "ephy-embed.h" #include <gtkmozembed.h> |