Commit 4523c805 by Herman Ounas

Lisatud search aknasse

parent 43e3d3dd
...@@ -21,6 +21,8 @@ typedef struct ...@@ -21,6 +21,8 @@ typedef struct
GtkSourceLanguageManager *LangManager; GtkSourceLanguageManager *LangManager;
GtkSourceLanguage *Language; GtkSourceLanguage *Language;
GtkWidget *search_entry;
} tab; } tab;
typedef struct typedef struct
......
#include "search.h"
void find (GtkTextView *text_view, const gchar *text, GtkTextIter *iter)
{
GtkTextIter mstart, mend;
GtkTextBuffer *buffer;
gboolean found;
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
found = gtk_text_iter_forward_search (iter, text, 0, &mstart, &mend, NULL);
if (found)
{
gtk_text_buffer_select_range (buffer, &mstart, &mend);
gtk_text_buffer_create_mark (buffer, "last_pos", &mend, FALSE);
}
}
// funktsioon selleks kui search nuppu vajutatakse
void Otsi_nupp_vajutatud (GtkWidget *search_button, tab *Tab)
{
const gchar *text;
GtkTextBuffer *buffer;
GtkTextIter iter;
text = gtk_entry_get_text (GTK_ENTRY (Tab->search_entry));
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (Tab->TextView));
gtk_text_buffer_get_start_iter (buffer, &iter);
find (GTK_TEXT_VIEW (Tab->TextView), text, &iter);
}
// funktsioon selleks kui jargmine_nupp vajutatakse
void Jargmine_nupp_vajutatud (GtkWidget *next_button, tab *Tab)
{
const gchar *text;
GtkTextBuffer *buffer;
GtkTextMark *last_pos;
GtkTextIter iter;
text = gtk_entry_get_text (GTK_ENTRY (Tab->search_entry));
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (Tab->TextView));
last_pos = gtk_text_buffer_get_mark (buffer, "last_pos");
if (last_pos == NULL)
return;
gtk_text_buffer_get_iter_at_mark (buffer, &iter, last_pos);
find (GTK_TEXT_VIEW (Tab->TextView), text, &iter);
}
#ifndef SEARCH_H
#define SEARCH_H
#include "ceditor.h"
#ifdef SOURCEVIEW
#include <gtksourceview/gtksource.h>
#endif
//void search_aken(ui *UI, tab *Tab);
void find (GtkTextView *text_view, const gchar *text, GtkTextIter *iter);
void Otsi_nupp_vajutatud (GtkWidget *search_button, tab *app);
void Jargmine_nupp_vajutatud (GtkWidget *next_button, tab *app);
#endif // SEARCH_H
...@@ -22,7 +22,24 @@ void LisaTab(ui *UI) ...@@ -22,7 +22,24 @@ void LisaTab(ui *UI)
// Tekstiaken // Tekstiaken
Tab->TextView = gtk_source_view_new(); // Loo tekstiaken Tab->TextView = gtk_source_view_new(); // Loo tekstiaken
Tab->Puhver = gtk_text_view_get_buffer(GTK_TEXT_VIEW(Tab->TextView)); // Tekstiakna teksti puhver Tab->Puhver = gtk_text_view_get_buffer(GTK_TEXT_VIEW(Tab->TextView)); // Tekstiakna teksti puhver
Tab->OnMuudetud = 0; //Tab->OnMuudetud = 0;
GtkWidget *hbox = gtk_box_new(FALSE, 0);
//search bar
Tab->search_entry = gtk_entry_new();
gtk_box_pack_start(GTK_BOX(hbox), Tab->search_entry, TRUE, TRUE, 0);
GtkWidget *Otsi_nupp = gtk_button_new_with_label ("Otsi"); // Otsi nupp
gtk_box_pack_start(GTK_BOX(hbox), Otsi_nupp, FALSE, TRUE, 3);
g_signal_connect (G_OBJECT (Otsi_nupp), "clicked",
G_CALLBACK (Otsi_nupp_vajutatud), &UI->Tabid[TabidN]);
GtkWidget *Jargmine_nupp = gtk_button_new_with_label ("Järgmine"); // Järmine nupp
gtk_box_pack_start(GTK_BOX(hbox), Jargmine_nupp, FALSE, TRUE, 3);
g_signal_connect (G_OBJECT (Jargmine_nupp), "clicked",
G_CALLBACK (Jargmine_nupp_vajutatud), &UI->Tabid[TabidN]);
// Scroll window // Scroll window
Tab->ScrollWindow = gtk_scrolled_window_new(NULL, NULL); // Loo scroll aken Tab->ScrollWindow = gtk_scrolled_window_new(NULL, NULL); // Loo scroll aken
...@@ -41,6 +58,7 @@ void LisaTab(ui *UI) ...@@ -41,6 +58,7 @@ void LisaTab(ui *UI)
// Box // Box
Tab->Box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); // Vertikaalne box, 0px vahe Tab->Box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); // Vertikaalne box, 0px vahe
gtk_box_pack_start(GTK_BOX(Tab->Box), Tab->ScrollWindow, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(Tab->Box), Tab->ScrollWindow, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(Tab->Box), hbox, FALSE, TRUE, 3);
gtk_box_pack_start(GTK_BOX(Tab->Box), Tab->StatusBar, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(Tab->Box), Tab->StatusBar, FALSE, FALSE, 0);
// Pealkiri // Pealkiri
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "ceditor.h" #include "ceditor.h"
#include "statusbar.h" #include "statusbar.h"
#include "textview.h" #include "textview.h"
#include "search.h"
void LisaTab(ui *UI); void LisaTab(ui *UI);
void KustutaTab(ui *UI, int Indeks); void KustutaTab(ui *UI, int Indeks);
......
...@@ -123,9 +123,11 @@ ui *LooUI() ...@@ -123,9 +123,11 @@ ui *LooUI()
UI->ToolBar = gtk_toolbar_new(); UI->ToolBar = gtk_toolbar_new();
gtk_toolbar_set_style(GTK_TOOLBAR(UI->ToolBar), GTK_TOOLBAR_ICONS); gtk_toolbar_set_style(GTK_TOOLBAR(UI->ToolBar), GTK_TOOLBAR_ICONS);
GtkWidget *UndoIcon = gtk_image_new_from_icon_name(GTK_STOCK_UNDO, 5); GtkWidget *UndoIcon = gtk_image_new_from_icon_name(GTK_STOCK_UNDO, 5);
UI->Undo = gtk_tool_button_new(UndoIcon, "undo");
GtkWidget *RedoIcon = gtk_image_new_from_icon_name(GTK_STOCK_REDO, 5); GtkWidget *RedoIcon = gtk_image_new_from_icon_name(GTK_STOCK_REDO, 5);
GtkWidget *SearchIcon = gtk_image_new_from_icon_name(GTK_STOCK_FIND, 5);
UI->Undo = gtk_tool_button_new(UndoIcon, "undo");
UI->Redo = gtk_tool_button_new(RedoIcon, "redo"); UI->Redo = gtk_tool_button_new(RedoIcon, "redo");
//g_signal_connect(UI->Search, "clicked", G_CALLBACK(search_aken), UI);
//nupud toolbarile //nupud toolbarile
gtk_toolbar_insert(GTK_TOOLBAR(UI->ToolBar), UI->Undo, -1); gtk_toolbar_insert(GTK_TOOLBAR(UI->ToolBar), UI->Undo, -1);
gtk_toolbar_insert(GTK_TOOLBAR(UI->ToolBar), UI->Redo, -1); gtk_toolbar_insert(GTK_TOOLBAR(UI->ToolBar), UI->Redo, -1);
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "tab.h" #include "tab.h"
#include "menubar.h" #include "menubar.h"
#include "compiler.h" #include "compiler.h"
#include "search.h"
#define PEALKIRI "CEditor" #define PEALKIRI "CEditor"
......
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