diff options
author | Shaun McCance <shaunm@gnome.org> | 2010-05-06 14:41:53 -0500 |
---|---|---|
committer | Shaun McCance <shaunm@gnome.org> | 2010-05-06 14:41:53 -0500 |
commit | 99cb028479ca53ff58a90caa68c70a715386a43c (patch) | |
tree | 7fd8bbfe1a232e627a982a1672a0623fdb156d6e | |
parent | d7a2f3d7d5397610a687254de38e4e7c6af44cab (diff) | |
download | yelp-99cb028479ca53ff58a90caa68c70a715386a43c.tar.gz |
Cleaning up some old files
-rw-r--r-- | .gitignore | 5 | ||||
-rw-r--r-- | configure.in | 3 | ||||
-rw-r--r-- | po/POTFILES.skip | 2 | ||||
-rw-r--r-- | src/Makefile.am | 49 | ||||
-rw-r--r-- | src/gtkentryaction.c | 357 | ||||
-rw-r--r-- | src/gtkentryaction.h | 67 | ||||
-rw-r--r-- | src/yelp-base.c | 321 | ||||
-rw-r--r-- | src/yelp-base.h | 67 | ||||
-rw-r--r-- | src/yelp-error.c | 149 | ||||
-rw-r--r-- | src/yelp-error.h | 54 | ||||
-rw-r--r-- | src/yelp-html.c | 587 | ||||
-rw-r--r-- | src/yelp-html.h | 109 | ||||
-rw-r--r-- | src/yelp-infos.xml | 15 | ||||
-rw-r--r-- | src/yelp-main.c | 437 | ||||
-rw-r--r-- | src/yelp-marshal.list | 6 |
15 files changed, 2 insertions, 2226 deletions
@@ -77,13 +77,8 @@ Makefile.in /po/POTFILES /po/stamp-it /po/yelp.pot -/src/client-bindings.h -/src/server-bindings.h -/src/stamp-yelp-marshal.h /src/yelp /src/yelp-dbus.h -/src/yelp-marshal.c -/src/yelp-marshal.h /stamp-h1 /stylesheets/db-title.xsl /stylesheets/db2html.xsl diff --git a/configure.in b/configure.in index c46960d9..0139f760 100644 --- a/configure.in +++ b/configure.in @@ -57,10 +57,7 @@ PKG_CHECK_MODULES(YELP, libxml-2.0 >= 2.6.5 libxslt >= 1.1.4 libexslt >= 0.8.1 - libstartup-notification-1.0 >= 0.8 dbus-glib-1 - rarian >= 0.7.0 - unique-1.0 webkit-1.0 >= 1.1.15 yelp-xsl ]) diff --git a/po/POTFILES.skip b/po/POTFILES.skip index 56ed8ff8..830d3ca2 100644 --- a/po/POTFILES.skip +++ b/po/POTFILES.skip @@ -1,7 +1,5 @@ src/eggdesktopfile.c src/eggsmclient.c -src/yelp-error.c -src/yelp-main.c src/yelp-man.c src/yelp-print.c src/yelp-search-parser.c diff --git a/src/Makefile.am b/src/Makefile.am index 2b4b7387..d4c8d71d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,21 +5,10 @@ yelp_SOURCES = \ yelp-window.c yelp-window.h \ yelp.c -# yelp-base.c yelp-base.h \ -# yelp-error.c yelp-error.h \ -# yelp-html.c yelp-html.h \ -# yelp-io-channel.c yelp-io-channel.h \ -# yelp-utils.c yelp-utils.h \ -# yelp-window.c yelp-window.h \ -# yelp-marshal.c yelp-marshal.h \ # yelp-toc.h yelp-toc.c \ # yelp-db-print.c yelp-db-print.h \ -# yelp-mallard.h yelp-mallard.c \ # yelp-man-parser.c yelp-man-parser.h \ # yelp-man.c yelp-man.h \ -# yelp-info.c yelp-info.h \ -# yelp-info-parser.c yelp-info-parser.h \ -# gtkentryaction.c gtkentryaction.h \ # yelp-search.c yelp-search.h \ # yelp-search-parser.c yelp-search-parser.h @@ -78,50 +67,16 @@ yelp_SOURCES += eggsmclient-osx.c endif endif -BUILT_SOURCES = \ - yelp-dbus.h \ - yelp-marshal.h \ - stamp-yelp-marshal.h \ - yelp-marshal.c \ - server-bindings.h \ - client-bindings.h +BUILT_SOURCES = yelp-dbus.h noinst_HEADERS = $(BUILT_SOURCES) yelp-dbus.h: yelp-dbus.xml dbus-binding-tool --prefix=yelp --mode=glib-server $<> $@ -server-bindings.h: yelp-infos.xml - dbus-binding-tool --prefix=server_object --mode=glib-server $< > $@ - -client-bindings.h: yelp-infos.xml - dbus-binding-tool --prefix=server_object --mode=glib-client $< > $@ - -yelp-marshal.h: stamp-yelp-marshal.h - @true - -stamp-yelp-marshal.h: yelp-marshal.list - @GLIB_GENMARSHAL@ --prefix=yelp_marshal $(srcdir)/yelp-marshal.list --header > xgen-ymh \ - && (cmp -s xgen-ymh yelp-marshal.h || cp xgen-ymh yelp-marshal.h) \ - && rm -f xgen-ymh xgen-ymh~ \ - && echo timestamp > $(@F) - -yelp-marshal.c: yelp-marshal.list - @GLIB_GENMARSHAL@ --prefix=yelp_marshal $(srcdir)/yelp-marshal.list --body > xgen-ymc \ - && cp xgen-ymc yelp-marshal.c \ - && rm -f xgen-ymc xgen-ymc~ - -yelp-marshal-main.c: yelp-marshal.c - -CLEANFILES = xgen-ymh xgen-ymc - MAINTAINERCLEANFILES = $(BUILT_SOURCES) -EXTRA_DIST = \ - yelp-dbus.xml \ - yelp-marshal.list \ - yelp-infos.xml - +EXTRA_DIST = yelp-dbus.xml install-exec-hook: rm -f $(DESTDIR)$(bindir)/gnome-help && \ diff --git a/src/gtkentryaction.c b/src/gtkentryaction.c deleted file mode 100644 index 25378762..00000000 --- a/src/gtkentryaction.c +++ /dev/null @@ -1,357 +0,0 @@ -/* - * Copyright (C) 2003, 2004 Marco Pesenti Gritti - * Copyright (C) 2003, 2004 Christian Persch - * - * 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. - * - * $Id$ - */ - -#include "config.h" - -#include "gtkentryaction.h" - -#include <gtk/gtk.h> - -#define GTK_ENTRY_ACTION_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), GTK_TYPE_ENTRY_ACTION, GtkEntryActionPrivate)) - -struct _GtkEntryActionPrivate -{ - char *text; - gboolean editable; - GtkWidget *entry_widget; -}; - -static void gtk_entry_action_init (GtkEntryAction *action); -static void gtk_entry_action_class_init (GtkEntryActionClass *class); -static void changed_cb (GtkEntry *entry, - GtkEntryAction *action); - -enum -{ - PROP_0, - PROP_TEXT, - PROP_EDITABLE, -}; - -static GObjectClass *parent_class = NULL; - -GType -gtk_entry_action_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) - { - static const GTypeInfo type_info = - { - sizeof (GtkEntryActionClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gtk_entry_action_class_init, - (GClassFinalizeFunc) NULL, - NULL, - sizeof (GtkEntryAction), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_entry_action_init, - }; - - type = g_type_register_static (GTK_TYPE_ACTION, - "GtkEntryAction", - &type_info, 0); - } - - return type; -} - -static GtkWidget * -gtk_entry_action_create_tool_item (GtkAction *action) -{ - GtkToolItem *tool_item; - GtkWidget *entry; - GtkWidget *box; - GtkWidget *label; - GtkEntryAction *action_cast = (GtkEntryAction *)action; - - tool_item = gtk_tool_item_new (); - box = gtk_hbox_new (FALSE, 6); - label = gtk_label_new (""); - entry = gtk_entry_new (); - action_cast->priv->entry_widget = entry; - gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry); - gtk_container_add (GTK_CONTAINER (tool_item), box); - gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (box), entry, FALSE, FALSE, 0); - gtk_widget_show (entry); - gtk_widget_show (box); - - g_object_set_data (G_OBJECT (tool_item), "label", label); - g_object_set_data (G_OBJECT (tool_item), "entry", entry); - - return GTK_WIDGET (tool_item); -} - -static gboolean -check_widget (GtkWidget *widget) -{ - return GTK_IS_TOOL_ITEM (widget) && - GTK_IS_LABEL (g_object_get_data (G_OBJECT (widget), "label")) && - GTK_IS_ENTRY (g_object_get_data (G_OBJECT (widget), "entry")); -} - -static void -sync_label (GtkAction *gaction, - GParamSpec *pspec, - GtkWidget *proxy) -{ - GtkEntryAction *action = GTK_ENTRY_ACTION (gaction); - GtkToolItem *item = GTK_TOOL_ITEM (proxy); - GtkLabel *label = GTK_LABEL (g_object_get_data (G_OBJECT (item), "label")); - char *text = NULL; - - g_object_get (action, "label", &text, NULL); - gtk_label_set_text_with_mnemonic (label, text); - if (text && *text) - gtk_widget_show (GTK_WIDGET (label)); - else - gtk_widget_hide (GTK_WIDGET (label)); - g_free (text); -} - -static void -sync_text (GtkAction *gaction, - GParamSpec *pspec, - GtkWidget *proxy) -{ - GtkEntryAction *action = GTK_ENTRY_ACTION (gaction); - GtkToolItem *item = GTK_TOOL_ITEM (proxy); - GtkEntry *entry = GTK_ENTRY (g_object_get_data (G_OBJECT (item), "entry")); - - g_signal_handlers_block_by_func (entry, G_CALLBACK (changed_cb), action); - gtk_entry_set_text (entry, action->priv->text); - g_signal_handlers_unblock_by_func (entry, G_CALLBACK (changed_cb), action); -} - -static void -sync_editable (GtkAction *gaction, - GParamSpec *pspec, - GtkWidget *proxy) -{ - GtkEntryAction *action = GTK_ENTRY_ACTION (gaction); - GtkToolItem *item = GTK_TOOL_ITEM (proxy); - GtkEntry *entry = GTK_ENTRY (g_object_get_data (G_OBJECT (item), "entry")); - - gtk_editable_set_editable (GTK_EDITABLE (entry), action->priv->editable); -} - -static void -changed_cb (GtkEntry *entry, GtkEntryAction *action) -{ - const char *text; - GtkWidget *proxy = GTK_WIDGET (entry)->parent; - - text = gtk_entry_get_text (entry); - - g_signal_handlers_block_by_func (action, G_CALLBACK (sync_text), proxy); - gtk_entry_action_set_text (action, text); - g_signal_handlers_unblock_by_func (action, G_CALLBACK (sync_text), proxy); -} - - - -static void -connect_proxy (GtkAction *action, GtkWidget *proxy) -{ - if (check_widget (proxy)) - { - GtkToolItem *item = GTK_TOOL_ITEM (proxy); - GtkEntry *entry = GTK_ENTRY (g_object_get_data (G_OBJECT (item), "entry")); - - sync_label (action, NULL, proxy); - g_signal_connect_object (action, "notify::label", - G_CALLBACK (sync_label), proxy, 0); - sync_text (action, NULL, proxy); - g_signal_connect_object (action, "notify::text", - G_CALLBACK (sync_text), proxy, 0); - sync_editable (action, NULL, proxy); - g_signal_connect_object (action, "notify::editable", - G_CALLBACK (sync_editable), proxy, 0); - - g_signal_connect_object (entry, "activate", - G_CALLBACK (gtk_action_activate), action, - G_CONNECT_SWAPPED); - g_signal_connect_object (entry, "changed", - G_CALLBACK (changed_cb), action, 0); - } - - GTK_ACTION_CLASS (parent_class)->connect_proxy (action, proxy); -} - -static void -disconnect_proxy (GtkAction *action, GtkWidget *proxy) -{ - GTK_ACTION_CLASS (parent_class)->disconnect_proxy (action, proxy); - - if (check_widget (proxy)) - { - GtkToolItem *item = GTK_TOOL_ITEM (proxy); - GtkEntry *entry = GTK_ENTRY (g_object_get_data (G_OBJECT (item), "entry")); - - g_signal_handlers_disconnect_matched (action, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, proxy); - g_signal_handlers_disconnect_matched (entry, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, action); - } -} - -static void -gtk_entry_action_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GtkEntryAction *action = GTK_ENTRY_ACTION (object); - - switch (prop_id) - { - case PROP_TEXT: - gtk_entry_action_set_text (action, g_value_get_string (value)); - break; - case PROP_EDITABLE: - action->priv->editable = g_value_get_boolean (value); - break; - } -} - -static void -gtk_entry_action_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GtkEntryAction *action = GTK_ENTRY_ACTION (object); - - switch (prop_id) - { - case PROP_TEXT: - g_value_set_string (value, gtk_entry_action_get_text (action)); - break; - case PROP_EDITABLE: - g_value_set_boolean (value, action->priv->editable); - break; - } -} - -static void -gtk_entry_action_finalize (GObject *object) -{ - GtkEntryAction *action = GTK_ENTRY_ACTION (object); - GtkEntryActionPrivate *priv = action->priv; - - g_free (priv->text); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -gtk_entry_action_class_init (GtkEntryActionClass *class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (class); - GtkActionClass *action_class = GTK_ACTION_CLASS (class); - - parent_class = g_type_class_peek_parent (class); - - object_class->finalize = gtk_entry_action_finalize; - object_class->get_property = gtk_entry_action_get_property; - object_class->set_property = gtk_entry_action_set_property; - - action_class->create_tool_item = gtk_entry_action_create_tool_item; - action_class->connect_proxy = connect_proxy; - action_class->disconnect_proxy = disconnect_proxy; - - g_object_class_install_property (object_class, - PROP_TEXT, - g_param_spec_string ("text", - "Text", - "The text", - "", - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_EDITABLE, - g_param_spec_boolean ("editable", - "Editable", - "Editable", - TRUE, - G_PARAM_READWRITE)); - - g_type_class_add_private (object_class, sizeof (GtkEntryActionPrivate)); -} - -static void -gtk_entry_action_init (GtkEntryAction *action) -{ - action->priv = GTK_ENTRY_ACTION_GET_PRIVATE (action); - - action->priv->text = g_strdup (""); - action->priv->editable = TRUE; -} - -GtkAction * -gtk_entry_action_new (const gchar *name, - const gchar *label, - const gchar *tooltip, - const gchar *stock_id) -{ - GtkAction *action; - - action = g_object_new (GTK_TYPE_ENTRY_ACTION, - "name", name, - "label", label, - "tooltip", tooltip, - "stock_id", stock_id, - NULL); - - return action; -} - -const char * -gtk_entry_action_get_text (GtkEntryAction *action) -{ - g_return_val_if_fail (GTK_IS_ENTRY_ACTION (action), ""); - - return action->priv->text; -} - -void -gtk_entry_action_set_text (GtkEntryAction *action, - const char *text) -{ - char *old_text; - g_return_if_fail (GTK_IS_ENTRY_ACTION (action)); - - old_text = action->priv->text; - action->priv->text = g_strdup (text); - g_free (old_text); - g_object_notify (G_OBJECT (action), "text"); -} - -gboolean -gtk_entry_action_has_focus (GtkEntryAction *action) -{ - g_return_val_if_fail (GTK_IS_ENTRY_ACTION (action), FALSE); - - return (GTK_WIDGET_HAS_FOCUS (action->priv->entry_widget)); - -} diff --git a/src/gtkentryaction.h b/src/gtkentryaction.h deleted file mode 100644 index 413fea60..00000000 --- a/src/gtkentryaction.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 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 - * 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. - * - * $Id$ - */ - -#ifndef GTK_ENTRY_ACTION_H -#define GTK_ENTRY_ACTION_H - -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -#define GTK_TYPE_ENTRY_ACTION (gtk_entry_action_get_type ()) -#define GTK_ENTRY_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ENTRY_ACTION, GtkEntryAction)) -#define GTK_ENTRY_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ENTRY_ACTION, GtkEntryActionClass)) -#define GTK_IS_ENTRY_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ENTRY_ACTION)) -#define GTK_IS_ENTRY_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GTK_TYPE_ENTRY_ACTION)) -#define GTK_ENTRY_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_ENTRY_ACTION, GtkEntryActionClass)) - -typedef struct _GtkEntryAction GtkEntryAction; -typedef struct _GtkEntryActionPrivate GtkEntryActionPrivate; -typedef struct _GtkEntryActionClass GtkEntryActionClass; - -struct _GtkEntryAction -{ - GtkAction parent; - - /*< private >*/ - GtkEntryActionPrivate *priv; -}; - -struct _GtkEntryActionClass -{ - GtkActionClass parent_class; -}; - -GType gtk_entry_action_get_type (void); - -GtkAction *gtk_entry_action_new (const gchar *name, - const gchar *label, - const gchar *tooltip, - const gchar *stock_id); - -const char *gtk_entry_action_get_text (GtkEntryAction *action); - -void gtk_entry_action_set_text (GtkEntryAction *action, - const char *text); - -gboolean gtk_entry_action_has_focus (GtkEntryAction *action); -G_END_DECLS - -#endif diff --git a/src/yelp-base.c b/src/yelp-base.c deleted file mode 100644 index c702a996..00000000 --- a/src/yelp-base.c +++ /dev/null @@ -1,321 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2001-2002 Mikael Hallendal <micke@imendio.com> - * - * 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 of the - * License, 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. - * - * Author: Mikael Hallendal <micke@imendio.com> - */ - -#include <config.h> - -#include <dbus/dbus-glib-bindings.h> -#include <gdk/gdkx.h> -#define SN_API_NOT_YET_FROZEN -#include <libsn/sn-launchee.h> - -#include <string.h> - -#include "yelp-window.h" -#include "yelp-settings.h" -#include "yelp-toc.h" -#include "yelp-base.h" -#include "yelp-bookmarks.h" -#include "server-bindings.h" - -gboolean main_running; - -#define YELP_BASE_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), YELP_TYPE_BASE, YelpBasePriv)) - -struct _YelpBasePriv { - GNode *toc_tree; - gboolean private_session; - - GList *index; - GSList *windows; -}; - -static void yelp_base_init (YelpBase *base); -static void yelp_base_class_init (YelpBaseClass *klass); -static void yelp_base_register_dbus (YelpBase *base); -static void yelp_base_new_window_cb (YelpWindow *window, - const gchar *uri, - YelpBase *base); -static void yelp_base_window_finalized_cb (YelpBase *base, - YelpWindow *window); - - -#define PARENT_TYPE G_TYPE_OBJECT -static GObjectClass *parent_class; - -GType -yelp_base_get_type (void) -{ - static GType base_type = 0; - - if (!base_type) { - static const GTypeInfo base_info = { - sizeof (YelpBaseClass), - NULL, - NULL, - (GClassInitFunc) yelp_base_class_init, - NULL, - NULL, - sizeof (YelpBase), - 0, - (GInstanceInitFunc) yelp_base_init, - }; - - base_type = g_type_register_static (G_TYPE_OBJECT, - "YelpBase", - &base_info, 0); - } - - return base_type; -} - -static void -yelp_base_init (YelpBase *base) -{ - YelpBasePriv *priv; - - base->priv = priv = YELP_BASE_GET_PRIVATE (base); - priv->toc_tree = g_node_new (NULL); - priv->index = NULL; - priv->windows = NULL; - yelp_bookmarks_init (); - yelp_settings_init (); - /* Init here to start processing before - * we even start the window */ - yelp_toc_new(); - -} - -static void -yelp_base_class_init (YelpBaseClass *klass) -{ - parent_class = g_type_class_peek (PARENT_TYPE); - - main_running = TRUE; - - g_type_class_add_private (klass, sizeof (YelpBasePriv)); -} - -gboolean -server_new_window (YelpBase *base, gchar *url, gchar *timestamp, - GError **error) -{ - GtkWidget *new_window; - - new_window = yelp_base_new_window (base, url, timestamp); - gtk_widget_show (new_window); - return TRUE; -} - -gboolean -server_get_url_list (YelpBase *server, gchar **urls, GError **error) -{ - gint len, i; - GSList *node; - const gchar *uri; - YelpBasePriv *priv; - - priv = server->priv; - - len = g_slist_length (priv->windows); - - node = priv->windows; - - uri = yelp_window_get_uri ((YelpWindow *) node->data); - *urls = g_strdup (uri); - node = node->next; - - for (i = 0; node; node = node->next, i++) { - gchar *list; - uri = yelp_window_get_uri ((YelpWindow *) node->data); - - list = g_strconcat (uri, ";", *urls, NULL); - g_free (*urls); - *urls = g_strdup (list); - g_free (list); - } - return TRUE; -} - -static void -yelp_base_new_window_cb (YelpWindow *window, const gchar *uri, - YelpBase *base) -{ - GtkWidget *new_window; - - g_return_if_fail (YELP_IS_WINDOW (window)); - g_return_if_fail (YELP_IS_BASE (base)); - - new_window = yelp_base_new_window (base, uri, NULL); - - gtk_widget_show (new_window); -} - -static void -yelp_base_window_finalized_cb (YelpBase *base, YelpWindow *window) -{ - YelpBasePriv *priv; - - g_return_if_fail (YELP_IS_BASE (base)); - - priv = base->priv; - - priv->windows = g_slist_remove (priv->windows, window); - - if (g_slist_length (priv->windows) == 0) { - main_running = FALSE; - gtk_main_quit (); - } -} - -YelpBase * -yelp_base_new (gboolean priv) -{ - YelpBase *base; - - base = g_object_new (YELP_TYPE_BASE, NULL); - if (!priv) - yelp_base_register_dbus (base); - base->priv->private_session = priv; - - return base; -} - -static void -sn_error_trap_push (SnDisplay *display, - Display *xdisplay) -{ - gdk_error_trap_push (); -} - -static void -sn_error_trap_pop (SnDisplay *display, - Display *xdisplay) -{ - gdk_error_trap_pop (); -} - -GtkWidget * -yelp_base_new_window (YelpBase *base, const gchar *uri, const gchar *startup_id) -{ - YelpBasePriv *priv; - GtkWidget *window; - SnDisplay *sn_display = NULL; - GdkScreen *screen = NULL; - GdkDisplay *display = NULL; - SnLauncheeContext *context = NULL; - - g_return_val_if_fail (YELP_IS_BASE (base), NULL); - - priv = base->priv; - - window = yelp_window_new (priv->toc_tree, priv->index); - gtk_widget_realize (GTK_WIDGET (window)); - - if (startup_id) { - screen = gtk_window_get_screen (GTK_WINDOW (window)); - display = gdk_screen_get_display (screen); - - sn_display = - sn_display_new (gdk_x11_display_get_xdisplay (display), - sn_error_trap_push, sn_error_trap_pop); - context = sn_launchee_context_new (sn_display, - gdk_screen_get_number (screen), - startup_id); - if (strncmp (sn_launchee_context_get_startup_id (context), - "_TIME", 5) != 0) - sn_launchee_context_setup_window (context, - GDK_WINDOW_XWINDOW (window->window)); - - if (sn_launchee_context_get_id_has_timestamp (context)) { - gulong time; - - time = sn_launchee_context_get_timestamp (context); - gdk_x11_window_set_user_time (window->window, time); - } - } - - priv->windows = g_slist_prepend (priv->windows, window); - - g_object_weak_ref (G_OBJECT (window), - (GWeakNotify) yelp_base_window_finalized_cb, - base); - - g_signal_connect (window, "new_window_requested", - G_CALLBACK (yelp_base_new_window_cb), - base); - - gtk_widget_show (window); - - if (uri && uri[0] != '\0') - yelp_window_load (YELP_WINDOW (window), uri); - else - yelp_window_load (YELP_WINDOW (window), "x-yelp-toc:"); - - if (context) { - sn_launchee_context_complete (context); - sn_launchee_context_unref (context); - sn_display_unref (sn_display); - } - - return window; -} - -static void -yelp_base_register_dbus (YelpBase *base) -{ - GError *error = NULL; - DBusGProxy *driver_proxy; - YelpBaseClass *klass = YELP_BASE_GET_CLASS (base); - guint request_ret; - YelpBasePriv *priv; - - priv = base->priv; - - klass->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - if (klass->connection == NULL) { - g_warning("Unable to connect to dbus: %s", error->message); - g_error_free (error); - return; - } - - dbus_g_object_type_install_info (YELP_TYPE_BASE, - &dbus_glib_server_object_object_info); - - dbus_g_connection_register_g_object (klass->connection, - "/org/gnome/YelpService", - G_OBJECT (base)); - - driver_proxy = dbus_g_proxy_new_for_name (klass->connection, - DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, - DBUS_INTERFACE_DBUS); - - if(!org_freedesktop_DBus_request_name (driver_proxy, - "org.gnome.YelpService", - 0, &request_ret, - &error)) { - g_warning("Unable to register service: %s", error->message); - g_error_free (error); - } - g_object_unref (driver_proxy); - -} diff --git a/src/yelp-base.h b/src/yelp-base.h deleted file mode 100644 index e5ac0e7c..00000000 --- a/src/yelp-base.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2001 Mikael Hallendal <micke@imendio.com> - * - * 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 of the - * License, 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. - * - * Author: Mikael Hallendal <micke@imendio.com> - */ - -#ifndef __YELP_BASE_H__ -#define __YELP_BASE_H__ - -#include <dbus/dbus-glib.h> - - -typedef struct _YelpBase YelpBase; -typedef struct _YelpBaseClass YelpBaseClass; -typedef struct _YelpBasePriv YelpBasePriv; - -#define YELP_TYPE_BASE (yelp_base_get_type ()) -#define YELP_BASE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), YELP_TYPE_BASE, YelpBase)) -#define YELP_BASE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), YELP_TYPE_BASE, YelpBaseClass)) -#define YELP_IS_BASE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), YELP_TYPE_BASE)) -#define YELP_IS_BASE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), YELP_TYPE_BASE)) -#define YELP_BASE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), YELP_TYPE_BASE, YelpBaseClass)) - - -struct _YelpBase { - GObject parent; - - YelpBasePriv *priv; -}; - -struct _YelpBaseClass { - GObjectClass parent_class; - - DBusGConnection *connection; -}; - -GType yelp_base_get_type (void); -YelpBase * yelp_base_new (gboolean priv); - -GtkWidget * yelp_base_new_window (YelpBase *base, - const gchar *uri, - const gchar *timestamp); -gboolean server_new_window (YelpBase *server, - gchar *url, - gchar *timestamp, - GError **error); -gboolean server_get_url_list (YelpBase *server, - gchar **urls, - GError **error); - -#endif /* __YELP_BASE_H__ */ diff --git a/src/yelp-error.c b/src/yelp-error.c deleted file mode 100644 index 63bd7748..00000000 --- a/src/yelp-error.c +++ /dev/null @@ -1,149 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * Copyright (C) 2002 Mikael Hallendal <micke@imendio.com> - * Copyright (C) 2007 Shaun McCance <shaunm@gnome.org> - * - * 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 of the - * License, 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. - */ - -#include <config.h> - -#include <glib.h> -#include <glib/gi18n.h> - -#include "yelp-error.h" - -struct _YelpError { - gchar *title; - gchar *message; -}; - -static YelpError * -yelp_error_new_valist (gchar *title, gchar *format, va_list args) -{ - YelpError *error; - - error = g_slice_new (YelpError); - error->title = g_strdup (title); - error->message = g_strdup_vprintf (format, args); - - return error; -} - -YelpError * -yelp_error_new (gchar *title, gchar *format, ...) -{ - YelpError *error; - va_list args; - - va_start (args, format); - error = yelp_error_new_valist (title, format, args); - va_end (args); - - return error; -} - -void -yelp_error_set (YelpError **error, gchar *title, gchar *format, ...) -{ - YelpError *new; - va_list args; - - va_start (args, format); - new = yelp_error_new_valist (title, format, args); - va_end (args); - - if (*error == NULL) - *error = new; - else - g_warning - ("YelpError set over the top of a previous YelpError or uninitialized\n" - "memory. This indicates a bug in someone's code. You must ensure an\n" - "error is NULL before it's set. The overwriting error message was:\n" - "%s", - new->message); -} - -YelpError * -yelp_error_copy (YelpError *error) -{ - YelpError *new; - - new = g_slice_new (YelpError); - new->title = g_strdup (error->title); - new->message = g_strdup (error->message); - - return new; -} - -const gchar * -yelp_error_get_title (YelpError *error) -{ - g_return_val_if_fail (error != NULL, NULL); - return error->title; -} - -const gchar * -yelp_error_get_message (YelpError *error) -{ - g_return_val_if_fail (error != NULL, NULL); - return error->message; -} - -void -yelp_error_free (YelpError *error) -{ - g_return_if_fail (error != NULL); - g_free (error->title); - g_free (error->message); - g_slice_free (YelpError, error); -} - -/******************************************************************************/ - -GQuark -yelp_gerror_quark (void) -{ - static GQuark q = 0; - - if (q == 0) - q = g_quark_from_static_string ("yelp-error-quark"); - - return q; -} - -const gchar * -yelp_gerror_get_title (GError *error) -{ - if (!error || error->domain != YELP_GERROR) - return _("Unknown Error"); - - switch (error->code) { - case YELP_GERROR_IO: - return _("Could Not Read File"); - } - - return _("Unknown Error"); -} - -const gchar * -yelp_gerror_get_message (GError *error) -{ - if (!error || !error->message) - return _("No information is available about this error."); - else - return error->message; -} diff --git a/src/yelp-error.h b/src/yelp-error.h deleted file mode 100644 index 91a5bda2..00000000 --- a/src/yelp-error.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * Copyright (C) 2002 Mikael Hallendal <micke@imendio.com> - * Copyright (C) 2007 Shaun McCance <shaunm@gnome.org> - * - * 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 of the - * License, 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 __YELP_ERROR_H__ -#define __YELP_ERROR_H__ - -#include <glib.h> - -typedef struct _YelpError YelpError; - -YelpError * yelp_error_new (gchar *title, - gchar *format, - ...); -void yelp_error_set (YelpError **error, - gchar *title, - gchar *format, - ...); -YelpError * yelp_error_copy (YelpError *error); - -const gchar * yelp_error_get_title (YelpError *error); -const gchar * yelp_error_get_message (YelpError *error); - -void yelp_error_free (YelpError *error); - - -#define YELP_GERROR yelp_gerror_quark () - -enum { - YELP_GERROR_IO -}; - -GQuark yelp_gerror_quark (void) G_GNUC_CONST; -const gchar * yelp_gerror_get_title (GError *error); -const gchar * yelp_gerror_get_message (GError *error); - -#endif /* __YELP_ERROR_H__ */ diff --git a/src/yelp-html.c b/src/yelp-html.c deleted file mode 100644 index bc07c37b..00000000 --- a/src/yelp-html.c +++ /dev/null @@ -1,587 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * Copyright (C) 2004 Marco Pesenti Gritti - * Copyright (C) 2005 Christian Persch - * - * 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 of the - * License, 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. - * - * Author: Marco Pesenti Gritti <marco@gnome.org> - */ - -#include <config.h> -#include "yelp-marshal.h" -#include "yelp-settings.h" - -#include <string.h> -#include <webkit/webkitwebframe.h> -#include <webkit/webkitnetworkrequest.h> -#include <webkit/webkitwebview.h> -#include <webkit/webkitwebsettings.h> - -#include "yelp-html.h" -#include "yelp-debug.h" - - -#define YELP_HTML_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), YELP_TYPE_HTML, YelpHtmlPriv)) - -struct _YelpHtmlPriv { - gchar *content; - gchar *mime; - gchar *find_string; - gboolean initialised; - gchar *base_uri; - gchar *anchor; - gboolean frames_enabled; - guint timeout; -}; - -static void html_set_fonts (YelpHtml *html); -static void html_set_colors (YelpHtml *html); -static void html_set_a11y (YelpHtml *html); - -enum { - URI_SELECTED, - FRAME_SELECTED, - TITLE_CHANGED, - POPUPMENU_REQUESTED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -static GObjectClass *parent_class = NULL; - -static gboolean -html_open_uri (WebKitWebView* view, - WebKitWebFrame* web_frame, - WebKitNetworkRequest* req, - WebKitWebNavigationAction* action, - WebKitWebPolicyDecision* decision, - gpointer data) -{ - const gchar *uri = webkit_network_request_get_uri (req); - WebKitNavigationResponse resp = WEBKIT_NAVIGATION_RESPONSE_IGNORE; - YelpHtml *html = YELP_HTML (view); - gboolean block_load; - gchar *real_uri; - - debug_print (DB_FUNCTION, "entering\n"); - debug_print (DB_ARG, " uri = \"%s\"\n", uri); - - /* Only emit our signals on clicks */ - if (webkit_web_navigation_action_get_reason (action) != WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) { - webkit_web_policy_decision_use (decision); - return TRUE; - } - - real_uri = g_strdup (uri); - - /* If we got an URI with an anchor, that means we got to a - * reference; we want to get what comes after #, and replace what - * is after ? in the base URI we have - */ - if (g_str_has_prefix (uri, html->priv->base_uri)) { - gint length = strlen (html->priv->base_uri); - - if (uri[length] == '#') { - gchar *question_mark = g_strrstr (real_uri, "?"); - gchar *tmp = real_uri; - - *question_mark = '\0'; - real_uri = g_strdup_printf ("%s?%s", tmp, uri + length + 1); - - g_free (tmp); - } - } - - if (!html->priv->frames_enabled) { - g_signal_emit (html, signals[URI_SELECTED], 0, real_uri, FALSE); - } else { - g_signal_emit (html, signals[FRAME_SELECTED], 0, real_uri, FALSE, &block_load); - } - - g_free (real_uri); - webkit_web_policy_decision_ignore (decision); - return TRUE; -} - -#ifdef HAVE_GECKO_1_9 -static void -html_reset_accessible_parent (GtkWidget *widget) -{ - AtkObject * html_acc = gtk_widget_get_accessible (widget); - AtkObject * parent_acc = gtk_widget_get_accessible (widget->parent); - if (html_acc && parent_acc) { - atk_object_set_parent (html_acc, parent_acc); - } -} -#endif - -static void -html_realize (GtkWidget *widget) -{ -#ifdef HAVE_GECKO_1_9 - /* When Gecko accessibility module init, it will overwrite - * atk_class->get_root. - * But the top level accessible of yelp is not controlled by Gecko. - * So we need to restore the callback. See Bug #545162. - * It only need to do once. - * We do it here because Gecko a11y module inits when it is actually used, - * we call gtk_widget_get_accessible to pull the trigger. */ - - static gboolean gail_get_root_restored = FALSE; - static AtkObject * (*gail_get_root) (void); - static AtkUtilClass * atk_class = NULL; - if (!gail_get_root_restored) { - gpointer data; - data = g_type_class_peek (ATK_TYPE_UTIL); - if (data) { - atk_class = ATK_UTIL_CLASS (data); - gail_get_root = atk_class->get_root; - } - } -#endif - - YelpHtml *html = YELP_HTML (widget); - - GTK_WIDGET_CLASS (parent_class)->realize (widget); - -} - -static void -html_init (YelpHtml *html) -{ - YelpHtmlPriv *priv; - YelpHtmlClass *klass; - - html->priv = priv = YELP_HTML_GET_PRIVATE (html); - - priv->base_uri = NULL; - priv->anchor = NULL; - priv->timeout = 0; - priv->content = NULL; - priv->mime = NULL; - priv->initialised = FALSE; - - klass = YELP_HTML_GET_CLASS (html); - if (!klass->font_handler) { - klass->font_handler = - yelp_settings_notify_add (YELP_SETTINGS_INFO_FONTS, - (GHookFunc) html_set_fonts, - html); - html_set_fonts (html); - } - if (!klass->color_handler) { - klass->color_handler = - yelp_settings_notify_add (YELP_SETTINGS_INFO_COLOR, - (GHookFunc) html_set_colors, - html); - html_set_colors (html); - } - if (!klass->a11y_handler) { - klass->a11y_handler = - yelp_settings_notify_add (YELP_SETTINGS_INFO_A11Y, - (GHookFunc) html_set_a11y, - html); - html_set_a11y (html); - } - - g_signal_connect (html, "navigation-policy-decision-requested", - G_CALLBACK (html_open_uri), NULL); -} - -static void -html_dispose (GObject *object) -{ - YelpHtml *html = YELP_HTML (object); - - parent_class->dispose (object); -} - -static void -html_finalize (GObject *object) -{ - YelpHtml *html = YELP_HTML (object); - YelpHtmlPriv *priv = html->priv; - - - if (priv->timeout) - g_source_remove (priv->timeout); - g_free (priv->base_uri); - g_free (priv->anchor); - - g_signal_handlers_disconnect_by_func (html, html_open_uri, NULL); - - parent_class->finalize (object); -} - -static void -html_class_init (YelpHtmlClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - WebKitWebViewClass* wc_class = WEBKIT_WEB_VIEW_CLASS (klass); - - parent_class = (GObjectClass *) g_type_class_peek_parent (klass); - - object_class->finalize = html_finalize; - object_class->dispose = html_dispose; - - widget_class->realize = html_realize; - - - klass->font_handler = 0; - klass->color_handler = 0; - klass->a11y_handler = 0; - - signals[URI_SELECTED] = - g_signal_new ("uri_selected", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (YelpHtmlClass, - uri_selected), - NULL, NULL, - yelp_marshal_VOID__POINTER_BOOLEAN, - G_TYPE_NONE, - 2, G_TYPE_POINTER, G_TYPE_BOOLEAN); - - signals[FRAME_SELECTED] = - g_signal_new ("frame_selected", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (YelpHtmlClass, - frame_selected), - g_signal_accumulator_true_handled, NULL, - yelp_marshal_BOOLEAN__POINTER_BOOLEAN, - G_TYPE_BOOLEAN, - 2, G_TYPE_POINTER, G_TYPE_BOOLEAN); - - - signals[POPUPMENU_REQUESTED] = - g_signal_new ("popupmenu_requested", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (YelpHtmlClass, - popupmenu_requested), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, - 1, G_TYPE_STRING); - - g_type_class_add_private (klass, sizeof (YelpHtmlPriv)); -} - -GType -yelp_html_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo info = { - sizeof (YelpHtmlClass), - NULL, - NULL, - (GClassInitFunc) html_class_init, - NULL, - NULL, - sizeof (YelpHtml), - 0, - (GInstanceInitFunc) html_init, - }; - - type = g_type_register_static (WEBKIT_TYPE_WEB_VIEW, - "YelpHtml", - &info, (GTypeFlags) 0); - } - - return type; -} - -YelpHtml * -yelp_html_new (void) -{ - YelpHtml *html; - - html = YELP_HTML (g_object_new (YELP_TYPE_HTML, NULL)); - - return html; -} - -void -yelp_html_set_base_uri (YelpHtml *html, const gchar *uri) -{ - YelpHtmlPriv *priv; - - g_return_if_fail (YELP_IS_HTML (html)); - - debug_print (DB_FUNCTION, "entering\n"); - debug_print (DB_ARG, " uri = \"%s\"\n", uri); - - priv = html->priv; - - if (priv->base_uri) - g_free (priv->base_uri); - - if (uri[0] == '/') - priv->base_uri = g_strdup_printf ("file://%s", uri); - else - priv->base_uri = g_strdup (uri); -} - -void -yelp_html_open_stream (YelpHtml *html, const gchar *mime) -{ - debug_print (DB_FUNCTION, "entering\n"); - - html->priv->frames_enabled = FALSE; - g_free (html->priv->content); - html->priv->content = NULL; - g_free (html->priv->mime); - html->priv->mime = g_strdup(mime); -} - -void -yelp_html_write (YelpHtml *html, const gchar *data, gint len) -{ - gchar *tmp = NULL; - - if (len == -1) len = strlen (data); - - debug_print (DB_FUNCTION, "entering\n"); - debug_print (DB_ARG, " data = %i bytes\n", strlen (data)); - debug_print (DB_ARG, " len = %i\n", len); - - if (html->priv->content) { - tmp = g_strjoin (NULL, html->priv->content, data, NULL); - g_free (html->priv->content); - html->priv->content = tmp; - } else { - html->priv->content = g_strdup (data); - } -} - -void -yelp_html_frames (YelpHtml *html, gboolean enable) -{ - html->priv->frames_enabled = enable; - - -} - -void -yelp_html_printf (YelpHtml *html, char *format, ...) -{ - va_list args; - gchar *string; - - g_return_if_fail (format != NULL); - - va_start (args, format); - string = g_strdup_vprintf (format, args); - va_end (args); - - yelp_html_write (html, string, -1); - - g_free (string); -} - - -void -yelp_html_close (YelpHtml *html) -{ - debug_print (DB_FUNCTION, "entering\n"); - - if (!html->priv->initialised) { - html->priv->initialised = TRUE; - html_set_fonts (html); - html_set_colors (html); - html_set_a11y (html); - webkit_web_view_set_maintains_back_forward_list (WEBKIT_WEB_VIEW (html), FALSE); - } - - webkit_web_view_load_string (WEBKIT_WEB_VIEW (html), - html->priv->content, - html->priv->mime, - NULL, - html->priv->base_uri); - g_free (html->priv->content); - html->priv->content = NULL; - g_free (html->priv->mime); - html->priv->mime = NULL; -} - -gboolean -yelp_html_find (YelpHtml *html, - const gchar *find_string) -{ - if (html->priv->find_string) - g_free(html->priv->find_string); - html->priv->find_string = g_strdup (find_string); - return webkit_web_view_search_text (WEBKIT_WEB_VIEW (html), - find_string, FALSE, - TRUE, TRUE); -} - -gboolean -yelp_html_find_again (YelpHtml *html, - gboolean forward) -{ - return webkit_web_view_search_text (WEBKIT_WEB_VIEW (html), - html->priv->find_string, - FALSE, - forward, TRUE); -} - -void -yelp_html_set_find_props (YelpHtml *html, - const char *str, - gboolean match_case, - gboolean wrap) -{ - /* Empty */ -} - -void -yelp_html_jump_to_anchor (YelpHtml *html, - gchar *anchor) -{ - YelpHtmlPriv *priv; - - g_return_if_fail (html != NULL); - - priv = html->priv; - - g_free (priv->anchor); - priv->anchor = g_strdup (anchor); -} - -void -yelp_html_copy_selection (YelpHtml *html) -{ - webkit_web_view_copy_clipboard (WEBKIT_WEB_VIEW (html)); -} - -void -yelp_html_select_all (YelpHtml *html) -{ - webkit_web_view_select_all (WEBKIT_WEB_VIEW (html)); -} - -void -yelp_html_print (YelpHtml *html) -{ - webkit_web_view_execute_script (WEBKIT_WEB_VIEW (html), "print();"); -} - -static void -html_set_fonts (YelpHtml *html) -{ - gchar *font; - WebKitWebSettings *settings; - GValue *name, *size; - gchar *str_name; - gint i_size; - gchar *tmp; - - settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (html)); - - font = yelp_settings_get_font (YELP_FONT_VARIABLE); - - /* We have to separate the string into name and size and then - * assign to the 2 gvalues */ - tmp = g_strrstr (font, " "); - if (!tmp) { - g_warning ("Cannot decode font pattern %s", font); - g_free (font); - return; - } - - name = g_new0 (GValue, 1); - size = g_new0 (GValue, 1); - - name = g_value_init (name, G_TYPE_STRING); - size = g_value_init (size, G_TYPE_INT); - - str_name = g_strndup (font, tmp - font); - - i_size = g_strtod (tmp, NULL); - - g_value_set_string (name, str_name); - g_value_set_int (size, i_size); - - g_object_set_property (G_OBJECT (settings), "default-font-family", - name); - g_object_set_property (G_OBJECT (settings), "default-font-size", - size); - - g_free (font); - - font = yelp_settings_get_font (YELP_FONT_FIXED); - - tmp = g_strrstr (font, " "); - if (!tmp) { - g_warning ("Cannot decode monospace font pattern %s", font); - g_free (font); - return; - } - - name = g_value_reset (name); - size = g_value_reset (size); - - str_name = g_strndup (font, tmp - font); - - i_size = g_strtod (tmp, NULL); - - g_value_set_string (name, str_name); - g_value_set_int (size, i_size); - - - g_object_set_property (G_OBJECT (settings), "monospace-font-family", - name); - g_object_set_property (G_OBJECT (settings), "default-monospace-font-size", - size); - - g_free (font); -} - -static void -html_set_colors (YelpHtml *html) -{ - /* TODO: No Webkit equivalent ... */ - /* See https://bugs.webkit.org/show_bug.cgi?id=19486 */ - -} - -static void -html_set_a11y (YelpHtml *html) -{ - gboolean caret; - - caret = yelp_settings_get_caret (); - /* TODO Webkit version */ -} - -gboolean -yelp_html_initialize (void) -{ - return TRUE; -} - -void -yelp_html_shutdown (void) -{ - /* Empty */ -} diff --git a/src/yelp-html.h b/src/yelp-html.h deleted file mode 100644 index 82235991..00000000 --- a/src/yelp-html.h +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2001-2002 Mikael Hallendal <micke@imendio.com> - * - * 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 of the - * License, 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. - * - * Author: Mikael Hallendal <micke@imendio.com> - */ - -#ifndef __YELP_HTML_H__ -#define __YELP_HTML_H__ - -#include <config.h> -#include <webkit/webkit.h> - -G_BEGIN_DECLS - -#define YELP_TYPE_HTML (yelp_html_get_type ()) -#define YELP_HTML(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), YELP_TYPE_HTML, YelpHtml)) -#define YELP_HTML_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), YELP_TYPE_HTML, YelpHtmlClass)) -#define YELP_IS_HTML(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), YELP_TYPE_HTML)) -#define YELP_IS_HTML_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), YELP_TYPE_HTML)) -#define YELP_HTML_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), YELP_TYPE_HTML, YelpHtmlClass)) - -typedef struct _YelpHtml YelpHtml; -typedef struct _YelpHtmlClass YelpHtmlClass; -typedef struct _YelpHtmlPriv YelpHtmlPriv; - -struct _YelpHtml { - WebKitWebView parent; - YelpHtmlPriv *priv; -}; - -struct _YelpHtmlClass { - WebKitWebViewClass parent; - guint font_handler; - guint color_handler; - guint a11y_handler; - - /* Signals */ - void (*uri_selected) (YelpHtml *view, - gchar *uri, - gboolean handled); - gboolean (*frame_selected) (YelpHtml *view, - gchar *uri, - gboolean handled); - void (*title_changed) (YelpHtml *view, - const gchar *new_title); - void (*popupmenu_requested) (YelpHtml *view, - const gchar *link); - -}; - -GType yelp_html_get_type (void); -YelpHtml * yelp_html_new (void); - -void yelp_html_set_base_uri (YelpHtml *html, - const gchar *uri); -void yelp_html_open_stream (YelpHtml *html, - const gchar *mime); -void yelp_html_write (YelpHtml *html, - const gchar *data, - gint len); -void yelp_html_printf (YelpHtml *html, - char *format, - ...) G_GNUC_PRINTF (2,3); -void yelp_html_close (YelpHtml *html); - -void yelp_html_frames (YelpHtml *html, - gboolean enable); - -gboolean yelp_html_find (YelpHtml *html, - const gchar *str); - -gboolean yelp_html_find_again (YelpHtml *html, - gboolean forward); - -void yelp_html_set_find_props (YelpHtml *html, - const char *str, - gboolean match_case, - gboolean wrap); - -void yelp_html_jump_to_anchor (YelpHtml *html, - gchar *anchor); - -void yelp_html_copy_selection (YelpHtml *html); - -void yelp_html_select_all (YelpHtml *html); - -void yelp_html_print (YelpHtml *html); -gboolean yelp_html_initialize (void); -void yelp_html_shutdown (void); - -G_END_DECLS - -#endif /* __YELP_HTML_H__ */ diff --git a/src/yelp-infos.xml b/src/yelp-infos.xml deleted file mode 100644 index 18462b61..00000000 --- a/src/yelp-infos.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<node name="/org/gnome/YelpService"> - <interface name="org.gnome.YelpService"> - <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="server"/> - <method name="new_window"> - <arg type="s" name="url" direction="in" /> - <arg type="s" name="timestamp" direction="in" /> - </method> - <method name="get_url_list"> - <arg type="s" name="urls" direction="out" /> - </method> - <!-- Add more methods/signals if you want --> - </interface> -</node> diff --git a/src/yelp-main.c b/src/yelp-main.c deleted file mode 100644 index c88f26f4..00000000 --- a/src/yelp-main.c +++ /dev/null @@ -1,437 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2001-2003 Mikael Hallendal <micke@imendio.com> - * - * 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 of the - * License, 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. - * - * Author: Mikael Hallendal <micke@imendio.com> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <glib/gi18n.h> -#include <gtk/gtk.h> -#include <gdk/gdkx.h> -#include <dbus/dbus-glib-bindings.h> -#include <string.h> -#include <stdlib.h> -#include <libxslt/xslt.h> - -#ifdef WITH_SMCLIENT -#include "eggsmclient.h" -#endif /* WITH_SMCLIENT */ -#include "client-bindings.h" -#include "yelp-window.h" -#include "yelp-base.h" -#include "yelp-html.h" - -static gchar *cache_dir; -static gchar *open_urls; -static gchar *startup_id; -static gchar **files; -static gboolean private = FALSE; -static YelpBase *priv_base = NULL; - -static DBusGConnection *connection; - -/*structure defining command line option.*/ -enum { - OPTION_OPEN_URLS = 1, - OPTION_CACHE_DIR -}; - -static void main_start (const gchar *url); -static DBusGProxy * main_dbus_get_proxy (void); -static gboolean main_is_running (void); -static gboolean main_slave_start (gchar *url); - -#ifdef WITH_SMCLIENT -static int main_save_session (EggSMClient *client, - gpointer cdata); - -static void main_client_die (EggSMClient *client, - gpointer cdata); -#endif /* WITH_SMCLIENT */ - -static gboolean main_restore_session (void); -static Time slowly_and_stupidly_obtain_timestamp (Display *xdisplay); - - -static const GOptionEntry options[] = { - { - "open-urls", - '\0', - G_OPTION_FLAG_HIDDEN, - G_OPTION_ARG_STRING, - &open_urls, - NULL, NULL, - }, - { - "private-session", - 'p', - 0, G_OPTION_ARG_NONE, - &private, - N_("Use a private session"), - NULL, - }, - { - "with-cache-dir", - '\0', - 0, - G_OPTION_ARG_STRING, - &cache_dir, - N_("Define which cache directory to use"), - NULL, - }, - { G_OPTION_REMAINING, - 0, 0, G_OPTION_ARG_FILENAME_ARRAY, - &files, NULL, NULL }, - { NULL} -}; - -static void -main_start (const gchar *url) -{ - YelpBase *base; - GError *error = NULL; - - base = yelp_base_new (private); - - server_new_window (base, (gchar *) url, startup_id, &error); - priv_base = base; - - gtk_main (); - - return; -} - - -static gboolean -main_slave_start (gchar *url) -{ - DBusGProxy *proxy = NULL; - GError *error = NULL; - - proxy = main_dbus_get_proxy (); - - if (!proxy) - g_error ("Cannot connect to dbus\n"); - - if (!org_gnome_YelpService_new_window (proxy, url, startup_id, - &error)) - g_error ("%s\n", error->message); - - return FALSE; -} - - -#ifdef WITH_SMCLIENT -static gint -main_save_session (EggSMClient *client, - gpointer cdata) -{ - gchar **argv; - gchar *open_windows = NULL; - gint i=1; - gint arg_len = 1; - gboolean store_open_urls = FALSE; - /* DBusGProxy *proxy = NULL; */ - GError *error = NULL; - - /*proxy = main_dbus_get_proxy (); - if (!proxy) { - g_warning ("Unable to connect to bus again\n");*/ - - - if (!server_get_url_list (priv_base, &open_windows, - &error)) - g_warning ("Cannot recieve window list - %s\n", error->message); - - if (open_windows != NULL) { - store_open_urls = TRUE; - arg_len++; - } - - if (cache_dir) { - arg_len++; - } - - argv = g_malloc0 (sizeof (gchar *) * arg_len); - - /* Program name */ - argv[0] = g_strdup ("yelp"); - - if (cache_dir) { - argv[1] = g_strdup_printf ("--with-cache-dir=\"%s\"", - cache_dir); - } - - if (store_open_urls) { - argv[arg_len - 1] = g_strdup_printf ("--open-urls=\"%s\"", - open_windows); - } - - egg_sm_client_set_restart_command (client, arg_len, (const char **) argv); - - for (i = 0; i < arg_len; ++i) { - g_free (argv[i]); - } - g_free (argv); - - return TRUE; -} - -static void -main_client_die (EggSMClient *client, - gpointer cdata) -{ - gtk_main_quit (); -} -#endif /* WITH_SMCLIENT */ - -static gboolean -main_restore_session (void) -{ - YelpBase *yelp_base; - - yelp_base = yelp_base_new (private); - priv_base = yelp_base; - - if (!yelp_base) { - g_error ("Couldn't activate YelpBase"); - } - g_print ("restoring session\n"); - if (open_urls) { - gchar **urls = g_strsplit_set (open_urls, ";\"", -1); - gchar *url; - gint i = 0; - GError *error = NULL; - - while ((url = urls[i]) != NULL) { - if (*url != '\0') - server_new_window (yelp_base, url, - startup_id, &error); - ++i; - } - - g_strfreev (urls); - } - gtk_main (); - return FALSE; - -} - -/* Copied from libnautilus/nautilus-program-choosing.c; Needed in case - * we have no DESKTOP_STARTUP_ID (with its accompanying timestamp). - */ -static Time -slowly_and_stupidly_obtain_timestamp (Display *xdisplay) -{ - Window xwindow; - XEvent event; - - { - XSetWindowAttributes attrs; - Atom atom_name; - Atom atom_type; - gchar* name; - - attrs.override_redirect = True; - attrs.event_mask = PropertyChangeMask | StructureNotifyMask; - - xwindow = - XCreateWindow (xdisplay, - RootWindow (xdisplay, 0), - -100, -100, 1, 1, - 0, - CopyFromParent, - CopyFromParent, - CopyFromParent, - CWOverrideRedirect | CWEventMask, - &attrs); - - atom_name = XInternAtom (xdisplay, "WM_NAME", TRUE); - g_assert (atom_name != None); - atom_type = XInternAtom (xdisplay, "STRING", TRUE); - g_assert (atom_type != None); - - name = "Fake Window"; - XChangeProperty (xdisplay, - xwindow, atom_name, - atom_type, - 8, PropModeReplace, (guchar *) name, strlen (name)); - } - - XWindowEvent (xdisplay, - xwindow, - PropertyChangeMask, - &event); - - XDestroyWindow(xdisplay, xwindow); - - return event.xproperty.time; -} - -DBusGProxy * -main_dbus_get_proxy (void) -{ - if (!connection) - return NULL; - - return dbus_g_proxy_new_for_name (connection, - "org.gnome.YelpService", - "/org/gnome/YelpService", - "org.gnome.YelpService"); -} - -gboolean -main_is_running (void) -{ - DBusGProxy *proxy = NULL; - gboolean instance = TRUE; - GError * error = NULL; - - if (!connection) - return TRUE; - - proxy = dbus_g_proxy_new_for_name (connection, - DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, - DBUS_INTERFACE_DBUS); - - if (!dbus_g_proxy_call (proxy, "NameHasOwner", &error, - G_TYPE_STRING, "org.gnome.YelpService", - G_TYPE_INVALID, - G_TYPE_BOOLEAN, &instance, - G_TYPE_INVALID)) { - g_error ("Cannot connect to DBus - %s\n", error->message); - exit (2); - } - return instance; -} - - -int -main (int argc, char **argv) -{ - gchar *url = NULL; -#ifdef WITH_SMCLIENT - EggSMClient *sm_client; - GError *error = NULL; -#endif /* WITH_SMCLIENT */ - gboolean retval; - gboolean session_started = FALSE; - gchar *local_id; - GOptionContext *context; - - g_thread_init(NULL); - - bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - textdomain(GETTEXT_PACKAGE); - xsltInit (); - - local_id = (gchar *) g_getenv ("DESKTOP_STARTUP_ID"); - - if (local_id != NULL && *local_id != '\0') { - startup_id = g_strdup (local_id); - putenv ("DESKTOP_STARTUP_ID="); - } - - /* Commandline parsing is done here */ - context = g_option_context_new (N_(" GNOME Help Browser")); - - g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); - - g_option_context_add_group (context, gtk_get_option_group (TRUE)); - -#ifdef WITH_SMCLIENT - g_option_context_add_group (context, egg_sm_client_get_option_group ()); -#endif /* WITH_SMCLIENT */ - - g_option_context_set_translation_domain(context, GETTEXT_PACKAGE); - - gtk_window_set_auto_startup_notification(FALSE); - - retval = g_option_context_parse (context, &argc, &argv, &error); - g_option_context_free (context); - if (!retval) { - g_print ("%s", error->message); - g_error_free (error); - exit (1); - } - - dbus_g_thread_init(); - - if (!startup_id) { - Time tmp; - tmp = slowly_and_stupidly_obtain_timestamp (gdk_display); - startup_id = g_strdup_printf ("_TIME%lu", tmp); - } - g_set_application_name (_("Help")); - gtk_window_set_default_icon_name ("help-browser"); - - if (!private) { - connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL); - if (!connection) { - g_warning ("Cannot find dbus bus\n"); - private = TRUE; - } - } - - if (!yelp_html_initialize ()) { - g_printerr ("Could not initialize HTML component\n"); - exit (1); - } - - if (files != NULL && files[0] != NULL) { - url = g_strdup (files[0]); - g_strfreev (files); - } - -#ifdef WITH_SMCLIENT - sm_client = egg_sm_client_get (); - g_signal_connect (sm_client, "save-state", - G_CALLBACK (main_save_session), NULL); - g_signal_connect (sm_client, "quit", - G_CALLBACK (main_client_die), NULL); - session_started = egg_sm_client_is_resumed(sm_client); -#endif /* WITH_SMCLIENT */ - - if (private || !main_is_running ()) { - const gchar *env; - - xsltInit (); - if (session_started) { - main_restore_session (); - } else { - main_start (url); - } - } else { - main_slave_start (url); - } - - yelp_html_shutdown (); - -#ifdef WITH_SMCLIENT - g_signal_handlers_disconnect_matched (sm_client, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, NULL); -#endif /* WITH_SMCLIENT */ - - return 0; -} diff --git a/src/yelp-marshal.list b/src/yelp-marshal.list deleted file mode 100644 index 7501fd3a..00000000 --- a/src/yelp-marshal.list +++ /dev/null @@ -1,6 +0,0 @@ -VOID:POINTER,BOOLEAN -VOID:STRING -VOID:VOID -VOID:STRING,INT -VOID:POINTER -BOOLEAN:POINTER,BOOLEAN |