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 Sat 20 Sep 2014, 22:18
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 [4 Posts]  
Author Message
MU


Joined: 24 Aug 2005
Posts: 13642
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:
http://www.murga-linux.com/puppy/viewtopic.php?p=286272#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/Programming/Vala/WineColorSetter/WineColorSetter.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/Programming/Vala/WineColorSetter/WineColorSetterWine.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/Programming/Vala/Vala-for-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
WineColorSetter.jpg
 Description   
 Filesize   23.52 KB
 Viewed   747 Time(s)

WineColorSetter.jpg


_________________
my recommended links

Last edited by MU on Sat 28 Mar 2009, 10:14; edited 3 times in total
Back to top
View user's profile Send private message Visit poster's website 
Lobster
Official Crustacean


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

PostPosted: Sat 21 Mar 2009, 02:21    Post subject:  

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

Last edited by Lobster on Sat 02 May 2009, 10:02; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
MU


Joined: 24 Aug 2005
Posts: 13642
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

Mark

_________________
my recommended links
Back to top
View user's profile Send private message Visit poster's website 
MU


Joined: 24 Aug 2005
Posts: 13642
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.

Code:
/*------------------------------------------------------------
 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

_________________
my recommended links
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [4 Posts]  
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 post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


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