Set color theme for Wine (Genie example)

Stuff that has yet to be sorted into a category.
Post Reply
Message
Author
User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

Set color theme for Wine (Genie example)

#1 Post by MU »

This is my first application written in Genie.
Quick overview of Genie:
http://www.murga-linux.com/puppy/viewto ... 272#286272

It has a simple grafical interface, to give your Wine applications a different look.
This does not use the Theme-engine from Windows XP, as that one is buggy and slow.

Instead, it sets only other colors.
Applications look more pleasant now.

There are two pets.
You usually just will use:
http://dotpups.de/puppy4/dotpups/Progra ... Setter.pet

It is only 10 kb, compiled in Puppy 4.12.
Further down in this thread, you'll also find an updated sourcecode with more detailed comments.


The other one is 12 MB extracted.
http://dotpups.de/puppy4/dotpups/Progra ... erWine.pet
It includes a .exe, that can be run in Wine.
This just works, because I included 12 MB of Gtk for Windows related DLLs (even not all).
So this is basically a "proof of concept", intended for people, who want to test Genie programs in Wine, as "standalone" pack.

The DLLs are in the same folder as the application (/usr/local/WineColorSetter/), like this they don't need to be "installed".
Windows programs are often delivered in such a way.
It would however be more efficient, to install vala as described here:
http://dotpups.de/puppy4/dotpups/Progra ... r-Windows/
Like this you would need them only once, and not again for every single program.

Included are the projectfiles for the ValaIDE.
I will compile the newest version with official Genie support this evening.

Mark
Attachments
WineColorSetter.jpg
(23.52 KiB) Downloaded 1032 times
Last edited by MU on Sat 28 Mar 2009, 14:14, edited 3 times in total.
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#2 Post by Lobster »

This is my first application written in Genie.
[much cheering] 8)
Mark from your efforts what are your impressions of Genie?
I must say I find it a very readable language (coding is something that will take me time)

Also I once came across an idea or implementation that included the
code script of a compiled language in the exe executable.

In effect a size increase of the code - but how useful . . .
Last edited by Lobster on Sat 02 May 2009, 14:02, edited 1 time in total.
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#3 Post by MU »

I updated the pets, they are now compiled in Puppy 4.12.

Lob, I really like Genie.
It takes a bit to get things working, as I must look up even some basic things, like how to execute external commands.

But once this is done, I can add helper functions, that I can reuse later on.
This is not specific to Genie, you have this problem with every new language.

The new program now has two easy to use functions "run" (retrieve output from a program) and "exec" (run in background).

It also demonstrates, how to read a directory.
And how to use a combobox created with Glade.

I must admit, I am really excited.
Full access to glib, gtk, glade - in Gtkbasic, this always was somewhat limited.
Now in Genie, it is enormous.
And so small executables finally - fantastic.

:D :D :D

Mark
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#4 Post by MU »

I cleaned up the code a bit, so it is easier to understand.
As it does not change functionality, I do not repackage the pets.
I post it here, so people can quickly can look up how it works, even without installing the pet.

Code: Select all

/*------------------------------------------------------------
 we start with some definitions required by every program
 do not modify them, add own code below!
------------------------------------------------------------*/

/*-----------------------------------------------------------------------------
 to generate only the C code, run:
 valac -C --pkg gtk+-2.0 --pkg libglade-2.0 --pkg gmodule-2.0 main.gs 
 
 to compile in wine, use:
 wine start compile-win.bat

-----------------------------------------------------------------------------*/

[indent=2]
uses
  Gtk

xml : Glade.XML


/*-----------------------------------------------------------------------------
 we start with some "helpers".
 These methods look complicated, you don't need to understand them.
 They allow you to write easy to understand code on your own further down.

-----------------------------------------------------------------------------*/
//-- HELPER method: this is needed for every program using libglade --

