Replace search window with a searchbar

This commit is contained in:
TingPing 2013-07-24 20:47:01 -04:00
parent aa37686bbd
commit b0b8f40791
11 changed files with 214 additions and 313 deletions

View File

@ -438,6 +438,7 @@ const struct prefs vars[] =
{"gui_pane_right_size", P_OFFINT (hex_gui_pane_right_size), TYPE_INT},
{"gui_pane_right_size_min", P_OFFINT (hex_gui_pane_right_size_min), TYPE_INT},
{"gui_quit_dialog", P_OFFINT (hex_gui_quit_dialog), TYPE_BOOL},
{"gui_search_pos", P_OFFINT (hex_gui_search_pos), TYPE_INT},
/* {"gui_single", P_OFFINT (hex_gui_single), TYPE_BOOL}, */
{"gui_slist_fav", P_OFFINT (hex_gui_slist_fav), TYPE_BOOL},
{"gui_slist_select", P_OFFINT (hex_gui_slist_select), TYPE_INT},
@ -573,7 +574,6 @@ const struct prefs vars[] =
{"text_max_lines", P_OFFINT (hex_text_max_lines), TYPE_INT},
{"text_replay", P_OFFINT (hex_text_replay), TYPE_BOOL},
{"text_search_case_match", P_OFFINT (hex_text_search_case_match), TYPE_BOOL},
{"text_search_backward", P_OFFINT (hex_text_search_backward), TYPE_BOOL},
{"text_search_highlight_all", P_OFFINT (hex_text_search_highlight_all), TYPE_BOOL},
{"text_search_follow", P_OFFINT (hex_text_search_follow), TYPE_BOOL},
{"text_search_regexp", P_OFFINT (hex_text_search_regexp), TYPE_BOOL},

View File

@ -231,7 +231,6 @@ struct hexchatprefs
unsigned int hex_text_indent;
unsigned int hex_text_replay;
unsigned int hex_text_search_case_match;
unsigned int hex_text_search_backward;
unsigned int hex_text_search_highlight_all;
unsigned int hex_text_search_follow;
unsigned int hex_text_search_regexp;
@ -278,6 +277,7 @@ struct hexchatprefs
int hex_gui_pane_left_size;
int hex_gui_pane_right_size;
int hex_gui_pane_right_size_min;
int hex_gui_search_pos;
int hex_gui_slist_select;
int hex_gui_tab_layout;
int hex_gui_tab_newtofront;

View File

@ -10,7 +10,7 @@ EXTRA_DIST = \
about.h ascii.h banlist.h chanlist.h chanview.h chanview-tabs.c \
chanview-tree.c custom-list.h editlist.h fe-gtk.h fkeys.h gtkutil.h joind.h \
maingui.h menu.h mmx_cmod.S mmx_cmod.h notifygui.h palette.h pixmaps.h \
plugin-tray.h plugingui.c plugingui.h rawlog.h search.h sexy-iso-codes.h \
plugin-tray.h plugingui.c plugingui.h rawlog.h sexy-iso-codes.h \
sexy-spell-entry.h sexy-marshal.h textgui.h urlgrab.h userlistgui.h xtext.h
if USE_MMX
@ -29,5 +29,5 @@ endif
hexchat_SOURCES = about.c ascii.c banlist.c chanlist.c chanview.c custom-list.c \
dccgui.c editlist.c fe-gtk.c fkeys.c gtkutil.c ignoregui.c joind.c menu.c \
maingui.c $(mmx_cmod_S) notifygui.c palette.c pixmaps.c plugin-tray.c $(plugingui_c) \
rawlog.c search.c servlistgui.c setup.c $(sexy_spell) textgui.c \
rawlog.c servlistgui.c setup.c $(sexy_spell) textgui.c \
urlgrab.c userlistgui.c xtext.c

View File

