Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

A google search application using Gtk#

, 14 Jan 2005
An application (based on Gtk#) which uses the google web service to search the internet.
googlesearch_demo.zip
googleSearch
bin
Debug
googleSearch.pdb
googleSearch.exe
Release
googleSearch.exe
obj
Debug
temp
googleSearch.projdata
TempPE
Web References.com.google.api.Reference.cs.dll
googleSearch.pdb
googleSearch.exe
googleSearch.projdata1
Release
temp
TempPE
Web References.com.google.api.Reference.cs.dll
googleSearch.projdata
googleSearch.exe
googleSearch.csproj.user
googleSearch.suo
googlesearch.gladep.bak
googlesearch.glade.bak
Web References
com.google.api
GoogleSearch.wsdl
Reference.map
googlesearch.gladep
googlesearch.glade
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 Service 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

Share

About the Author

samirkut
Web Developer
Singapore Singapore
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.

| Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 14 Jan 2005
Article Copyright 2005 by samirkut
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid