[Mono-list] Basic Glade# question

Ian Parish iparish@novell.com
Tue, 25 Jan 2005 08:57:37 -0700


This is a MIME message. If you are reading this text, you may want to 
consider changing to a mail reader or gateway that understands how to 
properly handle MIME multipart messages.

--=__PartD2F26861.1__=
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

I'm about 2 weeks ahead of you in learning this functionality. 
 
Here's a section of code that I found that does what you are asking
about for dialog1.  But I have seen a problem with the
dialog1.AutoConnection(this) call.  It seems to disconnect the top level
In this example iconlist1 is set to null.  So when I click another menu
option reference to iconList I get Null Pointer exception.  Maybe
someone can help or provide some info about using another ConnectEvent()
method. 
 
As another Note, This took me a long time to figure out. There is a
difference between Close of a Dialog and the Delete Event.  The close is
called as a signal to a button on the dialog.  This doesnot remove the
instantiation of the dialog from memory  so .hide() is used.  The Delete
event on the other hand clears the memory reference so if the dialog is
invoked again it needs to be created again. 
 
void on_dialog1_close  (object o, EventArgs args) 
{ 
 System.Console.WriteLine(Clicked File-Verify dialog1_close); 
 
dialog1.Hide();  //Dialog1 Stays set in memory 
} 
 
public void on_dialog1_delete_event  (object o, EventArgs args) 
{ 
 System.Console.WriteLine(Clicked File-Verify dialog1_delete); 
dialog1 = null;  //dialog1 is deleted. 
} 
 
 
 
        public static void Main (string[] args) 
        { 
                new GladeApp (args); 
        } 
 
        public GladeApp (string[] args) 
        { 
           Application.Init(); 
 
           Glade.XML gxml = new Glade.XML (null, nal.glade, Nal, null); 
           gxml.Autoconnect (this); 
 
           iconlist1 = (Gnome.IconList)gxml.GetWidget(iconlist1); 
 
          Application.Run(); 
         
         }     
 
        public void on_verify1_activate  (object o, EventArgs args) 
 { 
  
 //  This is a Test and Only a Test.  When this silly little dialog pops
it's only a Test. 
 //  In the event of an actual emergency you will be informed. 
  
 System.Console.WriteLine(Clicked File-Verify); 
  
 if (dialog1 == null) 
{ 
System.Console.WriteLine(Clicked File-verify newPropertyBox == null); 
 
newDialogXML = new Glade.XML (null, nal.glade, dialog1, null); 
dialog1 = (Gtk.Dialog)newDialogXML.GetWidget(dialog1); 
 
} 
else 
{ 
System.Console.WriteLine(Clicked File-Properties  Else); 
 
dialog1.Show(); 
} 
 } 
 
 public void on_dialog1_close  (object o, EventArgs args) 
{ 
 System.Console.WriteLine(Clicked File-Verify dialog1_close); 
 
dialog1.Hide(); 
} 
 
public void on_dialog1_delete_event  (object o, EventArgs args) 
{ 
 System.Console.WriteLine(Clicked File-Verify dialog1_delete); 
dialog1 = null; 
} 
 
Ian 
 


>>>Jonas Geiregat <jonas.geiregat@gmail.com> 01/25/05 7:34 am >>>
>>Again I'm sorry for such a newbie question, but I couldn't find it
>>anywhere w/ google.  If anybody knows of a nice, extensive Glade# or
>>GTK# tutorial, let me know!

If you can wait untill the end of this week , then I'll have my Gtk#
with Glade# tutorial finished. I'll drop a reply when it's done here.

>
>Mono-list maillist  -  Mono-list@lists.ximian.com
>http://lists.ximian.com/mailman/listinfo/mono-list
>

Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


--=__PartD2F26861.1__=
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<html>
  <head>
    <style type=3D"text/css">
      <!--
        body { line-height: normal; margin-top: 4px; font-variant: normal; =
margin-bottom: 1px; margin-left: 4px; margin-right: 4px }
      -->
    </style>
   =20
  </head>
  <body style=3D"margin-top: 4px; margin-bottom: 1px; margin-left: 4px; =
margin-right: 4px">
    <DIV>      I&#39;m about 2 weeks ahead of you in learning this =
