Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 02 Jul 2015, 04:22
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Unsorted
Set color theme for Wine (Genie example)
Moderators: deshlab, Flash, GuestToo, Ian, JohnMurga, Lobster
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 1 Posts_count  
Author Message

Joined: 24 Aug 2005
Posts: 13644
Location: Karlsruhe, Germany

PostPosted: Sat 21 Mar 2009, 01:50    Post_subject:  Set color theme for Wine (Genie example)  

This is my first application written in Genie.
Quick overview of Genie:

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:

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.
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:
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.

 Filesize   23.52 KB
 Viewed   965 Time(s)


my recommended links

Back to top
View user's profile Send_private_message Visit_website 
Official Crustacean

Joined: 04 May 2005
Posts: 15121
Location: Paradox Realm

PostPosted: Sat 21 Mar 2009, 02:21    Post_subject:  

This is my first application written in Genie.

[much cheering] Cool
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 . . .

Puppy WIKI

Back to top
View user's profile Send_private_message Visit_website 

Joined: 24 Aug 2005
Posts: 13644
Location: Karlsruhe, Germany

PostPosted: Sat 21 Mar 2009, 02:33    Post_subject:  

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.

Very Happy Very Happy Very Happy


my recommended links
Back to top
View user's profile Send_private_message Visit_website 

Joined: 24 Aug 2005
Posts: 13644
Location: Karlsruhe, Germany

PostPosted: Sat 21 Mar 2009, 13:21    Post_subject:  

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.

 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



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)

//-- run a command and return the output --
def run(thecmd : string) : string
  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.
 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)

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

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

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

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

 main program

  //-- 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)
  //-- remove the first dummy entry from the combo

  //-- Finally let Gtk take over control of the window --
  Gtk.main ()


my recommended links
Back to top
View user's profile Send_private_message Visit_website 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Unsorted
Jump to:  

You cannot attach files in this forum
You can download files in this forum

Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0686s ][ Queries: 13 (0.0041s) ][ GZIP on ]