Example #1
0
static void dict_toggled(GtkWidget *widget, gpointer data)
{
	gboolean active;
	gboolean button_active;
	int i;
	gint idx = GPOINTER_TO_INT(data);

	GtkTreeIter   parent_iter;
	GtkTreeIter   child_iter;

	LOG(LOG_DEBUG, "IN : dict_toggled(idx=%d)", idx);

	button_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));


	if(gtk_tree_model_get_iter_first(GTK_TREE_MODEL(dict_store), &parent_iter) == TRUE){
		do { 
			gchar *title;

			gtk_tree_model_get(GTK_TREE_MODEL(dict_store), 
					   &parent_iter, 
					   DICT_TITLE_COLUMN, &title,
					   DICT_ACTIVE_COLUMN, &active,
					   -1);
			if(active == TRUE){
				i = 0;
				if(gtk_tree_model_iter_children(GTK_TREE_MODEL(dict_store), &child_iter, &parent_iter) == TRUE){
					do {
						if(i == idx) {
							gtk_tree_store_set(dict_store, &child_iter,
									   DICT_ACTIVE_COLUMN, button_active,
									   -1);
							goto END;
						}
						i ++;
					} while (gtk_tree_model_iter_next(GTK_TREE_MODEL(dict_store), &child_iter) == TRUE);
				}
			}
			g_free(title);
	       } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(dict_store), &parent_iter) == TRUE);
	}

 END:
	if(ebook_search_method() == SEARCH_METHOD_MULTI)
		show_multi();

	save_dictgroup();
	LOG(LOG_DEBUG, "OUT : dict_toggled()");
}
Example #2
0
static gint group_changed (GtkWidget *combo){
	const gchar *text;

	GtkTreeIter   iter;

	LOG(LOG_DEBUG, "IN : group_changed()");

	text = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo_group)->entry));

	if(gtk_tree_model_get_iter_first(GTK_TREE_MODEL(dict_store), &iter) == TRUE){
		do { 
			gchar *title;
			gtk_tree_model_get (GTK_TREE_MODEL(dict_store), 
					    &iter, 
					    DICT_TITLE_COLUMN, &title,
					    -1);

			if(strcmp(title, text) == 0){
				gtk_tree_store_set (dict_store, &iter,
						    DICT_ACTIVE_COLUMN, TRUE,
						    -1);
			} else {
				gtk_tree_store_set (dict_store, &iter,
						    DICT_ACTIVE_COLUMN, FALSE,
						    -1);
			}


	       } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(dict_store), &iter) == TRUE);
	}

	update_dict_button();

	save_dictgroup();

	if(ebook_search_method() == SEARCH_METHOD_MULTI)
		show_multi();


	LOG(LOG_DEBUG, "OUT : group_changed()");

	return(FALSE);
}
Example #3
0
static void search_selection()
{
	GtkTextIter start;
	GtkTextIter end;
	gchar *text;
	gchar *euc_str;
	gint method;

	LOG(LOG_DEBUG, "IN : search_selection()");

	gtk_text_buffer_get_selection_bounds(text_buffer, &start, &end);
	text = gtk_text_buffer_get_text(text_buffer, &start, &end, FALSE);

	if(strlen(text) == 0)
		return;
	gtk_entry_set_text(GTK_ENTRY(word_entry), text);
	euc_str = iconv_convert("utf-8", "euc-jp", text);

	method = ebook_search_method();
	if(method == SEARCH_METHOD_INTERNET){
		web_search();
	} else 	if(method == SEARCH_METHOD_GREP){
		clear_message();
		grep_search(euc_str);
	} else {
		clear_message();
		ebook_search(euc_str, method);
		if(search_result == NULL)
			push_message(_("No hit."));
	}

	save_word_history(text);
	gtk_editable_select_region(GTK_EDITABLE(word_entry), 
				   0,
				   GTK_ENTRY(word_entry)->text_length);
//	show_result_tree();
	g_free(euc_str);

	LOG(LOG_DEBUG, "OUT : search_selection()");
}
Example #4
0
static void search_selected(gchar *str)
{
	gchar *euc_str;
	gint method;
	glong len;

	LOG(LOG_DEBUG, "IN : search_selected(%s)", str);

	if(selection_mode <= SELECTION_DO_NOTHING) {
		LOG(LOG_DEBUG, "OUT : search_selected() = NOP1");
		return;
	}

	if(strcmp(previous, str) == 0){
		// Do nothing if the word is the save as before.
		LOG(LOG_DEBUG, "same as before");
		;
	} else {

		euc_str = iconv_convert("utf-8", "euc-jp", str);
		if(validate_euc_str(euc_str) == FALSE) {
			g_free(euc_str);
			LOG(LOG_DEBUG, "OUT : search_selected() = INVALID");
			return;
		}
		remove_space(euc_str);

		len = g_utf8_strlen(str, -1);

		if((auto_minchar <= len) && (len <= auto_maxchar)) {
			gtk_entry_set_text(GTK_ENTRY(word_entry), str);

			method = ebook_search_method();
			if((method == SEARCH_METHOD_INTERNET) ||
			   (method == SEARCH_METHOD_MULTI) ||
			   (method == SEARCH_METHOD_FULL_TEXT)){
				LOG(LOG_DEBUG, "OUT : search_selected() = NOP2");
				return;
			}

			if(selection_mode <= SELECTION_COPY_ONLY) {
				LOG(LOG_DEBUG, "OUT : search_selected() = COPY");
				return;
			}
			
			clear_message();
			clear_search_result();

			if(method == SEARCH_METHOD_GREP){
				grep_search(euc_str);
				show_result_tree();
				select_first_item();
				if(selection_mode == SELECTION_SEARCH_TOP)
					bring_to_top(main_window);
				save_word_history(str);
			} else {
				ebook_search_auto(euc_str, method);
				show_result_tree();
				if(search_result){
					if(selection_mode == SELECTION_POPUP) {
						show_result_in_popup();
					} else {
						select_first_item();
						if(selection_mode == SELECTION_SEARCH_TOP)
							bring_to_top(main_window);
					}
					save_word_history(str);
				} else {
					current_in_result = NULL;
					set_current_result(NULL);
					if(selection_mode == SELECTION_POPUP) {
						beep();
					} else {
						if(selection_mode == SELECTION_SEARCH_TOP)
							bring_to_top(main_window);
						push_message(_("No hit."));
					}
				}
			}
			
			sprintf(previous, "%s", str);
		} else {
			LOG(LOG_DEBUG, "OUT : search_selected() = LENGTH");
		}
		g_free(euc_str);
	}

	LOG(LOG_DEBUG, "OUT : search_selected()");
}