@ -176,6 +176,9 @@ typedef struct session_gui
*limit_entry, /* +l */
*key_entry; /* +k */
GtkWidget *shbox, *shentry; /* search bar hbox */
gulong search_changed_signal; /* hook for search change event so blanking the box doesn't suck */
#define MENU_ID_NUM 12
GtkWidget *menu_item[MENU_ID_NUM+1]; /* some items we may change state of */

View File

@ -118,7 +118,6 @@
<ClInclude Include="plugin-tray.h" />
<ClInclude Include="plugingui.h" />
<ClInclude Include="rawlog.h" />
<ClInclude Include="search.h" />
<ClInclude Include="servlistgui.h" />
<ClInclude Include="setup.h" />
<ClInclude Include="sexy-iso-codes.h" />
@ -151,7 +150,6 @@
<ClCompile Include="plugin-tray.c" />
<ClCompile Include="plugingui.c" />
<ClCompile Include="rawlog.c" />
<ClCompile Include="search.c" />
<ClCompile Include="servlistgui.c" />
<ClCompile Include="setup.c" />
<ClCompile Include="sexy-iso-codes.c" />

View File

@ -75,9 +75,6 @@
<ClInclude Include="rawlog.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="search.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="sexy-iso-codes.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -170,9 +167,6 @@
<ClCompile Include="rawlog.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="search.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="servlistgui.c">
<Filter>Source Files</Filter>
</ClCompile>

View File

