Pulling my hair out:-)



Ok I'm hoping that if I include the entire source file someone will 
say, "OH that's simple just do this" cause for the life of me I 
can't figure out what's wrong. 

I've read the source, I've read the GTK tutorial but I'm afraid my 
C skills just aren't up to that level.  All I want is a way to 
retrieve the row and column data in the method "select_row".

Any help greatly appreciated..


-------------------------------------------------
#include <obgnome/obgnome.h>

@interface GfaxPhoneBook : Gnome_AppWin
{

	id phbook;	
	Gtk_CList *itemList;
}
- init;
- mycb: (id) sender;

@end



/*==================================================================
	Make toolbar code
	
-------------------------------------------------------------------*/

GnomeUIInfo phtoolbar[] = {
  {GNOME_APP_UI_ITEM, N_("Add"), N_("Add New Item"), "close",
   NULL, NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_ADD, 0, 0, NULL},
  {GNOME_APP_UI_ITEM, N_("Edit"), N_("Edit Item"), "close",
   NULL, NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_SAVE, 0, 0, NULL},
  {GNOME_APP_UI_ITEM, N_("Delete"), N_("Delete Item"), "close",
   NULL, NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_CUT, 0, 0, NULL},
  {GNOME_APP_UI_ITEM, N_("Search"), N_("Search Phone Book"), "mycb",
   NULL, NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_SEARCH, 0, 0, NULL},
  {GNOME_APP_UI_ITEM, N_("Close"), N_("Close Phone Book"), "quit",
   NULL, NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_CLOSE, 0, 0, NULL},
  GNOMEUIINFO_END
};

/* end of make toolbar code */


@implementation GfaxPhoneBook
- init
{
	id hbox, vbox;

	const gchar *treeTitles[] = {"Phone Books"};
	const gchar *itemTitles[] = {"Name", "Number", "Attention", "Prefix"};
	const gchar *text[] = {"George", "555-1212", "Attention", "9"};
	
	gchar *nodeA[] = {"A"}, *nodeB[] = {"B"};
	gchar c;
	gint i;

	Gtk_Label *label;
	Gtk_CTree *treeBox, *subtree;
	Gtk_TreeItem *treeItem,*treeItem1;

	Gtk_Adjustment *horzAdj, *vertAdj;
	
	self = [super initWithAppWinInfo:"GfaxPhoneBook" :"Gfax Phone Book"];

	phbook = self;
	
	
	hbox = [[Gtk_HBox new] show];	//main box
	[hbox set_border_width:5];

	treeBox = [[[Gtk_CTree alloc] initWithCTreeInfoTitles:1 :0 Titles:treeTitles] show];
	[hbox pack_start:treeBox doExpand:TRUE doFill:TRUE doPadding:5];

	[treeBox insert_node:NULL :NULL :nodeA :0 :NULL :NULL :NULL :NULL :NO :NO];
	[treeBox insert_node:NULL :NULL :nodeB :0 :NULL :NULL :NULL :NULL :NO :NO];
		

	itemList = [[[Gtk_CList alloc] initWithCListInfoTitles:4 Titles:itemTitles] show];
	[hbox pack_start:itemList doExpand:TRUE doFill:TRUE doPadding:5];	
	[itemList set_selection_mode:GTK_SELECTION_BROWSE];
	
	[itemList connectObjMethod:"select_row" :self :@selector(select_row:)];

	[itemList insertCListRow:0 :text];	//sample text
		
	[self create_toolbar:phtoolbar];	// Make the toolbar
	[self set_contents:hbox];		// add for mainwin
	[self connect:"delete_event"];		// Set up the exit
	[self set_usize:500 height:400];
	[self show];

	return self;		// Return self
}

- mycb: (id) sender
{
	printf("well we got here\n");
	return self;
}

- select_row: (id) sender
{
	
	gchar *text;
	
	[itemList get_text:0 :0 getText:&text];
	
	g_print("Sender %s - Data is %s\n",[sender name], text);

}

- quit: (id) sender
{
	[phbook destroy];
	return self;
}


- delete_event:(id) sender :(GdkEventAny *) event
{
	return [self quit:sender];
}


@end



-- 
George Farris - VE7FRG
George@gmsys.com




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]