Here are patches for Touchy and gladevcp 

adds ability to change gtk themes
adds ability to move the windows to a second screen (for instance)
and maximized to that screen size.
adds ability to change a few important DRO and error message
text colors in Touchy

I would like to add them to 2.5.
Comments?

Chris M

                                          
From fbd67939671d59c9fab76fb833a41345eacc724d Mon Sep 17 00:00:00 2001
From: cmorley <[email protected]>
Date: Fri, 1 Jul 2011 12:45:19 -0700
Subject: [PATCH 1/8] 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


From 05db0721e36a3e7bfd5ed585eeb1836d49b379db Mon Sep 17 00:00:00 2001
From: cmorley <[email protected]>
Date: Sun, 3 Jul 2011 12:03:53 -0700
Subject: [PATCH 2/8] touchy - add ability to change DRO text color from preference file

added abs_textcolor rel_textcolor and dtg_textcolor to preference file.
set them to default for usual color or color like '#oB33E9' (blue)
---
 src/emc/usr_intf/touchy/touchy.py |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/src/emc/usr_intf/touchy/touchy.py b/src/emc/usr_intf/touchy/touchy.py
index 837acb0..7e34ac9 100755
--- a/src/emc/usr_intf/touchy/touchy.py
+++ b/src/emc/usr_intf/touchy/touchy.py
@@ -129,6 +129,10 @@ class touchy:
                             temp = search+1
                     self.wTree.get_widget("theme_choice").set_active(temp)
 
+                self.abs_textcolor = self.prefs.getpref('abs_textcolor', 'default', str)
+                self.rel_textcolor = self.prefs.getpref('rel_textcolor', 'default', str)
+                self.dtg_textcolor = self.prefs.getpref('dtg_textcolor', 'default', str)
+
                 self.invisible_cursor = self.prefs.getpref('invisible_cursor', 0)
                 if self.invisible_cursor:
                         self.wTree.get_widget("MainWindow").window.set_cursor(invisible)
@@ -594,7 +598,14 @@ class touchy:
                           'xa', 'ya', 'za', 'aa', 'ba', 'ca', 'ua', 'va', 'wa',
                           'xd', 'yd', 'zd', 'ad', 'bd', 'cd', 'ud', 'vd', 'wd']:
                         w = self.wTree.get_widget(i)
-                        if w: w.modify_font(self.dro_font)
+                        if w:
+                            w.modify_font(self.dro_font)
+                            if "r" in i and not self.rel_textcolor == "default":
+                                w.modify_fg(gtk.STATE_NORMAL,gtk.gdk.color_parse(self.rel_textcolor))
+                            elif "a" in i and not self.abs_textcolor == "default":
+                                w.modify_fg(gtk.STATE_NORMAL,gtk.gdk.color_parse(self.abs_textcolor))
+                            elif "d" in i and not self.dtg_textcolor == "default":
+                                w.modify_fg(gtk.STATE_NORMAL,gtk.gdk.color_parse(self.dtg_textcolor))
 
                 # status bar
                 for i in ["error"]:
-- 
1.7.0.4


From 3beb1a3ed4899835bb337d65aaacc1548ebe360c Mon Sep 17 00:00:00 2001
From: cmorley <[email protected]>
Date: Sun, 3 Jul 2011 14:04:03 -0700
Subject: [PATCH 3/8] touchy - fix for theme changes to 'follow system theme'

You now can immediately go back to the system theme instead
of having to reload Touchy
---
 src/emc/usr_intf/touchy/touchy.py |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/emc/usr_intf/touchy/touchy.py b/src/emc/usr_intf/touchy/touchy.py
index 7e34ac9..cb6428f 100755
--- a/src/emc/usr_intf/touchy/touchy.py
+++ b/src/emc/usr_intf/touchy/touchy.py
@@ -150,8 +150,9 @@ class touchy:
                 self.wTree.get_widget("listingfontbutton").set_font_name(self.listing_font_name)
                 self.listing_font = pango.FontDescription(self.listing_font_name)
 
+                settings = gtk.settings_get_default()
+                self.system_theme = settings.get_property("gtk-theme-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
@@ -544,10 +545,11 @@ class touchy:
 
         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)
+            if theme == "Follow System Theme":
+                theme = self.system_theme
+            settings = gtk.settings_get_default()
+            settings.set_string_property("gtk-theme-name", theme, "")
 
         def setfont(self):
                 # buttons
-- 
1.7.0.4


From 982a1068228a2714df7a5e76268076f908243e93 Mon Sep 17 00:00:00 2001
From: cmorley <[email protected]>
Date: Mon, 4 Jul 2011 01:36:16 -0700
Subject: [PATCH 4/8] gladevcp - add ability to change GTK theme of panel