@ -21,6 +21,8 @@
#include <stdio.h>
#include <ctype.h>
#include <gdk/gdkkeysyms.h>
#include "../common/hexchat.h"
#include "../common/fe.h"
#include "../common/server.h"
@ -33,6 +35,7 @@
#include "../common/util.h"
#include "../common/text.h"
#include "../common/chanopt.h"
#include "../common/cfgfiles.h"
#include "fe-gtk.h"
#include "banlist.h"
@ -77,6 +80,7 @@ enum
#define TAG_UTIL 1 /* dcc, notify, chanlist */
static void mg_create_entry (session *sess, GtkWidget *box);
static void mg_create_search (session *sess, GtkWidget *box);
static void mg_link_irctab (session *sess, int focus);
static session_gui static_mg_gui;
@ -2619,7 +2623,18 @@ mg_create_center (session *sess, session_gui *gui, GtkWidget *box)
vbox = gtk_vbox_new (FALSE, 3);
gtk_notebook_append_page (GTK_NOTEBOOK (book), vbox, NULL);
mg_create_topicbar (sess, vbox);
mg_create_textarea (sess, vbox);
if (prefs.hex_gui_search_pos)
{
mg_create_search (sess, vbox);
mg_create_textarea (sess, vbox);
}
else
{
mg_create_textarea (sess, vbox);
mg_create_search (sess, vbox);
}
mg_create_entry (sess, vbox);
mg_add_pane_signals (gui);
@ -2814,6 +2829,183 @@ mg_inputbox_rightclick (GtkEntry *entry, GtkWidget *menu)
mg_create_color_menu (menu, NULL);
}
/* Search bar adapted from Conspire's by William Pitcock */
#define SEARCH_CHANGE 1
#define SEARCH_NEXT 2
#define SEARCH_PREVIOUS 3
#define SEARCH_REFRESH 4
static void
search_handle_event(int search_type, session *sess)
{
textentry *last;
const gchar *text = NULL;
gtk_xtext_search_flags flags;
GError *err = NULL;
gboolean backwards = FALSE;
/* When just typing show most recent first */
if (search_type == SEARCH_PREVIOUS || search_type == SEARCH_CHANGE)
backwards = TRUE;
flags = ((prefs.hex_text_search_case_match == 1? case_match: 0) |
(backwards? backward: 0) |
(prefs.hex_text_search_highlight_all == 1? highlight: 0) |
(prefs.hex_text_search_follow == 1? follow: 0) |
(prefs.hex_text_search_regexp == 1? regexp: 0));
if (search_type != SEARCH_REFRESH)
text = gtk_entry_get_text (GTK_ENTRY(sess->gui->shentry));
last = gtk_xtext_search (GTK_XTEXT (sess->gui->xtext), text, flags, &err);
if (err)
{
gtk_entry_set_icon_from_stock (GTK_ENTRY (sess->gui->shentry), GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_DIALOG_ERROR);
gtk_entry_set_icon_tooltip_text (GTK_ENTRY (sess->gui->shentry), GTK_ENTRY_ICON_SECONDARY, _(err->message));
g_error_free (err);
}
else if (!last)
{
/* Either end of search or not found, try again to wrap if only end */
last = gtk_xtext_search (GTK_XTEXT (sess->gui->xtext), text, flags, &err);
if (!last) /* Not found error */
{
gtk_entry_set_icon_from_stock (GTK_ENTRY (sess->gui->shentry), GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_DIALOG_ERROR);
gtk_entry_set_icon_tooltip_text (GTK_ENTRY (sess->gui->shentry), GTK_ENTRY_ICON_SECONDARY, _("No results found."));
}
}
else
{
gtk_entry_set_icon_from_stock (GTK_ENTRY (sess->gui->shentry), GTK_ENTRY_ICON_SECONDARY, NULL);
}
}
static void
search_handle_change(GtkWidget *wid, session *sess)
{
search_handle_event(SEARCH_CHANGE, sess);
}
static void
search_handle_refresh(GtkWidget *wid, session *sess)
{
search_handle_event(SEARCH_REFRESH, sess);
}
void
mg_search_handle_previous(GtkWidget *wid, session *sess)
{
search_handle_event(SEARCH_PREVIOUS, sess);
}
void
mg_search_handle_next(GtkWidget *wid, session *sess)
{
search_handle_event(SEARCH_NEXT, sess);
}
static void
search_set_option (GtkToggleButton *but, guint *pref)
{
*pref = gtk_toggle_button_get_active(but);
save_config();
}
void
mg_search_toggle(session *sess)
{
if (gtk_widget_get_visible(sess->gui->shbox))
{
gtk_widget_hide(sess->gui->shbox);
gtk_widget_grab_focus(sess->gui->input_box);
gtk_entry_set_text(GTK_ENTRY(sess->gui->shentry), "");
}
else
{
/* Reset search state */
gtk_entry_set_icon_from_stock (GTK_ENTRY (sess->gui->shentry), GTK_ENTRY_ICON_SECONDARY, NULL);
/* Show and focus */
gtk_widget_show(sess->gui->shbox);
gtk_widget_grab_focus(sess->gui->shentry);
}
}
static gboolean
search_handle_esc (GtkWidget *win, GdkEventKey *key, session *sess)
{
if (key->keyval == GDK_KEY_Escape)
mg_search_toggle(sess);
return FALSE;
}
static void
mg_create_search(session *sess, GtkWidget *box)
{
GtkWidget *entry, *label, *next, *previous, *highlight, *matchcase, *regex, *close;
session_gui *gui = sess->gui;
gui->shbox = gtk_hbox_new(FALSE, 5);
gtk_box_pack_start(GTK_BOX(box), gui->shbox, FALSE, FALSE, 0);
close = gtk_button_new ();
gtk_button_set_image (GTK_BUTTON (close), gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU));
gtk_button_set_relief(GTK_BUTTON(close), GTK_RELIEF_NONE);
gtk_widget_set_can_focus (close, FALSE);
gtk_box_pack_start(GTK_BOX(gui->shbox), close, FALSE, FALSE, 0);
g_signal_connect_swapped(G_OBJECT(close), "clicked", G_CALLBACK(mg_search_toggle), sess);
label = gtk_label_new(_("Find:"));
gtk_box_pack_start(GTK_BOX(gui->shbox), label, FALSE, FALSE, 0);
gui->shentry = entry = gtk_entry_new();
gtk_box_pack_start(GTK_BOX(gui->shbox), entry, FALSE, FALSE, 0);
gtk_widget_set_size_request (gui->shentry, 180, -1);
gui->search_changed_signal = g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(search_handle_change), sess);
g_signal_connect (G_OBJECT (entry), "key_press_event", G_CALLBACK (search_handle_esc), sess);
g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(mg_search_handle_next), sess);
gtk_entry_set_icon_activatable (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY, FALSE);
gtk_entry_set_icon_tooltip_text (GTK_ENTRY (sess->gui->shentry), GTK_ENTRY_ICON_SECONDARY, _("Search hit end or not found."));
previous = gtk_button_new ();
gtk_button_set_image (GTK_BUTTON (previous), gtk_image_new_from_stock (GTK_STOCK_GO_BACK, GTK_ICON_SIZE_MENU));
gtk_button_set_relief(GTK_BUTTON(previous), GTK_RELIEF_NONE);
gtk_widget_set_can_focus (previous, FALSE);
gtk_box_pack_start(GTK_BOX(gui->shbox), previous, FALSE, FALSE, 0);
g_signal_connect(G_OBJECT(previous), "clicked", G_CALLBACK(mg_search_handle_previous), sess);
next = gtk_button_new ();
gtk_button_set_image (GTK_BUTTON (next), gtk_image_new_from_stock (GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_MENU));
gtk_button_set_relief(GTK_BUTTON(next), GTK_RELIEF_NONE);
gtk_widget_set_can_focus (next, FALSE);
gtk_box_pack_start(GTK_BOX(gui->shbox), next, FALSE, FALSE, 0);
g_signal_connect(G_OBJECT(next), "clicked", G_CALLBACK(mg_search_handle_next), sess);
highlight = gtk_check_button_new_with_mnemonic (_("Highlight _all"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(highlight), prefs.hex_text_search_case_match);
gtk_widget_set_can_focus (highlight, FALSE);
g_signal_connect (G_OBJECT (highlight), "toggled", G_CALLBACK (search_set_option), &prefs.hex_text_search_highlight_all);
g_signal_connect (G_OBJECT (highlight), "toggled", G_CALLBACK (search_handle_refresh), sess);
gtk_box_pack_start(GTK_BOX(gui->shbox), highlight, FALSE, FALSE, 0);
add_tip (highlight, _("Highlight all occurrences, and underline the current occurrence."));
matchcase = gtk_check_button_new_with_mnemonic (_("Mat_ch case"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(matchcase), prefs.hex_text_search_case_match);
gtk_widget_set_can_focus (matchcase, FALSE);
g_signal_connect (G_OBJECT (matchcase), "toggled", G_CALLBACK (search_set_option), &prefs.hex_text_search_case_match);
gtk_box_pack_start(GTK_BOX(gui->shbox), matchcase, FALSE, FALSE, 0);
add_tip (matchcase, _("Perform a case-sensitive search."));
regex = gtk_check_button_new_with_mnemonic (_("_Regex"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(regex), prefs.hex_text_search_regexp);
gtk_widget_set_can_focus (regex, FALSE);
g_signal_connect (G_OBJECT (regex), "toggled", G_CALLBACK (search_set_option), &prefs.hex_text_search_regexp);
gtk_box_pack_start(GTK_BOX(gui->shbox), regex, FALSE, FALSE, 0);
add_tip (regex, _("Regard search string as a regular expression."));
}
static void
mg_create_entry (session *sess, GtkWidget *box)
{
@ -3055,6 +3247,8 @@ mg_create_topwindow (session *sess)
if (!prefs.hex_gui_input_nick)
gtk_widget_hide (sess->gui->nick_box);
gtk_widget_hide(sess->gui->shbox);
mg_decide_userlist (sess, FALSE);
if (sess->type == SESS_DIALOG)
@ -3158,6 +3352,8 @@ mg_create_tabwindow (session *sess)
if (!prefs.hex_gui_input_nick)
gtk_widget_hide (sess->gui->nick_box);
gtk_widget_hide (sess->gui->shbox);
mg_place_userlist_and_chanview (sess->gui);
gtk_widget_show (win);

View File

@ -52,6 +52,10 @@ GtkWidget *mg_submenu (GtkWidget *menu, char *text);
gboolean mg_drag_begin_cb (GtkWidget *widget, GdkDragContext *context, gpointer userdata);
void mg_drag_end_cb (GtkWidget *widget, GdkDragContext *context, gpointer userdata);
gboolean mg_drag_drop_cb (GtkWidget *widget, GdkDragContext *context, int x, int y, guint time, gpointer user_data);
gboolean mg_drag_motion_cb (GtkWidget *widget, GdkDragContext *context, int x, int y, guint time, gpointer user_data);
gboolean mg_drag_motion_cb (GtkWidget *widget, GdkDragContext *context, int x, int y, guint time, gpointer user_data);
/* search */
void mg_search_toggle(session *sess);
void mg_search_handle_previous(GtkWidget *wid, session *sess);
void mg_search_handle_next(GtkWidget *wid, session *sess);
#endif

View File

@ -1237,41 +1237,19 @@ menu_quit (GtkWidget * wid, gpointer none)
static void
menu_search ()
{
search_open (current_sess);
mg_search_toggle (current_sess);
}
static void
menu_search_next ()
menu_search_next (GtkWidget *wid)
{
GtkXText *xtext = GTK_XTEXT (current_sess->gui->xtext);
xtext_buffer *buf = xtext->buffer;
if (!gtk_xtext_search (xtext, buf->search_text,
(buf->search_flags & (case_match | follow | regexp)), NULL))
{
fe_message (_("Search hit end, not found."), FE_MSG_ERROR);
}
mg_search_handle_next(wid, current_sess);
}
static void
menu_search_prev ()
menu_search_prev (GtkWidget *wid)
{
GtkXText *xtext = GTK_XTEXT (current_sess->gui->xtext);
xtext_buffer *buf = xtext->buffer;
if (!gtk_xtext_search(xtext, buf->search_text,
(buf->search_flags & (case_match | follow | regexp)) | backward, NULL))
{
fe_message (_("Search hit end, not found."), FE_MSG_ERROR);
}
}
static void
menu_search_reset ()
{
GtkXText *xtext = GTK_XTEXT (current_sess->gui->xtext);
gtk_xtext_search (xtext, "", 0, NULL);
mg_search_handle_previous(wid, current_sess);
}
static void
@ -1732,7 +1710,6 @@ static struct mymenu mymenu[] = {
#define SEARCH_OFFSET 68
{N_("Search"), 0, GTK_STOCK_JUSTIFY_LEFT, M_MENUSUB, 0, 0, 1},
{N_("Search Text..."), menu_search, GTK_STOCK_FIND, M_MENUSTOCK, 0, 0, 1, GDK_f},
{N_("Reset Search"), menu_search_reset, GTK_STOCK_FIND, M_MENUSTOCK, 0, 0, 1, GDK_F},
{N_("Search Next" ), menu_search_next, GTK_STOCK_FIND, M_MENUSTOCK, 0, 0, 1, GDK_g},
{N_("Search Previous" ), menu_search_prev, GTK_STOCK_FIND, M_MENUSTOCK, 0, 0, 1, GDK_G},
{0, 0, 0, M_END, 0, 0, 0},

View File

@ -1,246 +0,0 @@
/* X-Chat
* Copyright (C) 1998 Peter Zelezny.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "fe-gtk.h"
#include "../common/hexchat.h"
#include "../common/fe.h"
#include "../common/util.h"
#include "../common/hexchatc.h"
#include "../common/cfgfiles.h"
#include "gtkutil.h"
#include "xtext.h"
#include "maingui.h"
GtkWidget *searchwin;
GtkWidget *searchentry;
static void
search_search (session * sess, const gchar *text)
{
gtk_xtext_search_flags flags;
textentry *last;
GError *err = NULL;
flags = ((prefs.hex_text_search_case_match == 1? case_match: 0) |
(prefs.hex_text_search_backward == 1? backward: 0) |
(prefs.hex_text_search_highlight_all == 1? highlight: 0) |
(prefs.hex_text_search_follow == 1? follow: 0) |
(prefs.hex_text_search_regexp == 1? regexp: 0));
if (!is_session (sess))
{
fe_message (_("The window you opened this Search "
"for doesn't exist anymore."), FE_MSG_ERROR);
return;
}
last = gtk_xtext_search (GTK_XTEXT (sess->gui->xtext), text, flags, &err);
if (text == NULL || text[0] == 0)
{
return;
}
if (err)
{
fe_message (_(err->message), FE_MSG_ERROR);
g_error_free (err);
}
else if (!last)
{
gtk_entry_set_icon_from_stock (GTK_ENTRY (searchentry), GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_DIALOG_ERROR);
}
else
{
gtk_entry_set_icon_from_stock (GTK_ENTRY (searchentry), GTK_ENTRY_ICON_SECONDARY, NULL);
}
}
static void
search_find_cb (GtkWidget * button, session * sess)
{
GtkEntry *entry;
const gchar *text;
entry = g_object_get_data (G_OBJECT (button), "e");
text = gtk_entry_get_text (entry);
search_search (sess, text);
}
static void
search_close_cb (GtkWidget * button, GtkWidget * win)
{
gtk_widget_destroy (win);
searchwin = NULL;
}
static void
search_reset_cb (GtkWidget * button, session * sess)
{
search_search (sess, "");
if (searchwin)
{
search_close_cb (button, searchwin);
}
}
static void
search_cleanup_cb (GtkWidget * button, GtkWidget * win)
{
searchwin = NULL;
}
static void
search_entry_cb (GtkWidget * entry, session * sess)
{
search_search (sess, gtk_entry_get_text (GTK_ENTRY (entry)));
}
static void
search_changed_cb (GtkWidget * entry, gpointer userdata)
{
gtk_entry_set_icon_from_stock (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY, NULL);
}
static void
search_caseign_cb (GtkToggleButton * but, session * sess)
{
prefs.hex_text_search_case_match = (but->active)? 1: 0;
save_config();
}
static void
search_dirbwd_cb (GtkToggleButton * but, session * sess)
{
prefs.hex_text_search_backward = (but->active)? 1: 0;
save_config();
}
static void
search_regexp_cb (GtkToggleButton * but, session * sess)
{
prefs.hex_text_search_regexp = (but->active)? 1: 0;
save_config();
}
static void
search_highlight_cb (GtkToggleButton * but, session * sess)
{
prefs.hex_text_search_highlight_all = (but->active)? 1: 0;
save_config();
search_search (sess, NULL);
}
void
search_open (session * sess)
{
GtkWidget *win, *hbox, *vbox, *entry, *wid;
gchar *text;
if (searchwin)
{
gtk_widget_destroy (searchwin);
searchwin = NULL;
}
win = mg_create_generic_tab ("search", _(DISPLAY_NAME": Search"), TRUE, FALSE,
search_cleanup_cb, NULL, 0, 0, &vbox, 0);
gtk_container_set_border_width (GTK_CONTAINER (win), 12);
gtk_box_set_spacing (GTK_BOX (vbox), 4);
/* First line: _____________________ _Find */
hbox = gtk_hbox_new (0, 10);
gtk_container_add (GTK_CONTAINER (vbox), hbox);
gtk_widget_show (hbox);
entry = searchentry = gtk_entry_new ();
text = GTK_XTEXT (sess->gui->xtext)->buffer->search_text;
gtk_entry_set_icon_activatable (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY, FALSE);
gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY, _("Search hit end or not found."));
if (text)
{
gtk_entry_set_text (GTK_ENTRY (entry), text);
gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
}
g_signal_connect (G_OBJECT (entry), "activate",
G_CALLBACK (search_entry_cb), sess);
g_signal_connect (G_OBJECT (entry), "changed",
G_CALLBACK (search_changed_cb), NULL);
gtk_container_add (GTK_CONTAINER (hbox), entry);
gtk_widget_show (entry);
gtk_widget_grab_focus (entry);
wid = gtk_hbutton_box_new ();
gtk_container_add (GTK_CONTAINER (hbox), wid);
gtk_widget_show (wid);
wid = gtkutil_button (wid, GTK_STOCK_FIND, 0, search_find_cb, sess,
_("_Find"));
g_object_set_data (G_OBJECT (wid), "e", entry);
/* Second line: X Match case */
wid = gtk_check_button_new_with_mnemonic (_("_Match case"));
GTK_TOGGLE_BUTTON (wid)->active = prefs.hex_text_search_case_match;
g_signal_connect (G_OBJECT (wid), "toggled", G_CALLBACK (search_caseign_cb), sess);
gtk_container_add (GTK_CONTAINER (vbox), wid);
add_tip (wid, _("Perform a case-sensitive search."));
gtk_widget_show (wid);
/* Third line: X Search backwards */
wid = gtk_check_button_new_with_mnemonic (_("Search _backwards"));
GTK_TOGGLE_BUTTON (wid)->active = prefs.hex_text_search_backward;
g_signal_connect (G_OBJECT (wid), "toggled", G_CALLBACK (search_dirbwd_cb), sess);
gtk_container_add (GTK_CONTAINER (vbox), wid);
add_tip (wid, _("Search from the newest text line to the oldest."));
gtk_widget_show (wid);
/* Fourth line: X Highlight all */
wid = gtk_check_button_new_with_mnemonic (_("_Highlight all"));
GTK_TOGGLE_BUTTON (wid)->active = prefs.hex_text_search_highlight_all;
g_signal_connect (G_OBJECT (wid), "toggled", G_CALLBACK (search_highlight_cb), sess);
gtk_container_add (GTK_CONTAINER (vbox), wid);
add_tip (wid, _("Highlight all occurrences, and underline the current occurrence."));
gtk_widget_show (wid);
/* Fifth line: X Regular expression */
wid = gtk_check_button_new_with_mnemonic (_("R_egular expression"));
GTK_TOGGLE_BUTTON (wid)->active = prefs.hex_text_search_regexp;
g_signal_connect (G_OBJECT (wid), "toggled", G_CALLBACK (search_regexp_cb), sess);
gtk_container_add (GTK_CONTAINER (vbox), wid);
add_tip (wid, _("Regard search string as a regular expression."));
gtk_widget_show (wid);
/* Sixth line: _Close Close and _Reset */
hbox = gtk_hbutton_box_new ();
gtk_box_pack_start (GTK_BOX (vbox), hbox, 0, 0, 4);
gtk_widget_show (hbox);
wid = gtkutil_button (hbox, GTK_STOCK_CLOSE, 0, search_close_cb, win,
_("_Close"));
add_tip (wid, _("Close this box, but continue searching new lines."));
wid = gtkutil_button (hbox, "gtk-reset", 0, search_reset_cb, sess,
_("Close and _Reset"));
add_tip (wid, _("Close this box, reset highlighted search items, and stop searching new lines."));
/* Add recognition of the ESC key to close the box */
gtkutil_destroy_on_esc (win);
/* That's all, folks */
searchwin = win;
gtk_widget_show (win);
}

View File

@ -1,25 +0,0 @@
/* HexChat
* Copyright (C) 1998-2010 Peter Zelezny.
* Copyright (C) 2009-2013 Berke Viktor.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_SEARCH_H
#define HEXCHAT_SEARCH_H
void search_open (session * sess);
#endif