1 /**
2  * @file   gui-snippet.h
3  * @brief  Handle snippets and provide edit/new/delete function
4  *
5  * Copyright (C) 2009 Gummi Developers
6  * All Rights reserved.
7  *
8  * Permission is hereby granted, free of charge, to any person
9  * obtaining a copy of this software and associated documentation
10  * files (the "Software"), to deal in the Software without
11  * restriction, including without limitation the rights to use,
12  * copy, modify, merge, publish, distribute, sublicense, and/or sell
13  * copies of the Software, and to permit persons to whom the
14  * Software is furnished to do so, subject to the following
15  * conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27  * OTHER DEALINGS IN THE SOFTWARE.
28  */
29 
30 #ifndef __GUMMI_GUI_SNIPPETS__
31 #define __GUMMI_GUI_SNIPPETS__
32 
33 #include <glib.h>
34 #include <gtk/gtk.h>
35 
36 #include "snippets.h"
37 
38 #define GU_SNIPPETS_GUI(x) ((GuSnippetsGui*)x)
39 typedef struct _GuSnippetsGui GuSnippetsGui;
40 
41 struct _GuSnippetsGui {
42     GtkWindow* snippetswindow;
43     GtkTreeView* snippets_tree_view;
44     GtkScrolledWindow* snippet_scroll;
45     GtkEntry* tab_trigger_entry;
46     GtkEntry* accelerator_entry;
47     GtkListStore* list_snippets;
48     GtkCellRendererText* snippet_renderer;
49     GtkButton* button_new;
50     GtkButton* button_remove;
51     GtkSourceView* view;
52     GtkSourceBuffer* buffer;
53     slist* current;
54 };
55 
56 GuSnippetsGui* snippetsgui_init (GtkWindow* mainwindow);
57 void snippetsgui_main (GuSnippetsGui* sc);
58 void snippetsgui_load_snippets (GuSnippetsGui* sc);
59 void snippetsgui_move_cursor_to_row (GuSnippetsGui* sc, gint row);
60 void snippetsgui_update_snippet (GuSnippets* sc);
61 void on_button_new_snippet_clicked (GtkWidget* widget, void* user);
62 void on_button_remove_snippet_clicked (GtkWidget* widget, void* user);
63 gboolean on_tab_trigger_entry_key_release_event (GtkEntry* entry, void* user);
64 void on_accelerator_entry_focus_in_event (GtkWidget* widget, void* user);
65 void on_accelerator_entry_focus_out_event (GtkWidget* widget, void* user);
66 gboolean on_accelerator_entry_key_press_event (GtkWidget* widget,
67         GdkEventKey* event, void* user);
68 void on_snippetsgui_close_clicked (GtkWidget* widget, void* user);
69 void on_snippetsgui_reset_clicked (GtkWidget* widget, void* user);
70 void on_snippetsgui_selected_text_clicked (GtkWidget* widget, void* user);
71 void on_snippetsgui_filename_clicked (GtkWidget* widget, void* user);
72 void on_snippetsgui_basename_clicked (GtkWidget* widget, void* user);
73 
74 void on_snippets_tree_view_cursor_changed (GtkTreeView* view, void* user);
75 void on_snippet_renderer_edited (GtkCellRendererText* renderer, gchar *path,
76         gchar* name, void* user);
77 void on_snippet_renderer_editing_canceled (GtkCellRenderer* rend, void* user);
78 gboolean on_snippet_source_buffer_key_release (GtkWidget* widget, void* user);
79 
80 #endif /* __GUMMI_GUI_SNIPPETS__ */
81