Commit 26fd3047 authored by Victor Ananjevsky's avatar Victor Ananjevsky

add --disable-search option

parent 314557f5
......@@ -625,6 +625,9 @@ Set user agent string. Default is \fIYAD-Webkit (@VERSION@)\fP
.B \-\-user-style=\fIURI\fP
Set path or uri to custom user styles. Path to local file can be an absolute file name or uri with \fIfile://\fP prefix.
.TP
.B \-\-disable-search
Disable search bar.
.TP
.B \-\-wk-prop=\fIPROP\fP
Set additional WebKit setting. This option may be used multiply times. Setting \fIPROP\fP must be in a form "setting-name value". First character of value must be a type identifier \fIb\fP for booleans, \fIi\fP for integers and \fIs\fP for strings. The values itself following by a colon. List of possible settings can be found on this page - https://webkitgtk.org/reference/webkit2gtk/stable/WebKitSettings.html
.PP
......@@ -971,6 +974,9 @@ Save file on exit instead of print it content on stdout. This option works only
.B \-\-file-op
Enable file operations. This option adds open and save menu items to popup menu, This option works only in editable mode.
.TP
.B \-\-disable-search
Disable search bar.
.TP
Next options works only if yad builds with GtkSourceView.
.TP
.B \-\-lang=\fILANGUAGE\fP
......
......@@ -223,6 +223,8 @@ static GOptionEntry common_options[] = {
N_("Set extended completion for entries (any, all, or regex)"), N_("TYPE") },
{ "bool-fmt", 0, 0, G_OPTION_ARG_CALLBACK, set_bool_fmt_type,
N_("Set type of output for boolean values (T, t, Y, y, O, o, 1)"), N_("TYPE") },
{ "disable-search", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &options.common_data.enable_search,
N_("Disable search in text and html dialogs"), NULL },
#if GLIB_CHECK_VERSION(2,30,0)
{ "iec-format", 0, G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK, set_size_format,
N_("Use IEC (base 1024) units with for size values"), NULL },
......@@ -1641,6 +1643,7 @@ yad_options_init (void)
options.common_data.bool_fmt = YAD_BOOL_FMT_UT;
options.common_data.complete = YAD_COMPLETE_SIMPLE;
options.common_data.icon_size = 0;
options.common_data.enable_search = TRUE;
#if GLIB_CHECK_VERSION(2,30,0)
options.common_data.size_fmt = G_FORMAT_SIZE_DEFAULT;
#endif
......
......@@ -25,7 +25,7 @@ static GtkWidget *text_view;
static GObject *text_buffer;
static GtkTextTag *tag;
static GdkCursor *hand, *normal;
static YadSearchBar *search_bar;
static YadSearchBar *search_bar = NULL;
static GtkTextIter search_pos;
static gboolean text_changed = FALSE;
static gboolean search_changed = FALSE;
......@@ -277,6 +277,9 @@ key_press_cb (GtkWidget *w, GdkEventKey *key, gpointer d)
{
if ((key->state & GDK_CONTROL_MASK) && (key->keyval == GDK_KEY_F || key->keyval == GDK_KEY_f))
{
if (search_bar == NULL)
return FALSE;
ignore_esc = TRUE;
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (search_bar->bar), TRUE);
return gtk_search_bar_handle_event (GTK_SEARCH_BAR (search_bar->bar), (GdkEvent *) key);
......@@ -795,6 +798,22 @@ text_create_widget (GtkWidget * dlg)
gtk_container_add (GTK_CONTAINER (sw), tv);
/* create search bar */
if (options.common_data.enable_search)
{
if ((search_bar = create_search_bar ()) != NULL)
{
gtk_box_pack_start (GTK_BOX (w), search_bar->bar, FALSE, FALSE, 0);
g_signal_connect (G_OBJECT (search_bar->entry), "search-changed", G_CALLBACK (search_changed_cb), NULL);
g_signal_connect (G_OBJECT (search_bar->entry), "stop-search", G_CALLBACK (stop_search_cb), NULL);
g_signal_connect (G_OBJECT (search_bar->entry), "next-match", G_CALLBACK (do_find_next), NULL);
g_signal_connect (G_OBJECT (search_bar->entry), "previous-match", G_CALLBACK (do_find_prev), NULL);
g_signal_connect (G_OBJECT (search_bar->next), "clicked", G_CALLBACK (do_find_next), NULL);
g_signal_connect (G_OBJECT (search_bar->prev), "clicked", G_CALLBACK (do_find_prev), NULL);
}
}
/* load data */
if (options.common_data.uri)
fill_buffer_from_file ();
......@@ -809,18 +828,6 @@ text_create_widget (GtkWidget * dlg)
gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (text_buffer), &iter);
}
/* create search bar */
if ((search_bar = create_search_bar ()) != NULL)
{
gtk_box_pack_start (GTK_BOX (w), search_bar->bar, FALSE, FALSE, 0);
g_signal_connect (G_OBJECT (search_bar->entry), "search-changed", G_CALLBACK (search_changed_cb), NULL);
g_signal_connect (G_OBJECT (search_bar->entry), "stop-search", G_CALLBACK (stop_search_cb), NULL);
g_signal_connect (G_OBJECT (search_bar->entry), "next-match", G_CALLBACK (do_find_next), NULL);
g_signal_connect (G_OBJECT (search_bar->entry), "previous-match", G_CALLBACK (do_find_prev), NULL);
g_signal_connect (G_OBJECT (search_bar->next), "clicked", G_CALLBACK (do_find_next), NULL);
g_signal_connect (G_OBJECT (search_bar->prev), "clicked", G_CALLBACK (do_find_prev), NULL);
}
return w;
}
......
......@@ -518,6 +518,7 @@ typedef struct {
gboolean num_output;
gboolean hide_text;
gint icon_size;
gboolean enable_search;
#if GLIB_CHECK_VERSION(2,30,0)
GFormatSizeFlags size_fmt;
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment