Esempio n. 1
0
void
on_treeview_cursor_changed (GtkTreeView *treeview, gpointer user_data)
{
//	g_print("on treeview cursor changed called\n");
	GtkTreeModel *model;
	GtkTreeIter iter;
	gchar *word = NULL;
	GtkTreeSelection *selection;

	selection = gtk_tree_view_get_selection ( mydata.treeview );
		
	if( gtk_tree_selection_get_selected (  selection , &model, &iter ) ){
		gtk_tree_model_get ( model, &iter, LIST_ITEM, &word, -1);
		//cause of latency
		//g_print("row selection: %s\n", word);
		gtk_entry_set_text ( mydata.input_word, g_strdup(word) );
//
		gtk_statusbar_pop ( mydata.statusbar, mydata.statusbar_context_id );
		gtk_statusbar_push (GTK_STATUSBAR (mydata.statusbar), mydata.statusbar_context_id, "searching for selected word");
//
		on_find_clicked ();			
	}	
	g_free( word );
	
}
Esempio n. 2
0
void 
on_match_select( GtkEntryCompletion *widget, GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data )
{  
	GValue value = {0, };
	//gtk_tree_model_get_string_from_iter ()
	gtk_tree_model_get_value(model, iter, LIST_ITEM, &value);
//	g_print("You have selected %s\n", g_value_get_string(&value));
	gtk_entry_set_text ( mydata.input_word, g_value_get_string(&value) );
	on_find_clicked();
	g_value_unset(&value);
	return;
}
Esempio n. 3
0
void on_text_selection_changed(GtkClipboard *clipboard, GdkEvent *event, gpointer data)
{
	char* text = gtk_clipboard_wait_for_text(clipboard), *word =  NULL;
    if(text)
    {
	//printf("%s\n", text);
	//gtk_clipboard_clear(clipboard);
	//gtk_clipboard_set_text( clipboard, "", 0 );
		word = g_strdup( g_strchomp ( g_strchug ( g_strdown( text ) ) ) );
		gtk_entry_set_text ( mydata.input_word, word );
		load_hashtable_list( );
		on_find_clicked();
    }
	free( text );
	free( word );
}
int findData::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: searchSource((*reinterpret_cast< char*(*)>(_a[1]))); break;
        case 1: searchDestino((*reinterpret_cast< char*(*)>(_a[1]))); break;
        case 2: searchProtocolo((*reinterpret_cast< char*(*)>(_a[1]))); break;
        case 3: on_rbProtocolo_clicked(); break;
        case 4: on_rbDestino_clicked(); break;
        case 5: on_rdSource_clicked(); break;
        case 6: on_find_clicked(); break;
        default: ;
        }
        _id -= 7;
    }
    return _id;
}
Esempio n. 5
0
void
on_treeview_row_activated (GtkTreeView *treeview, GtkTreePath *treepath, GtkTreeViewColumn *treeviewcolumn, gpointer user_data)
{
	GtkTreeModel *model;
	GtkTreeIter iter;
	gchar *word;
	
	model = gtk_tree_view_get_model ( mydata.treeview );
	
	if( gtk_tree_model_get_iter ( model, &iter, treepath ) ){
			gtk_tree_model_get ( model, &iter, LIST_ITEM, &word, -1);
			//g_print("double click: row contains %s\n", word);
	}

	gtk_entry_set_text ( mydata.input_word, g_strdup(word) );
//
		gtk_statusbar_pop ( mydata.statusbar, mydata.statusbar_context_id );
		gtk_statusbar_push (GTK_STATUSBAR (mydata.statusbar), mydata.statusbar_context_id, "searching for selected word");
//
	on_find_clicked ();
	g_free( word );
}
Esempio n. 6
0
void
on_input_word_activate (GtkEntry *entry, gpointer user_data)
{

	char *word = NULL, *entry_word = NULL;
	
	entry_word = gtk_entry_get_text ( mydata.input_word );	
	word = g_strchomp( g_strchug( g_strdown( entry_word ) ) );

	if( strlen( word ) == 0 ){
		//g_print("on_input_word_activate():word is NULL\n");
		//avoid some latency by commenting below
//
		gtk_statusbar_pop ( mydata.statusbar, mydata.statusbar_context_id );
		gtk_statusbar_push (GTK_STATUSBAR (mydata.statusbar), mydata.statusbar_context_id, "Please enter a word");
//		remove_all_from_list();	// empty the list as there is no word to search for									
//		if we empty the list it causes a bug of not loading the list of same word although
//		hash table is still there
	}else{
		//it is cause of latency
//		g_print("on_input_word_activate():word= %s\n", word );
		if( ! isalpha( word[0] ) ){
			//g_print("on_input_word_activate(): enter proper word\n");
			// *************** show proper warning to enter proper word **********************
//
			gtk_statusbar_pop ( mydata.statusbar, mydata.statusbar_context_id );
			gtk_statusbar_push (GTK_STATUSBAR (mydata.statusbar), mydata.statusbar_context_id, "Please enter proper english word");
//
			return;
		}								
		//check if hash table is created for word[0] of not
		g_sprintf( file_loaded_name, APP_DBS"%c.db", g_ascii_tolower( word[0] ) );
//		g_print("on_input_word_activate(): filename = %s\n",file_loaded_name);
		
		if( mydata.hash_tab[ g_ascii_toupper(word[0]) - 'A' ] == NULL ){
			//remove the prev word entries
			//remove_all_from_list ();
//			g_print("on_input_word_activate(): generating hash table\n");
			mydata.hash_tab[ g_ascii_toupper(word[0]) - 'A' ] = generate_hash_table( file_loaded_name );
			mydata.list_store_arr[ g_ascii_toupper(word[0]) - 'A' ] = mydata.list_store;
			list_loaded = g_ascii_toupper(word[0]) - 'A';
			//check if hash table is created or not by generate_hash_table() func call				 
			if( mydata.hash_tab[ g_ascii_toupper(word[0]) - 'A' ] == NULL ){
				g_print("on_input_word_activate():\nafter trying to generate_hash_table\nfile: %s could not be located and loaded\n", file_loaded_name );
			}						 
		}else{
			//g_print("on_input_word_activate(): %d", list_loaded );
			if( list_loaded != (g_ascii_toupper(word[0]) - 'A') ){				
				//
				if( mydata.list_store_arr[ g_ascii_toupper(word[0]) - 'A' ] == NULL ){
					populate_list_only( file_loaded_name );
					//g_print("on_input_word_changed(): list populated from file\n" );
				}else{					
					mydata.list_store = mydata.list_store_arr[ g_ascii_toupper(word[0]) - 'A' ];
//					following may be necessary		  
					gtk_tree_view_set_model ( mydata.treeview, GTK_TREE_MODEL(mydata.list_store) );
					//g_print("on_input_word_changed(): list used from previous list\n" );
				}
				
				list_loaded = (g_ascii_toupper(word[0]) - 'A');
				//
			}
		}	
			
	}
	
	on_find_clicked();
	
}