def connect_signals (handler_name : string, object : GLib.Object, signal_name : string ,signal_data : string? , connect_object : GLib.Object?, after : bool)
  var module = Module.open (null, ModuleFlags.BIND_LAZY)
  sym : void*

  if (module.symbol (handler_name, out sym))
    Signal.connect (object, signal_name, (GLib.Callback) sym, null)


//-- HELPER method: check if we run in windows, using the inbuilt GLib Environment method --

def windows() : bool

  var tempdir = Environment.get_tmp_dir ()
  if tempdir.contains("\\")
    return true
    
  return false

//-- HELPER method: this method returns a WIDGET ! --
//-- it finds a widget object managed by libglade using the name of the widget --
def get_widget(name : string) : Widget
  var w = xml.get_widget(name)
  return w

//-- HELPER method: this method returns a BUTTON ! --
//-- to add a label, we must get the type of the widget --
def get_button(name : GLib.Object) : Button
  b : Button*
  b = name
  return b


//-- HELPER method: this method returns a COMBOBOX ! --
//-- to get selected text, we must get the type of the widget --
def get_combobox(name : GLib.Object) : ComboBox
  b : ComboBox*
  b = name
  return b

//-- HELPER methods to run executables/commands using GLib (which is inbuilt)

//-- run a program in background --
def exec(thecmd : string)
  Process.spawn_command_line_async(thecmd)

//-- run a command and return the output --
def run(thecmd : string) : string
  ret_stdout:string
  ret_stderr:string
  ret_status:int
  Process.spawn_command_line_sync(thecmd,out ret_stdout,out ret_stderr,out ret_status)
  return ret_stdout



/*------------------------------------------------------------------------
 here the signal handlers for the elements of a window are defined.
 So this is, where all the "action" takes place.
 ADD YOUR OWN CODE HERE.
 You must assign events to these methods in the Glade Interface Designer!
------------------------------------------------------------------------*/

//------------------------------------------------- ACTION
def on_button1_clicked (widget : Button)

  //-- we run regedit with the selected .reg file --

  var chosen = get_combobox(get_widget("combobox1")).get_active_text()  
  var cmd = "regedit regs/"
  if windows()
    cmd = "C:/windows/regedit.exe z:/usr/local/WineColorSetter/regs/"
  
  cmd = cmd.concat(chosen)
  cmd = cmd.concat(".reg")
  //print("%s" , cmd)
  run(cmd)

//------------------------------------------------- ACTION
def on_button2_clicked (widget : Widget)

  //-- we run the wine config program --
  
  var cmd = "/usr/bin/winecfg"
  if windows()
    cmd="Z:/usr/bin/winecfg"
    
  //print("%s" , cmd)
  exec(cmd)

//------------------------------------------------- ACTION
def on_window1_destroy (widget : Widget)

  //-- exit program when window is closed --
  
  Gtk.main_quit ()


  
/*-----------------
 main program
-----------------*/
init

  //-- initialize Gtk, create window, connect signals
  
  Gtk.init (ref args)
  xml = new Glade.XML ("project.glade", null, null)
  xml.signal_autoconnect_full (connect_signals)


  //-- here you can add code, that shall be run at startup, e.g. to set some defaultvalues.
  
  //-- read in a directory (regs), add matching entries with the suffix .reg to the combobox
  //-- note: the combo must have one dummy entry already, or libglade crashes.
  
  var check = ""
  mydir : Dir  
  mydir = Dir.open ("regs");
  var filename = ""
  while (filename = mydir.read_name ()) != null
    //print ("---%s" , filename)
    if filename.length > 4
      check = filename.substring(filename.length-4,4)
      //print ("----%s" , check)
      if check is ".reg"
        //print ("-ok---%s" , check)
        get_combobox(get_widget("combobox1")).append_text(filename.substring(0,filename.length-4))
  
  //-- remove the first dummy entry from the combo
  get_combobox(get_widget("combobox1")).remove_text(0)
  get_combobox(get_widget("combobox1")).set_active(0)


  //-- Finally let Gtk take over control of the window --
  
  Gtk.main ()
    
    
Mark
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

Post Reply