1 #include <config.h>
2 #include <string.h>
3 #include <glib/gi18n.h>
4 #include <gtk/gtk.h>
5 #include <gdk/gdkkeysyms.h>
6 
7 #include "xed-commands.h"
8 #include "xed-debug.h"
9 #include "xed-window.h"
10 #include "xed-utils.h"
11 #include "xed-searchbar.h"
12 #include "xed-view-frame.h"
13 
14 // void
15 // _xed_cmd_search_find (GtkAction *action,
16 //                       XedWindow *window)
17 // {
18 //     xed_searchbar_show (XED_SEARCHBAR (xed_window_get_searchbar (window)), FALSE);
19 // }
20 
21 void
_xed_cmd_search_find(GtkAction * action,XedWindow * window)22 _xed_cmd_search_find (GtkAction *action,
23                       XedWindow *window)
24 {
25     xed_searchbar_show (XED_SEARCHBAR (xed_window_get_searchbar (window)), XED_SEARCH_MODE_SEARCH);
26 }
27 
28 void
_xed_cmd_search_replace(GtkAction * action,XedWindow * window)29 _xed_cmd_search_replace (GtkAction *action,
30                          XedWindow *window)
31 {
32     xed_searchbar_show (XED_SEARCHBAR (xed_window_get_searchbar (window)), XED_SEARCH_MODE_REPLACE);
33 }
34 
35 void
_xed_cmd_search_find_next(GtkAction * action,XedWindow * window)36 _xed_cmd_search_find_next (GtkAction *action,
37                            XedWindow *window)
38 {
39     xed_debug (DEBUG_COMMANDS);
40     xed_searchbar_find_again (XED_SEARCHBAR (xed_window_get_searchbar (window)), FALSE);
41 }
42 
43 void
_xed_cmd_search_find_prev(GtkAction * action,XedWindow * window)44 _xed_cmd_search_find_prev (GtkAction *action,
45                            XedWindow *window)
46 {
47     xed_debug (DEBUG_COMMANDS);
48     xed_searchbar_find_again (XED_SEARCHBAR (xed_window_get_searchbar (window)), TRUE);
49 }
50 
51 void
_xed_cmd_search_clear_highlight(XedWindow * window)52 _xed_cmd_search_clear_highlight (XedWindow *window)
53 {
54     XedDocument *doc;
55 
56     xed_debug (DEBUG_COMMANDS);
57 
58     doc = xed_window_get_active_document (window);
59     if (doc != NULL)
60     {
61         xed_document_set_search_context (doc, NULL);
62     }
63 }
64 
65 void
_xed_cmd_search_goto_line(GtkAction * action,XedWindow * window)66 _xed_cmd_search_goto_line (GtkAction *action,
67                            XedWindow *window)
68 {
69     XedTab *active_tab;
70     XedViewFrame *frame;
71 
72     xed_debug (DEBUG_COMMANDS);
73 
74     active_tab = xed_window_get_active_tab (window);
75     if (active_tab == NULL)
76     {
77         return;
78     }
79 
80     /* Focus the view if needed: we need to focus the view otherwise
81      activating the binding for goto line has no effect */
82     // gtk_widget_grab_focus (GTK_WIDGET(active_view));
83 
84     /* Goto line is builtin in XedView, just activate the corresponding binding. */
85     frame = XED_VIEW_FRAME (_xed_tab_get_view_frame (active_tab));
86     xed_view_frame_popup_goto_line (frame);
87 }
88