Add patches adding some improvements

This commit is contained in:
Björn Esser 2017-04-14 16:21:59 +02:00
parent 52123a11be
commit ce843b1143
3 changed files with 218 additions and 1 deletions

View File

@ -0,0 +1,26 @@
From e1b5afc74ff609f934f22e8f99502e208b9c3bda Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= <besser82@fedoraproject.org>
Date: Fri, 14 Apr 2017 11:01:58 +0200
Subject: [PATCH] Avoid several warnings in cmake-files from Qt5
---
buildtools/CMakeLists.common | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/buildtools/CMakeLists.common b/buildtools/CMakeLists.common
index 55843f5..dbde70e 100644
--- a/buildtools/CMakeLists.common
+++ b/buildtools/CMakeLists.common
@@ -6,6 +6,12 @@ if( POLICY CMP0053 )
cmake_policy( SET CMP0053 OLD )
endif()
+# Avoid several warnings in cmake-files from Qt5.
+# CMP0043: Ignore COMPILE_DEFINITIONS_<Config> properties
+if( POLICY CMP0043 )
+ cmake_policy( SET CMP0043 OLD )
+endif()
+
INCLUDE( "${CMAKE_SOURCE_DIR}/PROJECTINFO.cmake" )
SET( BUILDTOOLS_DIR "buildtools/" )

View File