adds -t for theme name
some themes look better with AXIS for instance
different panels can have different themes
---
 src/hal/user_comps/gladevcp.py |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/hal/user_comps/gladevcp.py b/src/hal/user_comps/gladevcp.py
index 87ca8f9..87c1e50 100644
--- a/src/hal/user_comps/gladevcp.py
+++ b/src/hal/user_comps/gladevcp.py
@@ -54,6 +54,7 @@ Values are in pixel units, XOFFSET/YOFFSET is referenced from top left of screen
 use -g WIDTHxHEIGHT for just setting size or -g +XOFFSET+YOFFSET for just position""")
           , Option( '-H', dest='halfile', metavar='FILE'
                   , help="execute hal statements from FILE with halcmd after the component is set up and ready")
+          , Option( '-t', dest='theme', default="", help="Set gtk theme. Default is system theme")
           , Option( '-x', dest='parent', type=int, metavar='XID'
                   , help="Reparent gladevcp into an existing window XID instead of creating a new top level window")
           , Option( '-u', dest='usermod', action='append', default=[], metavar='FILE'
@@ -238,6 +239,11 @@ def main():
             parser.print_usage()
             sys.exit(1)
 
+    if opts.theme:
+        print "**** GLADE VCP INFO:    Switching %s to '%s' theme" %(opts.component,opts.theme)
+        settings = gtk.settings_get_default()
+        settings.set_string_property("gtk-theme-name", opts.theme, "")
+
     if opts.halfile:
         cmd = ["halcmd", "-f", opts.halfile]
         res = subprocess.call(cmd, stdout=sys.stdout, stderr=sys.stderr)
-- 
1.7.0.4


From 8b1a5b2ceb1f56123ae596f1599862a43ebeeb40 Mon Sep 17 00:00:00 2001
From: cmorley <[email protected]>
Date: Mon, 4 Jul 2011 01:56:36 -0700
Subject: [PATCH 5/8] gladevcp - add option to force panel to maximize

Together with the -g geometry option one can move the panel
to a second monitor and force it to use all of the screen
---
 src/hal/user_comps/gladevcp.py |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/hal/user_comps/gladevcp.py b/src/hal/user_comps/gladevcp.py
index 87c1e50..96c044a 100644
--- a/src/hal/user_comps/gladevcp.py
+++ b/src/hal/user_comps/gladevcp.py
@@ -54,6 +54,7 @@ Values are in pixel units, XOFFSET/YOFFSET is referenced from top left of screen
 use -g WIDTHxHEIGHT for just setting size or -g +XOFFSET+YOFFSET for just position""")
           , Option( '-H', dest='halfile', metavar='FILE'
                   , help="execute hal statements from FILE with halcmd after the component is set up and ready")
+          , Option( '-m', dest='maximum', default=False, help="Force panel window to maxumize")
           , Option( '-t', dest='theme', default="", help="Set gtk theme. Default is system theme")
           , Option( '-x', dest='parent', type=int, metavar='XID'
                   , help="Reparent gladevcp into an existing window XID instead of creating a new top level window")
@@ -244,6 +245,10 @@ def main():
         settings = gtk.settings_get_default()
         settings.set_string_property("gtk-theme-name", opts.theme, "")
 
+    # This needs to be done after geometry moves so on dual screens the window maxumizes to the actual used screen size.
+    if opts.maximum:
+        window.window.maximize()
+
     if opts.halfile:
         cmd = ["halcmd", "-f", opts.halfile]
         res = subprocess.call(cmd, stdout=sys.stdout, stderr=sys.stderr)
-- 
1.7.0.4


From c06ef0282ab1dcecae9c99853f0a66a100a02396 Mon Sep 17 00:00:00 2001
From: cmorley <[email protected]>
Date: Mon, 4 Jul 2011 02:07:14 -0700
Subject: [PATCH 6/8] touchy - add ability to force maximize after geometry move

This allows Touchy to be moved to a different screen on a
dual screen system and force it to maximize to the size of that
screen. add 'window_max = True' manually to .touchy_preference file
---
 src/emc/usr_intf/touchy/touchy.py |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/emc/usr_intf/touchy/touchy.py b/src/emc/usr_intf/touchy/touchy.py
index cb6428f..42dc5d7 100755
--- a/src/emc/usr_intf/touchy/touchy.py
+++ b/src/emc/usr_intf/touchy/touchy.py
@@ -115,6 +115,12 @@ class touchy:
                 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)
+                self.abs_textcolor = self.prefs.getpref('abs_textcolor', 'default', str)
+                self.rel_textcolor = self.prefs.getpref('rel_textcolor', 'default', str)
+                self.dtg_textcolor = self.prefs.getpref('dtg_textcolor', 'default', str)
+                self.window_geometry = self.prefs.getpref('window_geometry', 'default', str)
+                self.window_max = self.prefs.getpref('window_force_max', 'False', bool)
+
                 # initial screen setup
                 if os.path.exists(themedir):
                     model = self.wTree.get_widget("theme_choice").get_model()
