Commit 1209e466 authored by Jesse van den Kieboom's avatar Jesse van den Kieboom

Simplified support for OS dependent styles

parent 0dcef4fd
......@@ -429,15 +429,20 @@ VAPIGEN_CHECK([0.25.1])
if test "$os_osx" = "yes"; then
os_menus_ui=menus-osx.ui
RESOURCE_TRADITIONAL_MENUS_UI=
os_style_css=gedit-style-osx.css
else
os_menus_ui=menus-default.ui
RESOURCE_TRADITIONAL_MENUS_UI='<file preprocess="xml-stripblanks">gtk/menus-traditional.ui</file>'
fi
os_style_css=
AC_SUBST(RESOURCE_TRADITIONAL_MENUS_UI)
OS_DEPENDENT_RESOURCE_FILES='<file preprocess="xml-stripblanks">gtk/menus-traditional.ui</file>'
fi
if test "x$os_style_css" != "x"; then
OS_DEPENDENT_RESOURCE_FILES+="<file>css/gedit-style-os.css</file>"
AC_CONFIG_LINKS(gedit/resources/css/gedit-style-os.css:gedit/resources/css/$os_style_css)
fi
AC_SUBST(OS_DEPENDENT_RESOURCE_FILES)
AC_CONFIG_LINKS(gedit/resources/gtk/menus.ui:gedit/resources/gtk/$os_menus_ui)
AC_CONFIG_FILES([
......
......@@ -33,12 +33,6 @@ endif
data_convertdir = $(datadir)/GConf/gsettings
dist_data_convert_DATA = data/gedit.convert
if OS_OSX
data_geditdatadir = $(datadir)/gedit
dist_data_geditdata_DATA = \
data/osx.css
endif
EXTRA_DIST += \
$(data_desktop_in_files) \
$(data_appdata_in_files) \
......
......@@ -242,8 +242,10 @@ gedit_overrides_PYTHON = gedit/Gedit.py
endif
gedit_dist_resource_deps = \
$(filter-out gedit/resources/gtk/menus.ui,$(gedit_resource_deps)) \
gedit/resources/gtk/menus-traditional.ui
$(filter-out gedit/resources/css/gedit-style-os.css,$(filter-out gedit/resources/gtk/menus.ui,$(gedit_resource_deps))) \
gedit/resources/gtk/menus-traditional.ui \
gedit/resources/gtk/menus-default.ui \
gedit/resources/css/gedit-style-osx.css
EXTRA_DIST += \
gedit/gedit-enum-types.h.template \
......
......@@ -169,46 +169,6 @@ gedit_app_osx_set_window_title_impl (GeditApp *app,
GEDIT_APP_CLASS (gedit_app_osx_parent_class)->set_window_title (app, window, title);
}
static void
load_keybindings (void)
{
gchar *filename;
filename = g_build_filename (gedit_dirs_get_gedit_data_dir (),
"osx.css",
NULL);
if (filename != NULL)
{
GtkCssProvider *provider;
GError *error = NULL;
gedit_debug_message (DEBUG_APP, "Loading keybindings from %s\n", filename);
provider = gtk_css_provider_new ();
if (!gtk_css_provider_load_from_path (provider,
filename,
&error))
{
g_warning ("Failed to load osx keybindings from `%s':\n%s",
filename,
error->message);
g_error_free (error);
}
else
{
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_SETTINGS);
}
g_object_unref (provider);
g_free (filename);
}
}
typedef struct
{
GeditAppOSX *app;
......@@ -325,9 +285,6 @@ gedit_app_osx_startup (GApplication *application)
"win.replace",
replace_accels);
/* Load the osx specific keybinding overrides */
load_keybindings ();
app_osx = GEDIT_APP_OSX (application);
gedit_recent_configuration_init_default (&app_osx->priv->recent_config);
......
......@@ -477,6 +477,41 @@ add_accelerator (GeditApp *app,
gtk_application_set_accels_for_action (GTK_APPLICATION (app), action_name, vaccels);
}
static void
load_css_from_resource (const gchar *filename,
gboolean required)
{
GError *error = NULL;
GFile *css_file;
GtkCssProvider *provider;
gchar *resource_name;
resource_name = g_strdup_printf ("resource:///org/gnome/gedit/css/%s", filename);
css_file = g_file_new_for_uri (resource_name);
g_free (resource_name);
provider = gtk_css_provider_new ();
if (gtk_css_provider_load_from_file (provider, css_file, &error))
{
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref (provider);
}
else
{
if (required)
{
g_warning ("Could not load css provider: %s", error->message);
}
g_error_free (error);
}
g_object_unref (css_file);
}
static void
gedit_app_startup (GApplication *application)
{
......@@ -484,9 +519,6 @@ gedit_app_startup (GApplication *application)
GtkSourceStyleSchemeManager *manager;
const gchar *dir;
gchar *icon_dir;
GError *error = NULL;
GFile *css_file;
GtkCssProvider *provider;
G_APPLICATION_CLASS (gedit_app_parent_class)->startup (application);
......@@ -569,22 +601,8 @@ gedit_app_startup (GApplication *application)
load_accels ();
/* Load custom css */
error = NULL;
css_file = g_file_new_for_uri ("resource:///org/gnome/gedit/css/gedit-style.css");
provider = gtk_css_provider_new ();
if (gtk_css_provider_load_from_file (provider, css_file, &error))
{
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref (provider);
}
else
{
g_warning ("Could not load css provider: %s", error->message);
g_error_free (error);
}
g_object_unref (css_file);
load_css_from_resource ("gedit-style.css", TRUE);
load_css_from_resource ("gedit-style-os.css", FALSE);
/*
* We use the default gtksourceview style scheme manager so that plugins
......
......@@ -3,7 +3,6 @@
<gresource prefix="/org/gnome/gedit">
<file preprocess="xml-stripblanks">gtk/menus.ui</file>
<file preprocess="xml-stripblanks">gtk/menus-common.ui</file>
@RESOURCE_TRADITIONAL_MENUS_UI@
<file preprocess="xml-stripblanks">ui/gedit-encodings-dialog.ui</file>
<file preprocess="xml-stripblanks">ui/gedit-preferences-dialog.ui</file>
<file preprocess="xml-stripblanks">ui/gedit-replace-dialog.ui</file>
......@@ -20,5 +19,7 @@
<file preprocess="xml-stripblanks">ui/gedit-statusbar.ui</file>
<file>css/gedit-style.css</file>
<file>css/gedit.adwaita.css</file>
@OS_DEPENDENT_RESOURCE_FILES@
</gresource>
</gresources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment