Click here to Skip to main content
Click here to Skip to main content

A google search application using Gtk#

By , 14 Jan 2005
 
googlesearch_demo.zip
googleSearch
bin
Debug
googleSearch.exe
googleSearch.pdb
Release
googleSearch.exe
googleSearch.csproj.user
googlesearch.glade
googlesearch.glade.bak
googlesearch.gladep
googlesearch.gladep.bak
googleSearch.suo
obj
Debug
googleSearch.exe
googleSearch.pdb
googleSearch.projdata
googleSearch.projdata1
temp
TempPE
Web References.com.google.api.Reference.cs.dll
Release
googleSearch.exe
googleSearch.projdata
temp
TempPE
Web References.com.google.api.Reference.cs.dll
Web References
com.google.api
GoogleSearch.wsdl
Reference.map
using System;
using Gtk;
using Glade;
using googleSearch.com.google.api;

namespace googleSearch
{
	/// <summary>
	/// Summary description for GtkApp.
	/// </summary>
	public class GtkApp
	{
		
		[Widget]Window mainWindow;
		[Widget]Button btnSearch;
		[Widget]Button btnClear;
		[Widget]Entry entry1;
		[Widget]TextView textview1;

		/* Main Function */
		public static void Main (string[] args)
		{
			new GtkApp (args);
		}


		public GtkApp(string []args)
		{
			Application.Init();

			Glade.XML gxml = new Glade.XML (null, "googleSearch.googlesearch.glade", "mainWindow", null);
			gxml.Autoconnect (this);
			mainWindow.DeleteEvent+=new DeleteEventHandler(mainWindow_DeleteEvent);
			btnSearch.Clicked+=new EventHandler(btnSearch_Clicked);
			btnClear.Clicked+=new EventHandler(btnClear_Clicked);
			Application.Run();
		}

		private void mainWindow_DeleteEvent(object o, DeleteEventArgs args)
		{
			Application.Quit ();
			args.RetVal = true;
		}

		private void btnSearch_Clicked(object sender, EventArgs e)
		{
			try
			{
				textview1.Buffer.Text="";

				//do search
				GoogleSearchService svc=new GoogleSearchService();
				GoogleSearchResult result=svc.doGoogleSearch("FEkTsl8kwgQtrQIeGHJDSELrTtjNcp1eC",entry1.Text,0,10,true,"",true,"","","");
			
				foreach(ResultElement re in result.resultElements)
				{
					textview1.Buffer.Text+="Title: "+re.title+"\r\n";
					textview1.Buffer.Text+="Summary: "+re.summary+"\r\n";
					textview1.Buffer.Text+="URL: "+re.URL+"\r\n";
					textview1.Buffer.Text+="==========================\r\n\r\n";
				}

			}
			catch(Exception ex)
			{
				Gtk.MessageDialog md=new MessageDialog(mainWindow,Gtk.DialogFlags.Modal,Gtk.MessageType.Error,Gtk.ButtonsType.Ok,ex.Message);
				md.Show();
			}
		}

		private void btnClear_Clicked(object sender, EventArgs e)
		{
			textview1.Buffer.Text="";
			entry1.Text="";
		}

		
	}
}

By viewing downloads associated with this article you agree to the Terms of use and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

samirkut
Web Developer
Singapore Singapore
Member
Samir Kuthiala founded a Singapore based technology firm Innove Technologies Pte Ltd in 2002. Innove Technologies specialises in providing enterprise level .NET solutions to their clients.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 14 Jan 2005
Article Copyright 2005 by samirkut
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid