Commit 8871f32c by castro

koodi osad, mida lisasin

parent 85229167
Showing with 63 additions and 0 deletions
//struckt Otsi_akna jaoks
typedef struct _App
{
GtkWidget *text_view;
GtkWidget *search_entry;
} App;
//
****
//
// funktsioon selleks kui search nuppu vajutatakse
void Otsi_nupp_vajutatud (GtkWidget *Otsi_nupp, App *app)
{
const gchar *text;
GtkTextBuffer *buffer;
GtkTextIter iter;
GtkTextIter mstart, mend;
gboolean found;
text = gtk_entry_get_text (GTK_ENTRY (app->search_entry));
/* Get the buffer associated with the text view widget. */
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (app->text_view));
/* Search from the start from buffer for text. */
gtk_text_buffer_get_start_iter (buffer, &iter);
found = gtk_text_iter_forward_search (&iter, text, 0, &mstart, &mend, NULL);
if (found)
{
/* If found, hilight the text. */
gtk_text_buffer_select_range (buffer, &mstart, &mend);
}
}
//
****
//
// Search
GtkWidget *Otsi_nupp = gtk_button_new_with_label ("Otsi"); // Otsi nupp
GtkWidget *Otsi_aken = gtk_scrolled_window_new (NULL, NULL); // Otsi aken
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (Otsi_aken),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
App app;
gtk_box_pack_start (GTK_BOX (Box), Otsi_nupp, FALSE, FALSE, 0);
app.search_entry = gtk_entry_new ();
gtk_box_pack_start (GTK_BOX (Box), app.search_entry, TRUE, TRUE, 0);
g_signal_connect (G_OBJECT (Otsi_nupp), "clicked",
G_CALLBACK (Otsi_nupp_vajutatud), &app);
//
****
//
// paneb Otsi_aken boxi
gtk_box_pack_start (GTK_BOX (Box), Otsi_aken, TRUE, TRUE, 0);
app.text_view = gtk_text_view_new ();
gtk_container_add (GTK_CONTAINER (Otsi_aken), app.text_view);
\ No newline at end of file
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 sign in to comment