Skip to content

Commit 60166b1

Browse files
committed
gmoccapy: fix setting of themes
1 parent 5565398 commit 60166b1

1 file changed

Lines changed: 18 additions & 21 deletions

File tree

src/emc/usr_intf/gmoccapy/gmoccapy.py

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,7 @@ def __init__(self, argv):
232232
self.diameter_mode = False
233233

234234
# the default theme = System Theme we store here to be able to go back to that one later
235-
#TODO:
236-
#self.default_theme = Gtk.settings_get_default().get_property("Gtk-theme-name")
235+
self.default_theme = Gtk.Settings.get_default().get_property("gtk-theme-name")
237236
self.icon_theme = Gtk.IconTheme()
238237
self.icon_theme.append_search_path(ICON_THEME_DIR)
239238
self.icon_theme.append_search_path(USER_ICON_THEME_DIR)
@@ -1964,7 +1963,7 @@ def _init_themes(self):
19641963
for dirs in names:
19651964
try:
19661965
sbdirs = os.listdir(os.path.join(USERTHEMEDIR, dirs))
1967-
if 'Gtk-2.0' in sbdirs:
1966+
if 'gtk-3.0' in sbdirs:
19681967
themes.append(dirs)
19691968
except:
19701969
pass
@@ -1974,7 +1973,7 @@ def _init_themes(self):
19741973
for dirs in names:
19751974
try:
19761975
sbdirs = os.listdir(os.path.join(THEMEDIR, dirs))
1977-
if 'Gtk-2.0' in sbdirs:
1976+
if 'gtk-3.0' in sbdirs:
19781977
themes.append(dirs)
19791978
except:
19801979
pass
@@ -1985,10 +1984,9 @@ def _init_themes(self):
19851984
if theme == theme_name:
19861985
temp = index + 1
19871986
self.widgets.theme_choice.set_active(temp)
1988-
#TODO:
1989-
#settings = Gtk.settings_get_default()
1990-
#if not theme_name == "Follow System Theme":
1991-
# settings.set_string_property("Gtk-theme-name", theme_name, "")
1987+
settings = Gtk.Settings.get_default()
1988+
if not theme_name == "Follow System Theme":
1989+
settings.set_property("gtk-theme-name", theme_name)
19921990

19931991
def _init_icon_themes(self):
19941992
valid_icon_themes = icon_theme_helper.find_valid_icon_themes([USER_ICON_THEME_DIR, ICON_THEME_DIR])
@@ -3300,8 +3298,9 @@ def on_key_event(self, widget, event, signal):
33003298
# Notification stuff.
33013299
def _init_notification(self):
33023300
start_as = "rbtn_" + self.prefs.getpref("screen1", "window", str)
3303-
#TODO
3304-
xpos, ypos = (10,10)#self.widgets.window1.window.get_origin()
3301+
#TODO probably xpos and ypos should be added to notification's properties 'x_pos' and 'y_pos*.
3302+
# But then the behavior should be defined what should happen if the window is moved.
3303+
xpos, ypos = self.widgets.window1.get_position()
33053304
self.notification.set_property('x_pos', self.widgets.adj_x_pos_popup.get_value())
33063305
self.notification.set_property('y_pos', self.widgets.adj_y_pos_popup.get_value())
33073306
self.notification.set_property('message_width', self.widgets.adj_width_popup.get_value())
@@ -4412,17 +4411,15 @@ def on_btn_block_height_clicked(self, widget, data=None):
44124411

44134412
# choose a theme to apply
44144413
def on_theme_choice_changed(self, widget):
4415-
return
4416-
#TODO:
4417-
#theme = widget.get_active_text()
4418-
#if theme == None:
4419-
# return
4420-
#self.prefs.putpref('Gtk_theme', theme)
4421-
#settings = Gtk.settings_get_default()
4422-
##TODO:
4423-
# if theme == "Follow System Theme":
4424-
# theme = self.default_theme
4425-
#settings.set_string_property("Gtk-theme-name", theme, "")
4414+
active = widget.get_active_iter()
4415+
if active is None:
4416+
return
4417+
theme = widget.get_model()[active][0]
4418+
self.prefs.putpref('Gtk_theme', theme)
4419+
if theme == "Follow System Theme":
4420+
theme = self.default_theme
4421+
settings = Gtk.Settings.get_default()
4422+
settings.set_property("gtk-theme-name", theme)
44264423

44274424
def _set_icon_theme(self, name):
44284425
LOG.debug(f"Setting icon theme '{name}'")

0 commit comments

Comments
 (0)