Hi guys
I have this patch for Touchy that allows one to dynamically choose a
different GTK theme for Touchy then what the system is using.
For instance the default 'Ambiance' is hard to tell when
toggle buttons are on or off. 'Redmond' is much better.
It will also remember your choice and next time will use that theme.
If one was ambitious, one could write a gtkrc file just for Touchy
and change colors and such to what looks good for an industrial
control.
If there are no objections / suggestions I think its worth adding to 2.5
branch.
Chris M
From cbe1cbfcf1c4906188c87c459eb4a98b9c5baa93 Mon Sep 17 00:00:00 2001
From: cmorley <[email protected]>
Date: Fri, 1 Jul 2011 12:45:19 -0700
Subject: [PATCH] Touchy - add ability to choose different gtk theme then system
Some system themes dont work well with Touchy but are nice on the system.
also if one wanted to write a custom theme just for Touchy this allows it
to run on just Touchy
---
src/emc/usr_intf/touchy/touchy.glade | 51 +++++++++++++++++++++++++++++++++-
src/emc/usr_intf/touchy/touchy.py | 30 ++++++++++++++++++-
2 files changed, 78 insertions(+), 3 deletions(-)
diff --git a/src/emc/usr_intf/touchy/touchy.glade b/src/emc/usr_intf/touchy/touchy.glade
index f5ed223..10af965 100644
--- a/src/emc/usr_intf/touchy/touchy.glade
+++ b/src/emc/usr_intf/touchy/touchy.glade
@@ -3029,7 +3029,7 @@ F1 S1</property>
<child>
<widget class="GtkTable" id="table3">
<property name="visible">True</property>
- <property name="n_rows">4</property>
+ <property name="n_rows">5</property>
<property name="n_columns">3</property>
<child>
<widget class="GtkLabel" id="controlfont">
@@ -3207,6 +3207,55 @@ F1 S1</property>
<property name="y_padding">10</property>
</packing>
</child>
+ <child>
+ <widget class="GtkLabel" id="label8">
+ <property name="visible">True</property>
+ <property name="xalign">0.89999997615814209</property>
+ <property name="label" translatable="yes">GTK Theme:</property>
+ <property name="justify">right</property>
+ </widget>
+ <packing>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkComboBox" id="theme_choice">
+ <property name="visible">True</property>
+ <property name="button_sensitivity">on</property>
+ <property name="items" translatable="yes">default
+</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ <property name="x_padding">10</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="change_theme">
+ <property name="label" translatable="yes">Change Theme</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
+ <property name="image_position">bottom</property>
+ <signal name="clicked" handler="on_changetheme_clicked"/>
+ </widget>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="x_padding">10</property>
+ </packing>
+ </child>
</widget>
</child>
</widget>
diff --git a/src/emc/usr_intf/touchy/touchy.py b/src/emc/usr_intf/touchy/touchy.py
index 48e369d..837acb0 100755
--- a/src/emc/usr_intf/touchy/touchy.py
+++ b/src/emc/usr_intf/touchy/touchy.py
@@ -20,6 +20,7 @@ BASE = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), ".."))
libdir = os.path.join(BASE, "lib", "python")
datadir = os.path.join(BASE, "share", "emc")
sys.path.insert(0, libdir)
+themedir = "/usr/share/themes"
try:
import pygtk
pygtk.require("2.0")
@@ -113,8 +114,21 @@ class touchy:
self.dro_font_name = self.prefs.getpref('dro_font', 'Courier 10 Pitch Bold 16', str)
self.error_font_name = self.prefs.getpref('error_font', 'Sans Bold 10', str)
self.listing_font_name = self.prefs.getpref('listing_font', 'Sans 10', str)
-
+ self.theme_name = self.prefs.getpref('gtk_theme', 'Follow System Theme', str)
# initial screen setup
+ if os.path.exists(themedir):
+ model = self.wTree.get_widget("theme_choice").get_model()
+ model.clear()
+ model.append(("Follow System Theme",))
+ temp = 0
+ names = os.listdir(themedir)
+ names.sort()
+ for search,dirs in enumerate(names):
+ model.append((dirs,))
+ if dirs == self.theme_name:
+ temp = search+1
+ self.wTree.get_widget("theme_choice").set_active(temp)
+
self.invisible_cursor = self.prefs.getpref('invisible_cursor', 0)
if self.invisible_cursor:
self.wTree.get_widget("MainWindow").window.set_cursor(invisible)
@@ -132,6 +146,10 @@ class touchy:
self.wTree.get_widget("listingfontbutton").set_font_name(self.listing_font_name)
self.listing_font = pango.FontDescription(self.listing_font_name)
+ if not self.theme_name == "Follow System Theme":
+ settings = gtk.settings_get_default()
+ settings.set_string_property("gtk-theme-name", self.theme_name, "")
+
# interactive mdi command builder and issuer
mdi_labels = []
mdi_eventboxes = []
@@ -331,6 +349,7 @@ class touchy:
"on_spindle_faster_clicked" : self.emc.spindle_faster,
"on_toolset_fixture_clicked" : self.toolset_fixture,
"on_toolset_workpiece_clicked" : self.toolset_workpiece,
+ "on_changetheme_clicked" : self.change_theme,
}
self.wTree.signal_autoconnect(dic)
@@ -519,6 +538,13 @@ class touchy:
self.listing_font = pango.FontDescription(self.listing_font_name)
self.setfont()
+ def change_theme(self,b):
+ theme = self.wTree.get_widget("theme_choice").get_active_text()
+ if not theme == "Follow System Theme":
+ settings = gtk.settings_get_default()
+ settings.set_string_property("gtk-theme-name", theme, "")
+ self.prefs.putpref('gtk_theme', theme, str)
+
def setfont(self):
# buttons
for i in ["1", "2", "3", "4", "5", "6", "7",
@@ -537,7 +563,7 @@ class touchy:
"dro_commanded", "dro_actual", "dro_inch", "dro_mm",
"reload_tooltable", "opstop_on", "opstop_off",
"blockdel_on", "blockdel_off", "pointer_hide", "pointer_show",
- "toolset_workpiece", "toolset_fixture"]:
+ "toolset_workpiece", "toolset_fixture","change_theme"]:
w = self.wTree.get_widget(i)
if w:
w = w.child
--
1.7.0.4
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers