properties: Remove old extensions API

We want to control the layout of the window, not having extensions
injecting their own widgets.

This also avoids future breakage when porting to newer versions of GTK.
This commit is contained in:
António Fernandes 2022-08-06 15:55:50 +01:00
parent ad4cdb8a44
commit e418cf4362
9 changed files with 0 additions and 585 deletions

View file

@ -10,8 +10,6 @@ libnautilus_extension_headers = [
'nautilus-properties-model-provider.h',
'nautilus-properties-model.h',
'nautilus-properties-item.h',
'nautilus-property-page-provider.h',
'nautilus-property-page.h',
'nautilus-menu.h'
]
@ -48,8 +46,6 @@ libnautilus_extension_sources = [
'nautilus-properties-model-provider.c',
'nautilus-properties-model.c',
'nautilus-properties-item.c',
'nautilus-property-page-provider.c',
'nautilus-property-page.c',
'nautilus-menu.c'
]

View file

@ -29,8 +29,6 @@
#include <libnautilus-extension/nautilus-properties-model.h>
#include <libnautilus-extension/nautilus-properties-model-provider.h>
#include <libnautilus-extension/nautilus-properties-item.h>
#include <libnautilus-extension/nautilus-property-page.h>
#include <libnautilus-extension/nautilus-property-page-provider.h>
/**
* SECTION:nautilus-extension

View file

@ -1,48 +0,0 @@
/*
* nautilus-property-page-provider.c - Interface for Nautilus extensions
* that provide property pages for
* files.
*
* 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 "nautilus-property-page-provider.h"
G_DEFINE_INTERFACE (NautilusPropertyPageProvider, nautilus_property_page_provider,
G_TYPE_OBJECT)
static void
nautilus_property_page_provider_default_init (NautilusPropertyPageProviderInterface *klass)
{
}
GList *
nautilus_property_page_provider_get_pages (NautilusPropertyPageProvider *self,
GList *files)
{
NautilusPropertyPageProviderInterface *iface;
g_return_val_if_fail (NAUTILUS_IS_PROPERTY_PAGE_PROVIDER (self), NULL);
iface = NAUTILUS_PROPERTY_PAGE_PROVIDER_GET_IFACE (self);
g_return_val_if_fail (iface->get_pages != NULL, NULL);
return iface->get_pages (self, files);
}

View file

@ -1,88 +0,0 @@
/*
* nautilus-property-page-provider.h - Interface for Nautilus extensions
* that provide property pages.
*
* 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>
*
*/
/* This interface is implemented by Nautilus extensions that want to
* add property page to property dialogs. Extensions are called when
* Nautilus needs property pages for a selection. They are passed a
* list of NautilusFileInfo objects for which information should
* be displayed */
#pragma once
#if !defined (NAUTILUS_EXTENSION_H) && !defined (NAUTILUS_COMPILATION)
#warning "Only <nautilus-extension.h> should be included directly."
#endif
#include <glib-object.h>
G_BEGIN_DECLS
#define NAUTILUS_TYPE_PROPERTY_PAGE_PROVIDER (nautilus_property_page_provider_get_type ())
G_DECLARE_INTERFACE (NautilusPropertyPageProvider, nautilus_property_page_provider,
NAUTILUS, PROPERTY_PAGE_PROVIDER,
GObject)
/**
* SECTION:nautilus-property-page-provider
* @title: NautilusPropertyPageProvider
* @short_description: Interface to provide additional property pages
*
* #NautilusPropertyPageProvider allows extension to provide additional pages
* for the file properties dialog.
*/
/**
* NautilusPropertyPageProviderInterface:
* @g_iface: The parent interface.
* @get_pages: Returns a #GList of #NautilusPropertyPage.
* See nautilus_property_page_provider_get_pages() for details.
*
* Interface for extensions to provide additional property pages.
*/
struct _NautilusPropertyPageProviderInterface
{
GTypeInterface g_iface;
GList *(*get_pages) (NautilusPropertyPageProvider *provider,
GList *files);
};
/**
* nautilus_property_page_provider_get_pages:
* @provider: a #NautilusPropertyPageProvider
* @files: (element-type NautilusFileInfo): a #GList of #NautilusFileInfo
*
* This function is called by Nautilus when it wants property page
* items from the extension.
*
* This function is called in the main thread before a property page
* is shown, so it should return quickly.
*
* Returns: (nullable) (element-type NautilusPropertyPage) (transfer full): A #GList of allocated #NautilusPropertyPage items.
*/
GList *nautilus_property_page_provider_get_pages (NautilusPropertyPageProvider *provider,
GList *files);
G_END_DECLS