functionality.
    </DIV>
    <DIV>&nbsp;</DIV>
    <DIV>Here&#39;s a section of code that I found that does what you are =
asking about for dialog1. &nbsp;But I have seen a problem with the =
dialog1.AutoConnection&#40;this&#41; call. &nbsp;It seems to &quot;disconne=
ct&quot; the top level In this example iconlist1 is set to null. &nbsp;So =
when I click another menu option reference to iconList I get Null Pointer =
exception. &nbsp;Maybe someone can help or provide some info about using =
another ConnectEvent&#40;&#41; method.
    </DIV>
    <DIV>&nbsp;</DIV>
    <DIV>As another Note&#44; This took me a long time to figure out. =
There is a difference between &quot;Close&quot; of a Dialog and the Delete =
Event. &nbsp;The close is called as a signal to a button on the dialog. =
&nbsp;This doesnot remove the instantiation of the dialog from memory =
&nbsp;so .hide&#40;&#41; is used. &nbsp;The Delete event on the other hand =
clears the memory reference so if the dialog is invoked again it needs to =
be created again.
    </DIV>

    <DIV>&nbsp;</DIV>
    <DIV>
      void on_dialog1_close&nbsp;&#160;&#40;object o&#44; EventArgs =
args&#41;
    </DIV>
    <DIV>
      &#123;
    </DIV>
    <DIV>
      &#160;System.Console.WriteLine&#40;&quot;Clicked File-Verify =
dialog1_close&quot;&#41;&#59;
    </DIV>
    <DIV>&nbsp;</DIV>
    <DIV>
      dialog1.Hide&#40;&#41;&#59; &nbsp;//Dialog1 Stays set in memory
    </DIV>
    <DIV>
      &#125;
    </DIV>
    <DIV>&nbsp;</DIV>
    <DIV>
      public void on_dialog1_delete_event&nbsp;&#160;&#40;object o&#44; =
EventArgs args&#41;
    </DIV>
    <DIV>
      &#123;
    </DIV>
    <DIV>
      &#160;System.Console.WriteLine&#40;&quot;Clicked File-Verify =
dialog1_delete&quot;&#41;&#59;
    </DIV>
    <DIV>
      dialog1 &#61; null&#59; &nbsp;//dialog1 is deleted.
    </DIV>
    <DIV>
      &#125;
    </DIV>
    <DIV>&nbsp;</DIV>
    <DIV>&nbsp;</DIV>
    <DIV>&nbsp;</DIV>
    <DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public static =
void Main &#40;string&#91;&#93; args&#41;
    </DIV>
    <DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;
    </DIV>
    <DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new GladeApp &#40;args&#41;&#59;
    </DIV>
    <DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;
    </DIV>
    <DIV>&nbsp;</DIV>
    <DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public GladeApp =
&#40;string&#91;&#93; args&#41;=20
    </DIV>
    <DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;
    </DIV>
    <DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
Application.Init&#40;&#41;&#59;
    </DIV>
    <DIV>&nbsp;</DIV>
    <DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
Glade.XML gxml &#61; new Glade.XML &#40;null&#44; &quot;nal.glade&quot;&#44=
; &quot;Nal&quot;&#44; null&#41;&#59;
    </DIV>
    <DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
gxml.Autoconnect &#40;this&#41;&#59;
    </DIV>
    <DIV>&nbsp;</DIV>
    <DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
iconlist1 &#61; &#40;Gnome.IconList&#41;gxml.GetWidget&#40;&quot;iconlist1&=
quot;&#41;&#59;
    </DIV>
    <DIV>&nbsp;</DIV>
    <DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Applic=
ation.Run&#40;&#41;&#59;
    </DIV>
    <DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    </DIV>
    <DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;&nbsp;=
&nbsp;&nbsp;&nbsp;
    </DIV>
    <DIV>&nbsp;</DIV>
    <DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public void =
on_verify1_activate &nbsp;&#40;object o&#44; EventArgs args&#41;
    </DIV>
    <DIV>&nbsp;&#123;
    </DIV>
    <DIV>&nbsp;
    </DIV>
    <DIV>&nbsp;// &nbsp;This is a Test and Only a Test. &nbsp;When this =
silly little dialog pops it&#39;s only a Test.
    </DIV>
    <DIV>&nbsp;// &nbsp;In the event of an actual emergency you will be =
