diff options
author | Christian Hergert <chergert@redhat.com> | 2023-03-22 16:44:31 -0700 |
---|---|---|
committer | Christian Hergert <chergert@redhat.com> | 2023-03-22 16:44:31 -0700 |
commit | 37b9fae8ab0f31f64761762cb1693807add68613 (patch) | |
tree | ce2d72f42b97fa679f7bf56076b6978d9354f878 | |
parent | c68ecac0025caa5fa2401deff41d3b1959062600 (diff) | |
download | libpeas-37b9fae8ab0f31f64761762cb1693807add68613.tar.gz |
janitorial: clean up tree in preparation for libpeas-2.0
This starts the process of working towards a new Libpeas 2.0 ABI. The
goals of this ABI break are:
* Modernize and cleanup GObject usage within libpeas
* Use GObject's in more places to allow for better GIO integration
* Implement GListModel where it makes sense
* Remove GTK 3 and GTK-based APIs as those are trivial to implement in
applications with GTK 4 and newer.
* Drop Python 2 support
* Simplify support for new plugin loaders
# Conflicts:
# NEWS
# meson.build
82 files changed, 71 insertions, 7408 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9fa231f..5e6c5a0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,9 +16,7 @@ stages: ninja-build redhat-rpm-config glib2-devel - gtk3-devel gobject-introspection-devel - python2-devel python3-devel xorg-x11-server-Xvfb git @@ -39,7 +37,7 @@ stages: build peas: extends: '.build' script: - - 'meson -Dwidgetry=false -Dintrospection=true -Dvapi=true -Ddemos=false -Dgtk_doc=false _build .' + - 'meson -Dintrospection=true -Dvapi=true -Dgtk_doc=false _build .' - 'ninja -C _build test' build peas-gtk: @@ -53,16 +51,11 @@ reference: variables: MESON_ARGS: >- -Dgtk_doc=true - -Ddemos=false - -Dglade_catalog=false - -Dwidgetry=true script: - - mkdir -p _reference/libpeas-1.0 - - mkdir -p _reference/libpeas-gtk-1.0 + - mkdir -p _reference/libpeas-2.0 - meson ${MESON_ARGS} _build - ninja -C _build - - mv _build/docs/reference/libpeas-1.0/* _reference/libpeas-1.0 - - mv _build/docs/reference/libpeas-gtk-1.0/* _reference/libpeas-gtk-1.0 + - mv _build/docs/reference/libpeas-2.0/* _reference/libpeas-2.0 artifacts: paths: - _reference @@ -1,587 +1,51 @@ -Overview of Changes in libpeas 1.36.0 -===================================== +# Libpeas 1.99.0 -* PeasExtensionSet now implements GListModel -* libpeas now requires GLib 2.44 or newer for GListModel -* Translation updates: - - Interlingue - - Turkish +This is the beginning of the libpeas 2.0 series. It breaks ABI with previous +versions of libpeas and therefore can be installed along-side libpeas-1.0. -As a note to packagers, we'd like to mention that there is an intention to -release a new libpeas-2 ABI for GNOME 45 to fix a number of longstanding -needs which can only be resolved with an ABI break. +This allows libpeas to improve API ergonomics as well as implement features +which will improve integration with GTK 4. -Overview of Changes in libpeas 1.34.0 -===================================== +## Removals -* Resource-based plugins are sorted by module-name before loading - to aid in reproducibility. -* Sorting of plugins with dependencies has been altered to improve - sort-order with more complex plugin dependency graphs. -* Translation updates: - - Hebrew - - Georgian - - Bulgarian +### Removal of libpeas-gtk -Overview of Changes in libpeas 1.32.0 -===================================== +libpeas-gtk is not part of libpeas-2. -* Icon licenses have been corrected -* Parallel build system operation fixes -* Various build warnings squashed -* Various GIR data that should not have been exported was removed -* Use gi-docgen for documentation -* Translation updates: - - Russian - - Abkhazian - - Nepali - - Occitan - - Icelandic - - Hebrew - - Belarusian +Application developers are encouraged to use GTK 4's integration with +GtkListView and similar widgets with PeasEngine. It provides a GListModel +implementation with PeasPluginInfo to bind into row widgets. -Overview of Changes in libpeas 1.30.0 -===================================== +### Reoval of PeasActivatable -* Build system improvements -* Improvements when running on Windows -* Translation updates: - - Galician - - Greek - - Norwegian Bokmål - - Punjabi +Interfaces are cheap and easy to create in GObject these days. Application +developers are encouraged to create their own interfaces or base-objects +which can implemented by their plugins. -Overview of Changes in libpeas 1.28.0 -===================================== +### Removal of Python 2 support -* Do not build tests when introspection is disabled/missing -* add missing locale.h include -* Translation updates: - - Chinese (China) - - Portuguese - - Ukrainian +Everything of consequence is on Python 3 now. There is no need for us to +maintain the Python 2 loader for new applications targeting libpeas-2. -Overview of Changes in libpeas 1.26.0 -===================================== +### Deprecated API -* Simplified i18n usage -* Build system fixes -* Translation updates: - - British English - - Malay - - Slovak +Previously deprecated API has been removed from libpeas such as the very +old GObject Introspection integration using "call" on extension objects. -Overview of Changes in libpeas 1.25.3 -===================================== +## List Models -* Fix access to peas_gettext() -* Fix duplicate rename-to annotations -* Tighten symbol availability for GLib symbols -* Fix various tests to work with G_DISABLE_ASSERT -* Fix building with luajit -* Add peas_extension_set_new_with_properties() to aid in using libpeas - from language bindings -* Fix naming of Python2 loader -* Remove use of undocumented -export-dynamic -* Fis use of PeasExtension with GInitiallyUnowned -* Build fixes for macOS -* Fixes to pkg-config files -* Translation updates: - - Chinese (Taiwan) - - Danish - - Dutch - - Galicians - - Persian +### PeasEngine -Overview of Changes in libpeas 1.24.0 -===================================== +The PeasEngine object now implements a GListModel of PeasPluginInfo. Now +that PeasPluginInfo is a GObject, you may bind it's properties to labels +within rows of a GtkListView with relative ease. -* Setup troubleshooting environment when running automated tests -* Translation updates: - - Brazilian Portuguese - - German - - Italian - - Turkish +Additionally, you can easily filter lists based on type-to-search with +GtkFilterListModel, more than you could ever do with libpeas-gtk. -Overview of Changes in libpeas 1.23.92 -====================================== +### PeasExtensionSet -This is a RC release for the upcoming GNOME 3.34 release. +PeasExtensionSet is also a GListModel which improves situations where an +application wants to limit which extensions within a set are active based +on arbitrary conditions. -* Fix soname usage to match 1.22.x -* Fix typo in deprecation ignores -* Fix gtk_menu_popup() deprecations -* Fix meson build warning -* Translation updates: - - Basque - - Catalan - - Croatian - - Czech - - Finnish - - French - - Friulan - - Galician - - Hungarian - - Japanese - - Korean - - Lithuanian - - Polish - - Romanian - - Serbian - - Spanish - - Swedish - -Overview of Changes in libpeas 1.23.90.1 -======================================== - -This is a followup release to yesterdays 1.23.90 which includes a -fix to ensure that programs linking against libpeas-1.0 also link -against gobject-introspection-1.0. - -Overview of Changes in libpeas 1.23.90 -====================================== - -This release is the first to use the meson build system. Autotools -has been removed. In most cases, the transition to meson should be -relatively painless, and has many examples from other projects in -the GNOME ecosystem to serve as examples. - -See meson_options.txt for the updated parameters. - -We'll have a series of .90, .91, .92 releases up to 1.24 if they -are necessary following the GNOME release schedule for 3.34 in -September. - -* Port to meson build system, autotools has been removed -* Support for python3.8 in the python3 loader -* Reduce warning impact of GParameter deprecations on API consumers -* Fix a number of deprecations in internal API -* Remove use of intltool in favor of gettext -* Add versioning macros and hide non-public symbols -* Translation updates: - - Catalan - - Dutch - - Esperanto - - French - - Icelandic - - Malayalam - - Polish - -Thanks to everyone who provided patches along the way. - -Overview of Changes in libpeas 1.22.0 -==================================== - -* Translation updates: - - Catalan - - Danish - -Overview of Changes in libpeas 1.21.0 -==================================== - -* Consider all an interfaces potential properties -* Fix PeasEngine virtual annotations -* Allow extensions to be an Abstract Base Class -* Cache an extension type's base class and interfaces - -* Translation updates: - - Belarusian - - Croatian - - Simplified Chinese - -Overview of Changes in libpeas 1.20.0 -==================================== - -* Translation updates: - - British English - - Friulian - - Hebrew - - Occitan - - Polish - - Portuguese - -Overview of Changes in libpeas 1.18.0 -==================================== - -* Translation updates: - - Latvian - - Occitan - -Overview of Changes in libpeas 1.17.0 -==================================== - -* Fix Python plugin loader module paths -* Do not add pyexecdir to Python's paths at runtime -* Add support for embedded C plugins -* Order the PeasEngine:plugin-list by dependencies -* Keep plugins order in PeasExtensionSet -* Misc bugfixes - -* Translation updates: - - Basque - - Chinese - - Lithuanian - - Occitan - - Serbian - - Serbian (Latin) - -Overview of Changes in libpeas 1.16.0 -==================================== - -* Translation updates: - - Brazilian Portuguese - - Chinese (Taiwan) - - Danish - - Finnish - - French - - Galicians - - German - - German - - Greek - - Indonesian - - Italian - - Kazakh - - Korean - - Lithuanian - - Persian - - Polish - - Portuguese - - Russian - - Slovak - - Slovenian - - Swedish - - Thai - -Overview of Changes in libpeas 1.15.0 -==================================== - -* Add g_autoptr() autocleanup support -* Fix Python tests on OpenBSD -* Fix libpeas crash on windows -* Simplify __all__ support in the Python plugin loader -* Misc bugfixes - -* Translation updates: - - Czech - - Hungarian - - Icelandic - - Norwegian bokmål - - Occitan - - Romanian - - Spanish - - Turkish - -Overview of Changes in libpeas 1.14.0 -==================================== - -* Misc bugfixes - -* Translation updates: - - Aragonese - - Bosnian - - Chinese (Taiwan) - - Danish - - Finnish - - French - - Greek - - Indonesian - - Italian - - Kazakh - - Korean - - Korean - - Lithuanian - - Norwegian bokmål - - Polish - - Serbian - - Slovak - - Slovenian - - Swedish - - Turkish - -Overview of Changes in libpeas 1.13.0 -==================================== - -* Removed support for Seed plugins -* Added support for Lua 5.1 plugins using the LGI bindings -* PeasEngine is now thread-safe -* Added support for non-global plugins loaders -* Load C plugins with local linkage -* Use Python to implement the plugin loader's logic -* Support Python plugins that define __all__ -* Use Lua to implement the plugin loader's logic -* Prevent the accidental escaping of globals with Lua plugins -* Misc bugfixes - -* Translation updates: - - Basque - - Brazilian Portuguese - - Czech - - Friulian - - Galician - - Hebrew - - Hungarian - - Japanese - - Kannada - - Nepali - - Russian - - Spanish - - Turkish - -Overview of Changes in libpeas 1.12.1 -==================================== - -* Dist the GResources XML of the Python plugin loaders - -Overview of Changes in libpeas 1.12.0 -==================================== - -* Add easy python profiling support -* Disable GLib diagnostics in tests -* Fix various deprecation warning from GTK+ -* Check return values from Python API -* [osx] Check for bundle before resource path -* Improved dependency-less support for OS X -* Misc bugfixes - -* Translation updates: - - Assamese - - Bengali (India) - - Brazilian Portuguese - - Catalan - - Catalan (Valencian) - - Czech - - Danish - - French - - Galicians - - German - - Greek - - Gujarati - - Hebrew - - Hindi - - Hungarian - - Indonesian - - Kannada - - Korean - - Lithuanian - - Marathis - - Norwegian bokmål - - Oriya - - Polish - - Punjabi - - Russian - - Simplified Chinese - - Slovenian - - Spanish - - Swedish - - Tamil - - Telugus - - Traditional Chinese - -Overview of Changes in libpeas 1.10.1 -==================================== - -* Fix initializing Python loader from Python application -* Prevent and warn when trying to enable multiple loaders -* W32: Allow shared libs to be built -* Misc bugfixes - -Overview of Changes in libpeas 1.10.0 -==================================== - -* Remove support for gjs-based Javascript plugins -* Misc bugfixes - -Overview of Changes in libpeas 1.9.0 -==================================== - -* Misc bugfixes - -* Translation updates: - - Tajik - -Overview of Changes in libpeas 1.8.0 -==================================== - -* Misc bugfixes - -* Translation updates: - - Aragonese - - Portuguese - - Tadjik - - Uyghur - -Overview of Changes in libpeas 1.7.0 -==================================== - -* Add python3 loader - -* Translation updates: - - Friulan - - Kannada - - Odia - -Overview of Changes in libpeas 1.6.2 -==================================== - -* Fix gjs single-include issues - -* Translation updates: - - Slovak - -Overview of Changes in libpeas 1.6.1 -==================================== - -* Better SIGINT handling for python signals module - -* Translation updates: - - Kannada - -Overview of Changes in libpeas 1.6.0 -==================================== - -* Remove the vala demo plugin - -* Add min required and max allowed version for glib and Gdk - -* Translation updates: - - Assamese - - Bengali (India) - - Galician - - Gujarati - - Hindi - - Latvian - - Marathi - - Polish - - Thai - - Türkçe - -Overview of Changes in libpeas 1.5.0 -==================================== - -* Warn if activate or deactivate are not implemented - -* Find extension construct properties also in interface prerequisites - -* Fix interface sorting in GJS and Seed - -* Added peas_engine_prepend_search_path - -* Added peas_plugin_info_get_external_data - -* Misc bugfixes - -* Translation updates: - - Greek - - Indonesian - -Overview of Changes in libpeas 1.3.0 -==================================== - -* Extensions can now implement multiple interfaces. - -* Added GSettings API to PeasPluginInfo. - -* Misc improvement and fixes. - -* Translation updates: - - Russian - - Bulgarian - - Brazilian Portuguese - - Galicians - - Danish - - Serbian - - German - - Norwegian bokmål - - Polish - - Swedish - - Belarusian - - Telugu - - Catalan (Valencian) - - Catalan - - Hebrew - - Japanese - - Slovenian - - Czech - - Spanish - -Overview of Changes in libpeas 1.2 -==================================== - -* Fix using Python plugins. - -* Misc improvement and fixes. - -* Translation updates: - - Assamese - - Esperanto - - Telugu - -Overview of Changes in libpeas 1.1.4 -==================================== - -* Fix to work with PyGObject 3. - -* Do not expose the peas_extension_set_call* API to GObject-Introspection. - -* Disable log hooks used by PyGObject and Seed. - -* Doc updates. - -* Misc improvement and fixes. - -* Translation updates: - - Asturian - - Thai - -Overview of Changes in libpeas 1.1.3 -==================================== - -* Do not expose the PeasExtension API using GObject-Introspection - -* Misc improvement and fixes. - -Overview of Changes in libpeas 1.1.2 -==================================== - -* Doc updates. - -* Link against pygobject 3. - -* Do not cast pointers to unsigned integers. - -* Translation updates: - - Indonesian - -Overview of Changes in libpeas 1.1.1 -==================================== - -* PeasExtension has been deprecated - -* You should be able to use C plugins without GObject-Introspection. - -* The plugin manager's disable plugins dialog will no longer show - hidden plugins. - -Overview of Changes in libpeas 1.1.0 -==================================== - -* Add support gjs-based Javascript extensions - -* Seed Javascript extension support improvements - - Use the new() keyword to instantiate new Javascript extensions. - - Previously used "copied arrays" have been deprecated. - - Allow using prototypes when defining new extensions. - -* Add peas_extension_set_foreach() - - Also deprecate the old peas_extension_set_call() method as a result. - -* Drop support for Gtk+ 2 - -* Translation updates: - - Lithuanian - - Japanese - - Turkish - - Esperanto - - Persian - - Catalan (Valencian) - - Finnish @@ -14,8 +14,7 @@ Documentation Documentation can be found at: -- Peas-1.0: https://gnome.pages.gitlab.gnome.org/libpeas/libpeas-1.0/. -- GtkPeas-1.0: https://gnome.pages.gitlab.gnome.org/libpeas/libpeas-gtk-1.0/. +- Peas-2.0: https://gnome.pages.gitlab.gnome.org/libpeas/libpeas-2.0/. Multiple extension points ------------------------- @@ -29,7 +28,7 @@ On-demand programming language support -------------------------------------- libpeas comes with a set of supported languages (currently, C, Lua 5.1, -Python 2 and Python 3). Those languages are supported through “loaders” which +and Python 3). Those languages are supported through “loaders” which are loaded on demand. What it means is that you only pay for what you use: if you have no Python plugin, the Python interpreter won't be loaded in memory. Of course, the same goes for the C loader. @@ -86,16 +85,5 @@ Let's try and give a definition of both of these words in this context: the configuration dialog, the left panel pane and a completion provider for file names. -Sample code ------------ - -The libpeas package contains a sample application called peas-demo, and sample -plugins written in C, Lua and Python. - -The global idea is this one: you create a new PeasEngine instance and give it -the information needed for it to find your plugins. Then you load some plugins -(you can use the PeasGtkPluginManager for that purpose) and perform actions -through some PeasExtensions objects you can get from the engine. - Copied from http://log.istique.net/2010/announcing-libpeas diff --git a/data/glade/libpeas-gtk.xml.in b/data/glade/libpeas-gtk.xml.in deleted file mode 100644 index d7547f8..0000000 --- a/data/glade/libpeas-gtk.xml.in +++ /dev/null @@ -1,36 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<glade-catalog version="1.0" supports="gtkbuilder" name="libpeas-gtk" library="peas-gtk-1.0" domain="@GETTEXT_PACKAGE@" depends="gtk+" book="libpeas"> - <glade-widget-classes> - <glade-widget-class name="PeasGtkPluginManager" title="Plugin Manager" generic-name="pluginmanager"> - <properties> - <!-- Translators: What PeasGtkPluginManagerView to use --> - <property id="view" name="View" create-type="PeasGtkPluginManagerView" query="False" /> - - <!-- Disable GtkBox properties that should never be modified --> - <property id="homogeneous" disabled="True" /> - <property id="padding" disabled="True" /> - <property id="size" disabled="True" query="False" /> - <property id="spacing" disabled="True" /> - </properties> - </glade-widget-class> - - <glade-widget-class name="PeasGtkPluginManagerView" title="Plugin Manager View" generic-name="pluginmanagerview"> - <properties> - <!-- Translators: Whether builtin plugins should appear in the view (property name) --> - <property id="show-builtin" name="Show Builtin" default="False" /> - - <!-- Disable GtkTreeView properties that should never be modified --> - <property id="model" disabled="True" query="False" /> - </properties> - - <signals> - <signal id="populate-popup" /> - </signals> - </glade-widget-class> - </glade-widget-classes> - - <glade-widget-group name="PeasGtk" title="Peas Gtk"> - <glade-widget-class-ref name="PeasGtkPluginManager" /> - <glade-widget-class-ref name="PeasGtkPluginManagerView" /> - </glade-widget-group> -</glade-catalog> diff --git a/data/glade/meson.build b/data/glade/meson.build deleted file mode 100644 index 0681bdf..0000000 --- a/data/glade/meson.build +++ /dev/null @@ -1,29 +0,0 @@ -glade_catalog_xml = configuration_data() -glade_catalog_xml.set('GETTEXT_PACKAGE', package_string) - -peas_glade_catalog = configure_file( - input: 'libpeas-gtk.xml.in', - output: 'libpeas-gtk.xml', - configuration: glade_catalog_xml, - install_dir: catalogdir, -) - -# Glade file does not currently validate and this does not appear to be -# the fault of libpeas. -#if xmllint_prg.found() -# glade_catalog_dtd_path = join_paths( -# gladeui_dep.get_pkgconfig_variable('catalogdir'), -# 'glade-catalog.dtd' -# ) -# -# test( -# 'Validate Glade catalogue', -# xmllint_prg, -# args: [ -# '--dtdvalid', -# glade_catalog_dtd_path, -# peas_glade_catalog, -# '--noout', -# ] -# ) -#endif diff --git a/data/meson.build b/data/meson.build index 59295ae..feb1c1e 100644 --- a/data/meson.build +++ b/data/meson.build @@ -1,5 +1 @@ -if install_glade_catalog == true - subdir('glade') -endif - subdir('icons') diff --git a/docs/reference/libpeas-gtk-urlmap.js b/docs/reference/libpeas-gtk-urlmap.js deleted file mode 100644 index 0b6777e..0000000 --- a/docs/reference/libpeas-gtk-urlmap.js +++ /dev/null @@ -1,8 +0,0 @@ -// A map between namespaces and base URLs for their online documentation -baseURLs = [ - [ 'GLib', 'https://docs.gtk.org/glib/' ], - [ 'GObject', 'https://docs.gtk.org/gobject/' ], - [ 'Gio', 'https://docs.gtk.org/gio/' ], - [ 'Gtk', 'https://docs.gtk.org/gtk4/' ], - [ 'Peas', 'https://gnome.pages.gitlab.gnome.org/libpeas/libpeas-1.0/' ], -] diff --git a/docs/reference/libpeas-gtk.toml.in b/docs/reference/libpeas-gtk.toml.in deleted file mode 100644 index 8854102..0000000 --- a/docs/reference/libpeas-gtk.toml.in +++ /dev/null @@ -1,55 +0,0 @@ -[library] -version = "@VERSION@" -browse_url = "https://gitlab.gnome.org/GNOME/libpeas" -repository_url = "https://gitlab.gnome.org/GNOME/libpeas.git" -docs_url = "https://gnome.pages.gitlab.gnome.org/libpeas/libpeas-gtk-1.0/" -website_url = "https://gitlab.gnome.org/GNOME/libpeas" -authors = "Steve Frécinaux, Garrett Regier, Christian Hergert" -license = "LGPL-2.0-or-later" -description = "GObject-based plugins engine" -dependencies = [ "GObject-2.0", "GLib-1.0", "Gio-2.0", "Gtk-3.0", "Peas-1.0" ] -devhelp = true -search_index = true - -[dependencies."GObject-2.0"] -name = "GObject" -description = "The base type system library" -docs_url = "https://docs.gtk.org/gobject/" - -[dependencies."GLib-2.0"] -name = "GLib" -description = "The base type system library" -docs_url = "https://docs.gtk.org/glib/" - -[dependencies."Gio-2.0"] -name = "GIO" -description = "GObject Interfaces and Objects, Networking, IPC, and I/O" -docs_url = "https://docs.gtk.org/gio/" - -[dependencies."Gtk-3.0"] -name = "GTK" -description = "The GTK toolkit" -docs_url = "https://docs.gtk.org/gtk3/" - -[dependencies."Peas-1.0"] -name = "Peas" -description = "GObject-based plugins engine" -docs_url = "https://gnome.pages.gitlab.gnome.org/libpeas/libpeas-1.0/" - -[theme] -name = "basic" -show_index_summary = true -show_class_hierarchy = true - -[source-location] -base_url = "https://gitlab.gnome.org/GNOME/libpeas/-/blob/master/" - -[extra] -# The same order will be used when generating the index -content_files = [ -] - -content_images = [ - 'images/peas-gtk-plugin-manager.png', -] -urlmap_file = "libpeas-gtk-urlmap.js" diff --git a/docs/reference/meson.build b/docs/reference/meson.build index fd4b513..ef0afe9 100644 --- a/docs/reference/meson.build +++ b/docs/reference/meson.build @@ -33,32 +33,3 @@ custom_target('libpeas-doc', install: true, install_dir: docs_dir, ) - -if build_gtk_widgetry == true - libpeas_gtk_toml = configure_file( - input: 'libpeas-gtk.toml.in', - output: 'libpeas-gtk.toml', - configuration: toml_data - ) - - custom_target('libpeas-gtk-doc', - input: [libpeas_gtk_toml, libpeas_gtk_gir[0], libpeas_gir[0]], - output: 'libpeas-gtk-@0@'.format(api_version), - command: [ - gidocgen, - 'generate', - '--quiet', - '--add-include-path=@0@'.format(meson.current_build_dir() / '../../libpeas-gtk'), - '--add-include-path=@0@'.format(meson.current_build_dir() / '../../libpeas'), - '--config=@INPUT0@', - '--output-dir=@OUTPUT@', - '--no-namespace-dir', - '--content-dir=@0@'.format(meson.current_source_dir()), - '@INPUT1@', - ], - depend_files: [ expand_content_md_files ], - build_by_default: true, - install: true, - install_dir: docs_dir, - ) -endif diff --git a/libpeas-gtk/meson.build b/libpeas-gtk/meson.build deleted file mode 100644 index 01e10eb..0000000 --- a/libpeas-gtk/meson.build +++ /dev/null @@ -1,110 +0,0 @@ -libpeas_gtk_srcdir = include_directories('.') - -libpeas_gtk_public_h = files( - 'peas-gtk-autocleanups.h', - 'peas-gtk-configurable.h', - 'peas-gtk-plugin-manager.h', - 'peas-gtk-plugin-manager-view.h', - 'peas-gtk.h', -) - -libpeas_gtk_c = files( - 'peas-gtk-configurable.c', - 'peas-gtk-disable-plugins-dialog.c', - 'peas-gtk-plugin-manager.c', - 'peas-gtk-plugin-manager-store.c', - 'peas-gtk-plugin-manager-view.c', -) - -libpeas_gtk_deps = [ - glib_dep, - gobject_dep, - introspection_dep, - gtk_dep, - libpeas_dep, -] - -libpeas_gtk_c_args = [ - '-DHAVE_CONFIG_H', - '-DG_LOG_DOMAIN="libpeas-gtk"', -] - -libpeas_gtk_c_args += hidden_visibility_args - -libpeas_gtk_link_args = [ -] - -install_headers( - libpeas_gtk_public_h, - install_dir: join_paths( - pkgincludedir, - package_gtk_name, - ) -) - -libpeas_gtk_sha = library( - package_gtk_string.strip('lib'), - libpeas_gtk_c, - version: lib_version, - darwin_versions: lib_version_osx, - include_directories: rootdir, - dependencies: libpeas_gtk_deps, - c_args: project_c_args + libpeas_gtk_c_args, - link_args: libpeas_gtk_link_args, - install: true, -) - -libpeas_gtk_dep_sources = [] - -if generate_gir == true - libpeas_gtk_gir_includes = [ - 'GObject-2.0', - 'Gtk-3.0', - libpeas_gir.get(0) - ] - - libpeas_gtk_gir = gnome.generate_gir( - libpeas_gtk_sha, - sources: libpeas_gtk_c + libpeas_gtk_public_h, - nsversion: api_version, - namespace: 'PeasGtk', - symbol_prefix: 'peas_gtk', - identifier_prefix: 'PeasGtk', - header: 'libpeas-gtk/peas-gtk.h', - export_packages: [package_gtk_string], - includes: libpeas_gtk_gir_includes, - link_with: [libpeas_sha, libpeas_gtk_sha], - install: true, - install_dir_gir: girdir, - install_dir_typelib: typelibdir, - extra_args: [ - '--warn-all', - ], - ) - - libpeas_gtk_dep_sources += [ - libpeas_gtk_gir, - ] -endif - -libpeas_gtk_dep = declare_dependency( - link_with: libpeas_gtk_sha, - dependencies: libpeas_gtk_deps, - include_directories: rootdir, - sources: libpeas_gtk_dep_sources, -) - -libpeas_gtk_pc_reqs = [ - glib_dep, - gtk_dep, - package_string + ' >= @0@'.format(version) -] - -libpeas_gtk_pc = pkg.generate( - libpeas_gtk_sha, - name: package_gtk_string, - description: 'GObject plugins library widgetery', - requires: libpeas_gtk_pc_reqs, - subdirs: package_string, - install_dir: pkgconfigdir, -) diff --git a/libpeas-gtk/peas-gtk-autocleanups.h b/libpeas-gtk/peas-gtk-autocleanups.h deleted file mode 100644 index 587f3d8..0000000 --- a/libpeas-gtk/peas-gtk-autocleanups.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * peas-gtk-autocleanups.h - * This file is part of libpeas - * - * Copyright (C) 2015 - Garrett Regier - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - - -#ifndef __PEAS_GTK_AUTOCLEANUPS_H__ -#define __PEAS_GTK_AUTOCLEANUPS_H__ - -#include "peas-gtk-configurable.h" -#include "peas-gtk-plugin-manager.h" -#include "peas-gtk-plugin-manager-view.h" - -G_BEGIN_DECLS - -#ifndef __GI_SCANNER__ -#if GLIB_CHECK_VERSION (2, 44, 0) - -G_DEFINE_AUTOPTR_CLEANUP_FUNC (PeasGtkConfigurable, g_object_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC (PeasGtkPluginManager, g_object_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC (PeasGtkPluginManagerView, g_object_unref) - -#endif /* GLIB_CHECK_VERSION (2, 44, 0) */ -#endif /* __GI_SCANNER__ */ - -G_END_DECLS - -#endif /* __PEAS_GTK_AUTOCLEANUPS_H__ */ diff --git a/libpeas-gtk/peas-gtk-configurable.c b/libpeas-gtk/peas-gtk-configurable.c deleted file mode 100644 index afd634c..0000000 --- a/libpeas-gtk/peas-gtk-configurable.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * peas-gtk-configurable.c - * This file is part of libpeas - * - * Copyright (C) 2009-2010 Steve Frécinaux - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "peas-gtk-configurable.h" - -/** - * PeasGtkConfigurable: - * - * Interface for providing a plugin configuration UI. - * - * The #PeasGtkConfigurable interface will allow a plugin to provide a - * graphical interface for the user to configure the plugin through the - * [class@PluginManager]: the #PeasGtkPluginManager will make its - * “Configure Plugin” button active when the selected plugin implements - * the #PeasGtkConfigurable interface. - * - * To allow plugin configuration from the #PeasGtkPluginManager, the - * plugin writer will just need to implement the - * [method@Configurable.create_configure_widget] method. - **/ - -G_DEFINE_INTERFACE(PeasGtkConfigurable, peas_gtk_configurable, G_TYPE_OBJECT) - -static void -peas_gtk_configurable_default_init (PeasGtkConfigurableInterface *iface) -{ -} - -/** - * peas_gtk_configurable_create_configure_widget: - * @configurable: A #PeasGtkConfigurable - * - * Creates the configure widget for the plugin. - * - * The returned widget should allow configuring all the relevant aspects of the - * plugin, and should allow instant-apply, as promoted by the Gnome Human - * Interface Guidelines. - * - * [class@PluginManager] will embed the returned widget into a dialog box, - * but you shouldn't take this behaviour for granted as other implementations - * of a plugin manager UI might do otherwise. - * - * This method should always return a valid [class@Gtk.Widget] instance, never %NULL. - * - * Returns: (transfer full): A #GtkWidget used for configuration. - */ -GtkWidget * -peas_gtk_configurable_create_configure_widget (PeasGtkConfigurable *configurable) -{ - PeasGtkConfigurableInterface *iface; - - g_return_val_if_fail (PEAS_GTK_IS_CONFIGURABLE (configurable), NULL); - - iface = PEAS_GTK_CONFIGURABLE_GET_IFACE (configurable); - - if (G_LIKELY (iface->create_configure_widget != NULL)) - return iface->create_configure_widget (configurable); - - /* Default implementation */ - return NULL; -} diff --git a/libpeas-gtk/peas-gtk-configurable.h b/libpeas-gtk/peas-gtk-configurable.h deleted file mode 100644 index 20a79b1..0000000 --- a/libpeas-gtk/peas-gtk-configurable.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * peas-gtk-configurable.h - * This file is part of libpeas - * - * Copyright (C) 2009 Steve Frécinaux - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __PEAS_GTK_CONFIGURABLE_H__ -#define __PEAS_GTK_CONFIGURABLE_H__ - -#include <gtk/gtk.h> -#include <libpeas/peas.h> - -G_BEGIN_DECLS - -/* - * Type checking and casting macros - */ -#define PEAS_GTK_TYPE_CONFIGURABLE (peas_gtk_configurable_get_type ()) -#define PEAS_GTK_CONFIGURABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PEAS_GTK_TYPE_CONFIGURABLE, PeasGtkConfigurable)) -#define PEAS_GTK_CONFIGURABLE_IFACE(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), PEAS_GTK_TYPE_CONFIGURABLE, PeasGtkConfigurableInterface)) -#define PEAS_GTK_IS_CONFIGURABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PEAS_GTK_TYPE_CONFIGURABLE)) -#define PEAS_GTK_CONFIGURABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), PEAS_GTK_TYPE_CONFIGURABLE, PeasGtkConfigurableInterface)) - -/** - * PeasGtkConfigurable: - * - * Interface for configurable plugins. - */ -typedef struct _PeasGtkConfigurable PeasGtkConfigurable; /* dummy typedef */ -typedef struct _PeasGtkConfigurableInterface PeasGtkConfigurableInterface; - -/** - * PeasGtkConfigurableInterface: - * @g_iface: The parent interface. - * @create_configure_widget: Creates the configure widget for the plugin. - * - * Provides an interface for configurable plugins. - */ -struct _PeasGtkConfigurableInterface -{ - GTypeInterface g_iface; - - GtkWidget *(*create_configure_widget) (PeasGtkConfigurable *configurable); -}; - -PEAS_AVAILABLE_IN_ALL -GType peas_gtk_configurable_get_type (void) G_GNUC_CONST; -PEAS_AVAILABLE_IN_ALL -GtkWidget *peas_gtk_configurable_create_configure_widget (PeasGtkConfigurable *configurable); - -G_END_DECLS - -#endif /* __PEAS_GTK_PLUGIN_MANAGER_H__ */ diff --git a/libpeas-gtk/peas-gtk-disable-plugins-dialog.c b/libpeas-gtk/peas-gtk-disable-plugins-dialog.c deleted file mode 100644 index 2b01389..0000000 --- a/libpeas-gtk/peas-gtk-disable-plugins-dialog.c +++ /dev/null @@ -1,309 +0,0 @@ -/* - * peas-gtk-disable-plugins-dialog.c - * This file is part of libpeas - * - * Copyright (C) 2011 Garrett Regier - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <libpeas/peas-i18n-priv.h> -#include <libpeas/peas-plugin-info.h> - -#include "peas-gtk-disable-plugins-dialog.h" - -enum { - PLUGIN_INFO_NAME_COLUMN = 0 -}; - -typedef struct { - PeasPluginInfo *plugin_info; - GList *dep_plugins; -} PeasGtkDisablePluginsDialogPrivate; - -/* Properties */ -enum { - PROP_0, - PROP_PLUGIN_INFO, - PROP_DEPENDENT_PLUGINS, - N_PROPERTIES -}; - -static GParamSpec *properties[N_PROPERTIES] = { NULL }; - -G_DEFINE_TYPE_WITH_PRIVATE (PeasGtkDisablePluginsDialog, - peas_gtk_disable_plugins_dialog, - GTK_TYPE_MESSAGE_DIALOG) - -#define GET_PRIV(o) \ - (peas_gtk_disable_plugins_dialog_get_instance_private (o)) - -static gint -model_name_sort_func (GtkListStore *store, - GtkTreeIter *iter1, - GtkTreeIter *iter2, - gpointer user_data) -{ - gchar *name1, *name2; - gint retval; - - gtk_tree_model_get (GTK_TREE_MODEL (store), iter1, - PLUGIN_INFO_NAME_COLUMN, &name1, - -1); - - gtk_tree_model_get (GTK_TREE_MODEL (store), iter1, - PLUGIN_INFO_NAME_COLUMN, &name2, - -1); - - retval = g_utf8_collate (name1, name2); - - g_free (name1); - g_free (name2); - - return retval; -} - -static void -build_multiple_dependent_plugins (PeasGtkDisablePluginsDialog *dialog) -{ - PeasGtkDisablePluginsDialogPrivate *priv = GET_PRIV (dialog); - gchar *message; - GtkWidget *message_area; - GtkWidget *sw; - GtkListStore *store; - GList *dep_plugin; - GtkWidget *tree_view; - GtkCellRenderer *cell; - - message = g_strconcat ("<span weight=\"bold\" size=\"larger\">", - _("Additional plugins must be disabled"), - "</span>", NULL); - - gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), message); - g_free (message); - - gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), - _("The following plugins depend on “%s” and will also be disabled:"), - peas_plugin_info_get_name (priv->plugin_info)); - - message_area = gtk_message_dialog_get_message_area (GTK_MESSAGE_DIALOG (dialog)); - - sw = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), - GTK_SHADOW_IN); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_box_pack_start (GTK_BOX (message_area), sw, TRUE, TRUE, 0); - - store = gtk_list_store_new (1, G_TYPE_STRING); - - /* Sort on the plugin names */ - gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (store), - (GtkTreeIterCompareFunc) model_name_sort_func, - NULL, NULL); - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), - GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, - GTK_SORT_ASCENDING); - - for (dep_plugin = priv->dep_plugins; dep_plugin != NULL; - dep_plugin = dep_plugin->next) - { - PeasPluginInfo *plugin = (PeasPluginInfo *) dep_plugin->data; - GtkTreeIter iter; - - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, - PLUGIN_INFO_NAME_COLUMN, peas_plugin_info_get_name (plugin), - -1); - } - - tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store)); - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE); - gtk_tree_view_set_enable_search (GTK_TREE_VIEW (tree_view), FALSE); - gtk_widget_set_size_request (tree_view, 260, 120); - gtk_container_add (GTK_CONTAINER (sw), tree_view); - - cell = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), - 0, _("Plugins"), - cell, - "text", PLUGIN_INFO_NAME_COLUMN, - NULL); - - g_object_unref (store); - - gtk_widget_show_all (sw); -} - -static void -build_single_dependent_plugin (PeasGtkDisablePluginsDialog *dialog) -{ - PeasGtkDisablePluginsDialogPrivate *priv = GET_PRIV (dialog); - gchar *message; - - message = g_strconcat ("<span weight=\"bold\" size=\"larger\">", - _("An additional plugin must be disabled"), - "</span>", NULL); - - gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), message); - g_free (message); - - gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), - _("The “%s” plugin depends on the “%s” plugin.\n" - "If you disable “%s”, “%s” will also be disabled."), - peas_plugin_info_get_name (priv->plugin_info), - peas_plugin_info_get_name (priv->dep_plugins->data), - peas_plugin_info_get_name (priv->plugin_info), - peas_plugin_info_get_name (priv->dep_plugins->data)); -} - -static void -peas_gtk_disable_plugins_dialog_init (PeasGtkDisablePluginsDialog *dialog) -{ - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - - gtk_dialog_add_button (GTK_DIALOG (dialog), - _("_Cancel"), GTK_RESPONSE_CANCEL); - gtk_dialog_add_button (GTK_DIALOG (dialog), - _("Disable Plugins"), GTK_RESPONSE_OK); -} - -static void -peas_gtk_disable_plugins_dialog_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - PeasGtkDisablePluginsDialog *dialog = PEAS_GTK_DISABLE_PLUGINS_DIALOG (object); - PeasGtkDisablePluginsDialogPrivate *priv = GET_PRIV (dialog); - - switch (prop_id) - { - case PROP_PLUGIN_INFO: - priv->plugin_info = g_value_get_pointer (value); - break; - case PROP_DEPENDENT_PLUGINS: - priv->dep_plugins = g_value_get_pointer (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -peas_gtk_disable_plugins_dialog_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - PeasGtkDisablePluginsDialog *dialog = PEAS_GTK_DISABLE_PLUGINS_DIALOG (object); - PeasGtkDisablePluginsDialogPrivate *priv = GET_PRIV (dialog); - - switch (prop_id) - { - case PROP_PLUGIN_INFO: - g_value_set_pointer (value, priv->plugin_info); - break; - case PROP_DEPENDENT_PLUGINS: - g_value_set_pointer (value, priv->dep_plugins); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -peas_gtk_disable_plugins_dialog_constructed (GObject *object) -{ - PeasGtkDisablePluginsDialog *dialog = PEAS_GTK_DISABLE_PLUGINS_DIALOG (object); - PeasGtkDisablePluginsDialogPrivate *priv = GET_PRIV (dialog); - - if (priv->dep_plugins->next == NULL) - build_single_dependent_plugin (dialog); - else - build_multiple_dependent_plugins (dialog); - - G_OBJECT_CLASS (peas_gtk_disable_plugins_dialog_parent_class)->constructed (object); -} - -static void -peas_gtk_disable_plugins_dialog_finalize (GObject *object) -{ - PeasGtkDisablePluginsDialog *dialog = PEAS_GTK_DISABLE_PLUGINS_DIALOG (object); - PeasGtkDisablePluginsDialogPrivate *priv = GET_PRIV (dialog); - - g_list_free (priv->dep_plugins); - - G_OBJECT_CLASS (peas_gtk_disable_plugins_dialog_parent_class)->finalize (object); -} - -static void -peas_gtk_disable_plugins_dialog_class_init (PeasGtkDisablePluginsDialogClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->get_property = peas_gtk_disable_plugins_dialog_get_property; - object_class->set_property = peas_gtk_disable_plugins_dialog_set_property; - object_class->constructed = peas_gtk_disable_plugins_dialog_constructed; - object_class->finalize = peas_gtk_disable_plugins_dialog_finalize; - - properties[PROP_PLUGIN_INFO] = - g_param_spec_pointer ("plugin-info", - "Plugin Information", - "Plugin that is being disabled", - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - - properties[PROP_DEPENDENT_PLUGINS] = - g_param_spec_pointer ("dependent-plugins", - "Dependant plugins", - "Dependant plugins", - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - - g_object_class_install_properties (object_class, N_PROPERTIES, properties); -} - -/* - * peas_gtk_disable_plugins_dialog_new: - * @parent: transient window. - * @info: the #PeasPluginInfo being disabled. - * @dep_plugins: (transfer container) (element-type Peas.PluginInfo): - * list of plugins that are dependent on @info. - * - * Creates a new #PeasGtkDisablePluginsDialog. - * - * Returns: the new #PeasGtkDisablePluginsDialog. - */ -GtkWidget * -peas_gtk_disable_plugins_dialog_new (GtkWindow *parent, - PeasPluginInfo *info, - GList *dep_plugins) -{ - return GTK_WIDGET (g_object_new (PEAS_GTK_TYPE_DISABLE_PLUGINS_DIALOG, - "transient-for", parent, - "plugin-info", info, - "dependent-plugins", dep_plugins, - "message-type", GTK_MESSAGE_QUESTION, - NULL)); -} diff --git a/libpeas-gtk/peas-gtk-disable-plugins-dialog.h b/libpeas-gtk/peas-gtk-disable-plugins-dialog.h deleted file mode 100644 index f7cb4f6..0000000 --- a/libpeas-gtk/peas-gtk-disable-plugins-dialog.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * peas-gtk-disable-plugins-dialog.h - * This file is part of libpeas - * - * Copyright (C) 2011 Garrett Regier - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __PEAS_GTK_DISABLE_PLUGINS_DIALOG_H__ -#define __PEAS_GTK_DISABLE_PLUGINS_DIALOG_H__ - -#include <gtk/gtk.h> -#include <libpeas/peas-plugin-info.h> - -G_BEGIN_DECLS - -/* - * Type checking and casting macros - */ -#define PEAS_GTK_TYPE_DISABLE_PLUGINS_DIALOG (peas_gtk_disable_plugins_dialog_get_type()) -#define PEAS_GTK_DISABLE_PLUGINS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PEAS_GTK_TYPE_DISABLE_PLUGINS_DIALOG, PeasGtkDisablePluginsDialog)) -#define PEAS_GTK_DISABLE_PLUGINS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PEAS_GTK_TYPE_DISABLE_PLUGINS_DIALOG, PeasGtkDisablePluginsDialogClass)) -#define PEAS_GTK_IS_DISABLE_PLUGINS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PEAS_GTK_TYPE_DISABLE_PLUGINS_DIALOG)) -#define PEAS_GTK_IS_DISABLE_PLUGINS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PEAS_GTK_TYPE_DISABLE_PLUGINS_DIALOG)) -#define PEAS_GTK_DISABLE_PLUGINS_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PEAS_GTK_TYPE_DISABLE_PLUGINS_DIALOG, PeasGtkDisablePluginsDialogClass)) - -typedef struct _PeasGtkDisablePluginsDialog PeasGtkDisablePluginsDialog; -typedef struct _PeasGtkDisablePluginsDialogClass PeasGtkDisablePluginsDialogClass; - -struct _PeasGtkDisablePluginsDialog { - GtkMessageDialog parent; -}; - -struct _PeasGtkDisablePluginsDialogClass { - GtkMessageDialogClass parent_class; -}; - -GType peas_gtk_disable_plugins_dialog_get_type (void) G_GNUC_CONST; - -GtkWidget *peas_gtk_disable_plugins_dialog_new (GtkWindow *parent, - PeasPluginInfo *info, - GList *dep_plugins); - -G_END_DECLS - -#endif /* __PEAS_GTK_DISABLE_PLUGINS_DIALOG_H__ */ diff --git a/libpeas-gtk/peas-gtk-plugin-manager-store.c b/libpeas-gtk/peas-gtk-plugin-manager-store.c deleted file mode 100644 index e181195..0000000 --- a/libpeas-gtk/peas-gtk-plugin-manager-store.c +++ /dev/null @@ -1,599 +0,0 @@ -/* - * peas-gtk-plugin-manager-store.c - * This file is part of libpeas - * - * Copyright (C) 2002 Paolo Maggi and James Willcox - * Copyright (C) 2003-2006 Paolo Maggi, Paolo Borelli - * Copyright (C) 2007-2009 Paolo Maggi, Paolo Borelli, Steve Frécinaux - * Copyright (C) 2010 Garrett Regier - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gio/gio.h> - -#include <libpeas/peas-plugin-info.h> - -#include "peas-gtk-plugin-manager-store.h" - -static const GType ColumnTypes[] = { - G_TYPE_BOOLEAN, /* Enabled */ - G_TYPE_BOOLEAN, /* Enabled Visible */ - G_TYPE_OBJECT, /* GIcon Icon */ - G_TYPE_STRING, /* Stock ID Icon */ - G_TYPE_BOOLEAN, /* Icon Visible */ - G_TYPE_STRING, /* Info */ - G_TYPE_BOOLEAN, /* Info Visible */ - /* To avoid having to unref it all the time */ - G_TYPE_POINTER /* PeasPluginInfo */ -}; - -G_STATIC_ASSERT (G_N_ELEMENTS (ColumnTypes) == PEAS_GTK_PLUGIN_MANAGER_STORE_N_COLUMNS); - -typedef struct { - PeasEngine *engine; -} PeasGtkPluginManagerStorePrivate; - -/* Properties */ -enum { - PROP_0, - PROP_ENGINE, - N_PROPERTIES -}; - -static GParamSpec *properties[N_PROPERTIES] = { NULL }; - -G_DEFINE_TYPE_WITH_PRIVATE (PeasGtkPluginManagerStore, - peas_gtk_plugin_manager_store, - GTK_TYPE_LIST_STORE) - -#define GET_PRIV(o) \ - (peas_gtk_plugin_manager_store_get_instance_private (o)) - -static void -update_plugin (PeasGtkPluginManagerStore *store, - GtkTreeIter *iter, - PeasPluginInfo *info) -{ - gboolean loaded; - gboolean available; - gboolean builtin; - gchar *markup; - const gchar *icon_name; - const gchar *icon_stock_id = NULL; - GIcon *icon_gicon = NULL; - - loaded = peas_plugin_info_is_loaded (info); - available = peas_plugin_info_is_available (info, NULL); - builtin = peas_plugin_info_is_builtin (info); - - if (peas_plugin_info_get_description (info) == NULL) - { - markup = g_markup_printf_escaped ("<b>%s</b>", - peas_plugin_info_get_name (info)); - } - else - { - markup = g_markup_printf_escaped ("<b>%s</b>\n%s", - peas_plugin_info_get_name (info), - peas_plugin_info_get_description (info)); - } - - if (!available) - { - icon_gicon = g_themed_icon_new ("dialog-error"); - } - else - { - gchar *icon_path; - - icon_name = peas_plugin_info_get_icon_name (info); - icon_path = g_build_filename (peas_plugin_info_get_data_dir (info), - icon_name, - NULL); - - /* Prevent warning for the common case that icon_path - * does not exist but warn when it is a directory - */ - if (g_file_test (icon_path, G_FILE_TEST_EXISTS)) - { - GFile *icon_file; - - icon_file = g_file_new_for_path (icon_path); - icon_gicon = g_file_icon_new (icon_file); - - g_object_unref (icon_file); - } - else - { - gint i; - GtkIconTheme *icon_theme; - const gchar * const *names; - gboolean found_icon = FALSE; - - icon_gicon = g_themed_icon_new_with_default_fallbacks (icon_name); - - icon_theme = gtk_icon_theme_get_default (); - names = g_themed_icon_get_names (G_THEMED_ICON (icon_gicon)); - - for (i = 0; !found_icon && names[i] != NULL; ++i) - found_icon = gtk_icon_theme_has_icon (icon_theme, names[i]); - - if (!found_icon) - { - GtkStockItem stock_item; - - g_clear_object (&icon_gicon); - - G_GNUC_BEGIN_IGNORE_DEPRECATIONS - if (gtk_stock_lookup (icon_name, &stock_item)) - { - icon_stock_id = icon_name; - } - else - { - icon_gicon = g_themed_icon_new ("libpeas-plugin"); - } - G_GNUC_END_IGNORE_DEPRECATIONS - } - } - - g_free (icon_path); - } - - gtk_list_store_set (GTK_LIST_STORE (store), iter, - PEAS_GTK_PLUGIN_MANAGER_STORE_ENABLED_COLUMN, loaded, - PEAS_GTK_PLUGIN_MANAGER_STORE_CAN_ENABLE_COLUMN, !builtin && available, - PEAS_GTK_PLUGIN_MANAGER_STORE_ICON_GICON_COLUMN, icon_gicon, - PEAS_GTK_PLUGIN_MANAGER_STORE_ICON_STOCK_ID_COLUMN, icon_stock_id, - PEAS_GTK_PLUGIN_MANAGER_STORE_ICON_VISIBLE_COLUMN, !available, - PEAS_GTK_PLUGIN_MANAGER_STORE_INFO_COLUMN, markup, - PEAS_GTK_PLUGIN_MANAGER_STORE_INFO_SENSITIVE_COLUMN, available && (!builtin || loaded), - PEAS_GTK_PLUGIN_MANAGER_STORE_PLUGIN_COLUMN, info, - -1); - - g_clear_object (&icon_gicon); - g_free (markup); -} - -static void -plugin_loaded_toggled_cb (PeasEngine *engine, - PeasPluginInfo *info, - PeasGtkPluginManagerStore *store) -{ - GtkTreeIter iter; - - if (peas_gtk_plugin_manager_store_get_iter_from_plugin (store, &iter, info)) - update_plugin (store, &iter, info); -} - -static gint -model_name_sort_func (PeasGtkPluginManagerStore *store, - GtkTreeIter *iter1, - GtkTreeIter *iter2, - gpointer user_data) -{ - PeasPluginInfo *info1; - PeasPluginInfo *info2; - - info1 = peas_gtk_plugin_manager_store_get_plugin (store, iter1); - info2 = peas_gtk_plugin_manager_store_get_plugin (store, iter2); - - return g_utf8_collate (peas_plugin_info_get_name (info1), - peas_plugin_info_get_name (info2)); -} - -static void -peas_gtk_plugin_manager_store_init (PeasGtkPluginManagerStore *store) -{ - gtk_list_store_set_column_types (GTK_LIST_STORE (store), - PEAS_GTK_PLUGIN_MANAGER_STORE_N_COLUMNS, - (GType *) ColumnTypes); - - /* Sort on the plugin names */ - gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (store), - (GtkTreeIterCompareFunc) model_name_sort_func, - NULL, NULL); - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), - GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, - GTK_SORT_ASCENDING); -} - -static void -peas_gtk_plugin_manager_store_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - PeasGtkPluginManagerStore *store = PEAS_GTK_PLUGIN_MANAGER_STORE (object); - PeasGtkPluginManagerStorePrivate *priv = GET_PRIV (store); - - switch (prop_id) - { - case PROP_ENGINE: - priv->engine = g_value_get_object (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -peas_gtk_plugin_manager_store_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - PeasGtkPluginManagerStore *store = PEAS_GTK_PLUGIN_MANAGER_STORE (object); - PeasGtkPluginManagerStorePrivate *priv = GET_PRIV (store); - - switch (prop_id) - { - case PROP_ENGINE: - g_value_set_object (value, priv->engine); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -peas_gtk_plugin_manager_store_constructed (GObject *object) -{ - PeasGtkPluginManagerStore *store = PEAS_GTK_PLUGIN_MANAGER_STORE (object); - PeasGtkPluginManagerStorePrivate *priv = GET_PRIV (store); - - if (priv->engine == NULL) - priv->engine = peas_engine_get_default (); - - g_object_ref (priv->engine); - - g_signal_connect_object (priv->engine, - "load-plugin", - G_CALLBACK (plugin_loaded_toggled_cb), - store, - G_CONNECT_AFTER); - g_signal_connect_object (priv->engine, - "unload-plugin", - G_CALLBACK (plugin_loaded_toggled_cb), - store, - G_CONNECT_AFTER); - - peas_gtk_plugin_manager_store_reload (store); - - G_OBJECT_CLASS (peas_gtk_plugin_manager_store_parent_class)->constructed (object); -} - -static void -peas_gtk_plugin_manager_store_dispose (GObject *object) -{ - PeasGtkPluginManagerStore *store = PEAS_GTK_PLUGIN_MANAGER_STORE (object); - PeasGtkPluginManagerStorePrivate *priv = GET_PRIV (store); - - g_clear_object (&priv->engine); - - G_OBJECT_CLASS (peas_gtk_plugin_manager_store_parent_class)->dispose (object); -} - -static void -peas_gtk_plugin_manager_store_class_init (PeasGtkPluginManagerStoreClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->set_property = peas_gtk_plugin_manager_store_set_property; - object_class->get_property = peas_gtk_plugin_manager_store_get_property; - object_class->constructed = peas_gtk_plugin_manager_store_constructed; - object_class->dispose = peas_gtk_plugin_manager_store_dispose; - - /* - * PeasGtkPLuginManagerStore:engine: - * - * The #PeasEngine this store is attached to. - */ - properties[PROP_ENGINE] = - g_param_spec_object ("engine", - "engine", - "The PeasEngine this store is attached to", - PEAS_TYPE_ENGINE, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - - g_object_class_install_properties (object_class, N_PROPERTIES, properties); -} - -/* - * peas_gtk_plugin_manager_store_new: - * @engine: (allow-none): A #PeasEngine, or %NULL. - * - * Creates a new plugin manager store for the given #PeasEngine. - * - * If @engine is %NULL, then the default engine will be used. - * - * Returns: the new #PeasGtkPluginManagerStore. - */ -PeasGtkPluginManagerStore * -peas_gtk_plugin_manager_store_new (PeasEngine *engine) -{ - g_return_val_if_fail (engine == NULL || PEAS_IS_ENGINE (engine), NULL); - - return PEAS_GTK_PLUGIN_MANAGER_STORE (g_object_new (PEAS_GTK_TYPE_PLUGIN_MANAGER_STORE, - "engine", engine, - NULL)); -} - -/* - * peas_gtk_plugin_manager_store_reload: - * @store: A #PeasGtkPluginManagerStore. - * - * Reloads the list of plugins. - */ -void -peas_gtk_plugin_manager_store_reload (PeasGtkPluginManagerStore *store) -{ - PeasGtkPluginManagerStorePrivate *priv = GET_PRIV (store); - GtkListStore *list_store; - const GList *plugins; - GtkTreeIter iter; - - g_return_if_fail (PEAS_GTK_IS_PLUGIN_MANAGER_STORE (store)); - - list_store = GTK_LIST_STORE (store); - - gtk_list_store_clear (list_store); - - plugins = peas_engine_get_plugin_list (priv->engine); - - while (plugins != NULL) - { - PeasPluginInfo *info; - - info = PEAS_PLUGIN_INFO (plugins->data); - - if (!peas_plugin_info_is_hidden (info)) - { - gtk_list_store_append (list_store, &iter); - update_plugin (store, &iter, info); - } - - plugins = plugins->next; - } -} - -/* - * peas_gtk_plugin_manager_store_set_enabled: - * @store: A #PeasGtkPluginManagerStore. - * @iter: A #GtkTreeIter. - * @enabled: If the plugin should be enabled. - * - * Sets if the plugin at @iter should be enabled. - */ -void -peas_gtk_plugin_manager_store_set_enabled (PeasGtkPluginManagerStore *store, - GtkTreeIter *iter, - gboolean enabled) -{ - PeasGtkPluginManagerStorePrivate *priv = GET_PRIV (store); - PeasPluginInfo *info; - - g_return_if_fail (PEAS_GTK_IS_PLUGIN_MANAGER_STORE (store)); - g_return_if_fail (iter != NULL); - g_return_if_fail (peas_gtk_plugin_manager_store_can_enable (store, iter)); - - info = peas_gtk_plugin_manager_store_get_plugin (store, iter); - g_return_if_fail (info != NULL); - - if (enabled) - { - peas_engine_load_plugin (priv->engine, info); - } - else - { - peas_engine_unload_plugin (priv->engine, info); - } - - /* Don't need to manually update the plugin as - * PeasEngine::{load,unload}-plugin are connected to - */ -} - -/* - * peas_gtk_plugin_manager_store_set_enabled: - * @store: A #PeasGtkPluginManagerStore. - * @iter: A #GtkTreeIter. - * - * Returns if the plugin at @iter is enabled. - * - * Returns: if the plugin at @iter is enabled. - */ -gboolean -peas_gtk_plugin_manager_store_get_enabled (PeasGtkPluginManagerStore *store, - GtkTreeIter *iter) -{ - GValue value = G_VALUE_INIT; - gboolean enabled; - - g_return_val_if_fail (PEAS_GTK_IS_PLUGIN_MANAGER_STORE (store), FALSE); - g_return_val_if_fail (iter != NULL, FALSE); - - gtk_tree_model_get_value (GTK_TREE_MODEL (store), iter, - PEAS_GTK_PLUGIN_MANAGER_STORE_ENABLED_COLUMN, &value); - - g_return_val_if_fail (G_VALUE_HOLDS_BOOLEAN (&value), FALSE); - enabled = g_value_get_boolean (&value); - - g_value_unset (&value); - - return enabled; -} - -/* - * peas_gtk_plugin_manager_store_set_all_enabled: - * @store: A #PeasGtkPluginManagerStore. - * @enabled: If all the plugins should be enabled. - * - * Sets if all the plugins should be enabled. - */ -void -peas_gtk_plugin_manager_store_set_all_enabled (PeasGtkPluginManagerStore *store, - gboolean enabled) -{ - GtkTreeModel *model; - GtkTreeIter iter; - - g_return_if_fail (PEAS_GTK_IS_PLUGIN_MANAGER_STORE (store)); - - model = GTK_TREE_MODEL (store); - - if (!gtk_tree_model_get_iter_first (model, &iter)) - return; - - do - { - if (peas_gtk_plugin_manager_store_can_enable (store, &iter)) - peas_gtk_plugin_manager_store_set_enabled (store, &iter, enabled); - } - while (gtk_tree_model_iter_next (model, &iter)); -} - -/* - * peas_gtk_plugin_manager_store_toggle_enabled: - * @store: A #PeasGtkPluginManagerStore. - * @iter: A #GtkTreeIter. - * - * Toggles the if the plugin should should be enabled. - */ -void -peas_gtk_plugin_manager_store_toggle_enabled (PeasGtkPluginManagerStore *store, - GtkTreeIter *iter) -{ - gboolean enabled; - - g_return_if_fail (PEAS_GTK_IS_PLUGIN_MANAGER_STORE (store)); - g_return_if_fail (iter != NULL); - - enabled = peas_gtk_plugin_manager_store_get_enabled (store, iter); - - peas_gtk_plugin_manager_store_set_enabled (store, iter, !enabled); -} - -/* - * peas_gtk_plugin_manager_store_can_enabled: - * @store: A #PeasGtkPluginManagerStore. - * @iter: A #GtkTreeIter. - * - * Returns if the plugin at @iter can be enabled. - * Note: that while a plugin may be enableable there are other factors - * that can cause it to not be enabled. - * - * Returns: if the plugin can be enabled. - */ -gboolean -peas_gtk_plugin_manager_store_can_enable (PeasGtkPluginManagerStore *store, - GtkTreeIter *iter) -{ - GValue value = G_VALUE_INIT; - gboolean can_enable; - - g_return_val_if_fail (PEAS_GTK_IS_PLUGIN_MANAGER_STORE (store), FALSE); - g_return_val_if_fail (iter != NULL, FALSE); - - gtk_tree_model_get_value (GTK_TREE_MODEL (store), iter, - PEAS_GTK_PLUGIN_MANAGER_STORE_CAN_ENABLE_COLUMN, &value); - - g_return_val_if_fail (G_VALUE_HOLDS_BOOLEAN (&value), FALSE); - can_enable = g_value_get_boolean (&value); - - g_value_unset (&value); - - return can_enable; -} - -/* - * peas_gtk_plugin_manager_store_get_plugin: - * @store: A #PeasGtkPluginManagerStore. - * @iter: A #GtkTreeIter. - * - * Returns the plugin at @iter. - * - * Returns: the plugin at @iter. - */ -PeasPluginInfo * -peas_gtk_plugin_manager_store_get_plugin (PeasGtkPluginManagerStore *store, - GtkTreeIter *iter) -{ - GValue value = G_VALUE_INIT; - PeasPluginInfo *info; - - g_return_val_if_fail (PEAS_GTK_IS_PLUGIN_MANAGER_STORE (store), NULL); - g_return_val_if_fail (iter != NULL, NULL); - - gtk_tree_model_get_value (GTK_TREE_MODEL (store), iter, - PEAS_GTK_PLUGIN_MANAGER_STORE_PLUGIN_COLUMN, &value); - - g_return_val_if_fail (G_VALUE_HOLDS_POINTER (&value), NULL); - info = g_value_get_pointer (&value); - - g_value_unset (&value); - - /* We register it as a pointer instead - * of a boxed so no need to unref it - */ - return info; -} - -/* - * peas_gtk_plugin_manager_store_get_iter_from_plugin: - * @store: A #PeasGtkPluginManagerStore. - * @iter: A #GtkTreeIter. - * @info: A #PeasPluginInfo. - * - * Sets @iter to the @info. - * - * Returns: if @iter was set. - */ -gboolean -peas_gtk_plugin_manager_store_get_iter_from_plugin (PeasGtkPluginManagerStore *store, - GtkTreeIter *iter, - const PeasPluginInfo *info) -{ - GtkTreeModel *model = GTK_TREE_MODEL (store); - gboolean found = FALSE; - - g_return_val_if_fail (PEAS_GTK_IS_PLUGIN_MANAGER_STORE (store), FALSE); - g_return_val_if_fail (iter != NULL, FALSE); - g_return_val_if_fail (info != NULL, FALSE); - - if (gtk_tree_model_get_iter_first (model, iter)) - { - PeasPluginInfo *current_info; - - do - { - current_info = peas_gtk_plugin_manager_store_get_plugin (store, iter); - - found = (info == current_info); - } - while (!found && gtk_tree_model_iter_next (model, iter)); - } - - return found; -} diff --git a/libpeas-gtk/peas-gtk-plugin-manager-store.h b/libpeas-gtk/peas-gtk-plugin-manager-store.h deleted file mode 100644 index 6c3a13b..0000000 --- a/libpeas-gtk/peas-gtk-plugin-manager-store.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * peas-plugin-manager-store.h - * This file is part of libpeas - * - * Copyright (C) 2002 Paolo Maggi and James Willcox - * Copyright (C) 2003-2006 Paolo Maggi, Paolo Borelli - * Copyright (C) 2007-2009 Paolo Maggi, Paolo Borelli, Steve Frécinaux - * Copyright (C) 2010 Garrett Regier - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __PEAS_GTK_PLUGIN_MANAGER_STORE_H__ -#define __PEAS_GTK_PLUGIN_MANAGER_STORE_H__ - -#include <gtk/gtk.h> -#include <libpeas/peas-engine.h> -#include <libpeas/peas-plugin-info.h> - -G_BEGIN_DECLS - -typedef enum { - PEAS_GTK_PLUGIN_MANAGER_STORE_ENABLED_COLUMN = 0, - PEAS_GTK_PLUGIN_MANAGER_STORE_CAN_ENABLE_COLUMN, - PEAS_GTK_PLUGIN_MANAGER_STORE_ICON_GICON_COLUMN, - PEAS_GTK_PLUGIN_MANAGER_STORE_ICON_STOCK_ID_COLUMN, - PEAS_GTK_PLUGIN_MANAGER_STORE_ICON_VISIBLE_COLUMN, - PEAS_GTK_PLUGIN_MANAGER_STORE_INFO_COLUMN, - PEAS_GTK_PLUGIN_MANAGER_STORE_INFO_SENSITIVE_COLUMN, - PEAS_GTK_PLUGIN_MANAGER_STORE_PLUGIN_COLUMN, - PEAS_GTK_PLUGIN_MANAGER_STORE_N_COLUMNS -} PeasGtkPluginManagerStoreColumns; - -/* - * Type checking and casting macros - */ -#define PEAS_GTK_TYPE_PLUGIN_MANAGER_STORE (peas_gtk_plugin_manager_store_get_type()) -#define PEAS_GTK_PLUGIN_MANAGER_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PEAS_GTK_TYPE_PLUGIN_MANAGER_STORE, PeasGtkPluginManagerStore)) -#define PEAS_GTK_PLUGIN_MANAGER_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PEAS_GTK_TYPE_PLUGIN_MANAGER_STORE, PeasGtkPluginManagerStoreClass)) -#define PEAS_GTK_IS_PLUGIN_MANAGER_STORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PEAS_GTK_TYPE_PLUGIN_MANAGER_STORE)) -#define PEAS_GTK_IS_PLUGIN_MANAGER_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PEAS_GTK_TYPE_PLUGIN_MANAGER_STORE)) -#define PEAS_GTK_PLUGIN_MANAGER_STORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PEAS_GTK_TYPE_PLUGIN_MANAGER_STORE, PeasGtkPluginManagerStoreClass)) - -typedef struct _PeasGtkPluginManagerStore PeasGtkPluginManagerStore; -typedef struct _PeasGtkPluginManagerStoreClass PeasGtkPluginManagerStoreClass; - -struct _PeasGtkPluginManagerStore { - GtkListStore parent; -}; - -struct _PeasGtkPluginManagerStoreClass { - GtkListStoreClass parent_class; -}; - -GType peas_gtk_plugin_manager_store_get_type (void) G_GNUC_CONST; -PEAS_AVAILABLE_IN_ALL -PeasGtkPluginManagerStore *peas_gtk_plugin_manager_store_new (PeasEngine *engine); - -void peas_gtk_plugin_manager_store_reload (PeasGtkPluginManagerStore *store); - -void peas_gtk_plugin_manager_store_set_enabled (PeasGtkPluginManagerStore *store, - GtkTreeIter *iter, - gboolean enabled); -PEAS_AVAILABLE_IN_ALL -gboolean peas_gtk_plugin_manager_store_get_enabled (PeasGtkPluginManagerStore *store, - GtkTreeIter *iter); -void peas_gtk_plugin_manager_store_set_all_enabled (PeasGtkPluginManagerStore *store, - gboolean enabled); -void peas_gtk_plugin_manager_store_toggle_enabled (PeasGtkPluginManagerStore *store, - GtkTreeIter *iter); - -gboolean peas_gtk_plugin_manager_store_can_enable (PeasGtkPluginManagerStore *store, - GtkTreeIter *iter); - -PEAS_AVAILABLE_IN_ALL -PeasPluginInfo *peas_gtk_plugin_manager_store_get_plugin (PeasGtkPluginManagerStore *store, - GtkTreeIter *iter); - -PEAS_AVAILABLE_IN_ALL -gboolean peas_gtk_plugin_manager_store_get_iter_from_plugin (PeasGtkPluginManagerStore *store, - GtkTreeIter *iter, - const PeasPluginInfo *info); -G_END_DECLS - -#endif /* __PEAS_GTK_PLUGIN_MANAGER_STORE_H__ */ diff --git a/libpeas-gtk/peas-gtk-plugin-manager-view.c b/libpeas-gtk/peas-gtk-plugin-manager-view.c deleted file mode 100644 index 62b5011..0000000 --- a/libpeas-gtk/peas-gtk-plugin-manager-view.c +++ /dev/null @@ -1,1050 +0,0 @@ -/* - * peas-plugin-manager-view.c - * This file is part of libpeas - * - * Copyright (C) 2002 Paolo Maggi and James Willcox - * Copyright (C) 2003-2006 Paolo Maggi, Paolo Borelli - * Copyright (C) 2007-2009 Paolo Maggi, Paolo Borelli, Steve Frécinaux - * Copyright (C) 2010 Garrett Regier - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> - -#include <libpeas/peas-engine.h> -#include <libpeas/peas-i18n-priv.h> - -#include "peas-gtk-plugin-manager-view.h" -#include "peas-gtk-disable-plugins-dialog.h" -#include "peas-gtk-plugin-manager-store.h" -#include "peas-gtk-configurable.h" - -/** - * PeasGtkPluginManagerView: - * - * Management tree view for plugins. - * - * The #PeasGtkPluginManagerView is a tree view that can be used to manage - * plugins, i.e. load or unload them, and see some pieces of information. - * - * The only thing you need to do as an application writer if you wish - * to use the view to display your plugins is to instantiate it using - * [ctor@PluginManagerView.new] and pack it into another - * widget or a window. - * - * Note: Changing the model of the view is not supported. - * - **/ - -struct _PeasGtkPluginManagerViewPrivate { - PeasEngine *engine; - - PeasGtkPluginManagerStore *store; - - GtkWidget *popup_menu; - - guint show_builtin : 1; -}; - -/* Properties */ -enum { - PROP_0, - PROP_ENGINE, - PROP_SHOW_BUILTIN, - N_PROPERTIES -}; - -/* Signals */ -enum { - POPULATE_POPUP, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL]; -static GParamSpec *properties[N_PROPERTIES] = { NULL }; - -G_DEFINE_TYPE_WITH_PRIVATE (PeasGtkPluginManagerView, - peas_gtk_plugin_manager_view, - GTK_TYPE_TREE_VIEW) - -#define GET_PRIV(o) \ - (peas_gtk_plugin_manager_view_get_instance_private (o)) - -static void -convert_iter_to_child_iter (PeasGtkPluginManagerView *view, - GtkTreeIter *iter) -{ - PeasGtkPluginManagerViewPrivate *priv = GET_PRIV (view); - - if (!priv->show_builtin) - { - GtkTreeModel *model; - GtkTreeIter child_iter; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (view)); - - gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (model), - &child_iter, iter); - - *iter = child_iter; - } -} - -static gboolean -convert_child_iter_to_iter (PeasGtkPluginManagerView *view, - GtkTreeIter *child_iter) -{ - PeasGtkPluginManagerViewPrivate *priv = GET_PRIV (view); - gboolean success = TRUE; - - if (!priv->show_builtin) - { - GtkTreeModel *model; - GtkTreeIter iter; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (view)); - - success = gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (model), - &iter, child_iter); - - if (success) - *child_iter = iter; - } - - return success; -} - -static GList * -get_dependant_plugins (PeasGtkPluginManagerView *view, - PeasPluginInfo *info) -{ - PeasGtkPluginManagerViewPrivate *priv = GET_PRIV (view); - const gchar *module_name; - const GList *plugins; - GList *dep_plugins = NULL; - - module_name = peas_plugin_info_get_module_name (info); - plugins = peas_engine_get_plugin_list (priv->engine); - - for (; plugins != NULL; plugins = plugins->next) - { - PeasPluginInfo *plugin = (PeasPluginInfo *) plugins->data; - - if (peas_plugin_info_is_hidden (plugin) || - !peas_plugin_info_is_loaded (plugin)) - continue; - - /* Don't add builtin plugins if they are not shown */ - if (!priv->show_builtin && peas_plugin_info_is_builtin (plugin)) - continue; - - if (peas_plugin_info_has_dependency (plugin, module_name)) - dep_plugins = g_list_prepend (dep_plugins, plugin); - } - - return dep_plugins; -} - -static void -toggle_enabled (PeasGtkPluginManagerView *view, - GtkTreeIter *iter) -{ - PeasGtkPluginManagerViewPrivate *priv = GET_PRIV (view); - PeasPluginInfo *info; - - info = peas_gtk_plugin_manager_store_get_plugin (priv->store, iter); - - if (peas_plugin_info_is_loaded (info)) - { - GList *dep_plugins; - - dep_plugins = get_dependant_plugins (view, info); - - if (dep_plugins != NULL) - { - GtkWindow *parent; - GtkWidget *dialog; - gint response; - - parent = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))); - - /* The dialog takes the list so don't free it */ - dialog = peas_gtk_disable_plugins_dialog_new (parent, info, - dep_plugins); - - response = gtk_dialog_run (GTK_DIALOG (dialog)); - - gtk_widget_destroy (dialog); - - if (response != GTK_RESPONSE_OK) - return; - } - } - - peas_gtk_plugin_manager_store_toggle_enabled (priv->store, iter); -} - -static void -plugin_list_changed_cb (PeasEngine *engine, - GParamSpec *pspec, - PeasGtkPluginManagerView *view) -{ - PeasGtkPluginManagerViewPrivate *priv = GET_PRIV (view); - PeasPluginInfo *info; - - info = peas_gtk_plugin_manager_view_get_selected_plugin (view); - - peas_gtk_plugin_manager_store_reload (priv->store); - - if (info != NULL) - peas_gtk_plugin_manager_view_set_selected_plugin (view, info); -} - -static gboolean -filter_builtins_visible (PeasGtkPluginManagerStore *store, - GtkTreeIter *iter, - PeasGtkPluginManagerView *view) -{ - PeasGtkPluginManagerViewPrivate *priv = GET_PRIV (view); - PeasPluginInfo *info; - - /* We never filter showing builtins */ - g_assert (priv->show_builtin == FALSE); - - info = peas_gtk_plugin_manager_store_get_plugin (store, iter); - - if (info == NULL) - return FALSE; - - return !peas_plugin_info_is_builtin (info); -} - -static void -enabled_toggled_cb (GtkCellRendererToggle *cell, - gchar *path_str, - PeasGtkPluginManagerView *view) -{ - GtkTreeModel *model; - GtkTreePath *path; - GtkTreeIter iter; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (view)); - path = gtk_tree_path_new_from_string (path_str); - - if (gtk_tree_model_get_iter (model, &iter, path)) - { - convert_iter_to_child_iter (view, &iter); - toggle_enabled (view, &iter); - } - - gtk_tree_path_free (path); -} - -/* Callback used as the interactive search comparison function */ -static gboolean -name_search_cb (GtkTreeModel *model, - gint column, - const gchar *key, - GtkTreeIter *iter, - PeasGtkPluginManagerView *view) -{ - PeasGtkPluginManagerViewPrivate *priv = GET_PRIV (view); - GtkTreeIter child_iter = *iter; - PeasPluginInfo *info; - gchar *normalized_string; - gchar *normalized_key; - gchar *case_normalized_string; - gchar *case_normalized_key; - gint key_len; - gboolean retval; - - convert_iter_to_child_iter (view, &child_iter); - info = peas_gtk_plugin_manager_store_get_plugin (priv->store, &child_iter); - - if (info == NULL) - return FALSE; - - normalized_string = g_utf8_normalize (peas_plugin_info_get_name (info), -1, G_NORMALIZE_ALL); - normalized_key = g_utf8_normalize (key, -1, G_NORMALIZE_ALL); - case_normalized_string = g_utf8_casefold (normalized_string, -1); - case_normalized_key = g_utf8_casefold (normalized_key, -1); - - key_len = strlen (case_normalized_key); - - /* Oddly enough, this callback must return whether to stop the search - * because we found a match, not whether we actually matched. - */ - retval = strncmp (case_normalized_key, case_normalized_string, key_len) != 0; - - g_free (normalized_key); - g_free (normalized_string); - g_free (case_normalized_key); - g_free (case_normalized_string); - - return retval; -} - -static void -enabled_menu_cb (GtkMenu *menu, - PeasGtkPluginManagerView *view) -{ - GtkTreeIter iter; - GtkTreeSelection *selection; - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view)); - - g_return_if_fail (gtk_tree_selection_get_selected (selection, NULL, &iter)); - - convert_iter_to_child_iter (view, &iter); - - toggle_enabled (view, &iter); -} - -static void -enable_all_menu_cb (GtkMenu *menu, - PeasGtkPluginManagerView *view) -{ - PeasGtkPluginManagerViewPrivate *priv = GET_PRIV (view); - - peas_gtk_plugin_manager_store_set_all_enabled (priv->store, TRUE); -} - -static void -disable_all_menu_cb (GtkMenu *menu, - PeasGtkPluginManagerView *view) -{ - PeasGtkPluginManagerViewPrivate *priv = GET_PRIV (view); - - peas_gtk_plugin_manager_store_set_all_enabled (priv->store, FALSE); -} - -static GtkWidget * -create_popup_menu (PeasGtkPluginManagerView *view) -{ - PeasPluginInfo *info; - GtkWidget *menu; - GtkWidget *item; - - info = peas_gtk_plugin_manager_view_get_selected_plugin (view); - - if (info == NULL) - return NULL; - - menu = gtk_menu_new (); - - item = gtk_check_menu_item_new_with_mnemonic (_("_Enabled")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - peas_plugin_info_is_loaded (info)); - g_signal_connect (item, "toggled", G_CALLBACK (enabled_menu_cb), view); - gtk_widget_set_sensitive (item, peas_plugin_info_is_available (info, NULL) && - !peas_plugin_info_is_builtin (info)); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - - item = gtk_separator_menu_item_new (); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - - item = gtk_menu_item_new_with_mnemonic (_("E_nable All")); - g_signal_connect (item, "activate", G_CALLBACK (enable_all_menu_cb), view); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - - item = gtk_menu_item_new_with_mnemonic (_("_Disable All")); - g_signal_connect (item, "activate", G_CALLBACK (disable_all_menu_cb), view); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - - g_signal_emit (view, signals[POPULATE_POPUP], 0, menu); - - gtk_widget_show_all (menu); - - return menu; -} - -static void -popup_menu_detach (PeasGtkPluginManagerView *view, - GtkMenu *menu) -{ - PeasGtkPluginManagerViewPrivate *priv = GET_PRIV (view); - - priv->popup_menu = NULL; -} - -static void -get_selected_area (GtkTreeView *tree_view, - GdkRectangle *area) -{ - GtkTreeSelection *selection; - GtkTreeIter iter; - - selection = gtk_tree_view_get_selection (tree_view); - - if (gtk_tree_selection_get_selected (selection, NULL, &iter)) - { - GtkTreeModel *model; - GtkTreePath *path; - - model = gtk_tree_view_get_model (tree_view); - path = gtk_tree_model_get_path (model, &iter); - gtk_tree_view_get_cell_area (tree_view, - path, - gtk_tree_view_get_column (tree_view, 0), - area); - gtk_tree_path_free (path); - } - else - { - gtk_widget_get_allocation (GTK_WIDGET (tree_view), area); - } -} - -#if !GTK_CHECK_VERSION(3, 22, 0) -static void -menu_position_under_tree_view (GtkMenu *menu, - gint *x, - gint *y, - gboolean *push_in, - GtkTreeView *tree_view) -{ - GtkTreeSelection *selection; - GtkTreeIter iter; - GdkWindow *window; - - selection = gtk_tree_view_get_selection (tree_view); - - window = gtk_widget_get_window (GTK_WIDGET (tree_view)); - gdk_window_get_origin (window, x, y); - - if (gtk_tree_selection_get_selected (selection, NULL, &iter)) - { - GtkTreeModel *model; - GtkTreePath *path; - GdkRectangle rect; - - model = gtk_tree_view_get_model (tree_view); - path = gtk_tree_model_get_path (model, &iter); - gtk_tree_view_get_cell_area (tree_view, - path, - gtk_tree_view_get_column (tree_view, 0), /* FIXME 0 for RTL ? */ - &rect); - gtk_tree_path_free (path); - - *x += rect.x; - *y += rect.y + rect.height; - - if (gtk_widget_get_direction (GTK_WIDGET (tree_view)) == GTK_TEXT_DIR_RTL) - { - GtkRequisition requisition; - gtk_widget_get_preferred_size (GTK_WIDGET (menu), &requisition, - NULL); - *x += rect.width - requisition.width; - } - } - else - { - GtkAllocation allocation; - - gtk_widget_get_allocation (GTK_WIDGET (tree_view), &allocation); - - *x += allocation.x; - *y += allocation.y; - - if (gtk_widget_get_direction (GTK_WIDGET (tree_view)) == GTK_TEXT_DIR_RTL) - { - GtkRequisition requisition; - - gtk_widget_get_preferred_size (GTK_WIDGET (menu), &requisition, - NULL); - - *x += allocation.width - requisition.width; - } - } - - *push_in = TRUE; -} -#endif - -static gboolean -show_popup_menu (GtkTreeView *tree_view, - PeasGtkPluginManagerView *view, - GdkEventButton *event) -{ - PeasGtkPluginManagerViewPrivate *priv = GET_PRIV (view); - - if (priv->popup_menu) - gtk_widget_destroy (priv->popup_menu); - - priv->popup_menu = create_popup_menu (view); - - if (priv->popup_menu == NULL) - return FALSE; - - gtk_menu_attach_to_widget (GTK_MENU (priv->popup_menu), - GTK_WIDGET (view), - (GtkMenuDetachFunc) popup_menu_detach); - - if (event != NULL) - { -#if GTK_CHECK_VERSION(3, 22, 0) - gtk_menu_popup_at_pointer (GTK_MENU (priv->popup_menu), - (const GdkEvent *)event); -#else - gtk_menu_popup (GTK_MENU (priv->popup_menu), NULL, NULL, - NULL, NULL, event->button, event->time); -#endif - } - else - { -#if GTK_CHECK_VERSION(3, 22, 0) - GdkRectangle cell_area; - - get_selected_area (GTK_TREE_VIEW (view), &cell_area); - - gtk_menu_popup_at_rect (GTK_MENU (priv->popup_menu), - gtk_widget_get_window (GTK_WIDGET (view)), - &cell_area, - GDK_GRAVITY_SOUTH_WEST, - GDK_GRAVITY_NORTH_WEST, - (const GdkEvent *)event); - -#else - gtk_menu_popup (GTK_MENU (priv->popup_menu), NULL, NULL, - (GtkMenuPositionFunc) menu_position_under_tree_view, - view, 0, gtk_get_current_event_time ()); -#endif - - gtk_menu_shell_select_first (GTK_MENU_SHELL (priv->popup_menu), - FALSE); - } - - return TRUE; -} - -static void -plugin_icon_data_func (GtkTreeViewColumn *column, - GtkCellRenderer *cell, - GtkTreeModel *model, - GtkTreeIter *iter) -{ - GIcon *icon_gicon; - gchar *icon_stock_id; - - gtk_tree_model_get (model, iter, - PEAS_GTK_PLUGIN_MANAGER_STORE_ICON_GICON_COLUMN, &icon_gicon, - PEAS_GTK_PLUGIN_MANAGER_STORE_ICON_STOCK_ID_COLUMN, &icon_stock_id, - -1); - - if (icon_gicon == NULL) - { - g_object_set (cell, "stock-id", icon_stock_id, NULL); - } - else - { - g_object_set (cell, "gicon", icon_gicon, NULL); - g_object_unref (icon_gicon); - } - - g_free (icon_stock_id); -} - -static void -peas_gtk_plugin_manager_view_init (PeasGtkPluginManagerView *view) -{ - GtkTreeViewColumn *column; - GtkCellRenderer *cell; - - gtk_widget_set_has_tooltip (GTK_WIDGET (view), TRUE); - - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (view), FALSE); - - /* first column */ - column = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title (column, _("Enabled")); - gtk_tree_view_column_set_resizable (column, FALSE); - - cell = gtk_cell_renderer_toggle_new (); - gtk_tree_view_column_pack_start (column, cell, FALSE); - g_object_set (cell, "xpad", 6, NULL); - gtk_tree_view_column_set_attributes (column, cell, - "active", PEAS_GTK_PLUGIN_MANAGER_STORE_ENABLED_COLUMN, - "activatable", PEAS_GTK_PLUGIN_MANAGER_STORE_CAN_ENABLE_COLUMN, - "sensitive", PEAS_GTK_PLUGIN_MANAGER_STORE_CAN_ENABLE_COLUMN, - "visible", PEAS_GTK_PLUGIN_MANAGER_STORE_CAN_ENABLE_COLUMN, - NULL); - g_signal_connect (cell, - "toggled", - G_CALLBACK (enabled_toggled_cb), - view); - - gtk_tree_view_append_column (GTK_TREE_VIEW (view), column); - - /* second column */ - column = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title (column, _("Plugin")); - gtk_tree_view_column_set_resizable (column, FALSE); - - cell = gtk_cell_renderer_pixbuf_new (); - gtk_tree_view_column_pack_start (column, cell, FALSE); - g_object_set (cell, "stock-size", GTK_ICON_SIZE_SMALL_TOOLBAR, NULL); - gtk_tree_view_column_set_cell_data_func (column, cell, - (GtkTreeCellDataFunc) plugin_icon_data_func, - NULL, NULL); - - cell = gtk_cell_renderer_text_new (); - gtk_tree_view_column_pack_start (column, cell, TRUE); - g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_END, NULL); - gtk_tree_view_column_set_attributes (column, cell, - "sensitive", PEAS_GTK_PLUGIN_MANAGER_STORE_INFO_SENSITIVE_COLUMN, - "markup", PEAS_GTK_PLUGIN_MANAGER_STORE_INFO_COLUMN, - NULL); - - gtk_tree_view_column_set_spacing (column, 6); - gtk_tree_view_append_column (GTK_TREE_VIEW (view), column); - - /* Enable search for our non-string column */ - gtk_tree_view_set_search_column (GTK_TREE_VIEW (view), - PEAS_GTK_PLUGIN_MANAGER_STORE_PLUGIN_COLUMN); - gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (view), - (GtkTreeViewSearchEqualFunc) name_search_cb, - view, - NULL); -} - -static gboolean -peas_gtk_plugin_manager_view_button_press_event (GtkWidget *tree_view, - GdkEventButton *event) -{ - PeasGtkPluginManagerView *view = PEAS_GTK_PLUGIN_MANAGER_VIEW (tree_view); - GtkWidgetClass *widget_class; - gboolean handled; - - widget_class = GTK_WIDGET_CLASS (peas_gtk_plugin_manager_view_parent_class); - - /* The selection must by updated */ - handled = widget_class->button_press_event (tree_view, event); - - if (event->type != GDK_BUTTON_PRESS || event->button != 3 || !handled) - return handled; - - return show_popup_menu (GTK_TREE_VIEW (tree_view), view, event); -} - -static gboolean -peas_gtk_plugin_manager_view_popup_menu (GtkWidget *tree_view) -{ - PeasGtkPluginManagerView *view = PEAS_GTK_PLUGIN_MANAGER_VIEW (tree_view); - - return show_popup_menu (GTK_TREE_VIEW (tree_view), view, NULL); -} - -static gboolean -peas_gtk_plugin_manager_view_query_tooltip (GtkWidget *widget, - gint x, - gint y, - gboolean keyboard_mode, - GtkTooltip *tooltip) -{ - PeasGtkPluginManagerView *view = PEAS_GTK_PLUGIN_MANAGER_VIEW (widget); - PeasGtkPluginManagerViewPrivate *priv = GET_PRIV (view); - gboolean is_row; - GtkTreeIter iter; - PeasPluginInfo *info; - gchar *to_bold, *error_msg, *message; - GError *error = NULL; - - is_row = gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (widget), - &x, &y, keyboard_mode, - NULL, NULL, &iter); - - if (!is_row) - return FALSE; - - convert_iter_to_child_iter (view, &iter); - - info = peas_gtk_plugin_manager_store_get_plugin (priv->store, &iter); - - if (peas_plugin_info_is_available (info, &error)) - return FALSE; - - /* Avoid having markup in a translated string */ - to_bold = g_strdup_printf (_("The plugin “%s” could not be loaded"), - peas_plugin_info_get_name (info)); - - /* Keep separate because some translations do special things - * for the ':' and might accidentally not keep the space after it - */ - error_msg = g_strdup_printf (_("An error occurred: %s"), error->message); - - message = g_strconcat ("<b>", to_bold, "</b>\n", error_msg, NULL); - - gtk_tooltip_set_markup (tooltip, message); - - g_free (message); - g_free (error_msg); - g_free (to_bold); - g_error_free (error); - - return TRUE; -} - -static void -peas_gtk_plugin_manager_view_row_activated (GtkTreeView *tree_view, - GtkTreePath *path, - GtkTreeViewColumn *column) -{ - PeasGtkPluginManagerView *view = PEAS_GTK_PLUGIN_MANAGER_VIEW (tree_view); - PeasGtkPluginManagerViewPrivate *priv = GET_PRIV (view); - GtkTreeIter iter; - GtkTreeViewClass *tree_view_class; - - if (!gtk_tree_model_get_iter (gtk_tree_view_get_model (tree_view), &iter, path)) - return; - - convert_iter_to_child_iter (view, &iter); - - if (peas_gtk_plugin_manager_store_can_enable (priv->store, &iter)) - toggle_enabled (view, &iter); - - tree_view_class = GTK_TREE_VIEW_CLASS (peas_gtk_plugin_manager_view_parent_class); - if (tree_view_class->row_activated != NULL) - tree_view_class->row_activated (tree_view, path, column); -} - -static void -peas_gtk_plugin_manager_view_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - PeasGtkPluginManagerView *view = PEAS_GTK_PLUGIN_MANAGER_VIEW (object); - PeasGtkPluginManagerViewPrivate *priv = GET_PRIV (view); - - switch (prop_id) - { - case PROP_ENGINE: - priv->engine = g_value_get_object (value); - break; - case PROP_SHOW_BUILTIN: - peas_gtk_plugin_manager_view_set_show_builtin (view, - g_value_get_boolean (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -peas_gtk_plugin_manager_view_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - PeasGtkPluginManagerView *view = PEAS_GTK_PLUGIN_MANAGER_VIEW (object); - PeasGtkPluginManagerViewPrivate *priv = GET_PRIV (view); - - switch (prop_id) - { - case PROP_ENGINE: - g_value_set_object (value, priv->engine); - break; - case PROP_SHOW_BUILTIN: - g_value_set_boolean (value, - peas_gtk_plugin_manager_view_get_show_builtin (view)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -peas_gtk_plugin_manager_view_constructed (GObject *object) -{ - PeasGtkPluginManagerView *view = PEAS_GTK_PLUGIN_MANAGER_VIEW (object); - PeasGtkPluginManagerViewPrivate *priv = GET_PRIV (view); - - if (priv->engine == NULL) - priv->engine = peas_engine_get_default (); - - g_object_ref (priv->engine); - - priv->store = peas_gtk_plugin_manager_store_new (priv->engine); - - /* Properly set the model */ - priv->show_builtin = TRUE; - peas_gtk_plugin_manager_view_set_show_builtin (view, FALSE); - - g_signal_connect_object (priv->engine, - "notify::plugin-list", - G_CALLBACK (plugin_list_changed_cb), - view, - 0); - - G_OBJECT_CLASS (peas_gtk_plugin_manager_view_parent_class)->constructed (object); -} - -static void -peas_gtk_plugin_manager_view_dispose (GObject *object) -{ - PeasGtkPluginManagerView *view = PEAS_GTK_PLUGIN_MANAGER_VIEW (object); - PeasGtkPluginManagerViewPrivate *priv = GET_PRIV (view); - - g_clear_pointer (&priv->popup_menu, gtk_widget_destroy); - - g_clear_object (&priv->engine); - g_clear_object (&priv->store); - - G_OBJECT_CLASS (peas_gtk_plugin_manager_view_parent_class)->dispose (object); -} - -static void -peas_gtk_plugin_manager_view_class_init (PeasGtkPluginManagerViewClass *klass) -{ - GType the_type = G_TYPE_FROM_CLASS (klass); - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - GtkTreeViewClass *tree_view_class = GTK_TREE_VIEW_CLASS (klass); - - object_class->set_property = peas_gtk_plugin_manager_view_set_property; - object_class->get_property = peas_gtk_plugin_manager_view_get_property; - object_class->constructed = peas_gtk_plugin_manager_view_constructed; - object_class->dispose = peas_gtk_plugin_manager_view_dispose; - - widget_class->button_press_event = peas_gtk_plugin_manager_view_button_press_event; - widget_class->popup_menu = peas_gtk_plugin_manager_view_popup_menu; - widget_class->query_tooltip = peas_gtk_plugin_manager_view_query_tooltip; - - tree_view_class->row_activated = peas_gtk_plugin_manager_view_row_activated; - - /** - * PeasGtkPLuginManagerView:engine: - * - * The [class@Peas.Engine] this view is attached to. - */ - properties[PROP_ENGINE] = - g_param_spec_object ("engine", - "engine", - "The PeasEngine this view is attached to", - PEAS_TYPE_ENGINE, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - - /** - * PeasGtkPluginManagerView:show-builtin: - * - * If builtin plugins should be shown. - * - * Deprecated: 1.2: Use hidden plugins instead. - */ - properties[PROP_SHOW_BUILTIN] = - g_param_spec_boolean ("show-builtin", - "show-builtin", - "If builtin plugins should be shown", - FALSE, - G_PARAM_DEPRECATED | - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - - /** - * PeasGtkPluginManagerView::populate-popup: - * @view: A #PeasGtkPluginManagerView. - * @menu: A #GtkMenu. - * - * Emitted before showing the context menu of the view. - * - * If you need to add items to the context menu, - * connect to this signal and add your menuitems to the @menu. - */ - signals[POPULATE_POPUP] = - g_signal_new (I_("populate-popup"), - the_type, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (PeasGtkPluginManagerViewClass, populate_popup), - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, - 1, - GTK_TYPE_MENU); - - g_object_class_install_properties (object_class, N_PROPERTIES, properties); -} - -/** - * peas_gtk_plugin_manager_view_new: - * @engine: (allow-none): A #PeasEngine, or %NULL. - * - * Creates a new plugin manager view for the given [class@Peas.Engine]. - * - * If @engine is %NULL, then the default engine will be used. - * - * Returns: the new #PeasGtkPluginManagerView. - */ -GtkWidget * -peas_gtk_plugin_manager_view_new (PeasEngine *engine) -{ - g_return_val_if_fail (engine == NULL || PEAS_IS_ENGINE (engine), NULL); - - return GTK_WIDGET (g_object_new (PEAS_GTK_TYPE_PLUGIN_MANAGER_VIEW, - "engine", engine, - NULL)); -} - -/** - * peas_gtk_plugin_manager_view_set_show_builtin: - * @view: A #PeasGtkPluginManagerView. - * @show_builtin: If builtin plugins should be shown. - * - * Sets if builtin plugins should be shown. - * - * Deprecated: 1.2: Use hidden plugins instead. - */ -void -peas_gtk_plugin_manager_view_set_show_builtin (PeasGtkPluginManagerView *view, - gboolean show_builtin) -{ - PeasGtkPluginManagerViewPrivate *priv = GET_PRIV (view); - GtkTreeSelection *selection; - GtkTreeIter iter; - gboolean iter_set; - - g_return_if_fail (PEAS_GTK_IS_PLUGIN_MANAGER_VIEW (view)); - - show_builtin = (show_builtin != FALSE); - - if (priv->show_builtin == show_builtin) - return; - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view)); - - /* We must get the selected iter before setting if builtin - plugins should be shown so the proper model is set */ - iter_set = gtk_tree_selection_get_selected (selection, NULL, &iter); - - if (iter_set) - convert_iter_to_child_iter (view, &iter); - - priv->show_builtin = show_builtin; - - if (show_builtin) - { - gtk_tree_view_set_model (GTK_TREE_VIEW (view), - GTK_TREE_MODEL (priv->store)); - } - else - { - GtkTreeModel *model; - - model = gtk_tree_model_filter_new (GTK_TREE_MODEL (priv->store), NULL); - gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (model), - (GtkTreeModelFilterVisibleFunc) filter_builtins_visible, - view, - NULL); - - gtk_tree_view_set_model (GTK_TREE_VIEW (view), model); - - g_object_unref (model); - } - - if (iter_set && convert_child_iter_to_iter (view, &iter)) - gtk_tree_selection_select_iter (selection, &iter); - - g_object_notify_by_pspec (G_OBJECT (view), - properties[PROP_SHOW_BUILTIN]); -} - -/** - * peas_gtk_plugin_manager_view_get_show_builtin: - * @view: A #PeasGtkPluginManagerView. - * - * Returns if builtin plugins should be shown. - * - * Returns: if builtin plugins should be shown. - * - * Deprecated: 1.2: Use hidden plugins instead. - */ -gboolean -peas_gtk_plugin_manager_view_get_show_builtin (PeasGtkPluginManagerView *view) -{ - PeasGtkPluginManagerViewPrivate *priv = GET_PRIV (view); - - g_return_val_if_fail (PEAS_GTK_IS_PLUGIN_MANAGER_VIEW (view), FALSE); - - return priv->show_builtin; -} - -/** - * peas_gtk_plugin_manager_view_set_selected_plugin: - * @view: A #PeasGtkPluginManagerView. - * @info: A #PeasPluginInfo. - * - * Selects the given plugin. - */ -void -peas_gtk_plugin_manager_view_set_selected_plugin (PeasGtkPluginManagerView *view, - PeasPluginInfo *info) -{ - PeasGtkPluginManagerViewPrivate *priv = GET_PRIV (view); - GtkTreeIter iter; - GtkTreeSelection *selection; - - g_return_if_fail (PEAS_GTK_IS_PLUGIN_MANAGER_VIEW (view)); - g_return_if_fail (info != NULL); - - g_return_if_fail (peas_gtk_plugin_manager_store_get_iter_from_plugin (priv->store, - &iter, info)); - - if (!convert_child_iter_to_iter (view, &iter)) - return; - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view)); - gtk_tree_selection_select_iter (selection, &iter); -} - -/** - * peas_gtk_plugin_manager_view_get_selected_plugin: - * @view: A #PeasGtkPluginManagerView. - * - * Returns the currently selected plugin, or %NULL if a plugin is not selected. - * - * Returns: (transfer none) (nullable): the selected plugin. - */ -PeasPluginInfo * -peas_gtk_plugin_manager_view_get_selected_plugin (PeasGtkPluginManagerView *view) -{ - PeasGtkPluginManagerViewPrivate *priv = GET_PRIV (view); - GtkTreeSelection *selection; - GtkTreeIter iter; - PeasPluginInfo *info = NULL; - - g_return_val_if_fail (PEAS_GTK_IS_PLUGIN_MANAGER_VIEW (view), NULL); - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view)); - - /* Since gtk+ 3.4 gtk_tree_view_get_selection() can in practice return NULL - * here because 'cursor-changed' is emitted during 'destroy' (it wasn't - * the case previously and is not properly documented as of today). - */ - if (selection != NULL && gtk_tree_selection_get_selected (selection, NULL, &iter)) - { - convert_iter_to_child_iter (view, &iter); - info = peas_gtk_plugin_manager_store_get_plugin (priv->store, &iter); - } - - return info; -} diff --git a/libpeas-gtk/peas-gtk-plugin-manager-view.h b/libpeas-gtk/peas-gtk-plugin-manager-view.h deleted file mode 100644 index 34c50ad..0000000 --- a/libpeas-gtk/peas-gtk-plugin-manager-view.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * peas-plugin-manager-view.h - * This file is part of libpeas - * - * Copyright (C) 2002 Paolo Maggi and James Willcox - * Copyright (C) 2003-2006 Paolo Maggi, Paolo Borelli - * Copyright (C) 2007-2009 Paolo Maggi, Paolo Borelli, Steve Frécinaux - * Copyright (C) 2010 Garrett Regier - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __PEAS_GTK_PLUGIN_MANAGER_VIEW_H__ -#define __PEAS_GTK_PLUGIN_MANAGER_VIEW_H__ - -#include <gtk/gtk.h> -#include <libpeas/peas-engine.h> - -G_BEGIN_DECLS - -/* - * Type checking and casting macros - */ -#define PEAS_GTK_TYPE_PLUGIN_MANAGER_VIEW (peas_gtk_plugin_manager_view_get_type()) -#define PEAS_GTK_PLUGIN_MANAGER_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PEAS_GTK_TYPE_PLUGIN_MANAGER_VIEW, PeasGtkPluginManagerView)) -#define PEAS_GTK_PLUGIN_MANAGER_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PEAS_GTK_TYPE_PLUGIN_MANAGER_VIEW, PeasGtkPluginManagerViewClass)) -#define PEAS_GTK_IS_PLUGIN_MANAGER_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PEAS_GTK_TYPE_PLUGIN_MANAGER_VIEW)) -#define PEAS_GTK_IS_PLUGIN_MANAGER_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PEAS_GTK_TYPE_PLUGIN_MANAGER_VIEW)) -#define PEAS_GTK_PLUGIN_MANAGER_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PEAS_GTK_TYPE_PLUGIN_MANAGER_VIEW, PeasGtkPluginManagerViewClass)) - -typedef struct _PeasGtkPluginManagerView PeasGtkPluginManagerView; -typedef struct _PeasGtkPluginManagerViewClass PeasGtkPluginManagerViewClass; -typedef struct _PeasGtkPluginManagerViewPrivate PeasGtkPluginManagerViewPrivate; - -/** - * PeasGtkPluginManagerView: - * - * The #PeasGtkPluginManagerView structure contains only private data - * and should only be accessed using the provided API. - */ -struct _PeasGtkPluginManagerView { - GtkTreeView parent; - - /*< private > */ - PeasGtkPluginManagerViewPrivate *priv; -}; - -/** - * PeasGtkPluginManagerViewClass: - * @parent_class: The parent class. - * @populate_popup: Signal class handler for the - * #PeasGtkPluginManagerView::populate-popup signal. - * - * The class structure for #PeasGtkPluginManagerView. - */ -struct _PeasGtkPluginManagerViewClass { - GtkTreeViewClass parent_class; - - void (*populate_popup) (PeasGtkPluginManagerView *view, - GtkMenu *menu); - - /*< private >*/ - gpointer padding[8]; -}; - -PEAS_AVAILABLE_IN_ALL -GType peas_gtk_plugin_manager_view_get_type (void) G_GNUC_CONST; -PEAS_AVAILABLE_IN_ALL -GtkWidget *peas_gtk_plugin_manager_view_new (PeasEngine *engine); - -#ifndef PEAS_DISABLE_DEPRECATED -PEAS_AVAILABLE_IN_ALL -void peas_gtk_plugin_manager_view_set_show_builtin (PeasGtkPluginManagerView *view, - gboolean show_builtin); -PEAS_AVAILABLE_IN_ALL -gboolean peas_gtk_plugin_manager_view_get_show_builtin (PeasGtkPluginManagerView *view); -#endif - -PEAS_AVAILABLE_IN_ALL -void peas_gtk_plugin_manager_view_set_selected_plugin (PeasGtkPluginManagerView *view, - PeasPluginInfo *info); -PEAS_AVAILABLE_IN_ALL -PeasPluginInfo *peas_gtk_plugin_manager_view_get_selected_plugin (PeasGtkPluginManagerView *view); - -G_END_DECLS - -#endif /* __PEAS_GTK_PLUGIN_MANAGER_VIEW_H__ */ diff --git a/libpeas-gtk/peas-gtk-plugin-manager.c b/libpeas-gtk/peas-gtk-plugin-manager.c deleted file mode 100644 index 9d7d812..0000000 --- a/libpeas-gtk/peas-gtk-plugin-manager.c +++ /dev/null @@ -1,617 +0,0 @@ -/* - * peas-plugin-manager.c - * This file is part of libpeas - * - * Copyright (C) 2002 Paolo Maggi and James Willcox - * Copyright (C) 2003-2006 Paolo Maggi, Paolo Borelli - * Copyright (C) 2007-2009 Paolo Maggi, Paolo Borelli, Steve Frécinaux - * Copyright (C) 2010 Garrett Regier - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> -#include <girepository.h> - -#ifdef OS_OSX -#include "peas-utils-osx.h" -#endif - -#include <libpeas/peas-engine.h> -#include <libpeas/peas-plugin-info.h> -#include <libpeas/peas-i18n-priv.h> - -#include "peas-gtk-plugin-manager.h" -#include "peas-gtk-plugin-manager-view.h" -#include "peas-gtk-configurable.h" - -/** - * PeasGtkPluginManager: - * - * Management GUI for plugins. - * - * The #PeasGtkPluginManager is a widget that can be used to manage plugins, - * i.e. load or unload them, and see some pieces of information. - * - * <picture> - * <source srcset="peas-gtk-plugin-manager.png"> - * </picture> - * - * The only thing you need to do as an application writer if you wish to use - * the manager to configure your plugins is to instantiate it using - * [ctor@PluginManager.new] and pack it into another widget or a window - * (as in the screenshot above). - * - **/ - -struct _PeasGtkPluginManagerPrivate { - PeasEngine *engine; - - GtkWidget *sw; - GtkWidget *view; - - GtkWidget *about; - - GtkWidget *about_button; - GtkWidget *configure_button; -}; - -/* Properties */ -enum { - PROP_0, - PROP_ENGINE, - PROP_VIEW, - N_PROPERTIES -}; - -static GParamSpec *properties[N_PROPERTIES] = { NULL }; - -G_DEFINE_TYPE_WITH_PRIVATE (PeasGtkPluginManager, - peas_gtk_plugin_manager, - GTK_TYPE_BOX) - -static GtkWindow * -get_toplevel (GtkWidget *widget) -{ - GtkWindow *toplevel; - - toplevel = (GtkWindow *) gtk_widget_get_toplevel (widget); - if (!GTK_IS_WINDOW (toplevel)) - return NULL; - - /* Make sure the window always has a window group */ - if (!gtk_window_has_group (toplevel)) - { - GtkWindowGroup *window_group; - - window_group = gtk_window_group_new (); - gtk_window_group_add_window (window_group, toplevel); - g_object_unref (window_group); - } - - return toplevel; -} - -static gboolean -plugin_is_configurable (PeasGtkPluginManager *pm, - PeasPluginInfo *info) -{ - PeasGtkPluginManagerPrivate *priv = peas_gtk_plugin_manager_get_instance_private (pm); - - if (info == NULL || !peas_plugin_info_is_loaded (info)) - return FALSE; - - return peas_engine_provides_extension (priv->engine, info, - PEAS_GTK_TYPE_CONFIGURABLE); -} - -static void -update_button_sensitivity (PeasGtkPluginManager *pm, - PeasPluginInfo *info) -{ - PeasGtkPluginManagerPrivate *priv = peas_gtk_plugin_manager_get_instance_private (pm); - - gtk_widget_set_sensitive (priv->about_button, info != NULL); - gtk_widget_set_sensitive (priv->configure_button, - plugin_is_configurable (pm, info)); -} - -static void -show_about_cb (GtkWidget *widget, - PeasGtkPluginManager *pm) -{ - PeasGtkPluginManagerPrivate *priv = peas_gtk_plugin_manager_get_instance_private (pm); - PeasGtkPluginManagerView *view; - PeasPluginInfo *info; - GtkWindow *toplevel; - gboolean modal; - - view = PEAS_GTK_PLUGIN_MANAGER_VIEW (priv->view); - - info = peas_gtk_plugin_manager_view_get_selected_plugin (view); - g_return_if_fail (info != NULL); - - toplevel = get_toplevel (GTK_WIDGET (pm)); - modal = toplevel == NULL ? FALSE : gtk_window_get_modal (toplevel); - - /* If there is another about dialog already open destroy it */ - g_clear_pointer (&priv->about, gtk_widget_destroy); - - priv->about = GTK_WIDGET (g_object_new (GTK_TYPE_ABOUT_DIALOG, - "program-name", peas_plugin_info_get_name (info), - "copyright", peas_plugin_info_get_copyright (info), - "authors", peas_plugin_info_get_authors (info), - "comments", peas_plugin_info_get_description (info), - "website", peas_plugin_info_get_website (info), - "logo-icon-name", peas_plugin_info_get_icon_name (info), - "version", peas_plugin_info_get_version (info), - "destroy-with-parent", TRUE, - "transient-for", toplevel, - "modal", modal, - NULL)); - - g_signal_connect (priv->about, - "response", - G_CALLBACK (gtk_widget_destroy), - NULL); - g_signal_connect (priv->about, - "destroy", - G_CALLBACK (gtk_widget_destroyed), - &priv->about); - - gtk_widget_show (priv->about); -} - -static void -help_button_cb (GtkWidget *button, - PeasPluginInfo *info) -{ - const gchar *help_uri; -#ifndef OS_OSX - GError *error = NULL; - GtkWidget *error_dlg; -#endif - - g_return_if_fail (peas_plugin_info_get_help_uri (info) != NULL); - - help_uri = peas_plugin_info_get_help_uri (info); - -#ifdef OS_OSX - peas_open_url_osx (help_uri); -#else - - gtk_show_uri_on_window (get_toplevel (button), help_uri, GDK_CURRENT_TIME, &error); - if (error == NULL) - return; - - g_debug ("Failed to show help URI: '%s'", help_uri); - - error_dlg = gtk_message_dialog_new (get_toplevel (button), - GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - _("There was an error displaying the help.")); - - gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (error_dlg), - "%s", error->message); - - g_signal_connect (error_dlg, - "response", - G_CALLBACK (gtk_widget_destroy), - NULL); - - gtk_widget_show_all (error_dlg); - - g_error_free (error); -#endif -} - -static void -show_configure_cb (GtkWidget *widget, - PeasGtkPluginManager *pm) -{ - PeasGtkPluginManagerPrivate *priv = peas_gtk_plugin_manager_get_instance_private (pm); - PeasGtkPluginManagerView *view; - PeasPluginInfo *info; - PeasExtension *exten; - GtkWidget *conf_widget = NULL; - GtkWidget *conf_dlg; - GtkWidget *vbox; - - view = PEAS_GTK_PLUGIN_MANAGER_VIEW (priv->view); - - info = peas_gtk_plugin_manager_view_get_selected_plugin (view); - g_return_if_fail (info != NULL); - - exten = peas_engine_create_extension (priv->engine, info, PEAS_GTK_TYPE_CONFIGURABLE, NULL); - g_return_if_fail (PEAS_IS_EXTENSION (exten)); - - conf_widget = peas_gtk_configurable_create_configure_widget (PEAS_GTK_CONFIGURABLE (exten)); - g_object_unref (exten); - - g_return_if_fail (GTK_IS_WIDGET (conf_widget)); - g_return_if_fail (!gtk_widget_is_toplevel (conf_widget)); - - conf_dlg = gtk_dialog_new_with_buttons (peas_plugin_info_get_name (info), - get_toplevel (GTK_WIDGET (pm)), - GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - _("_Close"), - GTK_RESPONSE_CLOSE, - NULL); - - vbox = gtk_dialog_get_content_area (GTK_DIALOG (conf_dlg)); - gtk_box_pack_start (GTK_BOX (vbox), conf_widget, TRUE, TRUE, 0); - - if (peas_plugin_info_get_help_uri (info) != NULL) - { - GtkWidget *help_button; - - help_button = gtk_dialog_add_button (GTK_DIALOG (conf_dlg), - _("_Help"), GTK_RESPONSE_HELP); - - g_signal_connect (help_button, - "clicked", - G_CALLBACK (help_button_cb), - info); - } - - gtk_widget_show_all (conf_dlg); - - g_signal_connect (conf_dlg, - "response", - G_CALLBACK (gtk_widget_destroy), - NULL); -} - -static void -plugin_loaded_toggled_cb (PeasEngine *engine, - PeasPluginInfo *info, - PeasGtkPluginManager *pm) -{ - PeasGtkPluginManagerPrivate *priv = peas_gtk_plugin_manager_get_instance_private (pm); - PeasGtkPluginManagerView *view; - PeasPluginInfo *selected; - - view = PEAS_GTK_PLUGIN_MANAGER_VIEW (priv->view); - selected = peas_gtk_plugin_manager_view_get_selected_plugin (view); - - if (selected == info) - update_button_sensitivity (pm, info); -} - -static void -selection_changed_cb (PeasGtkPluginManager *pm) -{ - PeasGtkPluginManagerPrivate *priv = peas_gtk_plugin_manager_get_instance_private (pm); - PeasGtkPluginManagerView *view; - PeasPluginInfo *info; - - view = PEAS_GTK_PLUGIN_MANAGER_VIEW (priv->view); - info = peas_gtk_plugin_manager_view_get_selected_plugin (view); - - update_button_sensitivity (pm, info); -} - -static void -populate_popup_cb (PeasGtkPluginManagerView *view, - GtkMenu *menu, - PeasGtkPluginManager *pm) -{ - PeasPluginInfo *info; - GtkWidget *item; - - info = peas_gtk_plugin_manager_view_get_selected_plugin (view); - - if (info == NULL) - return; - - item = gtk_check_menu_item_new_with_mnemonic (_("Pr_eferences")); - g_signal_connect (item, "activate", G_CALLBACK (show_configure_cb), pm); - gtk_widget_set_sensitive (item, plugin_is_configurable (pm, info)); - gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item); - - item = gtk_check_menu_item_new_with_mnemonic (_("_About")); - g_signal_connect (item, "activate", G_CALLBACK (show_about_cb), pm); - gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item); -} - -static void -peas_gtk_plugin_manager_init (PeasGtkPluginManager *pm) -{ - PeasGtkPluginManagerPrivate *priv = peas_gtk_plugin_manager_get_instance_private (pm); - GtkWidget *toolbar; - GtkStyleContext *context; - GtkToolItem *toolitem; - GtkWidget *toolbar_box; - GtkWidget *item_box; - - /* If we are using a PeasGtkPluginManager, we know for sure we will be using - libpeas-gtk, so let's load the typelib for it here. */ - g_irepository_require (g_irepository_get_default (), - "PeasGtk", "1.0", 0, NULL); - - gtk_orientable_set_orientation (GTK_ORIENTABLE (pm), - GTK_ORIENTATION_VERTICAL); - - priv->sw = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->sw), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (priv->sw), - GTK_SHADOW_IN); - context = gtk_widget_get_style_context (priv->sw); - gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM); - gtk_box_pack_start (GTK_BOX (pm), priv->sw, TRUE, TRUE, 0); - - toolbar = gtk_toolbar_new (); - gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_MENU); - context = gtk_widget_get_style_context (toolbar); - gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP); - gtk_style_context_add_class (context, GTK_STYLE_CLASS_INLINE_TOOLBAR); - gtk_box_pack_start (GTK_BOX (pm), toolbar, FALSE, FALSE, 0); - - toolitem = gtk_tool_item_new (); - gtk_tool_item_set_expand (toolitem, TRUE); - gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1); - - /* this box is needed to get the items at the end of the toolbar */ - toolbar_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); - gtk_container_add (GTK_CONTAINER (toolitem), toolbar_box); - - /* we need another box to disable css grouping */ - item_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); - gtk_box_pack_end (GTK_BOX (toolbar_box), item_box, FALSE, FALSE, 0); - - priv->about_button = gtk_button_new_with_mnemonic (_("_About")); - gtk_box_pack_start (GTK_BOX (item_box), priv->about_button, - FALSE, FALSE, 0); - - /* we need another box to disable css grouping */ - item_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); - gtk_box_pack_end (GTK_BOX (toolbar_box), item_box, FALSE, FALSE, 0); - - priv->configure_button = gtk_button_new_with_mnemonic (_("_Preferences")); - gtk_box_pack_start (GTK_BOX (item_box), priv->configure_button, - FALSE, FALSE, 0); - - /* setup a window of a sane size. */ - gtk_widget_set_size_request (GTK_WIDGET (priv->sw), 270, 100); - - g_signal_connect (priv->about_button, - "clicked", - G_CALLBACK (show_about_cb), - pm); - g_signal_connect (priv->configure_button, - "clicked", - G_CALLBACK (show_configure_cb), - pm); -} - -static void -peas_gtk_plugin_manager_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - PeasGtkPluginManager *pm = PEAS_GTK_PLUGIN_MANAGER (object); - PeasGtkPluginManagerPrivate *priv = peas_gtk_plugin_manager_get_instance_private (pm); - - switch (prop_id) - { - case PROP_ENGINE: - priv->engine = g_value_get_object (value); - break; - case PROP_VIEW: - priv->view = g_value_get_object (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -peas_gtk_plugin_manager_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - PeasGtkPluginManager *pm = PEAS_GTK_PLUGIN_MANAGER (object); - PeasGtkPluginManagerPrivate *priv = peas_gtk_plugin_manager_get_instance_private (pm); - - switch (prop_id) - { - case PROP_ENGINE: - g_value_set_object (value, priv->engine); - break; - case PROP_VIEW: - g_value_set_object (value, peas_gtk_plugin_manager_get_view (pm)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -peas_gtk_plugin_manager_constructed (GObject *object) -{ - PeasGtkPluginManager *pm = PEAS_GTK_PLUGIN_MANAGER (object); - PeasGtkPluginManagerPrivate *priv = peas_gtk_plugin_manager_get_instance_private (pm); - GtkTreeSelection *selection; - - if (priv->engine == NULL) - priv->engine = peas_engine_get_default (); - - g_object_ref (priv->engine); - - /* When we create the manager, we always rescan the plugins directory - * Must come after the view has connected to notify::plugin-list - */ - peas_engine_rescan_plugins (priv->engine); - - /* For the view to behave as expected, we must ensure it uses the same - * engine as the manager itself. - */ - if (priv->view != NULL) - { - PeasEngine *engine; - - g_object_get (priv->view, - "engine", &engine, - NULL); - - g_warn_if_fail (engine == priv->engine); - - if (engine != priv->engine) - g_clear_object (&priv->view); - - g_object_unref (engine); - } - - if (priv->view == NULL) - priv->view = peas_gtk_plugin_manager_view_new (priv->engine); - - gtk_container_add (GTK_CONTAINER (priv->sw), priv->view); - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->view)); - - g_signal_connect_object (selection, - "changed", - G_CALLBACK (selection_changed_cb), - pm, - G_CONNECT_SWAPPED); - g_signal_connect_object (priv->view, - "cursor-changed", - G_CALLBACK (selection_changed_cb), - pm, - G_CONNECT_SWAPPED); - g_signal_connect_object (priv->view, - "populate-popup", - G_CALLBACK (populate_popup_cb), - pm, - 0); - g_signal_connect_object (priv->engine, - "load-plugin", - G_CALLBACK (plugin_loaded_toggled_cb), - pm, - G_CONNECT_AFTER); - g_signal_connect_object (priv->engine, - "unload-plugin", - G_CALLBACK (plugin_loaded_toggled_cb), - pm, - G_CONNECT_AFTER); - - /* Update the button sensitivity */ - selection_changed_cb (pm); - - G_OBJECT_CLASS (peas_gtk_plugin_manager_parent_class)->constructed (object); -} - -static void -peas_gtk_plugin_manager_dispose (GObject *object) -{ - PeasGtkPluginManager *pm = PEAS_GTK_PLUGIN_MANAGER (object); - PeasGtkPluginManagerPrivate *priv = peas_gtk_plugin_manager_get_instance_private (pm); - - g_clear_object (&priv->engine); - g_clear_pointer (&priv->about, gtk_widget_destroy); - - G_OBJECT_CLASS (peas_gtk_plugin_manager_parent_class)->dispose (object); -} - -static void -peas_gtk_plugin_manager_class_init (PeasGtkPluginManagerClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->set_property = peas_gtk_plugin_manager_set_property; - object_class->get_property = peas_gtk_plugin_manager_get_property; - object_class->constructed = peas_gtk_plugin_manager_constructed; - object_class->dispose = peas_gtk_plugin_manager_dispose; - - /** - * PeasGtkPluginManager:engine: - * - * The [class@Peas.Engine] this manager is attached to. - */ - properties[PROP_ENGINE] = - g_param_spec_object ("engine", - "engine", - "The PeasEngine this manager is attached to", - PEAS_TYPE_ENGINE, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - - /** - * PeasGtkPluginManager:view: - * - * The [class@PluginManagerView] shown in the #PeasGtkPluginManager. - */ - properties[PROP_VIEW] = - g_param_spec_object ("view", - "view", - "The view shown in the manager", - PEAS_GTK_TYPE_PLUGIN_MANAGER_VIEW, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - - g_object_class_install_properties (object_class, N_PROPERTIES, properties); -} - -/** - * peas_gtk_plugin_manager_new: - * @engine: (allow-none): A #PeasEngine, or %NULL. - * - * Creates a new plugin manager for the given [class@Peas.Engine]. - * - * If @engine is %NULL, then the default engine will be used. - * - * Returns: the new #PeasGtkPluginManager. - */ -GtkWidget * -peas_gtk_plugin_manager_new (PeasEngine *engine) -{ - g_return_val_if_fail (engine == NULL || PEAS_IS_ENGINE (engine), NULL); - - return GTK_WIDGET (g_object_new (PEAS_GTK_TYPE_PLUGIN_MANAGER, - "engine", engine, - NULL)); -} - -/** - * peas_gtk_plugin_manager_get_view: - * @pm: A #PeasGtkPluginManager. - * - * Returns the [class@PluginManagerView] of @pm. - * - * Returns: (transfer none): the #GtkTreeView of @pm. - */ -GtkWidget * -peas_gtk_plugin_manager_get_view (PeasGtkPluginManager *pm) -{ - PeasGtkPluginManagerPrivate *priv = peas_gtk_plugin_manager_get_instance_private (pm); - - g_return_val_if_fail (PEAS_GTK_IS_PLUGIN_MANAGER (pm), NULL); - - return priv->view; -} diff --git a/libpeas-gtk/peas-gtk-plugin-manager.h b/libpeas-gtk/peas-gtk-plugin-manager.h deleted file mode 100644 index c98385b..0000000 --- a/libpeas-gtk/peas-gtk-plugin-manager.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * peas-gtk-plugin-manager.h - * This file is part of libpeas - * - * Copyright (C) 2005-2009 Paolo Maggi, Paolo Borelli - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __PEAS_GTK_PLUGIN_MANAGER_H__ -#define __PEAS_GTK_PLUGIN_MANAGER_H__ - -#include <gtk/gtk.h> -#include <libpeas/peas-engine.h> - -G_BEGIN_DECLS - -/* - * Type checking and casting macros - */ -#define PEAS_GTK_TYPE_PLUGIN_MANAGER (peas_gtk_plugin_manager_get_type()) -#define PEAS_GTK_PLUGIN_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PEAS_GTK_TYPE_PLUGIN_MANAGER, PeasGtkPluginManager)) -#define PEAS_GTK_PLUGIN_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PEAS_GTK_TYPE_PLUGIN_MANAGER, PeasGtkPluginManagerClass)) -#define PEAS_GTK_IS_PLUGIN_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PEAS_GTK_TYPE_PLUGIN_MANAGER)) -#define PEAS_GTK_IS_PLUGIN_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PEAS_GTK_TYPE_PLUGIN_MANAGER)) -#define PEAS_GTK_PLUGIN_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PEAS_GTK_TYPE_PLUGIN_MANAGER, PeasGtkPluginManagerClass)) - -typedef struct _PeasGtkPluginManager PeasGtkPluginManager; -typedef struct _PeasGtkPluginManagerClass PeasGtkPluginManagerClass; -typedef struct _PeasGtkPluginManagerPrivate PeasGtkPluginManagerPrivate; - -/** - * PeasGtkPluginManager: - * - * The #PeasGtkPluginManager structure contains only private data - * and should only be accessed using the provided API. - */ -struct _PeasGtkPluginManager -{ - GtkBox box; - - /*< private > */ - PeasGtkPluginManagerPrivate *priv; -}; - -/** - * PeasGtkPluginManagerClass: - * @parent_class: The parent class. - * - * The class structure for #PeasGtkPluginManager. - */ -struct _PeasGtkPluginManagerClass -{ - GtkBoxClass parent_class; - - /*< private >*/ - gpointer padding[8]; -}; - -PEAS_AVAILABLE_IN_ALL -GType peas_gtk_plugin_manager_get_type (void) G_GNUC_CONST; -PEAS_AVAILABLE_IN_ALL -GtkWidget *peas_gtk_plugin_manager_new (PeasEngine *engine); - -PEAS_AVAILABLE_IN_ALL -GtkWidget *peas_gtk_plugin_manager_get_view (PeasGtkPluginManager *pm); - -G_END_DECLS - -#endif /* __PEAS_GTK_PLUGIN_MANAGER_H__ */ diff --git a/libpeas-gtk/peas-gtk.h b/libpeas-gtk/peas-gtk.h deleted file mode 100644 index aade466..0000000 --- a/libpeas-gtk/peas-gtk.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * peas-gtk.h - * This file is part of libpeas - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __PEAS_GTK_H__ -#define __PEAS_GTK_H__ - -#include "peas-gtk-autocleanups.h" -#include "peas-gtk-configurable.h" -#include "peas-gtk-plugin-manager.h" -#include "peas-gtk-plugin-manager-view.h" - -#endif diff --git a/libpeas/meson.build b/libpeas/meson.build index 2583173..83ed349 100644 --- a/libpeas/meson.build +++ b/libpeas/meson.build @@ -10,14 +10,10 @@ peas_version_h = configure_file( input: 'peas-version.h.in', output: 'peas-version.h', configuration: version_data, - install_dir: join_paths( - pkgincludedir, - package_name, - ), + install_dir: pkgincludedir, ) libpeas_public_h = files( - 'peas-activatable.h', 'peas-autocleanups.h', 'peas-engine.h', 'peas-extension.h', @@ -30,7 +26,6 @@ libpeas_public_h = files( ) libpeas_sources = files( - 'peas-activatable.c', 'peas-debug.c', 'peas-dirs.c', 'peas-engine.c', @@ -88,13 +83,7 @@ libpeas_marshal = gnome.genmarshal( libpeas_marshals_h = libpeas_marshal.get(1) -install_headers( - libpeas_public_h, - install_dir: join_paths( - pkgincludedir, - package_name, - ), -) +install_headers(libpeas_public_h, install_dir: pkgincludedir) libpeas_sha = library( package_string.strip('lib'), @@ -128,7 +117,7 @@ if generate_gir == true namespace: 'Peas', symbol_prefix: 'peas', identifier_prefix: 'Peas', - header: 'libpeas/peas.h', + header: 'peas.h', export_packages: [package_string], includes: libpeas_gir_includes, link_with: libpeas_sha, diff --git a/libpeas/peas-activatable.c b/libpeas/peas-activatable.c deleted file mode 100644 index 7714d1d..0000000 --- a/libpeas/peas-activatable.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - * peas-activatable.c - * This file is part of libpeas - * - * Copyright (C) 2010 Steve Frécinaux - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include "peas-activatable.h" - -/** - * PeasActivatable: - * - * Interface for activatable plugins. - * - * #PeasActivatable is an interface which should be implemented by plugins - * that should be activated on an object of a certain type (depending on the - * application). For instance, in a typical windowed application, - * #PeasActivatable plugin instances could be bound to individual toplevel - * windows. - * - * It is typical to use #PeasActivatable along with [class@ExtensionSet] in order - * to activate and deactivate extensions automatically when plugins are loaded - * or unloaded. - * - * You can also use the code of this interface as a base for your own - * extension types, as illustrated by gedit's %GeditWindowActivatable and - * %GeditDocumentActivatable interfaces. - **/ - -G_DEFINE_INTERFACE(PeasActivatable, peas_activatable, G_TYPE_OBJECT) - -static void -peas_activatable_default_init (PeasActivatableInterface *iface) -{ - /** - * PeasActivatable:object: - * - * The object property contains the targetted object for this #PeasActivatable - * instance. - * - * For example a toplevel window in a typical windowed application. It is set - * at construction time and won't change. - */ - g_object_interface_install_property (iface, - g_param_spec_object ("object", - "Object", - "Object", - G_TYPE_OBJECT, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); -} - -/** - * peas_activatable_activate: - * @activatable: A #PeasActivatable. - * - * Activates the extension on the targetted object. - * - * On activation, the extension should hook itself to the object - * where it makes sense. - */ -void -peas_activatable_activate (PeasActivatable *activatable) -{ - PeasActivatableInterface *iface; - - g_return_if_fail (PEAS_IS_ACTIVATABLE (activatable)); - - iface = PEAS_ACTIVATABLE_GET_IFACE (activatable); - g_return_if_fail (iface->activate != NULL); - - iface->activate (activatable); -} - -/** - * peas_activatable_deactivate: - * @activatable: A #PeasActivatable. - * - * Deactivates the extension on the targetted object. - * - * On deactivation, an extension should remove itself from all the hooks it - * used and should perform any cleanup required, so it can be unreffed safely - * and without any more effect on the host application. - */ -void -peas_activatable_deactivate (PeasActivatable *activatable) -{ - PeasActivatableInterface *iface; - - g_return_if_fail (PEAS_IS_ACTIVATABLE (activatable)); - - iface = PEAS_ACTIVATABLE_GET_IFACE (activatable); - g_return_if_fail (iface->deactivate != NULL); - - iface->deactivate (activatable); -} - -/** - * peas_activatable_update_state: - * @activatable: A #PeasActivatable. - * - * Triggers an update of the extension internal state to take into account - * state changes in the targetted object, due to some event or user action. - */ -void -peas_activatable_update_state (PeasActivatable *activatable) -{ - PeasActivatableInterface *iface; - - g_return_if_fail (PEAS_IS_ACTIVATABLE (activatable)); - - iface = PEAS_ACTIVATABLE_GET_IFACE (activatable); - if (iface->update_state != NULL) - iface->update_state (activatable); -} - diff --git a/libpeas/peas-activatable.h b/libpeas/peas-activatable.h deleted file mode 100644 index eb77e58..0000000 --- a/libpeas/peas-activatable.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * peas-activatable.h - * This file is part of libpeas - * - * Copyright (C) 2010 - Steve Frécinaux - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __PEAS_ACTIVATABLE_H__ -#define __PEAS_ACTIVATABLE_H__ - -#include <glib-object.h> - -#include "peas-version-macros.h" - -G_BEGIN_DECLS - -/* - * Type checking and casting macros - */ -#define PEAS_TYPE_ACTIVATABLE (peas_activatable_get_type ()) -#define PEAS_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PEAS_TYPE_ACTIVATABLE, PeasActivatable)) -#define PEAS_ACTIVATABLE_IFACE(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), PEAS_TYPE_ACTIVATABLE, PeasActivatableInterface)) -#define PEAS_IS_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PEAS_TYPE_ACTIVATABLE)) -#define PEAS_ACTIVATABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), PEAS_TYPE_ACTIVATABLE, PeasActivatableInterface)) - -/** - * PeasActivatable: - * - * Interface for activatable plugins. - */ -typedef struct _PeasActivatable PeasActivatable; /* dummy typedef */ -typedef struct _PeasActivatableInterface PeasActivatableInterface; - -/** - * PeasActivatableInterface: - * @g_iface: The parent interface. - * @activate: Activates the plugin. - * @deactivate: Deactivates the plugin. - * @update_state: Updates the plugin's internal state to take account of - * a change in the target object's state. - * - * Provides an interface for activatable plugins. - */ -struct _PeasActivatableInterface { - GTypeInterface g_iface; - - /* Virtual public methods */ - void (*activate) (PeasActivatable *activatable); - void (*deactivate) (PeasActivatable *activatable); - void (*update_state) (PeasActivatable *activatable); -}; - -/* - * Public methods - */ -PEAS_AVAILABLE_IN_ALL -GType peas_activatable_get_type (void) G_GNUC_CONST; - -PEAS_AVAILABLE_IN_ALL -void peas_activatable_activate (PeasActivatable *activatable); -PEAS_AVAILABLE_IN_ALL -void peas_activatable_deactivate (PeasActivatable *activatable); -PEAS_AVAILABLE_IN_ALL -void peas_activatable_update_state (PeasActivatable *activatable); - -G_END_DECLS - -#endif /* __PEAS_ACTIVATABLE_H__ */ diff --git a/libpeas/peas-autocleanups.h b/libpeas/peas-autocleanups.h index 68f7870..6f4f1c0 100644 --- a/libpeas/peas-autocleanups.h +++ b/libpeas/peas-autocleanups.h @@ -22,7 +22,6 @@ #ifndef __PEAS_AUTOCLEANUPS_H__ #define __PEAS_AUTOCLEANUPS_H__ -#include "peas-activatable.h" #include "peas-engine.h" #include "peas-extension.h" #include "peas-extension-base.h" @@ -34,7 +33,6 @@ G_BEGIN_DECLS #ifndef __GI_SCANNER__ #if GLIB_CHECK_VERSION (2, 44, 0) -G_DEFINE_AUTOPTR_CLEANUP_FUNC (PeasActivatable, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (PeasEngine, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (PeasExtension, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (PeasExtensionBase, g_object_unref) diff --git a/libpeas/peas-dirs.c b/libpeas/peas-dirs.c index 6f182e2..6b7b81c 100644 --- a/libpeas/peas-dirs.c +++ b/libpeas/peas-dirs.c @@ -61,12 +61,12 @@ peas_dirs_get_data_dir (void) win32_dir = g_win32_get_package_installation_directory_of_module (libpeas_dll); - data_dir = g_build_filename (win32_dir, "share", "libpeas-1.0", NULL); + data_dir = g_build_filename (win32_dir, "share", "libpeas-2", NULL); g_free (win32_dir); #elif defined (OS_OSX) data_dir = peas_dirs_os_x_get_data_dir (); #else - data_dir = g_build_filename (DATADIR, "libpeas-1.0", NULL); + data_dir = g_build_filename (DATADIR, "libpeas-2", NULL); #endif return data_dir; @@ -82,12 +82,12 @@ peas_dirs_get_lib_dir (void) win32_dir = g_win32_get_package_installation_directory_of_module (libpeas_dll); - lib_dir = g_build_filename (win32_dir, "lib", "libpeas-1.0", NULL); + lib_dir = g_build_filename (win32_dir, "lib", "libpeas-2", NULL); g_free (win32_dir); #elif defined (OS_OSX) lib_dir = peas_dirs_os_x_get_lib_dir (); #else - lib_dir = g_build_filename (LIBDIR, "libpeas-1.0", NULL); + lib_dir = g_build_filename (LIBDIR, "libpeas-2", NULL); #endif return lib_dir; @@ -133,4 +133,3 @@ peas_dirs_get_locale_dir (void) return locale_dir; } - diff --git a/libpeas/peas-extension-set.c b/libpeas/peas-extension-set.c index fa402a8..6625714 100644 --- a/libpeas/peas-extension-set.c +++ b/libpeas/peas-extension-set.c @@ -52,19 +52,19 @@ * * ```c * static void - * on_extension_added (PeasExtensionSet *set, - * PeasPluginInfo *info, - * PeasActivatable *activatable) + * on_extension_added (PeasExtensionSet *set, + * PeasPluginInfo *info, + * ExampleActivatable *activatable) * { - * peas_activatable_activate (activatable); + * example_activatable_activate (activatable); * } * * static void - * on_extension_removed (PeasExtensionSet *set, - * PeasPluginInfo *info, - * PeasActivatable *activatable) + * on_extension_removed (PeasExtensionSet *set, + * PeasPluginInfo *info, + * ExampleActivatable *activatable) * { - * peas_activatable_deactivate (activatable); + * example_activatable_deactivate (activatable); * } * * PeasExtensionSet * @@ -73,7 +73,7 @@ * { * PeasExtensionSet *set; * - * set = peas_extension_set_new (engine, PEAS_TYPE_ACTIVATABLE, + * set = peas_extension_set_new (engine, EXAMPLE_TYPE_ACTIVATABLE, * "object", window, NULL); * peas_extension_set_foreach (set, * (PeasExtensionSetForeachFunc) on_extension_added, diff --git a/libpeas/peas.h b/libpeas/peas.h index c6d3633..711cdd8 100644 --- a/libpeas/peas.h +++ b/libpeas/peas.h @@ -20,7 +20,6 @@ #ifndef __PEAS_H__ #define __PEAS_H__ -#include "peas-activatable.h" #include "peas-autocleanups.h" #include "peas-engine.h" #include "peas-extension.h" diff --git a/loaders/meson.build b/loaders/meson.build index d86cbf9..6235ff9 100644 --- a/loaders/meson.build +++ b/loaders/meson.build @@ -2,10 +2,6 @@ if build_lua51_loader == true subdir('lua5.1') endif -if build_python2_loader == true - subdir('python') -endif - if build_python3_loader == true - subdir('python3') + subdir('python') endif diff --git a/loaders/python/meson.build b/loaders/python/meson.build index 9ca733a..458781e 100644 --- a/loaders/python/meson.build +++ b/loaders/python/meson.build @@ -1,29 +1,29 @@ -python2_loader_name = 'pythonloader' +python3_loader_name = 'pythonloader' pygobject_version = pygobject_dep.version() pygobject_version_arr = pygobject_version.split('.') pygobject_version_major = pygobject_version_arr[0].to_int() pygobject_version_minor = pygobject_version_arr[1].to_int() -pygobject_version_micro = pygobject_version_arr[2].to_int() +pygobject_version_micro = pygobject_version_arr[3].to_int() -python2_loader_c = files( +python3_loader_c = files( 'peas-plugin-loader-python.c', 'peas-python-internal.c', ) -python2_loader_res = gnome.compile_resources( +python3_loader_res = gnome.compile_resources( 'peas-python-resources', 'peas-python.gresource.xml', export: true, ) -python2_loader_deps = [ +python3_loader_deps = [ libpeas_dep, - python2_dep, + python3_dep, pygobject_dep, ] -python2_loader_c_args = [ +python3_loader_c_args = [ '-DHAVE_CONFIG_H', '-DPEAS_LOCALEDIR="@0@"'.format(localedir), '-DPYGOBJECT_MAJOR_VERSION=@0@'.format(pygobject_version_major), @@ -31,12 +31,12 @@ python2_loader_c_args = [ '-DPYGOBJECT_MICRO_VERSION=@0@'.format(pygobject_version_micro), ] -python2_loader_sha = shared_module( - python2_loader_name, - python2_loader_c + python2_loader_res, +python3_loader_sha = shared_module( + python3_loader_name, + python3_loader_c + python3_loader_res, include_directories: rootdir, - dependencies: python2_loader_deps, - c_args: project_c_args + python2_loader_c_args, + dependencies: python3_loader_deps, + c_args: project_c_args + python3_loader_c_args, install: true, install_dir: join_paths( pkglibdir, diff --git a/loaders/python3/meson.build b/loaders/python3/meson.build deleted file mode 100644 index d6f9eba..0000000 --- a/loaders/python3/meson.build +++ /dev/null @@ -1,46 +0,0 @@ -python3_loader_name = 'python3loader' - -pygobject_version = pygobject_dep.version() -pygobject_version_arr = pygobject_version.split('.') -pygobject_version_major = pygobject_version_arr[0].to_int() -pygobject_version_minor = pygobject_version_arr[1].to_int() -pygobject_version_micro = pygobject_version_arr[2].to_int() - -python3_loader_c = files( - '../python/peas-plugin-loader-python.c', - '../python/peas-python-internal.c', -) - -python3_loader_res = gnome.compile_resources( - 'peas-python2-resources', - 'peas-python3.gresource.xml', - export: true, -) - -python3_loader_deps = [ - libpeas_dep, - python3_dep, - pygobject_dep, -] - -python3_loader_c_args = [ - '-DHAVE_CONFIG_H', - '-DPEAS_LOCALEDIR="@0@"'.format(localedir), - '-DPYGOBJECT_MAJOR_VERSION=@0@'.format(pygobject_version_major), - '-DPYGOBJECT_MINOR_VERSION=@0@'.format(pygobject_version_minor), - '-DPYGOBJECT_MICRO_VERSION=@0@'.format(pygobject_version_micro), -] - -python3_loader_sha = shared_module( - python3_loader_name, - python3_loader_c + python3_loader_res, - include_directories: rootdir, - dependencies: python3_loader_deps, - c_args: project_c_args + python3_loader_c_args, - install: true, - install_dir: join_paths( - pkglibdir, - 'loaders', - ), - name_suffix: module_suffix -) diff --git a/loaders/python3/peas-python3.gresource.xml b/loaders/python3/peas-python3.gresource.xml deleted file mode 100644 index af79914..0000000 --- a/loaders/python3/peas-python3.gresource.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<gresources> - <gresource prefix="/org/gnome/libpeas/loaders/python3"> - <file alias="internal.py">../python/peas-python-internal.py</file> - </gresource> -</gresources> diff --git a/meson.build b/meson.build index 847b348..f5c1c64 100644 --- a/meson.build +++ b/meson.build @@ -1,11 +1,9 @@ project( 'libpeas', 'c', - version: '1.36.1', + version: '2.0.0.alpha', license: 'LGPLv2.1+', - meson_version: '>= 0.50.0', - default_options: [ - 'buildtype=debugoptimized', - ] + meson_version: '>= 0.62.0', + default_options: ['buildtype=debugoptimized', 'warning_level=2'] ) gnome = import('gnome') @@ -20,7 +18,7 @@ version_major = version_arr[0].to_int() version_minor = version_arr[1].to_int() version_micro = version_arr[2].to_int() -api_version = '@0@.0'.format(version_major) +api_version = '@0@'.format(version_major) if version_minor.is_odd() interface_age = 0 @@ -86,13 +84,11 @@ config_h.set_quoted('GETTEXT_PACKAGE', package_string) # Dependencies cc = meson.get_compiler('c') -glib_req_version = '2.44.0' +glib_req_version = '2.74' glib_req = '>= @0@'.format(glib_req_version) introspection_req = '>= 1.39.0' -gtk_req = '>= 3.0.0' gtk_doc_req = '>= 1.11' -python2_req = '>= 2.5.2' python3_req = '>= 3.2.0' pygobject_req = '>= 3.2.0' lua_req = '>= 5.1.0' @@ -104,13 +100,11 @@ gobject_dep = dependency('gobject-2.0', version: glib_req) gmodule_dep = dependency('gmodule-2.0', version: glib_req) gio_dep = dependency('gio-2.0', version: glib_req) introspection_dep = dependency('gobject-introspection-1.0', version: introspection_req) -gtk_dep = dependency('gtk+-3.0', version: gtk_req, required: false) gi_docgen_dep = dependency('gi-docgen', version: '>= 2021.7', fallback: ['gi-docgen', 'dummy_dep'], native: true, required: get_option('gtk_doc')) -gladeui_dep = dependency('gladeui-2.0', required: false) # From python 3.8 we neeed python3-embed python3_dep = dependency('python3-embed', required: false) @@ -126,16 +120,6 @@ if host_machine.system() == 'windows' and not python3_dep.found() endif endif - -python2_dep = dependency('python2', version: python2_req, required: false) -if host_machine.system() == 'windows' and not python2_dep.found() - python2 = pymod.find_installation(get_option('python2_path') != '' ? get_option('python2_path') : 'python2', - required: false) - if python2.found() - python2_dep = python2.dependency(version: python2_req, required: false) - endif -endif - pygobject_dep = dependency('pygobject-3.0', version: pygobject_req, required: false) lua51_dep = dependency('lua51', version: lua_req, required: false) if not lua51_dep.found() @@ -253,31 +237,6 @@ configure_file( # Options build_gtk_doc = get_option('gtk_doc') and gi_docgen_dep.found() -install_glade_catalog = get_option('glade_catalog') -if install_glade_catalog and not gladeui_dep.found() - install_glade_catalog = false -elif install_glade_catalog == true - catalogdir = join_paths(datadir, 'glade', 'catalogs') -# FIXME: In gladeui-2.0.pc, catalogdir should be relative to datadir: -# https://gitlab.gnome.org/GNOME/glade/issues/353 -# catalogdir = gladeui_dep.get_pkgconfig_variable( -# 'catalogdir', -# define_variable: [ -# 'datadir', datadir, -# ] -# ) -endif - -build_gtk_widgetry = get_option('widgetry') -if build_gtk_widgetry and not gtk_dep.found() - build_gtk_widgetry = false -endif - -build_demos = get_option('demos') -if build_demos and not build_gtk_widgetry - build_demos = false -endif - generate_gir = get_option('introspection') if generate_gir and not introspection_dep.found() generate_gir = false @@ -289,12 +248,6 @@ if build_lua51_loader and not lua51_found build_lua51_loader = false endif -build_python2_loader = get_option('python2') -python2_found = python2_dep.found() and pygobject_dep.found() -if build_python2_loader and not python2_found - build_python2_loader = false -endif - build_python3_loader = get_option('python3') python3_found = python3_dep.found() and pygobject_dep.found() if build_python3_loader and not python3_found @@ -305,9 +258,6 @@ endif copyfile_script = find_program('copyfile.py') subdir('libpeas') -if build_gtk_widgetry == true - subdir('libpeas-gtk') -endif if build_gtk_doc == true subdir('docs') @@ -318,9 +268,6 @@ subdir('po') subdir('loaders') -if build_demos == true - subdir('peas-demo') -endif if generate_gir == true subdir('tests') endif @@ -330,13 +277,9 @@ summary = [ '------', 'libpeas @0@ (@1@)'.format(version, api_version), '', - ' Demos: @0@'.format(build_demos), ' Documentation: @0@'.format(build_gtk_doc), - ' Glade catalog: @0@'.format(install_glade_catalog), - ' GTK+ widgetry: @0@'.format(build_gtk_widgetry), ' Introspection: @0@'.format(generate_gir), ' Lua 5.1 support: @0@'.format(build_lua51_loader), - ' Python 2 support: @0@'.format(build_python2_loader), ' Python 3 support: @0@'.format(build_python3_loader), '', 'Directories:', diff --git a/meson_options.txt b/meson_options.txt index cb21e45..7ff25b9 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -2,16 +2,10 @@ option('lua51', type: 'boolean', value: true, description: 'Enable Lua 5.1 support (requires lua-lgi)') -option('python2', - type: 'boolean', value: false, - description: 'Enable Python 2 support (requires pygobject)') option('python3', type: 'boolean', value: true, description: 'Enable Python 3 support (requires pygobject)') -option('python2_path', - type: 'string', value: '', - description: 'Path to Python 2.x interpreter (Windows only)') option('python3_path', type: 'string', value: '', description: 'Path to Python 3.x interpreter (Windows only)') @@ -23,13 +17,6 @@ option('vapi', type: 'boolean', value: false, description: 'Generate vapi data (requires vapigen)') -option('widgetry', - type: 'boolean', value: true, - description: 'Build GTK+ widgetry (requires gtk+)') -option('glade_catalog', - type: 'boolean', value: true, - description: 'Install Glade catalog (requires gladeui)') - option('demos', type: 'boolean', value: true, description: 'Build demo programs') diff --git a/peas-demo/meson.build b/peas-demo/meson.build deleted file mode 100644 index a3ec53b..0000000 --- a/peas-demo/meson.build +++ /dev/null @@ -1,25 +0,0 @@ -peas_demo_name = 'peas-demo' -peas_demo_string = '@0@-@1@'.format(peas_demo_name, api_version) -peas_demo_plugins_dir = join_paths(get_option('libdir'), 'peas-demo', 'plugins') - -peas_demo_c = [ - 'peas-demo-window.c', - 'peas-demo.c', -] - -peas_demo_c_args = [ - '-DHAVE_CONFIG_H', - '-DPEAS_BUILDDIR="@0@"'.format(builddir), - '-DPEAS_PREFIX="@0@"'.format(prefix), - '-DPEAS_LIBDIR="@0@"'.format(libdir), -] - -executable( - peas_demo_name, - peas_demo_c, - c_args: project_c_args + peas_demo_c_args, - dependencies: [libpeas_gtk_dep], - install: true, -) - -subdir('plugins') diff --git a/peas-demo/peas-demo-window.c b/peas-demo/peas-demo-window.c deleted file mode 100644 index 4f2943a..0000000 --- a/peas-demo/peas-demo-window.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * peas-demo-window.c - * This file is part of libpeas - * - * Copyright (C) 2010 Steve Frécinaux - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "peas-demo-window.h" - -G_DEFINE_TYPE (DemoWindow, demo_window, GTK_TYPE_WINDOW) - -static void -on_extension_added (PeasExtensionSet *set, - PeasPluginInfo *info, - PeasExtension *exten, - DemoWindow *dw) -{ - peas_activatable_activate (PEAS_ACTIVATABLE (exten)); -} - -static void -on_extension_removed (PeasExtensionSet *set, - PeasPluginInfo *info, - PeasExtension *exten, - DemoWindow *dw) -{ - peas_activatable_deactivate (PEAS_ACTIVATABLE (exten)); -} - -static void -demo_window_init (DemoWindow *dw) -{ - DemoWindowClass *klass = DEMO_WINDOW_GET_CLASS (dw); - gchar *label; - - dw->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); - gtk_box_set_homogeneous (GTK_BOX (dw->box), TRUE); - gtk_container_add (GTK_CONTAINER (dw), dw->box); - - label = g_strdup_printf ("Peas Window %d", ++(klass->n_windows)); - gtk_window_set_title (GTK_WINDOW (dw), label); - g_free (label); - - dw->exten_set = peas_extension_set_new (peas_engine_get_default (), - PEAS_TYPE_ACTIVATABLE, - "object", dw, - NULL); - - peas_extension_set_foreach (dw->exten_set, - (PeasExtensionSetForeachFunc) on_extension_added, - dw); - - g_signal_connect (dw->exten_set, "extension-added", G_CALLBACK (on_extension_added), dw); - g_signal_connect (dw->exten_set, "extension-removed", G_CALLBACK (on_extension_removed), dw); -} - -static void -demo_window_dispose (GObject *object) -{ - DemoWindow *dw = DEMO_WINDOW (object); - - g_clear_object (&dw->exten_set); - - G_OBJECT_CLASS (demo_window_parent_class)->dispose (object); -} - -static void -demo_window_class_init (DemoWindowClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->dispose = demo_window_dispose; - - klass->n_windows = 0; -} - -GtkWidget * -demo_window_new (void) -{ - return GTK_WIDGET (g_object_new (DEMO_TYPE_WINDOW, NULL)); -} diff --git a/peas-demo/peas-demo-window.h b/peas-demo/peas-demo-window.h deleted file mode 100644 index 028cf31..0000000 --- a/peas-demo/peas-demo-window.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * peas-demo-window.h - * This file is part of libpeas - * - * Copyright (C) 2010 Steve Frécinaux - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __PEAS_DEMO_WINDOW_H__ -#define __PEAS_DEMO_WINDOW_H__ - -#include <gtk/gtk.h> -#include <libpeas/peas.h> - -G_BEGIN_DECLS - -/* - * Type checking and casting macros - */ -#define DEMO_TYPE_WINDOW (demo_window_get_type()) -#define DEMO_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), DEMO_TYPE_WINDOW, DemoWindow)) -#define DEMO_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), DEMO_TYPE_WINDOW, DemoWindowClass)) -#define DEMO_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), DEMO_TYPE_WINDOW)) -#define DEMO_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEMO_TYPE_WINDOW)) -#define DEMO_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), DEMO_TYPE_WINDOW, DemoWindowClass)) - -typedef struct _DemoWindow DemoWindow; -typedef struct _DemoWindowClass DemoWindowClass; - -struct _DemoWindow -{ - GtkWindow parent; - - GtkWidget *box; - - PeasEngine *engine; - PeasExtensionSet *exten_set; -}; - -struct _DemoWindowClass -{ - GtkWindowClass parent_class; - - guint n_windows; -}; - -GType demo_window_get_type (void) G_GNUC_CONST; -GtkWidget *demo_window_new (void); - -G_END_DECLS - -#endif /* __DEMO_WINDOW_H__ */ diff --git a/peas-demo/peas-demo.c b/peas-demo/peas-demo.c deleted file mode 100644 index fd9b766..0000000 --- a/peas-demo/peas-demo.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - * peas-demo.c - * This file is part of libpeas - * - * Copyright (C) 2009-2010 Steve Frécinaux - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <girepository.h> -#include <glib/gi18n.h> -#include <gtk/gtk.h> -#include <locale.h> - -#include <libpeas/peas.h> -#include <libpeas-gtk/peas-gtk.h> - -#include "peas-demo-window.h" - -gboolean run_from_build_dir; -static GtkWidget *main_window; -static int n_windows; - -static GOptionEntry demo_args[] = { - { "run-from-build-dir", 'b', 0, G_OPTION_ARG_NONE, &run_from_build_dir, - /* Translators: The directory in which the demo program was compiled at */ - N_("Run from build directory"), NULL }, - { NULL } -}; - -static void -create_new_window (void) -{ - GtkWidget *window; - - window = demo_window_new (); - gtk_widget_show_all (window); -} - -static GtkWidget * -create_main_window (void) -{ - GtkWidget *window; - GtkWidget *box; - GtkWidget *manager; - GtkWidget *scrolled_window; - GtkWidget *button_box; - GtkWidget *button; - - gtk_window_set_default_icon_name ("libpeas-plugin"); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - g_signal_connect (window, "delete-event", G_CALLBACK (gtk_main_quit), NULL); - gtk_container_set_border_width (GTK_CONTAINER (window), 6); - gtk_window_set_title (GTK_WINDOW (window), "Peas Demo"); - - box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); - gtk_container_add (GTK_CONTAINER (window), box); - - manager = peas_gtk_plugin_manager_new (peas_engine_get_default ()); - gtk_box_pack_start (GTK_BOX (box), manager, TRUE, TRUE, 0); - - /* Always show all plugins, there are only a few */ - scrolled_window = gtk_test_find_sibling (manager, - GTK_TYPE_SCROLLED_WINDOW); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_NEVER, GTK_POLICY_NEVER); - - button_box = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL); - gtk_box_set_spacing (GTK_BOX (button_box), 6); - gtk_button_box_set_layout (GTK_BUTTON_BOX (button_box), GTK_BUTTONBOX_END); - gtk_box_pack_start (GTK_BOX (box), button_box, FALSE, FALSE, 0); - - button = gtk_button_new_with_label ("New window"); - g_signal_connect (button, "clicked", G_CALLBACK (create_new_window), NULL); - gtk_container_add (GTK_CONTAINER (button_box), button); - - button = gtk_button_new_with_mnemonic (_("_Quit")); - g_signal_connect (button, "clicked", G_CALLBACK (gtk_main_quit), NULL); - gtk_container_add (GTK_CONTAINER (button_box), button); - - return window; -} - -int -main (int argc, - char **argv) -{ - GOptionContext *option_context; - GError *error = NULL; - gchar *plugin_dir; - PeasEngine *engine; - - setlocale (LC_ALL, ""); - /* Normally, we'd need to call bindtextdomain() here. But that would require - * access to the dynamic peas_dirs_get_locale_dir() which is not available - * via the ABI. However, libpeas has a static constructor for it so we do - * not need to call it anyway. - */ - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - textdomain (GETTEXT_PACKAGE); - - option_context = g_option_context_new (_("— libpeas demo application")); - g_option_context_add_main_entries (option_context, demo_args, GETTEXT_PACKAGE); - g_option_context_add_group (option_context, gtk_get_option_group (TRUE)); - - if (!g_option_context_parse (option_context, &argc, &argv, &error)) - { - g_warning ("Error while parsing arguments: %s", error->message); - g_error_free (error); - return -1; - } - - g_option_context_free (option_context); - - if (run_from_build_dir) - { - g_debug ("Running from build directory: %s", PEAS_BUILDDIR); - - /* Use the uninstalled typelibs */ - g_irepository_prepend_search_path (PEAS_BUILDDIR "/libpeas"); - g_irepository_prepend_search_path (PEAS_BUILDDIR "/libpeas-gtk"); - - /* Use the uninstalled plugin loaders */ - g_setenv ("PEAS_PLUGIN_LOADERS_DIR", PEAS_BUILDDIR "/loaders", TRUE); - } - - engine = peas_engine_get_default (); - plugin_dir = g_build_filename (g_get_user_config_dir (), "peas-demo/plugins", NULL); - peas_engine_add_search_path (engine, plugin_dir, plugin_dir); - g_free (plugin_dir); - - /* We don't care about leaking memory */ - g_setenv ("PEAS_ALLOW_ALL_LOADERS", "1", TRUE); - peas_engine_enable_loader (engine, "lua5.1"); - peas_engine_enable_loader (engine, "python3"); - - if (run_from_build_dir) - peas_engine_add_search_path (engine, PEAS_BUILDDIR "/peas-demo/plugins", NULL); - else - { -#ifdef G_OS_WIN32 - char *prefix; - char *demo_pluginlibdir, *demo_plugindatadir; -#endif - - peas_engine_add_search_path (engine, - PEAS_LIBDIR "/peas-demo/plugins/", - PEAS_PREFIX "/share/peas-demo/plugins"); - -#ifdef G_OS_WIN32 - /* this is so that the paths are relocatable on Windows */ - prefix = g_win32_get_package_installation_directory_of_module (NULL); - demo_pluginlibdir = g_build_filename (prefix, - "lib", - "peas-demo", - "plugins", - NULL); - demo_plugindatadir = g_build_filename (prefix, - "share", - "peas-demo", - "plugins", - NULL); - peas_engine_add_search_path (engine, - demo_pluginlibdir, - demo_plugindatadir); - - g_free (demo_plugindatadir); - g_free (demo_pluginlibdir); - g_free (prefix); -#endif - } - - n_windows = 0; - main_window = create_main_window (); - gtk_widget_show_all (main_window); - - gtk_main (); - - gtk_widget_destroy (main_window); - - g_object_unref (engine); - - return 0; -} diff --git a/peas-demo/plugins/helloworld/helloworld.plugin b/peas-demo/plugins/helloworld/helloworld.plugin deleted file mode 100644 index 7efed12..0000000 --- a/peas-demo/plugins/helloworld/helloworld.plugin +++ /dev/null @@ -1,8 +0,0 @@ -[Plugin] -Module=helloworld -Name=Hello World -Description=Inserts a box containing "Hello World" in every windows. -Authors=Steve Frécinaux <code@istique.net> -Copyright=Copyright © 2009 Steve Frécinaux -Website=http://code.istique.net/ -Help=http://git.gnome.org/browse/libpeas diff --git a/peas-demo/plugins/helloworld/meson.build b/peas-demo/plugins/helloworld/meson.build deleted file mode 100644 index c4ad81c..0000000 --- a/peas-demo/plugins/helloworld/meson.build +++ /dev/null @@ -1,34 +0,0 @@ -libhelloworld_name = 'helloworld' - -libhelloworld_c = [ - 'peasdemo-hello-world-configurable.c', - 'peasdemo-hello-world-plugin.c', -] - -libhelloworld_plugin_data = [ - 'helloworld.plugin', -] - -libhelloworld_c_args = [ - '-DHAVE_CONFIG_H', -] - -libhelloworld_lib = shared_library( - libhelloworld_name, - libhelloworld_c, - include_directories: rootdir, - dependencies: [gtk_dep, libpeas_gtk_dep], - c_args: project_c_args + libhelloworld_c_args, - install_dir: join_paths(peas_demo_plugins_dir, 'helloworld'), - install: true, -) - -custom_target( - 'lib@0@-data'.format(libhelloworld_name), - input: libhelloworld_plugin_data, - output: libhelloworld_plugin_data, - command: [copyfile_script, '@INPUT@', '@OUTDIR@'], - build_by_default: true, - install_dir: join_paths(peas_demo_plugins_dir, 'helloworld'), - install: true, -) diff --git a/peas-demo/plugins/helloworld/peasdemo-hello-world-configurable.c b/peas-demo/plugins/helloworld/peasdemo-hello-world-configurable.c deleted file mode 100644 index a44e70e..0000000 --- a/peas-demo/plugins/helloworld/peasdemo-hello-world-configurable.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * peasdemo-hello-world-configurable.c - * This file is part of libpeas - * - * Copyright (C) 2009-2010 Steve Frécinaux - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <glib.h> -#include <glib-object.h> -#include <gmodule.h> -#include <gtk/gtk.h> - -#include <libpeas/peas.h> -#include <libpeas-gtk/peas-gtk.h> - -#include "peasdemo-hello-world-configurable.h" - -static void peas_gtk_configurable_iface_init (PeasGtkConfigurableInterface *iface); - -G_DEFINE_DYNAMIC_TYPE_EXTENDED (PeasDemoHelloWorldConfigurable, - peasdemo_hello_world_configurable, - PEAS_TYPE_EXTENSION_BASE, - 0, - G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_GTK_TYPE_CONFIGURABLE, - peas_gtk_configurable_iface_init)) - -static void -peasdemo_hello_world_configurable_init (PeasDemoHelloWorldConfigurable *plugin) -{ - g_debug ("%s", G_STRFUNC); -} - -static GtkWidget * -peasdemo_hello_world_configurable_create_configure_widget (PeasGtkConfigurable *configurable) -{ - g_debug ("%s", G_STRFUNC); - - return gtk_label_new ("This is a configuration dialog for the HelloWorld plugin."); -} - -static void -peasdemo_hello_world_configurable_class_init (PeasDemoHelloWorldConfigurableClass *klass) -{ -} - -static void -peas_gtk_configurable_iface_init (PeasGtkConfigurableInterface *iface) -{ - iface->create_configure_widget = peasdemo_hello_world_configurable_create_configure_widget; -} - -static void -peasdemo_hello_world_configurable_class_finalize (PeasDemoHelloWorldConfigurableClass *klass) -{ -} - -void -peasdemo_hello_world_configurable_register (GTypeModule *module) -{ - peasdemo_hello_world_configurable_register_type (module); -} diff --git a/peas-demo/plugins/helloworld/peasdemo-hello-world-configurable.h b/peas-demo/plugins/helloworld/peasdemo-hello-world-configurable.h deleted file mode 100644 index 27fab24..0000000 --- a/peas-demo/plugins/helloworld/peasdemo-hello-world-configurable.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * peasdemo-hello-world-configurable.h - * This file is part of libpeas - * - * Copyright (C) 2009-2010 Steve Frécinaux - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __PEASDEMO_HELLO_WORLD_CONFIGURABLE_H__ -#define __PEASDEMO_HELLO_WORLD_CONFIGURABLE_H__ - -#include <gtk/gtk.h> -#include <libpeas/peas.h> - -G_BEGIN_DECLS - -#define PEASDEMO_TYPE_HELLO_WORLD_CONFIGURABLE (peasdemo_hello_world_configurable_get_type ()) -#define PEASDEMO_HELLO_WORLD_CONFIGURABLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PEASDEMO_TYPE_HELLO_WORLD_CONFIGURABLE, PeasDemoHelloWorldConfigurable)) -#define PEASDEMO_HELLO_WORLD_CONFIGURABLE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PEASDEMO_TYPE_HELLO_WORLD_CONFIGURABLE, PeasDemoHelloWorldConfigurable)) -#define PEASDEMO_IS_HELLO_WORLD_CONFIGURABLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PEASDEMO_TYPE_HELLO_WORLD_CONFIGURABLE)) -#define PEASDEMO_IS_HELLO_WORLD_CONFIGURABLE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PEASDEMO_TYPE_HELLO_WORLD_CONFIGURABLE)) -#define PEASDEMO_HELLO_WORLD_CONFIGURABLE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PEASDEMO_TYPE_HELLO_WORLD_CONFIGURABLE, PeasDemoHelloWorldConfigurableClass)) - -typedef struct _PeasDemoHelloWorldConfigurable PeasDemoHelloWorldConfigurable; -typedef struct _PeasDemoHelloWorldConfigurableClass PeasDemoHelloWorldConfigurableClass; - -struct _PeasDemoHelloWorldConfigurable { - PeasExtensionBase parent; -}; - -struct _PeasDemoHelloWorldConfigurableClass { - PeasExtensionBaseClass parent_class; -}; - -GType peasdemo_hello_world_configurable_get_type (void) G_GNUC_CONST; -void peasdemo_hello_world_configurable_register (GTypeModule *module); - -G_END_DECLS - -#endif /* __PEASDEMO_HELLO_WORLD_CONFIGURABLE_H__ */ diff --git a/peas-demo/plugins/helloworld/peasdemo-hello-world-plugin.c b/peas-demo/plugins/helloworld/peasdemo-hello-world-plugin.c deleted file mode 100644 index 3ac4172..0000000 --- a/peas-demo/plugins/helloworld/peasdemo-hello-world-plugin.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - * peasdemo-hello-world-plugin.c - * This file is part of libpeas - * - * Copyright (C) 2009-2010 Steve Frécinaux - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <glib.h> -#include <glib-object.h> -#include <gmodule.h> -#include <gtk/gtk.h> - -#include <libpeas/peas.h> -#include <libpeas-gtk/peas-gtk.h> - -#include "peasdemo-hello-world-plugin.h" -#include "peasdemo-hello-world-configurable.h" - -static void peas_activatable_iface_init (PeasActivatableInterface *iface); - -G_DEFINE_DYNAMIC_TYPE_EXTENDED (PeasDemoHelloWorldPlugin, - peasdemo_hello_world_plugin, - PEAS_TYPE_EXTENSION_BASE, - 0, - G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE, - peas_activatable_iface_init)) - -enum { - PROP_0, - PROP_OBJECT -}; - -static void -peasdemo_hello_world_plugin_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - PeasDemoHelloWorldPlugin *plugin = PEASDEMO_HELLO_WORLD_PLUGIN (object); - - switch (prop_id) - { - case PROP_OBJECT: - plugin->window = GTK_WIDGET (g_value_dup_object (value)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -peasdemo_hello_world_plugin_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - PeasDemoHelloWorldPlugin *plugin = PEASDEMO_HELLO_WORLD_PLUGIN (object); - - switch (prop_id) - { - case PROP_OBJECT: - g_value_set_object (value, plugin->window); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - - -static void -peasdemo_hello_world_plugin_init (PeasDemoHelloWorldPlugin *plugin) -{ - g_debug ("%s", G_STRFUNC); -} - -static void -peasdemo_hello_world_plugin_finalize (GObject *object) -{ - PeasDemoHelloWorldPlugin *plugin = PEASDEMO_HELLO_WORLD_PLUGIN (object); - - g_debug ("%s", G_STRFUNC); - - g_object_unref (plugin->label); - g_object_unref (plugin->window); - - G_OBJECT_CLASS (peasdemo_hello_world_plugin_parent_class)->finalize (object); -} - -static GtkBox * -get_box (GtkWidget *window) -{ - return GTK_BOX (gtk_bin_get_child (GTK_BIN (window))); -} - -static void -peasdemo_hello_world_plugin_activate (PeasActivatable *activatable) -{ - PeasDemoHelloWorldPlugin *plugin = PEASDEMO_HELLO_WORLD_PLUGIN (activatable); - - g_debug ("%s", G_STRFUNC); - - plugin->label = gtk_label_new ("Hello World!"); - gtk_box_pack_start (get_box (plugin->window), plugin->label, 1, 1, 0); - gtk_widget_show (plugin->label); - g_object_ref (plugin->label); -} - -static void -peasdemo_hello_world_plugin_deactivate (PeasActivatable *activatable) -{ - PeasDemoHelloWorldPlugin *plugin = PEASDEMO_HELLO_WORLD_PLUGIN (activatable); - - g_debug ("%s", G_STRFUNC); - - gtk_container_remove (GTK_CONTAINER (get_box (plugin->window)), plugin->label); -} - -static void -peasdemo_hello_world_plugin_class_init (PeasDemoHelloWorldPluginClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->set_property = peasdemo_hello_world_plugin_set_property; - object_class->get_property = peasdemo_hello_world_plugin_get_property; - object_class->finalize = peasdemo_hello_world_plugin_finalize; - - g_object_class_override_property (object_class, PROP_OBJECT, "object"); -} - -static void -peas_activatable_iface_init (PeasActivatableInterface *iface) -{ - iface->activate = peasdemo_hello_world_plugin_activate; - iface->deactivate = peasdemo_hello_world_plugin_deactivate; -} - -static void -peasdemo_hello_world_plugin_class_finalize (PeasDemoHelloWorldPluginClass *klass) -{ -} - -G_MODULE_EXPORT void -peas_register_types (PeasObjectModule *module) -{ - peasdemo_hello_world_plugin_register_type (G_TYPE_MODULE (module)); - peasdemo_hello_world_configurable_register (G_TYPE_MODULE (module)); - - peas_object_module_register_extension_type (module, - PEAS_TYPE_ACTIVATABLE, - PEASDEMO_TYPE_HELLO_WORLD_PLUGIN); - peas_object_module_register_extension_type (module, - PEAS_GTK_TYPE_CONFIGURABLE, - PEASDEMO_TYPE_HELLO_WORLD_CONFIGURABLE); -} diff --git a/peas-demo/plugins/helloworld/peasdemo-hello-world-plugin.h b/peas-demo/plugins/helloworld/peasdemo-hello-world-plugin.h deleted file mode 100644 index 910b0a8..0000000 --- a/peas-demo/plugins/helloworld/peasdemo-hello-world-plugin.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * peasdemo-hello-world-plugin.h - * This file is part of libpeas - * - * Copyright (C) 2009-2010 Steve Frécinaux - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __PEASDEMO_HELLO_WORLD_PLUGIN_H__ -#define __PEASDEMO_HELLO_WORLD_PLUGIN_H__ - -#include <gtk/gtk.h> -#include <libpeas/peas.h> - -G_BEGIN_DECLS - -#define PEASDEMO_TYPE_HELLO_WORLD_PLUGIN (peasdemo_hello_world_plugin_get_type ()) -#define PEASDEMO_HELLO_WORLD_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PEASDEMO_TYPE_HELLO_WORLD_PLUGIN, PeasDemoHelloWorldPlugin)) -#define PEASDEMO_HELLO_WORLD_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PEASDEMO_TYPE_HELLO_WORLD_PLUGIN, PeasDemoHelloWorldPlugin)) -#define PEASDEMO_IS_HELLO_WORLD_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PEASDEMO_TYPE_HELLO_WORLD_PLUGIN)) -#define PEASDEMO_IS_HELLO_WORLD_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PEASDEMO_TYPE_HELLO_WORLD_PLUGIN)) -#define PEASDEMO_HELLO_WORLD_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PEASDEMO_TYPE_HELLO_WORLD_PLUGIN, PeasDemoHelloWorldPluginClass)) - -typedef struct _PeasDemoHelloWorldPlugin PeasDemoHelloWorldPlugin; -typedef struct _PeasDemoHelloWorldPluginClass PeasDemoHelloWorldPluginClass; - -struct _PeasDemoHelloWorldPlugin { - PeasExtensionBase parent_instance; - - GtkWidget *window; - GtkWidget *label; -}; - -struct _PeasDemoHelloWorldPluginClass { - PeasExtensionBaseClass parent_class; -}; - -GType peasdemo_hello_world_plugin_get_type (void) G_GNUC_CONST; -G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module); - -G_END_DECLS - -#endif /* __PEASDEMO_HELLO_WORLD_PLUGIN_H__ */ diff --git a/peas-demo/plugins/luahello/luahello.lua b/peas-demo/plugins/luahello/luahello.lua deleted file mode 100644 index e33c659..0000000 --- a/peas-demo/plugins/luahello/luahello.lua +++ /dev/null @@ -1,67 +0,0 @@ --- --- Copyright (C) 2014 - Garrett Regier --- --- libpeas 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. --- --- libpeas 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 --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - -local lgi = require 'lgi' - -local GObject = lgi.GObject -local Gtk = lgi.Gtk -local Peas = lgi.Peas -local PeasGtk = lgi.PeasGtk - - -local LuaHelloPlugin = GObject.Object:derive('LuaHelloPlugin', { - Peas.Activatable -}) - -LuaHelloPlugin._property.object = - GObject.ParamSpecObject('object', 'object', 'object', - GObject.Object._gtype, - { GObject.ParamFlags.READABLE, - GObject.ParamFlags.WRITABLE }) - -function LuaHelloPlugin:do_activate() - local window = self.priv.object - print('LuaHelloPlugin:do_activate', tostring(window)) - self.priv.label = Gtk.Label.new('Lua Says Hello!') - self.priv.label:show() - window:get_child():pack_start(self.priv.label, true, true, 0) -end - -function LuaHelloPlugin:do_deactivate() - local window = self.priv.object - print('LuaHelloPlugin:do_deactivate', tostring(window)) - window:get_child():remove(self.priv.label) - self.priv.label:destroy() -end - -function LuaHelloPlugin:do_update_state() - local window = self.priv.object - print('LuaHelloPlugin:do_update_state', tostring(window)) -end - - -local LuaHelloConfigurable = GObject.Object:derive('LuaHelloConfigurable', { - PeasGtk.Configurable -}) - -function LuaHelloConfigurable:do_create_configure_widget() - return Gtk.Label.new('Lua Hello configure widget') -end - -return { LuaHelloPlugin, LuaHelloConfigurable } - --- ex:set ts=4 et sw=4 ai: diff --git a/peas-demo/plugins/luahello/luahello.plugin b/peas-demo/plugins/luahello/luahello.plugin deleted file mode 100644 index dddfe21..0000000 --- a/peas-demo/plugins/luahello/luahello.plugin +++ /dev/null @@ -1,7 +0,0 @@ -[Plugin] -Module=luahello -Loader=lua5.1 -Name=Lua Says Hello -Description=Inserts a box containing "Lua Says Hello" in every windows. -Authors=Garrett Regier <garrettregier@gmail.com> -Copyright=Copyright © 2014 Garrett Regier diff --git a/peas-demo/plugins/luahello/meson.build b/peas-demo/plugins/luahello/meson.build deleted file mode 100644 index 0d6997d..0000000 --- a/peas-demo/plugins/luahello/meson.build +++ /dev/null @@ -1,16 +0,0 @@ -luahello_name = 'luahello' - -luahello_plugin_data = [ - 'luahello.lua', - 'luahello.plugin', -] - -custom_target( - '@0@-data'.format(luahello_name), - input: luahello_plugin_data, - output: luahello_plugin_data, - command: [copyfile_script, '@INPUT@', '@OUTDIR@'], - build_by_default: true, - install_dir: join_paths(peas_demo_plugins_dir, 'luahello'), - install: true, -) diff --git a/peas-demo/plugins/meson.build b/peas-demo/plugins/meson.build deleted file mode 100644 index c2c343f..0000000 --- a/peas-demo/plugins/meson.build +++ /dev/null @@ -1,11 +0,0 @@ -subdir('helloworld') - -if build_lua51_loader == true - subdir('luahello') -endif - -if build_python3_loader == true - subdir('pythonhello') -endif - -subdir('secondtime') diff --git a/peas-demo/plugins/pythonhello/meson.build b/peas-demo/plugins/pythonhello/meson.build deleted file mode 100644 index 64e4202..0000000 --- a/peas-demo/plugins/pythonhello/meson.build +++ /dev/null @@ -1,16 +0,0 @@ -pythonhello_name = 'pythonhello' - -pythonhello_plugin_data = [ - 'pythonhello.py', - 'pythonhello.plugin', -] - -custom_target( - '@0@-data'.format(pythonhello_name), - input: pythonhello_plugin_data, - output: pythonhello_plugin_data, - command: [copyfile_script, '@INPUT@', '@OUTDIR@'], - build_by_default: true, - install_dir: join_paths(peas_demo_plugins_dir, 'pythonhello'), - install: true, -) diff --git a/peas-demo/plugins/pythonhello/pythonhello.plugin b/peas-demo/plugins/pythonhello/pythonhello.plugin deleted file mode 100644 index 6b96e73..0000000 --- a/peas-demo/plugins/pythonhello/pythonhello.plugin +++ /dev/null @@ -1,12 +0,0 @@ -[Plugin] -Module=pythonhello -Loader=python3 -Name=Python Says Hello -Description=Inserts a box containing "Python Says Hello" in every windows. -Authors=Steve Frécinaux <code@istique.net> -Copyright=Copyright © 2009 Steve Frécinaux -Website=http://code.istique.net/ -Help=http://git.gnome.org/browse/error -Help-Windows=http://git.gnome.org/browse/libpeas -Help-MacOS-X=http://git.gnome.org/browse/libpeas -Help-GNOME=http://git.gnome.org/browse/libpeas diff --git a/peas-demo/plugins/pythonhello/pythonhello.py b/peas-demo/plugins/pythonhello/pythonhello.py deleted file mode 100644 index bf832b3..0000000 --- a/peas-demo/plugins/pythonhello/pythonhello.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- - -# pythonhello.py -# This file is part of libpeas -# -# Copyright (C) 2009-2010 Steve Frécinaux -# -# libpeas 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. -# -# libpeas 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 -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - -from gi.repository import GObject -from gi.repository import Peas -from gi.repository import PeasGtk -from gi.repository import Gtk - -LABEL_STRING="Python Says Hello!" - -class PythonHelloPlugin(GObject.Object, Peas.Activatable): - __gtype_name__ = 'PythonHelloPlugin' - - object = GObject.Property(type=GObject.Object) - - def do_activate(self): - window = self.object - print("PythonHelloPlugin.do_activate", repr(window)) - window._pythonhello_label = Gtk.Label() - window._pythonhello_label.set_text(LABEL_STRING) - window._pythonhello_label.show() - window.get_child().pack_start(window._pythonhello_label, True, True, 0) - - def do_deactivate(self): - window = self.object - print("PythonHelloPlugin.do_deactivate", repr(window)) - window.get_child().remove(window._pythonhello_label) - window._pythonhello_label.destroy() - - def do_update_state(self): - print("PythonHelloPlugin.do_update_state", repr(self.object)) - -class PythonHelloConfigurable(GObject.Object, PeasGtk.Configurable): - __gtype_name__ = 'PythonHelloConfigurable' - - def do_create_configure_widget(self): - return Gtk.Label.new("Python Hello configure widget") - -# ex:set ts=4 et sw=4 ai: diff --git a/peas-demo/plugins/secondtime/gnome-foot.png b/peas-demo/plugins/secondtime/gnome-foot.png Binary files differdeleted file mode 100644 index 0476658..0000000 --- a/peas-demo/plugins/secondtime/gnome-foot.png +++ /dev/null diff --git a/peas-demo/plugins/secondtime/meson.build b/peas-demo/plugins/secondtime/meson.build deleted file mode 100644 index c1631a7..0000000 --- a/peas-demo/plugins/secondtime/meson.build +++ /dev/null @@ -1,33 +0,0 @@ -libsecondtime_name = 'secondtime' - -libsecondtime_c = [ - 'second-time.c', -] - -libsecondtime_plugin_data = [ - 'secondtime.plugin', -] - -libsecondtime_c_args = [ - '-DHAVE_CONFIG_H', -] - -libsecondtime_lib = shared_library( - libsecondtime_name, - libsecondtime_c, - include_directories: rootdir, - dependencies: [gtk_dep, libpeas_dep], - c_args: project_c_args + libsecondtime_c_args, - install_dir: join_paths(peas_demo_plugins_dir, 'secondtime'), - install: true, -) - -custom_target( - 'lib@0@-data'.format(libsecondtime_name), - input: libsecondtime_plugin_data, - output: libsecondtime_plugin_data, - command: [copyfile_script, '@INPUT@', '@OUTDIR@'], - build_by_default: true, - install_dir: join_paths(peas_demo_plugins_dir, 'secondtime'), - install: true, -) diff --git a/peas-demo/plugins/secondtime/second-time.c b/peas-demo/plugins/secondtime/second-time.c deleted file mode 100644 index 5edfca4..0000000 --- a/peas-demo/plugins/secondtime/second-time.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * second-time.c - * This file is part of libpeas - * - * Copyright (C) 2009-2010 Steve Frécinaux - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <glib.h> -#include <glib-object.h> -#include <gmodule.h> -#include <gtk/gtk.h> - -#include <libpeas/peas.h> - -#include "second-time.h" - -static void peas_activatable_iface_init (PeasActivatableInterface *iface); - -G_DEFINE_DYNAMIC_TYPE_EXTENDED (PeasDemoSecondTime, - peasdemo_second_time, - PEAS_TYPE_EXTENSION_BASE, - 0, - G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE, - peas_activatable_iface_init)) - -enum { - PROP_0, - PROP_OBJECT -}; - -static void -peasdemo_second_time_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - PeasDemoSecondTime *plugin = PEASDEMO_SECOND_TIME (object); - - switch (prop_id) - { - case PROP_OBJECT: - plugin->window = GTK_WIDGET (g_value_dup_object (value)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -peasdemo_second_time_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - PeasDemoSecondTime *plugin = PEASDEMO_SECOND_TIME (object); - - switch (prop_id) - { - case PROP_OBJECT: - g_value_set_object (value, plugin->window); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - - -static void -peasdemo_second_time_init (PeasDemoSecondTime *plugin) -{ - g_debug ("%s", G_STRFUNC); -} - -static void -peasdemo_second_time_finalize (GObject *object) -{ - PeasDemoSecondTime *plugin = PEASDEMO_SECOND_TIME (object); - - g_debug ("%s", G_STRFUNC); - - g_object_unref (plugin->label); - g_object_unref (plugin->window); - - G_OBJECT_CLASS (peasdemo_second_time_parent_class)->finalize (object); -} - -static GtkBox * -get_box (GtkWidget *window) -{ - return GTK_BOX (gtk_bin_get_child (GTK_BIN (window))); -} - -static void -peasdemo_second_time_activate (PeasActivatable *activatable) -{ - PeasDemoSecondTime *plugin = PEASDEMO_SECOND_TIME (activatable); - - g_debug ("%s", G_STRFUNC); - - plugin->label = gtk_label_new ("A second time!"); - gtk_box_pack_start (get_box (plugin->window), plugin->label, 1, 1, 0); - gtk_widget_show (plugin->label); - g_object_ref (plugin->label); -} - -static void -peasdemo_second_time_deactivate (PeasActivatable *activatable) -{ - PeasDemoSecondTime *plugin = PEASDEMO_SECOND_TIME (activatable); - - g_debug ("%s", G_STRFUNC); - - gtk_container_remove (GTK_CONTAINER (get_box (plugin->window)), plugin->label); -} - -static void -peasdemo_second_time_class_init (PeasDemoSecondTimeClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->set_property = peasdemo_second_time_set_property; - object_class->get_property = peasdemo_second_time_get_property; - object_class->finalize = peasdemo_second_time_finalize; - - g_object_class_override_property (object_class, PROP_OBJECT, "object"); -} - -static void -peas_activatable_iface_init (PeasActivatableInterface *iface) -{ - iface->activate = peasdemo_second_time_activate; - iface->deactivate = peasdemo_second_time_deactivate; -} - -static void -peasdemo_second_time_class_finalize (PeasDemoSecondTimeClass *klass) -{ -} - -G_MODULE_EXPORT void -peas_register_types (PeasObjectModule *module) -{ - peasdemo_second_time_register_type (G_TYPE_MODULE (module)); - - peas_object_module_register_extension_type (module, - PEAS_TYPE_ACTIVATABLE, - PEASDEMO_TYPE_SECOND_TIME); -} diff --git a/peas-demo/plugins/secondtime/second-time.h b/peas-demo/plugins/secondtime/second-time.h deleted file mode 100644 index 47ca685..0000000 --- a/peas-demo/plugins/secondtime/second-time.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * second-time.h - * This file is part of libpeas - * - * Copyright (C) 2010 Steve Frécinaux - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef __PEASDEMO_SECOND_TIME_H__ -#define __PEASDEMO_SECOND_TIME_H__ - -#include <gtk/gtk.h> -#include <libpeas/peas.h> - -G_BEGIN_DECLS - -#define PEASDEMO_TYPE_SECOND_TIME (peasdemo_second_time_get_type ()) -#define PEASDEMO_SECOND_TIME(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PEASDEMO_TYPE_SECOND_TIME, PeasDemoSecondTime)) -#define PEASDEMO_SECOND_TIME_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PEASDEMO_TYPE_SECOND_TIME, PeasDemoSecondTime)) -#define PEASDEMO_IS_SECOND_TIME(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PEASDEMO_TYPE_SECOND_TIME)) -#define PEASDEMO_IS_SECOND_TIME_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PEASDEMO_TYPE_SECOND_TIME)) -#define PEASDEMO_SECOND_TIME_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PEASDEMO_TYPE_SECOND_TIME, PeasDemoSecondTimeClass)) - -typedef struct _PeasDemoSecondTime PeasDemoSecondTime; -typedef struct _PeasDemoSecondTimeClass PeasDemoSecondTimeClass; - -struct _PeasDemoSecondTime { - PeasExtensionBase parent_instance; - - GtkWidget *window; - GtkWidget *label; -}; - -struct _PeasDemoSecondTimeClass { - PeasExtensionBaseClass parent_class; -}; - -GType peasdemo_second_time_get_type (void) G_GNUC_CONST; -G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module); - -G_END_DECLS - -#endif /* __PEASDEMO_SECOND_TIME_H__ */ diff --git a/peas-demo/plugins/secondtime/secondtime.plugin b/peas-demo/plugins/secondtime/secondtime.plugin deleted file mode 100644 index 27e30f9..0000000 --- a/peas-demo/plugins/secondtime/secondtime.plugin +++ /dev/null @@ -1,9 +0,0 @@ -[Plugin] -Module=secondtime -Depends=helloworld -Icon=gnome-foot.png -Name=A Second Time! -Description=Inserts a box containing "A second time!" in every windows. -Authors=Steve Frécinaux <code@istique.net> -Copyright=Copyright © 2010 Steve Frécinaux -Website=https://wiki.gnome.org/Projects/Libpeas diff --git a/po/POTFILES.in b/po/POTFILES.in index b5b759d..7b53a78 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -6,8 +6,3 @@ libpeas/peas-extension-set.c libpeas/peas-object-module.c libpeas/peas-plugin-info.c libpeas/peas-plugin-loader.c -libpeas-gtk/peas-gtk-disable-plugins-dialog.c -libpeas-gtk/peas-gtk-plugin-manager.c -libpeas-gtk/peas-gtk-plugin-manager-view.c -peas-demo/peas-demo.c -tests/libpeas-gtk/plugin-manager.c diff --git a/tests/libpeas-gtk/meson.build b/tests/libpeas-gtk/meson.build deleted file mode 100644 index a185110..0000000 --- a/tests/libpeas-gtk/meson.build +++ /dev/null @@ -1,34 +0,0 @@ - -libpeas_gtk_tests_sources = [ - ['plugin-manager'], - ['plugin-manager-store'], - ['plugin-manager-view'], -] - -subdir('testing') - -subdir('plugins') - -libpeas_gtk_tests_deps = [ - glib_dep, - gtk_dep, - libpeas_dep, - libpeas_gtk_dep, - - libtesting_util_dep, - libpeas_gtk_testing_dep, -] - -foreach test: libpeas_gtk_tests_sources - test_name = test.get(0) - test_sources = ['@0@.c'.format(test_name)] - - test_exe = executable( - test_name, - test_sources, - c_args: ['-UG_DISABLE_ASSERT', '-UG_DISABLE_CAST_CHECKS'], - dependencies: libpeas_gtk_tests_deps - ) - - test('test-@0@'.format(test_name), test_exe, env: test_env) -endforeach diff --git a/tests/libpeas-gtk/plugin-manager-store.c b/tests/libpeas-gtk/plugin-manager-store.c deleted file mode 100644 index e9f5d06..0000000 --- a/tests/libpeas-gtk/plugin-manager-store.c +++ /dev/null @@ -1,363 +0,0 @@ -/* - * plugin-manager-store.c - * This file is part of libpeas - * - * Copyright (C) 2010 - Garrett Regier - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <glib.h> -#include <gtk/gtk.h> -#include <libpeas/peas.h> -#include <libpeas-gtk/peas-gtk.h> - -#include "libpeas-gtk/peas-gtk-plugin-manager-store.h" - -#include "testing/testing.h" - -typedef struct _TestFixture TestFixture; - -struct _TestFixture { - PeasEngine *engine; - GtkTreeModel *model; - PeasGtkPluginManagerStore *store; -}; - -static void -test_setup (TestFixture *fixture, - gconstpointer data) -{ - fixture->engine = testing_engine_new (); - fixture->store = peas_gtk_plugin_manager_store_new (fixture->engine); - fixture->model = GTK_TREE_MODEL (fixture->store); -} - -static void -test_teardown (TestFixture *fixture, - gconstpointer data) -{ - g_object_unref (fixture->store); - - testing_engine_free (fixture->engine); -} - -static void -test_runner (TestFixture *fixture, - gconstpointer data) -{ - ((void (*) (TestFixture *)) data) (fixture); -} - -static void -test_gtk_plugin_manager_store_sorted (TestFixture *fixture) -{ - GtkTreeIter iter; - PeasPluginInfo *info1, *info2; - - /* TODO: add a plugin that would cause this to assert if strcmp() was used */ - - g_assert (gtk_tree_model_get_iter_first (fixture->model, &iter)); - - info2 = peas_gtk_plugin_manager_store_get_plugin (fixture->store, &iter); - - while (gtk_tree_model_iter_next (fixture->model, &iter)) - { - info1 = info2; - info2 = peas_gtk_plugin_manager_store_get_plugin (fixture->store, &iter); - - g_assert_cmpint (g_utf8_collate (peas_plugin_info_get_name (info1), - peas_plugin_info_get_name (info2)), - <, 0); - } -} - -static void -test_gtk_plugin_manager_store_plugin_loaded (TestFixture *fixture) -{ - GtkTreeIter iter; - PeasPluginInfo *info; - - g_assert (gtk_tree_model_get_iter_first (fixture->model, &iter)); - info = peas_gtk_plugin_manager_store_get_plugin (fixture->store, &iter); - - g_assert (!peas_gtk_plugin_manager_store_get_enabled (fixture->store, &iter)); - - peas_engine_load_plugin (fixture->engine, info); - - g_assert (peas_gtk_plugin_manager_store_get_enabled (fixture->store, &iter)); -} - -static void -test_gtk_plugin_manager_store_plugin_unloaded (TestFixture *fixture) -{ - GtkTreeIter iter; - PeasPluginInfo *info; - - test_gtk_plugin_manager_store_plugin_loaded (fixture); - - g_assert (gtk_tree_model_get_iter_first (fixture->model, &iter)); - info = peas_gtk_plugin_manager_store_get_plugin (fixture->store, &iter); - - peas_engine_unload_plugin (fixture->engine, info); - - g_assert (!peas_gtk_plugin_manager_store_get_enabled (fixture->store, &iter)); -} - -static void -verify_model (TestFixture *fixture, - PeasPluginInfo *info, - gboolean can_enable, - const gchar *icon_name, - GType icon_type, - gboolean icon_visible, - gboolean info_sensitive) -{ - GtkTreeIter iter; - gboolean model_can_enable, model_icon_visible, model_info_sensitive; - GIcon *model_icon_gicon; - gchar *model_icon_stock_id; - - g_assert (peas_gtk_plugin_manager_store_get_iter_from_plugin (fixture->store, - &iter, info)); - - gtk_tree_model_get (fixture->model, &iter, - PEAS_GTK_PLUGIN_MANAGER_STORE_CAN_ENABLE_COLUMN, &model_can_enable, - PEAS_GTK_PLUGIN_MANAGER_STORE_ICON_GICON_COLUMN, &model_icon_gicon, - PEAS_GTK_PLUGIN_MANAGER_STORE_ICON_STOCK_ID_COLUMN, &model_icon_stock_id, - PEAS_GTK_PLUGIN_MANAGER_STORE_ICON_VISIBLE_COLUMN, &model_icon_visible, - PEAS_GTK_PLUGIN_MANAGER_STORE_INFO_SENSITIVE_COLUMN, &model_info_sensitive, - -1); - - g_assert_cmpint (model_can_enable, ==, can_enable); - g_assert_cmpint (model_icon_visible, ==, icon_visible); - g_assert_cmpint (model_info_sensitive, ==, info_sensitive); - - if (icon_type == G_TYPE_INVALID) - { - g_assert_cmpstr (model_icon_stock_id, ==, icon_name); - } - else - { - g_assert (g_type_is_a (G_OBJECT_TYPE (model_icon_gicon), icon_type)); - - if (icon_type == G_TYPE_FILE_ICON) - { - GFile *file; - gchar *basename; - - file = g_file_icon_get_file (G_FILE_ICON (model_icon_gicon)); - basename = g_file_get_basename (file); - - g_assert_cmpstr (basename, ==, icon_name); - - g_free (basename); - } - else if (icon_type == G_TYPE_THEMED_ICON) - { - GThemedIcon *themed_icon; - const gchar * const *icon_names; - - themed_icon = G_THEMED_ICON (model_icon_gicon); - icon_names = g_themed_icon_get_names (themed_icon); - - g_assert (icon_names); - g_assert_cmpstr (icon_names[0], ==, icon_name); - } - else - { - g_assert_not_reached (); - } - - g_object_unref (model_icon_gicon); - } - - g_free (model_icon_stock_id); -} - -static void -test_gtk_plugin_manager_store_verify_loadable (TestFixture *fixture) -{ - PeasPluginInfo *info; - - info = peas_engine_get_plugin_info (fixture->engine, "loadable"); - - verify_model (fixture, info, TRUE, "libpeas-plugin", G_TYPE_THEMED_ICON, - FALSE, TRUE); -} - -static void -test_gtk_plugin_manager_store_verify_unavailable (TestFixture *fixture) -{ - PeasPluginInfo *info; - - testing_util_push_log_hook ("Could not find plugin 'does-not-exist'*"); - - info = peas_engine_get_plugin_info (fixture->engine, "unavailable"); - - verify_model (fixture, info, TRUE, "libpeas-plugin", G_TYPE_THEMED_ICON, - FALSE, TRUE); - - peas_engine_load_plugin (fixture->engine, info); - - verify_model (fixture, info, FALSE, "dialog-error", - G_TYPE_THEMED_ICON, TRUE, FALSE); -} - -static void -test_gtk_plugin_manager_store_verify_builtin (TestFixture *fixture) -{ - PeasPluginInfo *info; - - info = peas_engine_get_plugin_info (fixture->engine, "builtin"); - - verify_model (fixture, info, FALSE, "libpeas-plugin", G_TYPE_THEMED_ICON, - FALSE, FALSE); - - peas_engine_load_plugin (fixture->engine, info); - - verify_model (fixture, info, FALSE, "libpeas-plugin", G_TYPE_THEMED_ICON, - FALSE, TRUE); -} - -static void -test_gtk_plugin_manager_store_verify_info (TestFixture *fixture) -{ - GtkTreeIter iter; - PeasPluginInfo *info; - gchar *model_info; - - /* Has description */ - info = peas_engine_get_plugin_info (fixture->engine, "configurable"); - g_assert (peas_gtk_plugin_manager_store_get_iter_from_plugin (fixture->store, - &iter, info)); - - gtk_tree_model_get (fixture->model, &iter, - PEAS_GTK_PLUGIN_MANAGER_STORE_INFO_COLUMN, &model_info, - -1); - g_assert_cmpstr (model_info, ==, "<b>Configurable</b>\nA plugin " - "that can be loaded and configured."); - g_free (model_info); - - /* Does not have description */ - info = peas_engine_get_plugin_info (fixture->engine, "min-info"); - g_assert (peas_gtk_plugin_manager_store_get_iter_from_plugin (fixture->store, - &iter, info)); - - gtk_tree_model_get (fixture->model, &iter, - PEAS_GTK_PLUGIN_MANAGER_STORE_INFO_COLUMN, &model_info, - -1); - g_assert_cmpstr (model_info, ==, "<b>Min Info</b>"); - g_free (model_info); -} - -static void -verify_icon (TestFixture *fixture, - const gchar *plugin_name, - const gchar *icon_name, - GType icon_type) -{ - PeasPluginInfo *info; - - info = peas_engine_get_plugin_info (fixture->engine, plugin_name); - - verify_model (fixture, info, TRUE, icon_name, icon_type, FALSE, TRUE); -} - -static void -test_gtk_plugin_manager_store_valid_custom_icon (TestFixture *fixture) -{ - verify_icon (fixture, "valid-custom-icon", "exists.png", G_TYPE_FILE_ICON); -} - -static void -test_gtk_plugin_manager_store_valid_stock_icon (TestFixture *fixture) -{ - GtkIconTheme *icon_theme; - GType icon_type = G_TYPE_INVALID; - - icon_theme = gtk_icon_theme_get_default (); - - /* Usually the theme does not have this icon */ - if (gtk_icon_theme_has_icon (icon_theme, "gtk-unindent")) - icon_type = G_TYPE_THEMED_ICON; - - verify_icon (fixture, "valid-stock-icon", "gtk-unindent", icon_type); -} - -static void -test_gtk_plugin_manager_store_invalid_custom_icon (TestFixture *fixture) -{ - verify_icon (fixture, "invalid-custom-icon", "libpeas-plugin", - G_TYPE_THEMED_ICON); -} - -static void -test_gtk_plugin_manager_store_invalid_stock_icon (TestFixture *fixture) -{ - verify_icon (fixture, "invalid-stock-icon", "libpeas-plugin", - G_TYPE_THEMED_ICON); -} - -static void -test_gtk_plugin_manager_store_hidden (TestFixture *fixture) -{ - PeasPluginInfo *info; - GtkTreeIter iter; - - info = peas_engine_get_plugin_info (fixture->engine, "hidden"); - - g_assert (peas_plugin_info_is_hidden (info)); - - g_assert (!peas_gtk_plugin_manager_store_get_iter_from_plugin (fixture->store, - &iter, info)); -} - -int -main (int argc, - char **argv) -{ - testing_init (&argc, &argv); - -#define TEST(path, ftest) \ - g_test_add ("/gtk/plugin-manager-store/" path, TestFixture, \ - (gpointer) test_gtk_plugin_manager_store_##ftest, \ - test_setup, test_runner, test_teardown) - - TEST ("sorted", sorted); - - TEST ("plugin-loaded", plugin_loaded); - TEST ("plugin-unloaded", plugin_unloaded); - - TEST ("verify-loadable", verify_loadable); - TEST ("verify-unavailable", verify_unavailable); - TEST ("verify-builtin", verify_builtin); - TEST ("verify-info", verify_info); - - TEST ("valid-custom-icon", valid_custom_icon); - TEST ("valid-stock-icon", valid_stock_icon); - TEST ("invalid-custom-icon", invalid_custom_icon); - TEST ("invalid-stock-icon", invalid_stock_icon); - - TEST ("hidden", hidden); - -#undef TEST - - return testing_run_tests (); -} diff --git a/tests/libpeas-gtk/plugin-manager-view.c b/tests/libpeas-gtk/plugin-manager-view.c deleted file mode 100644 index 2acd209..0000000 --- a/tests/libpeas-gtk/plugin-manager-view.c +++ /dev/null @@ -1,264 +0,0 @@ -/* - * plugin-manager-view.c - * This file is part of libpeas - * - * Copyright (C) 2010 - Garrett Regier - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <glib.h> -#include <gtk/gtk.h> -#include <libpeas/peas.h> -#include <libpeas-gtk/peas-gtk.h> - -#include "testing/testing.h" - -typedef struct _TestFixture TestFixture; - -struct _TestFixture { - PeasEngine *engine; - GtkTreeView *tree_view; - PeasGtkPluginManagerView *view; - GtkTreeSelection *selection; - GtkTreeModel *model; - GtkListStore *store; -}; - -static void -notify_model_cb (GtkTreeView *view, - GParamSpec *pspec, - TestFixture *fixture) -{ - fixture->model = gtk_tree_view_get_model (fixture->tree_view); - - if (GTK_IS_TREE_MODEL_FILTER (fixture->model)) - { - GtkTreeModelFilter *filter = GTK_TREE_MODEL_FILTER (fixture->model); - fixture->store = GTK_LIST_STORE (gtk_tree_model_filter_get_model (filter)); - } - else - { - fixture->store = GTK_LIST_STORE (fixture->model); - } -} - -static void -test_setup (TestFixture *fixture, - gconstpointer data) -{ - fixture->engine = testing_engine_new (); - fixture->tree_view = GTK_TREE_VIEW (peas_gtk_plugin_manager_view_new (NULL)); - fixture->view = PEAS_GTK_PLUGIN_MANAGER_VIEW (fixture->tree_view); - fixture->selection = gtk_tree_view_get_selection (fixture->tree_view); - - g_signal_connect (fixture->view, - "notify::model", - G_CALLBACK (notify_model_cb), - fixture); - - /* Set the model and store */ - g_object_notify (G_OBJECT (fixture->tree_view), "model"); - - g_object_ref_sink (fixture->tree_view); -} - -static void -test_teardown (TestFixture *fixture, - gconstpointer data) -{ - gtk_widget_destroy (GTK_WIDGET (fixture->tree_view)); - g_object_unref (fixture->tree_view); - - testing_engine_free (fixture->engine); -} - -static void -test_runner (TestFixture *fixture, - gconstpointer data) -{ - ((void (*) (TestFixture *)) data) (fixture); -} - -/* Based on code from peas-gtk-manager-view.h */ -static void -convert_iter_to_child_iter (PeasGtkPluginManagerView *view, - GtkTreeIter *iter) -{ - GtkTreeModel *model; - GtkTreeIter child_iter; - - if (peas_gtk_plugin_manager_view_get_show_builtin (view)) - return; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (view)); - - gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (model), - &child_iter, iter); - - *iter = child_iter; -} - -static gboolean -model_has_builtin (TestFixture *fixture) -{ - GtkTreeIter iter; - gboolean found = FALSE; - - if (gtk_tree_model_get_iter_first (fixture->model, &iter)) - { - do - { - if (peas_plugin_info_is_builtin (testing_get_plugin_info_for_iter (fixture->view, &iter))) - found = TRUE; - } - while (!found && gtk_tree_model_iter_next (fixture->model, &iter)); - } - - return found; -} - -static void -test_gtk_plugin_manager_view_selection (TestFixture *fixture) -{ - GtkTreeIter iter; - PeasPluginInfo *info; - - info = peas_gtk_plugin_manager_view_get_selected_plugin (fixture->view); - g_assert (info == NULL); - - g_assert (gtk_tree_model_get_iter_first (fixture->model, &iter)); - gtk_tree_selection_select_iter (fixture->selection, &iter); - - info = peas_gtk_plugin_manager_view_get_selected_plugin (fixture->view); - g_assert (info != NULL); -} - -static void -test_gtk_plugin_manager_view_show_builtin (TestFixture *fixture) -{ - peas_gtk_plugin_manager_view_set_show_builtin (fixture->view, TRUE); - - g_assert (model_has_builtin (fixture)); -} - -static void -test_gtk_plugin_manager_view_hide_builtin (TestFixture *fixture) -{ - /* Should this be here given its already the default? */ - peas_gtk_plugin_manager_view_set_show_builtin (fixture->view, FALSE); - - g_assert (!model_has_builtin (fixture)); -} - -static void -test_gtk_plugin_manager_view_reload (TestFixture *fixture) -{ - GtkTreeIter iter; - PeasPluginInfo *removed_info, *selected_info; - - g_assert (gtk_tree_model_get_iter_first (fixture->model, &iter)); - gtk_tree_selection_select_iter (fixture->selection, &iter); - removed_info = testing_get_plugin_info_for_iter (fixture->view, &iter); - - convert_iter_to_child_iter (fixture->view, &iter); - gtk_list_store_remove (fixture->store, &iter); - - g_assert (gtk_tree_model_get_iter_first (fixture->model, &iter)); - gtk_tree_selection_select_iter (fixture->selection, &iter); - selected_info = testing_get_plugin_info_for_iter (fixture->view, &iter); - - g_object_notify (G_OBJECT (fixture->engine), "plugin-list"); - - g_assert (gtk_tree_selection_get_selected (fixture->selection, NULL, &iter)); - g_assert (testing_get_plugin_info_for_iter (fixture->view, &iter) == selected_info); - - g_assert (gtk_tree_model_get_iter_first (fixture->model, &iter)); - g_assert (testing_get_plugin_info_for_iter (fixture->view, &iter) == removed_info); -} - -static void -test_gtk_plugin_manager_view_enable_plugin (TestFixture *fixture) -{ - GtkTreeIter iter; - GtkTreePath *path; - GtkTreeViewColumn *column; - PeasPluginInfo *info; - - g_assert (gtk_tree_model_get_iter_first (fixture->model, &iter)); - info = testing_get_plugin_info_for_iter (fixture->view, &iter); - path = gtk_tree_model_get_path (fixture->model, &iter); - column = gtk_tree_view_get_column (fixture->tree_view, 0); - - g_assert (!peas_plugin_info_is_loaded (info)); - gtk_tree_view_row_activated (fixture->tree_view, path, column); - g_assert (peas_plugin_info_is_loaded (info)); - - gtk_tree_path_free (path); -} - -static void -test_gtk_plugin_manager_view_enable_builtin_plugin (TestFixture *fixture) -{ - GtkTreeIter iter; - GtkTreePath *path; - GtkTreeViewColumn *column; - PeasPluginInfo *info; - - peas_gtk_plugin_manager_view_set_show_builtin (fixture->view, TRUE); - - info = peas_engine_get_plugin_info (fixture->engine, "builtin"); - - testing_get_iter_for_plugin_info (fixture->view, info, &iter); - - path = gtk_tree_model_get_path (fixture->model, &iter); - column = gtk_tree_view_get_column (fixture->tree_view, 0); - - g_assert (!peas_plugin_info_is_loaded (info)); - gtk_tree_view_row_activated (fixture->tree_view, path, column); - g_assert (!peas_plugin_info_is_loaded (info)); - - gtk_tree_path_free (path); -} - -int -main (int argc, - char **argv) -{ - testing_init (&argc, &argv); - -#define TEST(path, ftest) \ - g_test_add ("/gtk/plugin-manager-view/" path, TestFixture, \ - (gpointer) test_gtk_plugin_manager_view_##ftest, \ - test_setup, test_runner, test_teardown) - - TEST ("selection", selection); - - TEST ("show-builtin", show_builtin); - TEST ("hide-builtin", hide_builtin); - - TEST ("reload", reload); - - TEST ("enable-plugin", enable_plugin); - TEST ("enable-builtin-plugin", enable_builtin_plugin); - -#undef TEST - - return testing_run_tests (); -} diff --git a/tests/libpeas-gtk/plugin-manager.c b/tests/libpeas-gtk/plugin-manager.c deleted file mode 100644 index f2e9147..0000000 --- a/tests/libpeas-gtk/plugin-manager.c +++ /dev/null @@ -1,416 +0,0 @@ -/* - * plugin-manager.c - * This file is part of libpeas - * - * Copyright (C) 2010 - Garrett Regier - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <gtk/gtk.h> - -#include <libpeas/peas.h> -#include <libpeas/peas-i18n-priv.h> -#include <libpeas-gtk/peas-gtk.h> - -#ifdef G_OS_WIN32 -#define WIN32_LEAN_AND_MEAN -#include <windows.h> -#endif - -#include "testing/testing.h" - -typedef struct _TestFixture TestFixture; - -struct _TestFixture { - PeasEngine *engine; - GtkWidget *window; - PeasGtkPluginManager *manager; - PeasGtkPluginManagerView *view; - GtkTreeSelection *selection; - GtkTreeModel *model; - GtkWidget *about_button; - GtkWidget *configure_button; -}; - -static void -notify_model_cb (GtkTreeView *view, - GParamSpec *pspec, - TestFixture *fixture) -{ - fixture->model = gtk_tree_view_get_model (GTK_TREE_VIEW (fixture->view)); -} - -static void -test_setup (TestFixture *fixture, - gconstpointer data) -{ - fixture->engine = testing_engine_new (); - fixture->window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - fixture->manager = PEAS_GTK_PLUGIN_MANAGER (peas_gtk_plugin_manager_new (NULL)); - fixture->view = PEAS_GTK_PLUGIN_MANAGER_VIEW (peas_gtk_plugin_manager_get_view (fixture->manager)); - fixture->selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (fixture->view)); - - gtk_container_add (GTK_CONTAINER (fixture->window), - GTK_WIDGET (fixture->manager)); - - g_signal_connect (fixture->view, - "notify::model", - G_CALLBACK (notify_model_cb), - fixture); - - /* Set the model */ - g_object_notify (G_OBJECT (fixture->view), "model"); - - fixture->about_button = gtk_test_find_widget (fixture->window, - _("About"), - GTK_TYPE_BUTTON); - g_assert (GTK_IS_BUTTON (fixture->about_button)); - - fixture->configure_button = gtk_test_find_widget (fixture->window, - _("Preferences"), - GTK_TYPE_BUTTON); - g_assert (GTK_IS_BUTTON (fixture->configure_button)); -} - -static void -test_teardown (TestFixture *fixture, - gconstpointer data) -{ - gtk_widget_destroy (GTK_WIDGET (fixture->window)); - - testing_engine_free (fixture->engine); -} - -static void -test_runner (TestFixture *fixture, - gconstpointer data) -{ - ((void (*) (TestFixture *)) data) (fixture); -} - -static GtkWidget * -find_window_by_title (GtkWindow *window, - const gchar *title) -{ - GtkWindowGroup *group; - GList *windows; - GList *l; - GtkWidget *found_window = NULL; - - group = gtk_window_get_group (window); - windows = gtk_window_group_list_windows (group); - - for (l = windows; l != NULL; l = l->next) - { - if (g_strcmp0 (gtk_window_get_title (l->data), title) == 0) - { - found_window = l->data; - break; - } - } - - g_list_free (windows); - - g_assert (GTK_IS_WINDOW (found_window)); - - return found_window; -} - -static void -test_gtk_plugin_manager_about_button_sensitivity (TestFixture *fixture) -{ - GtkTreeIter iter; - PeasPluginInfo *info; - - testing_util_push_log_hook ("Could not find plugin 'does-not-exist'*"); - - /* Must come first otherwise the first iter may - * be after a revealed builtin plugin - */ - peas_gtk_plugin_manager_view_set_show_builtin (fixture->view, TRUE); - - /* Causes the plugin to become unavailable */ - info = peas_engine_get_plugin_info (fixture->engine, "unavailable"); - peas_engine_load_plugin (fixture->engine, info); - - g_assert (gtk_tree_model_get_iter_first (fixture->model, &iter)); - - do - { - gtk_tree_selection_select_iter (fixture->selection, &iter); - - g_assert (gtk_widget_get_sensitive (fixture->about_button)); - } - while (gtk_tree_model_iter_next (fixture->model, &iter)); -} - -static void -test_gtk_plugin_manager_configure_button_sensitivity (TestFixture *fixture) -{ - GtkTreeIter iter; - PeasPluginInfo *info; - - testing_util_push_log_hook ("Could not find plugin 'does-not-exist'*"); - - /* Must come first otherwise the first iter may - * be after a revealed builtin plugin - */ - peas_gtk_plugin_manager_view_set_show_builtin (fixture->view, TRUE); - - /* So we can configure them */ - info = peas_engine_get_plugin_info (fixture->engine, "builtin-configurable"); - peas_engine_load_plugin (fixture->engine, info); - info = peas_engine_get_plugin_info (fixture->engine, "configurable"); - peas_engine_load_plugin (fixture->engine, info); - - /* Causes the plugin to become unavailable */ - info = peas_engine_get_plugin_info (fixture->engine, "unavailable"); - peas_engine_load_plugin (fixture->engine, info); - - g_assert (gtk_tree_model_get_iter_first (fixture->model, &iter)); - - do - { - gboolean sensitive; - - gtk_tree_selection_select_iter (fixture->selection, &iter); - - info = testing_get_plugin_info_for_iter (fixture->view, &iter); - - if (!peas_plugin_info_is_loaded (info)) - { - sensitive = FALSE; - } - else - { - sensitive = peas_engine_provides_extension (fixture->engine, info, - PEAS_GTK_TYPE_CONFIGURABLE); - } - - g_assert_cmpint (gtk_widget_get_sensitive (fixture->configure_button), - ==, sensitive); - } - while (gtk_tree_model_iter_next (fixture->model, &iter)); -} - -static void -test_gtk_plugin_manager_plugin_loaded (TestFixture *fixture) -{ - GtkTreeIter iter; - PeasPluginInfo *info; - - info = peas_engine_get_plugin_info (fixture->engine, "configurable"); - testing_get_iter_for_plugin_info (fixture->view, info, &iter); - - gtk_tree_selection_select_iter (fixture->selection, &iter); - - g_assert (!gtk_widget_is_sensitive (fixture->configure_button)); - peas_engine_load_plugin (fixture->engine, info); - g_assert (gtk_widget_is_sensitive (fixture->configure_button)); -} - -static void -test_gtk_plugin_manager_plugin_unloaded (TestFixture *fixture) -{ - GtkTreeIter iter; - PeasPluginInfo *info; - - test_gtk_plugin_manager_plugin_loaded (fixture); - - info = peas_engine_get_plugin_info (fixture->engine, "configurable"); - testing_get_iter_for_plugin_info (fixture->view, info, &iter); - - g_assert (gtk_widget_is_sensitive (fixture->configure_button)); - peas_engine_unload_plugin (fixture->engine, info); - g_assert (!gtk_widget_is_sensitive (fixture->configure_button)); -} - -static void -test_gtk_plugin_manager_about_dialog (TestFixture *fixture) -{ - gint i; - GtkTreeIter iter; - GtkWidget *window; - PeasPluginInfo *info; - const gchar **authors_plugin; - const gchar * const *authors_dialog; - - /* Full Info is a builtin plugin */ - peas_gtk_plugin_manager_view_set_show_builtin (fixture->view, TRUE); - - info = peas_engine_get_plugin_info (fixture->engine, "full-info"); - - testing_get_iter_for_plugin_info (fixture->view, info, &iter); - gtk_tree_selection_select_iter (fixture->selection, &iter); - - /* Must be first so we the window is added to the window group */ - gtk_button_clicked (GTK_BUTTON (fixture->about_button)); - - window = find_window_by_title (GTK_WINDOW (fixture->window), - "About Full Info"); - g_assert (GTK_IS_ABOUT_DIALOG (window)); - - - g_assert_cmpstr (gtk_about_dialog_get_program_name (GTK_ABOUT_DIALOG (window)), - ==, peas_plugin_info_get_name (info)); - g_assert_cmpstr (gtk_about_dialog_get_copyright (GTK_ABOUT_DIALOG (window)), - ==, peas_plugin_info_get_copyright (info)); - g_assert_cmpstr (gtk_about_dialog_get_website (GTK_ABOUT_DIALOG (window)), - ==, peas_plugin_info_get_website (info)); - g_assert_cmpstr (gtk_about_dialog_get_logo_icon_name (GTK_ABOUT_DIALOG (window)), - ==, peas_plugin_info_get_icon_name (info)); - g_assert_cmpstr (gtk_about_dialog_get_version (GTK_ABOUT_DIALOG (window)), - ==, peas_plugin_info_get_version (info)); - g_assert_cmpstr (gtk_about_dialog_get_comments (GTK_ABOUT_DIALOG (window)), - ==, peas_plugin_info_get_description (info)); - - authors_plugin = peas_plugin_info_get_authors (info); - authors_dialog = gtk_about_dialog_get_authors (GTK_ABOUT_DIALOG (window)); - - for (i = 0; authors_plugin[i] == NULL && authors_dialog[i] == NULL; ++i) - g_assert_cmpstr (authors_plugin[i], ==, authors_dialog[i]); - - gtk_widget_destroy (window); -} - -static void -test_gtk_plugin_manager_configure_dialog (TestFixture *fixture) -{ - GtkTreeIter iter; - GtkWidget *window; - PeasPluginInfo *info; - GList *list; - GList *list_it; - GtkWidget *content; - GtkWidget *label = NULL; - GtkWidget *close_button = NULL; - GtkWidget *help_button = NULL; - - info = peas_engine_get_plugin_info (fixture->engine, "configurable"); - - peas_engine_load_plugin (fixture->engine, info); - - testing_get_iter_for_plugin_info (fixture->view, info, &iter); - gtk_tree_selection_select_iter (fixture->selection, &iter); - - /* Must be first so the window is added to the window group */ - gtk_button_clicked (GTK_BUTTON (fixture->configure_button)); - - window = find_window_by_title (GTK_WINDOW (fixture->window), "Configurable"); - g_assert (GTK_IS_DIALOG (window)); - - content = gtk_dialog_get_content_area (GTK_DIALOG (window)); - list = gtk_container_get_children (GTK_CONTAINER (content)); - - for (list_it = list; list_it != NULL; list_it = list_it->next) - { - if (GTK_IS_LABEL (list_it->data)) - { - const gchar *text = gtk_label_get_text (GTK_LABEL (list_it->data)); - - if (g_strcmp0 (text, "Hello, World!") == 0) - label = GTK_WIDGET (list_it->data); - } - } - - g_assert (label != NULL); - - g_list_free (list); - - - close_button = gtk_dialog_get_widget_for_response (GTK_DIALOG (window), - GTK_RESPONSE_CLOSE); - g_assert (close_button != NULL); - - help_button = gtk_dialog_get_widget_for_response (GTK_DIALOG (window), - GTK_RESPONSE_HELP); - g_assert (help_button != NULL); - - gtk_widget_destroy (window); -} - -static void -test_gtk_plugin_manager_gtkbuilder (void) -{ - GtkBuilder *builder; - GError *error = NULL; - PeasGtkPluginManager *manager; - PeasGtkPluginManagerView *view; - static const gchar *gtkbuilder_string = - "<?xml version='1.0' encoding='UTF-8'?>\n" - "<interface>\n" - "<object class='PeasGtkPluginManagerView' id='view'>\n" - " <property name='show-builtin'>True</property>\n" - "</object>\n" - "<object class='PeasGtkPluginManager' id='manager'>\n" - " <property name='view'>view</property>\n" - "</object>\n" - "</interface>"; - - builder = gtk_builder_new (); - - gtk_builder_add_from_string (builder, gtkbuilder_string, -1, &error); - g_assert_no_error (error); - - manager = PEAS_GTK_PLUGIN_MANAGER (gtk_builder_get_object (builder, "manager")); - g_assert (PEAS_GTK_IS_PLUGIN_MANAGER (manager)); - - view = PEAS_GTK_PLUGIN_MANAGER_VIEW (peas_gtk_plugin_manager_get_view (manager)); - - g_assert (G_OBJECT (view) == gtk_builder_get_object (builder, "view")); - - g_assert (peas_gtk_plugin_manager_view_get_show_builtin (view)); - - /* Freeing the builder will free the objects */ - g_object_unref (builder); -} - -int -main (int argc, - char **argv) -{ - testing_init (&argc, &argv); - -#ifdef G_OS_WIN32 - SetThreadLocale (MAKELCID (MAKELANGID (LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT)); -#endif - -#define TEST(path, ftest) \ - g_test_add ("/gtk/plugin-manager/" path, TestFixture, \ - (gpointer) test_gtk_plugin_manager_##ftest, \ - test_setup, test_runner, test_teardown) - -#define TEST_FUNC(path, ftest) \ - g_test_add_func ("/gtk/plugin-manager/" path, \ - test_gtk_plugin_manager_##ftest) - - TEST ("about-button-sensitivity", about_button_sensitivity); - TEST ("configure-button-sensitivity", configure_button_sensitivity); - - TEST ("plugin-loaded", plugin_loaded); - TEST ("plugin-unloaded", plugin_unloaded); - - TEST ("about-dialog", about_dialog); - TEST ("configure-dialog", configure_dialog); - - TEST_FUNC ("gtkbuilder", gtkbuilder); - -#undef TEST - - return testing_run_tests (); -} diff --git a/tests/libpeas-gtk/plugins/builtin-configurable/builtin-configurable.c b/tests/libpeas-gtk/plugins/builtin-configurable/builtin-configurable.c deleted file mode 100644 index 3bb83e6..0000000 --- a/tests/libpeas-gtk/plugins/builtin-configurable/builtin-configurable.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * builtin-configurable.c - * This file is part of libpeas - * - * Copyright (C) 2010 - Garrett Regier - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <glib.h> -#include <glib-object.h> -#include <gmodule.h> - -#include <libpeas/peas.h> -#include <libpeas-gtk/peas-gtk.h> - -#include "builtin-configurable.h" - -static void peas_gtk_configurable_iface_init (PeasGtkConfigurableInterface *iface); - -G_DEFINE_DYNAMIC_TYPE_EXTENDED (TestingBuiltinConfigurable, - testing_builtin_configurable, - PEAS_TYPE_EXTENSION_BASE, - 0, - G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_GTK_TYPE_CONFIGURABLE, - peas_gtk_configurable_iface_init)) - -static void -testing_builtin_configurable_init (TestingBuiltinConfigurable *configurable) -{ -} - -static void -testing_builtin_configurable_class_init (TestingBuiltinConfigurableClass *klass) -{ -} - -static GtkWidget * -testing_builtin_create_configure_widget (PeasGtkConfigurable *configurable) -{ - return gtk_label_new ("Hello, World!"); -} - -static void -peas_gtk_configurable_iface_init (PeasGtkConfigurableInterface *iface) -{ - iface->create_configure_widget = testing_builtin_create_configure_widget; -} - -static void -testing_builtin_configurable_class_finalize (TestingBuiltinConfigurableClass *klass) -{ -} - -G_MODULE_EXPORT void -peas_register_types (PeasObjectModule *module) -{ - testing_builtin_configurable_register_type (G_TYPE_MODULE (module)); - - peas_object_module_register_extension_type (module, - PEAS_GTK_TYPE_CONFIGURABLE, - TESTING_TYPE_BUILTIN_CONFIGURABLE); -} diff --git a/tests/libpeas-gtk/plugins/builtin-configurable/builtin-configurable.h b/tests/libpeas-gtk/plugins/builtin-configurable/builtin-configurable.h deleted file mode 100644 index e41871b..0000000 --- a/tests/libpeas-gtk/plugins/builtin-configurable/builtin-configurable.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * builtin-configurable.h - * This file is part of libpeas - * - * Copyright (C) 2010 - Garrett Regier - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __TESTING_BUILTIN_CONFIGURABLE_H__ -#define __TESTING_BUILTIN_CONFIGURABLE_H__ - -#include <libpeas/peas.h> - -G_BEGIN_DECLS - -#define TESTING_TYPE_BUILTIN_CONFIGURABLE (testing_builtin_configurable_get_type ()) -#define TESTING_BUILTIN_CONFIGURABLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TESTING_TYPE_BUILTIN_CONFIGURABLE, TestingBuiltinConfigurable)) -#define TESTING_BUILTIN_CONFIGURABLE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), TESTING_TYPE_BUILTIN_CONFIGURABLE, TestingBuiltinConfigurable)) -#define TESTING_IS_BUILTIN_CONFIGURABLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TESTING_TYPE_BUILTIN_CONFIGURABLE)) -#define TESTING_IS_BUILTIN_CONFIGURABLE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TESTING_TYPE_BUILTIN_CONFIGURABLE)) -#define TESTING_BUILTIN_CONFIGURABLE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TESTING_TYPE_BUILTIN_CONFIGURABLE, TestingBuiltinConfigurableClass)) - -typedef struct _TestingBuiltinConfigurable TestingBuiltinConfigurable; -typedef struct _TestingBuiltinConfigurableClass TestingBuiltinConfigurableClass; - -struct _TestingBuiltinConfigurable { - PeasExtensionBase parent_instance; -}; - -struct _TestingBuiltinConfigurableClass { - PeasExtensionBaseClass parent_class; -}; - -GType testing_builtin_configurable_get_type (void) G_GNUC_CONST; -G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module); - -G_END_DECLS - -#endif /* __TESTING_BUILTIN_CONFIGURABLE_H__ */ diff --git a/tests/libpeas-gtk/plugins/builtin-configurable/builtin-configurable.plugin b/tests/libpeas-gtk/plugins/builtin-configurable/builtin-configurable.plugin deleted file mode 100644 index b6360c3..0000000 --- a/tests/libpeas-gtk/plugins/builtin-configurable/builtin-configurable.plugin +++ /dev/null @@ -1,7 +0,0 @@ -[Plugin] -Module=builtin-configurable -Name=Builtin Configurable -Description=A plugin that can be loaded, is builtin and configurable. -Authors=Garrett Regier -Copyright=Copyright © 2010 Garrett Regier -Builtin=true diff --git a/tests/libpeas-gtk/plugins/builtin-configurable/meson.build b/tests/libpeas-gtk/plugins/builtin-configurable/meson.build deleted file mode 100644 index 4ce8c6f..0000000 --- a/tests/libpeas-gtk/plugins/builtin-configurable/meson.build +++ /dev/null @@ -1,37 +0,0 @@ -libbuiltin_configurable_name = 'builtin-configurable' - -libbuiltin_configurable_public_h = [ - 'builtin-configurable.h', -] - -libbuiltin_configurable_c = [ - 'builtin-configurable.c', -] - -libbuiltin_configurable_plugin_data = [ - 'builtin-configurable.plugin', -] - -libbuiltin_configurable_deps = [ - glib_dep, - gobject_dep, - gmodule_dep, - libpeas_dep, - libpeas_gtk_dep, -] - -libbuiltin_configurable_lib = shared_library( - libbuiltin_configurable_name, - libbuiltin_configurable_c, - include_directories: rootdir, - dependencies: libbuiltin_configurable_deps, - install: false, -) - -custom_target( - 'lib@0@-data'.format(libbuiltin_configurable_name), - input: libbuiltin_configurable_plugin_data, - output: libbuiltin_configurable_plugin_data, - command: [copyfile_script, '@INPUT@', '@OUTDIR@'], - build_by_default: true, -) diff --git a/tests/libpeas-gtk/plugins/configurable/configurable-plugin.c b/tests/libpeas-gtk/plugins/configurable/configurable-plugin.c deleted file mode 100644 index f56180e..0000000 --- a/tests/libpeas-gtk/plugins/configurable/configurable-plugin.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * configurable-plugin.c - * This file is part of libpeas - * - * Copyright (C) 2010 - Garrett Regier - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <glib.h> -#include <glib-object.h> -#include <gmodule.h> - -#include <libpeas/peas.h> -#include <libpeas-gtk/peas-gtk.h> - -#include "configurable-plugin.h" - -static void peas_gtk_configurable_iface_init (PeasGtkConfigurableInterface *iface); - -G_DEFINE_DYNAMIC_TYPE_EXTENDED (TestingConfigurablePlugin, - testing_configurable_plugin, - PEAS_TYPE_EXTENSION_BASE, - 0, - G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_GTK_TYPE_CONFIGURABLE, - peas_gtk_configurable_iface_init)) - -static void -testing_configurable_plugin_init (TestingConfigurablePlugin *configurable) -{ -} - -static void -testing_configurable_plugin_class_init (TestingConfigurablePluginClass *klass) -{ -} - -static GtkWidget * -testing_configurable_plugin_create_configure_widget (PeasGtkConfigurable *configurable) -{ - return gtk_label_new ("Hello, World!"); -} - -static void -peas_gtk_configurable_iface_init (PeasGtkConfigurableInterface *iface) -{ - iface->create_configure_widget = testing_configurable_plugin_create_configure_widget; -} - -static void -testing_configurable_plugin_class_finalize (TestingConfigurablePluginClass *klass) -{ -} - -G_MODULE_EXPORT void -peas_register_types (PeasObjectModule *module) -{ - testing_configurable_plugin_register_type (G_TYPE_MODULE (module)); - - peas_object_module_register_extension_type (module, - PEAS_GTK_TYPE_CONFIGURABLE, - TESTING_TYPE_CONFIGURABLE_PLUGIN); -} diff --git a/tests/libpeas-gtk/plugins/configurable/configurable-plugin.h b/tests/libpeas-gtk/plugins/configurable/configurable-plugin.h deleted file mode 100644 index a999073..0000000 --- a/tests/libpeas-gtk/plugins/configurable/configurable-plugin.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * configurable-plugin.h - * This file is part of libpeas - * - * Copyright (C) 2010 - Garrett Regier - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __TESTING_CONFIGURABLE_PLUGIN_H__ -#define __TESTING_CONFIGURABLE_PLUGIN_H__ - -#include <libpeas/peas.h> - -G_BEGIN_DECLS - -#define TESTING_TYPE_CONFIGURABLE_PLUGIN (testing_configurable_plugin_get_type ()) -#define TESTING_CONFIGURABLE_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TESTING_TYPE_CONFIGURABLE_PLUGIN, TestingConfigurablePlugin)) -#define TESTING_CONFIGURABLE_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), TESTING_TYPE_CONFIGURABLE_PLUGIN, TestingConfigurablePlugin)) -#define TESTING_IS_CONFIGURABLE_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TESTING_TYPE_CONFIGURABLE_PLUGIN)) -#define TESTING_IS_CONFIGURABLE_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TESTING_TYPE_CONFIGURABLE_PLUGIN)) -#define TESTING_CONFIGURABLE_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TESTING_TYPE_CONFIGURABLE_PLUGIN, TestingConfigurablePluginClass)) - -typedef struct _TestingConfigurablePlugin TestingConfigurablePlugin; -typedef struct _TestingConfigurablePluginClass TestingConfigurablePluginClass; - -struct _TestingConfigurablePlugin { - PeasExtensionBase parent_instance; -}; - -struct _TestingConfigurablePluginClass { - PeasExtensionBaseClass parent_class; -}; - -GType testing_configurable_plugin_get_type (void) G_GNUC_CONST; -G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module); - -G_END_DECLS - -#endif /* __TESTING_CONFIGURABLE_PLUGIN_H__ */ diff --git a/tests/libpeas-gtk/plugins/configurable/configurable.plugin b/tests/libpeas-gtk/plugins/configurable/configurable.plugin deleted file mode 100644 index 6df52e3..0000000 --- a/tests/libpeas-gtk/plugins/configurable/configurable.plugin +++ /dev/null @@ -1,7 +0,0 @@ -[Plugin] -Module=configurable -Name=Configurable -Description=A plugin that can be loaded and configured. -Authors=Garrett Regier -Copyright=Copyright © 2010 Garrett Regier -Help=This is required to test that the Help button is enabled. diff --git a/tests/libpeas-gtk/plugins/configurable/meson.build b/tests/libpeas-gtk/plugins/configurable/meson.build deleted file mode 100644 index 9c8f885..0000000 --- a/tests/libpeas-gtk/plugins/configurable/meson.build +++ /dev/null @@ -1,37 +0,0 @@ -libconfigurable_name = 'configurable' - -libconfigurable_public_h = [ - 'configurable-plugin.h', -] - -libconfigurable_c = [ - 'configurable-plugin.c', -] - -libconfigurable_plugin_data = [ - 'configurable.plugin', -] - -libconfigurable_deps = [ - glib_dep, - gobject_dep, - gmodule_dep, - libpeas_dep, - libpeas_gtk_dep, -] - -libconfigurable_lib = shared_library( - libconfigurable_name, - libconfigurable_c, - include_directories: rootdir, - dependencies: libconfigurable_deps, - install: false, -) - -custom_target( - 'lib@0@-data'.format(libconfigurable_name), - input: libconfigurable_plugin_data, - output: libconfigurable_plugin_data, - command: [copyfile_script, '@INPUT@', '@OUTDIR@'], - build_by_default: true, -) diff --git a/tests/libpeas-gtk/plugins/hidden.plugin b/tests/libpeas-gtk/plugins/hidden.plugin deleted file mode 100644 index 639aa69..0000000 --- a/tests/libpeas-gtk/plugins/hidden.plugin +++ /dev/null @@ -1,7 +0,0 @@ -[Plugin] -Module=hidden -Name=Hidden -Description=A plugin that is hidden. -Authors=Garrett Regier -Copyright=Copyright © 2011 Garrett Regier -Hidden=true diff --git a/tests/libpeas-gtk/plugins/invalid-custom-icon.plugin b/tests/libpeas-gtk/plugins/invalid-custom-icon.plugin deleted file mode 100644 index 1ff3e00..0000000 --- a/tests/libpeas-gtk/plugins/invalid-custom-icon.plugin +++ /dev/null @@ -1,7 +0,0 @@ -[Plugin] -Module=invalid-custom-icon -Name=Invalid Custom Icon -Description=A plugin that has an invalid custom icon. -Icon=does-not-exist.png -Authors=Garrett Regier -Copyright=Copyright © 2010 Garrett Regier diff --git a/tests/libpeas-gtk/plugins/invalid-stock-icon.plugin b/tests/libpeas-gtk/plugins/invalid-stock-icon.plugin deleted file mode 100644 index 4b4f3a9..0000000 --- a/tests/libpeas-gtk/plugins/invalid-stock-icon.plugin +++ /dev/null @@ -1,7 +0,0 @@ -[Plugin] -Module=invalid-stock-icon -Name=Invalid Stock Icon -Description=A plugin that has an invalid stock icon. -Icon=does-not-exist -Authors=Garrett Regier -Copyright=Copyright © 2010 Garrett Regier diff --git a/tests/libpeas-gtk/plugins/meson.build b/tests/libpeas-gtk/plugins/meson.build deleted file mode 100644 index be1c704..0000000 --- a/tests/libpeas-gtk/plugins/meson.build +++ /dev/null @@ -1,18 +0,0 @@ -libpeas_gtk_plugins_data = [ - 'hidden.plugin', - 'invalid-custom-icon.plugin', - 'invalid-stock-icon.plugin', - 'valid-stock-icon.plugin', -] - -custom_target( - 'libpeas-gtk-test-data', - input: libpeas_gtk_plugins_data, - output: libpeas_gtk_plugins_data, - command: [copyfile_script, '@INPUT@', '@OUTDIR@'], - build_by_default: true, -) - -subdir('builtin-configurable') -subdir('configurable') -subdir('valid-custom-icon') diff --git a/tests/libpeas-gtk/plugins/valid-custom-icon/exists.png b/tests/libpeas-gtk/plugins/valid-custom-icon/exists.png Binary files differdeleted file mode 100644 index 0476658..0000000 --- a/tests/libpeas-gtk/plugins/valid-custom-icon/exists.png +++ /dev/null diff --git a/tests/libpeas-gtk/plugins/valid-custom-icon/meson.build b/tests/libpeas-gtk/plugins/valid-custom-icon/meson.build deleted file mode 100644 index e1aac3b..0000000 --- a/tests/libpeas-gtk/plugins/valid-custom-icon/meson.build +++ /dev/null @@ -1,14 +0,0 @@ -valid_custom_icon_name = 'valid-custom-icon' - -valid_custom_icon_plugin_data = [ - 'exists.png', - 'valid-custom-icon.plugin', -] - -custom_target( - '@0@-data'.format(valid_custom_icon_name), - input: valid_custom_icon_plugin_data, - output: valid_custom_icon_plugin_data, - command: [copyfile_script, '@INPUT@', '@OUTDIR@'], - build_by_default: true, -) diff --git a/tests/libpeas-gtk/plugins/valid-custom-icon/valid-custom-icon.plugin b/tests/libpeas-gtk/plugins/valid-custom-icon/valid-custom-icon.plugin deleted file mode 100644 index eaffdae..0000000 --- a/tests/libpeas-gtk/plugins/valid-custom-icon/valid-custom-icon.plugin +++ /dev/null @@ -1,7 +0,0 @@ -[Plugin] -Module=valid-custom-icon -Name=Valid Custom Icon -Description=A plugin that has a valid custom icon. -Icon=exists.png -Authors=Garrett Regier -Copyright=Copyright © 2010 Garrett Regier diff --git a/tests/libpeas-gtk/plugins/valid-stock-icon.plugin b/tests/libpeas-gtk/plugins/valid-stock-icon.plugin deleted file mode 100644 index 027ef5f..0000000 --- a/tests/libpeas-gtk/plugins/valid-stock-icon.plugin +++ /dev/null @@ -1,7 +0,0 @@ -[Plugin] -Module=valid-stock-icon -Name=Valid Stock Icon -Description=A plugin that has a valid stock icon. -Icon=gtk-unindent -Authors=Garrett Regier -Copyright=Copyright © 2010 Garrett Regier diff --git a/tests/libpeas-gtk/testing/meson.build b/tests/libpeas-gtk/testing/meson.build deleted file mode 100644 index 646f42d..0000000 --- a/tests/libpeas-gtk/testing/meson.build +++ /dev/null @@ -1,39 +0,0 @@ -libpeas_gtk_testing_name = 'libpeas-gtk-testing' -libpeas_gtk_testing_string = '@0@-@1@'.format(libpeas_gtk_testing_name, api_version) - -libpeas_gtk_testing_public_h = [ - 'testing.h', -] - -libpeas_gtk_testing_c = [ - 'testing.c', -] - -libpeas_gtk_testing_deps = [ - glib_dep, - introspection_dep, - libpeas_dep, - libpeas_gtk_dep, - libtesting_util_dep, -] - -libpeas_gtk_testing_c_args = [ - '-DHAVE_CONFIG_H', - '-DBUILDDIR="@0@"'.format(builddir), - '-DSRCDIR="@0@"'.format(srcdir), -] - -libpeas_gtk_testing_lib = library( - libpeas_gtk_testing_string, - libpeas_gtk_testing_c, - include_directories: rootdir, - dependencies: libpeas_gtk_testing_deps, - c_args: libpeas_gtk_testing_c_args, - install: false, -) - -libpeas_gtk_testing_dep = declare_dependency( - link_with: libpeas_gtk_testing_lib, - include_directories: include_directories('.'), - dependencies: libpeas_gtk_testing_deps, -) diff --git a/tests/libpeas-gtk/testing/testing.c b/tests/libpeas-gtk/testing/testing.c deleted file mode 100644 index 656955d..0000000 --- a/tests/libpeas-gtk/testing/testing.c +++ /dev/null @@ -1,173 +0,0 @@ -/* - * testing.c - * This file is part of libpeas - * - * Copyright (C) 2010 - Garrett Regier - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <stdlib.h> - -#include <glib.h> -#include <girepository.h> -#include <testing-util.h> - -#include "testing.h" - -void -testing_init (gint *argc, - gchar ***argv) -{ - GError *error = NULL; - static gboolean initialized = FALSE; - - if (initialized) - return; - - /* Must set environment variables first */ - testing_util_envars (); - - gtk_test_init (argc, argv, NULL); - - /* Must be called after gtk_test_init() - * because it changed the log settings - */ - testing_util_init (); - - g_irepository_require_private (g_irepository_get_default (), - BUILDDIR "/libpeas-gtk", - "PeasGtk", "1.0", 0, &error); - g_assert_no_error (error); - - initialized = TRUE; -} - -PeasEngine * -testing_engine_new (void) -{ - PeasEngine *engine; - - engine = testing_util_engine_new (); - peas_engine_add_search_path (engine, BUILDDIR "/tests/libpeas-gtk/plugins", - SRCDIR "/tests/libpeas-gtk/plugins"); - - return engine; -} - -PeasPluginInfo * -testing_get_plugin_info_for_iter (PeasGtkPluginManagerView *view, - GtkTreeIter *iter) -{ - GtkTreeSelection *selection; - GtkTreeIter selected_iter; - gboolean had_selection; - PeasPluginInfo *info; - - /* This is annoying but the only way to get the plugin info - * is to ask the view for the info of the selected plugin - */ - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view)); - - had_selection = gtk_tree_selection_get_selected (selection, - NULL, &selected_iter); - - gtk_tree_selection_select_iter (selection, iter); - - info = peas_gtk_plugin_manager_view_get_selected_plugin (view); - - if (had_selection) - gtk_tree_selection_select_iter (selection, &selected_iter); - - return info; -} - -gboolean -testing_get_iter_for_plugin_info (PeasGtkPluginManagerView *view, - PeasPluginInfo *info, - GtkTreeIter *iter) -{ - GtkTreeModel *model; - GtkTreeIter pos_iter; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (view)); - - g_assert (gtk_tree_model_get_iter_first (model, &pos_iter)); - - do - { - if (testing_get_plugin_info_for_iter (view, &pos_iter) == info) - { - if (iter != NULL) - *iter = pos_iter; - - return TRUE; - } - } - while (gtk_tree_model_iter_next (model, &pos_iter)); - - return FALSE; -} - -static gboolean -delete_event_cb (GtkWidget *window, - GdkEvent *event, - GtkWidget *widget) -{ - gtk_main_quit (); - - return TRUE; -} - -/* This takes a gpointer for ease of debugging */ -void -testing_show_widget (gpointer widget) -{ - GtkWidget *window; - GLogFunc orig_log_handler; - - g_assert (GTK_IS_WIDGET (widget)); - - widget = gtk_widget_get_toplevel (GTK_WIDGET (widget)); - - if (gtk_widget_is_toplevel (GTK_WIDGET (widget))) - window = widget; - else - { - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (widget)); - } - - gtk_window_set_default_size (GTK_WINDOW (window), 200, 100); - - gtk_widget_show_all (window); - - g_signal_connect (window, - "delete-event", - G_CALLBACK (delete_event_cb), - widget); - - /* Do not abort if a warning occurs while running the widget */ - orig_log_handler = g_log_set_default_handler (g_log_default_handler, NULL); - - gtk_main (); - - g_log_set_default_handler (orig_log_handler, NULL); -} diff --git a/tests/libpeas-gtk/testing/testing.h b/tests/libpeas-gtk/testing/testing.h deleted file mode 100644 index 9126238..0000000 --- a/tests/libpeas-gtk/testing/testing.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * testing.h - * This file is part of libpeas - * - * Copyright (C) 2010 - Garrett Regier - * - * libpeas 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. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __TESTING_H__ -#define __TESTING_H__ - -#include <libpeas/peas.h> -#include <libpeas-gtk/peas-gtk.h> -#include <testing-util.h> - -G_BEGIN_DECLS - -PEAS_TEST_EXPORT -void testing_init (gint *argc, - gchar ***argv); - -PEAS_TEST_EXPORT -PeasEngine *testing_engine_new (void); - -PEAS_TEST_EXPORT -PeasPluginInfo *testing_get_plugin_info_for_iter (PeasGtkPluginManagerView *view, - GtkTreeIter *iter); -PEAS_TEST_EXPORT -gboolean testing_get_iter_for_plugin_info (PeasGtkPluginManagerView *view, - PeasPluginInfo *info, - GtkTreeIter *iter); - -PEAS_TEST_EXPORT -void testing_show_widget (gpointer widget); - -/* libtesting-util functions which do not need to be overridden */ -#define testing_engine_free testing_util_engine_free -#define testing_run_tests testing_util_run_tests - -G_END_DECLS - -#endif /* __TESTING_H__ */ diff --git a/tests/meson.build b/tests/meson.build index 3b2dbac..e68083e 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -6,10 +6,5 @@ test_env = [ ] subdir('testing-util') - subdir('libpeas') -if build_gtk_widgetry == true - subdir('libpeas-gtk') -endif - subdir('plugins') |