[Xfce4-commits] <midori:master> Rewrite Midori.Viewable in Vala

Christian Dywan noreply at xfce.org
Sun May 27 16:32:01 CEST 2012


Updating branch refs/heads/master
         to a0a0325db40997953eace81065a7e5b8324ce78d (commit)
       from 85153f3b49875fd7f1ff5c462b441a14473bef64 (commit)

commit a0a0325db40997953eace81065a7e5b8324ce78d
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sun May 27 16:30:09 2012 +0200

    Rewrite Midori.Viewable in Vala

 midori/midori-panel.h       |    6 +--
 midori/midori-viewable.c    |  163 -------------------------------------------
 midori/midori-viewable.h    |   61 ----------------
 midori/midori-viewable.vala |   23 ++++++
 midori/midori.h             |    1 -
 panels/midori-bookmarks.c   |    2 +-
 panels/midori-extensions.c  |    1 -
 panels/midori-history.c     |    2 +-
 panels/midori-transfers.c   |    1 +
 panels/midori-transfers.h   |    6 +--
 10 files changed, 28 insertions(+), 238 deletions(-)

diff --git a/midori/midori-panel.h b/midori/midori-panel.h
index 8716667..c5cd275 100644
--- a/midori/midori-panel.h
+++ b/midori/midori-panel.h
@@ -12,11 +12,7 @@
 #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
index f17c305..0000000
--- a/midori/midori-viewable.c
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- Copyright (C) 2008 Christian Dywan <christian at 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
index 7e36c7b..0000000
--- a/midori/midori-viewable.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- Copyright (C) 2008 Christian Dywan <christian at 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
index 0000000..3fa177e
--- /dev/null
+++ b/midori/midori-viewable.vala
@@ -0,0 +1,23 @@
+/*
+ Copyright (C) 2008 Christian Dywan <christian at 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);
+    }
+}
+
diff --git a/midori/midori.h b/midori/midori.h
index a272938..2dace3d 100644
--- a/midori/midori.h
+++ b/midori/midori.h
@@ -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 */
diff --git a/panels/midori-bookmarks.c b/panels/midori-bookmarks.c
index 099e9d8..390ebae 100644
--- a/panels/midori-bookmarks.c
+++ b/panels/midori-bookmarks.c
@@ -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>
diff --git a/panels/midori-extensions.c b/panels/midori-extensions.c
index 0aec2be..c2bf899 100644
--- a/panels/midori-extensions.c
+++ b/panels/midori-extensions.c
@@ -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>
diff --git a/panels/midori-history.c b/panels/midori-history.c
index 7ec1717..d478971 100644
--- a/panels/midori-history.c
+++ b/panels/midori-history.c
@@ -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>
diff --git a/panels/midori-transfers.c b/panels/midori-transfers.c
index 1c8ca47..337e6ad 100644
--- a/panels/midori-transfers.c
+++ b/panels/midori-transfers.c
@@ -15,6 +15,7 @@
 #include "midori-browser.h"
 #include "midori-platform.h"
 #include "midori-view.h"
+#include "midori-core.h"
 
 #include <glib/gi18n.h>
 
diff --git a/panels/midori-transfers.h b/panels/midori-transfers.h
index 9778711..1174ac9 100644
--- a/panels/midori-transfers.h
+++ b/panels/midori-transfers.h
@@ -12,11 +12,7 @@
 #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
 


More information about the Xfce4-commits mailing list