View file

@ -1,242 +0,0 @@
/*
* nautilus-property-page.h - Property pages exported by
* NautilusPropertyProvider objects.
*
* 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-property-page.h"
#include <glib/gi18n-lib.h>
enum
{
PROP_0,
PROP_NAME,
PROP_LABEL,
PROP_PAGE,
LAST_PROP
};
struct _NautilusPropertyPage
{
GObject parent_instance;
char *name;
GtkWidget *label;
GtkWidget *page;
};
G_DEFINE_TYPE (NautilusPropertyPage, nautilus_property_page, G_TYPE_OBJECT)
NautilusPropertyPage *
nautilus_property_page_new (const char *name,
GtkWidget *label,
GtkWidget *page_widget)
{
NautilusPropertyPage *page;
g_return_val_if_fail (name != NULL, NULL);
g_return_val_if_fail (GTK_IS_WIDGET (label), NULL);
g_return_val_if_fail (GTK_IS_WIDGET (page_widget), NULL);
page = g_object_new (NAUTILUS_TYPE_PROPERTY_PAGE,
"name", name,
"label", label,
"page", page_widget,
NULL);
return page;
}
static void
nautilus_property_page_get_property (GObject *object,
guint param_id,
GValue *value,
GParamSpec *pspec)
{
NautilusPropertyPage *page;
page = NAUTILUS_PROPERTY_PAGE (object);
switch (param_id)
{
case PROP_NAME:
{
g_value_set_string (value, page->name);
}
break;
case PROP_LABEL:
{
g_value_set_object (value, page->label);
}
break;
case PROP_PAGE:
{
g_value_set_object (value, page->page);
}
break;
default:
{
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
}
break;
}
}
static void
nautilus_property_page_set_property (GObject *object,
guint param_id,
const GValue *value,
GParamSpec *pspec)
{
NautilusPropertyPage *page;
page = NAUTILUS_PROPERTY_PAGE (object);
switch (param_id)
{
case PROP_NAME:
{
g_free (page->name);
page->name = g_strdup (g_value_get_string (value));
g_object_notify (object, "name");
}
break;
case PROP_LABEL:
{
if (page->label)
{
g_object_unref (page->label);
}
page->label = g_object_ref (g_value_get_object (value));
g_object_notify (object, "label");
}
break;
case PROP_PAGE:
{
if (page->page)
{
g_object_unref (page->page);
}
page->page = g_object_ref (g_value_get_object (value));
g_object_notify (object, "page");
}
break;
default:
{
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
}
break;
}
}
static void
nautilus_property_page_dispose (GObject *object)
{
NautilusPropertyPage *page;
page = NAUTILUS_PROPERTY_PAGE (object);
if (page->label)
{
g_object_unref (page->label);
page->label = NULL;
}
if (page->page)
{
g_object_unref (page->page);
page->page = NULL;
}
}
static void
nautilus_property_page_finalize (GObject *object)
{
NautilusPropertyPage *page;
page = NAUTILUS_PROPERTY_PAGE (object);
g_free (page->name);
G_OBJECT_CLASS (nautilus_property_page_parent_class)->finalize (object);
}
static void
nautilus_property_page_init (NautilusPropertyPage *page)
{
}
static void
nautilus_property_page_class_init (NautilusPropertyPageClass *class)
{
G_OBJECT_CLASS (class)->finalize = nautilus_property_page_finalize;
G_OBJECT_CLASS (class)->dispose = nautilus_property_page_dispose;
G_OBJECT_CLASS (class)->get_property = nautilus_property_page_get_property;
G_OBJECT_CLASS (class)->set_property = nautilus_property_page_set_property;
g_object_class_install_property (G_OBJECT_CLASS (class),
PROP_NAME,
g_param_spec_string ("name",
"Name",
"Name of the page",
NULL,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (class),
PROP_LABEL,
g_param_spec_object ("label",
"Label",
"Label widget to display in the notebook tab",
GTK_TYPE_WIDGET,
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (class),
PROP_PAGE,
g_param_spec_object ("page",
"Page",
"Widget for the property page",
GTK_TYPE_WIDGET,
G_PARAM_READWRITE));
}
GtkWidget *
nautilus_property_page_get_label (NautilusPropertyPage *page)
{
return page->label;
}
const char *
nautilus_property_page_get_name (NautilusPropertyPage *page)
{
return page->name;
}
GtkWidget *
nautilus_property_page_get_widget (NautilusPropertyPage *page)
{
return page->page;
}

View file

@ -1,96 +0,0 @@
/*
* nautilus-property-page.h - Property pages exported by
* NautilusPropertyProvider objects.
*
* 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>
*
*/
#pragma once
#if !defined (NAUTILUS_EXTENSION_H) && !defined (NAUTILUS_COMPILATION)
#warning "Only <nautilus-extension.h> should be included directly."
#endif
#include <glib-object.h>
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define NAUTILUS_TYPE_PROPERTY_PAGE (nautilus_property_page_get_type ())
G_DECLARE_FINAL_TYPE (NautilusPropertyPage, nautilus_property_page,
NAUTILUS, PROPERTY_PAGE,
GObject)
/**
* SECTION:nautilus-property-page
* @title: NautilusPropertyPage
* @short_description: Property page descriptor object
*
* #NautilusPropertyPage is an object that describes a page in the file
* properties dialog. Extensions can provide #NautilusPropertyPage objects
* by registering a #NautilusPropertyPageProvider and returning them from
* nautilus_property_page_provider_get_pages(), which will be called by the
* main application when creating file properties dialogs.
*/
/**
* nautilus_property_page_new:
* @name: the identifier for the property page
* @label: the user-visible label of the property page
* @page: the property page to display
*
* Returns: (transfer full): a new #NautilusPropertyPage
*/
NautilusPropertyPage *nautilus_property_page_new (const char *name,
GtkWidget *label,
GtkWidget *page);
/* NautilusPropertyPage has the following properties:
* name (string) - the identifier for the property page
* label (widget) - the user-visible label of the property page
* page (widget) - the property page to display
*/
/**
* nautilus_property_page_get_label:
* @page: the property page
*
* Returns: (transfer none): the label of this #NautilusPropertyPage
*/
GtkWidget * nautilus_property_page_get_label (NautilusPropertyPage *page);
/**
* nautilus_property_page_get_name:
* @page: the property page
*
* Returns: (transfer none): the name of this #NautilusPropertyPage
*/
const char *nautilus_property_page_get_name (NautilusPropertyPage *page);
/**
* nautilus_property_page_get_widget:
* @page: the property page
*
* Returns: (transfer none): the widget associated wtih this #NautilusPropertyPage
*/
GtkWidget * nautilus_property_page_get_widget (NautilusPropertyPage *page);
G_END_DECLS

