Jump to page: 1 2
Thread overview
Does anyone have examples of GTK code in D?
Apr 09, 2005
Charles Hixson
Apr 09, 2005
J C Calvarese
Apr 09, 2005
Charles Hixson
Apr 12, 2005
Ant
May 09, 2005
TechnoZeus
May 09, 2005
Ant
May 09, 2005
John Reimer
May 10, 2005
TechnoZeus
May 10, 2005
Ant
May 10, 2005
Ant
May 11, 2005
TechnoZeus
Apr 09, 2005
Thomas Kuehne
Apr 11, 2005
clayasaurus
Apr 11, 2005
Charles Hixson
glade rulez
Apr 15, 2005
G.Vidal
Apr 16, 2005
Chris Sauls
Apr 17, 2005
G.Vidal
May 27, 2005
TechnoZeus
May 28, 2005
Chris Sauls
May 28, 2005
TechnoZeus
April 09, 2005
Does anyone have examples of GTK code in D?

Sorry, but my background doesn't include much C, so the standard examples don't help me much.

What I'd like to do is put some text on a window, put a button with a pixmap on the window, and then change the color of the window whenever the button is pushed.

(This is for a game on learning note names.  If I finish it, I'll gladly post it as a sample, but even though the Python original is working, I can't figure out how to get started on the D gtk interface.  Thanks to teqDruid<me@teqdruid.com> for the files, so I can see that it OUGHT to be possible.)
April 09, 2005
Charles Hixson wrote:
> Does anyone have examples of GTK code in D?

