Updated mintDesktop to allow button layout switching

Contribute code & patches
Forum rules
No support questions here please

Re: Updated mintDesktop to allow button layout switching

Postby exploder on Sat Mar 27, 2010 7:28 pm

ikey, that is pretty cool! :D
exploder
Level 15
Level 15
 
Posts: 5813
Joined: Tue Feb 13, 2007 10:50 am
Location: HartfordCity, Indiana USA

Linux Mint is funded by ads and donations.
 

Re: Updated mintDesktop to allow button layout switching

Postby Kendall on Mon Mar 29, 2010 1:56 pm

ikey,

Would it make any sense to take some of what I've done with my keyboard/mouse settings app and add it to this?
User avatar
Kendall
Level 7
Level 7
 
Posts: 1580
Joined: Mon Nov 16, 2009 12:20 pm
Location: Asheville, NC, USA

Re: Updated mintDesktop to allow button layout switching

Postby Kendall on Mon Mar 29, 2010 2:27 pm

It's not the best coded app in existence, but it's effective. I haven't translated it just yet as xgettext hasn't been playing nice, also I was going to move everything into HBox's and VBox's instead of the fixed layout but I haven't made the time for it.

Code: Select all
#!/usr/bin/env python
#
# mintInput
#
# by Kendall Weaver <kendalltweaver@gmail.com>
#
# Graphical settings tool written for the Linux Mint Fluxbox edition
# to replace Simple-Mouse and Simple-Keyboard with a single, better
# featured application.

import sys
import gtk
import os

pad = str("synclient TouchPadOff=0")
paw = str("pointer = 1 2 3")
acc = int(2)
thr = int(2)
kac = int(20)
ksn = int(100)

class Mouse(gtk.Window):

   def on_clicked(self, widget):
      gtk.main_quit()

   def on_destroy(self, widget):
      gtk.main_quit()

   def applicate(self, widget):
      os.system('touch $HOME/.linuxmint/tools/sms')
      os.system('echo "#!/bin/sh" > $HOME/.linuxmint/tools/sms')
      os.system('echo "#Autogenerated script - Do not edit" >> $HOME/.linuxmint/tools/sms')
      os.system('echo \"' + pad + '\" >> $HOME/.linuxmint/tools/sms')
      os.system('echo \'xmodmap -e \"' + paw + '\"\' >> $HOME/.linuxmint/tools/sms')
      os.system('echo \"xset m ' + str(acc) + ' ' + str(thr) + '\" >> $HOME/.linuxmint/tools/sms')
      os.system("sms1")

   #Apply function for Keyboard tab needs finishing.
   #Use kac and ksn variables with "xset r rate".
   def applicate2(self, widget):
      os.system('touch $HOME/.linuxmint/tools/sms')
      os.system('echo "#!/bin/sh" > $HOME/.linuxmint/tools/sks')
      os.system('echo "#Autogenerated script - Do not edit" >> $HOME/.linuxmint/tools/sks')
      os.system('echo \"xset r rate ' + str(kac) + ' ' + str(ksn) + '\" >> $HOME/.linuxmint/tools/sks')
      os.system("sks1")

   def enable(self, widget):
      if widget.get_active():
         global pad
         pad = str("synclient TouchPadOff=0")
      else:
         global pad
         pad = str("synclient TouchPadOff=1")
      global pad
      print pad

   def southpaw(self, widget):
      if widget.get_active():
         global paw
         paw = str("pointer = 3 2 1")
      else:
         global paw
         paw = str("pointer = 1 2 3")
      print paw

   def acceleration(self, widget):
      widget.get_value()
      acc = int(widget.get_value())
      global acc
      print acc

   def threshold(self, widget):
      widget.get_value()
      thr = int(widget.get_value())
      global thr
      print thr

   def keyaccel(self, widget):
      widget.get_value()
      kac = int(10 * (widget.get_value()))
      global kac
      print kac

   def keysense(self, widget):
      widget.get_value()
      ksn = int(widget.get_value())
      global ksn
      print ksn

   def layout(self, widget):
      os.system("skl")

   def __init__(self):
      super(Mouse, self).__init__()

      self.set_title("Keyboard and Mouse")
      self.set_size_request(400, 225)
      self.set_position(gtk.WIN_POS_CENTER)

      try:
         self.set_icon_from_file("/usr/lib/linuxmint/mint-fluxbox-tools/mouse.png")
         self.mouse = gtk.gdk.pixbuf_new_from_file("/usr/lib/linuxmint/mint-fluxbox-tools/mouse.png")
         self.keys = gtk.gdk.pixbuf_new_from_file("/usr/lib/linuxmint/mint-fluxbox-tools/keyboard.png")
      except Exception, e:
         print e.message
         sys.exit(1)

      image1 = gtk.Image()
      image1.set_from_pixbuf(self.keys)
      image2 = gtk.Image()
      image2.set_from_pixbuf(self.mouse)

      chk1 = gtk.CheckButton("Touchpad enabled")
      chk1.set_active(True)
      chk1.connect("clicked", self.enable)
      chk2 = gtk.CheckButton("Left Handed")
      chk2.set_active(False)
      chk2.connect("clicked", self.southpaw)

      lbl1 = gtk.Label("Acceleration")
      lbl2 = gtk.Label("Threshold")

      lbl5 = gtk.Label("Delay")
      lbl6 = gtk.Label("Interval")

      scl1 = gtk.HScale()
      scl1.set_range(0, 10)
      scl1.set_increments(1, 2)
      scl1.set_digits(0)
      scl1.set_value(2)
      scl1.set_size_request(150, 35)
      scl1.connect("value-changed", self.acceleration)
      scl2 = gtk.HScale()
      scl2.set_range(0, 10)
      scl2.set_increments(1, 2)
      scl2.set_digits(0)
      scl2.set_value(2)
      scl2.set_size_request(150, 35)
      scl2.connect("value-changed", self.threshold)
      scl3 = gtk.HScale()
      scl3.set_range(10, 100)
      scl3.set_increments(1, 1)
      scl3.set_digits(0)
      scl3.set_value(20)
      scl3.set_size_request(170, 35)
      scl3.connect("value-changed", self.keyaccel)
      scl4 = gtk.HScale()
      scl4.set_range(10, 100)
      scl4.set_increments(1, 1)
      scl4.set_digits(0)
      scl4.set_value(100)
      scl4.set_size_request(170, 35)
      scl4.connect("value-changed", self.keysense)

      btn1 = gtk.Button(stock=gtk.STOCK_APPLY)
      btn1.set_size_request(80, 30)
      btn1.connect("clicked", self.applicate)
      btn2 = gtk.Button(stock=gtk.STOCK_CLOSE)
      btn2.set_size_request(80, 30)
      btn2.connect("clicked", self.on_clicked)
      btn3 = gtk.Button(stock=gtk.STOCK_APPLY)
      btn3.set_size_request(80, 30)
      btn3.connect("clicked", self.applicate2)
      btn4 = gtk.Button(stock=gtk.STOCK_CLOSE)
      btn4.set_size_request(80, 30)
      btn4.connect("clicked", self.on_clicked)
      btn5 = gtk.Button("Select Layout")
      btn5.set_size_request(170, 30)
      btn5.connect("clicked", self.layout)

      fix1 = gtk.Fixed()
      fix2 = gtk.Fixed()

      lbl3 = gtk.Label("Keyboard")
      lbl4 = gtk.Label("Mouse")

      nbk1 = gtk.Notebook()
      nbk1.set_tab_pos(gtk.POS_TOP)
      nbk1.insert_page(fix1, lbl3, 0)
      nbk1.insert_page(fix2, lbl4, 1)

      fix1.put(lbl5, 135, 39)
      fix1.put(lbl6, 125, 94)
      fix1.put(scl3, 205, 20)
      fix1.put(scl4, 205, 75)
      fix1.put(btn3, 205, 147)
      fix1.put(btn4, 295, 147)
      fix1.put(btn5, 15, 147)
      fix1.put(image1, 10, 22)

      fix2.put(chk1, 10, 140)
      fix2.put(chk2, 10, 165)
      fix2.put(lbl1, 125, 39)
      fix2.put(lbl2, 140, 94)
      fix2.put(scl1, 225, 20)
      fix2.put(scl2, 225, 75)
      fix2.put(btn1, 205, 147)
      fix2.put(btn2, 295, 147)
      fix2.put(image2, 10, 22)

      self.connect("destroy", self.on_destroy)

      self.add(nbk1)
      self.show_all()

