+++ /dev/null
-/*
- Copyright (C) 2008 Christian Dywan <christian@twotoasts.de>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- See the file COPYING for the full license text.
-*/
-
-#include "midori-pane.h"
-
-#include <glib/gi18n.h>
-
-struct _MidoriPane
-{
- GtkHBox parent_instance;
-};
-
-static void
-midori_pane_base_init (MidoriPaneIface* iface);
-
-GType
-midori_pane_get_type (void)
-{
- static GType pane_type = 0;
-
- if (!pane_type)
- {
- const GTypeInfo pane_info =
- {
- sizeof (MidoriPaneIface),
- (GBaseInitFunc) midori_pane_base_init,
- (GBaseFinalizeFunc) NULL,
- };
-
- pane_type = g_type_register_static (G_TYPE_INTERFACE,
- "MidoriPane",
- &pane_info, 0);
- g_type_interface_add_prerequisite (pane_type, GTK_TYPE_WIDGET);
- }
-
- return pane_type;
-}
-
-static const gchar*
-midori_pane_default_get_stock_id (MidoriPane* pane)
-{
- return NULL;
-}
-
-static const gchar*
-midori_pane_default_get_label (MidoriPane* pane)
-{
- return NULL;
-}
-
-static GtkWidget*
-midori_pane_default_get_toolbar (MidoriPane* pane)
-{
- return NULL;
-}
-
-static void
-midori_pane_base_init (MidoriPaneIface* iface)
-{
- static gboolean initialized = FALSE;
-
- if (initialized)
- return;
-
- iface->get_stock_id = midori_pane_default_get_stock_id;
- iface->get_label = midori_pane_default_get_label;
- iface->get_toolbar = midori_pane_default_get_toolbar;
-
- initialized = TRUE;
-}
-
-/**
- * midori_pane_get_stock_id:
- * @pane: a #MidoriPane
- *
- * Retrieves the stock ID of the pane.
- *
- * Return value: a stock ID
- **/
-const gchar*
-midori_pane_get_stock_id (MidoriPane* pane)
-{
- g_return_val_if_fail (MIDORI_IS_PANE (pane), NULL);
-
- return MIDORI_PANE_GET_IFACE (pane)->get_stock_id (pane);
-}
-
-/**
- * midori_pane_get_label:
- * @pane: a #MidoriPane
- *
- * Retrieves the label of the pane.
- *
- * Return value: a label string
- **/
-const gchar*
-midori_pane_get_label (MidoriPane* pane)
-{
- g_return_val_if_fail (MIDORI_IS_PANE (pane), NULL);
-
- return MIDORI_PANE_GET_IFACE (pane)->get_label (pane);
-}
-
-/**
- * midori_pane_get_toolbar:
- * @pane: a #MidoriPane
- *
- * Retrieves the toolbar of the pane.
- *
- * Return value: a toolbar
- **/
-GtkWidget*
-midori_pane_get_toolbar (MidoriPane* pane)
-{
- GtkWidget* toolbar;
-
- g_return_val_if_fail (MIDORI_IS_PANE (pane), NULL);
-
- toolbar = MIDORI_PANE_GET_IFACE (pane)->get_toolbar (pane);
- if (!toolbar)
- toolbar = gtk_event_box_new ();
- return toolbar;
-}
+++ /dev/null
-/*
- Copyright (C) 2008 Christian Dywan <christian@twotoasts.de>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- See the file COPYING for the full license text.
-*/
-
-#ifndef __MIDORI_PANE_H__
-#define __MIDORI_PANE_H__
-
-#include <gtk/gtk.h>
-
-#include <katze/katze.h>
-
-G_BEGIN_DECLS
-
-#define MIDORI_TYPE_PANE \
- (midori_pane_get_type ())
-#define MIDORI_PANE(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), MIDORI_TYPE_PANE, MidoriPane))
-#define MIDORI_IS_PANE(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIDORI_TYPE_PANE))
-#define MIDORI_PANE_GET_IFACE(inst) \
- (G_TYPE_INSTANCE_GET_INTERFACE ((inst), MIDORI_TYPE_PANE, MidoriPaneIface))
-
-typedef struct _MidoriPane MidoriPane;
-typedef struct _MidoriPaneIface MidoriPaneIface;
-
-struct _MidoriPaneIface
-{
- GTypeInterface base_iface;
-
- /* Virtual functions */
- const gchar*
- (*get_stock_id) (MidoriPane* pane);
-
- const gchar*
- (*get_label) (MidoriPane* pane);
-
- GtkWidget*
- (*get_toolbar) (MidoriPane* pane);
-};
-
-GType
-midori_pane_get_type (void);
-
-const gchar*
-midori_pane_get_stock_id (MidoriPane* pane);
-
-const gchar*
-midori_pane_get_label (MidoriPane* pane);
-
-GtkWidget*
-midori_pane_get_toolbar (MidoriPane* pane);
-
-G_END_DECLS
-
-#endif /* __MIDORI_PANE_H__ */
/**
* midori_panel_append_page:
* @panel: a #MidoriPanel
- * @child: the child widget
+ * @viewable: a viewable widget
* @toolbar: a toolbar widget, or %NULL
* @stock_id: a stock ID
* @label: a string to use as the label
*
* Appends a new page to the panel. If @toolbar is specified it will
- * be packed above @child.
+ * be packed above @viewable.
*
* In the case of an error, -1 is returned.
*
* Return value: the index of the new page, or -1
**/
gint
-midori_panel_append_page (MidoriPanel* panel,
- MidoriPane* pane)
+midori_panel_append_page (MidoriPanel* panel,
+ MidoriViewable* viewable)
{
GtkWidget* scrolled;
GObjectClass* gobject_class;
guint n;
g_return_val_if_fail (MIDORI_IS_PANEL (panel), -1);
- g_return_val_if_fail (MIDORI_IS_PANE (pane), -1);
+ g_return_val_if_fail (MIDORI_IS_VIEWABLE (viewable), -1);
- if (GTK_IS_SCROLLED_WINDOW (pane))
- scrolled = (GtkWidget*)pane;
+ if (GTK_IS_SCROLLED_WINDOW (viewable))
+ scrolled = (GtkWidget*)viewable;
else
{
scrolled = gtk_scrolled_window_new (NULL, NULL);
GTK_POLICY_AUTOMATIC);
GTK_WIDGET_SET_FLAGS (scrolled, GTK_CAN_FOCUS);
gtk_widget_show (scrolled);
- gobject_class = G_OBJECT_GET_CLASS (pane);
+ gobject_class = G_OBJECT_GET_CLASS (viewable);
if (GTK_WIDGET_CLASS (gobject_class)->set_scroll_adjustments_signal)
- widget = (GtkWidget*)pane;
+ widget = (GtkWidget*)viewable;
else
{
widget = gtk_viewport_new (NULL, NULL);
gtk_widget_show (widget);
- gtk_container_add (GTK_CONTAINER (widget), GTK_WIDGET (pane));
+ gtk_container_add (GTK_CONTAINER (widget), GTK_WIDGET (viewable));
}
gtk_container_add (GTK_CONTAINER (scrolled), widget);
}
gtk_container_add (GTK_CONTAINER (panel->notebook), scrolled);
- toolbar = midori_pane_get_toolbar (pane);
+ toolbar = midori_viewable_get_toolbar (viewable);
gtk_widget_show (toolbar);
gtk_container_add (GTK_CONTAINER (panel->toolbook), toolbar);
n = midori_panel_page_num (panel, scrolled);
- label = midori_pane_get_label (pane);
- stock_id = midori_pane_get_stock_id (pane);
+ label = midori_viewable_get_label (viewable);
+ stock_id = midori_viewable_get_stock_id (viewable);
toolitem = gtk_radio_tool_button_new_from_stock (panel->group, stock_id);
panel->group = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (
gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem), label);
gtk_widget_set_tooltip_text (GTK_WIDGET (toolitem), label);
}
- g_object_set_data (G_OBJECT (toolitem), "page", pane);
+ g_object_set_data (G_OBJECT (toolitem), "page", viewable);
g_signal_connect (toolitem, "clicked",
G_CALLBACK (midori_panel_menu_item_activate_cb), panel);
gtk_widget_show_all (GTK_WIDGET (toolitem));
{
menuitem = gtk_image_menu_item_new_from_stock (stock_id, NULL);
gtk_widget_show (menuitem);
- g_object_set_data (G_OBJECT (menuitem), "page", pane);
+ g_object_set_data (G_OBJECT (menuitem), "page", viewable);
g_object_set_data (G_OBJECT (menuitem), "toolitem", toolitem);
g_signal_connect (menuitem, "activate",
G_CALLBACK (midori_panel_menu_item_activate_cb),
midori_panel_set_current_page (MidoriPanel* panel,
gint n)
{
- GtkWidget* pane;
+ GtkWidget* viewable;
g_return_if_fail (MIDORI_IS_PANEL (panel));
gtk_notebook_set_current_page (GTK_NOTEBOOK (panel->toolbook), n);
gtk_notebook_set_current_page (GTK_NOTEBOOK (panel->notebook), n);
- if ((pane = midori_panel_get_nth_page (panel, n)))
+ if ((viewable = midori_panel_get_nth_page (panel, n)))
{
- const gchar* label = midori_pane_get_label (MIDORI_PANE (pane));
+ const gchar* label;
+
+ label = midori_viewable_get_label (MIDORI_VIEWABLE (viewable));
g_object_set (panel->toolbar_label, "label", label, NULL);
}
}
gchar* label;
gchar* stock_id;
GtkWidget* toolbar;
-} MidoriDummyPane;
+} MidoriDummyViewable;
typedef struct
{
GtkAlignmentClass parent_class;
-} MidoriDummyPaneClass;
+} MidoriDummyViewableClass;
-#define MIDORI_TYPE_DUMMY_PANE (midori_dummy_pane_get_type ())
-#define MIDORI_DUMMY_PANE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- MIDORI_TYPE_DUMMY_PANE, MidoriDummyPane))
-#define MIDORI_IS_DUMMY_PANE(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIDORI_TYPE_DUMMY_PANE))
+#define MIDORI_TYPE_DUMMY_VIEWABLE (midori_dummy_viewable_get_type ())
+#define MIDORI_DUMMY_VIEWABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ MIDORI_TYPE_DUMMY_VIEWABLE, MidoriDummyViewable))
+#define MIDORI_IS_DUMMY_VIEWABLE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIDORI_TYPE_DUMMY_VIEWABLE))
static void
-midori_dummy_pane_iface_init (MidoriPaneIface* iface);
+midori_dummy_viewable_iface_init (MidoriViewableIface* iface);
static void
-midori_dummy_pane_finalize (GObject* object);
+midori_dummy_viewable_finalize (GObject* object);
-G_DEFINE_TYPE_WITH_CODE (MidoriDummyPane, midori_dummy_pane, GTK_TYPE_ALIGNMENT,
- G_IMPLEMENT_INTERFACE (MIDORI_TYPE_PANE,
- midori_dummy_pane_iface_init));
+G_DEFINE_TYPE_WITH_CODE (MidoriDummyViewable, midori_dummy_viewable,
+ GTK_TYPE_ALIGNMENT,
+ G_IMPLEMENT_INTERFACE (MIDORI_TYPE_VIEWABLE,
+ midori_dummy_viewable_iface_init));
static void
-midori_dummy_pane_class_init (MidoriDummyPaneClass* class)
+midori_dummy_viewable_class_init (MidoriDummyViewableClass* class)
{
GObjectClass* gobject_class;
gobject_class = G_OBJECT_CLASS (class);
- gobject_class->finalize = midori_dummy_pane_finalize;
+ gobject_class->finalize = midori_dummy_viewable_finalize;
}
static const gchar*
-midori_dummy_pane_get_label (MidoriPane* pane)
+midori_dummy_viewable_get_label (MidoriViewable* viewable)
{
- return MIDORI_DUMMY_PANE (pane)->label;
+ return MIDORI_DUMMY_VIEWABLE (viewable)->label;
}
static const gchar*
-midori_dummy_pane_get_stock_id (MidoriPane* pane)
+midori_dummy_viewable_get_stock_id (MidoriViewable* viewable)
{
- return MIDORI_DUMMY_PANE (pane)->stock_id;
+ return MIDORI_DUMMY_VIEWABLE (viewable)->stock_id;
}
static GtkWidget*
-midori_dummy_pane_get_toolbar (MidoriPane* pane)
+midori_dummy_viewable_get_toolbar (MidoriViewable* viewable)
{
- return MIDORI_DUMMY_PANE (pane)->toolbar;
+ return MIDORI_DUMMY_VIEWABLE (viewable)->toolbar;
}
static void
-midori_dummy_pane_iface_init (MidoriPaneIface* iface)
+midori_dummy_viewable_iface_init (MidoriViewableIface* iface)
{
- iface->get_stock_id = midori_dummy_pane_get_stock_id;
- iface->get_label = midori_dummy_pane_get_label;
- iface->get_toolbar = midori_dummy_pane_get_toolbar;
+ iface->get_stock_id = midori_dummy_viewable_get_stock_id;
+ iface->get_label = midori_dummy_viewable_get_label;
+ iface->get_toolbar = midori_dummy_viewable_get_toolbar;
}
static void
-midori_dummy_pane_init (MidoriDummyPane* pane)
+midori_dummy_viewable_init (MidoriDummyViewable* viewable)
{
- pane->stock_id = NULL;
- pane->label = NULL;
- pane->toolbar = NULL;
+ viewable->stock_id = NULL;
+ viewable->label = NULL;
+ viewable->toolbar = NULL;
}
static void
-midori_dummy_pane_finalize (GObject* object)
+midori_dummy_viewable_finalize (GObject* object)
{
- MidoriDummyPane* pane = MIDORI_DUMMY_PANE (object);
+ MidoriDummyViewable* viewable = MIDORI_DUMMY_VIEWABLE (object);
- katze_assign (pane->stock_id, NULL);
- katze_assign (pane->label, NULL);
+ katze_assign (viewable->stock_id, NULL);
+ katze_assign (viewable->label, NULL);
- G_OBJECT_CLASS (midori_dummy_pane_parent_class)->finalize (object);
+ G_OBJECT_CLASS (midori_dummy_viewable_parent_class)->finalize (object);
}
static GtkWidget*
-midori_dummy_pane_new (const gchar* stock_id,
+midori_dummy_viewable_new (const gchar* stock_id,
const gchar* label,
GtkWidget* toolbar)
{
- GtkWidget* pane = g_object_new (MIDORI_TYPE_DUMMY_PANE, NULL);
+ GtkWidget* viewable = g_object_new (MIDORI_TYPE_DUMMY_VIEWABLE, NULL);
- MIDORI_DUMMY_PANE (pane)->stock_id = g_strdup (stock_id);
- MIDORI_DUMMY_PANE (pane)->label = g_strdup (label);
- MIDORI_DUMMY_PANE (pane)->toolbar = toolbar;
+ MIDORI_DUMMY_VIEWABLE (viewable)->stock_id = g_strdup (stock_id);
+ MIDORI_DUMMY_VIEWABLE (viewable)->label = g_strdup (label);
+ MIDORI_DUMMY_VIEWABLE (viewable)->toolbar = toolbar;
- return pane;
+ return viewable;
}
/**
* @toolbar: a toolbar widget, or %NULL
*
* Appends an arbitrary widget to the panel by wrapping it
- * in a #MidoriPane created on the fly.
+ * in a #MidoriViewable created on the fly.
*
- * Actually implementing #MidoriPane instead of using
+ * Actually implementing #MidoriViewable instead of using
* this convenience is recommended.
*
* In the case of an error, -1 is returned.
const gchar* label,
GtkWidget* toolbar)
{
- GtkWidget* pane;
+ GtkWidget* viewable;
g_return_val_if_fail (MIDORI_IS_PANEL (panel), -1);
g_return_val_if_fail (GTK_IS_WIDGET (widget), -1);
g_return_val_if_fail (stock_id != NULL, -1);
g_return_val_if_fail (!toolbar || GTK_IS_WIDGET (toolbar), -1);
- pane = midori_dummy_pane_new (stock_id, label, toolbar);
- gtk_widget_show (pane);
- gtk_container_add (GTK_CONTAINER (pane), widget);
- return midori_panel_append_page (panel, MIDORI_PANE (pane));
+ viewable = midori_dummy_viewable_new (stock_id, label, toolbar);
+ gtk_widget_show (viewable);
+ gtk_container_add (GTK_CONTAINER (viewable), widget);
+ return midori_panel_append_page (panel, MIDORI_VIEWABLE (viewable));
}
#include <katze/katze.h>
-#include "midori-pane.h"
+#include "midori-viewable.h"
G_BEGIN_DECLS
gint
midori_panel_append_page (MidoriPanel* panel,
- MidoriPane* pane);
+ MidoriViewable* viewable);
gint
midori_panel_get_current_page (MidoriPanel* panel);
--- /dev/null
+/*
+ Copyright (C) 2008 Christian Dywan <christian@twotoasts.de>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ See the file COPYING for the full license text.
+*/
+
+#include "midori-viewable.h"
+
+#include <glib/gi18n.h>
+
+static void
+midori_viewable_base_init (MidoriViewableIface* iface);
+
+static void
+midori_viewable_base_finalize (MidoriViewableIface* iface);
+
+GType
+midori_viewable_get_type (void)
+{
+ static GType viewable_type = 0;
+
+ if (!viewable_type)
+ {
+ const GTypeInfo viewable_info =
+ {
+ sizeof (MidoriViewableIface),
+ (GBaseInitFunc) midori_viewable_base_init,
+ (GBaseFinalizeFunc) midori_viewable_base_finalize,
+ };
+
+ viewable_type = g_type_register_static (G_TYPE_INTERFACE,
+ "MidoriViewable",
+ &viewable_info, 0);
+ g_type_interface_add_prerequisite (viewable_type, GTK_TYPE_WIDGET);
+ }
+
+ return viewable_type;
+}
+
+static const gchar*
+midori_viewable_default_get_stock_id (MidoriViewable* viewable)
+{
+ return NULL;
+}
+
+static const gchar*
+midori_viewable_default_get_label (MidoriViewable* viewable)
+{
+ return NULL;
+}
+
+static GtkWidget*
+midori_viewable_default_get_toolbar (MidoriViewable* viewable)
+{
+ return NULL;
+}
+
+static void
+midori_viewable_base_init (MidoriViewableIface* iface)
+{
+ static gboolean initialized = FALSE;
+
+ if (initialized)
+ return;
+
+ iface->p = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+
+ iface->get_stock_id = midori_viewable_default_get_stock_id;
+ iface->get_label = midori_viewable_default_get_label;
+ iface->get_toolbar = midori_viewable_default_get_toolbar;
+
+ initialized = TRUE;
+}
+
+static void
+midori_viewable_base_finalize (MidoriViewableIface* iface)
+{
+ g_hash_table_destroy (iface->p);
+}
+
+/**
+ * midori_viewable_new_from_uri:
+ * @uri: an URI
+ *
+ * Attempts to create a new #MidoriViewable from the specified URI.
+ *
+ * The protocol of @uri must previously have been registered by
+ * the #MidoriViewable via midori_viewable_register_protocol().
+ *
+ * Return value: a new #MidoriViewable, or %NULL
+ **/
+GtkWidget*
+midori_viewable_new_from_uri (const gchar* uri)
+{
+ MidoriViewableIface* iface;
+ gchar** parts;
+ gchar* type_name;
+ GType type;
+
+ if (!(iface = g_type_default_interface_peek (MIDORI_TYPE_VIEWABLE)))
+ {
+ g_warning ("No viewable interface available");
+ return NULL;
+ }
+
+ g_return_val_if_fail (uri != NULL, NULL);
+
+ g_debug ("size: %d", g_hash_table_size (iface->p));
+ if (!g_hash_table_size (iface->p))
+ return NULL;
+
+ if ((parts = g_strsplit (uri, "://", 2)))
+ {
+ g_debug ("%s, %s", parts[0], uri);
+ if (!(type_name = g_hash_table_lookup (iface->p, parts[0])))
+ {
+ /* FIXME: Support midori://dummy/foo */
+
+ type_name = g_hash_table_lookup (iface->p, uri);
+ }
+ g_strfreev (parts);
+ if (type_name)
+ {
+ type = g_type_from_name (type_name);
+ g_free (type_name);
+ if (type)
+ return g_object_new (type, "uri", uri, NULL);
+ }
+ }
+ else if ((parts = g_strsplit_set (uri, ":", 2)))
+ {
+ g_debug (parts[0]);
+ type_name = g_hash_table_lookup (iface->p, parts[0]);
+ g_strfreev (parts);
+ if (type_name)
+ {
+ type = g_type_from_name (type_name);
+ g_free (type_name);
+ if (type)
+ return g_object_new (type, "uri", uri, NULL);
+ }
+ }
+ return NULL;
+}
+
+static gboolean
+viewable_type_implements (GType type,
+ GType interface)
+{
+ GType *interfaces;
+ guint i;
+
+ if (!(interfaces = g_type_interfaces (type, NULL)))
+ return FALSE;
+ for (i = 0; interfaces[i]; i++)
+ {
+ if (interfaces[i] == interface)
+ {
+ g_free (interfaces);
+ return TRUE;
+ }
+ }
+ g_free (interfaces);
+ return FALSE;
+}
+
+/**
+ * midori_viewable_register_protocol:
+ * @type: a type that implements #MidoriViewable
+ * @protocol: a protocol
+ *
+ * Registers the specified protocol as supported by @type.
+ *
+ * The following kinds of protocols are supported:
+ *
+ * "dummy": support URIs like "dummy://foo/bar"
+ * "about:dummy": support URIs like "about:dummy"
+ * FIXME: The following is not yet fully supported
+ * "midori://dummy": support URIs like "midori://dummy/foo"
+ *
+ * Return value: a new #MidoriViewable, or %NULL
+ **/
+void
+midori_viewable_register_protocol (GType type,
+ const gchar* protocol)
+{
+ MidoriViewableIface* iface;
+ GObjectClass* class;
+
+ if (!(iface = g_type_default_interface_peek (MIDORI_TYPE_VIEWABLE)))
+ {
+ g_warning ("No viewable interface available");
+ return;
+ }
+
+ g_return_if_fail (viewable_type_implements (type, MIDORI_TYPE_VIEWABLE));
+
+ if (!(class = g_type_class_peek (type)))
+ {
+ g_warning ("No class for %s available", g_type_name (type));
+ return;
+ }
+ g_return_if_fail (g_object_class_find_property (class, "uri"));
+ /* FIXME: Verify the syntax of protocol */
+
+ g_hash_table_insert (iface->p, g_strdup (protocol),
+ g_strdup (g_type_name (type)));
+}
+
+/**
+ * midori_viewable_get_stock_id:
+ * @viewable: a #MidoriViewable
+ *
+ * Retrieves the stock ID of the viewable.
+ *
+ * Return value: a stock ID
+ **/
+const gchar*
+midori_viewable_get_stock_id (MidoriViewable* viewable)
+{
+ g_return_val_if_fail (MIDORI_IS_VIEWABLE (viewable), NULL);
+
+ return MIDORI_VIEWABLE_GET_IFACE (viewable)->get_stock_id (viewable);
+}
+
+/**
+ * midori_viewable_get_label:
+ * @viewable: a #MidoriViewable
+ *
+ * Retrieves the label of the viewable.
+ *
+ * Return value: a label string
+ **/
+const gchar*
+midori_viewable_get_label (MidoriViewable* viewable)
+{
+ g_return_val_if_fail (MIDORI_IS_VIEWABLE (viewable), NULL);
+
+ return MIDORI_VIEWABLE_GET_IFACE (viewable)->get_label (viewable);
+}
+
+/**
+ * midori_viewable_get_toolbar:
+ * @viewable: a #MidoriViewable
+ *
+ * Retrieves the toolbar of the viewable.
+ *
+ * Return value: a toolbar
+ **/
+GtkWidget*
+midori_viewable_get_toolbar (MidoriViewable* viewable)
+{
+ GtkWidget* toolbar;
+
+ g_return_val_if_fail (MIDORI_IS_VIEWABLE (viewable), NULL);
+
+ toolbar = MIDORI_VIEWABLE_GET_IFACE (viewable)->get_toolbar (viewable);
+ if (!toolbar)
+ toolbar = gtk_event_box_new ();
+ return toolbar;
+}
--- /dev/null
+/*
+ Copyright (C) 2008 Christian Dywan <christian@twotoasts.de>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ See the file COPYING for the full license text.
+*/
+
+#ifndef __MIDORI_VIEWABLE_H__
+#define __MIDORI_VIEWABLE_H__
+
+#include <gtk/gtk.h>
+
+#include <katze/katze.h>
+
+G_BEGIN_DECLS
+
+#define MIDORI_TYPE_VIEWABLE \
+ (midori_viewable_get_type ())
+#define MIDORI_VIEWABLE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), MIDORI_TYPE_VIEWABLE, MidoriViewable))
+#define MIDORI_IS_VIEWABLE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIDORI_TYPE_VIEWABLE))
+#define MIDORI_VIEWABLE_GET_IFACE(inst) \
+ (G_TYPE_INSTANCE_GET_INTERFACE ((inst), MIDORI_TYPE_VIEWABLE, \
+ MidoriViewableIface))
+
+typedef struct _MidoriViewable MidoriViewable;
+typedef struct _MidoriViewableIface MidoriViewableIface;
+
+struct _MidoriViewableIface
+{
+ GTypeInterface base_iface;
+
+ /* Virtual functions */
+ const gchar*
+ (*get_stock_id) (MidoriViewable* viewable);
+
+ const gchar*
+ (*get_label) (MidoriViewable* viewable);
+
+ GtkWidget*
+ (*get_toolbar) (MidoriViewable* viewable);
+
+ /* Private data */
+ gpointer p;
+};
+
+GType
+midori_viewable_get_type (void);
+
+GtkWidget*
+midori_viewable_new_from_uri (const gchar* uri);
+
+void
+midori_viewable_register_protocol (GType type,
+ const gchar* protocol);
+
+const gchar*
+midori_viewable_get_stock_id (MidoriViewable* viewable);
+
+const gchar*
+midori_viewable_get_label (MidoriViewable* viewable);
+
+GtkWidget*
+midori_viewable_get_toolbar (MidoriViewable* viewable);
+
+G_END_DECLS
+
+#endif /* __MIDORI_VIEWABLE_H__ */
#include "midori-extension.h"
#include "midori-locationaction.h"
#include "midori-locationentry.h"
-#include "midori-pane.h"
#include "midori-panel.h"
#include "midori-preferences.h"
#include "midori-searchaction.h"
#include "midori-source.h"
#include "midori-stock.h"
#include "midori-view.h"
+#include "midori-viewable.h"
#include "midori-websettings.h"
/* For convenience, include localization header */