Commit 7e2605c6 authored by Ernestas Kulik's avatar Ernestas Kulik 🦑

general: refactor extension library

The changes include:

  * adding a single-include header and deprecating
    nautilus-extension-types.h and direct inclusions of individual
    headers;

  * type definition simplifications - this causes some breakages in
    nautilus-file, because NautilusFile used to be typedefed to
    NautilusFileInfo, and that is no longer possible, so the interface
    implementation was moved to static functions and the public
    NautilusFile API provides thin wrappers for them to maintain
    compatibility;

  * documentation cleanups and reorganization;

  * general build rule and code cleanups: mostly g_auto* sprinkled
    around and style changes (sorry)
parent 2128efcc
......@@ -14,19 +14,24 @@
<part>
<title>API Reference</title>
<chapter>
<title>Core Classes</title>
<xi:include href="xml/nautilus-column.xml" />
<xi:include href="xml/nautilus-file-info.xml" />
<xi:include href="xml/nautilus-menu.xml" />
<xi:include href="xml/nautilus-menu-item.xml" />
<xi:include href="xml/nautilus-property-page.xml" />
</chapter>
<xi:include href="xml/nautilus-extension.xml" />
<chapter>
<title>Extension Interfaces</title>
<xi:include href="xml/nautilus-column-provider.xml" />
<xi:include href="xml/nautilus-column.xml" />
<xi:include href="xml/nautilus-extension-types.xml" />
<xi:include href="xml/nautilus-file-info.xml" />
<xi:include href="xml/nautilus-info-provider.xml" />
<xi:include href="xml/nautilus-location-widget-provider.xml" />
<xi:include href="xml/nautilus-menu-provider.xml" />
<xi:include href="xml/nautilus-menu.xml" />
<xi:include href="xml/nautilus-menu-item.xml" />
<xi:include href="xml/nautilus-property-page-provider.xml" />
<xi:include href="xml/nautilus-property-page.xml" />
</chapter>
</part>
......
<INCLUDE>nautilus-extension.h</INCLUDE>
<SECTION>
<FILE>nautilus-extension</FILE>
nautilus_module_initialize
nautilus_module_shutdown
nautilus_module_list_types
</SECTION>
<SECTION>
<FILE>nautilus-location-widget-provider</FILE>
NautilusLocationWidgetProvider
NautilusLocationWidgetProviderIface
NautilusLocationWidgetProviderInterface
nautilus_location_widget_provider_get_widget
<SUBSECTION Standard>
NAUTILUS_LOCATION_WIDGET_PROVIDER
NAUTILUS_IS_LOCATION_WIDGET_PROVIDER
NAUTILUS_TYPE_LOCATION_WIDGET_PROVIDER
nautilus_location_widget_provider_get_type
NAUTILUS_LOCATION_WIDGET_PROVIDER_GET_IFACE
</SECTION>
<SECTION>
<FILE>nautilus-menu-provider</FILE>
NautilusMenuProvider
NautilusMenuProviderIface
NautilusMenuProviderInterface
nautilus_menu_provider_get_file_items
nautilus_menu_provider_get_background_items
nautilus_menu_provider_emit_items_updated_signal
<SUBSECTION Standard>
NAUTILUS_MENU_PROVIDER
NAUTILUS_IS_MENU_PROVIDER
NAUTILUS_TYPE_MENU_PROVIDER
nautilus_menu_provider_get_type
NAUTILUS_MENU_PROVIDER_GET_IFACE
</SECTION>
<SECTION>
<FILE>nautilus-menu</FILE>
NautilusMenuPrivate
NautilusMenu
nautilus_menu_new
nautilus_menu_append_item
nautilus_menu_get_items
<SUBSECTION Standard>
NAUTILUS_MENU
NAUTILUS_IS_MENU
NAUTILUS_TYPE_MENU
nautilus_menu_get_type
NAUTILUS_MENU_CLASS
NAUTILUS_IS_MENU_CLASS
NAUTILUS_MENU_GET_CLASS
</SECTION>
<SECTION>
......@@ -51,40 +39,20 @@ nautilus_menu_item_get_type
nautilus_menu_item_new
nautilus_menu_item_activate
nautilus_menu_item_set_submenu
<SUBSECTION Standard>
NAUTILUS_TYPE_MENU_ITEM
NAUTILUS_MENU_ITEM
NAUTILUS_MENU_ITEM_CLASS
NAUTILUS_MENU_IS_ITEM
NAUTILUS_MENU_IS_ITEM_CLASS
NAUTILUS_MENU_ITEM_GET_CLASS
NautilusMenuItemDetails
</SECTION>
<SECTION>
<FILE>nautilus-column-provider</FILE>
NautilusColumnProvider
NautilusColumnProviderIface
NautilusColumnProviderInterface
nautilus_column_provider_get_columns
<SUBSECTION Standard>
NAUTILUS_COLUMN_PROVIDER
NAUTILUS_IS_COLUMN_PROVIDER
NAUTILUS_TYPE_COLUMN_PROVIDER
nautilus_column_provider_get_type
NAUTILUS_COLUMN_PROVIDER_GET_IFACE
</SECTION>
<SECTION>
<FILE>nautilus-property-page-provider</FILE>
NautilusPropertyPageProvider
NautilusPropertyPageProviderIface
NautilusPropertyPageProviderInterface
nautilus_property_page_provider_get_pages
<SUBSECTION Standard>
NAUTILUS_PROPERTY_PAGE_PROVIDER
NAUTILUS_IS_PROPERTY_PAGE_PROVIDER
NAUTILUS_TYPE_PROPERTY_PAGE_PROVIDER
nautilus_property_page_provider_get_type
NAUTILUS_PROPERTY_PAGE_PROVIDER_GET_IFACE
</SECTION>
<SECTION>
......@@ -92,7 +60,7 @@ NAUTILUS_PROPERTY_PAGE_PROVIDER_GET_IFACE
NAUTILUS_FILE_DEFINED
NautilusFile
NautilusFileInfo
NautilusFileInfoIface
NautilusFileInfoInterface
nautilus_file_info_create
nautilus_file_info_create_for_uri
nautilus_file_info_lookup
......@@ -118,68 +86,28 @@ nautilus_file_info_add_emblem
nautilus_file_info_get_string_attribute
nautilus_file_info_add_string_attribute
nautilus_file_info_invalidate_extension_info
<SUBSECTION Standard>
NAUTILUS_FILE_INFO
NAUTILUS_IS_FILE_INFO
NAUTILUS_TYPE_FILE_INFO
nautilus_file_info_get_type
NAUTILUS_FILE_INFO_GET_IFACE
</SECTION>
<SECTION>
<FILE>nautilus-column</FILE>
NautilusColumn
nautilus_column_new
<SUBSECTION Standard>
NAUTILUS_COLUMN
NAUTILUS_INFO_IS_COLUMN
NAUTILUS_TYPE_COLUMN
nautilus_column_get_type
NAUTILUS_COLUMN_CLASS
NAUTILUS_INFO_IS_COLUMN_CLASS
NAUTILUS_COLUMN_GET_CLASS
NautilusColumnDetails
</SECTION>
<SECTION>
<FILE>nautilus-info-provider</FILE>
NautilusInfoProvider
NautilusInfoProviderIface
NautilusInfoProviderUpdateComplete
NautilusInfoProviderInterface
NautilusOperationHandle
NautilusOperationResult
nautilus_info_provider_update_file_info
nautilus_info_provider_cancel_update
nautilus_info_provider_update_complete_invoke
<SUBSECTION Standard>
NAUTILUS_TYPE_OPERATION_RESULT
nautilus_operation_result_get_type
NAUTILUS_INFO_PROVIDER
NAUTILUS_IS_INFO_PROVIDER
NAUTILUS_TYPE_INFO_PROVIDER
nautilus_info_provider_get_type
NAUTILUS_INFO_PROVIDER_GET_IFACE
</SECTION>
<SECTION>
<FILE>nautilus-property-page</FILE>
NautilusPropertyPage
nautilus_property_page_new
<SUBSECTION Standard>
NAUTILUS_PROPERTY_PAGE
NAUTILUS_IS_PROPERTY_PAGE
NAUTILUS_TYPE_PROPERTY_PAGE
nautilus_property_page_get_type
NAUTILUS_PROPERTY_PAGE_CLASS
NAUTILUS_IS_PROPERTY_PAGE_CLASS
NAUTILUS_PROPERTY_PAGE_GET_CLASS
NautilusPropertyPageDetails
</SECTION>
<SECTION>
<FILE>nautilus-extension-types</FILE>
nautilus_module_initialize
nautilus_module_shutdown
nautilus_module_list_types
</SECTION>
nautilus_extension_version = '1.4.0'
nautilus_extension_version = '1.5.0'
libnautilus_extension_deprecated_headers = [
'nautilus-extension-types.h',
'nautilus-menu-item.h'
]
libnautilus_extension_headers = [
'nautilus-column-provider.h',
'nautilus-column.h',
'nautilus-extension-types.h',
'nautilus-file-info.h',
'nautilus-info-provider.h',
'nautilus-location-widget-provider.h',
'nautilus-menu-item.h',
'nautilus-menu-provider.h',
'nautilus-property-page-provider.h',
'nautilus-property-page.h',
'nautilus-menu.h'
]
install_headers(
'nautilus-extension.h',
subdir: 'nautilus'
)
install_headers(
libnautilus_extension_headers,
libnautilus_extension_deprecated_headers,
subdir: join_paths('nautilus', 'libnautilus-extension')
)
libnautilus_extension_sources = [
gnome.mkenums_simple(
'nautilus-extension-enum-types',
install_header: true,
install_dir: join_paths(includedir, 'nautilus', 'libnautilus-extension'),
sources: [
'nautilus-info-provider.h'
]
),
libnautilus_extension_headers,
'nautilus-column-provider.c',
'nautilus-column.c',
'nautilus-extension-types.c',
'nautilus-extension.h',
'nautilus-extension-private.h',
'nautilus-file-info.c',
'nautilus-info-provider.c',
......@@ -40,8 +57,13 @@ libnautilus_extension_deps = [
]
libnautilus_extension = shared_library(
'nautilus-extension',
libnautilus_extension_sources,
'nautilus-extension', [
libnautilus_extension_deprecated_headers,
libnautilus_extension_sources,
],
c_args: [
'-DNAUTILUS_COMPILATION'
],
dependencies: libnautilus_extension_deps,
include_directories: nautilus_include_dirs,
version: nautilus_extension_version,
......@@ -50,10 +72,10 @@ libnautilus_extension = shared_library(
gnome.generate_gir(
libnautilus_extension,
sources: [
libnautilus_extension_headers,
libnautilus_extension_sources
extra_args: [
'-DNAUTILUS_COMPILATION'
],
sources: libnautilus_extension_sources,
nsversion: '3.0',
namespace: 'Nautilus',
includes: [
......@@ -61,6 +83,7 @@ gnome.generate_gir(
'Gio-2.0',
'GLib-2.0'
],
header: 'nautilus-extension.h',
install: true
)
......
......@@ -21,55 +21,24 @@
*
*/
#include <config.h>
#include "nautilus-column-provider.h"
#include <glib-object.h>
G_DEFINE_INTERFACE (NautilusColumnProvider, nautilus_column_provider, G_TYPE_OBJECT)
/**
* SECTION:nautilus-column-provider
* @title: NautilusColumnProvider
* @short_description: Interface to provide additional list view columns
* @include: libnautilus-extension/nautilus-column-provider.h
*
* #NautilusColumnProvider allows extension to provide additional columns
* in the file manager list view.
*/
static void
nautilus_column_provider_base_init (gpointer g_class)
nautilus_column_provider_default_init (NautilusColumnProviderInterface *klass)
{
}
GType
nautilus_column_provider_get_type (void)
{
static GType type = 0;
if (!type)
{
const GTypeInfo info =
{
sizeof (NautilusColumnProviderIface),
nautilus_column_provider_base_init,
NULL,
NULL,
NULL,
NULL,
0,
0,
NULL
};
type = g_type_register_static (G_TYPE_INTERFACE,
"NautilusColumnProvider",
&info, 0);
g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
}
return type;
}
/**
* nautilus_column_provider_get_columns:
* @provider: a #NautilusColumnProvider
......@@ -77,11 +46,15 @@ nautilus_column_provider_get_type (void)
* Returns: (element-type NautilusColumn) (transfer full): the provided #NautilusColumn objects
*/
GList *
nautilus_column_provider_get_columns (NautilusColumnProvider *provider)
nautilus_column_provider_get_columns (NautilusColumnProvider *self)
{
g_return_val_if_fail (NAUTILUS_IS_COLUMN_PROVIDER (provider), NULL);
g_return_val_if_fail (NAUTILUS_COLUMN_PROVIDER_GET_IFACE (provider)->get_columns != NULL, NULL);
NautilusColumnProviderInterface *iface;
g_return_val_if_fail (NAUTILUS_IS_COLUMN_PROVIDER (self), NULL);
iface = NAUTILUS_COLUMN_PROVIDER_GET_IFACE (self);
g_return_val_if_fail (iface->get_columns != NULL, NULL);
return NAUTILUS_COLUMN_PROVIDER_GET_IFACE (provider)->get_columns
(provider);
return iface->get_columns (self);
}
......@@ -30,37 +30,40 @@
#ifndef NAUTILUS_COLUMN_PROVIDER_H
#define NAUTILUS_COLUMN_PROVIDER_H
#if !defined (NAUTILUS_EXTENSION_H) && !defined (NAUTILUS_COMPILATION)
#warning "Only <nautilus-extension.h> should be included directly."
#endif
#include <glib-object.h>
#include "nautilus-extension-types.h"
#include "nautilus-column.h"
G_BEGIN_DECLS
#define NAUTILUS_TYPE_COLUMN_PROVIDER (nautilus_column_provider_get_type ())
#define NAUTILUS_COLUMN_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_COLUMN_PROVIDER, NautilusColumnProvider))
#define NAUTILUS_IS_COLUMN_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_COLUMN_PROVIDER))
#define NAUTILUS_COLUMN_PROVIDER_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NAUTILUS_TYPE_COLUMN_PROVIDER, NautilusColumnProviderIface))
#define NAUTILUS_TYPE_COLUMN_PROVIDER (nautilus_column_provider_get_type ())
G_DECLARE_INTERFACE (NautilusColumnProvider, nautilus_column_provider,
NAUTILUS, COLUMN_PROVIDER,
GObject)
typedef struct _NautilusColumnProvider NautilusColumnProvider;
typedef struct _NautilusColumnProviderIface NautilusColumnProviderIface;
/* For compatibility reasons, remove this once you start introducing breaking changes. */
typedef NautilusColumnProviderInterface NautilusColumnProviderIface;
/**
* NautilusColumnProviderIface:
* NautilusColumnProviderInterface:
* @g_iface: The parent interface.
* @get_columns: Returns a #GList of #NautilusColumn.
* See nautilus_column_provider_get_columns() for details.
*
* Interface for extensions to provide additional list view columns.
*/
struct _NautilusColumnProviderIface {
GTypeInterface g_iface;
struct _NautilusColumnProviderInterface
{
GTypeInterface g_iface;
GList *(*get_columns) (NautilusColumnProvider *provider);
GList *(*get_columns) (NautilusColumnProvider *provider);
};
/* Interface Functions */
GType nautilus_column_provider_get_type (void);
GList *nautilus_column_provider_get_columns (NautilusColumnProvider *provider);
GList *nautilus_column_provider_get_columns (NautilusColumnProvider *provider);
G_END_DECLS
......
......@@ -21,8 +21,6 @@
*
*/
#include <config.h>
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include "nautilus-column.h"
......@@ -39,8 +37,10 @@ enum
LAST_PROP
};
struct _NautilusColumnDetails
struct _NautilusColumn
{
GObject parent_instance;
char *name;
GQuark attribute;
char *label;
......@@ -55,7 +55,6 @@ G_DEFINE_TYPE (NautilusColumn, nautilus_column, G_TYPE_OBJECT);
* SECTION:nautilus-column
* @title: NautilusColumn
* @short_description: List view column descriptor object
* @include: libnautilus-extension/nautilus-column.h
*
* #NautilusColumn is an object that describes a column in the file manager
* list view. Extensions can provide #NautilusColumn by registering a
......@@ -112,43 +111,43 @@ nautilus_column_get_property (GObject *object,
{
case PROP_NAME:
{
g_value_set_string (value, column->details->name);
g_value_set_string (value, column->name);
}
break;
case PROP_ATTRIBUTE:
{
g_value_set_string (value, g_quark_to_string (column->details->attribute));
g_value_set_string (value, g_quark_to_string (column->attribute));
}
break;
case PROP_ATTRIBUTE_Q:
{
g_value_set_uint (value, column->details->attribute);
g_value_set_uint (value, column->attribute);
}
break;
case PROP_LABEL:
{
g_value_set_string (value, column->details->label);
g_value_set_string (value, column->label);
}
break;
case PROP_DESCRIPTION:
{
g_value_set_string (value, column->details->description);
g_value_set_string (value, column->description);
}
break;
case PROP_XALIGN:
{
g_value_set_float (value, column->details->xalign);
g_value_set_float (value, column->xalign);
}
break;
case PROP_DEFAULT_SORT_ORDER:
{
g_value_set_enum (value, column->details->default_sort_order);
g_value_set_enum (value, column->default_sort_order);
}
break;
......@@ -174,15 +173,15 @@ nautilus_column_set_property (GObject *object,
{
case PROP_NAME:
{
g_free (column->details->name);
column->details->name = g_strdup (g_value_get_string (value));
g_free (column->name);
column->name = g_strdup (g_value_get_string (value));
g_object_notify (object, "name");
}
break;
case PROP_ATTRIBUTE:
{
column->details->attribute = g_quark_from_string (g_value_get_string (value));
column->attribute = g_quark_from_string (g_value_get_string (value));
g_object_notify (object, "attribute");
g_object_notify (object, "attribute_q");
}
......@@ -190,30 +189,30 @@ nautilus_column_set_property (GObject *object,
case PROP_LABEL:
{
g_free (column->details->label);
column->details->label = g_strdup (g_value_get_string (value));
g_free (column->label);
column->label = g_strdup (g_value_get_string (value));
g_object_notify (object, "label");
}
break;
case PROP_DESCRIPTION:
{
g_free (column->details->description);
column->details->description = g_strdup (g_value_get_string (value));
g_free (column->description);
column->description = g_strdup (g_value_get_string (value));
g_object_notify (object, "description");
}
break;
case PROP_XALIGN:
{
column->details->xalign = g_value_get_float (value);
column->xalign = g_value_get_float (value);
g_object_notify (object, "xalign");
}
break;
case PROP_DEFAULT_SORT_ORDER:
{
column->details->default_sort_order = g_value_get_enum (value);
column->default_sort_order = g_value_get_enum (value);
g_object_notify (object, "default-sort-order");
}
break;
......@@ -233,11 +232,9 @@ nautilus_column_finalize (GObject *object)
column = NAUTILUS_COLUMN (object);
g_free (column->details->name);
g_free (column->details->label);
g_free (column->details->description);
g_free (column->details);
g_free (column->name);
g_free (column->label);
g_free (column->description);
G_OBJECT_CLASS (nautilus_column_parent_class)->finalize (object);
}
......@@ -245,8 +242,7 @@ nautilus_column_finalize (GObject *object)
static void
nautilus_column_init (NautilusColumn *column)
{
column->details = g_new0 (NautilusColumnDetails, 1);
column->details->xalign = 0.0;
column->xalign = 0.0;
}
static void
......
......@@ -24,37 +24,22 @@
#ifndef NAUTILUS_COLUMN_H
#define NAUTILUS_COLUMN_H
#if !defined (NAUTILUS_EXTENSION_H) && !defined (NAUTILUS_COMPILATION)
#warning "Only <nautilus-extension.h> should be included directly."
#endif
#include <glib-object.h>
#include "nautilus-extension-types.h"
G_BEGIN_DECLS
#define NAUTILUS_TYPE_COLUMN (nautilus_column_get_type())
#define NAUTILUS_COLUMN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_COLUMN, NautilusColumn))
#define NAUTILUS_COLUMN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_COLUMN, NautilusColumnClass))
#define NAUTILUS_INFO_IS_COLUMN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_COLUMN))
#define NAUTILUS_INFO_IS_COLUMN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NAUTILUS_TYPE_COLUMN))
#define NAUTILUS_COLUMN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), NAUTILUS_TYPE_COLUMN, NautilusColumnClass))
typedef struct _NautilusColumn NautilusColumn;
typedef struct _NautilusColumnDetails NautilusColumnDetails;
typedef struct _NautilusColumnClass NautilusColumnClass;
struct _NautilusColumn {
GObject parent;
NautilusColumnDetails *details;
};
#define NAUTILUS_TYPE_COLUMN (nautilus_column_get_type())
struct _NautilusColumnClass {
GObjectClass parent;
};
G_DECLARE_FINAL_TYPE (NautilusColumn, nautilus_column, NAUTILUS, COLUMN, GObject)
GType nautilus_column_get_type (void);
NautilusColumn * nautilus_column_new (const char *name,
const char *attribute,
const char *label,
const char *description);
NautilusColumn *nautilus_column_new (const char *name,
const char *attribute,
const char *label,
const char *description);
/* NautilusColumn has the following properties:
* name (string) - the identifier for the column
......
/*
* nautilus-extension-types.c - Type definitions for Nautilus extensions
*
* Copyright (C) 2003 Novell, Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Author: Dave Camp <dave@ximian.com>
*
*/
#include <config.h>
#include "nautilus-extension-types.h"
GType
nautilus_operation_result_get_type (void)
{
static GType type = 0;
if (type == 0)
{
static const GEnumValue values[] =
{
{
NAUTILUS_OPERATION_COMPLETE,
"NAUTILUS_OPERATION_COMPLETE",
"complete",
},
{
NAUTILUS_OPERATION_FAILED,
"NAUTILUS_OPERATION_FAILED",
"failed",
},
{
NAUTILUS_OPERATION_IN_PROGRESS,
"NAUTILUS_OPERATION_IN_PROGRESS",
"in_progress",
},
{ 0, NULL, NULL }
};
type = g_enum_register_static ("NautilusOperationResult",
values);
}
return type;
}
/*
* nautilus-info-provider.h - Type definitions for Nautilus extensions
*
/* nautilus-info-provider.h - Type definitions for Nautilus extensions
*
* Copyright (C) 2003 Novell, Inc.
*
* This library is free software; you can redistribute it and/or
......@@ -17,7 +16,7 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
* Author: Dave Camp <dave@ximian.com>
*
*
*/
/* This interface is implemented by Nautilus extensions that want to
......@@ -28,64 +27,8 @@
#ifndef NAUTILUS_EXTENSION_TYPES_H
#define NAUTILUS_EXTENSION_TYPES_H
#include <glib-object.h>
G_BEGIN_DECLS
#define NAUTILUS_TYPE_OPERATION_RESULT (nautilus_operation_result_get_type ())
/**
* NautilusOperationHandle:
*
* Handle for asynchronous interfaces. These are opaque handles that must
* be unique within an extension object. These are returned by operations
* that return #NAUTILUS_OPERATION_IN_PROGRESS.