@@ -129,9 +135,12 @@ class touchy:
                             temp = search+1
                     self.wTree.get_widget("theme_choice").set_active(temp)
 
-                self.abs_textcolor = self.prefs.getpref('abs_textcolor', 'default', str)
-                self.rel_textcolor = self.prefs.getpref('rel_textcolor', 'default', str)
-                self.dtg_textcolor = self.prefs.getpref('dtg_textcolor', 'default', str)
+                if self.window_geometry == "default":
+		            self.wTree.get_widget("MainWindow").window.maximize()
+                else:
+                    self.wTree.get_widget("MainWindow").parse_geometry(self.window_geometry)
+                    if self.window_max:
+                        self.wTree.get_widget("MainWindow").window.maximize()
 
                 self.invisible_cursor = self.prefs.getpref('invisible_cursor', 0)
                 if self.invisible_cursor:
@@ -614,8 +623,6 @@ class touchy:
                         w = self.wTree.get_widget(i)
                         w.modify_font(self.error_font)
 
-		self.wTree.get_widget("MainWindow").window.maximize()
-
         def mdi_set_tool(self, b):
                 self.mdi_control.set_tool(self.status.get_current_tool(), self.g10l11)
 
-- 
1.7.0.4


From b8471578ae17db63bee09a91bc8fa8fe309f3718 Mon Sep 17 00:00:00 2001
From: cmorley <[email protected]>
Date: Mon, 4 Jul 2011 02:11:47 -0700
Subject: [PATCH 7/8] touchy - move theme change button to proper spot

---
 src/emc/usr_intf/touchy/touchy.glade |   34 +++++++++++++++++-----------------
 1 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/src/emc/usr_intf/touchy/touchy.glade b/src/emc/usr_intf/touchy/touchy.glade
index 10af965..25e176a 100644
--- a/src/emc/usr_intf/touchy/touchy.glade
+++ b/src/emc/usr_intf/touchy/touchy.glade
@@ -3170,7 +3170,7 @@ F1 S1</property>
                                     <child>
                                       <widget class="GtkTable" id="table23">
                                         <property name="visible">True</property>
-                                        <property name="n_rows">2</property>
+                                        <property name="n_rows">3</property>
                                         <child>
                                           <widget class="GtkToggleButton" id="pointer_hide">
                                             <property name="label" translatable="yes">Hide pointer</property>
@@ -3197,6 +3197,21 @@ F1 S1</property>
                                             <property name="bottom_attach">2</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="top_attach">2</property>
+                                            <property name="bottom_attach">3</property>
+                                          </packing>
+                                        </child>
                                       </widget>
                                       <packing>
                                         <property name="left_attach">2</property>
@@ -3239,22 +3254,7 @@ F1 S1</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>
+                                      <placeholder/>
                                     </child>
                                   </widget>
                                 </child>
-- 
1.7.0.4


From 8e5813b080de2759f2f80c725a6f0cf96fd1feb1 Mon Sep 17 00:00:00 2001
From: cmorley <[email protected]>
Date: Mon, 4 Jul 2011 03:13:07 -0700
Subject: [PATCH 8/8] touchy - add ability to choose error message text color

This really makes it stand out better on some themes.
add 'err_textcolor = #F9F326' to .touchy_preferences file
for yellow text for instance. Or = default for standard color
---
 src/emc/usr_intf/touchy/touchy.py |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/emc/usr_intf/touchy/touchy.py b/src/emc/usr_intf/touchy/touchy.py
index 42dc5d7..8b509e3 100755
--- a/src/emc/usr_intf/touchy/touchy.py
+++ b/src/emc/usr_intf/touchy/touchy.py
@@ -118,6 +118,7 @@ class touchy:
                 self.abs_textcolor = self.prefs.getpref('abs_textcolor', 'default', str)
                 self.rel_textcolor = self.prefs.getpref('rel_textcolor', 'default', str)
                 self.dtg_textcolor = self.prefs.getpref('dtg_textcolor', 'default', str)
+                self.err_textcolor = self.prefs.getpref('err_textcolor', 'default', str)
                 self.window_geometry = self.prefs.getpref('window_geometry', 'default', str)
                 self.window_max = self.prefs.getpref('window_force_max', 'False', bool)
 
@@ -622,6 +623,7 @@ class touchy:
                 for i in ["error"]:
                         w = self.wTree.get_widget(i)
                         w.modify_font(self.error_font)
+                        w.modify_fg(gtk.STATE_NORMAL,gtk.gdk.color_parse(self.err_textcolor))
 
         def mdi_set_tool(self, b):
                 self.mdi_control.set_tool(self.status.get_current_tool(), self.g10l11)
-- 
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

Reply via email to