Change the background colour of the search bar in the toolbar according to the search result.
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1687 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
34e0036c10
commit
8528f95e82
@ -13,6 +13,9 @@
|
||||
Use only supported symbol types in the symbol view for PHP.
|
||||
* src/treeviews.c: Focus the editor widget after switching between
|
||||
files with the open files list.
|
||||
* src/callbacks.c, src/document.c, src/document.h:
|
||||
Change the background colour of the search bar in the toolbar
|
||||
according to the search result.
|
||||
|
||||
|
||||
2007-07-08 Enrico Tröger <enrico.troeger@uvena.de>
|
||||
|
||||
@ -566,6 +566,23 @@ on_toolbutton10_clicked (GtkToolButton *toolbutton,
|
||||
}
|
||||
|
||||
|
||||
static void set_search_bar_background(GtkWidget *widget, gboolean success)
|
||||
{
|
||||
const GdkColor red = {0, 0xffff, 0x6666, 0x6666};
|
||||
const GdkColor white = {0, 0xffff, 0xffff, 0xffff};
|
||||
static gboolean old_value = TRUE;
|
||||
|
||||
// only update if really needed
|
||||
if (old_value != success)
|
||||
{
|
||||
gtk_widget_modify_base(widget, GTK_STATE_NORMAL, success ? NULL : &red);
|
||||
gtk_widget_modify_text(widget, GTK_STATE_NORMAL, success ? NULL : &white);
|
||||
|
||||
old_value = success;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// store text, clear search flags so we can use Search->Find Next/Previous
|
||||
static void setup_find_next(GtkEditable *editable)
|
||||
{
|
||||
@ -582,9 +599,11 @@ on_entry1_activate (GtkEntry *entry,
|
||||
gpointer user_data)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
gboolean result;
|
||||
|
||||
setup_find_next(GTK_EDITABLE(entry));
|
||||
document_search_bar_find(idx, search_data.text, 0, FALSE);
|
||||
result = document_search_bar_find(idx, search_data.text, 0, FALSE);
|
||||
set_search_bar_background(GTK_WIDGET(entry), result);
|
||||
}
|
||||
|
||||
|
||||
@ -594,9 +613,11 @@ on_entry1_changed (GtkEditable *editable,
|
||||
gpointer user_data)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
gboolean result;
|
||||
|
||||
setup_find_next(editable);
|
||||
document_search_bar_find(idx, search_data.text, 0, TRUE);
|
||||
result = document_search_bar_find(idx, search_data.text, 0, TRUE);
|
||||
set_search_bar_background(GTK_WIDGET(editable), result);
|
||||
}
|
||||
|
||||
|
||||
@ -607,10 +628,12 @@ on_toolbutton18_clicked (GtkToolButton *toolbutton,
|
||||
{
|
||||
//on_entry1_changed(NULL, NULL);
|
||||
gint idx = document_get_cur_idx();
|
||||
gboolean result;
|
||||
GtkWidget *entry = lookup_widget(GTK_WIDGET(app->window), "entry1");
|
||||
|
||||
setup_find_next(GTK_EDITABLE(entry));
|
||||
document_search_bar_find(idx, search_data.text, 0, FALSE);
|
||||
result = document_search_bar_find(idx, search_data.text, 0, FALSE);
|
||||
set_search_bar_background(entry, result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1113,14 +1113,19 @@ gboolean document_save_file(gint idx, gboolean force)
|
||||
}
|
||||
|
||||
|
||||
/* special search function, used from the find entry in the toolbar */
|
||||
void document_search_bar_find(gint idx, const gchar *text, gint flags, gboolean inc)
|
||||
/* special search function, used from the find entry in the toolbar
|
||||
* return TRUE if text was found otherwise FALSE
|
||||
* return also TRUE if text is empty */
|
||||
gboolean document_search_bar_find(gint idx, const gchar *text, gint flags, gboolean inc)
|
||||
{
|
||||
gint start_pos, search_pos;
|
||||
struct TextToFind ttf;
|
||||
|
||||
g_return_if_fail(text != NULL);
|
||||
if (! DOC_IDX_VALID(idx) || ! *text) return;
|
||||
g_return_val_if_fail(text != NULL, FALSE);
|
||||
if (! DOC_IDX_VALID(idx))
|
||||
return FALSE;
|
||||
if (! *text)
|
||||
return TRUE;
|
||||
|
||||
start_pos = (inc) ? sci_get_selection_start(doc_list[idx].sci) :
|
||||
sci_get_selection_end(doc_list[idx].sci); // equal if no selection
|
||||
@ -1144,6 +1149,7 @@ void document_search_bar_find(gint idx, const gchar *text, gint flags, gboolean
|
||||
sci_set_selection_start(doc_list[idx].sci, ttf.chrgText.cpMin);
|
||||
sci_set_selection_end(doc_list[idx].sci, ttf.chrgText.cpMax);
|
||||
doc_list[idx].scroll_percent = 0.3F;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1153,6 +1159,7 @@ void document_search_bar_find(gint idx, const gchar *text, gint flags, gboolean
|
||||
}
|
||||
utils_beep();
|
||||
sci_goto_pos(doc_list[idx].sci, start_pos, FALSE); // clear selection
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -160,8 +160,7 @@ gint document_reload_file(gint idx, const gchar *forced_enc);
|
||||
* It returns whether the file could be saved or not. */
|
||||
gboolean document_save_file(gint idx, gboolean force);
|
||||
|
||||
/* special search function, used from the find entry in the toolbar */
|
||||
void document_search_bar_find(gint idx, const gchar *text, gint flags, gboolean inc);
|
||||
gboolean document_search_bar_find(gint idx, const gchar *text, gint flags, gboolean inc);
|
||||
|
||||
/* General search function, used from the find dialog.
|
||||
* Returns -1 on failure or the start position of the matching text. */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user