View file

@ -14,7 +14,6 @@ extensions/image-properties/nautilus-image-properties-model.c
extensions/image-properties/nautilus-image-properties-model-provider.c
libnautilus-extension/nautilus-column.c
libnautilus-extension/nautilus-menu-item.c
libnautilus-extension/nautilus-property-page.c
src/nautilus-application.c
src/nautilus-app-chooser.c
src/nautilus-autorun-software.c

View file

@ -48,7 +48,6 @@
#include "nautilus-module.h"
#include "nautilus-properties-model.h"
#include "nautilus-properties-item.h"
#include "nautilus-property-page.h"
#include "nautilus-signaller.h"
#include "nautilus-tag-manager.h"
#include "nautilus-ui-utilities.h"
@ -133,8 +132,6 @@ struct _NautilusPropertiesWindow
GtkWidget *permissions_navigation_row;
GtkWidget *permissions_value_label;
GtkListBox *extension_list_box;
GtkWidget *extension_models_list_box;
GList *extensions_properties_models;
@ -470,7 +467,6 @@ static void set_icon (const char *icon_path,
static void remove_pending (StartupData *data,
gboolean cancel_call_when_ready,
gboolean cancel_timed_wait);
static void refresh_extension_pages (NautilusPropertiesWindow *self);
static void refresh_extension_model_pages (NautilusPropertiesWindow *self);
G_DEFINE_TYPE (NautilusPropertiesWindow, nautilus_properties_window, ADW_TYPE_WINDOW);
@ -547,15 +543,6 @@ navigate_permissions_page (NautilusPropertiesWindow *self,
gtk_stack_set_visible_child_name (self->page_stack, "permissions");
}
static void
navigate_extension_page (NautilusPropertiesWindow *self,
GParamSpec *params,
AdwPreferencesRow *row)
{
gtk_stack_set_visible_child_name (self->page_stack,
adw_preferences_row_get_title (row));
}
static void
navigate_extension_model_page (NautilusPropertiesWindow *self,
GParamSpec *params,
@ -925,55 +912,6 @@ file_list_get_string_attribute (GList *file_list,
}
}
static GtkWidget *
add_extension_page (NautilusPropertyPage *property_page,
NautilusPropertiesWindow *self)
{
GtkWidget *row;
GtkWidget *image;
GtkWidget *page_widget;
GtkWidget *header_bar;
GtkWidget *up_button;
GtkWidget *box;
const char *extension_type;
g_autofree char *navigation_label = NULL;
row = adw_action_row_new ();
image = gtk_image_new_from_icon_name ("go-next-symbolic");
extension_type = gtk_label_get_text (GTK_LABEL (nautilus_property_page_get_label (property_page)));
navigation_label = g_strdup_printf (_("%s Properties"), extension_type);
page_widget = nautilus_property_page_get_widget (property_page);
adw_preferences_row_set_title (ADW_PREFERENCES_ROW (row), navigation_label);
adw_action_row_add_suffix (ADW_ACTION_ROW (row), image);
gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (row), TRUE);
gtk_list_box_row_set_selectable (GTK_LIST_BOX_ROW (row), FALSE);
g_signal_connect_swapped (row, "activated",
G_CALLBACK (navigate_extension_page),
self);
header_bar = gtk_header_bar_new ();
gtk_header_bar_set_title_widget (GTK_HEADER_BAR (header_bar),
adw_window_title_new (navigation_label, NULL));
up_button = gtk_button_new_from_icon_name ("go-previous-symbolic");
g_signal_connect_swapped (up_button, "clicked", G_CALLBACK (navigate_main_page), self);
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), up_button);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_box_append (GTK_BOX (box), header_bar);
gtk_box_append (GTK_BOX (box), page_widget);
gtk_widget_add_css_class (page_widget, "background");
gtk_stack_add_named (self->page_stack,
box,
navigation_label);
return row;
}
static GtkWidget *
create_extension_group_row (NautilusPropertiesItem *item,
NautilusPropertiesWindow *self)
@ -1470,7 +1408,6 @@ properties_window_update (NautilusPropertiesWindow *self,
{
if (!mime_list_equal (self->mime_list, mime_list))
{
refresh_extension_pages (self);
refresh_extension_model_pages (self);
}
@ -3694,35 +3631,6 @@ setup_permissions_page (NautilusPropertiesWindow *self)
}
}
static void
refresh_extension_pages (NautilusPropertiesWindow *self)
{
GListStore *extension_providers = g_list_store_new (NAUTILUS_TYPE_PROPERTY_PAGE);
g_autolist (GObject) providers =
nautilus_module_get_extensions_for_type (NAUTILUS_TYPE_PROPERTY_PAGE_PROVIDER);
for (GList *p = providers; p != NULL; p = p->next)
{
NautilusPropertyPageProvider *provider = NAUTILUS_PROPERTY_PAGE_PROVIDER (p->data);
g_autolist (NautilusPropertyPage) pages =
nautilus_property_page_provider_get_pages (provider, self->original_files);
for (GList *l = pages; l != NULL; l = l->next)
{
g_list_store_append (extension_providers, NAUTILUS_PROPERTY_PAGE (l->data));
}
}
gtk_widget_set_visible (GTK_WIDGET (self->extension_list_box),
g_list_model_get_n_items (G_LIST_MODEL (extension_providers)) > 0);
gtk_list_box_bind_model (self->extension_list_box,
G_LIST_MODEL (extension_providers),
(GtkListBoxCreateWidgetFunc) add_extension_page,
self,
NULL);
}
static void
refresh_extension_model_pages (NautilusPropertiesWindow *self)
{
@ -3966,9 +3874,6 @@ create_properties_window (StartupData *startup_data)
gtk_widget_show (GTK_WIDGET (window->execution_row));
}
/* Add available extension pages */
refresh_extension_pages (window);
/* Add available extension models pages */
refresh_extension_model_pages (window);
@ -4532,7 +4437,6 @@ nautilus_properties_window_class_init (NautilusPropertiesWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, accessed_value_label);
gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, permissions_navigation_row);
gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, permissions_value_label);
gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, extension_list_box);
gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, extension_models_list_box);
gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, free_space_value_label);
gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, permissions_stack);

View file

@ -662,14 +662,6 @@
</style>
</object>
</child>
<child>
<object class="GtkListBox" id="extension_list_box">
<property name="selection-mode">none</property>
<style>
<class name="boxed-list"/>
</style>
</object>
</child>
<child>
<object class="GtkListBox" id="extension_models_list_box">
<property name="selection-mode">none</property>