Have you tried DUI (http://dui.sourceforge.net/)? It's a wrapper based on GTK+.


-- 
jcc7
http://jcc_7.tripod.com/d/
April 09, 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Charles Hixson schrieb am Sat, 09 Apr 2005 14:53:55 -0700:
> Does anyone have examples of GTK code in D?
>
> Sorry, but my background doesn't include much C, so the standard examples don't help me much.
>
> What I'd like to do is put some text on a window, put a button with a pixmap on the window, and then change the color of the window whenever the button is pushed.

Might provide some hints:
http://dui.sourceforge.net/

Thomas


-----BEGIN PGP SIGNATURE-----

iD8DBQFCWGRW3w+/yD4P9tIRAh02AKCPiRF9oFJmuY+5VZ1Yo9QDTTwU/wCbBK/o
AzWXfxJv4e9fgGC9t6hK5SU=
=Bog6
-----END PGP SIGNATURE-----
April 09, 2005
J C Calvarese wrote:
> Charles Hixson wrote:
> 
>> Does anyone have examples of GTK code in D?
> 
> 
> Have you tried DUI (http://dui.sourceforge.net/)? It's a wrapper based on GTK+.
> 
> 
From what I seen of it (I haven't looked into it deeply) it's dependent on more than just GTK+.  For me this would be bad, because I want to port to multiple platforms:
Linux-86, Linux-PPC, MacOSX, and MSWind95.
I think I can get basic GTK on all of those (I'm not sure about MSWind95), but anything more...

That said, no, I haven't tried it.  It ought, if nothing else, to be a good source of examples.
April 11, 2005
Charles Hixson wrote:
> Does anyone have examples of GTK code in D?
> 
> Sorry, but my background doesn't include much C, so the standard examples don't help me much.

I suggest you learn GTK C before you learn GTK D.

Anyway, D GTK bindings are here... http://svn.dsource.org/svn/projects/bindings/trunk/

> 
> What I'd like to do is put some text on a window, put a button with a pixmap on the window, and then change the color of the window whenever the button is pushed.
> 
> (This is for a game on learning note names.  If I finish it, I'll gladly post it as a sample, but even though the Python original is working, I can't figure out how to get started on the D gtk interface.  Thanks to teqDruid<me@teqdruid.com> for the files, so I can see that it OUGHT to be possible.)


April 11, 2005
clayasaurus wrote:
> Charles Hixson wrote:
> 
>> Does anyone have examples of GTK code in D?
>>
>> Sorry, but my background doesn't include much C, so the standard examples don't help me much.
> 
> 
> I suggest you learn GTK C before you learn GTK D.
You may have a point, but that removes a lot of the reason for using D on this project.  O, well.

> 
> Anyway, D GTK bindings are here... http://svn.dsource.org/svn/projects/bindings/trunk/
> 
>>
>> What I'd like to do is put some text on a window, put a button with a pixmap on the window, and then change the color of the window whenever the button is pushed.
>>
>> (This is for a game on learning note names.  If I finish it, I'll gladly post it as a sample, but even though the Python original is working, I can't figure out how to get started on the D gtk interface.  Thanks to teqDruid<me@teqdruid.com> for the files, so I can see that it OUGHT to be possible.)
> 
> 
> 
April 12, 2005
Charles Hixson wrote:
> J C Calvarese wrote:
> 
>> Charles Hixson wrote:
>>
>>> Does anyone have examples of GTK code in D?
>>
>>
>>
>> Have you tried DUI (http://dui.sourceforge.net/)? It's a wrapper based on GTK+.
>>
>>
>  From what I seen of it (I haven't looked into it deeply) it's dependent on more than just GTK+.

there are no other dependencies.
things like zlib1.dll are required by gtk it self.
other like libpng are optional.

the plain gtk D bindings migth be better for you but anyway
here is the DUI code to do it, the functions names are similar
setBorderWidth was gtk_set_border_width.
/**
 * Modified HelloWorld
 */
class HelloWorld : MainWindow
{
	
	private import std.stdio;

	this()
	{
		super("DUI Hello World");
		setBorderWidth(100);
		Button button = new PixbufButton(logo, &buttonAction);
		
		add(button);

		show();
	}

	// the functionalities of this should be integrated into
	// the main class Button	
	class PixbufButton : Button
	{
		this(char** xpm, void delegate(Button) dlg)
		{
			super("", dlg);
			Pixbuf pixbuf = new Pixbuf(logo);
			removeAll();
			add(new Image(pixbuf));
			setBorderWidth(0);
			setRelief(ReliefStyle.NONE);
		}
	}
	
	ubyte cLevel;
	void buttonAction(Button button)
	{
		printf("Hello there\n");
		cLevel+=80;
		modifyBG(
		  StateType.NORMAL,
		  new Color(cLevel,cast(ubyte)0,cast(ubyte)(255-cLevel))
		);
	}
}

void main(char[][] args)
{
	DUI dui = DUI.dui(args);
	new HelloWorld();
	dui.go();
}


/* XPM */
static char** logo = [
"32 42 6 1",
"       c None",
".      c #FEFEFE",
"+      c #000000",
"@      c #0000FF",
"#      c #FF0000",
"$      c #00FF00",
"................................",
"................................",
"................................",
"...............+++++............",
".............+++@@++............",
"...........+++@@@@@@++..........",
"..........++@@@@@@@@@++.........",
"........+++@@+++++++@@+++.......",
"......+++@@+++++++++++@@@++.....",
"....+++@@@+++@@@@@@+++@@@@@+....",
"...++@@@@@++@@@@@@@@++@@@@@++...",
"...+@@@@@@++@@@@@@@@++@@@@@@@+..",
"..+++@@@@@++@@@@++@@@@@@@@@@@++.",
"..+#++@@@@++@@@@++++@@@@@@@++++.",
"..+##++@@@@+++@@@+++@@@@@++$$++.",
"..+###+++@@@+++++++@@@@+++$$$++.",
"..+####+++@@@@@+@@@@+++$$$$$$+..",
"..+######+++@@@@@@@+++$$$$$$$+..",
"..+##++###+++@@@@+++$$$$$++$$+..",
"..+##+++###+++@@++$$$$$$$++$$+..",
"..+##+++++###+++$$$$$$$$++$$$+..",
"..+##+++++++##++$$++$$$++$$$$+..",
"..+####++++++#++$$+++$+++$$$$+..",
"..+####++++++#++$$+++$+++$$$+...",
"..+####+++#++#++$$+++++$$$$$+...",
"..+####+++##+#++$$+++++$$$$$+...",
"..+####+++####++$$+++++++$$$+...",
"..+####+++####++$$++$$+++++$+...",
"..+####+++####++$$++$$$$++$$++..",
"..+####+++####++$$++$$$$$$$+++..",
"...+####++####++$$++$$$$$$$++...",
"....+#########++$$++$$$$$$++....",
".....+########++$$+$$$$$$++.....",
"......+#######++$$$$$$$+++......",
".......++#####++$$$$$$++........",
"........++####++$$$$++..........",
".........++###++$$$+++..........",
"...........+##++$++.............",
"............++++++..............",
".............+++................",
"..............+.................",
"................................"];


here's what users say about DUI:
"[DUI] is great to use"
http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.dtl/314

"I REALLY REALLY REALLY like DUI. It's sosoooasy to use :)"
"Kenny B
April 15, 2005

You don't even need to learn GTK. Get GLADE, it's a wysiwyg Gtk gui builder that will output a XML file. Then use the libglade binding (it's on dsource) and with 3 or 4 lines of D code, you can dynamically load the XML file etc... sooo easy.

GLADE RULEZ !



Le Sat, 09 Apr 2005 14:53:55 -0700, Charles Hixson a écrit :

> Does anyone have examples of GTK code in D?
> 
> Sorry, but my background doesn't include much C, so the standard examples don't help me much.
> 
> What I'd like to do is put some text on a window, put a button with a pixmap on the window, and then change the color of the window whenever the button is pushed.
> 
> (This is for a game on learning note names.  If I finish it, I'll gladly post it as a sample, but even though the Python original is working, I can't figure out how to get started on the D gtk interface.  Thanks to teqDruid<me@teqdruid.com> for the files, so I can see that it OUGHT to be possible.)

April 16, 2005
G.Vidal wrote:
> You don't even need to learn GTK. Get GLADE, it's a wysiwyg Gtk gui
> builder that will output a XML file. Then use the libglade binding (it's
> on dsource) and with 3 or 4 lines of D code, you can dynamically load the
> XML file etc... sooo easy.

Interesting... I'm actually in the middle of setting up something similar for Win32 (in the middle means I just finished the (fairly minimalistic) XML parser).  Its part of a library I've been working on for one reason and one reason only: I could use it myself, and I wanted to test a couple of ideas.  One of them being this "store a GUI as an XML file" thing.

What does the GLADE XML look like?  My CGX (Casal GUI XML) files look something like this:
# <AppFrame caption="Test Window" controls="min,max" icon="file:icon.bmp" width="640" height="480" position="center">
#     <BorderLayout north="*,20%" south="*,20%" east="20%,*" west="20%,*">
#         <Label position="north" caption="Hello World, from Casual Win32!" name="top text"/>
#         <Panel position="west">
#             <ColumnLayout>
#                 <Button caption="Text 1" action="appframe text 1" />
#                 <Button caption="Text 2" action="appframe text 2" />
#             </ColumnLayout>
#         </Panel>
#         <Label position="center" caption="Just a simple demonstration application that does extremely little.  Play around with the buttons a bit, and check out the file 'text.cgx' where this entire GUI is defined!  Amazing, huh?" />
#         <Button position="east" caption="Press me!" action="appframe pressme" name="pressme button" />
#         <Panel position="south">
#             <Button caption="Minimize" action="appframe min" name="min/max button" />
#             <Button caption="Exit" action="app exit" />
#         </Panel>
#     </BorderLayout>
# </AppFrame>

I have a singleton called CgxManager (module casual.cgx.manager) which can be notified of new classes implementing interface ICgxWidget (module casual.cgx.widget) and thus expand on what can be put in the CGX file. But... this thing is going to be forever in coming, so I should hush about it.

-- Chris Sauls
April 17, 2005
Le Sat, 16 Apr 2005 12:59:51 -0500, Chris Sauls a écrit :


> Interesting... I'm actually in the middle of setting up something similar for Win32 (in the middle means I just finished the (fairly minimalistic) XML parser).  Its part of a library I've been working on for one reason and one reason only: I could use it myself, and I wanted to test a couple of ideas.  One of them being this "store a GUI as an XML file" thing.


win32 ? I didn't know people were still using this sh**... anyway, you can use libglade under win32 as there's GTK2 dlls for win32...

A GLADE XML file looks like this:

<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">

<glade-interface>

<widget class="GtkWindow" id="window1">
  <property name="visible">True</property>
  <property name="title" translatable="yes">This is a test</property>
  <property name="type">GTK_WINDOW_TOPLEVEL</property>
  <property name="window_position">GTK_WIN_POS_NONE</property>
  <property name="modal">False</property>
  <property name="resizable">True</property>
  <property name="destroy_with_parent">True</property>
  <property name="decorated">True</property>
  <property name="skip_taskbar_hint">False</property>
  <property name="skip_pager_hint">False</property>
  <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
  <property name="focus_on_map">True</property>

  <child>
    <widget class="GtkButton" id="button1">
      <property name="visible">True</property>
      <property name="can_focus">True</property>
      <property name="relief">GTK_RELIEF_NORMAL</property>
      <property name="focus_on_click">True</property>
      <signal name="clicked" handler="on_button1_clicked" last_modification_time="Sun, 17 Apr 2005 10:27:51 GMT"/>

      <child>
	<widget class="GtkAlignment" id="alignment1">
	  <property name="visible">True</property>
	  <property name="xalign">0.5</property>
	  <property name="yalign">0.5</property>
	  <property name="xscale">0</property>
	  <property name="yscale">0</property>
	  <property name="top_padding">0</property>
	  <property name="bottom_padding">0</property>
	  <property name="left_padding">0</property>
	  <property name="right_padding">0</property>

	  <child>
	    <widget class="GtkHBox" id="hbox1">
	      <property name="visible">True</property>
	      <property name="homogeneous">False</property>
	      <property name="spacing">2</property>

	      <child>
		<widget class="GtkImage" id="image1">
		  <property name="visible">True</property>
		  <property name="stock">gtk-jump-to</property>
		  <property name="icon_size">4</property>
		  <property name="xalign">0.5</property>
		  <property name="yalign">0.5</property>
		  <property name="xpad">0</property>
		  <property name="ypad">0</property>
		</widget>
		<packing>
		  <property name="padding">0</property>
		  <property name="expand">False</property>
		  <property name="fill">False</property>
		</packing>
	      </child>

	      <child>
		<widget class="GtkLabel" id="label1">
		  <property name="visible">True</property>
		  <property name="label" translatable="yes">Click me !</property>
		  <property name="use_underline">True</property>
		  <property name="use_markup">False</property>
		  <property name="justify">GTK_JUSTIFY_LEFT</property>
		  <property name="wrap">False</property>
		  <property name="selectable">False</property>
		  <property name="xalign">0.5</property>
		  <property name="yalign">0.5</property>
		  <property name="xpad">0</property>
		  <property name="ypad">0</property>
		  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
		  <property name="width_chars">-1</property>
		  <property name="single_line_mode">False</property>
		  <property name="angle">0</property>
		</widget>
		<packing>
		  <property name="padding">0</property>
		  <property name="expand">False</property>
		  <property name="fill">False</property>
		</packing>
	      </child>
	    </widget>
	  </child>
	</widget>
      </child>
    </widget>
  </child>
</widget>

</glade-interface>


See ya

« First   ‹ Prev
1 2