From: Christian Dywan Date: Tue, 18 Nov 2008 01:08:50 +0000 (+0100) Subject: Add two example extensions X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9158e3356720cec5827afc1dc72992e7f91e07ef;p=midori Add two example extensions --- diff --git a/extensions/statusbar-features.c b/extensions/statusbar-features.c new file mode 100644 index 00000000..26e2876e --- /dev/null +++ b/extensions/statusbar-features.c @@ -0,0 +1,52 @@ +/* + Copyright (C) 2008 Christian Dywan + + 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 + +void +realign_tabs_app_add_browser_cb (MidoriApp* app, + MidoriBrowser* browser) +{ + GtkWidget* statusbar; + GtkWidget* bbox; + MidoriWebSettings* settings; + GtkWidget* button; + + /* FIXME: Monitor each view and modify its settings individually + instead of merely replicating the global preferences. */ + + statusbar = katze_object_get_object (browser, "statusbar"); + bbox = gtk_hbutton_box_new (); + settings = katze_object_get_object (browser, "settings"); + button = katze_property_proxy (settings, "auto-load-images", NULL); + gtk_container_add (GTK_CONTAINER (bbox), button); + gtk_widget_show (button); + button = katze_property_proxy (settings, "enable-scripts", NULL); + gtk_container_add (GTK_CONTAINER (bbox), button); + gtk_widget_show (button); + gtk_widget_show (bbox); + gtk_box_pack_start (GTK_BOX (statusbar), bbox, FALSE, FALSE, 3); +} + +MidoriExtension* extension_main (MidoriApp* app) +{ + MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION, + "name", "Statusbar Features", + "description", "", + "version", "0.1", + "authors", "Christian Dywan ", + NULL); + + g_signal_connect (app, "add-browser", + G_CALLBACK (realign_tabs_app_add_browser_cb), NULL); + + return extension; +} diff --git a/extensions/tab-panel/main.c b/extensions/tab-panel/main.c new file mode 100644 index 00000000..83664ba8 --- /dev/null +++ b/extensions/tab-panel/main.c @@ -0,0 +1,45 @@ +/* + Copyright (C) 2008 Christian Dywan + + 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 "tab-panel-extension.h" + +#include + +void +tab_panel_app_add_browser_cb (MidoriApp* app, + MidoriBrowser* browser) +{ + GtkWidget* panel; + GtkWidget* child; + + /* FIXME: Actually provide a tree view listing all views. */ + + panel = katze_object_get_object (browser, "panel"); + child = midori_view_new (NULL); + gtk_widget_show (child); + midori_panel_append_page (MIDORI_PANEL (panel), child, + NULL, GTK_STOCK_INDEX, "Tab Panel"); +} + +MidoriExtension* extension_main (MidoriApp* app) +{ + MidoriExtension* extension = g_object_new (TAB_PANEL_TYPE_EXTENSION, + "name", "Tab Panel", + "description", "", + "version", "0.1", + "authors", "Christian Dywan ", + NULL); + + g_signal_connect (app, "add-browser", + G_CALLBACK (tab_panel_app_add_browser_cb), extension); + + return extension; +} diff --git a/extensions/tab-panel/tab-panel-extension.c b/extensions/tab-panel/tab-panel-extension.c new file mode 100644 index 00000000..27cdb92a --- /dev/null +++ b/extensions/tab-panel/tab-panel-extension.c @@ -0,0 +1,38 @@ +/* + Copyright (C) 2008 Christian Dywan + + 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 "tab-panel-extension.h" + +#include + +struct _TabPanelExtension +{ + MidoriExtension parent_instance; +}; + +struct _TabPanelExtensionClass +{ + MidoriExtensionClass parent_class; +}; + +G_DEFINE_TYPE (TabPanelExtension, tab_panel_extension, MIDORI_TYPE_EXTENSION); + +static void +tab_panel_extension_class_init (TabPanelExtensionClass* class) +{ + /* Nothing to do. */ +} + +static void +tab_panel_extension_init (TabPanelExtension* source) +{ + /* Nothing to do. */ +} diff --git a/extensions/tab-panel/tab-panel-extension.h b/extensions/tab-panel/tab-panel-extension.h new file mode 100644 index 00000000..583998b4 --- /dev/null +++ b/extensions/tab-panel/tab-panel-extension.h @@ -0,0 +1,43 @@ +/* + Copyright (C) 2008 Christian Dywan + + 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 __TAB_PANEL_EXTENSION_H__ +#define __TAB_PANEL_EXTENSION_H__ + +#include + +G_BEGIN_DECLS + +#define TAB_PANEL_TYPE_EXTENSION \ + (midori_extension_get_type ()) +#define TAB_PANEL_EXTENSION(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), TAB_PANEL_TYPE_EXTENSION, TabPanelExtension)) +#define TAB_PANEL_EXTENSION_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), TAB_PANEL_TYPE_EXTENSION, TabPanelExtensionClass)) +#define TAB_PANEL_IS_EXTENSION(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TAB_PANEL_TYPE_EXTENSION)) +#define TAB_PANEL_IS_EXTENSION_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), TAB_PANEL_TYPE_EXTENSION)) +#define TAB_PANEL_EXTENSION_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), TAB_PANEL_TYPE_EXTENSION, TabPanelExtensionClass)) + +typedef struct _TabPanelExtension TabPanelExtension; +typedef struct _TabPanelExtensionClass TabPanelExtensionClass; + +GType +tab_panel_extension_get_type (void); + +/* There is no API for TabPanelExtension. Please use the + available properties and signals. */ + +G_END_DECLS + +#endif /* __TAB_PANEL_EXTENSION_H__ */