From f2d0b1b1266b3bd92916dc23019af6322d510f77 Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Tue, 4 Nov 2003 23:26:31 +0000 Subject: Get rid of gresult type. Use return values instead of out-parameters 2003-11-05 Christian Persch * 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. --- embed/Makefile.am | 1 - embed/ephy-command-manager.c | 11 +- embed/ephy-command-manager.h | 26 +- embed/ephy-embed-event.c | 85 +++-- embed/ephy-embed-event.h | 23 +- embed/ephy-embed-persist.c | 6 +- embed/ephy-embed-persist.h | 10 +- embed/ephy-embed-popup-control.c | 10 +- embed/ephy-embed-single.c | 113 +++---- embed/ephy-embed-single.h | 120 ++++--- embed/ephy-embed-types.h | 46 --- embed/ephy-embed.c | 528 ++++++++++++++---------------- embed/ephy-embed.h | 377 ++++++++++------------ embed/ephy-history.c | 5 +- embed/find-dialog.c | 10 +- embed/mozilla/mozilla-embed-persist.cpp | 43 ++- embed/mozilla/mozilla-embed-single.cpp | 128 +++----- embed/mozilla/mozilla-embed.cpp | 548 +++++++++++--------------------- embed/mozilla/mozilla-embed.h | 5 +- 19 files changed, 851 insertions(+), 1244 deletions(-) delete mode 100644 embed/ephy-embed-types.h (limited to 'embed') diff --git a/embed/Makefile.am b/embed/Makefile.am index 614ed9955..f283889bd 100644 --- a/embed/Makefile.am +++ b/embed/Makefile.am @@ -35,7 +35,6 @@ INST_H_FILES = \ ephy-embed-prefs.h \ ephy-embed-single.h \ ephy-embed-shell.h \ - ephy-embed-types.h \ ephy-encodings.h \ ephy-history.h diff --git a/embed/ephy-command-manager.c b/embed/ephy-command-manager.c index 08654fee5..d71017446 100644 --- a/embed/ephy-command-manager.c +++ b/embed/ephy-command-manager.c @@ -79,19 +79,18 @@ ephy_command_manager_base_init (gpointer g_class) } } -gresult +void ephy_command_manager_do_command (EphyCommandManager *manager, const char *command) { EphyCommandManagerClass *klass = EPHY_COMMAND_MANAGER_GET_CLASS (manager); - return klass->do_command (manager, command); + klass->do_command (manager, command); } -gresult +gboolean ephy_command_manager_get_command_state (EphyCommandManager *manager, - const char *command, - gboolean *enabled) + const char *command) { EphyCommandManagerClass *klass = EPHY_COMMAND_MANAGER_GET_CLASS (manager); - return klass->get_command_state (manager, command, enabled); + return klass->get_command_state (manager, command); } diff --git a/embed/ephy-command-manager.h b/embed/ephy-command-manager.h index 14d7a4ca6..c8eaf0514 100644 --- a/embed/ephy-command-manager.h +++ b/embed/ephy-command-manager.h @@ -19,8 +19,6 @@ #ifndef EPHY_COMMAND_MANAGER_H #define EPHY_COMMAND_MANAGER_H -#include "ephy-embed-types.h" - #include #include @@ -38,28 +36,26 @@ typedef struct _EphyCommandManager EphyCommandManager; struct EphyCommandManagerClass { - GTypeInterface base_iface; + GTypeInterface base_iface; - gresult (* do_command) (EphyCommandManager *manager, - const char *command); - gresult (* get_command_state) (EphyCommandManager *manager, - const char *command, - gboolean *enabled); + void (* do_command) (EphyCommandManager *manager, + const char *command); + gboolean (* get_command_state) (EphyCommandManager *manager, + const char *command); /* Signals */ - void (* command_changed) (EphyCommandManager *manager, + void (* command_changed) (EphyCommandManager *manager, char *command); }; -GType ephy_command_manager_get_type (void); +GType ephy_command_manager_get_type (void); -gresult ephy_command_manager_do_command (EphyCommandManager *manager, - const char *command); +void ephy_command_manager_do_command (EphyCommandManager *manager, + const char *command); -gresult ephy_command_manager_get_command_state (EphyCommandManager *manager, - const char *command, - gboolean *enabled); +gboolean ephy_command_manager_get_command_state (EphyCommandManager *manager, + const char *command); G_END_DECLS diff --git a/embed/ephy-embed-event.c b/embed/ephy-embed-event.c index 027164114..bc99b81bf 100644 --- a/embed/ephy-embed-event.c +++ b/embed/ephy-embed-event.c @@ -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 @@ -44,37 +44,37 @@ ephy_embed_event_get_type (void) { static GType ephy_embed_event_type = 0; - if (ephy_embed_event_type == 0) - { - static const GTypeInfo our_info = - { - sizeof (EphyEmbedEventClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) ephy_embed_event_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EphyEmbedEvent), - 0, /* n_preallocs */ - (GInstanceInitFunc) ephy_embed_event_init - }; - - ephy_embed_event_type = g_type_register_static (G_TYPE_OBJECT, - "EphyEmbedEvent", - &our_info, 0); - } - - return ephy_embed_event_type; + if (ephy_embed_event_type == 0) + { + static const GTypeInfo our_info = + { + sizeof (EphyEmbedEventClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) ephy_embed_event_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (EphyEmbedEvent), + 0, /* n_preallocs */ + (GInstanceInitFunc) ephy_embed_event_init + }; + + ephy_embed_event_type = g_type_register_static (G_TYPE_OBJECT, + "EphyEmbedEvent", + &our_info, 0); + } + + return ephy_embed_event_type; } static void ephy_embed_event_class_init (EphyEmbedEventClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); + parent_class = g_type_class_peek_parent (klass); - object_class->finalize = ephy_embed_event_finalize; + object_class->finalize = ephy_embed_event_finalize; g_type_class_add_private (object_class, sizeof(EphyEmbedEventPrivate)); } @@ -89,7 +89,7 @@ free_g_value (gpointer value) static void ephy_embed_event_init (EphyEmbedEvent *event) { - event->priv = EPHY_EMBED_EVENT_GET_PRIVATE (event); + event->priv = EPHY_EMBED_EVENT_GET_PRIVATE (event); event->priv->props = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, free_g_value); @@ -98,22 +98,18 @@ ephy_embed_event_init (EphyEmbedEvent *event) static void ephy_embed_event_finalize (GObject *object) { - EphyEmbedEvent *event = EPHY_EMBED_EVENT (object); + EphyEmbedEvent *event = EPHY_EMBED_EVENT (object); g_hash_table_destroy (event->priv->props); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (parent_class)->finalize (object); } EphyEmbedEvent * ephy_embed_event_new (void) { - EphyEmbedEvent *event; - - event = EPHY_EMBED_EVENT (g_object_new (EPHY_TYPE_EMBED_EVENT, NULL)); - - return event; + return EPHY_EMBED_EVENT (g_object_new (EPHY_TYPE_EMBED_EVENT, NULL)); } guint @@ -122,29 +118,24 @@ ephy_embed_event_get_modifier (EphyEmbedEvent *event) return event->modifier; } -gresult -ephy_embed_event_get_event_type (EphyEmbedEvent *event, - EphyEmbedEventType *type) +EphyEmbedEventType +ephy_embed_event_get_event_type (EphyEmbedEvent *event) { - *type = event->type; - return G_OK; + return event->type; } -gresult +void ephy_embed_event_get_coords (EphyEmbedEvent *event, guint *x, guint *y) { *x = event->x; *y = event->y; - return G_OK; } -gresult -ephy_embed_event_get_context (EphyEmbedEvent *event, - EmbedEventContext *context) +EmbedEventContext +ephy_embed_event_get_context (EphyEmbedEvent *event) { - *context = event->context; - return G_OK; + return event->context; } void @@ -153,8 +144,8 @@ ephy_embed_event_set_property (EphyEmbedEvent *event, GValue *value) { g_hash_table_insert (event->priv->props, - g_strdup (name), - value); + g_strdup (name), + value); } void diff --git a/embed/ephy-embed-event.h b/embed/ephy-embed-event.h index 6b994d7f1..bf87560f5 100644 --- a/embed/ephy-embed-event.h +++ b/embed/ephy-embed-event.h @@ -19,8 +19,6 @@ #ifndef EPHY_EMBED_EVENT_H #define EPHY_EMBED_EVENT_H -#include "ephy-embed-types.h" - #include #include @@ -75,33 +73,30 @@ struct EphyEmbedEventClass GObjectClass parent_class; }; -GType ephy_embed_event_get_type (void); +GType ephy_embed_event_get_type (void); -EphyEmbedEvent *ephy_embed_event_new (void); +EphyEmbedEvent *ephy_embed_event_new (void); -guint ephy_embed_event_get_modifier (EphyEmbedEvent *event); +guint ephy_embed_event_get_modifier (EphyEmbedEvent *event); -gresult ephy_embed_event_get_event_type (EphyEmbedEvent *event, - EphyEmbedEventType *type); +EphyEmbedEventType ephy_embed_event_get_event_type (EphyEmbedEvent *event); -gresult ephy_embed_event_get_coords (EphyEmbedEvent *event, +void ephy_embed_event_get_coords (EphyEmbedEvent *event, guint *x, guint *y); -gresult ephy_embed_event_get_context (EphyEmbedEvent *event, - EmbedEventContext *context); +EmbedEventContext ephy_embed_event_get_context (EphyEmbedEvent *event); -void ephy_embed_event_set_property (EphyEmbedEvent *event, +void ephy_embed_event_set_property (EphyEmbedEvent *event, const char *name, GValue *value); -void ephy_embed_event_get_property (EphyEmbedEvent *event, +void ephy_embed_event_get_property (EphyEmbedEvent *event, const char *name, const GValue **value); -gboolean ephy_embed_event_has_property (EphyEmbedEvent *event, +gboolean ephy_embed_event_has_property (EphyEmbedEvent *event, const char *name); - G_END_DECLS #endif diff --git a/embed/ephy-embed-persist.c b/embed/ephy-embed-persist.c index 231bf3064..1ffa39cc6 100644 --- a/embed/ephy-embed-persist.c +++ b/embed/ephy-embed-persist.c @@ -431,14 +431,14 @@ ephy_embed_persist_class_init (EphyEmbedPersistClass *klass) g_type_class_add_private (object_class, sizeof(EphyEmbedPersistPrivate)); } -gresult +void ephy_embed_persist_cancel (EphyEmbedPersist *persist) { EphyEmbedPersistClass *klass = EPHY_EMBED_PERSIST_GET_CLASS (persist); - return klass->cancel (persist); + klass->cancel (persist); } -gresult +gboolean ephy_embed_persist_save (EphyEmbedPersist *persist) { EphyEmbedPersistClass *klass = EPHY_EMBED_PERSIST_GET_CLASS (persist); diff --git a/embed/ephy-embed-persist.h b/embed/ephy-embed-persist.h index ca53ff7a2..8e5980128 100644 --- a/embed/ephy-embed-persist.h +++ b/embed/ephy-embed-persist.h @@ -60,22 +60,22 @@ struct EphyEmbedPersistClass { GObjectClass parent_class; - void (* completed) (EphyEmbedPersist *persist); + void (* completed) (EphyEmbedPersist *persist); /* Methods */ - gresult (* save) (EphyEmbedPersist *persist); + gboolean (* save) (EphyEmbedPersist *persist); - gresult (* cancel) (EphyEmbedPersist *persist); + void (* cancel) (EphyEmbedPersist *persist); }; GType ephy_embed_persist_get_type (void); EphyEmbedPersist *ephy_embed_persist_new (EphyEmbed *embed); -gresult ephy_embed_persist_save (EphyEmbedPersist *persist); +gboolean ephy_embed_persist_save (EphyEmbedPersist *persist); -gresult ephy_embed_persist_cancel (EphyEmbedPersist *persist); +void ephy_embed_persist_cancel (EphyEmbedPersist *persist); void ephy_embed_persist_set_dest (EphyEmbedPersist *persist, const char *value); diff --git a/embed/ephy-embed-popup-control.c b/embed/ephy-embed-popup-control.c index 9c816840f..be4a43fb4 100644 --- a/embed/ephy-embed-popup-control.c +++ b/embed/ephy-embed-popup-control.c @@ -391,7 +391,7 @@ ephy_embed_popup_control_set_event (EphyEmbedPopupControl *p, g_object_unref (G_OBJECT (p->priv->event)); } - ephy_embed_event_get_context (event, &context); + context = ephy_embed_event_get_context (event); p->priv->context = context; @@ -442,7 +442,7 @@ embed_popup_copy_location_cmd (BonoboUIComponent *uic, const char* verbname) { char *location; - ephy_embed_get_location (popup->priv->embed, FALSE, &location); + location = ephy_embed_get_location (popup->priv->embed, FALSE); embed_popup_copy_to_clipboard (popup, location); g_free (location); } @@ -635,8 +635,7 @@ embed_popup_save_page_as_cmd (BonoboUIComponent *uic, { char *location; - ephy_embed_get_location (popup->priv->embed, - FALSE, &location); + location = ephy_embed_get_location (popup->priv->embed, FALSE); save_url (popup, _("Save Page As"), TRUE, location); g_free (location); } @@ -657,8 +656,7 @@ embed_popup_open_frame_cmd (BonoboUIComponent *uic, { char *location; - ephy_embed_get_location (popup->priv->embed, - FALSE, &location); + location = ephy_embed_get_location (popup->priv->embed, FALSE); ephy_embed_load_url (popup->priv->embed, location); diff --git a/embed/ephy-embed-single.c b/embed/ephy-embed-single.c index 7c82b6000..c09a0defa 100644 --- a/embed/ephy-embed-single.c +++ b/embed/ephy-embed-single.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000, 2001, 2002, 2003 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 @@ -60,27 +60,27 @@ ephy_embed_single_get_type (void) { static GType ephy_embed_single_type = 0; - if (ephy_embed_single_type == 0) - { - static const GTypeInfo our_info = - { - sizeof (EphyEmbedSingleClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) ephy_embed_single_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EphyEmbedSingle), - 0, /* n_preallocs */ - (GInstanceInitFunc) ephy_embed_single_init - }; - - ephy_embed_single_type = g_type_register_static (G_TYPE_OBJECT, + if (ephy_embed_single_type == 0) + { + static const GTypeInfo our_info = + { + sizeof (EphyEmbedSingleClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) ephy_embed_single_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (EphyEmbedSingle), + 0, /* n_preallocs */ + (GInstanceInitFunc) ephy_embed_single_init + }; + + ephy_embed_single_type = g_type_register_static (G_TYPE_OBJECT, "EphyEmbedSingle", &our_info, 0); - } + } - return ephy_embed_single_type; + return ephy_embed_single_type; } static void @@ -91,15 +91,15 @@ ephy_embed_single_class_init (EphyEmbedSingleClass *klass) parent_class = (GObjectClass *) g_type_class_peek_parent (klass); ephy_embed_single_signals[NEW_WINDOW] = - g_signal_new ("new_window_orphan", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EphyEmbedSingleClass, new_window), - NULL, NULL, - ephy_marshal_VOID__POINTER_INT, - G_TYPE_NONE, - 2, - G_TYPE_POINTER, + g_signal_new ("new_window_orphan", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EphyEmbedSingleClass, new_window), + NULL, NULL, + ephy_marshal_VOID__POINTER_INT, + G_TYPE_NONE, + 2, + G_TYPE_POINTER, G_TYPE_INT); g_type_class_add_private (object_class, sizeof(EphyEmbedSinglePrivate)); @@ -116,75 +116,72 @@ ephy_embed_single_init (EphyEmbedSingle *ges) ges->priv->favicon_cache = NULL; } -gresult +void ephy_embed_single_clear_cache (EphyEmbedSingle *shell) { EphyEmbedSingleClass *klass = EPHY_EMBED_SINGLE_GET_CLASS (shell); - return klass->clear_cache (shell); + klass->clear_cache (shell); } -gresult +void ephy_embed_single_set_offline_mode (EphyEmbedSingle *shell, gboolean offline) { EphyEmbedSingleClass *klass = EPHY_EMBED_SINGLE_GET_CLASS (shell); - return klass->set_offline_mode (shell, offline); + klass->set_offline_mode (shell, offline); } -gresult +void ephy_embed_single_load_proxy_autoconf (EphyEmbedSingle *shell, const char* url) { EphyEmbedSingleClass *klass = EPHY_EMBED_SINGLE_GET_CLASS (shell); - return klass->load_proxy_autoconf (shell, url); + klass->load_proxy_autoconf (shell, url); } -gresult +GList * ephy_embed_single_get_font_list (EphyEmbedSingle *shell, - const char *langGroup, - GList **fontList) + const char *langGroup) { EphyEmbedSingleClass *klass = EPHY_EMBED_SINGLE_GET_CLASS (shell); - return klass->get_font_list (shell, langGroup, fontList); + return klass->get_font_list (shell, langGroup); } -gresult -ephy_embed_single_list_cookies (EphyEmbedSingle *shell, - GList **cookies) +GList * +ephy_embed_single_list_cookies (EphyEmbedSingle *shell) { EphyEmbedSingleClass *klass = EPHY_EMBED_SINGLE_GET_CLASS (shell); - return klass->list_cookies (shell, cookies); + return klass->list_cookies (shell); } -gresult +void ephy_embed_single_remove_cookies (EphyEmbedSingle *shell, GList *cookies) { EphyEmbedSingleClass *klass = EPHY_EMBED_SINGLE_GET_CLASS (shell); - return klass->remove_cookies (shell, cookies); + klass->remove_cookies (shell, cookies); } -gresult +GList * ephy_embed_single_list_passwords (EphyEmbedSingle *shell, - PasswordType type, - GList **passwords) + PasswordType type) { EphyEmbedSingleClass *klass = EPHY_EMBED_SINGLE_GET_CLASS (shell); - return klass->list_passwords (shell, type, passwords); + return klass->list_passwords (shell, type); } -gresult +void ephy_embed_single_remove_passwords (EphyEmbedSingle *shell, - GList *passwords, - PasswordType type) + GList *passwords, + PasswordType type) { EphyEmbedSingleClass *klass = EPHY_EMBED_SINGLE_GET_CLASS (shell); - return klass->remove_passwords (shell, passwords, type); + klass->remove_passwords (shell, passwords, type); } -gresult +void ephy_embed_single_free_cookies (EphyEmbedSingle *shell, - GList *cookies) + GList *cookies) { GList *l; @@ -202,13 +199,11 @@ ephy_embed_single_free_cookies (EphyEmbedSingle *shell, } g_list_free (cookies); - - return G_OK; } -gresult +void ephy_embed_single_free_passwords (EphyEmbedSingle *shell, - GList *passwords) + GList *passwords) { GList *l; @@ -221,6 +216,4 @@ ephy_embed_single_free_passwords (EphyEmbedSingle *shell, } g_list_free (passwords); - - return G_OK; } diff --git a/embed/ephy-embed-single.h b/embed/ephy-embed-single.h index e45b99cad..598ccdfd3 100644 --- a/embed/ephy-embed-single.h +++ b/embed/ephy-embed-single.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 @@ -47,17 +47,17 @@ typedef struct EphyEmbedSinglePrivate EphyEmbedSinglePrivate; typedef enum { - modeOpen = 0, - modeSave = 1, - modeGetFolder =2 + modeOpen = 0, + modeSave = 1, + modeGetFolder =2 } FilePickerMode; typedef struct { - /* description of the file format */ - gchar *description; - /* tipical sufixes, NULL terminated */ - gchar **extensions; + /* description of the file format */ + gchar *description; + /* tipical sufixes, NULL terminated */ + gchar **extensions; } FileFormat; /** @@ -66,11 +66,11 @@ typedef struct typedef struct { gchar *domain; - gchar *name; - gchar *value; - gchar *path; - gchar *secure; - gchar *expire; + gchar *name; + gchar *value; + gchar *path; + gchar *secure; + gchar *expire; } CookieInfo; /** @@ -78,8 +78,8 @@ typedef struct */ typedef struct { - gchar *host; - gchar *username; + gchar *host; + gchar *username; } PasswordInfo; /** @@ -87,8 +87,8 @@ typedef struct */ typedef enum { - PASSWORD_PASSWORD, - PASSWORD_REJECT + PASSWORD_PASSWORD, + PASSWORD_REJECT } PasswordType; typedef enum @@ -100,77 +100,71 @@ typedef enum struct EphyEmbedSingle { GObject parent; - EphyEmbedSinglePrivate *priv; + EphyEmbedSinglePrivate *priv; }; struct EphyEmbedSingleClass { - GObjectClass parent_class; + GObjectClass parent_class; /* Signals */ void (* new_window) (EphyEmbedSingle *shell, - EphyEmbed **new_embed, + EphyEmbed **new_embed, EmbedChromeMask chromemask); /* Methods */ - gresult (* clear_cache) (EphyEmbedSingle *shell); - gresult (* set_offline_mode) (EphyEmbedSingle *shell, - gboolean offline); - gresult (* load_proxy_autoconf) (EphyEmbedSingle *shell, - const char* url); - gresult (* show_java_console) (EphyEmbedSingle *shell); - gresult (* show_js_console) (EphyEmbedSingle *shell); - gresult (* get_font_list) (EphyEmbedSingle *shell, - const char *langGroup, - GList **fontList); - gresult (* list_cookies) (EphyEmbedSingle *shell, - GList **cokies); - gresult (* remove_cookies) (EphyEmbedSingle *shell, - GList *cookies); - gresult (* list_passwords) (EphyEmbedSingle *shell, - PasswordType type, - GList **passwords); - gresult (* remove_passwords) (EphyEmbedSingle *shell, - GList *passwords, - PasswordType type); + void (* clear_cache) (EphyEmbedSingle *shell); + void (* set_offline_mode) (EphyEmbedSingle *shell, + gboolean offline); + void (* load_proxy_autoconf) (EphyEmbedSingle *shell, + const char* url); + void (* show_java_console) (EphyEmbedSingle *shell); + void (* show_js_console) (EphyEmbedSingle *shell); + GList * (* get_font_list) (EphyEmbedSingle *shell, + const char *langGroup); + GList * (* list_cookies) (EphyEmbedSingle *shell); + void (* remove_cookies) (EphyEmbedSingle *shell, + GList *cookies); + GList * (* list_passwords) (EphyEmbedSingle *shell, + PasswordType type); + void (* remove_passwords) (EphyEmbedSingle *shell, + GList *passwords, + PasswordType type); }; -GType ephy_embed_single_get_type (void); +GType ephy_embed_single_get_type (void); -gresult ephy_embed_single_clear_cache (EphyEmbedSingle *shell); +void ephy_embed_single_clear_cache (EphyEmbedSingle *shell); -gresult ephy_embed_single_set_offline_mode (EphyEmbedSingle *shell, - gboolean offline); +void ephy_embed_single_set_offline_mode (EphyEmbedSingle *shell, + gboolean offline); -gresult ephy_embed_single_load_proxy_autoconf (EphyEmbedSingle *shell, - const char* url); +void ephy_embed_single_load_proxy_autoconf (EphyEmbedSingle *shell, + const char* url); -gresult ephy_embed_single_get_font_list (EphyEmbedSingle *shell, - const char *langGroup, - GList **fontList); +GList *ephy_embed_single_get_font_list (EphyEmbedSingle *shell, + const char *langGroup); /* Cookies */ -gresult ephy_embed_single_list_cookies (EphyEmbedSingle *shell, - GList **cookies); +GList *ephy_embed_single_list_cookies (EphyEmbedSingle *shell); -gresult ephy_embed_single_remove_cookies (EphyEmbedSingle *shell, - GList *cookies); +void ephy_embed_single_remove_cookies (EphyEmbedSingle *shell, + GList *cookies); -gresult ephy_embed_single_free_cookies (EphyEmbedSingle *shell, - GList *cookies); +void ephy_embed_single_free_cookies (EphyEmbedSingle *shell, + GList *cookies); /* Passwords */ -gresult ephy_embed_single_list_passwords (EphyEmbedSingle *shell, - PasswordType type, - GList **passwords); +GList *ephy_embed_single_list_passwords (EphyEmbedSingle *shell, + PasswordType type); -gresult ephy_embed_single_free_passwords (EphyEmbedSingle *shell, - GList *passwords); +void ephy_embed_single_free_passwords (EphyEmbedSingle *shell, + GList *passwords); -gresult ephy_embed_single_remove_passwords (EphyEmbedSingle *shell, - GList *passwords, - PasswordType type); +void ephy_embed_single_remove_passwords (EphyEmbedSingle *shell, + GList *passwords, + PasswordType type); G_END_DECLS diff --git a/embed/ephy-embed-types.h b/embed/ephy-embed-types.h deleted file mode 100644 index baae4e6f9..000000000 --- a/embed/ephy-embed-types.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2000, 2001, 2002 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 - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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. - */ - -#ifndef EPHY_EMBED_TYPES_H -#define EPHY_EMBED_TYPES_H - -#include "ephy-types.h" - -G_BEGIN_DECLS - -typedef enum -{ - EMBED_CHROME_NONE = 0, - EMBED_CHROME_DEFAULT = 1 << 0, - EMBED_CHROME_MENUBARON = 1 << 1, - EMBED_CHROME_TOOLBARON = 1 << 2, - EMBED_CHROME_BOOKMARKSBARON = 1 << 3, - EMBED_CHROME_BOOKMARKSBAR_DEFAULT = 1 << 4, - EMBED_CHROME_STATUSBARON = 1 << 5, - EMBED_CHROME_WINDOWRAISED = 1 << 6, - EMBED_CHROME_WINDOWLOWERED = 1 << 7, - EMBED_CHROME_CENTERSCREEN = 1 << 8, - EMBED_CHROME_OPENASDIALOG = 1 << 9, - EMBED_CHROME_OPENASCHROME = 1 << 10, - EMBED_CHROME_OPENASPOPUP = 1 << 11, - EMBED_CHROME_PPVIEWTOOLBARON = 1 << 12 -} EmbedChromeMask; - -G_END_DECLS - -#endif diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c index a988f9732..516d6c6d6 100644 --- a/embed/ephy-embed.c +++ b/embed/ephy-embed.c @@ -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 @@ -19,13 +19,13 @@ */ #ifdef HAVE_CONFIG_H -#include +#include "config.h" #endif -#include "ephy-marshal.h" #include "ephy-embed.h" -#include "mozilla-embed-single.h" +#include "ephy-marshal.h" +#include "mozilla-embed-single.h" #include "mozilla-embed.h" enum @@ -50,37 +50,31 @@ enum LAST_SIGNAL }; -static void -ephy_embed_base_init (gpointer base_class); - -struct EphyEmbedPrivate -{ - gpointer dummy; -}; - static guint ephy_embed_signals[LAST_SIGNAL] = { 0 }; +static void ephy_embed_base_init (gpointer base_class); + GType ephy_embed_get_type (void) { - static GType ephy_embed_type = 0; + static GType ephy_embed_type = 0; - if (ephy_embed_type == 0) - { - static const GTypeInfo our_info = - { - sizeof (EphyEmbedClass), - ephy_embed_base_init, - NULL, - }; - - ephy_embed_type = g_type_register_static (G_TYPE_INTERFACE, + if (ephy_embed_type == 0) + { + static const GTypeInfo our_info = + { + sizeof (EphyEmbedClass), + ephy_embed_base_init, + NULL, + }; + + ephy_embed_type = g_type_register_static (G_TYPE_INTERFACE, "EphyEmbed", &our_info, (GTypeFlags)0); - } + } - return ephy_embed_type; + return ephy_embed_type; } static void @@ -91,177 +85,177 @@ ephy_embed_base_init (gpointer g_class) if (!initialized) { ephy_embed_signals[NEW_WINDOW] = - g_signal_new ("ge_new_window", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyEmbedClass, new_window), - NULL, NULL, - ephy_marshal_VOID__POINTER_INT, + g_signal_new ("ge_new_window", + EPHY_TYPE_EMBED, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EphyEmbedClass, new_window), + NULL, NULL, + ephy_marshal_VOID__POINTER_INT, G_TYPE_NONE, - 2, - G_TYPE_POINTER, + 2, + G_TYPE_POINTER, G_TYPE_INT); ephy_embed_signals[LINK_MESSAGE] = - g_signal_new ("ge_link_message", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyEmbedClass, link_message), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, - 1, + g_signal_new ("ge_link_message", + EPHY_TYPE_EMBED, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EphyEmbedClass, link_message), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, + 1, G_TYPE_STRING); ephy_embed_signals[CONTEXT_MENU] = - g_signal_new ("ge_context_menu", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EphyEmbedClass, context_menu), - g_signal_accumulator_true_handled, NULL, - ephy_marshal_BOOLEAN__OBJECT, - G_TYPE_BOOLEAN, - 1, + g_signal_new ("ge_context_menu", + EPHY_TYPE_EMBED, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EphyEmbedClass, context_menu), + g_signal_accumulator_true_handled, NULL, + ephy_marshal_BOOLEAN__OBJECT, + G_TYPE_BOOLEAN, + 1, G_TYPE_OBJECT); ephy_embed_signals[FAVICON] = - g_signal_new ("ge_favicon", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyEmbedClass, favicon), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, - 1, + g_signal_new ("ge_favicon", + EPHY_TYPE_EMBED, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EphyEmbedClass, favicon), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, + 1, G_TYPE_STRING); ephy_embed_signals[JS_STATUS] = - g_signal_new ("ge_js_status", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyEmbedClass, js_status), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, + g_signal_new ("ge_js_status", + EPHY_TYPE_EMBED, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EphyEmbedClass, js_status), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, - 1, + 1, G_TYPE_STRING); ephy_embed_signals[LOCATION] = - g_signal_new ("ge_location", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyEmbedClass, location), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, - 1, + g_signal_new ("ge_location", + EPHY_TYPE_EMBED, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EphyEmbedClass, location), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, + 1, G_TYPE_STRING); ephy_embed_signals[TITLE] = - g_signal_new ("ge_title", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyEmbedClass, title), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); + g_signal_new ("ge_title", + EPHY_TYPE_EMBED, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EphyEmbedClass, title), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); ephy_embed_signals[PROGRESS] = - g_signal_new ("ge_progress", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyEmbedClass, progress), - NULL, NULL, - ephy_marshal_VOID__STRING_INT_INT, - G_TYPE_NONE, - 3, + g_signal_new ("ge_progress", + EPHY_TYPE_EMBED, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EphyEmbedClass, progress), + NULL, NULL, + ephy_marshal_VOID__STRING_INT_INT, + G_TYPE_NONE, + 3, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT); ephy_embed_signals[NET_STATE] = - g_signal_new ("ge_net_state", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyEmbedClass, net_state), - NULL, NULL, - ephy_marshal_VOID__STRING_INT, - G_TYPE_NONE, - 2, + g_signal_new ("ge_net_state", + EPHY_TYPE_EMBED, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EphyEmbedClass, net_state), + NULL, NULL, + ephy_marshal_VOID__STRING_INT, + G_TYPE_NONE, + 2, G_TYPE_STRING, G_TYPE_INT); ephy_embed_signals[VISIBILITY] = - g_signal_new ("ge_visibility", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyEmbedClass, visibility), - NULL, NULL, - g_cclosure_marshal_VOID__BOOLEAN, - G_TYPE_NONE, - 1, + g_signal_new ("ge_visibility", + EPHY_TYPE_EMBED, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EphyEmbedClass, visibility), + NULL, NULL, + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, + 1, G_TYPE_BOOLEAN); ephy_embed_signals[DESTROY_BRSR] = - g_signal_new ("ge_destroy_brsr", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyEmbedClass, destroy_brsr), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); + g_signal_new ("ge_destroy_brsr", + EPHY_TYPE_EMBED, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EphyEmbedClass, destroy_brsr), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); ephy_embed_signals[OPEN_URI] = - g_signal_new ("ge_open_uri", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EphyEmbedClass, open_uri), - NULL, NULL, - ephy_marshal_INT__STRING, - G_TYPE_INT, - 1, + g_signal_new ("ge_open_uri", + EPHY_TYPE_EMBED, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EphyEmbedClass, open_uri), + NULL, NULL, + ephy_marshal_INT__STRING, + G_TYPE_INT, + 1, G_TYPE_STRING); ephy_embed_signals[SIZE_TO] = - g_signal_new ("ge_size_to", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EphyEmbedClass, size_to), - NULL, NULL, - ephy_marshal_VOID__INT_INT, - G_TYPE_NONE, - 2, + g_signal_new ("ge_size_to", + EPHY_TYPE_EMBED, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EphyEmbedClass, size_to), + NULL, NULL, + ephy_marshal_VOID__INT_INT, + G_TYPE_NONE, + 2, G_TYPE_INT, G_TYPE_INT); ephy_embed_signals[DOM_MOUSE_CLICK] = - g_signal_new ("ge_dom_mouse_click", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EphyEmbedClass, dom_mouse_click), - g_signal_accumulator_true_handled, NULL, - ephy_marshal_BOOLEAN__OBJECT, - G_TYPE_BOOLEAN, - 1, + g_signal_new ("ge_dom_mouse_click", + EPHY_TYPE_EMBED, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EphyEmbedClass, dom_mouse_click), + g_signal_accumulator_true_handled, NULL, + ephy_marshal_BOOLEAN__OBJECT, + G_TYPE_BOOLEAN, + 1, G_TYPE_POINTER); ephy_embed_signals[DOM_MOUSE_DOWN] = - g_signal_new ("ge_dom_mouse_down", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EphyEmbedClass, dom_mouse_down), - g_signal_accumulator_true_handled, NULL, - ephy_marshal_BOOLEAN__OBJECT, - G_TYPE_BOOLEAN, - 1, + g_signal_new ("ge_dom_mouse_down", + EPHY_TYPE_EMBED, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EphyEmbedClass, dom_mouse_down), + g_signal_accumulator_true_handled, NULL, + ephy_marshal_BOOLEAN__OBJECT, + G_TYPE_BOOLEAN, + 1, G_TYPE_POINTER); ephy_embed_signals[SECURITY_CHANGE] = - g_signal_new ("ge_security_change", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EphyEmbedClass, security_change), - NULL, NULL, - g_cclosure_marshal_VOID__INT, - G_TYPE_NONE, - 1, + g_signal_new ("ge_security_change", + EPHY_TYPE_EMBED, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EphyEmbedClass, security_change), + NULL, NULL, + g_cclosure_marshal_VOID__INT, + G_TYPE_NONE, + 1, G_TYPE_INT); ephy_embed_signals[ZOOM_CHANGE] = - g_signal_new ("ge_zoom_change", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EphyEmbedClass, zoom_change), - NULL, NULL, - g_cclosure_marshal_VOID__FLOAT, - G_TYPE_NONE, - 1, + g_signal_new ("ge_zoom_change", + EPHY_TYPE_EMBED, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EphyEmbedClass, zoom_change), + NULL, NULL, + g_cclosure_marshal_VOID__FLOAT, + G_TYPE_NONE, + 1, G_TYPE_FLOAT); initialized = TRUE; } @@ -270,280 +264,224 @@ ephy_embed_base_init (gpointer g_class) EphyEmbed * ephy_embed_new (GObject *single) { - if (MOZILLA_IS_EMBED_SINGLE (single)) - { - return EPHY_EMBED (g_object_new - (MOZILLA_TYPE_EMBED, NULL)); - } - - g_assert_not_reached (); + g_assert (MOZILLA_IS_EMBED_SINGLE (single)); - return NULL; + return EPHY_EMBED (g_object_new (MOZILLA_TYPE_EMBED, NULL)); } void -ephy_embed_get_capabilities (EphyEmbed *embed, - EmbedCapabilities *caps) -{ - EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - klass->get_capabilities (embed, caps); -} - -gresult ephy_embed_load_url (EphyEmbed *embed, - const char *url) + const char *url) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->load_url (embed, url); + klass->load_url (embed, url); } -gresult +void ephy_embed_stop_load (EphyEmbed *embed) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->stop_load (embed); + klass->stop_load (embed); } -gresult +gboolean ephy_embed_can_go_back (EphyEmbed *embed) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->can_go_back (embed); + return klass->can_go_back (embed); } -gresult +gboolean ephy_embed_can_go_forward (EphyEmbed *embed) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->can_go_forward (embed); + return klass->can_go_forward (embed); } -gresult +gboolean ephy_embed_can_go_up (EphyEmbed *embed) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->can_go_up (embed); + return klass->can_go_up (embed); } -gresult -ephy_embed_get_go_up_list (EphyEmbed *embed, GSList **l) +GSList * +ephy_embed_get_go_up_list (EphyEmbed *embed) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->get_go_up_list (embed, l); + return klass->get_go_up_list (embed); } -gresult +void ephy_embed_go_back (EphyEmbed *embed) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->go_back (embed); + klass->go_back (embed); } -gresult +void ephy_embed_go_forward (EphyEmbed *embed) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->go_forward (embed); + klass->go_forward (embed); } -gresult +void ephy_embed_go_up (EphyEmbed *embed) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->go_up (embed); -} - -gresult -ephy_embed_render_data (EphyEmbed *embed, - const char *data, - guint32 len, - const char *base_uri, - const char *mime_type) -{ - EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->render_data (embed, data, len, base_uri, mime_type); + klass->go_up (embed); } -gresult -ephy_embed_open_stream (EphyEmbed *embed, - const char *base_uri, - const char *mime_type) -{ - EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->open_stream (embed, base_uri, mime_type); -} - -gresult -ephy_embed_append_data (EphyEmbed *embed, - const char *data, - guint32 len) -{ - EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->append_data (embed, data, len); -} -gresult -ephy_embed_close_stream (EphyEmbed *embed) +char * +ephy_embed_get_title (EphyEmbed *embed) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->close_stream (embed); + return klass->get_title (embed); } -gresult -ephy_embed_get_title (EphyEmbed *embed, - char **title) -{ - EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->get_title (embed, title); -} - -gresult +char * ephy_embed_get_location (EphyEmbed *embed, - gboolean toplevel, - char **location) + gboolean toplevel) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->get_location (embed, toplevel, location); + return klass->get_location (embed, toplevel); } -gresult +void ephy_embed_reload (EphyEmbed *embed, - EmbedReloadFlags flags) + EmbedReloadFlags flags) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->reload (embed, flags); + klass->reload (embed, flags); } -gresult +void ephy_embed_zoom_set (EphyEmbed *embed, - float zoom, - gboolean reflow) + float zoom, + gboolean reflow) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->zoom_set (embed, zoom, reflow); + klass->zoom_set (embed, zoom, reflow); } -gresult -ephy_embed_zoom_get (EphyEmbed *embed, - float *zoom) +float +ephy_embed_zoom_get (EphyEmbed *embed) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->zoom_get (embed, zoom); + return klass->zoom_get (embed); } -gresult -ephy_embed_shistory_count (EphyEmbed *embed, - int *count) +int +ephy_embed_shistory_n_items (EphyEmbed *embed) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->shistory_count (embed, count); + return klass->shistory_n_items (embed); } -gresult +void ephy_embed_shistory_get_nth (EphyEmbed *embed, - int nth, - gboolean is_relative, - char **url, - char **title) + int nth, + gboolean is_relative, + char **url, + char **title) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->shistory_get_nth (embed, nth, is_relative, url, title); + klass->shistory_get_nth (embed, nth, is_relative, url, title); } -gresult -ephy_embed_shistory_get_pos (EphyEmbed *embed, - int *pos) +int +ephy_embed_shistory_get_pos (EphyEmbed *embed) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->shistory_get_pos (embed, pos); + return klass->shistory_get_pos (embed); } -gresult +void ephy_embed_shistory_go_nth (EphyEmbed *embed, - int nth) + int nth) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->shistory_go_nth (embed, nth); + klass->shistory_go_nth (embed, nth); } -gresult +void ephy_embed_get_security_level (EphyEmbed *embed, - EmbedSecurityLevel *level, - char **description) + EmbedSecurityLevel *level, + char **description) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->get_security_level (embed, level, description); + klass->get_security_level (embed, level, description); } -gresult +void ephy_embed_find_set_properties (EphyEmbed *embed, char *search_string, gboolean case_sensitive, gboolean match_word) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->find_set_properties (embed, search_string, case_sensitive, match_word); + klass->find_set_properties (embed, search_string, case_sensitive, match_word); } -gresult +gboolean ephy_embed_find_next (EphyEmbed *embed, gboolean backwards) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->find_next (embed, backwards); + return klass->find_next (embed, backwards); } -gresult +void ephy_embed_activate (EphyEmbed *embed) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->activate (embed); + klass->activate (embed); } -gresult +void ephy_embed_set_encoding (EphyEmbed *embed, const char *encoding) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->set_encoding (embed, encoding); + klass->set_encoding (embed, encoding); } -gresult -ephy_embed_get_encoding_info (EphyEmbed *embed, - EphyEncodingInfo **info) +EphyEncodingInfo * +ephy_embed_get_encoding_info (EphyEmbed *embed) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->get_encoding_info (embed, info); + return klass->get_encoding_info (embed); } -gresult +void ephy_embed_print (EphyEmbed *embed, - EmbedPrintInfo *info) + EmbedPrintInfo *info) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->print (embed, info); + klass->print (embed, info); } -gresult +void ephy_embed_print_preview_close (EphyEmbed *embed) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->print_preview_close (embed); + klass->print_preview_close (embed); } -gresult -ephy_embed_print_preview_num_pages (EphyEmbed *embed, gint *retNum) +int +ephy_embed_print_preview_n_pages (EphyEmbed *embed) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->print_preview_num_pages (embed, retNum); + return klass->print_preview_n_pages (embed); } -gresult +void ephy_embed_print_preview_navigate (EphyEmbed *embed, - EmbedPrintPreviewNavType navType, - gint pageNum) + EmbedPrintPreviewNavType type, + int page) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->print_preview_navigate (embed, navType, pageNum); + return klass->print_preview_navigate (embed, type, page); } - diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h index b25f02dea..0ee52025c 100644 --- a/embed/ephy-embed.h +++ b/embed/ephy-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 EPHY_EMBED_H #define EPHY_EMBED_H -#include "ephy-embed-types.h" #include "ephy-embed-event.h" #include "ephy-encodings.h" @@ -56,17 +57,21 @@ typedef enum typedef enum { - EMBED_CLIPBOARD_CAP = 1 << 0, - EMBED_COOKIES_CAP = 1 << 1, - EMBED_LINKS_CAP = 1 << 2, - EMBED_ZOOM_CAP = 1 << 3, - EMBED_PRINT_CAP = 1 << 6, - EMBED_FIND_CAP = 1 << 7, - EMBED_SCROLL_CAP = 1 << 8, - EMBED_SECURITY_CAP = 1 << 9, - EMBED_ENCODING_CAP = 1 << 10, - EMBED_SHISTORY_CAP = 1 << 11 -} EmbedCapabilities; + EMBED_CHROME_NONE = 0, + EMBED_CHROME_DEFAULT = 1 << 0, + EMBED_CHROME_MENUBARON = 1 << 1, + EMBED_CHROME_TOOLBARON = 1 << 2, + EMBED_CHROME_BOOKMARKSBARON = 1 << 3, + EMBED_CHROME_BOOKMARKSBAR_DEFAULT = 1 << 4, + EMBED_CHROME_STATUSBARON = 1 << 5, + EMBED_CHROME_WINDOWRAISED = 1 << 6, + EMBED_CHROME_WINDOWLOWERED = 1 << 7, + EMBED_CHROME_CENTERSCREEN = 1 << 8, + EMBED_CHROME_OPENASDIALOG = 1 << 9, + EMBED_CHROME_OPENASCHROME = 1 << 10, + EMBED_CHROME_OPENASPOPUP = 1 << 11, + EMBED_CHROME_PPVIEWTOOLBARON = 1 << 12 +} EmbedChromeMask; typedef struct { @@ -88,37 +93,37 @@ typedef enum typedef struct { - gboolean print_to_file; - gchar *printer; - gchar *file; - gchar *paper; - gint top_margin; - gint bottom_margin; - gint left_margin; - gint right_margin; - gint pages; - gint from_page; - gint to_page; - gint frame_type; - gint orientation; - gboolean print_color; - - /* - * &T - title - * &U - Document URL - * &D - Date/Time - * &P - Page Number - * &PT - Page Number with total Number of Pages (example: 1 of 34) - * - * So, if headerLeftStr = "&T" the title and the document URL - * will be printed out on the top left-hand side of each page. - */ - gchar *header_left_string; - gchar *header_center_string; - gchar *header_right_string; - gchar *footer_left_string; - gchar *footer_center_string; - gchar *footer_right_string; + gboolean print_to_file; + gchar *printer; + gchar *file; + gchar *paper; + gint top_margin; + gint bottom_margin; + gint left_margin; + gint right_margin; + gint pages; + gint from_page; + gint to_page; + gint frame_type; + gint orientation; + gboolean print_color; + + /* + * &T - title + * &U - Document URL + * &D - Date/Time + * &P - Page Number + * &PT - Page Number with total Number of Pages (example: 1 of 34) + * + * So, if headerLeftStr = "&T" the title and the document URL + * will be printed out on the top left-hand side of each page. + */ + gchar *header_left_string; + gchar *header_center_string; + gchar *header_right_string; + gchar *footer_left_string; + gchar *footer_center_string; + gchar *footer_right_string; gboolean preview; } @@ -145,7 +150,7 @@ typedef enum struct EphyEmbedClass { - GTypeInterface base_iface; + GTypeInterface base_iface; gint (* context_menu) (EphyEmbed *embed, EphyEmbedEvent *event); @@ -160,217 +165,169 @@ struct EphyEmbedClass void (* title) (EphyEmbed *embed); void (* progress) (EphyEmbed *embed, const char *uri, - gint curprogress, + gint curprogress, gint maxprogress); void (* net_state) (EphyEmbed *embed, const char *uri, - EmbedState state); + EmbedState state); void (* new_window) (EphyEmbed *embed, - EphyEmbed **new_embed, - EmbedChromeMask chromemask); + EphyEmbed **new_embed, + EmbedChromeMask chromemask); void (* visibility) (EphyEmbed *embed, - gboolean visibility); + gboolean visibility); void (* destroy_brsr) (EphyEmbed *embed); gint (* open_uri) (EphyEmbed *embed, - const char *uri); + const char *uri); void (* size_to) (EphyEmbed *embed, - gint width, - gint height); + gint width, + gint height); gint (* dom_mouse_click) (EphyEmbed *embed, - EphyEmbedEvent *event); + EphyEmbedEvent *event); gint (* dom_mouse_down) (EphyEmbed *embed, - EphyEmbedEvent *event); + EphyEmbedEvent *event); void (* security_change) (EphyEmbed *embed, - EmbedSecurityLevel level); + EmbedSecurityLevel level); void (* zoom_change) (EphyEmbed *embed, - guint new_zoom); + guint new_zoom); /* Methods */ - void (* get_capabilities) (EphyEmbed *embed, - EmbedCapabilities *caps); - gresult (* load_url) (EphyEmbed *embed, - const char *url); - gresult (* stop_load) (EphyEmbed *embed); - gresult (* can_go_back) (EphyEmbed *embed); - gresult (* can_go_forward) (EphyEmbed *embed); - gresult (* can_go_up) (EphyEmbed *embed); - gresult (* get_go_up_list) (EphyEmbed *embed, GSList **l); - gresult (* go_back) (EphyEmbed *embed); - gresult (* go_forward) (EphyEmbed *embed); - gresult (* go_up) (EphyEmbed *embed); - gresult (* render_data) (EphyEmbed *embed, - const char *data, - guint32 len, - const char *base_uri, - const char *mime_type); - gresult (* open_stream) (EphyEmbed *embed, - const char *base_uri, - const char *mime_type); - gresult (* append_data) (EphyEmbed *embed, - const char *data, - guint32 len); - gresult (* close_stream) (EphyEmbed *embed); - gresult (* get_title) (EphyEmbed *embed, - char **title); - gresult (* get_location) (EphyEmbed *embed, - gboolean toplevel, - char **location); - gresult (* reload) (EphyEmbed *embed, - EmbedReloadFlags flags); - gresult (* zoom_set) (EphyEmbed *embed, - float zoom, - gboolean reflow); - gresult (* zoom_get) (EphyEmbed *embed, - float *zoom); - gresult (* shistory_count) (EphyEmbed *embed, - int *count); - gresult (* shistory_get_nth) (EphyEmbed *embed, - int nth, - gboolean is_relative, - char **url, - char **title); - gresult (* shistory_get_pos) (EphyEmbed *embed, - int *pos); - gresult (* shistory_go_nth) (EphyEmbed *embed, - int nth); - gresult (* get_security_level) (EphyEmbed *embed, - EmbedSecurityLevel *level, - char **description); - gresult (* find_set_properties) (EphyEmbed *embed, - char *search_string, - gboolean case_sensitive, - gboolean wrap_around); - gresult (* find_next) (EphyEmbed *embed, - gboolean backwards); - gresult (* activate) (EphyEmbed *embed); - gresult (* print) (EphyEmbed *embed, - EmbedPrintInfo *info); - gresult (* print_preview_close) (EphyEmbed *embed); - gresult (* print_preview_num_pages) (EphyEmbed *embed, - gint *retNum); - gresult (* print_preview_navigate) (EphyEmbed *embed, - EmbedPrintPreviewNavType navType, - gint pageNum); - gresult (* set_encoding) (EphyEmbed *embed, - const char *encoding); - gresult (* get_encoding_info) (EphyEmbed *embed, - EphyEncodingInfo **info); + void (* load_url) (EphyEmbed *embed, + const char *url); + void (* stop_load) (EphyEmbed *embed); + void (* reload) (EphyEmbed *embed, + EmbedReloadFlags flags); + gboolean (* can_go_back) (EphyEmbed *embed); + gboolean (* can_go_forward) (EphyEmbed *embed); + gboolean (* can_go_up) (EphyEmbed *embed); + GSList * (* get_go_up_list) (EphyEmbed *embed); + void (* go_back) (EphyEmbed *embed); + void (* go_forward) (EphyEmbed *embed); + void (* go_up) (EphyEmbed *embed); + + char * (* get_title) (EphyEmbed *embed); + char * (* get_location) (EphyEmbed *embed, + gboolean toplevel); + int (* shistory_n_items) (EphyEmbed *embed); + void (* shistory_get_nth) (EphyEmbed *embed, + int nth, + gboolean is_relative, + char **url, + char **title); + int (* shistory_get_pos) (EphyEmbed *embed); + void (* shistory_go_nth) (EphyEmbed *embed, + int nth); + void (* get_security_level) (EphyEmbed *embed, + EmbedSecurityLevel *level, + char **description); + void (* zoom_set) (EphyEmbed *embed, + float zoom, + gboolean reflow); + float (* zoom_get) (EphyEmbed *embed); + void (* find_set_properties) (EphyEmbed *embed, + char *search_string, + gboolean case_sensitive, + gboolean wrap_around); + gboolean (* find_next) (EphyEmbed *embed, + gboolean backwards); + void (* set_encoding) (EphyEmbed *embed, + const char *encoding); + EphyEncodingInfo * (* get_encoding_info) (EphyEmbed *embed); + void (* print) (EphyEmbed *embed, + EmbedPrintInfo *info); + void (* print_preview_close) (EphyEmbed *embed); + int (* print_preview_n_pages) (EphyEmbed *embed); + void (* print_preview_navigate) (EphyEmbed *embed, + EmbedPrintPreviewNavType type, + int page); + void (* activate) (EphyEmbed *embed); }; -GType ephy_embed_get_type (void); +GType ephy_embed_get_type (void); -/* Base */ +EphyEmbed *ephy_embed_new (GObject *single); -EphyEmbed *ephy_embed_new (GObject *single); - -void ephy_embed_get_capabilities (EphyEmbed *embed, - EmbedCapabilities *caps); +/* Base */ +void ephy_embed_load_url (EphyEmbed *embed, + const char *url); -gresult ephy_embed_load_url (EphyEmbed *embed, - const char *url); +void ephy_embed_stop_load (EphyEmbed *embed); -gresult ephy_embed_stop_load (EphyEmbed *embed); +void ephy_embed_reload (EphyEmbed *embed, + EmbedReloadFlags flags); -gresult ephy_embed_can_go_back (EphyEmbed *embed); +char *ephy_embed_get_title (EphyEmbed *embed); -gresult ephy_embed_can_go_forward (EphyEmbed *embed); +char *ephy_embed_get_location (EphyEmbed *embed, + gboolean toplevel); -gresult ephy_embed_can_go_up (EphyEmbed *embed); +/* Navigation */ +gboolean ephy_embed_can_go_back (EphyEmbed *embed); -gresult ephy_embed_get_go_up_list (EphyEmbed *embed, - GSList **l); +gboolean ephy_embed_can_go_forward (EphyEmbed *embed); -gresult ephy_embed_go_back (EphyEmbed *embed); +gboolean ephy_embed_can_go_up (EphyEmbed *embed); -gresult ephy_embed_go_forward (EphyEmbed *embed); +GSList *ephy_embed_get_go_up_list (EphyEmbed *embed); -gresult ephy_embed_go_up (EphyEmbed *embed); +void ephy_embed_go_back (EphyEmbed *embed); -gresult ephy_embed_render_data (EphyEmbed *embed, - const char *data, - guint32 len, - const char *base_uri, - const char *mime_type); +void ephy_embed_go_forward (EphyEmbed *embed); -gresult ephy_embed_open_stream (EphyEmbed *embed, - const char *base_uri, - const char *mime_type); +void ephy_embed_go_up (EphyEmbed *embed); -gresult ephy_embed_append_data (EphyEmbed *embed, - const char *data, - guint32 len); +int ephy_embed_shistory_n_items (EphyEmbed *embed); -gresult ephy_embed_close_stream (EphyEmbed *embed); +void ephy_embed_shistory_get_nth (EphyEmbed *embed, + int nth, + gboolean is_relative, + char **url, + char **title); -gresult ephy_embed_get_title (EphyEmbed *embed, - char **title); +int ephy_embed_shistory_get_pos (EphyEmbed *embed); -gresult ephy_embed_get_location (EphyEmbed *embed, - gboolean toplevel, - char **location); +void ephy_embed_shistory_go_nth (EphyEmbed *embed, + int nth); -gresult ephy_embed_reload (EphyEmbed *embed, - EmbedReloadFlags flags); +void ephy_embed_get_security_level (EphyEmbed *embed, + EmbedSecurityLevel *level, + char **description); /* Zoom */ -gresult ephy_embed_zoom_set (EphyEmbed *embed, - float zoom, - gboolean reflow); - -gresult ephy_embed_zoom_get (EphyEmbed *embed, - float *zoom); - -/* Session history */ -gresult ephy_embed_shistory_count (EphyEmbed *embed, - int *count); - -gresult ephy_embed_shistory_get_nth (EphyEmbed *embed, - int nth, - gboolean is_relative, - char **url, - char **title); - -gresult ephy_embed_shistory_get_pos (EphyEmbed *embed, - int *pos); - -gresult ephy_embed_shistory_go_nth (EphyEmbed *embed, - int nth); - -/* Utils */ - -gresult ephy_embed_get_security_level (EphyEmbed *embed, - EmbedSecurityLevel *level, - char **description); +void ephy_embed_zoom_set (EphyEmbed *embed, + float zoom, + gboolean reflow); -gresult ephy_embed_find_set_properties (EphyEmbed *embed, - char *search_string, - gboolean case_sensitive, - gboolean wrap_around); +float ephy_embed_zoom_get (EphyEmbed *embed); -gresult ephy_embed_find_next (EphyEmbed *embed, - gboolean backwards); +/* Find */ +void ephy_embed_find_set_properties (EphyEmbed *embed, + char *search_string, + gboolean case_sensitive, + gboolean wrap_around); -gresult ephy_embed_set_encoding (EphyEmbed *embed, - const char *encoding); +gboolean ephy_embed_find_next (EphyEmbed *embed, + gboolean backwards); -gresult ephy_embed_get_encoding_info (EphyEmbed *embed, - EphyEncodingInfo **info); +/* Encoding */ +void ephy_embed_set_encoding (EphyEmbed *embed, + const char *encoding); -gresult ephy_embed_activate (EphyEmbed *embed); +EphyEncodingInfo *ephy_embed_get_encoding_info (EphyEmbed *embed); -/* Printing */ +/* Print */ +void ephy_embed_print (EphyEmbed *embed, + EmbedPrintInfo *info); -gresult ephy_embed_print (EphyEmbed *embed, - EmbedPrintInfo *info); +void ephy_embed_print_preview_close (EphyEmbed *embed); -gresult ephy_embed_print_preview_close (EphyEmbed *embed); +int ephy_embed_print_preview_n_pages (EphyEmbed *embed); -gresult ephy_embed_print_preview_num_pages (EphyEmbed *embed, - gint *retNum); +void ephy_embed_print_preview_navigate (EphyEmbed *embed, + EmbedPrintPreviewNavType type, + int page); -gresult ephy_embed_print_preview_navigate (EphyEmbed *embed, - EmbedPrintPreviewNavType navType, - gint pageNum); +/* Misc. utility */ +void ephy_embed_activate (EphyEmbed *embed); G_END_DECLS diff --git a/embed/ephy-history.c b/embed/ephy-history.c index 1f269af70..f318a66a3 100644 --- a/embed/ephy-history.c +++ b/embed/ephy-history.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002 Marco Pesenti Gritti + * Copyright (C) 2002, 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 @@ -19,10 +19,9 @@ */ #ifdef HAVE_CONFIG_H -#include +#include "config.h" #endif -#include "ephy-types.h" #include "ephy-history.h" #include "ephy-file-helpers.h" #include "ephy-debug.h" diff --git a/embed/find-dialog.c b/embed/find-dialog.c index d280f35e1..ace630cda 100755 --- a/embed/find-dialog.c +++ b/embed/find-dialog.c @@ -302,7 +302,6 @@ find_dialog_new_with_parent (GtkWidget *window, static void find_dialog_go_next (FindDialog *dialog) { - gresult result; EphyEmbed *embed; g_return_if_fail (EPHY_IS_FIND_DIALOG (dialog)); @@ -310,9 +309,7 @@ find_dialog_go_next (FindDialog *dialog) embed = ephy_embed_dialog_get_embed (EPHY_EMBED_DIALOG(dialog)); g_return_if_fail (embed != NULL); - result = ephy_embed_find_next (embed, FALSE); - - if (result == G_OK) + if (ephy_embed_find_next (embed, FALSE)) { update_navigation_controls (dialog, TRUE, TRUE); } @@ -325,7 +322,6 @@ find_dialog_go_next (FindDialog *dialog) static void find_dialog_go_prev (FindDialog *dialog) { - gresult result; EphyEmbed *embed; g_return_if_fail (EPHY_IS_FIND_DIALOG (dialog)); @@ -333,9 +329,7 @@ find_dialog_go_prev (FindDialog *dialog) embed = ephy_embed_dialog_get_embed (EPHY_EMBED_DIALOG(dialog)); g_return_if_fail (embed != NULL); - result = ephy_embed_find_next (embed, TRUE); - - if (result == G_OK) + if (ephy_embed_find_next (embed, TRUE)) { update_navigation_controls (dialog, TRUE, TRUE); } 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 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 dirService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv)); - if (!dirService) return G_FAILED; + if (!dirService) return FALSE; nsCOMPtr 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 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 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 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 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 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 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 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 cookieManager = do_CreateInstance (NS_COOKIEMANAGER_CONTRACTID); nsCOMPtr 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 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 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 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 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 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 #include @@ -41,106 +42,74 @@ #include #include -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 channel; channel = do_QueryInterface (MOZILLA_EMBED(embed)->priv->request, &result); - if (NS_FAILED (result)) return G_FAILED; + if (NS_FAILED (result)) return; nsCOMPtr info; result = channel->GetSecurityInfo(getter_AddRefs(info)); - if (NS_FAILED (result)) return G_FAILED; + if (NS_FAILED (result)) return; - *description = NULL; if (info) { nsCOMPtr 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 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(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 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 -- cgit v1.2.3