xed-searchbar.c/h: Clean up styling a bit
This commit is contained in:
parent
5267b52c70
commit
6a997b1b79
|
@ -21,12 +21,14 @@
|
||||||
/* Signals */
|
/* Signals */
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
SHOW_REPLACE, LAST_SIGNAL
|
SHOW_REPLACE,
|
||||||
|
LAST_SIGNAL
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _XedSearchbarPrivate
|
struct _XedSearchbarPrivate
|
||||||
{
|
{
|
||||||
gboolean show_replace;
|
gboolean show_replace;
|
||||||
|
|
||||||
GtkWidget *revealer;
|
GtkWidget *revealer;
|
||||||
GtkWidget *grid;
|
GtkWidget *grid;
|
||||||
GtkWidget *search_label;
|
GtkWidget *search_label;
|
||||||
|
@ -50,7 +52,7 @@ G_DEFINE_TYPE(XedSearchbar, xed_searchbar, GTK_TYPE_BOX)
|
||||||
static void
|
static void
|
||||||
xed_searchbar_class_init (XedSearchbarClass *klass)
|
xed_searchbar_class_init (XedSearchbarClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS(klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
g_type_class_add_private (object_class, sizeof(XedSearchbarPrivate));
|
g_type_class_add_private (object_class, sizeof(XedSearchbarPrivate));
|
||||||
}
|
}
|
||||||
|
@ -65,20 +67,24 @@ text_found (XedWindow *window,
|
||||||
{
|
{
|
||||||
if (occurrences > 1)
|
if (occurrences > 1)
|
||||||
{
|
{
|
||||||
xed_statusbar_flash_message (XED_STATUSBAR(window->priv->statusbar), window->priv->generic_message_cid,
|
xed_statusbar_flash_message (XED_STATUSBAR (window->priv->statusbar),
|
||||||
ngettext ("Found and replaced %d occurrence", "Found and replaced %d occurrences", occurrences),
|
window->priv->generic_message_cid,
|
||||||
|
ngettext ("Found and replaced %d occurrence", "Found and replaced %d occurrences",
|
||||||
|
occurrences),
|
||||||
occurrences);
|
occurrences);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (occurrences == 1)
|
if (occurrences == 1)
|
||||||
{
|
{
|
||||||
xed_statusbar_flash_message (XED_STATUSBAR(window->priv->statusbar), window->priv->generic_message_cid,
|
xed_statusbar_flash_message (XED_STATUSBAR (window->priv->statusbar),
|
||||||
|
window->priv->generic_message_cid,
|
||||||
_("Found and replaced one occurrence"));
|
_("Found and replaced one occurrence"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xed_statusbar_flash_message (XED_STATUSBAR(window->priv->statusbar), window->priv->generic_message_cid,
|
xed_statusbar_flash_message (XED_STATUSBAR (window->priv->statusbar),
|
||||||
|
window->priv->generic_message_cid,
|
||||||
" ");
|
" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,7 +97,8 @@ text_not_found (XedWindow *window,
|
||||||
gchar *searched;
|
gchar *searched;
|
||||||
|
|
||||||
searched = xed_utils_str_end_truncate (text, MAX_MSG_LENGTH);
|
searched = xed_utils_str_end_truncate (text, MAX_MSG_LENGTH);
|
||||||
xed_statusbar_flash_message (XED_STATUSBAR(window->priv->statusbar), window->priv->generic_message_cid,
|
xed_statusbar_flash_message (XED_STATUSBAR (window->priv->statusbar),
|
||||||
|
window->priv->generic_message_cid,
|
||||||
_("\"%s\" not found"), searched);
|
_("\"%s\" not found"), searched);
|
||||||
g_free (searched);
|
g_free (searched);
|
||||||
}
|
}
|
||||||
|
@ -110,14 +117,16 @@ run_search (XedView *view,
|
||||||
gboolean found = FALSE;
|
gboolean found = FALSE;
|
||||||
|
|
||||||
doc = XED_DOCUMENT(gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
|
doc = XED_DOCUMENT(gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
|
||||||
gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER(doc), &start_iter, &end_iter);
|
gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (doc), &start_iter, &end_iter);
|
||||||
|
|
||||||
if (!search_backwards)
|
if (!search_backwards)
|
||||||
{
|
{
|
||||||
if (jump_to_next_result) {
|
if (jump_to_next_result)
|
||||||
|
{
|
||||||
found = xed_document_search_forward (doc, &end_iter, NULL, &match_start, &match_end);
|
found = xed_document_search_forward (doc, &end_iter, NULL, &match_start, &match_end);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
found = xed_document_search_forward (doc, &start_iter, NULL, &match_start, &match_end);
|
found = xed_document_search_forward (doc, &start_iter, NULL, &match_start, &match_end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,13 +151,13 @@ run_search (XedView *view,
|
||||||
|
|
||||||
if (found)
|
if (found)
|
||||||
{
|
{
|
||||||
gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER(doc), &match_start);
|
gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (doc), &match_start);
|
||||||
gtk_text_buffer_move_mark_by_name (GTK_TEXT_BUFFER(doc), "selection_bound", &match_end);
|
gtk_text_buffer_move_mark_by_name (GTK_TEXT_BUFFER (doc), "selection_bound", &match_end);
|
||||||
xed_view_scroll_to_cursor (view);
|
xed_view_scroll_to_cursor (view);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER(doc), &start_iter);
|
gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (doc), &start_iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
|
@ -178,15 +187,15 @@ do_find (XedSearchbar *searchbar,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
doc = XED_DOCUMENT(gtk_text_view_get_buffer (GTK_TEXT_VIEW (active_view)));
|
doc = XED_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (active_view)));
|
||||||
|
|
||||||
match_case = xed_searchbar_get_match_case (searchbar);
|
match_case = xed_searchbar_get_match_case (searchbar);
|
||||||
entire_word = xed_searchbar_get_entire_word (searchbar);
|
entire_word = xed_searchbar_get_entire_word (searchbar);
|
||||||
wrap_around = xed_searchbar_get_wrap_around (searchbar);
|
wrap_around = xed_searchbar_get_wrap_around (searchbar);
|
||||||
entry_text = xed_searchbar_get_search_text (searchbar);
|
entry_text = xed_searchbar_get_search_text (searchbar);
|
||||||
|
|
||||||
XED_SEARCH_SET_CASE_SENSITIVE(flags, match_case);
|
XED_SEARCH_SET_CASE_SENSITIVE (flags, match_case);
|
||||||
XED_SEARCH_SET_ENTIRE_WORD(flags, entire_word);
|
XED_SEARCH_SET_ENTIRE_WORD (flags, entire_word);
|
||||||
|
|
||||||
search_text = xed_document_get_search_text (doc, &old_flags);
|
search_text = xed_document_get_search_text (doc, &old_flags);
|
||||||
|
|
||||||
|
@ -218,13 +227,13 @@ xed_searchbar_find_again (XedSearchbar *searchbar,
|
||||||
gpointer data;
|
gpointer data;
|
||||||
|
|
||||||
active_view = xed_window_get_active_view (searchbar->window);
|
active_view = xed_window_get_active_view (searchbar->window);
|
||||||
g_return_if_fail(active_view != NULL);
|
g_return_if_fail (active_view != NULL);
|
||||||
|
|
||||||
data = g_object_get_data (G_OBJECT(searchbar->window), XED_SEARCHBAR_KEY);
|
data = g_object_get_data (G_OBJECT (searchbar->window), XED_SEARCHBAR_KEY);
|
||||||
|
|
||||||
if (data != NULL)
|
if (data != NULL)
|
||||||
{
|
{
|
||||||
wrap_around = xed_searchbar_get_wrap_around (XED_SEARCHBAR(data));
|
wrap_around = xed_searchbar_get_wrap_around (XED_SEARCHBAR (data));
|
||||||
}
|
}
|
||||||
|
|
||||||
run_search (active_view, wrap_around, backward, TRUE);
|
run_search (active_view, wrap_around, backward, TRUE);
|
||||||
|
@ -248,8 +257,8 @@ get_selected_text (GtkTextBuffer *doc,
|
||||||
{
|
{
|
||||||
GtkTextIter start, end;
|
GtkTextIter start, end;
|
||||||
|
|
||||||
g_return_val_if_fail(selected_text != NULL, FALSE);
|
g_return_val_if_fail (selected_text != NULL, FALSE);
|
||||||
g_return_val_if_fail(*selected_text == NULL, FALSE);
|
g_return_val_if_fail (*selected_text == NULL, FALSE);
|
||||||
|
|
||||||
if (!gtk_text_buffer_get_selection_bounds (doc, &start, &end))
|
if (!gtk_text_buffer_get_selection_bounds (doc, &start, &end))
|
||||||
{
|
{
|
||||||
|
@ -274,8 +283,8 @@ static void
|
||||||
replace_selected_text (GtkTextBuffer *buffer,
|
replace_selected_text (GtkTextBuffer *buffer,
|
||||||
const gchar *replace)
|
const gchar *replace)
|
||||||
{
|
{
|
||||||
g_return_if_fail(gtk_text_buffer_get_selection_bounds (buffer, NULL, NULL));
|
g_return_if_fail (gtk_text_buffer_get_selection_bounds (buffer, NULL, NULL));
|
||||||
g_return_if_fail(replace != NULL);
|
g_return_if_fail (replace != NULL);
|
||||||
|
|
||||||
gtk_text_buffer_begin_user_action (buffer);
|
gtk_text_buffer_begin_user_action (buffer);
|
||||||
gtk_text_buffer_delete_selection (buffer, FALSE, TRUE);
|
gtk_text_buffer_delete_selection (buffer, FALSE, TRUE);
|
||||||
|
@ -301,22 +310,22 @@ do_replace (XedSearchbar *searchbar)
|
||||||
}
|
}
|
||||||
|
|
||||||
search_entry_text = xed_searchbar_get_search_text (searchbar);
|
search_entry_text = xed_searchbar_get_search_text (searchbar);
|
||||||
g_return_if_fail((search_entry_text) != NULL);
|
g_return_if_fail ((search_entry_text) != NULL);
|
||||||
g_return_if_fail((*search_entry_text) != '\0');
|
g_return_if_fail ((*search_entry_text) != '\0');
|
||||||
|
|
||||||
/* replace text may be "", we just delete */
|
/* replace text may be "", we just delete */
|
||||||
replace_entry_text = xed_searchbar_get_replace_text (searchbar);
|
replace_entry_text = xed_searchbar_get_replace_text (searchbar);
|
||||||
g_return_if_fail((replace_entry_text) != NULL);
|
g_return_if_fail ((replace_entry_text) != NULL);
|
||||||
|
|
||||||
unescaped_search_text = xed_utils_unescape_search_text (search_entry_text);
|
unescaped_search_text = xed_utils_unescape_search_text (search_entry_text);
|
||||||
|
|
||||||
get_selected_text (GTK_TEXT_BUFFER(doc), &selected_text, NULL);
|
get_selected_text (GTK_TEXT_BUFFER (doc), &selected_text, NULL);
|
||||||
|
|
||||||
match_case = xed_searchbar_get_match_case (searchbar);
|
match_case = xed_searchbar_get_match_case (searchbar);
|
||||||
|
|
||||||
if ((selected_text == NULL)
|
if ((selected_text == NULL) ||
|
||||||
|| (match_case && (strcmp (selected_text, unescaped_search_text) != 0))
|
(match_case && (strcmp (selected_text, unescaped_search_text) != 0)) ||
|
||||||
|| (!match_case && !g_utf8_caselessnmatch (selected_text,
|
(!match_case && !g_utf8_caselessnmatch (selected_text,
|
||||||
unescaped_search_text,
|
unescaped_search_text,
|
||||||
strlen (selected_text),
|
strlen (selected_text),
|
||||||
strlen (unescaped_search_text)) != 0))
|
strlen (unescaped_search_text)) != 0))
|
||||||
|
@ -329,7 +338,7 @@ do_replace (XedSearchbar *searchbar)
|
||||||
}
|
}
|
||||||
|
|
||||||
unescaped_replace_text = xed_utils_unescape_search_text (replace_entry_text);
|
unescaped_replace_text = xed_utils_unescape_search_text (replace_entry_text);
|
||||||
replace_selected_text (GTK_TEXT_BUFFER(doc), unescaped_replace_text);
|
replace_selected_text (GTK_TEXT_BUFFER (doc), unescaped_replace_text);
|
||||||
|
|
||||||
g_free (unescaped_search_text);
|
g_free (unescaped_search_text);
|
||||||
g_free (selected_text);
|
g_free (selected_text);
|
||||||
|
@ -356,21 +365,21 @@ do_replace_all (XedSearchbar *searchbar)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
doc = XED_DOCUMENT(gtk_text_view_get_buffer (GTK_TEXT_VIEW (active_view)));
|
doc = XED_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (active_view)));
|
||||||
|
|
||||||
search_entry_text = xed_searchbar_get_search_text (searchbar);
|
search_entry_text = xed_searchbar_get_search_text (searchbar);
|
||||||
g_return_if_fail((search_entry_text) != NULL);
|
g_return_if_fail ((search_entry_text) != NULL);
|
||||||
g_return_if_fail((*search_entry_text) != '\0');
|
g_return_if_fail ((*search_entry_text) != '\0');
|
||||||
|
|
||||||
/* replace text may be "", we just delete all occurrences */
|
/* replace text may be "", we just delete all occurrences */
|
||||||
replace_entry_text = xed_searchbar_get_replace_text (searchbar);
|
replace_entry_text = xed_searchbar_get_replace_text (searchbar);
|
||||||
g_return_if_fail((replace_entry_text) != NULL);
|
g_return_if_fail ((replace_entry_text) != NULL);
|
||||||
|
|
||||||
match_case = xed_searchbar_get_match_case (searchbar);
|
match_case = xed_searchbar_get_match_case (searchbar);
|
||||||
entire_word = xed_searchbar_get_entire_word (searchbar);
|
entire_word = xed_searchbar_get_entire_word (searchbar);
|
||||||
|
|
||||||
XED_SEARCH_SET_CASE_SENSITIVE(flags, match_case);
|
XED_SEARCH_SET_CASE_SENSITIVE (flags, match_case);
|
||||||
XED_SEARCH_SET_ENTIRE_WORD(flags, entire_word);
|
XED_SEARCH_SET_ENTIRE_WORD (flags, entire_word);
|
||||||
|
|
||||||
count = xed_document_replace_all (doc, search_entry_text, replace_entry_text, flags);
|
count = xed_document_replace_all (doc, search_entry_text, replace_entry_text, flags);
|
||||||
|
|
||||||
|
@ -577,7 +586,7 @@ xed_searchbar_init (XedSearchbar *searchbar)
|
||||||
gtk_grid_attach (GTK_GRID (searchbar->priv->grid), searchbar->priv->search_entry, 2, 0, 1, 1);
|
gtk_grid_attach (GTK_GRID (searchbar->priv->grid), searchbar->priv->search_entry, 2, 0, 1, 1);
|
||||||
|
|
||||||
searchbar->priv->replace_entry = xed_history_entry_new ("history-replace-with", TRUE);
|
searchbar->priv->replace_entry = xed_history_entry_new ("history-replace-with", TRUE);
|
||||||
xed_history_entry_set_escape_func (XED_HISTORY_ENTRY(searchbar->priv->replace_entry),
|
xed_history_entry_set_escape_func (XED_HISTORY_ENTRY (searchbar->priv->replace_entry),
|
||||||
(XedHistoryEntryEscapeFunc) xed_utils_escape_search_text);
|
(XedHistoryEntryEscapeFunc) xed_utils_escape_search_text);
|
||||||
|
|
||||||
searchbar->priv->replace_text_entry = xed_history_entry_get_entry (
|
searchbar->priv->replace_text_entry = xed_history_entry_get_entry (
|
||||||
|
@ -653,7 +662,7 @@ xed_searchbar_new (GtkWindow *parent,
|
||||||
XedSearchbar *searchbar;
|
XedSearchbar *searchbar;
|
||||||
searchbar = g_object_new (XED_TYPE_SEARCHBAR, NULL);
|
searchbar = g_object_new (XED_TYPE_SEARCHBAR, NULL);
|
||||||
searchbar->window = XED_WINDOW (parent);
|
searchbar->window = XED_WINDOW (parent);
|
||||||
return GTK_WIDGET(searchbar);
|
return GTK_WIDGET (searchbar);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -667,9 +676,9 @@ xed_searchbar_show (XedSearchbar *searchbar,
|
||||||
gint sel_len;
|
gint sel_len;
|
||||||
|
|
||||||
doc = xed_window_get_active_document (searchbar->window);
|
doc = xed_window_get_active_document (searchbar->window);
|
||||||
g_return_if_fail(doc != NULL);
|
g_return_if_fail (doc != NULL);
|
||||||
|
|
||||||
selection_exists = get_selected_text (GTK_TEXT_BUFFER(doc), &find_text, &sel_len);
|
selection_exists = get_selected_text (GTK_TEXT_BUFFER (doc), &find_text, &sel_len);
|
||||||
|
|
||||||
if (selection_exists && find_text != NULL && sel_len < 80)
|
if (selection_exists && find_text != NULL && sel_len < 80)
|
||||||
{
|
{
|
||||||
|
@ -680,11 +689,11 @@ xed_searchbar_show (XedSearchbar *searchbar,
|
||||||
* search for '\n' and then open the search searchbar again,
|
* search for '\n' and then open the search searchbar again,
|
||||||
* you'll get an unprintable single-character literal '\n' in the "search for" box).
|
* you'll get an unprintable single-character literal '\n' in the "search for" box).
|
||||||
*/
|
*/
|
||||||
search_text = xed_searchbar_get_search_text (XED_SEARCHBAR(searchbar));
|
search_text = xed_searchbar_get_search_text (XED_SEARCHBAR (searchbar));
|
||||||
if (!(search_text != NULL && !strcmp (xed_utils_unescape_search_text (search_text), find_text)))
|
if (!(search_text != NULL && !strcmp (xed_utils_unescape_search_text (search_text), find_text)))
|
||||||
{
|
{
|
||||||
/* General case */
|
/* General case */
|
||||||
xed_searchbar_set_search_text (XED_SEARCHBAR(searchbar), find_text);
|
xed_searchbar_set_search_text (XED_SEARCHBAR (searchbar), find_text);
|
||||||
}
|
}
|
||||||
g_free (find_text);
|
g_free (find_text);
|
||||||
}
|
}
|
||||||
|
@ -692,15 +701,15 @@ xed_searchbar_show (XedSearchbar *searchbar,
|
||||||
{
|
{
|
||||||
g_free (find_text);
|
g_free (find_text);
|
||||||
}
|
}
|
||||||
gtk_revealer_set_transition_type (GTK_REVEALER(searchbar->priv->revealer), GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP);
|
gtk_revealer_set_transition_type (GTK_REVEALER (searchbar->priv->revealer), GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP);
|
||||||
gtk_revealer_set_reveal_child (GTK_REVEALER(searchbar->priv->revealer), TRUE);
|
gtk_revealer_set_reveal_child (GTK_REVEALER (searchbar->priv->revealer), TRUE);
|
||||||
if (show_replace)
|
if (show_replace)
|
||||||
{
|
{
|
||||||
gtk_widget_show (searchbar->priv->replace_label);
|
gtk_widget_show (searchbar->priv->replace_label);
|
||||||
gtk_widget_show (searchbar->priv->replace_entry);
|
gtk_widget_show (searchbar->priv->replace_entry);
|
||||||
gtk_widget_show (searchbar->priv->replace_all_button);
|
gtk_widget_show (searchbar->priv->replace_all_button);
|
||||||
gtk_widget_show (searchbar->priv->replace_button);
|
gtk_widget_show (searchbar->priv->replace_button);
|
||||||
gtk_grid_set_row_spacing (GTK_GRID(searchbar->priv->grid), 10);
|
gtk_grid_set_row_spacing (GTK_GRID (searchbar->priv->grid), 10);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -708,7 +717,7 @@ xed_searchbar_show (XedSearchbar *searchbar,
|
||||||
gtk_widget_hide (searchbar->priv->replace_entry);
|
gtk_widget_hide (searchbar->priv->replace_entry);
|
||||||
gtk_widget_hide (searchbar->priv->replace_all_button);
|
gtk_widget_hide (searchbar->priv->replace_all_button);
|
||||||
gtk_widget_hide (searchbar->priv->replace_button);
|
gtk_widget_hide (searchbar->priv->replace_button);
|
||||||
gtk_grid_set_row_spacing (GTK_GRID(searchbar->priv->grid), 0);
|
gtk_grid_set_row_spacing (GTK_GRID (searchbar->priv->grid), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_widget_show (searchbar->priv->find_button);
|
gtk_widget_show (searchbar->priv->find_button);
|
||||||
|
@ -718,14 +727,14 @@ xed_searchbar_show (XedSearchbar *searchbar,
|
||||||
void
|
void
|
||||||
xed_searchbar_hide (XedSearchbar *searchbar)
|
xed_searchbar_hide (XedSearchbar *searchbar)
|
||||||
{
|
{
|
||||||
gtk_revealer_set_transition_type (GTK_REVEALER(searchbar->priv->revealer), GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN);
|
gtk_revealer_set_transition_type (GTK_REVEALER (searchbar->priv->revealer), GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN);
|
||||||
gtk_revealer_set_reveal_child (GTK_REVEALER(searchbar->priv->revealer), FALSE);
|
gtk_revealer_set_reveal_child (GTK_REVEALER (searchbar->priv->revealer), FALSE);
|
||||||
|
|
||||||
// focus document
|
// focus document
|
||||||
XedView *active_view = xed_window_get_active_view (searchbar->window);
|
XedView *active_view = xed_window_get_active_view (searchbar->window);
|
||||||
if (active_view != NULL)
|
if (active_view != NULL)
|
||||||
{
|
{
|
||||||
gtk_widget_grab_focus (GTK_WIDGET(active_view));
|
gtk_widget_grab_focus (GTK_WIDGET (active_view));
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove highlighting
|
// remove highlighting
|
||||||
|
@ -736,9 +745,9 @@ void
|
||||||
xed_searchbar_set_search_text (XedSearchbar *searchbar,
|
xed_searchbar_set_search_text (XedSearchbar *searchbar,
|
||||||
const gchar *text)
|
const gchar *text)
|
||||||
{
|
{
|
||||||
g_return_if_fail(XED_IS_SEARCHBAR (searchbar));
|
g_return_if_fail (XED_IS_SEARCHBAR (searchbar));
|
||||||
g_return_if_fail(text != NULL);
|
g_return_if_fail (text != NULL);
|
||||||
gtk_entry_set_text (GTK_ENTRY(searchbar->priv->search_text_entry), text);
|
gtk_entry_set_text (GTK_ENTRY (searchbar->priv->search_text_entry), text);
|
||||||
search_buttons_set_sensitive (searchbar, (text != '\0'));
|
search_buttons_set_sensitive (searchbar, (text != '\0'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -748,68 +757,68 @@ xed_searchbar_set_search_text (XedSearchbar *searchbar,
|
||||||
const gchar *
|
const gchar *
|
||||||
xed_searchbar_get_search_text (XedSearchbar *searchbar)
|
xed_searchbar_get_search_text (XedSearchbar *searchbar)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(XED_IS_SEARCHBAR (searchbar), NULL);
|
g_return_val_if_fail (XED_IS_SEARCHBAR (searchbar), NULL);
|
||||||
return gtk_entry_get_text (GTK_ENTRY(searchbar->priv->search_text_entry));
|
return gtk_entry_get_text (GTK_ENTRY (searchbar->priv->search_text_entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xed_searchbar_set_replace_text (XedSearchbar *searchbar,
|
xed_searchbar_set_replace_text (XedSearchbar *searchbar,
|
||||||
const gchar *text)
|
const gchar *text)
|
||||||
{
|
{
|
||||||
g_return_if_fail(XED_IS_SEARCHBAR (searchbar));
|
g_return_if_fail (XED_IS_SEARCHBAR (searchbar));
|
||||||
g_return_if_fail(text != NULL);
|
g_return_if_fail (text != NULL);
|
||||||
|
|
||||||
gtk_entry_set_text (GTK_ENTRY(searchbar->priv->replace_text_entry), text);
|
gtk_entry_set_text (GTK_ENTRY (searchbar->priv->replace_text_entry), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
const gchar *
|
const gchar *
|
||||||
xed_searchbar_get_replace_text (XedSearchbar *searchbar)
|
xed_searchbar_get_replace_text (XedSearchbar *searchbar)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(XED_IS_SEARCHBAR (searchbar), NULL);
|
g_return_val_if_fail (XED_IS_SEARCHBAR (searchbar), NULL);
|
||||||
return gtk_entry_get_text (GTK_ENTRY(searchbar->priv->replace_text_entry));
|
return gtk_entry_get_text (GTK_ENTRY (searchbar->priv->replace_text_entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xed_searchbar_set_match_case (XedSearchbar *searchbar,
|
xed_searchbar_set_match_case (XedSearchbar *searchbar,
|
||||||
gboolean match_case)
|
gboolean match_case)
|
||||||
{
|
{
|
||||||
g_return_if_fail(XED_IS_SEARCHBAR (searchbar));
|
g_return_if_fail (XED_IS_SEARCHBAR (searchbar));
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(searchbar->priv->match_case_checkbutton), match_case);
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (searchbar->priv->match_case_checkbutton), match_case);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
xed_searchbar_get_match_case (XedSearchbar *searchbar)
|
xed_searchbar_get_match_case (XedSearchbar *searchbar)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(XED_IS_SEARCHBAR (searchbar), FALSE);
|
g_return_val_if_fail (XED_IS_SEARCHBAR (searchbar), FALSE);
|
||||||
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(searchbar->priv->match_case_checkbutton));
|
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (searchbar->priv->match_case_checkbutton));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xed_searchbar_set_entire_word (XedSearchbar *searchbar,
|
xed_searchbar_set_entire_word (XedSearchbar *searchbar,
|
||||||
gboolean entire_word)
|
gboolean entire_word)
|
||||||
{
|
{
|
||||||
g_return_if_fail(XED_IS_SEARCHBAR (searchbar));
|
g_return_if_fail (XED_IS_SEARCHBAR (searchbar));
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(searchbar->priv->entire_word_checkbutton), entire_word);
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (searchbar->priv->entire_word_checkbutton), entire_word);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
xed_searchbar_get_entire_word (XedSearchbar *searchbar)
|
xed_searchbar_get_entire_word (XedSearchbar *searchbar)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(XED_IS_SEARCHBAR (searchbar), FALSE);
|
g_return_val_if_fail (XED_IS_SEARCHBAR (searchbar), FALSE);
|
||||||
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(searchbar->priv->entire_word_checkbutton));
|
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (searchbar->priv->entire_word_checkbutton));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xed_searchbar_set_wrap_around (XedSearchbar *searchbar,
|
xed_searchbar_set_wrap_around (XedSearchbar *searchbar,
|
||||||
gboolean wrap_around)
|
gboolean wrap_around)
|
||||||
{
|
{
|
||||||
g_return_if_fail(XED_IS_SEARCHBAR (searchbar));
|
g_return_if_fail (XED_IS_SEARCHBAR (searchbar));
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(searchbar->priv->wrap_around_checkbutton), wrap_around);
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (searchbar->priv->wrap_around_checkbutton), wrap_around);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
xed_searchbar_get_wrap_around (XedSearchbar *searchbar)
|
xed_searchbar_get_wrap_around (XedSearchbar *searchbar)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(XED_IS_SEARCHBAR (searchbar), FALSE);
|
g_return_val_if_fail (XED_IS_SEARCHBAR (searchbar), FALSE);
|
||||||
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(searchbar->priv->wrap_around_checkbutton));
|
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (searchbar->priv->wrap_around_checkbutton));
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
/*
|
|
||||||
* Type checking and casting macros
|
|
||||||
*/
|
|
||||||
#define XED_TYPE_SEARCHBAR (xed_searchbar_get_type())
|
#define XED_TYPE_SEARCHBAR (xed_searchbar_get_type())
|
||||||
#define XED_SEARCHBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XED_TYPE_SEARCHBAR, XedSearchbar))
|
#define XED_SEARCHBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XED_TYPE_SEARCHBAR, XedSearchbar))
|
||||||
#define XED_SEARCHBAR_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XED_TYPE_SEARCHBAR, XedSearchbar const))
|
#define XED_SEARCHBAR_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XED_TYPE_SEARCHBAR, XedSearchbar const))
|
||||||
|
@ -18,13 +15,9 @@ G_BEGIN_DECLS
|
||||||
#define XED_IS_SEARCHBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_SEARCHBAR))
|
#define XED_IS_SEARCHBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_SEARCHBAR))
|
||||||
#define XED_SEARCHBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XED_TYPE_SEARCHBAR, XedSearchbarClass))
|
#define XED_SEARCHBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XED_TYPE_SEARCHBAR, XedSearchbarClass))
|
||||||
|
|
||||||
/* Private structure type */
|
|
||||||
typedef struct _XedSearchbarPrivate XedSearchbarPrivate;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Main object structure
|
|
||||||
*/
|
|
||||||
typedef struct _XedSearchbar XedSearchbar;
|
typedef struct _XedSearchbar XedSearchbar;
|
||||||
|
typedef struct _XedSearchbarPrivate XedSearchbarPrivate;
|
||||||
|
typedef struct _XedSearchbarClass XedSearchbarClass;
|
||||||
|
|
||||||
struct _XedSearchbar
|
struct _XedSearchbar
|
||||||
{
|
{
|
||||||
|
@ -35,11 +28,6 @@ struct _XedSearchbar
|
||||||
XedSearchbarPrivate *priv;
|
XedSearchbarPrivate *priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Class definition
|
|
||||||
*/
|
|
||||||
typedef struct _XedSearchbarClass XedSearchbarClass;
|
|
||||||
|
|
||||||
struct _XedSearchbarClass
|
struct _XedSearchbarClass
|
||||||
{
|
{
|
||||||
GtkBoxClass parent_class;
|
GtkBoxClass parent_class;
|
||||||
|
@ -55,9 +43,6 @@ enum
|
||||||
XED_SEARCHBAR_REPLACE_ALL_RESPONSE
|
XED_SEARCHBAR_REPLACE_ALL_RESPONSE
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Public methods
|
|
||||||
*/
|
|
||||||
GType xed_searchbar_get_type (void) G_GNUC_CONST;
|
GType xed_searchbar_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
GtkWidget *xed_searchbar_new (GtkWindow *parent, gboolean show_replace);
|
GtkWidget *xed_searchbar_new (GtkWindow *parent, gboolean show_replace);
|
||||||
|
|
Loading…
Reference in New Issue