Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7899837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:48:43+00:00 2026-06-03T08:48:43+00:00

I’m trying to create a Nautilus extension in C, but there are just Python

  • 0

I’m trying to create a Nautilus extension in C, but there are just Python examples and helps.

Almost no documentation and literally no examples, but just some complete extensions which are long and hard to understand for a beginner.

I need just a simple sample code that creates a new column in Nautilus’s list view. How to write and compile it.

The code I’ve tried is:

#include <libnautilus-extension/nautilus-column-provider.h>

typedef struct _FooExtension FooExtension;
typedef struct _FooExtensionClass FooExtensionClass;

struct _FooExtension
{
    GObject parent_slot;
};

struct _FooExtensionClass
{
    GObjectClass parent_slot;
};

static void foo_extension_class_init    (FooExtensionClass *class);
static void foo_extension_instance_init (FooExtension      *img);

static void foo_extension_class_init(FooExtensionClass *class)
{
}

static void foo_extension_instance_init(FooExtension *img)
{
}

static GType provider_types[1];

static GType foo_extension_type;

static void foo_extension_register_type(GTypeModule *module)
{
    static const GTypeInfo info = {
                sizeof(FooExtensionClass),
                (GBaseInitFunc) NULL,
                (GBaseFinalizeFunc) NULL,
                (GClassInitFunc) foo_extension_class_init,
                NULL,
                NULL,
                sizeof (FooExtension),
                0,
                (GInstanceInitFunc) foo_extension_instance_init,
                };
    foo_extension_type = g_type_module_register_type(module,
                              G_TYPE_OBJECT,
                              "FooExtension",
                              &info, 0);
        /* ... add interfaces ... */
}

GType foo_extension_get_type(void)
{
    return foo_extension_type;
}

static GList *foo_extension_get_columns(NautilusColumnProvider *provider)
{
    NautilusColumn *column;
    GList *ret;
    column = nautilus_column_new("FooExtension::foo_data_column", "FooExtension::foo_data", "Foo Data", "Foo Description");
/*                    _("Foo Data"),
                      _("Information from the Foo Extension"));*/
    ret = g_list_append(NULL, column);
    return ret;
}

void nautilus_module_initialize (GTypeModule  *module)
{
    foo_extension_register_type(module);
    provider_types[0] = foo_extension_get_type();
}

void nautilus_module_shutdown(void)
{
    /* Any module-specific shutdown */
}

void nautilus_module_list_types (const GType **types, int *num_types)
{
    *types = provider_types;
    *num_types = G_N_ELEMENTS (provider_types);
}

and I’ve built it with:

gcc-c foo_extension.c -o foo_extension.o -fPIC $(pkg-config libnautilus-extension --libs --cflags)
gcc -shared foo_extension.o -o foo_extension.so $(pkg-config libnautilus-extension --libs --cflags)

