void
addEntries(int numEntries)
{
  void (*f[])(GtkWidget *, State *) = {&addTimeoutCB, &addIdleCB};
  GList *tmpList = NULL;
  int i, j;
  GtkWidget *label;
  char buf[100];
  State *state;

  for(i = 0; i < 2 ; i++) {
    tmpList = NULL;
    for(j = 0; j < numEntries; j++) {
	state = (State *) g_malloc(sizeof(State));
        state->index = j;
	state->id = 0;
	state->isActive = FALSE;
	state->count = 0;

/*	f[i](NULL, state); */
	sprintf(buf, "%s %d", i == TIMER ? "timer" : "idle", j + 1);
	label = gtk_list_item_new_with_label((char *) buf);
	gtk_widget_show(label);
	gtk_signal_connect(GTK_OBJECT(label), "select", f[i], state);
        tmpList = g_list_append(tmpList, label);
    }
    gtk_list_append_items(GTK_LIST(lists[i]), tmpList);
  }
}
Exemple #2
0
int
clip_GTK_COMBOSETPOPDOWNSTRINGS(ClipMachine * ClipMachineMemory)
{
   C_widget *ccmb = _fetch_cw_arg(ClipMachineMemory);

   ClipArrVar *astr = (ClipArrVar *) _clip_vptr(_clip_spar(ClipMachineMemory, 2));

   GList    *str_list = NULL;

   gchar    *text_utf;

   ClipStrVar *s;

   int       i;

   CHECKCWID(ccmb, GTK_IS_COMBO);
   CHECKOPT(2, ARRAY_type_of_ClipVarType);

   for (i = 0; i < astr->count; i++)
    {
       if (astr->items[i].t.ClipVartype_type_of_ClipType != CHARACTER_type_of_ClipVarType)
	  continue;
       s = (ClipStrVar *) _clip_vptr(&astr->items[i]);
       text_utf = _clip_locale_to_utf8(s->str.buf);
       if (ccmb->objtype == GTK_WIDGET_COMBO_SIMPLE)
	{
	   str_list = g_list_append(str_list, gtk_list_item_new_with_label(text_utf));
	   g_free(text_utf);
	}
       else
	  str_list = g_list_append(str_list, text_utf);
    }
   if (ccmb->objtype == GTK_WIDGET_COMBO_SIMPLE)
    {
       gtk_list_clear_items(GTK_LIST(GTK_COMBO(ccmb->widget)->list), 0, -1);
       gtk_list_append_items(GTK_LIST(GTK_COMBO(ccmb->widget)->list), str_list);
    }
   else
      gtk_combo_set_popdown_strings(GTK_COMBO(ccmb->widget), str_list);

/*
	while (str_list)
	{
		g_free(str_list->data);
		str_list = g_list_next(str_list);
	}
*/
   return 0;
 err:
   return 1;
}
gboolean BuiltinLibOptionsNewButtonClicked_callback (char *filename, gpointer userData)
{
    if (!filename || !*filename)
        return TRUE;

    GtkWidget *dialogue = GTK_WIDGET (userData);
    GtkList *sourceList = GTK_LIST (gtk_object_get_data (GTK_OBJECT (dialogue), "SourceList"));
    char *relativeFilename = ImportPaths_ConvertFileToRelative (filename);
    GList *itemsStr = g_list_prepend (NULL, relativeFilename);
    GList *items = MakeListItemListFromStringList (itemsStr);

    gtk_list_append_items (sourceList, items);
    return TRUE;                /* destroy dialogue */
}
Exemple #4
0
static void
listprop_reset_widget(ListProperty *prop, WIDGET *widget)
{
  guint i;
  GList *items = NULL;
  gtk_list_clear_items(GTK_LIST(widget),0,-1);

  for (i = 0; i < prop->lines->len; i++) {
    items = g_list_append(items, make_item(g_ptr_array_index(prop->lines,i)));
  }
  gtk_list_append_items(GTK_LIST(widget),items);
  prop->w_selected = prop->selected;
  gtk_list_select_item(GTK_LIST(widget),prop->selected);
}
Exemple #5
0
//__________________________________________________________________
void        _HYPlatformPullDown::_AddMenuItem   (_String& newItem, long index)
{
    if (theMenu) {
        GList * singleItem   = g_list_alloc();
        singleItem->prev = singleItem->next = nil;
        if (newItem.Equal(&menuSeparator)) {
            GtkWidget * itemContents = gtk_separator_menu_item_new ();
            gtk_widget_show (itemContents);
            singleItem->data = gtk_list_item_new();
            gtk_container_add((GtkContainer*)singleItem->data,itemContents);
            gtk_combo_set_item_string (GTK_COMBO (theMenu), GTK_ITEM (singleItem->data), "");
            gtk_widget_set_sensitive((GtkWidget*)singleItem->data,false);
            widgetList.InsertElement ((BaseRef)itemContents,2*index,false,false);
        } else {
            _String inItem = newItem;
            if (newItem.beginswith ("(")) {
                inItem.Trim (1,-1);
            }

            GtkWidget * itemContents = gtk_menu_item_new_with_label (inItem.sData);
            gtk_widget_show (itemContents);
            singleItem->data = gtk_list_item_new();
            gtk_container_add((GtkContainer*)singleItem->data,itemContents);
            gtk_combo_set_item_string (GTK_COMBO (theMenu), GTK_ITEM (singleItem->data), inItem.sData);
            gtk_widget_set_sensitive((GtkWidget*)singleItem->data,inItem.sLength == newItem.sLength);
            widgetList.InsertElement ((BaseRef)itemContents,2*index,false,false);
        }
        widgetList.InsertElement ((BaseRef)singleItem->data,2*index,false,false);
        GdkColor convColor = HYColorToGDKColor(_hyGTKMenuBackground);
        gtk_widget_modify_bg ((GtkWidget*)singleItem->data, GTK_STATE_INSENSITIVE, 
        	&convColor);
        gtk_widget_show ((GtkWidget*)singleItem->data);
        if (index<0) {
            gtk_list_append_items (GTK_LIST (GTK_COMBO (theMenu)->list), singleItem);
        } else {
            gtk_list_insert_items (GTK_LIST (GTK_COMBO (theMenu)->list), singleItem, index);
        }

        /*printf ("\nAdding menu item %s at %d\n", newItem.sData, index);
        for (long k = 0; k<widgetList.lLength; k++)
            printf ("%d %s\n", k, GTK_OBJECT_TYPE_NAME (GTK_WIDGET (widgetList(k))));*/
    }

    if (((_HYPullDown*)this)->MenuItemCount()==1||selection==index) {
        cbSelection = -1;
        _RefreshComboBox();
    }
}
Exemple #6
0
static void add_message(GtkWidget *list, const char *str, ...)
{
	static int line = 0;
    va_list ap;
    char buf[BUFSIZ];
	GList *items = NULL;
	GtkWidget *item;

    va_start(ap, str);
    vsnprintf(buf, sizeof(buf), str, ap);
    va_end(ap);

	item = gtk_list_item_new_with_label(buf);
	gtk_widget_show(item);
	items = g_list_append(items, item);
	gtk_list_append_items(GTK_LIST(list), items);
	line++;
	gtk_list_scroll_vertical(GTK_LIST(list), GTK_SCROLL_JUMP, 1.0);
}
Exemple #7
0
int
clip_GTK_COMBOSETPOPDOWNSTRINGS(ClipMachine * ClipMachineMemory)
{
   C_widget *ccmb = _fetch_cw_arg(ClipMachineMemory);

   ClipArrVar *astr = (ClipArrVar *) _clip_vptr(_clip_spar(ClipMachineMemory, 2));

   GList    *str_list = NULL;

   ClipStrVar *s;

   int       i;

   CHECKCWID(ccmb, GTK_IS_COMBO);
   CHECKOPT(2, ARRAY_type_of_ClipVarType);

   for (i = 0; i < astr->count_of_ClipArrVar; i++)
    {
       if (astr->ClipVar_items_of_ClipArrVar[i].ClipType_t_of_ClipVar.ClipVartype_type_of_ClipType !=
	   CHARACTER_type_of_ClipVarType)
	  continue;
       s = (ClipStrVar *) _clip_vptr(&astr->ClipVar_items_of_ClipArrVar[i]);
       if (ccmb->objtype == GTK_WIDGET_COMBO_SIMPLE)
	  str_list = g_list_append(str_list, gtk_list_item_new_with_label(s->ClipBuf_str_of_ClipStrVar.buf_of_ClipBuf));
       else
	  str_list = g_list_append(str_list, s->ClipBuf_str_of_ClipStrVar.buf_of_ClipBuf);
    }
   if (ccmb->objtype == GTK_WIDGET_COMBO_SIMPLE)
    {
       gtk_list_clear_items(GTK_LIST(GTK_COMBO(ccmb->widget)->list), 0, -1);
       gtk_list_append_items(GTK_LIST(GTK_COMBO(ccmb->widget)->list), str_list);
    }
   else
      gtk_combo_set_popdown_strings(GTK_COMBO(ccmb->widget), str_list);
   return 0;
 err:
   return 1;
}
Exemple #8
0
Fichier : list.c Projet : dimkr/gtk
gint main( int    argc,
           gchar *argv[] )
{                                  
    GtkWidget *separator;
    GtkWidget *window;
    GtkWidget *vbox;
    GtkWidget *scrolled_window;
    GtkWidget *frame;
    GtkWidget *gtklist;
    GtkWidget *button;
    GtkWidget *list_item;
    GList *dlist;
    guint i;
    gchar buffer[64];
    
    
    /* Initialize GTK (and subsequently GDK) */

    gtk_init(&argc, &argv);
    
    
    /* Create a window to put all the widgets in
     * connect gtk_main_quit() to the "destroy" event of
     * the window to handle window manager close-window-events
     */
    window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(window), "GtkList Example");
    gtk_signal_connect(GTK_OBJECT(window),
		       "destroy",
		       GTK_SIGNAL_FUNC(gtk_main_quit),
		       NULL);
    
    
    /* Inside the window we need a box to arrange the widgets
     * vertically */
    vbox=gtk_vbox_new(FALSE, 5);
    gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
    gtk_container_add(GTK_CONTAINER(window), vbox);
    gtk_widget_show(vbox);
    
    /* This is the scrolled window to put the List widget inside */
    scrolled_window=gtk_scrolled_window_new(NULL, NULL);
    gtk_widget_set_usize(scrolled_window, 250, 150);
    gtk_container_add(GTK_CONTAINER(vbox), scrolled_window);
    gtk_widget_show(scrolled_window);
    
    /* Create thekList widget.
     * Connect the sigh_print_selection() signal handler
     * function to the "selection_changed" signal of the List
     * to print out the selected items each time the selection
     * has changed */
    gtklist=gtk_list_new();
    gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(scrolled_window),
                                           gtklist);
    gtk_widget_show(gtklist);
    gtk_signal_connect(GTK_OBJECT(gtklist),
		       "selection_changed",
		       GTK_SIGNAL_FUNC(sigh_print_selection),
		       NULL);
    
    /* We create a "Prison" to put a list item in ;) */
    frame=gtk_frame_new("Prison");
    gtk_widget_set_usize(frame, 200, 50);
    gtk_container_set_border_width(GTK_CONTAINER(frame), 5);
    gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_OUT);
    gtk_container_add(GTK_CONTAINER(vbox), frame);
    gtk_widget_show(frame);
    
    /* Connect the sigh_button_event() signal handler to the List
     * which will handle the "arresting" of list items
     */
    gtk_signal_connect(GTK_OBJECT(gtklist),
		       "button_release_event",
		       GTK_SIGNAL_FUNC(sigh_button_event),
		       frame);
    
    /* Create a separator */
    separator=gtk_hseparator_new();
    gtk_container_add(GTK_CONTAINER(vbox), separator);
    gtk_widget_show(separator);
    
    /* Finally create a button and connect its "clicked" signal
     * to the destruction of the window */
    button=gtk_button_new_with_label("Close");
    gtk_container_add(GTK_CONTAINER(vbox), button);
    gtk_widget_show(button);
    gtk_signal_connect_object(GTK_OBJECT(button),
			      "clicked",
			      GTK_SIGNAL_FUNC(gtk_widget_destroy),
			      GTK_OBJECT(window));
    
    
    /* Now we create 5 list items, each having its own
     * label and add them to the List using gtk_container_add()
     * Also we query the text string from the label and
     * associate it with the list_item_data_key for each list item
     */
    for (i=0; i<5; i++) {
	GtkWidget       *label;
	gchar           *string;
	
	sprintf(buffer, "ListItemContainer with Label #%d", i);
	label=gtk_label_new(buffer);
	list_item=gtk_list_item_new();
	gtk_container_add(GTK_CONTAINER(list_item), label);
	gtk_widget_show(label);
	gtk_container_add(GTK_CONTAINER(gtklist), list_item);
	gtk_widget_show(list_item);
	gtk_label_get(GTK_LABEL(label), &string);
	gtk_object_set_data(GTK_OBJECT(list_item),
			    list_item_data_key,
			    string);
    }
    /* Here, we are creating another 5 labels, this time
     * we use gtk_list_item_new_with_label() for the creation
     * we can't query the text string from the label because
     * we don't have the labels pointer and therefore
     * we just associate the list_item_data_key of each
     * list item with the same text string.
     * For adding of the list items we put them all into a doubly
     * linked list (GList), and then add them by a single call to
     * gtk_list_append_items().
     * Because we use g_list_prepend() to put the items into the
     * doubly linked list, their order will be descending (instead
     * of ascending when using g_list_append())
     */
    dlist=NULL;
    for (; i<10; i++) {
	sprintf(buffer, "List Item with Label %d", i);
	list_item=gtk_list_item_new_with_label(buffer);
	dlist=g_list_prepend(dlist, list_item);
	gtk_widget_show(list_item);
	gtk_object_set_data(GTK_OBJECT(list_item),
			    list_item_data_key,
			    "ListItem with integrated Label");
    }
    gtk_list_append_items(GTK_LIST(gtklist), dlist);
    
    /* Finally we want to see the window, don't we? ;) */
    gtk_widget_show(window);
    
    /* Fire up the main event loop of gtk */
    gtk_main();
    
    /* We get here after gtk_main_quit() has been called which
     * happens if the main window gets destroyed
     */
    return(0);
}
//Algoritmo T9 di predizione del testo basato su liste
void gestionet9 (struttura *str)
{
	gtk_list_clear_items ((GtkList *) str->tp.gtklist,0,N);
        if (str->tp.luncodicet9==-1) /*possibile solo se provenienti da un delete*/
         {
          gtk_widget_set_usize(str->tp.scrolled_window, 0,S_W_MAIN); 
          str->tp.luncodicet9=0; 
          return;
         }
        //fase inizializzazione
	str->tp.numparoletrovate=0;
	int i=0;
	for (i=0; i<N;i++)
	{
		bzero(str->tp.vetparole[i].parola,LEN_WORD_DB+1);
	}
	
	//aggiornamento
	str->tp.luncodicet9++;
	str->tp.codicet9[str->tp.luncodicet9]=0;
	//printf("\nTasti premuti: %s\tlunghezza:%d\n",str->tp.codicet9,str->tp.luncodicet9);
	char query[200];
	bzero (query,200);
	//se freq0 globale, se 1 pers
	sprintf (query, " select parola,codice,frequenza from globale where codice like \'%s%%\' order by codice,frequenza desc  limit 0,%d;",str->tp.codicet9,N);
  	//GtkWidget *list_item;
	GList *dlist=NULL;
	gchar *s;
	s = (gchar*)malloc(sizeof(gchar));
	*s=0;//equals sprintf(s,"");
	//printf("\n%s\n",query);
	int  retval = sqlite3_prepare_v2(str->tp.db,query,-1,&str->tp.stmt,0);    
	if(retval)
	{
        	return;
	}
        
	// Read the number of rows fetched
	int cols = sqlite3_column_count(str->tp.stmt);
	    
	while(1)
	{
		// fetch a row's status
		retval = sqlite3_step(str->tp.stmt);
		if(retval == SQLITE_DONE) break;
                else if(retval == SQLITE_ROW)
		{
			// SQLITE_ROW means fetched a row
		   	 str->tp.numparoletrovate=str->tp.numparoletrovate+1;
		    	//printf ("\n");
		    	// sqlite3_column_text returns a const void* , typecast it to const char*
		    	for(int col=0 ; col<cols;col++)
		  	{
		        	char *val = (char *)sqlite3_column_text(str->tp.stmt,col);
		                //printf("%s = %s\t",sqlite3_column_name(str->tp.stmt,col),val);
				if (col==0) 
			         {
                                        sprintf(str->tp.vetparole[str->tp.numparoletrovate-1].parola,"%s",val);
                                        str->tp.list_item=gtk_list_item_new_with_label(val);
					dlist=g_list_append(dlist, str->tp.list_item);
                                        gtk_widget_set_usize(str->tp.list_item,0,25);
					gtk_widget_show(str->tp.list_item);
					gtk_object_set_data(GTK_OBJECT(str->tp.list_item), list_item_data_key,s);

				}
				else
                                 strcpy(str->tp.vetparole[str->tp.numparoletrovate-1].keyparola,val);
				
		   	 }  
		}
		else
		{
			// Some error encountered
		    	return;
		}
	}
	str->tp.indice=0;
	if(str->tp.numparoletrovate> 0)
          gtk_list_append_items((GtkList*)(str->tp.gtklist), dlist);
	else{
          ins(str);	
	  fButtonTP(str);
        }
        gdk_window_process_all_updates ();
	
	//printf ("\n");
	
}
Exemple #10
0
static int MicrocodeDialog()
{
	GtkWidget *infoLabel;
	GtkWidget *infoFrame, *infoTable;
	GtkWidget *crcInfoLabel, *crcDataInfoLabel, *textInfoLabel;
	GtkWidget *crcLabel = NULL, *crcDataLabel = NULL, *textLabel = NULL;
	GtkWidget *selectUcodeLabel;
	//GtkWidget *microcodeLabel;
	GtkWidget *okButton, *stopButton;
	GList *ucodeList = 0;
	char buf[1024];

	if (!g_thread_supported())
		g_thread_init( NULL );
	gdk_threads_enter();

	// create dialog
	if (microcodeWindow == 0)
	{
		microcodeWindow = gtk_dialog_new();
		gtk_signal_connect( GTK_OBJECT(microcodeWindow), "delete_event",
		                    GTK_SIGNAL_FUNC(delete_question_event), (gpointer)NULL );
		sprintf( buf, "%s - unknown microcode", pluginName );
		gtk_window_set_title( GTK_WINDOW(microcodeWindow), buf );
		gtk_container_set_border_width( GTK_CONTAINER(GTK_DIALOG(microcodeWindow)->vbox), 11 );

		// ok button
		okButton = gtk_button_new_with_label( "Ok" );
		gtk_signal_connect_object( GTK_OBJECT(okButton), "clicked",
                               GTK_SIGNAL_FUNC(okButton_clicked), NULL );
		gtk_container_add( GTK_CONTAINER(GTK_DIALOG(microcodeWindow)->action_area), okButton );

		// stop button
		stopButton = gtk_button_new_with_label( "Stop" );
		gtk_signal_connect_object( GTK_OBJECT(stopButton), "clicked",
                               GTK_SIGNAL_FUNC(stopButton_clicked), NULL );
		gtk_container_add( GTK_CONTAINER(GTK_DIALOG(microcodeWindow)->action_area), stopButton );

		// info label
		infoLabel = gtk_label_new( "Unknown microcode. Please notify Orkin, including the following information:" );
		gtk_box_pack_start_defaults( GTK_BOX(GTK_DIALOG(microcodeWindow)->vbox), infoLabel );

		// info frame
		infoFrame = gtk_frame_new( "Microcode info" );
		gtk_container_set_border_width( GTK_CONTAINER(infoFrame), 7 );
		gtk_box_pack_start_defaults( GTK_BOX(GTK_DIALOG(microcodeWindow)->vbox), infoFrame );

		infoTable = gtk_table_new( 3, 2, FALSE );
		gtk_container_set_border_width( GTK_CONTAINER(infoTable), 7 );
		gtk_table_set_col_spacings( GTK_TABLE(infoTable), 3 );
		gtk_table_set_row_spacings( GTK_TABLE(infoTable), 3 );
		gtk_container_add( GTK_CONTAINER(infoFrame), infoTable );

		crcInfoLabel = gtk_label_new( "Microcode CRC:" );
		crcDataInfoLabel = gtk_label_new( "Microcode Data CRC:" );
		textInfoLabel = gtk_label_new( "Microcode Text:" );

		crcLabel = gtk_label_new( "" );
		crcDataLabel = gtk_label_new( "" );
		textLabel = gtk_label_new( "" );

		gtk_table_attach_defaults( GTK_TABLE(infoTable), crcInfoLabel, 0, 1, 0, 1 );
		gtk_table_attach_defaults( GTK_TABLE(infoTable), crcLabel, 1, 2, 0, 1 );
		gtk_table_attach_defaults( GTK_TABLE(infoTable), crcDataInfoLabel, 0, 1, 1, 2 );
		gtk_table_attach_defaults( GTK_TABLE(infoTable), crcDataLabel, 1, 2, 1, 2 );
		gtk_table_attach_defaults( GTK_TABLE(infoTable), textInfoLabel, 0, 1, 2, 3 );
		gtk_table_attach_defaults( GTK_TABLE(infoTable), textLabel, 1, 2, 2, 3 );

		selectUcodeLabel = gtk_label_new( "You can manually select the closest matching microcode." );
		for (int i = 0; i < numMicrocodeTypes; i++)
			ucodeList = g_list_append( ucodeList, gtk_list_item_new_with_label( MicrocodeTypes[i] ) );
		microcodeList = gtk_list_new();
		gtk_list_set_selection_mode( GTK_LIST(microcodeList), GTK_SELECTION_SINGLE );
		gtk_list_append_items( GTK_LIST(microcodeList), ucodeList );

		gtk_box_pack_start_defaults( GTK_BOX(GTK_DIALOG(microcodeWindow)->vbox), selectUcodeLabel );
		gtk_box_pack_start_defaults( GTK_BOX(GTK_DIALOG(microcodeWindow)->vbox), microcodeList );
	}

	snprintf( buf, 1024, "0x%8.8X", (unsigned int)uc_crc );
        if(crcLabel) gtk_label_set_text( GTK_LABEL(crcLabel), buf );
	snprintf( buf, 1024, "0x%8.8X", (unsigned int)uc_dcrc );
	if(crcDataLabel) gtk_label_set_text( GTK_LABEL(crcDataLabel), buf );
	if(textLabel) gtk_label_set_text( GTK_LABEL(textLabel), uc_str );

	selectedMicrocode = -1;
	gtk_widget_show_all( microcodeWindow );

	while (selectedMicrocode == -1)
	{
//		if( gtk_main_iteration() )
//			break;
		usleep( 10000 );
	}
	gdk_threads_leave();
	return selectedMicrocode;
}
//Algoritmo T9 di predizione del testo basato su liste
void gestionet9 (struttura *str,int tasto)
{
	//fase inizializzazione
	str->tp.numparoletrovate=0;
	int i=0;
	for (i=0; i<N;i++)
	{
		str->tp.vetparole[i].frequenza=0;
		bzero(str->tp.vetparole[i].parola,30);
	}
	gtk_list_clear_items ((GtkList *) str->tp.gtklist,0,N);

	//aggiornamento
	str->tp.luncodicet9=str->tp.luncodicet9+1;
	sprintf(str->tp.codicet9,"%s%d",str->tp.codicet9,tasto);
	//printf("\nTasti premuti: %s\tlunghezza:%d\n",str->tp.codicet9,str->tp.luncodicet9);
	char query[200];
	bzero (query,200);
	//se freq0 globale, se 1 pers
	sprintf (query, " select parola dist,frequenza from personale where codice like \'%s%%\' union select parola dist,frequenza from globale where 		codice like \'%s%%\' order by 2 desc, 1 asc limit 0,5;",str->tp.codicet9,str->tp.codicet9);
  	//GtkWidget *list_item;
	GList *dlist=NULL;
	gchar *s;
	s = (gchar*)malloc(sizeof(gchar));
	sprintf(s,"");
	printf("\n%s\n",query);
	int  retval = sqlite3_prepare_v2(str->tp.db,query,-1,&str->tp.stmt,0);    
	if(retval)
	{
        	printf("\nerrore database\n");
        	return;
	}
        
	// Read the number of rows fetched
	int cols = sqlite3_column_count(str->tp.stmt);
	    
	while(1)
	{
		// fetch a row's status
		retval = sqlite3_step(str->tp.stmt);
		if(retval == SQLITE_DONE) break;
                else if(retval == SQLITE_ROW)
		{
			// SQLITE_ROW means fetched a row
		   	 str->tp.numparoletrovate=str->tp.numparoletrovate+1;
		    	printf ("\n");
		    	// sqlite3_column_text returns a const void* , typecast it to const char*
		    	for(int col=0 ; col<cols;col++)
		   	{
		        	const char *val = (const char*)sqlite3_column_text(str->tp.stmt,col);
		        //printf("%s = %s\t",sqlite3_column_name(str->tp.stmt,col),val);
				if (col==0) 
				{
					printf ("%s",val);
					sprintf(str->tp.vetparole[str->tp.numparoletrovate-1].parola,"%s",val);
					str->tp.list_item=gtk_list_item_new_with_label(val);
					dlist=g_list_append(dlist, str->tp.list_item);
					gtk_widget_show(str->tp.list_item);
					gtk_object_set_data(GTK_OBJECT(str->tp.list_item), list_item_data_key,s);

				}
				else 
				{
					printf ("\tfr=%s",val);
					str->tp.vetparole[str->tp.numparoletrovate-1].frequenza=atoi(val);
				}
		   	 }  
		}
		else
		{
			// Some error encountered
		   	 printf("errori query\n");
		    	return;
		}
	}
	str->tp.indice=0;
	Display *display = XOpenDisplay(0);
	if(str->tp.numparoletrovate> 0)
	{ 
		gtk_list_append_items((GtkList*)(str->tp.gtklist), dlist);
		
			
	}
		gdk_window_process_all_updates ();
		XCloseDisplay(display);
	    printf ("\n");
	
}
Exemple #12
0
void wxListBox::GtkAddItem( const wxString &item, int pos )
{
    wxCHECK_RET( m_list != NULL, wxT("invalid listbox") );

    GtkWidget *list_item;

    wxString label(item);
#if wxUSE_CHECKLISTBOX
    if (m_hasCheckBoxes)
    {
        label.Prepend(wxCHECKLBOX_STRING);
    }
#endif // wxUSE_CHECKLISTBOX

    list_item = gtk_list_item_new_with_label( wxGTK_CONV( label ) );

    GList *gitem_list = g_list_alloc ();
    gitem_list->data = list_item;

    if (pos == -1)
        gtk_list_append_items( GTK_LIST (m_list), gitem_list );
    else
        gtk_list_insert_items( GTK_LIST (m_list), gitem_list, pos );

    gtk_signal_connect_after( GTK_OBJECT(list_item), "select",
      GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );

    if (HasFlag(wxLB_MULTIPLE) || HasFlag(wxLB_EXTENDED))
        gtk_signal_connect_after( GTK_OBJECT(list_item), "deselect",
          GTK_SIGNAL_FUNC(gtk_listitem_deselect_callback), (gpointer)this );

    gtk_signal_connect( GTK_OBJECT(list_item),
                        "button_press_event",
                        (GtkSignalFunc)gtk_listbox_button_press_callback,
                        (gpointer) this );

    gtk_signal_connect_after( GTK_OBJECT(list_item),
                        "button_release_event",
                        (GtkSignalFunc)gtk_listbox_button_release_callback,
                        (gpointer) this );

    gtk_signal_connect( GTK_OBJECT(list_item),
                           "key_press_event",
                           (GtkSignalFunc)gtk_listbox_key_press_callback,
                           (gpointer)this );


    gtk_signal_connect( GTK_OBJECT(list_item), "focus_in_event",
            GTK_SIGNAL_FUNC(gtk_listitem_focus_in_callback), (gpointer)this );

    gtk_signal_connect( GTK_OBJECT(list_item), "focus_out_event",
            GTK_SIGNAL_FUNC(gtk_listitem_focus_out_callback), (gpointer)this );

    ConnectWidget( list_item );

    if (GTK_WIDGET_REALIZED(m_widget))
    {
        gtk_widget_show( list_item );

        gtk_widget_realize( list_item );
        gtk_widget_realize( GTK_BIN(list_item)->child );

#if wxUSE_TOOLTIPS
        if (m_tooltip) m_tooltip->Apply( this );
#endif
    }

    // Apply current widget style to the new list_item
    GtkRcStyle *style = CreateWidgetStyle();
    if (style)
    {
        gtk_widget_modify_style( GTK_WIDGET( list_item ), style );
        GtkBin *bin = GTK_BIN( list_item );
        gtk_widget_modify_style( GTK_WIDGET( bin->child ), style );
        gtk_rc_style_unref( style );
    }
}
Exemple #13
0
/* Adds items to the end of the list. */
int
clip_GTK_LISTAPPENDITEMS(ClipMachine * ClipMachineMemory)
{
   C_widget *clst = _fetch_cw_arg(ClipMachineMemory);

   ClipVar  *cv = _clip_spar(ClipMachineMemory, 2);

   GList    *items = NULL;

   CHECKCWID(clst, GTK_IS_LIST);
   CHECKARG4(2, ARRAY_type_of_ClipVarType, CHARACTER_type_of_ClipVarType, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType);
   switch (cv->ClipType_t_of_ClipVar.ClipVartype_type_of_ClipType)
    {
    case CHARACTER_type_of_ClipVarType:
       items =
	g_list_append(items,
		      gtk_list_item_new_with_label(cv->ClipStrVar_s_of_ClipVar.ClipBuf_str_of_ClipStrVar.buf_of_ClipBuf));
       break;

    case MAP_type_of_ClipVarType:
    case NUMERIC_type_of_ClipVarType:
       {
	  C_widget *citem = _fetch_cwidget(ClipMachineMemory, cv);

	  CHECKCWID(citem, GTK_IS_WIDGET);
	  if (GTK_IS_LIST_ITEM(citem->widget))
	     items = g_list_append(items, citem->widget);
	  else
	   {
	      GtkWidget *item = gtk_list_item_new();

	      gtk_container_add(GTK_CONTAINER(item), citem->widget);
	      items = g_list_append(items, item);
	   }
	  break;
       }

    case ARRAY_type_of_ClipVarType:
       {
	  C_widget *citem;

	  GtkWidget *item;

	  int       i;

	  for (i = 0; i < cv->ClipArrVar_a_of_ClipVar.count_of_ClipArrVar; i++)
	   {
	      switch (cv->ClipArrVar_a_of_ClipVar.ClipVar_items_of_ClipArrVar[i].ClipType_t_of_ClipVar.
		      ClipVartype_type_of_ClipType)
	       {
	       case CHARACTER_type_of_ClipVarType:
		  items =
		   g_list_append(items,
				 gtk_list_item_new_with_label(cv->ClipArrVar_a_of_ClipVar.
							      ClipVar_items_of_ClipArrVar[i].ClipStrVar_s_of_ClipVar.
							      ClipBuf_str_of_ClipStrVar.buf_of_ClipBuf));
		  break;
	       case MAP_type_of_ClipVarType:
	       case NUMERIC_type_of_ClipVarType:
		  citem = _fetch_cwidget(ClipMachineMemory, &cv->ClipArrVar_a_of_ClipVar.ClipVar_items_of_ClipArrVar[i]);
		  CHECKCWID(citem, GTK_IS_WIDGET);
		  if (GTK_IS_LIST_ITEM(citem->widget))
		     items = g_list_append(items, citem->widget);
		  else
		   {
		      item = gtk_list_item_new();
		      gtk_container_add(GTK_CONTAINER(item), citem->widget);
		      items = g_list_append(items, item);
		   }
		  break;
	       default:
		  break;
	       }
	   }

       }
    default:
       break;
    }
   gtk_list_append_items(GTK_LIST(clst->widget), items);
   return 0;
 err:
   return 1;
}
void CallBuiltinLibSelectionWindow (PtrBalsaFile file, PtrBuiltinLib editedTest)
{
    GtkWidget *dialogue = create_BuiltinLibOptionsDialogue ();

    GtkEntry *nameEntry = GTK_ENTRY (gtk_object_get_data (GTK_OBJECT (dialogue), "NameEntry"));
    GtkEntry *compileOptionsEntry = GTK_ENTRY (gtk_object_get_data (GTK_OBJECT (dialogue), "CompileOptionsEntry"));
    GtkList *sourceList = GTK_LIST (gtk_object_get_data (GTK_OBJECT (dialogue), "SourceList"));

    if (editedTest)
    {
        gtk_entry_set_text (nameEntry, g_strdup (editedTest->name));
        gtk_entry_set_text (GTK_ENTRY (compileOptionsEntry), editedTest->compileOptions);

        GList *items = MakeListItemListFromStringList (editedTest->sourceFilenames);

        gtk_list_append_items (sourceList, items);
    } else
    {                           // find a unused name for the test
        char *test_name = NULL;
        int num = 1;

        test_name = g_strdup (file->name);
        goto jump1;
      retry:
        g_free (test_name);
        test_name = g_strdup_printf ("lib%d", num);
      jump1:
        {                       // Check the test name doesn't already exist
            GList *files;

            for (files = CurrentBalsaProject->files; files; files = files->next)
            {
                PtrBalsaFile file = (PtrBalsaFile) files->data;

                GList *tests = file->info.balsaFile.testFixtures;

                for (; tests; tests = tests->next)
                {
                    PtrBalsaTest test = (PtrBalsaTest) tests->data;

                    if (!strcmp (test_name, test->name))
                    {
                        num++;
                        goto retry;
                    }
                }

            }
        }

        gtk_entry_set_text (nameEntry, test_name);
    }

    gtk_entry_select_region (nameEntry, 0, -1);
    gtk_widget_grab_focus (GTK_WIDGET (nameEntry));

    gtk_object_set_data (GTK_OBJECT (dialogue), "BalsaFile", file);
    gtk_object_set_data (GTK_OBJECT (dialogue), "EditedTest", editedTest);

    gtk_widget_show (dialogue);
}
Exemple #15
0
static void fill_wifi_list(GtkWidget *gtk_list, libin_wifi* pp)
{
	//GtkWidget *gtk_list;
	GList *items;
	GList *copy;
	GtkWidget *listitem;
	GtkWidget *elementItem;
	GSList *group;
	GtkWidget *radio;

	gint i;
	
	//must initialize here for first use!
	items = NULL;
	copy = NULL;
	group = NULL;

	Element*  element_content = NULL;

	for(i=1;i<=pp[i].NET_NUMBER;i++)
	{//.NET_NUMBER==0means the last??
		listitem = gtk_list_item_new();
		items = g_list_append(items, listitem);
		elementItem	= list_element_new(pp[i].ESSID, IMG_FILE,
				(double)(100+pp[i].Singal_level)/100, &group);
		char *onState = "on";
		char *offState = "off";
		if(!strcmp("on",pp[i].Encryption_key))
		{//if crypted
			elementItem	= list_element_new(pp[i].ESSID, IMG_ENCRYPTED,
					(double)(100+pp[i].Singal_level)/100, &group);
		}
		/*else if(!strcmp("off",pp[i].Encryption_key))
		{
			elementItem	= list_element_new(pp[i].ESSID, IMG_FILE,
					(double)(100+pp[i].Singal_level)/100, &group);
			//elementItem	= list_element_new(pp[i].ESSID, IMG_UNENCRYPTED,
			//		(double)(100+pp[i].Singal_level)/100, &group);
		}*/
		else
		{
			//elementItem	= list_element_new(pp[i].ESSID, IMG_FILE,
			//		(double)(100+pp[i].Singal_level)/100, &group);
			elementItem	= list_element_new(pp[i].ESSID, NULL,
					(double)(100+pp[i].Singal_level)/100, &group);
		}
		gtk_container_add(GTK_CONTAINER(listitem), elementItem);
		gtk_widget_show_all(listitem);
		//gtk_container_add(GTK_CONTAINER(gtk_list), listitem);
		element_content = g_object_get_data (G_OBJECT (elementItem), "element_content");
		g_object_set_data (G_OBJECT (element_content->radiobutton), "network", g_strdup (pp[i].ESSID));
		g_object_set_data (G_OBJECT (element_content->radiobutton), "password", pp[i].Encryption_key);
		if(1 == i)
		{
			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(element_content->radiobutton),TRUE);
			select_radio(GTK_TOGGLE_BUTTON(element_content->radiobutton), NULL);
		}
	}
	/*for(i = 0; i < 5; ++i)
	{
		listitem = gtk_list_item_new();
		items = g_list_append(items, listitem);
		elementItem	= list_element_new("name", IMG_FILE, 0.8, &group);
		//gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),TRUE);
#if MY_DEBUG_OUT == 1
		g_print("add element to listitem\n");
#endif
		gtk_container_add(GTK_CONTAINER(listitem), elementItem);
#if MY_DEBUG_OUT == 1
		g_print("add element to listitem ok\n");
#endif
		gtk_widget_show_all(listitem);
	}*/
	copy = g_list_copy(items);
	g_list_free(items);
	items = NULL;
	gtk_list_append_items(GTK_LIST(gtk_list), copy);
	//return gtk_list;
}