summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2018-02-17 23:14:03 -0500
committerMatthias Clasen <mclasen@redhat.com>2018-02-17 23:14:03 -0500
commit17052a2f1bda350c7b889c4414cbcb8dca870908 (patch)
tree11468a0f948241859d2559f6ed8957a5f06bc538
parentdb4895fbe52c63fdcee60a35c64a7afbb353e243 (diff)
downloadgtk+-wip/matthiasc/kill-modules.tar.gz
Stop loading moduleswip/matthiasc/kill-modules
Stop loading modules. We still support print backends and immodules, but general-purpose modules are going away.
-rw-r--r--gtk/gtk.h1
-rw-r--r--gtk/gtkmain.c34
-rw-r--r--gtk/gtkmodules.c412
-rw-r--r--gtk/gtkmodules.h54
-rw-r--r--gtk/gtkmodulesprivate.h10
-rw-r--r--gtk/gtkprintbackend.c1
-rw-r--r--gtk/gtksettings.c31
-rw-r--r--gtk/meson.build1
8 files changed, 0 insertions, 544 deletions
diff --git a/gtk/gtk.h b/gtk/gtk.h
index 3143f3f7f2..bb7fc29a4b 100644
--- a/gtk/gtk.h
+++ b/gtk/gtk.h
@@ -146,7 +146,6 @@
#include <gtk/gtkmenutoolbutton.h>
#include <gtk/gtkmessagedialog.h>
#include <gtk/gtkmodelbutton.h>
-#include <gtk/gtkmodules.h>
#include <gtk/gtkmountoperation.h>
#include <gtk/gtknativedialog.h>
#include <gtk/gtknotebook.h>
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index e8e74238ce..deb5810959 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -32,7 +32,6 @@
* Before using GTK+, you need to initialize it; initialization connects to the
* window system display, and parses some standard command line arguments. The
* gtk_init() macro initializes GTK+. gtk_init() exits the application if errors
- * occur; to avoid this, use gtk_init_check(). gtk_init_check() allows you to
* recover from a failed GTK+ initialization - you might start up your
* application in text mode instead.
*
@@ -120,8 +119,6 @@
#include "gtkdndprivate.h"
#include "gtkmain.h"
#include "gtkmenu.h"
-#include "gtkmodules.h"
-#include "gtkmodulesprivate.h"
#include "gtkprivate.h"
#include "gtkrecentmanager.h"
#include "gtksettingsprivate.h"
@@ -157,7 +154,6 @@ static const GDebugKey gtk_debug_keys[] = {
{ "tree", GTK_DEBUG_TREE },
{ "updates", GTK_DEBUG_UPDATES },
{ "keybindings", GTK_DEBUG_KEYBINDINGS },
- { "modules", GTK_DEBUG_MODULES },
{ "geometry", GTK_DEBUG_GEOMETRY },
{ "icontheme", GTK_DEBUG_ICONTHEME },
{ "printing", GTK_DEBUG_PRINTING} ,
@@ -383,8 +379,6 @@ gtk_disable_setlocale (void)
#undef gtk_init_check
#endif
-static GString *gtk_modules_string = NULL;
-
#ifdef G_OS_WIN32
static char *iso639_to_check = NULL;
@@ -559,9 +553,6 @@ do_pre_parse_initialization (void)
pre_initialized = TRUE;
- if (_gtk_module_has_mixed_deps (NULL))
- g_error ("GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported");
-
gdk_pre_parse ();
gdk_event_handler_set ((GdkEventFunc)gtk_main_do_event, NULL, NULL);
@@ -576,21 +567,6 @@ do_pre_parse_initialization (void)
}
#endif /* G_ENABLE_DEBUG */
- env_string = g_getenv ("GTK3_MODULES");
- if (env_string)
- gtk_modules_string = g_string_new (env_string);
-
- env_string = g_getenv ("GTK_MODULES");
- if (env_string)
- {
- if (gtk_modules_string)
- g_string_append_c (gtk_modules_string, G_SEARCHPATH_SEPARATOR);
- else
- gtk_modules_string = g_string_new (NULL);
-
- g_string_append (gtk_modules_string, env_string);
- }
-
env_string = g_getenv ("GTK_SLOWDOWN");
if (env_string)
{
@@ -647,16 +623,6 @@ do_post_parse_initialization (void)
gtk_initialized = TRUE;
- if (gtk_modules_string)
- {
- _gtk_modules_init (NULL, NULL, gtk_modules_string->str);
- g_string_free (gtk_modules_string, TRUE);
- }
- else
- {
- _gtk_modules_init (NULL, NULL, NULL);
- }
-
display_manager = gdk_display_manager_get ();
if (gdk_display_manager_get_default_display (display_manager) != NULL)
_gtk_accessibility_init ();
diff --git a/gtk/gtkmodules.c b/gtk/gtkmodules.c
index 4db4bc2fa8..4c73f87ab0 100644
--- a/gtk/gtkmodules.c
+++ b/gtk/gtkmodules.c
@@ -20,7 +20,6 @@
#include <string.h>
-#include "gtkmodules.h"
#include "gtksettings.h"
#include "gtkdebug.h"
#include "gtkprivate.h"
@@ -28,27 +27,6 @@
#include "gtkintl.h"
#include "gtkutilsprivate.h"
-#include <gmodule.h>
-
-typedef struct _GtkModuleInfo GtkModuleInfo;
-struct _GtkModuleInfo
-{
- GModule *module;
- gint ref_count;
- GtkModuleInitFunc init_func;
- GtkModuleDisplayInitFunc display_init_func;
- GSList *names;
-};
-
-static GSList *gtk_modules = NULL;
-
-static gboolean default_display_opened = FALSE;
-
-/* Saved argc, argv for delayed module initialization
- */
-static gint gtk_argc = 0;
-static gchar **gtk_argv = NULL;
-
static gchar **
get_module_path (void)
{
@@ -206,393 +184,3 @@ _gtk_find_module (const gchar *name,
g_strfreev (paths);
return module_name;
}
-
-static GModule *
-find_module (const gchar *name)
-{
- GModule *module;
- gchar *module_name;
-
- module_name = _gtk_find_module (name, "modules");
- if (!module_name)
- {
- /* As last resort, try loading without an absolute path (using system
- * library path)
- */
- module_name = g_module_build_path (NULL, name);
- }
-
- module = g_module_open (module_name, G_MODULE_BIND_LOCAL | G_MODULE_BIND_LAZY);
-
- if (_gtk_module_has_mixed_deps (module))
- {
- g_warning ("GTK+ module %s cannot be loaded.\n"
- "GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported.", module_name);
- g_module_close (module);
- module = NULL;
- }
-
- g_free (module_name);
-
- return module;
-}
-
-static gint
-cmp_module (GtkModuleInfo *info,
- GModule *module)
-{
- return info->module != module;
-}
-
-static gboolean
-module_is_blacklisted (const gchar *name,
- gboolean verbose)
-{
- if (g_str_equal (name, "gail") ||
- g_str_equal (name, "atk-bridge"))
- {
- if (verbose)
- g_message ("Not loading module \"%s\": The functionality is provided by GTK natively. Please try to not load it.", name);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-static GSList *
-load_module (GSList *module_list,
- const gchar *name)
-{
- GtkModuleInitFunc modinit_func;
- gpointer modinit_func_ptr;
- GtkModuleInfo *info = NULL;
- GModule *module = NULL;
- GSList *l;
- gboolean success = FALSE;
-
- if (g_module_supported ())
- {
- for (l = gtk_modules; l; l = l->next)
- {
- info = l->data;
- if (g_slist_find_custom (info->names, name,
- (GCompareFunc)strcmp))
- {
- info->ref_count++;
-
- success = TRUE;
- break;
- }
- info = NULL;
- }
-
- if (!success)
- {
- module = find_module (name);
-
- if (module)
- {
- /* Do the check this late so we only warn about existing modules,
- * not old modules that are still in the modules path. */
- if (module_is_blacklisted (name, TRUE))
- {
- modinit_func = NULL;
- success = TRUE;
- }
- else if (g_module_symbol (module, "gtk_module_init", &modinit_func_ptr))
- modinit_func = modinit_func_ptr;
- else
- modinit_func = NULL;
-
- if (!modinit_func)
- g_module_close (module);
- else
- {
- GSList *temp;
-
- success = TRUE;
- info = NULL;
-
- temp = g_slist_find_custom (gtk_modules, module,
- (GCompareFunc)cmp_module);
- if (temp != NULL)
- info = temp->data;
-
- if (!info)
- {
- info = g_new0 (GtkModuleInfo, 1);
-
- info->names = g_slist_prepend (info->names, g_strdup (name));
- info->module = module;
- info->ref_count = 1;
- info->init_func = modinit_func;
- g_module_symbol (module, "gtk_module_display_init",
- (gpointer *) &info->display_init_func);
-
- gtk_modules = g_slist_append (gtk_modules, info);
-
- /* display_init == NULL indicates a non-multihead aware module.
- * For these, we delay the call to init_func until first display is
- * opened, see default_display_notify_cb().
- * For multihead aware modules, we call init_func immediately,
- * and also call display_init_func on all opened displays.
- */
- if (default_display_opened || info->display_init_func)
- (* info->init_func) (&gtk_argc, &gtk_argv);
-
- if (info->display_init_func)
- {
- GSList *displays, *iter;
- displays = gdk_display_manager_list_displays (gdk_display_manager_get ());
- for (iter = displays; iter; iter = iter->next)
- {
- GdkDisplay *display = iter->data;
- (* info->display_init_func) (display);
- }
- g_slist_free (displays);
- }
- }
- else
- {
- GTK_NOTE (MODULES, g_message ("Module already loaded, ignoring: %s", name));
- info->names = g_slist_prepend (info->names, g_strdup (name));
- info->ref_count++;
- /* remove new reference count on module, we already have one */
- g_module_close (module);
- }
- }
- }
- }
- }
-
- if (success && info)
- {
- if (!g_slist_find (module_list, info))
- {
- module_list = g_slist_prepend (module_list, info);
- }
- }
- else
- {
- if (!module_is_blacklisted (name, FALSE))
- {
- const gchar *error = g_module_error ();
-
- g_message ("Failed to load module \"%s\"%s%s",
- name, error ? ": " : "", error ? error : "");
- }
- }
-
- return module_list;
-}
-
-
-static void
-gtk_module_info_unref (GtkModuleInfo *info)
-{
- GSList *l;
-
- info->ref_count--;
-
- if (info->ref_count == 0)
- {
- GTK_NOTE (MODULES,
- g_message ("Unloading module: %s", g_module_name (info->module)));
-
- gtk_modules = g_slist_remove (gtk_modules, info);
- g_module_close (info->module);
- for (l = info->names; l; l = l->next)
- g_free (l->data);
- g_slist_free (info->names);
- g_free (info);
- }
-}
-
-static GSList *
-load_modules (const char *module_str)
-{
- gchar **module_names;
- GSList *module_list = NULL;
- gint i;
-
- GTK_NOTE (MODULES, g_message ("Loading module list: %s", module_str));
-
- module_names = gtk_split_file_list (module_str);
- for (i = 0; module_names[i]; i++)
- module_list = load_module (module_list, module_names[i]);
-
- module_list = g_slist_reverse (module_list);
- g_strfreev (module_names);
-
- return module_list;
-}
-
-static void
-default_display_notify_cb (GdkDisplayManager *display_manager)
-{
- GSList *slist;
-
- /* Initialize non-multihead-aware modules when the
- * default display is first set to a non-NULL value.
- */
-
- if (!gdk_display_get_default () || default_display_opened)
- return;
-
- default_display_opened = TRUE;
-
- for (slist = gtk_modules; slist; slist = slist->next)
- {
- if (slist->data)
- {
- GtkModuleInfo *info = slist->data;
-
- if (!info->display_init_func)
- (* info->init_func) (&gtk_argc, &gtk_argv);
- }
- }
-}
-
-static void
-display_closed_cb (GdkDisplay *display,
- gboolean is_error)
-{
- GtkSettings *settings;
-
- settings = gtk_settings_get_for_display (display);
-
- g_object_set_data_full (G_OBJECT (settings), I_("gtk-modules"), NULL, NULL);
-}
-
-static void
-display_opened_cb (GdkDisplayManager *display_manager,
- GdkDisplay *display)
-{
- GValue value = G_VALUE_INIT;
- GSList *slist;
- GtkSettings *settings;
-
- for (slist = gtk_modules; slist; slist = slist->next)
- {
- if (slist->data)
- {
- GtkModuleInfo *info = slist->data;
-
- if (info->display_init_func)
- (* info->display_init_func) (display);
- }
- }
-
- g_value_init (&value, G_TYPE_STRING);
-
- if (gdk_display_get_setting (display, "gtk-modules", &value))
- {
- settings = gtk_settings_get_for_display (display);
- _gtk_modules_settings_changed (settings, g_value_get_string (&value));
- g_value_unset (&value);
- }
-
- /* Since closing display doesn't actually release the resources yet,
- * we have to connect to the ::closed signal.
- */
- g_signal_connect (display, "closed", G_CALLBACK (display_closed_cb), NULL);
-}
-
-void
-_gtk_modules_init (gint *argc,
- gchar ***argv,
- const gchar *gtk_modules_args)
-{
- GdkDisplayManager *display_manager;
- gint i;
-
- g_assert (gtk_argv == NULL);
-
- if (argc && argv)
- {
- /* store argc and argv for later use in mod initialization */
- gtk_argc = *argc;
- gtk_argv = g_new (gchar *, *argc + 1);
- for (i = 0; i < gtk_argc; i++)
- gtk_argv [i] = g_strdup ((*argv) [i]);
- gtk_argv [*argc] = NULL;
- }
-
- display_manager = gdk_display_manager_get ();
- default_display_opened = gdk_display_get_default () != NULL;
- g_signal_connect (display_manager, "notify::default-display",
- G_CALLBACK (default_display_notify_cb),
- NULL);
- g_signal_connect (display_manager, "display-opened",
- G_CALLBACK (display_opened_cb),
- NULL);
-
- if (gtk_modules_args)
- {
- /* Modules specified in the GTK_MODULES environment variable
- * or on the command line are always loaded, so we'll just leak
- * the refcounts.
- */
- g_slist_free (load_modules (gtk_modules_args));
- }
-}
-
-static void
-settings_destroy_notify (gpointer data)
-{
- GSList *iter, *modules = data;
-
- for (iter = modules; iter; iter = iter->next)
- {
- GtkModuleInfo *info = iter->data;
- gtk_module_info_unref (info);
- }
- g_slist_free (modules);
-}
-
-void
-_gtk_modules_settings_changed (GtkSettings *settings,
- const gchar *modules)
-{
- GSList *new_modules = NULL;
-
- GTK_NOTE (MODULES, g_message ("gtk-modules setting changed to: %s", modules));
-
- /* load/ref before unreffing existing */
- if (modules && modules[0])
- new_modules = load_modules (modules);
-
- g_object_set_data_full (G_OBJECT (settings),
- I_("gtk-modules"),
- new_modules,
- settings_destroy_notify);
-}
-
-/* Return TRUE if module_to_check causes version conflicts.
- * If module_to_check is NULL, check the main module.
- */
-gboolean
-_gtk_module_has_mixed_deps (GModule *module_to_check)
-{
- GModule *module;
- gpointer func;
- gboolean result;
-
- if (!module_to_check)
- module = g_module_open (NULL, 0);
- else
- module = module_to_check;
-
- if (g_module_symbol (module, "gtk_progress_get_type", &func))
- result = TRUE;
- else if (g_module_symbol (module, "gtk_misc_get_type", &func))
- result = TRUE;
- else
- result = FALSE;
-
- if (!module_to_check)
- g_module_close (module);
-
- return result;
-}
diff --git a/gtk/gtkmodules.h b/gtk/gtkmodules.h
deleted file mode 100644
index d851cd0f4c..0000000000
--- a/gtk/gtkmodules.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* GTK - The GIMP Toolkit
- * Copyright 1998-2002 Tim Janik, Red Hat, Inc., and others.
- * Copyright (C) 2003 Alex Graveley
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * 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, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __GTK_MODULES_H__
-#define __GTK_MODULES_H__
-
-#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
-#error "Only <gtk/gtk.h> can be included directly."
-#endif
-
-#include <gdk/gdk.h>
-
-G_BEGIN_DECLS
-
-/**
- * GtkModuleInitFunc:
- * @argc: (allow-none): GTK+ always passes %NULL for this argument
- * @argv: (allow-none) (array length=argc): GTK+ always passes %NULL for this argument
- *
- * Each GTK+ module must have a function gtk_module_init() with this prototype.
- * This function is called after loading the module.
- */
-typedef void (*GtkModuleInitFunc) (gint *argc,
- gchar ***argv);
-
-/**
- * GtkModuleDisplayInitFunc:
- * @display: an open #GdkDisplay
- *
- * A multihead-aware GTK+ module may have a gtk_module_display_init() function
- * with this prototype. GTK+ calls this function for each opened display.
- */
-typedef void (*GtkModuleDisplayInitFunc) (GdkDisplay *display);
-
-
-G_END_DECLS
-
-
-#endif /* __GTK_MODULES_H__ */
diff --git a/gtk/gtkmodulesprivate.h b/gtk/gtkmodulesprivate.h
index 11dbebfd9d..54427369f8 100644
--- a/gtk/gtkmodulesprivate.h
+++ b/gtk/gtkmodulesprivate.h
@@ -27,20 +27,10 @@
G_BEGIN_DECLS
-#include "gtksettings.h"
-
gchar * _gtk_find_module (const gchar *name,
const gchar *type);
gchar ** _gtk_get_module_path (const gchar *type);
-void _gtk_modules_init (gint *argc,
- gchar ***argv,
- const gchar *gtk_modules_args);
-void _gtk_modules_settings_changed (GtkSettings *settings,
- const gchar *modules);
-
-gboolean _gtk_module_has_mixed_deps (GModule *module);
-
G_END_DECLS
#endif /* __GTK_MODULES_PRIVATE_H__ */
diff --git a/gtk/gtkprintbackend.c b/gtk/gtkprintbackend.c
index 38bb769ee8..bd294fca0f 100644
--- a/gtk/gtkprintbackend.c
+++ b/gtk/gtkprintbackend.c
@@ -22,7 +22,6 @@
#include <gmodule.h>
#include "gtkintl.h"
-#include "gtkmodules.h"
#include "gtkmodulesprivate.h"
#include "gtkmarshalers.h"
#include "gtkprivate.h"
diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c
index 98dce9066c..67e377f1ba 100644
--- a/gtk/gtksettings.c
+++ b/gtk/gtksettings.c
@@ -22,8 +22,6 @@
#include "gtksettings.h"
-#include "gtkmodules.h"
-#include "gtkmodulesprivate.h"
#include "gtksettingsprivate.h"
#include "gtkintl.h"
#include "gtkwidget.h"
@@ -154,7 +152,6 @@ enum {
PROP_KEY_THEME_NAME,
PROP_DND_DRAG_THRESHOLD,
PROP_FONT_NAME,
- PROP_MODULES,
PROP_XFT_ANTIALIAS,
PROP_XFT_HINTING,
PROP_XFT_HINTSTYLE,
@@ -212,7 +209,6 @@ static guint settings_install_property_parser (GtkSettingsClass *class,
GParamSpec *pspec,
GtkRcPropertyParser parser);
static void settings_update_double_click (GtkSettings *settings);
-static void settings_update_modules (GtkSettings *settings);
static void settings_update_cursor_theme (GtkSettings *settings);
static void settings_update_font_options (GtkSettings *settings);
@@ -456,15 +452,6 @@ gtk_settings_class_init (GtkSettingsClass *class)
g_assert (result == PROP_FONT_NAME);
result = settings_install_property_parser (class,
- g_param_spec_string ("gtk-modules",
- P_("GTK Modules"),
- P_("List of currently active GTK modules"),
- NULL,
- GTK_PARAM_READWRITE),
- NULL);
- g_assert (result == PROP_MODULES);
-
- result = settings_install_property_parser (class,
g_param_spec_int ("gtk-xft-antialias",
P_("Xft Antialias"),
P_("Whether to antialias Xft fonts; 0=no, 1=yes, -1=default"),
@@ -1203,7 +1190,6 @@ gtk_settings_create_for_display (GdkDisplay *display)
settings_init_style (settings);
settings_update_xsettings (settings);
- settings_update_modules (settings);
settings_update_double_click (settings);
settings_update_cursor_theme (settings);
settings_update_font_options (settings);
@@ -1332,9 +1318,6 @@ gtk_settings_notify (GObject *object,
switch (property_id)
{
- case PROP_MODULES:
- settings_update_modules (settings);
- break;
case PROP_DOUBLE_CLICK_TIME:
case PROP_DOUBLE_CLICK_DISTANCE:
settings_update_double_click (settings);
@@ -2056,20 +2039,6 @@ settings_update_double_click (GtkSettings *settings)
}
static void
-settings_update_modules (GtkSettings *settings)
-{
- gchar *modules;
-
- g_object_get (settings,
- "gtk-modules", &modules,
- NULL);
-
- _gtk_modules_settings_changed (settings, modules);
-
- g_free (modules);
-}
-
-static void
settings_update_cursor_theme (GtkSettings *settings)
{
GtkSettingsPrivate *priv = settings->priv;
diff --git a/gtk/meson.build b/gtk/meson.build
index 92d4c0b434..4379956d86 100644
--- a/gtk/meson.build
+++ b/gtk/meson.build
@@ -486,7 +486,6 @@ gtk_public_headers = files([
'gtkmenutoolbutton.h',
'gtkmessagedialog.h',
'gtkmodelbutton.h',
- 'gtkmodules.h',
'gtkmountoperation.h',
'gtknativedialog.h',
'gtknotebook.h',