[Xfce4-commits] <thunar:jannis/desktop-extensions> Add skeletons for ThunarxDesktopView and ThunarxDesktopViewProvider.

Jannis Pohlmann noreply at xfce.org
Sat Mar 26 01:30:02 CET 2011


Updating branch refs/heads/jannis/desktop-extensions
         to 206468dd3c4844b706d2afbc3cf167528e419831 (commit)
       from b2462b86611db859714bfda516e4e4b617acba14 (commit)

commit 206468dd3c4844b706d2afbc3cf167528e419831
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Sat Mar 26 01:28:05 2011 +0100

    Add skeletons for ThunarxDesktopView and ThunarxDesktopViewProvider.

 thunarx/Makefile.am                     |    4 +
 thunarx/thunarx-desktop-view-provider.c |  150 +++++++++++++++++++++++++++
 thunarx/thunarx-desktop-view-provider.h |   71 +++++++++++++
 thunarx/thunarx-desktop-view.c          |  171 +++++++++++++++++++++++++++++++
 thunarx/thunarx-desktop-view.h          |   82 +++++++++++++++
 5 files changed, 478 insertions(+), 0 deletions(-)

diff --git a/thunarx/Makefile.am b/thunarx/Makefile.am
index e6d052c..820f802 100644
--- a/thunarx/Makefile.am
+++ b/thunarx/Makefile.am
@@ -10,6 +10,8 @@ INCLUDES =								\
 libthunarx_headers =							\
 	thunarx.h							\
 	thunarx-config.h						\
+	thunarx-desktop-view-provider.h					\
+	thunarx-desktop-view.h						\
 	thunarx-file-info.h						\
 	thunarx-menu-provider.h						\
 	thunarx-preferences-provider.h					\
@@ -32,6 +34,8 @@ lib_LTLIBRARIES =							\
 libthunarx_2_la_SOURCES =						\
 	$(libthunarx_headers)						\
 	thunarx-config.c						\
+	thunarx-desktop-view-provider.c					\
+	thunarx-desktop-view.c						\
 	thunarx-file-info.c						\
 	thunarx-menu-provider.c						\
 	thunarx-preferences-provider.c					\