Mouse()
gtk.main()
User avatar
Kendall
Level 7
Level 7
 
Posts: 1580
Joined: Mon Nov 16, 2009 12:20 pm
Location: Asheville, NC, USA

Re: Updated mintDesktop to allow button layout switching

Postby exploder on Mon Mar 29, 2010 4:31 pm

ikey, you are a genius! I wonder if it's possible to add the gdm changing utility I saw on gnome-look? Just throwing that idea out there because people are always asking how to change the background of the gdm.
exploder
Level 15
Level 15
 
Posts: 5813
Joined: Tue Feb 13, 2007 10:50 am
Location: HartfordCity, Indiana USA

Re: Updated mintDesktop to allow button layout switching

Postby Kendall on Mon Mar 29, 2010 4:36 pm

One app to rule them all...
User avatar
Kendall
Level 7
Level 7
 
Posts: 1580
Joined: Mon Nov 16, 2009 12:20 pm
Location: Asheville, NC, USA

Re: Updated mintDesktop to allow button layout switching

Postby Kendall on Mon Mar 29, 2010 4:48 pm

Personally I think it would make more sense to consolidate all the features of the default Gnome settings apps and get rid of them altogether, but that's just my opinion. I think the only thing in my app that isn't redundant functionality is the setting for the touchpad. Anyway, have fun with it and I hope Clem likes it well enough to include in Mint 9.
User avatar
Kendall
Level 7
Level 7
 
Posts: 1580
Joined: Mon Nov 16, 2009 12:20 pm
Location: Asheville, NC, USA

Re: Updated mintDesktop to allow button layout switching

Postby beefstu on Mon Mar 29, 2010 5:35 pm

Ikey, you're doing a brilliant job!

I think the general consensus has been to eliminate the replication in the app, so the
Fonts, Style and Wallpaper tabs will most likely be removed, see what happens..


Maybe Clem could think about using this app to replace the Appearance app to keep all things like that together? I know you wanted to avoid it getting bloated but all it would need is some theme settings and it would have all the same functionality in a much more 'mint-like' way.

Just my thoughts
Please go through the steps here when posting a question. Once your question has been resolved, edit the original question post and add [Solved] to the subject. Both of these will help others use the forum effectively.
User avatar
beefstu
Level 5
Level 5
 
Posts: 654
Joined: Tue Dec 29, 2009 10:22 am
Location: Southampton, UK

Linux Mint is funded by ads and donations.
 

Return to Code & Patches

Who is online

Users browsing this forum: No registered users and 1 guest