and I copied it into /usr/lib/nautilus/extensions-2.0/, then I tried nautilus -q but it doesn’t work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T08:48:44+00:00Added an answer on June 3, 2026 at 8:48 am

    You can also retrieve the documentation pointed in Nautilus Extension’s wiki from the copy in archive.org. The copy in archive.org has examples in C.

    EDIT: I added a complete working example, as well as as an explanation of the missing parts in your code.

    You are missing two things:

    1. Add the interfaces. For the column provider would be foo_extension_column_provider_iface_init, and there you need to associate the link the interfaces expected with your implementation. In this particular case get_columns.
    2. With the previous one, you would get only a column but with unknown value for each file. Therefore, you have to use the InfoProvider, too. In particular, the interface update_file_info. In that interface you can associate the attribute for your column with each file through nautilus_file_info_add_string_attribute.

    Below you have a working example. Beware NautilusFileInfoProvider is part of Nautilus’ asynchronous IO system. Hence, if the operations are slow, you will block Nautilus. In the example below I just set a fixed string per file (“Foo“). However, if you need to collect other information, you should implement also the arguments update_complete and handle, and the cancel_update interface. Check the documentation whose copy is available in archive.org

    #include <libnautilus-extension/nautilus-column-provider.h>
    #include <libnautilus-extension/nautilus-info-provider.h>
    
    typedef struct _FooExtension FooExtension;
    typedef struct _FooExtensionClass FooExtensionClass;
    
    typedef struct {
        GClosure *update_complete;
        NautilusInfoProvider *provider;
        NautilusFileInfo *file;
        int operation_handle;
        gboolean cancelled;
    } UpdateHandle;
    
    struct _FooExtension
    {
        GObject parent_slot;
    };
    
    struct _FooExtensionClass
    {
        GObjectClass parent_slot;
    };
    
    static void foo_extension_class_init    (FooExtensionClass *class);
    static void foo_extension_instance_init (FooExtension      *img);
    static GList *foo_extension_get_columns (NautilusColumnProvider *provider);
    static NautilusOperationResult foo_extension_update_file_info (
                                            NautilusInfoProvider *provider,
                                            NautilusFileInfo *file,
                                            GClosure *update_complete,
                                            NautilusOperationHandle **handle);
    
    /* Interfaces */
    static void
    foo_extension_column_provider_iface_init (NautilusColumnProviderIface *iface) {
      iface->get_columns = foo_extension_get_columns;
      return;
    }
    
    static void
    foo_extension_info_provider_iface_init (NautilusInfoProviderIface *iface) {
      iface->update_file_info = foo_extension_update_file_info;
      return;
    }
    
    /* Extension */
    static void foo_extension_class_init(FooExtensionClass *class)
    {
    }
    
    static void foo_extension_instance_init(FooExtension *img)
    {
    }
    
    static GType provider_types[1];
    
    static GType foo_extension_type;
    
    static void foo_extension_register_type(GTypeModule *module)
    {
        static const GTypeInfo info = {
                    sizeof(FooExtensionClass),
                    (GBaseInitFunc) NULL,
                    (GBaseFinalizeFunc) NULL,
                    (GClassInitFunc) foo_extension_class_init,
                    NULL,
                    NULL,
                    sizeof (FooExtension),
                    0,
                    (GInstanceInitFunc) foo_extension_instance_init,
                    };
    
        static const GInterfaceInfo column_provider_iface_info = {
            (GInterfaceInitFunc) foo_extension_column_provider_iface_init,
            NULL,
            NULL
        };
    
        static const GInterfaceInfo info_provider_iface_info = {
            (GInterfaceInitFunc) foo_extension_info_provider_iface_init,
            NULL,
            NULL
        };
    
        foo_extension_type = g_type_module_register_type(module,
                                  G_TYPE_OBJECT,
                                  "FooExtension",
                                  &info, 0);
    
        /* ... add interfaces ... */
        g_type_module_add_interface (module,
                                     foo_extension_type,
                                     NAUTILUS_TYPE_COLUMN_PROVIDER,
                                     &column_provider_iface_info);
    
        g_type_module_add_interface (module,
                                     foo_extension_type,
                                     NAUTILUS_TYPE_INFO_PROVIDER,
                                     &info_provider_iface_info);
    }
    
    GType foo_extension_get_type(void)
    {
        return foo_extension_type;
    }
    
    /* Column interfaces */
    static GList *foo_extension_get_columns(NautilusColumnProvider *provider)
    {
        NautilusColumn *column;
        GList *ret;
        column = nautilus_column_new ("FooExtension::foo_data_column",
                                      "FooExtension::foo_data",
                                      "Foo Data",
                                      "Foo Description");
        ret = g_list_append(NULL, column);
    
        return ret;
    }
    
    /* Info interfaces */
    static NautilusOperationResult
    foo_extension_update_file_info (NautilusInfoProvider *provider,
                                    NautilusFileInfo *file,
                                    GClosure *update_complete,
                                    NautilusOperationHandle **handle)
    {
        char *data;
    
        /* Check if we've previously cached the file info */
        data = g_object_get_data (G_OBJECT (file), "foo_extension_data");
    
        /* get and provide the information associated with the column.
           If the operation is not fast enough, we should use the arguments 
           update_complete and handle for asyncrhnous operation. */
        if (!data) {
            data = g_strdup ("Foo");
        }
    
        nautilus_file_info_add_string_attribute (file,
                                 "FooExtension::foo_data",
                                 data);
        return NAUTILUS_OPERATION_COMPLETE;
    }
    
    /* Extension initialization */
    void nautilus_module_initialize (GTypeModule  *module)
    {
        foo_extension_register_type(module);
        provider_types[0] = foo_extension_get_type();
    }
    
    void nautilus_module_shutdown(void)
    {
        /* Any module-specific shutdown */
    }
    
    void nautilus_module_list_types (const GType **types, int *num_types)
    {
        *types = provider_types;
        *num_types = G_N_ELEMENTS (provider_types);
    }
    

    To compile it:

    $ gcc -c foo-extension.c -o foo-extension.o -fPIC $(pkg-config libnautilus-extension --cflags)
    $ gcc -shared foo-extension.o -o foo-extension.so $(pkg-config libnautilus-extension --libs)
    

    For testing the extension, first you need to stop any running instance of nautilus and re-launch nautilus. That is:

    $ nautilus -q
    $ nautilus 
    

    Note that is without the option -q you used, which is for quit.

    If you would like to check if Nautilus is loading your extension, you can use strace as follow:

    $ strace -e trace=open nautilus
    

    And see what libraries and files Nautilus is loading/opening.

    While working in your extension, instead of copying the extension file in [libdir]/nautilus/extensions-3.0, you can create a symlink to your working directory. If you are using Nautilus 2.x, use [libdir]/nautilus/extensions-2.0 instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I have just tried to save a simple *.rtf file with some websites and
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.