Exemplo n.º 1
0
//! pembuatan 	view 
GtkWidget *tableCreate (void){
    table = struct_new(table_);
	databaseCreate();
	GtkTreeModel        *model;
 
	table->view = gtk_tree_view_new();
	//header
	GtkTreeViewColumn   *col  =  tableCreateHeader(table->view);	
	/* connect a cell data function */
	model = create_and_fill_model("");
	gtk_tree_view_set_model(GTK_TREE_VIEW(table->view), model);
 
	g_object_unref(model); /* destroy model automatically with view */

	
	gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(table->view)),GTK_SELECTION_SINGLE);
	gtk_tree_view_set_headers_clickable (table->view,TRUE);
	gtk_tree_view_set_rules_hint (table->view,TRUE);
	gtk_tree_view_set_grid_lines(table->view, GTK_TREE_VIEW_GRID_LINES_HORIZONTAL );

	g_object_set(	table->view ,"hover-selection" , TRUE,NULL);
	
	g_signal_connect(table->view, "button-press-event", (GCallback) table_onButtonPressed, NULL);

	return table->view;
}
Exemplo n.º 2
0
void databaseDelete(struct connection *conn,int id){
struct address addr = {.id=id,.set=0};
conn->db->rows[id] = addr;
}
void databaseList(struct connection *conn){
 for(int i=0;i<MAX_ROWS;i++){
  struct address *addp = conn->db->rows[i];
  if(addp->set) addressPrint(addp);
}
}
int main(int argc,char * argv[])
{
 if(argc<3) die("use it right dumass :/  <exec> <dbfile> <action> [action parameters]");

 char *filename = argv[1];
 char *action = argv[2][0];
 struct connection *conn = databaseOpen(filename,action);
 if(argc>3) int id = atoi(argv[3]);if(id>MAX_ROWS) die("limit the rowcount dammit");
 
 switch(action){
 case 'c':databaseCreate(conn);
          databasewrite(conn);
          break;
 case 'g':if(argc<4) die("you forgot the id moron.");
          databaseGet(conn,id);break;
 case 's':if(argc<6) die("can't add a jhon doe. try to remember next time.");
          databaseSet(conn,id,argv[4],argv[5]);
          databaseWrite(conn);
          break;
 case 'd':if(argc<4) die("for the love of god..delete WHAT?");
          databaseDelete(conn,id);
          databaseWrite(conn);
          break;
 case 'l':databaseList(conn);break;
 default: die("choose from the following cause i aint taking nothing else.\n c-create\ng-get\ns-set\nd-delete\nl-list");
}
databaseClose(conn);
return 0;
}