diff --git a/thunarx/thunarx-desktop-view-provider.c b/thunarx/thunarx-desktop-view-provider.c
new file mode 100644
index 0000000..e9ab453
--- /dev/null
+++ b/thunarx/thunarx-desktop-view-provider.c
@@ -0,0 +1,150 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * Copyright (c) 2011 Jannis Pohlmann <jannis at xfce.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General 
+ * Public License along with this library; if not, write to the 
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <thunarx/thunarx-desktop-view-provider.h>
+#include <thunarx/thunarx-desktop-view.h>
+#include <thunarx/thunarx-private.h>
+
+
+
+GType
+thunarx_desktop_view_provider_get_type (void)
+{
+  static volatile gsize type__volatile = 0;
+  GType                 type;
+  
+  if (g_once_init_enter (&type__volatile))
+    {
+      type = g_type_register_static_simple (G_TYPE_INTERFACE,
+                                            I_("ThunarxDesktopViewProvider"),
+                                            sizeof (ThunarxDesktopViewProviderIface),
+                                            NULL,
+                                            0,
+                                            NULL,
+                                            0);
+
+      g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
+
+      g_once_init_leave (&type__volatile, type);
+    }
+
+  return type__volatile;
+}
+
+
+
+/**
+ * thunarx_desktop_view_provider_get_view_infos:
+ * @provider : a #ThunarxDesktopViewProvider.
+ * 
+ * Returns a list of #ThunarxDesktopViewInfo<!---->s for the desktop views 
+ * @provider is offering.
+ *
+ * The caller is responsible to free the returned list of infos
+ * using something like this when no longer needed:
+ * <informalexample><programlisting>
+ * g_list_foreach (list, (GFunc) g_object_unref, NULL);
+ * g_list_free (list);
+ * </programlisting></informalexample>
+ *
+ * Return value: a list of #ThunarxDesktopViewInfo<!---->s for the desktop
+ *               views that @provider is offering.
+ **/
+GList *
+thunarx_desktop_view_provider_get_view_infos (ThunarxDesktopViewProvider *provider)
+{
+  GList *infos;
+
+  g_return_val_if_fail (THUNARX_IS_DESKTOP_VIEW_PROVIDER (provider), NULL);
+  
+  if (THUNARX_DESKTOP_VIEW_PROVIDER_GET_IFACE (provider)->get_view_infos != NULL)
+    {
+      /* query the view infos from the implementation */
+      infos = (*THUNARX_DESKTOP_VIEW_PROVIDER_GET_IFACE (provider)->get_view_infos) (provider);
+
+      /* TODO does it make sense to take a reference on the provider here to
+       * make sure the extension is kept loaded as long as we are using its
+       * view infos somewhere? */
+    }
+  else
+    {
+      infos = NULL;
+    }
+
+  return infos;
+}
+
+
+
+/**
+ * thunarx_desktop_view_provider_get_view:
+ * @provider : a #ThunarxDesktopViewProvider.
+ * @info     : a #ThunarxDesktopViewInfo.
+ * @folder   : a #ThunarxFolder.
+ * @error    : a return parameter to store error information in.
+ * 
+ * Returns a newly allocated #ThunarxDesktopView<!---->s for @info that
+ * uses @folder as the desktop folder. Returns %NULL and fills @error
+ * if the view cannot be created.
+ *
+ * The caller is responsible to free the returned view using something 
+ * like this when no longer needed:
+ * <informalexample><programlisting>
+ * g_object_unref (view);
+ * </programlisting></informalexample>
+ *
+ * Return value: a newly allocated #ThunarxDesktopView<!---->s for @info 
+ *               that uses @folder as the desktop folder. Returns %NULL
+ *               and fills @error in case the view cannot be created.
+ **/
+ThunarxDesktopView *
+thunarx_desktop_view_provider_get_view (ThunarxDesktopViewProvider *provider,
+                                        gpointer                    info,
+                                        GError                    **error)
+{
+  ThunarxDesktopView *view;
+
+  g_return_val_if_fail (THUNARX_IS_DESKTOP_VIEW_PROVIDER (provider), NULL);
+  g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+  
+  if (THUNARX_DESKTOP_VIEW_PROVIDER_GET_IFACE (provider)->get_view != NULL)
+    {
+      /* query the view infos from the implementation */
+      view = (*THUNARX_DESKTOP_VIEW_PROVIDER_GET_IFACE (provider)->get_view) (provider, 
+                                                                              info,
+                                                                              error);
+
+      /* TODO does it make sense to take a reference on the provider here to
+       * make sure the extension is kept loaded as long as we are using its
+       * views somewhere? */
+    }
+  else
+    {
+      view = NULL;
+
+      /* TODO set the error */
+    }
+
+  return view;
+}
diff --git a/thunarx/thunarx-desktop-view-provider.h b/thunarx/thunarx-desktop-view-provider.h
new file mode 100644
index 0000000..681c00d
--- /dev/null
+++ b/thunarx/thunarx-desktop-view-provider.h
@@ -0,0 +1,71 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * Copyright (c) 2011 Jannis Pohlmann <jannis at xfce.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General 
+ * Public License along with this library; if not, write to the 
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#if !defined(THUNARX_INSIDE_THUNARX_H) && !defined(THUNARX_COMPILATION)
+#error "Only <thunarx/thunarx.h> can be included directly, this file may disappear or change contents"
+#endif
+
+#ifndef __THUNARX_DESKTOP_VIEW_PROVIDER_H__
+#define __THUNARX_DESKTOP_VIEW_PROVIDER_H__
+
+#include <thunarx/thunarx-desktop-view.h>
+
+G_BEGIN_DECLS
+
+typedef struct _ThunarxDesktopViewProviderIface   ThunarxDesktopViewProviderIface;
+typedef struct _ThunarxDesktopViewProvider        ThunarxDesktopViewProvider;
+
+#define THUNARX_TYPE_DESKTOP_VIEW_PROVIDER           (thunarx_desktop_view_provider_get_type ())
+#define THUNARX_DESKTOP_VIEW_PROVIDER(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), THUNARX_TYPE_DESKTOP_VIEW_PROVIDER, ThunarxDesktopViewProvider))
+#define THUNARX_IS_DESKTOP_VIEW_PROVIDER(obj)        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THUNARX_TYPE_DESKTOP_VIEW_PROVIDER))
+#define THUNARX_DESKTOP_VIEW_PROVIDER_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), THUNARX_TYPE_DESKTOP_VIEW_PROVIDER, ThunarxDesktopViewProviderIface))
+
+struct _ThunarxDesktopViewProviderIface
+{
+  /*< private >*/
+  GTypeInterface __parent__;
+
+  /*< public >*/
+  GList              *(*get_view_infos) (ThunarxDesktopViewProvider *provider);
+
+  /* TODO add a ThunarxFolder parameter */
+  ThunarxDesktopView *(*get_view)       (ThunarxDesktopViewProvider *provider,
+                                         gpointer                    info,
+                                         GError                    **error);
+
+  /*< private >*/
+  void (*reserved1) (void);
+  void (*reserved2) (void);
+  void (*reserved3) (void);
+  void (*reserved4) (void);
+};
+
+GType               thunarx_desktop_view_provider_get_type       (void) G_GNUC_CONST;
+
+GList              *thunarx_desktop_view_provider_get_view_infos (ThunarxDesktopViewProvider *provider) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+
+/* TODO add a ThunarxFolder parameter */
+ThunarxDesktopView *thunarx_desktop_view_provider_get_view       (ThunarxDesktopViewProvider *provider,
+                                                                  gpointer                    info,
+                                                                  GError                    **error) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+
+G_END_DECLS
+
+#endif /* !__THUNARX_DESKTOP_VIEW_PROVIDER_H__ */
diff --git a/thunarx/thunarx-desktop-view.c b/thunarx/thunarx-desktop-view.c
new file mode 100644
index 0000000..6537ef0
--- /dev/null
+++ b/thunarx/thunarx-desktop-view.c
@@ -0,0 +1,171 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * Copyright (c) 2011 Jannis Pohlmann <jannis at xfce.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General 
+ * Public License along with this library; if not, write to the 
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib/gi18n-lib.h>
+
+#include <thunarx/thunarx-desktop-view.h>
+#include <thunarx/thunarx-private.h>
+
+
+
+#define THUNARX_DESKTOP_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), THUNARX_TYPE_DESKTOP_VIEW, ThunarxDesktopViewPrivate))
+
+
+
+/* Property identifiers */
+enum
+{
+  PROP_0,
+};
+
+/* Signal identifiers */
+enum
+{
+  LAST_SIGNAL,
+};
+
+
+
+static void     thunarx_desktop_view_finalize     (GObject                *object);
+static GObject *thunarx_desktop_view_constructor  (GType                   type,
+                                                   guint                   n_construct_properties,
+                                                   GObjectConstructParam  *construct_properties);
+static void     thunarx_desktop_view_get_property (GObject                *object,
+                                                   guint                   prop_id,
+                                                   GValue                 *value,
+                                                   GParamSpec             *pspec);
+static void     thunarx_desktop_view_set_property (GObject                *object,
+                                                   guint                   prop_id,
+                                                   const GValue           *value,
+                                                   GParamSpec             *pspec);
+
+
+
+struct _ThunarxDesktopViewPrivate
+{
+  int dummy;
+};
+
+
+
+#if 0
+static guint desktop_view_signals[LAST_SIGNAL];
+#endif
+
+
+
+G_DEFINE_ABSTRACT_TYPE (ThunarxDesktopView, thunarx_desktop_view, GTK_TYPE_WINDOW)
+
+
+
+static void
+thunarx_desktop_view_class_init (ThunarxDesktopViewClass *klass)
+{
+  GObjectClass *gobject_class;
+
+  /* add private data */
+  g_type_class_add_private (klass, sizeof (ThunarxDesktopViewPrivate));
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->finalize = thunarx_desktop_view_finalize;
+  gobject_class->constructor = thunarx_desktop_view_constructor;
+  gobject_class->get_property = thunarx_desktop_view_get_property;
+  gobject_class->set_property = thunarx_desktop_view_set_property;
+}
+
+
+
+static void
+thunarx_desktop_view_init (ThunarxDesktopView *desktop_view)
+{
+  /* grab a pointer on the private data */
+  desktop_view->priv = THUNARX_DESKTOP_VIEW_GET_PRIVATE (desktop_view);
+}
+
+
+
+static void
+thunarx_desktop_view_finalize (GObject *object)
+{
+#if 0
+  ThunarxDesktopView *desktop_view = THUNARX_DESKTOP_VIEW (object);
+#endif
+
+  (*G_OBJECT_CLASS (thunarx_desktop_view_parent_class)->finalize) (object);
+}
+
+
+
+static GObject*
+thunarx_desktop_view_constructor (GType                  type,
+                                  guint                  n_construct_properties,
+                                  GObjectConstructParam *construct_properties)
+{
+  GObject *object;
+
+  /* let the parent class constructor create the instance */
+  object = (*G_OBJECT_CLASS (thunarx_desktop_view_parent_class)->constructor) (type, n_construct_properties, construct_properties);
+
+  return object;
+}
+
+
+
+static void
+thunarx_desktop_view_get_property (GObject    *object,
+                                   guint       prop_id,
+                                   GValue     *value,
+                                   GParamSpec *pspec)
+{
+#if 0
+  ThunarxDesktopView *desktop_view = THUNARX_DESKTOP_VIEW (object);
+#endif
+
+  switch (prop_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+
+
+static void
+thunarx_desktop_view_set_property (GObject      *object,
+                                   guint         prop_id,
+                                   const GValue *value,
+                                   GParamSpec   *pspec)
+{
+#if 0
+  ThunarxDesktopView *desktop_view = THUNARX_DESKTOP_VIEW (object);
+#endif
+
+  switch (prop_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
diff --git a/thunarx/thunarx-desktop-view.h b/thunarx/thunarx-desktop-view.h
new file mode 100644
index 0000000..de1bf1a
--- /dev/null
+++ b/thunarx/thunarx-desktop-view.h
@@ -0,0 +1,82 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * Copyright (c) 2011 Jannis Pohlmann <jannis at xfce.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General 
+ * Public License along with this library; if not, write to the 
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#if !defined(THUNARX_INSIDE_THUNARX_H) && !defined(THUNARX_COMPILATION)
+#error "Only <thunarx/thunarx.h> can be included directly, this file may disappear or change contents"
+#endif
+
+#ifndef __THUNARX_DESKTOP_VIEW_H__
+#define __THUNARX_DESKTOP_VIEW_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+typedef struct _ThunarxDesktopViewPrivate ThunarxDesktopViewPrivate;
+typedef struct _ThunarxDesktopViewClass   ThunarxDesktopViewClass;
+typedef struct _ThunarxDesktopView        ThunarxDesktopView;
+
+#define THUNARX_TYPE_DESKTOP_VIEW            (thunarx_desktop_view_get_type ())
+#define THUNARX_DESKTOP_VIEW(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), THUNARX_TYPE_DESKTOP_VIEW, ThunarxDesktopView))
+#define THUNARX_DESKTOP_VIEW_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), THUNARX_TYPE_DESKTOP_VIEW, ThunarxDesktopViewClass))
+#define THUNARX_IS_DESKTOP_VIEW(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THUNARX_TYPE_DESKTOP_VIEW))
+#define THUNARX_IS_DESKTOP_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), THUNARX_TYPE_DESKTOP_VIEW))
+#define THUNARX_DESKTOP_VIEW_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), THUNARX_TYPE_DESKTOP_VIEW, ThunarxDesktopViewClass))
+
+struct _ThunarxDesktopViewClass
+{
+  /*< private >*/
+  GtkWindowClass __parent__;
+
+  /*< public >*/
+
+  /* virtual methods */
+
+  /*< private >*/
+  void (*reserved0) (void);
+  void (*reserved1) (void);
+  void (*reserved2) (void);
+  void (*reserved3) (void);
+  void (*reserved4) (void);
+
+  /*< public >*/
+
+  /* signals */
+
+  /*< private >*/
+  void (*reserved6) (void);
+  void (*reserved7) (void);
+  void (*reserved8) (void);
+  void (*reserved9) (void);
+};
+
+struct _ThunarxDesktopView
+{
+  GtkWindow __parent__;
+
+  /*< private >*/
+  ThunarxDesktopViewPrivate *priv;
+};
+
+GType        thunarx_desktop_view_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* !__THUNARX_DESKTOP_VIEW_H__ */



More information about the Xfce4-commits mailing list