informed.
    </DIV>
    <DIV>&nbsp;
    </DIV>
    <DIV>&nbsp;System.Console.WriteLine&#40;&quot;Clicked File-Verify&quot;=
&#41;&#59;
    </DIV>
    <DIV>&nbsp;
    </DIV>
    <DIV>&nbsp;if &#40;dialog1 &#61;&#61; null&#41;
    </DIV>
    <DIV>&#123;
    </DIV>
    <DIV>System.Console.WriteLine&#40;&quot;Clicked File-verify newProperty=
Box &#61;&#61; null&quot;&#41;&#59;
    </DIV>
    <DIV>&nbsp;</DIV>
    <DIV> newDialogXML &#61; new Glade.XML &#40;null&#44; &quot;nal.glade&q=
uot;&#44; &quot;dialog1&quot;&#44; null&#41;&#59;
    </DIV>
    <DIV>dialog1 &#61; &#40;Gtk.Dialog&#41;newDialogXML.GetWidget&#40;&quot=
;dialog1&quot;&#41;&#59;
    </DIV>
    <DIV>&nbsp;</DIV>
    <DIV>&#125;
    </DIV>
    <DIV>else
    </DIV>
    <DIV>&#123;
    </DIV>
    <DIV> System.Console.WriteLine&#40;&quot;Clicked File-Properties =
&nbsp;Else&quot;&#41;&#59;
    </DIV>
    <DIV>&nbsp;</DIV>
    <DIV>dialog1.Show&#40;&#41;&#59;
    </DIV>
    <DIV>&#125;
    </DIV>
    <DIV>&nbsp;&#125;
    </DIV>
    <DIV>&nbsp;</DIV>
    <DIV>&nbsp;public void on_dialog1_close &nbsp;&#40;object o&#44; =
EventArgs args&#41;
    </DIV>
    <DIV>&#123;
    </DIV>
    <DIV>&nbsp;System.Console.WriteLine&#40;&quot;Clicked File-Verify =
dialog1_close&quot;&#41;&#59;
    </DIV>
    <DIV>&nbsp;</DIV>
    <DIV>dialog1.Hide&#40;&#41;&#59;
    </DIV>
    <DIV>&#125;
    </DIV>
    <DIV>&nbsp;</DIV>
    <DIV>public void on_dialog1_delete_event &nbsp;&#40;object o&#44; =
EventArgs args&#41;
    </DIV>
    <DIV>&#123;
    </DIV>
    <DIV>&nbsp;System.Console.WriteLine&#40;&quot;Clicked File-Verify =
dialog1_delete&quot;&#41;&#59;
    </DIV>
    <DIV>dialog1 &#61; null&#59;
    </DIV>
    <DIV>&#125;
    </DIV>
    <DIV>&nbsp;</DIV>
    <DIV>Ian
    </DIV>
    <DIV>&nbsp;</DIV>
    <DIV><br><br>&gt;&gt;&gt;Jonas Geiregat &lt;jonas.geiregat@gmail.com&gt=
; 01/25/05 7:34 am &gt;&gt;&gt;<br>&gt;&gt;Again I&#39;m sorry for such a =
newbie question&#44; but I couldn&#39;t find it<br>&gt;&gt;anywhere w/ =
google.&#160;&nbsp;If anybody knows of a nice&#44; extensive Glade&#35; =
or<br>&gt;&gt;GTK&#35; tutorial&#44; let me know&#33;<br><br>If you can =
wait untill the end of this week &#44; then I&#39;ll have my Gtk&#35;<br>wi=
th Glade&#35; tutorial finished. I&#39;ll drop a reply when it&#39;s done =
here.<br><br>&gt;<br>&gt;Mono-list maillist&#160;&nbsp;-&#160;&nbsp;Mono-li=
st@lists.ximian.com<br>&gt;http://lists.ximian.com/mailman/listinfo/mono-li=
st<br>&gt;<br><br>Mono-list maillist&#160;&nbsp;-&#160;&nbsp;Mono-list@list=
s.ximian.com<br>http://lists.ximian.com/mailman/listinfo/mono-list<br>    =
</DIV>

  </body>
</html>

--=__PartD2F26861.1__=--