]> spindle.queued.net Git - midori/commitdiff
Rewrite Midori.Viewable in Vala
authorChristian Dywan <christian@twotoasts.de>
Sun, 27 May 2012 14:30:09 +0000 (16:30 +0200)
committerChristian Dywan <christian@twotoasts.de>
Sun, 27 May 2012 14:30:09 +0000 (16:30 +0200)
midori/midori-panel.h
midori/midori-viewable.c [deleted file]
midori/midori-viewable.h [deleted file]
midori/midori-viewable.vala [new file with mode: 0644]
midori/midori.h
panels/midori-bookmarks.c
panels/midori-extensions.c
panels/midori-history.c
panels/midori-transfers.c
panels/midori-transfers.h

index 87166674def0c68371c0573822387bf6e6039936..c5cd27565a40bf45a399c9590dae677c1e125ede 100644 (file)
 #ifndef __MIDORI_PANEL_H__
 #define __MIDORI_PANEL_H__
 
-#include <gtk/gtk.h>
-
-#include <katze/katze.h>
-
-#include "midori-viewable.h"
+#include "midori-core.h"
 
 G_BEGIN_DECLS
 
diff --git a/midori/midori-viewable.c b/midori/midori-viewable.c
deleted file mode 100644 (file)
index f17c305..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- 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>
-
-enum {
-    POPULATE_OPTION_MENU,
-
-    LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-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;
-
-    /**
-     * MidoriViewable::populate-option-menu:
-     * @viewable: the object on which the signal is emitted
-     * @menu: the #GtkMenu to populate
-     *
-     * Emitted when an Option menu is displayed, for instance
-     * when the user clicks the Options button in the panel.
-     *
-     * Deprecated: 0.2.3
-     */
-    signals[POPULATE_OPTION_MENU] = g_signal_new (
-        "populate-option-menu",
-        G_TYPE_FROM_INTERFACE (iface),
-        (GSignalFlags)(G_SIGNAL_RUN_LAST),
-        0,
-        0,
-        NULL,
-        g_cclosure_marshal_VOID__OBJECT,
-        G_TYPE_NONE, 1,
-        GTK_TYPE_MENU);
-
-    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)
-{
-}
-
-/**
- * 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_toolbar_new ();
-    return toolbar;
-}
diff --git a/midori/midori-viewable.h b/midori/midori-viewable.h
deleted file mode 100644 (file)
index 7e36c7b..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- 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 <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);
-};
-
-GType
-midori_viewable_get_type               (void) G_GNUC_CONST;
-
-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__ */
diff --git a/midori/midori-viewable.vala b/midori/midori-viewable.vala
new file mode 100644 (file)
index 0000000..3fa177e
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ 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.
+*/
+
+namespace Midori {
+    public interface Viewable {
+        public abstract unowned string get_stock_id ();
+        public abstract unowned string get_label ();
+        public abstract Gtk.Widget get_toolbar ();
+        /* Emitted when an Option menu is displayed, for instance
+         * when the user clicks the Options button in the panel.
+         * Deprecated: 0.2.3 */
+        public signal void populate_option_menu (Gtk.Menu menu);
+    }
+}
+
index a272938f9fb1dc75e3ae26a7089ad8786967513e..2dace3d6be8a7e7c2f3401ce0b3cd2df30548905 100644 (file)
@@ -22,7 +22,6 @@
 #include "midori-preferences.h"
 #include "midori-searchaction.h"
 #include "midori-view.h"
-#include "midori-viewable.h"
 #include "midori-websettings.h"
 #include "midori-platform.h"
 #include <midori/midori-core.h> /* Vala API */
index 099e9d8051503d3fda3c784fc3745cbb76653268..390ebae418b8b2a840afb44ad558dcf524ff8dc6 100644 (file)
@@ -16,7 +16,7 @@
 #include "midori-browser.h"
 #include "midori-platform.h"
 #include "midori-view.h"
-#include "midori-viewable.h"
+#include "midori-core.h"
 
 #include <glib/gi18n.h>
 #include <string.h>
index 0aec2be07492ebc3c891f6718b60cb6a6ed25eb4..c2bf899c050b591e2dca3b2b19a3d0a316cba1ee 100644 (file)
@@ -14,7 +14,6 @@
 #include "midori-app.h"
 #include "midori-extension.h"
 #include "midori-platform.h"
-#include "midori-viewable.h"
 #include "midori-core.h"
 
 #include <glib/gi18n.h>
index 7ec1717f871a433fe2404dd0f8f8a80795c35ca8..d478971e5e7145ece742bef3a7d026ff62bed94e 100644 (file)
@@ -16,7 +16,7 @@
 #include "midori-browser.h"
 #include "midori-platform.h"
 #include "midori-view.h"
-#include "midori-viewable.h"
+#include "midori-core.h"
 
 #include <glib/gi18n.h>
 #include <string.h>
index 1c8ca47077f68ee7e5cafbf78b8a316216081821..337e6ad9e28ab03b0f3f89fb684f131a3967df69 100644 (file)
@@ -15,6 +15,7 @@
 #include "midori-browser.h"
 #include "midori-platform.h"
 #include "midori-view.h"
+#include "midori-core.h"
 
 #include <glib/gi18n.h>
 
index 977871159e299c74a53ab33153762937aef8d12f..1174ac9cce6b78c33303eed299acf1e0c2536ad2 100644 (file)
 #ifndef __MIDORI_TRANSFERS_H__
 #define __MIDORI_TRANSFERS_H__
 
-#include <gtk/gtk.h>
-
-#include <katze/katze.h>
-
-#include "midori-viewable.h"
+#include "midori-core.h"
 
 G_BEGIN_DECLS