#include <midori/midori.h>
void
-realign_tabs_app_add_browser_cb (MidoriApp* app,
- MidoriBrowser* browser)
+statusbar_features_app_add_browser_cb (MidoriApp* app,
+ MidoriBrowser* browser)
{
GtkWidget* statusbar;
GtkWidget* bbox;
gtk_box_pack_start (GTK_BOX (statusbar), bbox, FALSE, FALSE, 3);
}
-MidoriExtension* extension_main (MidoriApp* app)
+static void
+statusbar_features_activate_cb (MidoriExtension* extension,
+ MidoriApp* app)
+{
+ g_signal_connect (app, "add-browser",
+ G_CALLBACK (statusbar_features_app_add_browser_cb), NULL);
+}
+
+MidoriExtension*
+extension_init (void)
{
MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION,
"name", "Statusbar Features",
"authors", "Christian Dywan <christian@twotoasts.de>",
NULL);
- g_signal_connect (app, "add-browser",
- G_CALLBACK (realign_tabs_app_add_browser_cb), NULL);
+ g_signal_connect (extension, "activate",
+ G_CALLBACK (statusbar_features_activate_cb), NULL);
return extension;
}
#include <midori/midori.h>
-void
+static void
tab_panel_app_add_browser_cb (MidoriApp* app,
MidoriBrowser* browser)
{
NULL, GTK_STOCK_INDEX, "Tab Panel");
}
-MidoriExtension* extension_main (MidoriApp* app)
+static void
+tab_panel_activate_cb (MidoriExtension* extension,
+ MidoriApp* app)
+{
+ g_signal_connect (app, "add-browser",
+ G_CALLBACK (tab_panel_app_add_browser_cb), NULL);
+}
+
+MidoriExtension*
+extension_init (void)
{
MidoriExtension* extension = g_object_new (TAB_PANEL_TYPE_EXTENSION,
"name", "Tab Panel",
"authors", "Christian Dywan <christian@twotoasts.de>",
NULL);
- g_signal_connect (app, "add-browser",
- G_CALLBACK (tab_panel_app_add_browser_cb), extension);
+ g_signal_connect (extension, "activate",
+ G_CALLBACK (tab_panel_activate_cb), NULL);
return extension;
}
G_CALLBACK (midori_history_clear_cb), db);
#endif
- g_object_set (app, "settings", settings,
- "bookmarks", bookmarks,
- "trash", trash,
- "search-engines", search_engines,
- "history", history,
- NULL);
-
/* Load extensions */
+ KatzeArray* extensions;
gchar* extension_path;
GDir* extension_dir;
const gchar* filename;
+ MidoriExtension* extension;
+ extensions = katze_array_new (MIDORI_TYPE_EXTENSION);
extension_path = g_build_filename (LIBDIR, PACKAGE_NAME, NULL);
if (g_module_supported ())
extension_dir = g_dir_open (extension_path, 0, NULL);
{
gchar* fullname;
GModule* module;
- typedef MidoriExtension* (*extension_main_func)(MidoriApp* app);
- extension_main_func extension_main;
+ typedef MidoriExtension* (*extension_init_func)(void);
+ extension_init_func extension_init;
fullname = g_build_filename (extension_path, filename, NULL);
module = g_module_open (fullname, G_MODULE_BIND_LOCAL);
continue;
}
;
- if (!g_module_symbol (module, "extension_main",
- (gpointer) &extension_main))
+ if (!g_module_symbol (module, "extension_init",
+ (gpointer) &extension_init))
{
g_warning ("%s", g_module_error ());
continue;
}
- extension_main (app);
+ extension = extension_init ();
+ katze_array_add_item (extensions, extension);
}
g_dir_close (extension_dir);
}
+ g_object_set (app, "settings", settings,
+ "bookmarks", bookmarks,
+ "trash", trash,
+ "search-engines", search_engines,
+ "history", history,
+ "extensions", extensions,
+ NULL);
+
+ n = katze_array_get_length (extensions);
+ for (i = 0; i < n; i++)
+ {
+ extension = katze_array_get_nth_item (extensions, i);
+ g_signal_emit_by_name (extension, "activate", app);
+ }
+
browser = g_object_new (MIDORI_TYPE_BROWSER,
"settings", settings,
"bookmarks", bookmarks,
KatzeArray* trash;
KatzeArray* search_engines;
KatzeArray* history;
+ KatzeArray* extensions;
gpointer instance;
};
PROP_BOOKMARKS,
PROP_TRASH,
PROP_SEARCH_ENGINES,
- PROP_BROWSER,
PROP_HISTORY,
+ PROP_EXTENSIONS,
+ PROP_BROWSER,
PROP_BROWSER_COUNT
};
KATZE_TYPE_ARRAY,
G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class,
+ PROP_HISTORY,
+ g_param_spec_object (
+ "history",
+ "History",
+ "The list of history items",
+ KATZE_TYPE_ARRAY,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (gobject_class,
+ PROP_EXTENSIONS,
+ g_param_spec_object (
+ "extensions",
+ "Extensions",
+ "The list of extensions",
+ KATZE_TYPE_ARRAY,
+ G_PARAM_READWRITE));
+
g_object_class_install_property (gobject_class,
PROP_BROWSER,
g_param_spec_object (
"The current number of browsers",
0, G_MAXUINT, 0,
G_PARAM_READABLE));
-
- g_object_class_install_property (gobject_class,
- PROP_HISTORY,
- g_param_spec_object (
- "history",
- "History",
- "The list of history items",
- KATZE_TYPE_ARRAY,
- G_PARAM_READWRITE));
}
static GObject*
app->trash = NULL;
app->search_engines = NULL;
app->history = NULL;
+ app->extensions = NULL;
#if HAVE_UNIQUE
display_name = g_strdup (gdk_display_get_name (gdk_display_get_default ()));
katze_object_assign (app->trash, NULL);
katze_object_assign (app->search_engines, NULL);
katze_object_assign (app->history, NULL);
+ katze_object_assign (app->extensions, NULL);
katze_object_assign (app->instance, NULL);
katze_object_assign (app->history, g_value_dup_object (value));
/* FIXME: Propagate history to all browsers */
break;
+ case PROP_EXTENSIONS:
+ katze_object_assign (app->extensions, g_value_dup_object (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
case PROP_HISTORY:
g_value_set_object (value, app->history);
break;
+ case PROP_EXTENSIONS:
+ g_value_set_object (value, app->extensions);
+ break;
case PROP_BROWSER:
g_value_set_object (value, app->browser);
break;
g_signal_emit (app, signals[ADD_BROWSER], 0, browser);
}
-/**
- * midori_app_get_settings:
- * @app: a #MidoriApp
- *
- * Retrieves the #MidoriWebSettings of the app.
- *
- * Return value: the assigned #MidoriWebSettings
- **/
-MidoriWebSettings*
-midori_app_get_settings (MidoriApp* app)
-{
- g_return_val_if_fail (MIDORI_IS_APP (app), NULL);
-
- return app->settings;
-}
-
-/**
- * midori_app_set_settings:
- * @app: a #MidoriApp
- *
- * Assigns the #MidoriWebSettings to the app.
- *
- * Return value: the assigned #MidoriWebSettings
- **/
-void
-midori_app_set_settings (MidoriApp* app,
- MidoriWebSettings* settings)
-{
- g_return_if_fail (MIDORI_IS_APP (app));
-
- g_object_set (app, "settings", settings, NULL);
-}
-
-/**
- * midori_app_get_trash:
- * @app: a #MidoriApp
- *
- * Retrieves the trash of the app.
- *
- * Return value: the assigned #MidoriTrash
- **/
-KatzeArray*
-midori_app_get_trash (MidoriApp* app)
-{
- g_return_val_if_fail (MIDORI_IS_APP (app), NULL);
-
- return app->trash;
-}
-
/**
* midori_app_quit:
* @app: a #MidoriApp
midori_app_add_browser (MidoriApp* app,
MidoriBrowser* browser);
-MidoriWebSettings*
-midori_app_get_settings (MidoriApp* app);
-
-void
-midori_app_set_settings (MidoriApp* app,
- MidoriWebSettings* settings);
-
-KatzeArray*
-midori_app_get_trash (MidoriApp* app);
-
void
midori_app_quit (MidoriApp* app);
#include "midori-extension.h"
+#include "midori-app.h"
+
#include <katze/katze.h>
G_DEFINE_TYPE (MidoriExtension, midori_extension, G_TYPE_OBJECT);
PROP_AUTHORS
};
+enum {
+ ACTIVATE,
+
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL];
+
static void
midori_extension_finalize (GObject* object);
GObjectClass* gobject_class;
GParamFlags flags;
+ signals[ACTIVATE] = g_signal_new (
+ "activate",
+ G_TYPE_FROM_CLASS (class),
+ (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ 0,
+ 0,
+ NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ MIDORI_TYPE_APP);
+
gobject_class = G_OBJECT_CLASS (class);
gobject_class->finalize = midori_extension_finalize;
gobject_class->set_property = midori_extension_set_property;