<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-12723914</id><updated>2011-09-06T01:17:17.476-07:00</updated><title type='text'>Computer Programming Today</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://programmingtoday.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12723914/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://programmingtoday.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Beer</name><uri>http://www.blogger.com/profile/04059827588058182222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-12723914.post-111818368942752913</id><published>2005-06-07T15:22:00.000-07:00</published><updated>2005-06-07T15:34:49.433-07:00</updated><title type='text'></title><content type='html'>Why I want to go to the Windows PDC conference by Beer...&lt;br /&gt;&lt;br /&gt;Well, I've went to linux world this year and I was able to take some snappy video and pictures and video&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.linuxsecurityaudits.com/lwvideo/"&gt;http://www.linuxsecurityaudits.com/lwvideo/&lt;/a&gt;&lt;a href="http://www.linuxsecurityaudits.com/lw/dsc00940.jpg" target="_blank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="http://www.linuxsecurityaudits.com/lw/dsc00935.jpg" /&gt;&lt;br /&gt;&lt;br /&gt;Most of all I want to go because Microsoft is paying for everything, which means it's all free. As somebody that likes free software, I also like free expense paid trips, especially on Microsoft's dime.&lt;br /&gt;&lt;br /&gt;I would take my cannon dv cam, my sony DSC cam, and of course my PSP, and I would shoot some video and pics for the for the linux forums I regularly post on, along with the C9 forum. I would also get all the free merch I can get from promo bags and stuff. I'd also check out the newest MS stuff so I can try to apply it to my linux programming, or try to emulate it with linux if it doesn't already exist on the platform.(time allowing of course).&lt;br /&gt;Most of all I just want the free trip and the free airfare along with the free food, and the free stuff.&lt;br /&gt;&lt;a href="http://channel9.msdn.com/pdc/pdcfriends.aspx?contest=true"&gt;&lt;br /&gt; &lt;img src="http://channel9.msdn.com/pdc/Flairs/Blogmyway-h.jpg" border="0" /&gt;&lt;br /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;more photos from linux world below&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.linuxsecurityaudits.com/lw/dsc00927.jpg" target="_blank"&gt;http://www.linuxsecurityaudits.com/lw/dsc00927.jpg&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.linuxsecurityaudits.com/lw/dsc00929.jpg" target="_blank"&gt;http://www.linuxsecurityaudits.com/lw/dsc00929.jpg&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.linuxsecurityaudits.com/lw/dsc00930.jpg" target="_blank"&gt;http://www.linuxsecurityaudits.com/lw/dsc00930.jpg&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.linuxsecurityaudits.com/lw/dsc00931.jpg" target="_blank"&gt;http://www.linuxsecurityaudits.com/lw/dsc00931.jpg&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.linuxsecurityaudits.com/lw/dsc00932.jpg" target="_blank"&gt;http://www.linuxsecurityaudits.com/lw/dsc00932.jpg&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.linuxsecurityaudits.com/lw/dsc00933.jpg" target="_blank"&gt;http://www.linuxsecurityaudits.com/lw/dsc00933.jpg&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.linuxsecurityaudits.com/lw/dsc00934.jpg" target="_blank"&gt;http://www.linuxsecurityaudits.com/lw/dsc00934.jpg&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.linuxsecurityaudits.com/lw/dsc00935.jpg" target="_blank"&gt;http://www.linuxsecurityaudits.com/lw/dsc00935.jpg&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.linuxsecurityaudits.com/lw/dsc00937.jpg" target="_blank"&gt;http://www.linuxsecurityaudits.com/lw/dsc00937.jpg&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.linuxsecurityaudits.com/lw/dsc00938.jpg" target="_blank"&gt;http://www.linuxsecurityaudits.com/lw/dsc00938.jpg&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.linuxsecurityaudits.com/lw/dsc00925.jpg" target="_blank"&gt;http://www.linuxsecurityaudits.com/lw/dsc00925.jpg&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.linuxsecurityaudits.com/lw/dsc00926.jpg" target="_blank"&gt;http://www.linuxsecurityaudits.com/lw/dsc00926.jpg&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.linuxsecurityaudits.com/lw/dsc00939.jpg" target="_blank"&gt;http://www.linuxsecurityaudits.com/lw/dsc00939.jpg&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.linuxsecurityaudits.com/lw/dsc00940.jpg" target="_blank"&gt;http://www.linuxsecurityaudits.com/lw/dsc00940.jpg&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12723914-111818368942752913?l=programmingtoday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programmingtoday.blogspot.com/feeds/111818368942752913/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12723914&amp;postID=111818368942752913' title='22 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12723914/posts/default/111818368942752913'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12723914/posts/default/111818368942752913'/><link rel='alternate' type='text/html' href='http://programmingtoday.blogspot.com/2005/06/why-i-want-to-go-to-windows-pdc.html' title=''/><author><name>Beer</name><uri>http://www.blogger.com/profile/04059827588058182222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>22</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12723914.post-111559714954844188</id><published>2005-05-08T16:51:00.000-07:00</published><updated>2005-05-08T22:35:36.053-07:00</updated><title type='text'></title><content type='html'>Code Example Download: &lt;a href="http://www.lookingglass3d.com/blog/gwget.tar.gz"&gt;gwget.tar.gz&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Microsoft Win32 or .NET programs that use Winsock32 are so easy you say?&lt;br /&gt;Let's make one on linux with the Gnome GTK api for C++ instead today.&lt;br /&gt;&lt;br /&gt;OK, This example outlines how to create a windowed program with &lt;a target="blank" href="http://www.gtkmm.org/"&gt;GTKmm&lt;/a&gt;, the C++ version of &lt;a target="blank" href="http://www.gtk.org/"&gt;GTK+&lt;/a&gt;&lt;br /&gt;So instead of winsock, which kind of sucks, seeing how some of the functionality was stripped in SP2 to prevent people from using raw sockets, we'll be using sys/socket.h for "linsocks", see it even sounds like winsock, you're half way there already.&lt;br /&gt;&lt;br /&gt;OK, so I made the GUI with Glade2, which is documented in the comments. Here we are using a class I made a long time ago for easy http gets and posts called CGetUrl, you may also use it in any of your other projects in accordance with GPL licensing and you must mention my name and email. It is a reusable class for http sockets.&lt;br /&gt;&lt;br /&gt;So having this class in the background, as you would a .NET TCP class of some kind, we can now focus on the actual GUI code, grabbing and displaying HTTP.&lt;br /&gt;&lt;br /&gt;I'll let the comments in the code speak for themselves on this one, but I will say that normally when you do TCP on a GUI app, you'll want to use some threading with the gthread library and keep your main thread for the UI non-blocking. Tommorow we will revisit this example, but doing a POST instead of a GET with the CGetURL class and we will make it non-blocking with gthread lib.&lt;br /&gt;&lt;br /&gt;Ok, below is the code, with some color coding and example downloads. I've highlighted the important parts&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;/*&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;C++ G-WGET EXAMPLE BY BEER necrorising@videotron.ca&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;Copyright (C) 2005 &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;This program is free software; you can redistribute it and/or&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;modify it under the terms of the GNU General Public License&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;as published by the Free Software Foundation; either version 2&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;of the License, or (at your option) any later version.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;This program is distributed in the hope that it will be useful,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;GNU General Public License for more details.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;You should have received a copy of the GNU General Public License&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;along with this program; if not, write to the Free Software&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;#include &amp;lt;gtkmm.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;#include &amp;lt;gtk/gtk.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;#include "geturl.hh"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;class mainwin : public Gtk::Window&lt;br /&gt;{&lt;br /&gt;public:&lt;br /&gt;      mainwin();&lt;br /&gt;      ~mainwin();&lt;br /&gt;&lt;br /&gt;private:&lt;br /&gt;      void on_urlentry_key_press_event(GdkEventKey *ev);&lt;br /&gt;      void on_submitbutton_clicked();&lt;br /&gt;      // ENTRY WIDGET&lt;br /&gt;      &lt;span style="color: rgb(51, 0, 153);"&gt;Gtk::Entry *urlentry;&lt;/span&gt;&lt;br /&gt;      // DISPLAY TEXTAREA WIDGET&lt;br /&gt;      &lt;span style="color: rgb(51, 0, 153);"&gt;Gtk::TextView *textview;&lt;/span&gt;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;mainwin::mainwin(&lt;br /&gt;) : Gtk::Window(Gtk::WINDOW_TOPLEVEL)&lt;br /&gt;{&lt;br /&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;// BEGIN GLADE STUFF&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; Gtk::Window *mainwin = this;&lt;br /&gt; Gtk::Label *label1 = Gtk::manage(new class Gtk::Label("Url Adress:"));&lt;br /&gt; urlentry = Gtk::manage(new class Gtk::Entry());&lt;br /&gt; Gtk::Button *submitbutton = Gtk::manage(new class Gtk::Button("Get Http"));&lt;br /&gt; Gtk::HBox *hbox1 = Gtk::manage(new class Gtk::HBox(false, 0));&lt;br /&gt; Gtk::HSeparator *hseparator1 = Gtk::manage(new class Gtk::HSeparator());&lt;br /&gt; textview = Gtk::manage(new class Gtk::TextView());&lt;br /&gt; Gtk::ScrolledWindow *scrolledwindow1 = Gtk::manage(new class Gtk::ScrolledWindow());&lt;br /&gt; Gtk::VBox *vbox1 = Gtk::manage(new class Gtk::VBox(false, 0));&lt;br /&gt; label1-&gt;set_alignment(0.5,0.5);&lt;br /&gt; label1-&gt;set_padding(0,0);&lt;br /&gt; label1-&gt;set_justify(Gtk::JUSTIFY_LEFT);&lt;br /&gt; label1-&gt;set_line_wrap(false);&lt;br /&gt; label1-&gt;set_use_markup(false);&lt;br /&gt; label1-&gt;set_selectable(false);&lt;br /&gt; urlentry-&gt;set_flags(Gtk::CAN_FOCUS);&lt;br /&gt; urlentry-&gt;set_visibility(true);&lt;br /&gt; urlentry-&gt;set_editable(true);&lt;br /&gt; urlentry-&gt;set_max_length(0);&lt;br /&gt; urlentry-&gt;set_text("http://www.example.com");&lt;br /&gt; urlentry-&gt;set_has_frame(true);&lt;br /&gt; urlentry-&gt;set_activates_default(false);&lt;br /&gt; submitbutton-&gt;set_flags(Gtk::CAN_FOCUS);&lt;br /&gt; submitbutton-&gt;set_relief(Gtk::RELIEF_NORMAL);&lt;br /&gt; hbox1-&gt;pack_start(*label1, Gtk::PACK_SHRINK, 0);&lt;br /&gt; hbox1-&gt;pack_start(*urlentry);&lt;br /&gt; hbox1-&gt;pack_start(*submitbutton, Gtk::PACK_SHRINK, 0);&lt;br /&gt; textview-&gt;set_flags(Gtk::CAN_FOCUS);&lt;br /&gt; textview-&gt;set_editable(true);&lt;br /&gt; textview-&gt;set_cursor_visible(true);&lt;br /&gt; textview-&gt;set_pixels_above_lines(0);&lt;br /&gt; textview-&gt;set_pixels_below_lines(0);&lt;br /&gt; textview-&gt;set_pixels_inside_wrap(0);&lt;br /&gt; textview-&gt;set_left_margin(0);&lt;br /&gt; textview-&gt;set_right_margin(0);&lt;br /&gt; textview-&gt;set_indent(0);&lt;br /&gt; textview-&gt;set_wrap_mode(Gtk::WRAP_NONE);&lt;br /&gt; textview-&gt;set_justification(Gtk::JUSTIFY_LEFT);&lt;br /&gt; textview-&gt;get_buffer()-&gt;set_text("Http From GET will Show Up here");&lt;br /&gt; scrolledwindow1-&gt;set_flags(Gtk::CAN_FOCUS);&lt;br /&gt; scrolledwindow1-&gt;set_shadow_type(Gtk::SHADOW_NONE);&lt;br /&gt; scrolledwindow1-&gt;set_policy(Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS);&lt;br /&gt; scrolledwindow1-&gt;property_window_placement().set_value(Gtk::CORNER_TOP_LEFT);&lt;br /&gt; scrolledwindow1-&gt;add(*textview);&lt;br /&gt; vbox1-&gt;pack_start(*hbox1, Gtk::PACK_SHRINK, 0);&lt;br /&gt; vbox1-&gt;pack_start(*hseparator1, Gtk::PACK_SHRINK, 5);&lt;br /&gt; vbox1-&gt;pack_start(*scrolledwindow1);&lt;br /&gt; mainwin-&gt;set_title("G-wget");&lt;br /&gt; mainwin-&gt;set_modal(false);&lt;br /&gt; mainwin-&gt;property_window_position().set_value(Gtk::WIN_POS_CENTER);&lt;br /&gt; mainwin-&gt;set_resizable(true);&lt;br /&gt; mainwin-&gt;property_destroy_with_parent().set_value(false);&lt;br /&gt; mainwin-&gt;add(*vbox1);&lt;br /&gt; mainwin-&gt;set_size_request(400,300);&lt;br /&gt; label1-&gt;show();&lt;br /&gt; urlentry-&gt;show();&lt;br /&gt; submitbutton-&gt;show();&lt;br /&gt; hbox1-&gt;show();&lt;br /&gt; hseparator1-&gt;show();&lt;br /&gt; textview-&gt;show();&lt;br /&gt; scrolledwindow1-&gt;show();&lt;br /&gt; vbox1-&gt;show();&lt;br /&gt; mainwin-&gt;show();&lt;br /&gt; urlentry-&gt;signal_key_press_event().connect_notify(SigC::slot(*this, &amp;mainwin::on_urlentry_key_press_event));&lt;br /&gt; submitbutton-&gt;signal_clicked().connect(SigC::slot(*this, &amp;mainwin::on_submitbutton_clicked));&lt;br /&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;// END GLADE STUFF&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;mainwin::~mainwin()&lt;br /&gt;{&lt;br /&gt;  //DESTROY&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void mainwin::on_urlentry_key_press_event(&lt;span style="color: rgb(102, 0, 0);"&gt;GdkEventKey *ev&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;  &lt;span style="color: rgb(0, 102, 0);"&gt;// ENTER KEY PRESSED ON ENTRY TEXTBOX&lt;/span&gt;&lt;br /&gt;  if (&lt;span style="color: rgb(204, 0, 0);"&gt;ev-&gt;keyval == GDK_Return&lt;/span&gt;) {&lt;br /&gt;          on_submitbutton_clicked();&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void mainwin::on_submitbutton_clicked()&lt;br /&gt;{&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;    // THIS METHOD IS BLOCKING, WHICH IS NOT OPTIMAL FOR A GUI PROGRAM&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;    // IN THE NEXT EXAMPLE WE WILL REVISIT THIS EXAMPLE BUT USING GTHREAD INSTEAD&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;    // FOR NON-BLOCKING HTTP GETS, AND POSTS&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  string tmp = urlentry-&gt;get_text();&lt;br /&gt;  &lt;span style="color: rgb(0, 102, 0);"&gt;// USE THE GETURL CLASS, IT DOES "GET" BY DEFAULT&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    CGetUrl clsurl;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    string szret = clsurl.fetchurl(tmp);&lt;/span&gt;&lt;br /&gt;  if (clsurl.success()) {&lt;br /&gt;      // HOORAY IT WORKED&lt;br /&gt;      ;&lt;br /&gt;  } else {&lt;br /&gt;      // CRAP IT DIDN'T WORK&lt;br /&gt;      szret = "Http GET Failed with this response code: ";&lt;br /&gt;szret += clsurl.num(clsurl.m_responsecode);&lt;br /&gt;  }&lt;br /&gt;  &lt;span style="color: rgb(0, 102, 0);"&gt;// DISPLAY IN TEXTAREA WIDGET&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;    Glib::RefPtr&lt;gtk::textbuffer&gt; buffer = textview-&gt;get_buffer();&lt;/gtk::textbuffer&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;    buffer-&gt;set_text(szret);&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main(int argc, char **argv)&lt;br /&gt;{&lt;br /&gt; Gtk::Main m(&amp;argc, &amp;amp;amp;amp;argv);&lt;br /&gt;  mainwin *mainwin = new class mainwin();&lt;br /&gt;  m.run(*mainwin);&lt;br /&gt;  delete mainwin;&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Voila!, the fruits of our laborious masterpiece:&lt;br /&gt;&lt;img src="http://www.lookingglass3d.com/blog/gwget.jpg" /&gt;&lt;br /&gt;&lt;br /&gt;Code Example Download: &lt;a href="http://www.lookingglass3d.com/blog/gwget.tar.gz"&gt;gwget.tar.gz&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;So this concludes a tutorial on how to use g-wget, and make a C++ application that fetches a web url using a GET method with Gnome and GTKmm, and display it in a scrolling textarea widget.&lt;br /&gt;&lt;br /&gt;Tommorows example will elaborate on this using the CGetUrl Class to POST to a url instead, and will also show how to use linux and gnome threading to fetch the http url data without blocking your application's drawing.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12723914-111559714954844188?l=programmingtoday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programmingtoday.blogspot.com/feeds/111559714954844188/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12723914&amp;postID=111559714954844188' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12723914/posts/default/111559714954844188'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12723914/posts/default/111559714954844188'/><link rel='alternate' type='text/html' href='http://programmingtoday.blogspot.com/2005/05/code-example-download-gwget.html' title=''/><author><name>Beer</name><uri>http://www.blogger.com/profile/04059827588058182222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12723914.post-111550691247211836</id><published>2005-05-07T15:58:00.000-07:00</published><updated>2005-05-07T16:12:16.276-07:00</updated><title type='text'></title><content type='html'>Code Example Download: &lt;a href="http://www.lookingglass3d.com/blog/eggtraycpp.tar.gz"&gt;eggtraycpp.tar.gz&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Microsoft MFC programs that minimize to the systray are so easy you say?&lt;br /&gt;Let's make one on linux with the Gnome GTK api for C++ instead today.&lt;br /&gt;&lt;br /&gt;OK, This example outlines how to create a windowed program with &lt;a target="blank" href="http://www.gtkmm.org/"&gt;GTKmm&lt;/a&gt;, the C++ version of &lt;a target="blank" href="http://www.gtk.org/"&gt;GTK+&lt;/a&gt;&lt;span class="" style="display: block;" id="formatbar_CreateLink" title="Link" onmouseover="ButtonHoverOn(this);" onmouseout="ButtonHoverOff(this);" onmousedown="CheckFormatting(event);FormatbarButton('richeditorframe', this, 8);ButtonMouseDown(this);"&gt;&lt;/span&gt;&lt;br /&gt;So because the helper api we'll be using is in C (eggtrayicon.c by Anders Carlsson), we'll have to drop down to C to create our systray widgets.&lt;br /&gt;&lt;br /&gt;Let's do that in main.cc&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;   // DROP TO C TO CREATE GTK+ WIDGETS FOR USE WITH eggtrayicon.c SYSTRAY STUFF, C++ DROPDOWNS WON'T DO&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;   box = gtk_event_box_new ();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;   icon = gtk_image_new ();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;   tray_icon = egg_tray_icon_new ("System Tray Example");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;   gtk_container_add (GTK_CONTAINER (box), icon);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;   gtk_container_add (GTK_CONTAINER (tray_icon), box);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;   gtk_widget_show_all (GTK_WIDGET (tray_icon));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This will create a box to go into the systray area, and an image widget with which to hold our blogger.com logo&lt;br /&gt;We initialize the EggTrayIcon pointer with the egg_tray_icon_new("title") function then we start adding the image to the box, then the box to the systray widget.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now we load the image up into the pixbuf from a file, I have included a 22x22 icon.png which is just the blogger.com logo&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;  // LOAD IMAGE INTO SYSTRAY WIDGET&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;   GdkPixbuf *pixbuf;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;   pixbuf = gtk_image_get_pixbuf (GTK_IMAGE (icon));&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;   if (pixbuf) g_object_unref (G_OBJECT (pixbuf)); &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;   pixbuf = gdk_pixbuf_new_from_file ("icon.png", NULL);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;   gtk_image_set_from_pixbuf (GTK_IMAGE (icon), pixbuf);   &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;We have also created a GTKmm menu&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;   Gtk::Image *image1 = Gtk::manage(new class Gtk::Image(Gtk::StockID("gtk-goto-top"), Gtk::IconSize(1)));&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;   Gtk::ImageMenuItem *show1 = NULL;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;   Gtk::MenuItem *separator1 = NULL;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;   Gtk::Image *image2 = Gtk::manage(new class Gtk::Image(Gtk::StockID("gtk-quit"), Gtk::IconSize(1)));&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;   Gtk::ImageMenuItem *quit2 = NULL;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;   menuitem4_menu = Gtk::manage(new class Gtk::Menu());&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;   Gtk::MenuItem *menuitem4 = NULL;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;   Gtk::MenuBar *menubar1 = Gtk::manage(new class Gtk::MenuBar());&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;   Gtk::Label *label1 = Gtk::manage(new class Gtk::Label("System Tray Icon Demo"));&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;   Gtk::VBox *vbox1 = Gtk::manage(new class Gtk::VBox(false, 0));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;with some image menu items for showing and quitting the application&lt;br /&gt;&lt;br /&gt;This is important because we have overridden the close button on the main Gtk::Window by overriding the bool on_delete_event(GdkEventAny* event); method in our parent window class. So the user can no longer use the close button, because we've overridden it to reduce the application to the system tray&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;bool eggwnd::on_delete_event(GdkEventAny* event)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;    // CLOSE BUTTON PRESSED&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;    GtkWindow* win = this-&gt;gobj();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;    gtk_widget_hide(GTK_WIDGET(win));&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;    return true;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;So they have to have another method to quit the app, so we provide that in the menu quit option&lt;br /&gt;&lt;br /&gt;After we've created the systray box and displayed it, we have to wire the mouse clicks to a function where we can hook it to display a context menu&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;   // ADD BUTTON PRESS ON SYSTRAY  - MUST CONNECT TO A STATIC FUNCTION&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;   g_signal_connect (G_OBJECT(box), "button-press-event", G_CALLBACK(&amp;eggwnd::_on_systray_click), this);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;So because the eggtrayicon helper is in C, we must use a static function to signal the mouse button presses.&lt;br /&gt;Because our main class is not static, we must access it through a static function.&lt;br /&gt;   void on_systray_click(GdkEventButton* event);&lt;br /&gt;   static void _on_systray_click(GtkWidget *widget, GdkEventButton *event, gpointer data) {&lt;br /&gt;       ((eggwnd*)data)-&gt;on_systray_click(event);&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;This basically takes the signal and forwards it to our class, which is instanciated and non-static.&lt;br /&gt;&lt;br /&gt;Now we handle the systray mouse clicks inside the class&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;void eggwnd::on_systray_click(GdkEventButton* event)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;      if((event-&gt;type == GDK_BUTTON_PRESS) &amp;&amp;amp;amp;amp;amp;amp;amp; (event-&gt;button == 3))&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;      {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;        menuitem4_menu-&gt;popup(event-&gt;button, event-&gt;time);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;        return;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;      }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;      if((event-&gt;type == GDK_2BUTTON_PRESS) &amp;&amp;amp; (event-&gt;button == 1))&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;      {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;        GtkWindow* win = this-&gt;gobj();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;        gtk_widget_show(GTK_WIDGET(win));&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;        return;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;      }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The right button shows our GTKmm menu and the left shows our application if it's hidden&lt;br /&gt;&lt;br /&gt;Our 2 menu options are for showing the application if it's hidden and quitting the application, because the close button was overridden&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;void eggwnd::on_show1_activate()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;{ &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;    GtkWindow* win = this-&gt;gobj();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;    gtk_widget_show(GTK_WIDGET(win));&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;void eggwnd::on_quit2_activate()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;{ &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;    gtk_main_quit();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When you are starting the app in main, please be carefull not to use the GTKmm .run () method if you intend to minimize to the system tray because if you do, GTKmm's .run() method will kill the app when you hide() it, instead use the gtk_main() method from gtk+&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;    eggwnd *eggwnd = new class eggwnd();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    // REASON, IF YOU gtk_widget_hide(GTK_WIDGET(win)); when the user presses the close button&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    // INSTEAD OF REDUCING TO THE SYSTRAY, IF GTKmm .run() is invoked it will terminate the app&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    // SO USE C gtk_main() instead.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    //   m.run(*eggwnd);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;    gtk_main();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Voila!, the fruits of our laborious masterpiece:&lt;br /&gt;&lt;img src="http://www.lookingglass3d.com/blog/eggtraycpp.jpg" /&gt;&lt;br /&gt;&lt;br /&gt;Code Example Download: &lt;a href="http://www.lookingglass3d.com/blog/eggtraycpp.tar.gz"&gt;eggtraycpp.tar.gz&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;So this concludes a tutorial on how to use Eggtrayicon, and make a C++ application that reduces to the systray when the user clicks on the close button with Gnome and GTKmm.&lt;br /&gt;It also demonstrates how to effectively use C api from C++ like using static functions to access non-static members of instanciated classes.&lt;br /&gt;&lt;br /&gt;So there will be much more to come in the way of GTKmm C++ linux programming examples. GTKmm is a rich set of C++ tools to build linux applications with and I will be covering more of it in further blog entries.&lt;br /&gt;&lt;a href="http://www.lookingglass3d.com/blog/eggtraycpp.tar.gz"&gt;&lt;span class="down" style="display: block;" id="formatbar_CreateLink" title="Link" onmouseover="ButtonHoverOn(this);" onmouseout="ButtonHoverOff(this);" onmousedown="CheckFormatting(event);FormatbarButton('richeditorframe', this, 8);ButtonMouseDown(this);"&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="down" style="display: block;" id="formatbar_ForeColor" title="Text Color" onmouseover="ButtonHoverOn(this);" onmouseout="ButtonHoverOff(this);" onmousedown="CheckFormatting(event);SelectColor(this,'ForeColor');ButtonMouseDown(this);"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12723914-111550691247211836?l=programmingtoday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programmingtoday.blogspot.com/feeds/111550691247211836/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12723914&amp;postID=111550691247211836' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12723914/posts/default/111550691247211836'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12723914/posts/default/111550691247211836'/><link rel='alternate' type='text/html' href='http://programmingtoday.blogspot.com/2005/05/code-example-download-eggtraycpp.html' title=''/><author><name>Beer</name><uri>http://www.blogger.com/profile/04059827588058182222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12723914.post-111548894535156905</id><published>2005-05-07T10:59:00.000-07:00</published><updated>2005-05-07T11:02:25.356-07:00</updated><title type='text'>The first honest blogger</title><content type='html'>This space for rent.&lt;br /&gt;&lt;br /&gt;That's right, I'm a blogger now, which means my opinion is for hire. Send me your free previews, products, demo's anything.&lt;br /&gt;&lt;br /&gt;--&gt; YOUR AD HERE &lt;--&lt;br /&gt;&lt;br /&gt;The best part is, I won't even tell people it's an ad or that I'm being coersed!&lt;br /&gt;&lt;br /&gt;Win, win....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12723914-111548894535156905?l=programmingtoday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programmingtoday.blogspot.com/feeds/111548894535156905/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12723914&amp;postID=111548894535156905' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12723914/posts/default/111548894535156905'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12723914/posts/default/111548894535156905'/><link rel='alternate' type='text/html' href='http://programmingtoday.blogspot.com/2005/05/first-honest-blogger.html' title='The first honest blogger'/><author><name>Beer</name><uri>http://www.blogger.com/profile/04059827588058182222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>