@ -0,0 +1,183 @@
From 23c95cf92b69ea69ff15ec8eac88859669ad666a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= <besser82@fedoraproject.org>
Date: Thu, 13 Apr 2017 21:11:26 +0200
Subject: [PATCH] Add $(ENV:YUI_PREFERED_BACKEND) to set prefered UI-backend
---
src/YUILoader.cc | 93 ++++++++++++++++++++++++++++++++++----------------------
src/YUILoader.h | 27 ++++++++++++++--
2 files changed, 81 insertions(+), 39 deletions(-)
diff --git a/src/YUILoader.cc b/src/YUILoader.cc
index 7933ae4..2be22c2 100644
--- a/src/YUILoader.cc
+++ b/src/YUILoader.cc
@@ -42,11 +42,29 @@
void YUILoader::loadUI( bool withThreads )
{
bool isGtk = false;
- const char * envDisplay = getenv( "DISPLAY" );
- const char * envDesktop = getenv( "XDG_CURRENT_DESKTOP" );
+ const char * envDesktop;
+ const char * envDisplay;
+ const char * envPreset;
std::string wantedGUI;
- yuiMilestone () << "XDG_CURRENT_DESKTOP: \"" << envDesktop << "\"" << std::endl;
+ if( getenv( "DISPLAY" ) )
+ envDisplay = getenv( "DISPLAY" );
+ else
+ envDisplay = "";
+
+ if( getenv( "XDG_CURRENT_DESKTOP" ) )
+ envDesktop = getenv( "XDG_CURRENT_DESKTOP" );
+ else
+ envDesktop = "";
+
+ if( getenv( "YUI_PREFERED_BACKEND" ) )
+ envPreset = getenv( "YUI_PREFERED_BACKEND" );
+ else
+ envPreset = "";
+
+ yuiMilestone () << "DISPLAY: \"" << envDisplay << "\"" << std::endl;
+ yuiMilestone () << "XDG_CURRENT_DESKTOP: \"" << envDesktop << "\"" << std::endl;
+ yuiMilestone () << "YUI_PREFERED_BACKEND: \"" << envPreset << "\"" << std::endl;
// Taken from: https://specifications.freedesktop.org/menu-spec/menu-spec-1.1.html#onlyshowin-registry
isGtk = ( ( strstr( envDesktop, "Cinnamon" ) != NULL ) || isGtk );
@@ -58,61 +76,62 @@ void YUILoader::loadUI( bool withThreads )
isGtk = ( ( strstr( envDesktop, "Unity" ) != NULL ) || isGtk );
isGtk = ( ( strstr( envDesktop, "XFCE" ) != NULL ) || isGtk );
- if( isGtk )
- {
- yuiMilestone () << "Detected a Gtk-based desktop environment." << std::endl;
- yuiMilestone () << "Prefering Gtk-UI if available." << std::endl;
- }
+ if( isGtk ) yuiMilestone () << "Detected a Gtk-based desktop environment." << std::endl
+ << "Prefering Gtk-UI if available and no" << std::endl
+ << "user-selected override is present." << std::endl;
YCommandLine cmdline;
- bool wantNcurses = cmdline.find("--ncurses") != -1;
- if( wantNcurses )
- yuiMilestone () << "Using UI-backend: \"" << YUIPlugin_NCurses << "\". Forced on command-line." << std::endl;
- bool wantQt = cmdline.find("--qt") != -1;
- if( wantQt )
- yuiMilestone () << "Using UI-backend: \"" << YUIPlugin_Qt << "\". Forced on command-line." << std::endl;
- bool wantGtk = cmdline.find("--gtk") != -1;
- if( wantGtk )
- yuiMilestone () << "Using UI-backend: \"" << YUIPlugin_Gtk << "\". Forced on command-line." << std::endl;
+ bool wantGtk = ( cmdline.find( "--gtk" ) != -1 );
+ bool wantNcurses = ( cmdline.find( "--ncurses" ) != -1 );
+ bool wantQt = ( cmdline.find( "--qt" ) != -1 );
+ wantGtk = ( wantGtk || ( strcmp( envPreset, YUIPlugin_Gtk ) == 0 ) ) && !( wantNcurses || wantQt );
+ wantNcurses = ( wantNcurses || ( strcmp( envPreset, YUIPlugin_NCurses ) == 0 ) ) && !( wantGtk || wantQt );
+ wantQt = ( wantQt || ( strcmp( envPreset, YUIPlugin_Qt ) == 0 ) ) && !( wantGtk || wantNcurses );
+
+ if( wantGtk ) wantedGUI = YUIPlugin_Gtk;
+ if( wantNcurses ) wantedGUI = YUIPlugin_NCurses;
+ if( wantQt ) wantedGUI = YUIPlugin_Qt;
+
+ yuiMilestone () << "User-selected UI-plugin: \"" << wantedGUI << "\"" << std::endl;
- bool haveQt = pluginExists( YUIPlugin_Qt );
- bool haveGtk = pluginExists( YUIPlugin_Gtk );
+ bool haveGtk = pluginExists( YUIPlugin_Gtk );
+ bool haveNcurses = pluginExists( YUIPlugin_NCurses );
+ bool haveQt = pluginExists( YUIPlugin_Qt );
- if ( envDisplay && !wantNcurses )
+ if ( ( haveGtk || haveQt ) && strcmp ( envDisplay, "" ) &&
+ ( !wantNcurses || !isatty( STDOUT_FILENO ) ) )
{
// Qt is default if available.
if ( haveQt )
- wantedGUI = YUIPlugin_Qt;
+ wantedGUI = YUIPlugin_Qt;
// Do we want to use Gtk instead?
- if ( haveGtk && ( isGtk || wantGtk ) && !wantQt )
- wantedGUI = YUIPlugin_Gtk;
+ if ( haveGtk && ( ( ( isGtk || wantGtk ) && !wantQt ) || !haveQt ) )
+ wantedGUI = YUIPlugin_Gtk;
- if ( strcmp( wantedGUI.c_str(), "" ) )
+ yuiMilestone () << "Using UI-plugin: \"" << wantedGUI << "\""<< std::endl;
+
+ try
{
- yuiMilestone () << "Using UI-backend: \"" << wantedGUI << "\""<< std::endl;
- try
- {
- YSettings::loadedUI( wantedGUI, true );
- loadPlugin( wantedGUI, withThreads );
- return;
- }
- catch ( YUIException & ex )
- {
- YUI_CAUGHT( ex );
- }
+ YSettings::loadedUI( wantedGUI, true );
+ loadPlugin( wantedGUI, withThreads );
+ return;
+ }
+ catch ( YUIException & ex )
+ {
+ YUI_CAUGHT( ex );
}
}
- if ( isatty( STDOUT_FILENO ) )
+ if ( haveNcurses && isatty( STDOUT_FILENO ) )
{
//
// NCurses UI
//
wantedGUI = YUIPlugin_NCurses;
- yuiMilestone () << "Using UI-backend: \"" << wantedGUI << "\""<< std::endl;
+ yuiMilestone () << "Using UI-plugin: \"" << wantedGUI << "\""<< std::endl;
try
{
diff --git a/src/YUILoader.h b/src/YUILoader.h
index 1086b65..dfbb50c 100644
--- a/src/YUILoader.h
+++ b/src/YUILoader.h
@@ -46,9 +46,32 @@ class YUILoader
{
public:
/**
- * Load any of the available UI plug-ins in this order:
+ * Load any of the available UI-plugins in this order:
* - Qt if $DISPLAY is set
- * - NCurses if stdout is a tty
+ * - Gtk if $DISPLAY is set and Qt is not
+ * available or a GTK-based desktop
+ * environment is detected from the
+ * environment variable XDG_CURRENT_DESKTOP
+ * - NCurses if stdout is a TTY or Qt and Gtk are not
+ * available
+ *
+ * This behaviour can be overridden by either
+ * - specifing one of the switches '--gtk', '--ncurses'
+ * or '--qt' on the command-line of the program, or
+ * - setting the environment variable YUI_PREFERED_BACKEND
+ * to one of 'gtk', 'ncurses' or 'qt'.
+ *
+ * If a command-line switch is given to the program, the
+ * setting from the environment variable will be overridden
+ * by the UI-plugin chosen with the switch.
+ *
+ * If the user-selected UI-plugin is not installed on the
+ * system, an installed UI-plugin will be chosen in the
+ * order as stated above.
+ *
+ * The same applies if a needed pre-condition for a specific
+ * UI-plugin (no $DISPLAY for Gtk and Qt or no TTY for NCurses)
+ * is not met.
**/
static void loadUI( bool withThreads = false );

View File

@ -14,13 +14,18 @@
Name: lib%{libsuffix}
Version: 3.3.1
Release: 1%{?dist}
Release: 2%{?dist}
Summary: GUI-abstraction library
License: (LGPLv2 or LGPLv3) and MIT
URL: https://github.com/%{name}/%{name}
Source0: %{url}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
# Improments, submitted upstream. See:
# https://github.com/libyui/libyui/pull/115
Patch0: https://github.com/besser82/libyui/commit/23c95cf92b69ea69ff15ec8eac88859669ad666a.patch#/%{name}-3.3.1-env_YUI_PREFERED_BACKEND.patch
Patch1: https://github.com/besser82/libyui/commit/e1b5afc74ff609f934f22e8f99502e208b9c3bda.patch#/%{name}-3.3.1-CMP0043.patch
BuildRequires: boost-devel
BuildRequires: cmake
@ -137,6 +142,9 @@ popd
%changelog
* Fri Apr 14 2017 Björn Esser <besser82@fedoraproject.org> - 3.3.1-2
- Add patches adding some improvements
* Thu Apr 13 2017 Björn Esser <besser82@fedoraproject.org> - 3.3.1-1
- New upstream release