Skip to content

Commit

Permalink
Merge from 2.3: Fix for issue spyder-ide#2036
Browse files Browse the repository at this point in the history
  • Loading branch information
ccordoba12 committed Oct 2, 2015
2 parents 5e57dc6 + 5fe22ae commit 47a5a0c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
17 changes: 17 additions & 0 deletions spyderlib/config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def get_filter(filetypes, ext):
# Fonts
#==============================================================================
def is_ubuntu():
"Detect if we are running in an Ubuntu-based distribution"
if sys.platform.startswith('linux') and osp.isfile('/etc/lsb-release'):
release_info = open('/etc/lsb-release').read()
if 'Ubuntu' in release_info:
Expand All @@ -131,6 +132,22 @@ def is_ubuntu():
return False


def is_gtk_desktop():
"Detect if we are running in a Gtk-based desktop"
if sys.platform.startswith('linux'):
xdg_desktop = os.environ.get('XDG_CURRENT_DESKTOP', '')
if xdg_desktop:
gtk_desktops = ['Unity', 'GNOME', 'XFCE']
if any([xdg_desktop.startswith(d) for d in gtk_desktops]):
return True
else:
return False
else:
return False
else:
return False


SANS_SERIF = ['Sans Serif', 'DejaVu Sans', 'Bitstream Vera Sans',
'Bitstream Charter', 'Lucida Grande', 'MS Shell Dlg 2',
'Calibri', 'Verdana', 'Geneva', 'Lucid', 'Arial',
Expand Down
7 changes: 6 additions & 1 deletion spyderlib/plugins/configdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from spyderlib.config.base import (_, running_in_mac_app, LANGUAGE_CODES,
save_lang_conf, load_lang_conf)
from spyderlib.config.main import CONF
from spyderlib.config.main import CONF, is_gtk_desktop
from spyderlib.config.gui import (CUSTOM_COLOR_SCHEME_NAME,
set_default_color_scheme)
from spyderlib.config.user import NoDefault
Expand Down Expand Up @@ -740,6 +740,11 @@ def setup_page(self):
# --- Interface
interface_group = QGroupBox(_("Interface"))
styles = [str(txt) for txt in list(QStyleFactory.keys())]
# Don't offer users the possibility to change to a different
# style in Gtk-based desktops
# Fixes Issue 2036
if is_gtk_desktop() and ('GTK+' in styles):
styles = ['GTK+']
choices = list(zip(styles, [style.lower() for style in styles]))
style_combo = self.create_combobox(_('Qt windows style'), choices,
'windows_style',
Expand Down
16 changes: 13 additions & 3 deletions spyderlib/spyder.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
from spyderlib.qt.QtGui import (QApplication, QMainWindow, QSplashScreen,
QPixmap, QMessageBox, QMenu, QColor, QShortcut,
QKeySequence, QDockWidget, QAction,
QDesktopServices)
QDesktopServices, QStyleFactory)
from spyderlib.qt.QtCore import (Signal, QPoint, Qt, QSize, QByteArray, QUrl,
Slot, QTimer, QCoreApplication, QThread)
from spyderlib.qt.compat import (from_qvariant, getopenfilename,
Expand Down Expand Up @@ -134,7 +134,8 @@
get_module_source_path, STDERR, DEBUG,
debug_print, TEST, SUBFOLDER, MAC_APP_NAME,
running_in_mac_app, get_module_path)
from spyderlib.config.main import CONF, EDIT_EXT, IMPORT_EXT, OPEN_FILES_PORT
from spyderlib.config.main import (CONF, EDIT_EXT, IMPORT_EXT, OPEN_FILES_PORT,
is_gtk_desktop)
from spyderlib.cli_options import get_options
from spyderlib import dependencies
from spyderlib.config.ipython import IPYTHON_QT_INSTALLED
Expand Down Expand Up @@ -2600,7 +2601,16 @@ def win_env(self):
def apply_settings(self):
"""Apply settings changed in 'Preferences' dialog box"""
qapp = QApplication.instance()
qapp.setStyle(CONF.get('main', 'windows_style', self.default_style))
# Set 'gtk+' as the default theme in Gtk-based desktops
# Fixes Issue 2036
if is_gtk_desktop() and ('GTK+' in QStyleFactory.keys()):
try:
qapp.setStyle('gtk+')
except:
pass
else:
qapp.setStyle(CONF.get('main', 'windows_style',
self.default_style))

default = self.DOCKOPTIONS
if CONF.get('main', 'vertical_tabs'):
Expand Down

0 comments on commit 47a5a0c

Please sign in to comment.