summaryrefslogtreecommitdiff
path: root/saedit
diff options
context:
space:
mode:
Diffstat (limited to 'saedit')
-rw-r--r--saedit/interface.h17
-rw-r--r--saedit/main.c5
-rw-r--r--saedit/main.h3
-rwxr-xr-xsaedit/saeditbin456240 -> 457806 bytes
-rw-r--r--saedit/search.h75
5 files changed, 65 insertions, 35 deletions
diff --git a/saedit/interface.h b/saedit/interface.h
index 97307dd..0fa0ef6 100644
--- a/saedit/interface.h
+++ b/saedit/interface.h
@@ -36,6 +36,8 @@ void set_up_interface() {
GtkAccelGroup *ag = gtk_accel_group_new();
gtk_window_add_accel_group(win, ag);
+ find_dialog = find_window_new(win);
+
GtkWidget *fcdialog = gtk_file_chooser_dialog_new(_("Open XML source file"), win, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
vbox = gtk_vbox_new(FALSE, 0);
@@ -59,6 +61,21 @@ void set_up_interface() {
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu);
gtk_menu_shell_append(GTK_MENU_SHELL(menubar), menuitem);
+ //Search menu
+ menu = gtk_menu_new();
+ gtk_menu_set_accel_group(menu, ag);
+
+ menuitem = gtk_menu_item_new_with_label(_("Find..."));
+ g_signal_connect(menuitem, "activate", show_find_dialog, NULL);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
+
+ gtk_menu_item_set_accel_path(GTK_MENU_ITEM(menuitem), "<MenuItems>/Search/Find");
+ gtk_accel_map_change_entry("<MenuItems>/Search/Find", gdk_keyval_from_name("F"), GDK_CONTROL_MASK, TRUE);
+
+ menuitem = gtk_menu_item_new_with_label(_("Search"));
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menubar), menuitem);
+
//View menu
menu = gtk_menu_new();
gtk_menu_set_accel_group(menu, ag);
diff --git a/saedit/main.c b/saedit/main.c
index 94a728d..65c97ca 100644
--- a/saedit/main.c
+++ b/saedit/main.c
@@ -18,6 +18,10 @@ void kill_timeout(int tag) {
g_source_remove(tag);
}
+void show_find_dialog() {
+ gtk_widget_show_all(find_dialog);
+}
+
Frame *frame_new(int index, int offsetX, int offsetY, int delay) {
Frame *res = g_new0(Frame, 1);
res->index = index;
@@ -661,7 +665,6 @@ int main(int argc, char *argv[]) {
paths = g_new0(Options, 1);
set_up_interface();
- //find_window_new(win);
load_config();
gtk_main();
diff --git a/saedit/main.h b/saedit/main.h
index f84ef5a..9e77048 100644
--- a/saedit/main.h
+++ b/saedit/main.h
@@ -180,6 +180,8 @@ GdkPixbuf *icon = NULL;
Options *paths;
Keys *config;
+GtkDialog *find_dialog;
+
static gboolean show_animation_by_info(AnimationInfo *anim_info);
static gchar *markup_bold(gchar *str);
static void format_src_string(gchar *src);
@@ -223,3 +225,4 @@ static void open_menu_item_activate(GtkMenuItem *menuitem, GtkFileChooserDialog
static void parse_xml_text(gchar *text, SAEInfo *sae_info);
static void show_animation(SAEInfo *sae_info);
static gboolean set_up_animation_by_direction(SAEInfo *sae_info, const gchar *direction);
+static void show_find_dialog();
diff --git a/saedit/saedit b/saedit/saedit
index b13d88b..53e0691 100755
--- a/saedit/saedit
+++ b/saedit/saedit
Binary files differ
diff --git a/saedit/search.h b/saedit/search.h
index 8e648e1..ff6185f 100644
--- a/saedit/search.h
+++ b/saedit/search.h
@@ -11,50 +11,57 @@
GtkWidget *find_entry;
-static gboolean find_text(GtkWidget *button, gpointer user_data) {
- GtkTextIter beg, end, start;
- gtk_text_buffer_get_start_iter(source_buffer, &start);
- if (!gtk_source_iter_forward_search(&start, gtk_entry_get_text(find_entry), 0, &beg, &end, NULL))
+static gboolean find_text() {
+ gboolean found;
+ gchar *text = gtk_entry_get_text(find_entry);
+
+ GtkTextIter m_start, m_end, start;
+ gtk_text_buffer_get_selection_bounds(source_buffer, NULL, &start);
+ found = gtk_source_iter_forward_search(&start, text, 0, &m_start, &m_end, NULL);
+
+ if (!found) {
+ gtk_text_buffer_get_start_iter(source_buffer, &start);
+ found = gtk_source_iter_forward_search(&start, text, 0, &m_start, &m_end, NULL);
+ }
+ if (found) {
+ gtk_text_buffer_place_cursor(source_buffer, &m_start);
+ gtk_text_buffer_move_mark_by_name(source_buffer, "selection_bound", &m_end);
+ gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (source_view),
+ gtk_text_buffer_get_insert (source_buffer),
+ 0.25,
+ FALSE,
+ 0.0,
+ 0.0);
+ return TRUE;
+ } else
return FALSE;
- gtk_text_buffer_place_cursor(source_buffer, &beg);
- gtk_text_view_set_cursor_visible(source_view, FALSE);
- gtk_text_buffer_move_mark_by_name(source_buffer, "selection_bound", &end);
- gtk_text_mark_set_visible(gtk_text_buffer_get_insert (source_buffer), TRUE);
- gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (source_view),
- gtk_text_buffer_get_insert (source_buffer),
- 0.25,
- FALSE,
- 0.0,
- 0.0);
- gtk_text_buffer_place_cursor(source_buffer, &end);
}
static GtkWidget *find_window_new(GtkWindow *parent) {
- GtkWidget *window;
+ GtkWidget *dialog;
GtkWidget *vbox;
GtkWidget *entry;
- GtkWidget *button;
+ GtkWidget *content_area;
+ GtkWidget *label;
- window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_transient_for(window, parent);
- gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
- gtk_window_set_title(GTK_WINDOW(window), _("Find"));
- gtk_widget_set_size_request(window, 250, 100);
- gtk_container_set_border_width(window, 4);
- gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
- gtk_widget_realize(window);
+ dialog = gtk_dialog_new_with_buttons (_("Find"),
+ parent,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_FIND,
+ GTK_RESPONSE_NONE,
+ NULL);
+ content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
- vbox = gtk_vbox_new(FALSE, 4);
- gtk_container_add(window, vbox);
+ label = gtk_label_new(_("Text:"));
+ gtk_container_add(GTK_CONTAINER(content_area), label);
entry = gtk_entry_new();
- gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(content_area), entry);
find_entry = entry;
- button = gtk_button_new_with_label(_("Find"));
- gtk_widget_set_size_request(button, 64, 32);
- gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
- g_signal_connect(button, "clicked", find_text, NULL);
-
- gtk_widget_show_all(window);
+ g_signal_connect(dialog,
+ "response",
+ G_CALLBACK(find_text),
+ NULL);
+ return dialog;
}