mail-archives/gtk-sharp-list/2003-February/000890.html

378 строки
14 KiB
HTML
Исходник Обычный вид История

2019-06-06 22:02:55 +03:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Gtk-sharp-list] Gnome# Hello World
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:farrisg%40mala.bc.ca">
<META NAME="robots" CONTENT="index,nofollow">
<LINK REL="Previous" HREF="000909.html">
<LINK REL="Next" HREF="000893.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Gtk-sharp-list] Gnome# Hello World
</H1>
<B>George Farris
</B>
<A HREF="mailto:farrisg%40mala.bc.ca"
TITLE="[Gtk-sharp-list] Gnome# Hello World">farrisg@mala.bc.ca
</A><BR>
<I>05 Feb 2003 09:22:49 -0800</I>
<P><UL>
<LI> Previous message: <A HREF="000909.html">[Gtk-sharp-list] Gnome# Hello World - Revised Version 2
</A></li>
<LI> Next message: <A HREF="000893.html">[Gtk-sharp-list] Gnome# Hello World
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#890">[ date ]</a>
<a href="thread.html#890">[ thread ]</a>
<a href="subject.html#890">[ subject ]</a>
<a href="author.html#890">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>How about something like this:
Possibly a smaller glade file for the example would be better.
Makefile ------------------------------------------------
MCS = mcs
RESOURCES = /resource:./hello.glade,hello.glade
REFERENCES = -r gnome-sharp -r gtk-sharp -r glib-sharp -r glade-sharp -r
gdk-sharp
SOURCES = hello.cs
all: hello.exe
hello.exe: $(SOURCES)
$(MCS) $(RESOURCES) -o $@ $(SOURCES) $(REFERENCES)
clean:
-rm *.exe *.bak *~
hello.cs file -------------------------------------------------
namespace hello {
using System;
using System.IO;
using GLib;
using Gtk;
using Gnome;
using Glade;
using GtkSharp;
public class hello : Program
{
Glade.XML gxml;
public static void Main (string[] args)
{
hello a = new hello (args);
}
public hello (string[] args)
: base (&quot;hello&quot;, &quot;0.1&quot;, Modules.UI, args, new object [0])
{
Application.Init ();
gxml = new Glade.XML (null, &quot;hello.glade&quot;, &quot;app1&quot;, null);
gxml.Autoconnect (this);
Application.Run ();
}
//
// Glade callbacks that are auto connected
//
private void on_quit1_activate (object o, EventArgs args)
{
Console.WriteLine(&quot;Goodbye...&quot;);
Application.Quit ();
}
private void on_app1_delete_event (object o, DeleteEventArgs args)
{
Application.Quit ();
args.RetVal = true;
}
private void on_about1_activate (object o, EventArgs args)
{
Gdk.Pixbuf icon = new Gdk.Pixbuf (&quot;/usr/share/pixmaps&quot; +
Path.DirectorySeparatorChar + &quot;gnome-logo-icon.png&quot;);
string[] authors = new string[] { &quot;Your Name &lt;<A HREF="mailto:email@anon.com">email@anon.com</A>&gt;&quot; };
string[] documentors = new string[] {};
About about = new About (&quot;&quot;, &quot;&quot;, &quot;Copyright (C) 2003 Your Name
&lt;<A HREF="mailto:email@anon.com">email@anon.com</A>&gt;&quot;, &quot;A Test application for GNOME&quot;, authors, documentors,
&quot;&quot;, icon);
about.Show ();
}
private void on_newButton_clicked (object o, EventArgs args)
{
Console.WriteLine(&quot;[New] button clicked&quot;);
}
private void on_openButton_clicked (object o, EventArgs args)
{
Console.WriteLine(&quot;[Open] button clicked&quot;);
}
private void on_saveButton_clicked (object o, EventArgs args)
{
Console.WriteLine(&quot;[Save] button clicked&quot;);
}
}
}
Glade file ------------------------------------------
&lt;?xml version=&quot;1.0&quot; standalone=&quot;no&quot;?&gt; &lt;!--*- mode: xml -*--&gt;
&lt;!DOCTYPE glade-interface SYSTEM &quot;<A HREF="http://glade.gnome.org/glade-2.0.dtd"">http://glade.gnome.org/glade-2.0.dtd&quot;</A>&gt;
&lt;glade-interface&gt;
&lt;requires lib=&quot;gnome&quot;/&gt;
&lt;requires lib=&quot;bonobo&quot;/&gt;
&lt;widget class=&quot;GnomeApp&quot; id=&quot;app1&quot;&gt;
&lt;property name=&quot;visible&quot;&gt;True&lt;/property&gt;
&lt;property name=&quot;title&quot; translatable=&quot;yes&quot;&gt;Test.glade&lt;/property&gt;
&lt;property name=&quot;type&quot;&gt;GTK_WINDOW_TOPLEVEL&lt;/property&gt;
&lt;property name=&quot;window_position&quot;&gt;GTK_WIN_POS_NONE&lt;/property&gt;
&lt;property name=&quot;modal&quot;&gt;False&lt;/property&gt;
&lt;property name=&quot;resizable&quot;&gt;True&lt;/property&gt;
&lt;property name=&quot;destroy_with_parent&quot;&gt;False&lt;/property&gt;
&lt;property name=&quot;enable_layout_config&quot;&gt;True&lt;/property&gt;
&lt;signal name=&quot;delete_event&quot; handler=&quot;on_app1_delete_event&quot;
last_modification_time=&quot;Mon, 27 Jan 2003 21:23:47 GMT&quot;/&gt;
&lt;child internal-child=&quot;dock&quot;&gt;
&lt;widget class=&quot;BonoboDock&quot; id=&quot;bonobodock1&quot;&gt;
&lt;property name=&quot;visible&quot;&gt;True&lt;/property&gt;
&lt;property name=&quot;allow_floating&quot;&gt;True&lt;/property&gt;
&lt;child&gt;
&lt;widget class=&quot;BonoboDockItem&quot; id=&quot;bonobodockitem1&quot;&gt;
&lt;property name=&quot;visible&quot;&gt;True&lt;/property&gt;
&lt;property name=&quot;shadow_type&quot;&gt;GTK_SHADOW_NONE&lt;/property&gt;
&lt;child&gt;
&lt;widget class=&quot;GtkMenuBar&quot; id=&quot;menubar1&quot;&gt;
&lt;property name=&quot;visible&quot;&gt;True&lt;/property&gt;
&lt;child&gt;
&lt;widget class=&quot;GtkMenuItem&quot; id=&quot;file1&quot;&gt;
&lt;property name=&quot;visible&quot;&gt;True&lt;/property&gt;
&lt;property name=&quot;stock_item&quot;&gt;GNOMEUIINFO_MENU_FILE_TREE&lt;/property&gt;
&lt;child&gt;
&lt;widget class=&quot;GtkMenu&quot; id=&quot;file1_menu&quot;&gt;
&lt;child&gt;
&lt;widget class=&quot;GtkMenuItem&quot; id=&quot;separator1&quot;&gt;
&lt;property name=&quot;visible&quot;&gt;True&lt;/property&gt;
&lt;/widget&gt;
&lt;/child&gt;
&lt;child&gt;
&lt;widget class=&quot;GtkImageMenuItem&quot; id=&quot;quit1&quot;&gt;
&lt;property name=&quot;visible&quot;&gt;True&lt;/property&gt;
&lt;property name=&quot;stock_item&quot;&gt;GNOMEUIINFO_MENU_EXIT_ITEM&lt;/property&gt;
&lt;signal name=&quot;activate&quot; handler=&quot;on_quit1_activate&quot;
last_modification_time=&quot;Mon, 27 Jan 2003 21:10:35 GMT&quot;/&gt;
&lt;/widget&gt;
&lt;/child&gt;
&lt;/widget&gt;
&lt;/child&gt;
&lt;/widget&gt;
&lt;/child&gt;
&lt;child&gt;
&lt;widget class=&quot;GtkMenuItem&quot; id=&quot;help1&quot;&gt;
&lt;property name=&quot;visible&quot;&gt;True&lt;/property&gt;
&lt;property name=&quot;stock_item&quot;&gt;GNOMEUIINFO_MENU_HELP_TREE&lt;/property&gt;
&lt;child&gt;
&lt;widget class=&quot;GtkMenu&quot; id=&quot;help1_menu&quot;&gt;
&lt;child&gt;
&lt;widget class=&quot;GtkImageMenuItem&quot; id=&quot;about1&quot;&gt;
&lt;property name=&quot;visible&quot;&gt;True&lt;/property&gt;
&lt;property name=&quot;stock_item&quot;&gt;GNOMEUIINFO_MENU_ABOUT_ITEM&lt;/property&gt;
&lt;signal name=&quot;activate&quot; handler=&quot;on_about1_activate&quot;
last_modification_time=&quot;Mon, 27 Jan 2003 21:10:35 GMT&quot;/&gt;
&lt;/widget&gt;
&lt;/child&gt;
&lt;/widget&gt;
&lt;/child&gt;
&lt;/widget&gt;
&lt;/child&gt;
&lt;/widget&gt;
&lt;/child&gt;
&lt;/widget&gt;
&lt;packing&gt;
&lt;property name=&quot;placement&quot;&gt;BONOBO_DOCK_TOP&lt;/property&gt;
&lt;property name=&quot;band&quot;&gt;0&lt;/property&gt;
&lt;property name=&quot;position&quot;&gt;0&lt;/property&gt;
&lt;property name=&quot;offset&quot;&gt;0&lt;/property&gt;
&lt;property
name=&quot;behavior&quot;&gt;BONOBO_DOCK_ITEM_BEH_EXCLUSIVE|BONOBO_DOCK_ITEM_BEH_NEVER_VERTICAL|BONOBO_DOCK_ITEM_BEH_LOCKED&lt;/property&gt;
&lt;/packing&gt;
&lt;/child&gt;
&lt;child&gt;
&lt;widget class=&quot;BonoboDockItem&quot; id=&quot;bonobodockitem2&quot;&gt;
&lt;property name=&quot;visible&quot;&gt;True&lt;/property&gt;
&lt;property name=&quot;shadow_type&quot;&gt;GTK_SHADOW_OUT&lt;/property&gt;
&lt;child&gt;
&lt;widget class=&quot;GtkToolbar&quot; id=&quot;toolbar1&quot;&gt;
&lt;property name=&quot;border_width&quot;&gt;1&lt;/property&gt;
&lt;property name=&quot;visible&quot;&gt;True&lt;/property&gt;
&lt;property
name=&quot;orientation&quot;&gt;GTK_ORIENTATION_HORIZONTAL&lt;/property&gt;
&lt;property name=&quot;toolbar_style&quot;&gt;GTK_TOOLBAR_BOTH&lt;/property&gt;
&lt;property name=&quot;tooltips&quot;&gt;True&lt;/property&gt;
&lt;child&gt;
&lt;widget class=&quot;button&quot; id=&quot;newButton&quot;&gt;
&lt;property name=&quot;visible&quot;&gt;True&lt;/property&gt;
&lt;property name=&quot;tooltip&quot; translatable=&quot;yes&quot;&gt;New File&lt;/property&gt;
&lt;property name=&quot;label&quot;&gt;gtk-new&lt;/property&gt;
&lt;property name=&quot;use_stock&quot;&gt;True&lt;/property&gt;
&lt;signal name=&quot;clicked&quot; handler=&quot;on_newButton_clicked&quot;
last_modification_time=&quot;Wed, 29 Jan 2003 04:31:30 GMT&quot;/&gt;
&lt;/widget&gt;
&lt;/child&gt;
&lt;child&gt;
&lt;widget class=&quot;button&quot; id=&quot;openButton&quot;&gt;
&lt;property name=&quot;visible&quot;&gt;True&lt;/property&gt;
&lt;property name=&quot;tooltip&quot; translatable=&quot;yes&quot;&gt;Open File&lt;/property&gt;
&lt;property name=&quot;label&quot;&gt;gtk-open&lt;/property&gt;
&lt;property name=&quot;use_stock&quot;&gt;True&lt;/property&gt;
&lt;signal name=&quot;clicked&quot; handler=&quot;on_openButton_clicked&quot;
last_modification_time=&quot;Wed, 29 Jan 2003 04:31:08 GMT&quot;/&gt;
&lt;/widget&gt;
&lt;/child&gt;
&lt;child&gt;
&lt;widget class=&quot;button&quot; id=&quot;saveButton&quot;&gt;
&lt;property name=&quot;visible&quot;&gt;True&lt;/property&gt;
&lt;property name=&quot;tooltip&quot; translatable=&quot;yes&quot;&gt;Save File&lt;/property&gt;
&lt;property name=&quot;label&quot;&gt;gtk-save&lt;/property&gt;
&lt;property name=&quot;use_stock&quot;&gt;True&lt;/property&gt;
&lt;signal name=&quot;clicked&quot; handler=&quot;on_saveButton_clicked&quot;
last_modification_time=&quot;Wed, 29 Jan 2003 04:31:49 GMT&quot;/&gt;
&lt;/widget&gt;
&lt;/child&gt;
&lt;/widget&gt;
&lt;/child&gt;
&lt;/widget&gt;
&lt;packing&gt;
&lt;property name=&quot;placement&quot;&gt;BONOBO_DOCK_TOP&lt;/property&gt;
&lt;property name=&quot;band&quot;&gt;1&lt;/property&gt;
&lt;property name=&quot;position&quot;&gt;0&lt;/property&gt;
&lt;property name=&quot;offset&quot;&gt;0&lt;/property&gt;
&lt;property name=&quot;behavior&quot;&gt;BONOBO_DOCK_ITEM_BEH_EXCLUSIVE&lt;/property&gt;
&lt;/packing&gt;
&lt;/child&gt;
&lt;child&gt;
&lt;widget class=&quot;GtkLabel&quot; id=&quot;label1&quot;&gt;
&lt;property name=&quot;visible&quot;&gt;True&lt;/property&gt;
&lt;property name=&quot;label&quot; translatable=&quot;yes&quot;&gt;Hello World&lt;/property&gt;
&lt;property name=&quot;use_underline&quot;&gt;False&lt;/property&gt;
&lt;property name=&quot;use_markup&quot;&gt;False&lt;/property&gt;
&lt;property name=&quot;justify&quot;&gt;GTK_JUSTIFY_LEFT&lt;/property&gt;
&lt;property name=&quot;wrap&quot;&gt;False&lt;/property&gt;
&lt;property name=&quot;selectable&quot;&gt;False&lt;/property&gt;
&lt;property name=&quot;xalign&quot;&gt;0.5&lt;/property&gt;
&lt;property name=&quot;yalign&quot;&gt;0.5&lt;/property&gt;
&lt;property name=&quot;xpad&quot;&gt;0&lt;/property&gt;
&lt;property name=&quot;ypad&quot;&gt;0&lt;/property&gt;
&lt;/widget&gt;
&lt;/child&gt;
&lt;/widget&gt;
&lt;packing&gt;
&lt;property name=&quot;padding&quot;&gt;0&lt;/property&gt;
&lt;property name=&quot;expand&quot;&gt;True&lt;/property&gt;
&lt;property name=&quot;fill&quot;&gt;True&lt;/property&gt;
&lt;/packing&gt;
&lt;/child&gt;
&lt;child internal-child=&quot;appbar&quot;&gt;
&lt;widget class=&quot;GnomeAppBar&quot; id=&quot;appbar1&quot;&gt;
&lt;property name=&quot;visible&quot;&gt;True&lt;/property&gt;
&lt;property name=&quot;has_progress&quot;&gt;True&lt;/property&gt;
&lt;property name=&quot;has_status&quot;&gt;True&lt;/property&gt;
&lt;/widget&gt;
&lt;packing&gt;
&lt;property name=&quot;padding&quot;&gt;0&lt;/property&gt;
&lt;property name=&quot;expand&quot;&gt;True&lt;/property&gt;
&lt;property name=&quot;fill&quot;&gt;True&lt;/property&gt;
&lt;/packing&gt;
&lt;/child&gt;
&lt;/widget&gt;
&lt;/glade-interface&gt;
On Tue, 2003-02-04 at 23:52, Charles Iliya Krempeaux wrote:
&gt;<i> Hello,
</I>&gt;<i>
</I>&gt;<i> I don't know if anyone has done this yet (on the MonkeyGuide),
</I>&gt;<i> but they might find this useful. Also, people just getting
</I>&gt;<i> into Gtk# might find this useful too. It is a Hello World program
</I>&gt;<i> for Gnome#. (Similar to the Gtk# one.)
</I>&gt;<i>
</I>&gt;<i> class Hello
</I>&gt;<i> {
</I>&gt;<i> static Main()
</I>&gt;<i> {
</I>&gt;<i> Gtk.Application.Init();
</I>&gt;<i>
</I>&gt;<i> Gnome.App app = new Gnome.App(&quot;Hello World&quot;, &quot;Hello World&quot;);
</I>&gt;<i> app.Show();
</I>&gt;<i>
</I>&gt;<i> Gtk.Application.Run();
</I>&gt;<i> }
</I>&gt;<i> }
</I>&gt;<i>
</I>&gt;<i>
</I>&gt;<i> Although I am not really sure if &quot;Gtk.Application.Init()&quot; and
</I>&gt;<i> &quot;Gtk.Application.Run()&quot; are suppose to be called. (Or if a
</I>&gt;<i> GNOME equivalent is suppose to be called.)
</I>&gt;<i>
</I>&gt;<i> (BTW, does anyone know when the GNOME 2 API docs are going to be
</I>&gt;<i> put on the developer.gnome.org website???)
</I>&gt;<i>
</I>&gt;<i>
</I>&gt;<i> See ya
</I>--
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI> Previous message: <A HREF="000909.html">[Gtk-sharp-list] Gnome# Hello World - Revised Version 2
</A></li>
<LI> Next message: <A HREF="000893.html">[Gtk-sharp-list] Gnome# Hello World
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#890">[ date ]</a>
<a href="thread.html#890">[ thread ]</a>
<a href="subject.html#890">[ subject ]</a>
<a href="author.html#890">[ author ]</a>
</LI>
</UL>
</body></html>