1 /* 2 * devhelpplugin.h 3 * 4 * Copyright 2011 Matthew Brush <mbrush@leftclick.ca> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 19 * MA 02110-1301, USA. 20 */ 21 22 #ifndef DEVHELP_PLUGIN_COMMON_H 23 #define DEVHELP_PLUGIN_COMMON_H 24 25 #include <gtk/gtk.h> 26 #include <webkit/webkitwebview.h> 27 28 G_BEGIN_DECLS 29 30 31 #ifndef DHPLUG_DATA_DIR 32 #define DHPLUG_DATA_DIR "/usr/local/share/geany-devhelp" 33 #endif 34 35 #define DHPLUG_WEBVIEW_HOME_FILE DHPLUG_DATA_DIR "/home.html" 36 #define DHPLUG_MAX_LABEL_TAG 30 /* never search for more than this many chars */ 37 38 #define DEVHELP_PLUGIN_WEBVIEW_TAB_LABEL _("Documentation") 39 #define DEVHELP_PLUGIN_DOCUMENTS_TAB_LABEL _("Code") 40 41 #define DEVHELP_TYPE_PLUGIN (devhelp_plugin_get_type()) 42 #define DEVHELP_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), DEVHELP_TYPE_PLUGIN, DevhelpPlugin)) 43 #define DEVHELP_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), DEVHELP_TYPE_PLUGIN, DevhelpPluginClass)) 44 #define DEVHELP_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), DEVHELP_TYPE_PLUGIN)) 45 #define DEVHELP_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), DEVHELP_TYPE_PLUGIN)) 46 #define DEVHELP_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), DEVHELP_TYPE_PLUGIN, DevhelpPluginClass)) 47 48 49 typedef struct _DevhelpPlugin DevhelpPlugin; 50 typedef struct _DevhelpPluginClass DevhelpPluginClass; 51 typedef struct _DevhelpPluginPrivate DevhelpPluginPrivate; 52 53 54 struct _DevhelpPlugin 55 { 56 GObject parent; 57 DevhelpPluginPrivate *priv; 58 }; 59 60 61 struct _DevhelpPluginClass 62 { 63 GObjectClass parent_class; 64 }; 65 66 67 typedef enum 68 { 69 DEVHELP_PLUGIN_WEBVIEW_LOCATION_NONE, 70 DEVHELP_PLUGIN_WEBVIEW_LOCATION_SIDEBAR, 71 DEVHELP_PLUGIN_WEBVIEW_LOCATION_MESSAGE_WINDOW, 72 DEVHELP_PLUGIN_WEBVIEW_LOCATION_MAIN_NOTEBOOK 73 } DevhelpPluginWebViewLocation; 74 75 76 GType devhelp_plugin_get_type (void); 77 DevhelpPlugin* devhelp_plugin_new (void); 78 79 80 void devhelp_plugin_load_settings (DevhelpPlugin *self, const gchar *filename); 81 void devhelp_plugin_store_settings (DevhelpPlugin *self, const gchar *filename); 82 83 84 /* Property getters */ 85 gchar* devhelp_plugin_get_current_word (DevhelpPlugin *self); 86 const gchar* devhelp_plugin_get_webview_uri (DevhelpPlugin *self); 87 gboolean devhelp_plugin_get_sidebar_tabs_bottom (DevhelpPlugin *self); 88 gboolean devhelp_plugin_get_ui_active (DevhelpPlugin *self); 89 gboolean devhelp_plugin_get_in_message_window (DevhelpPlugin *self); 90 gfloat devhelp_plugin_get_zoom_level (DevhelpPlugin *self); 91 WebKitWebView* devhelp_plugin_get_webview (DevhelpPlugin *self); 92 GList* devhelp_plugin_get_temp_files (DevhelpPlugin *self); 93 const gchar* devhelp_plugin_get_man_prog_path (DevhelpPlugin *self); 94 gboolean devhelp_plugin_get_have_man_prog (DevhelpPlugin *self); 95 96 97 /* Property setters */ 98 void devhelp_plugin_set_webview_uri (DevhelpPlugin *self, const gchar *uri); 99 void devhelp_plugin_set_sidebar_tabs_bottom (DevhelpPlugin *self, gboolean bottom); 100 void devhelp_plugin_set_ui_active (DevhelpPlugin *self, gboolean active); 101 void devhelp_plugin_set_in_message_window (DevhelpPlugin *self, gboolean in_msgwin); 102 void devhelp_plugin_set_zoom_level (DevhelpPlugin *self, gfloat zoom_level); 103 104 105 /* Methods */ 106 void devhelp_plugin_activate_ui (DevhelpPlugin *self, gboolean show_search_tab); 107 void devhelp_plugin_activate_search_tab (DevhelpPlugin *self); 108 void devhelp_plugin_activate_contents_tab (DevhelpPlugin *self); 109 void devhelp_plugin_activate_webview_tab (DevhelpPlugin *self); 110 void devhelp_plugin_activate_all_tabs (DevhelpPlugin *self); 111 112 void devhelp_plugin_toggle_search_tab (DevhelpPlugin *self); 113 void devhelp_plugin_toggle_contents_tab (DevhelpPlugin *self); 114 void devhelp_plugin_toggle_webview_tab (DevhelpPlugin *self); 115 116 void devhelp_plugin_search (DevhelpPlugin *self, const gchar *term); 117 void devhelp_plugin_search_books (DevhelpPlugin *self, const gchar *term); 118 void devhelp_plugin_search_code (DevhelpPlugin *self, const gchar *term, const gchar *lang); 119 120 121 /* Manual pages (see manpages.c) */ 122 void devhelp_plugin_search_manpages (DevhelpPlugin *self, const gchar *term); 123 gchar* devhelp_plugin_manpages_search (DevhelpPlugin *self, const gchar *term, const gchar *section); 124 void devhelp_plugin_add_temp_file (DevhelpPlugin *self, const gchar *filename); 125 void devhelp_plugin_remove_manpages_temp_files (DevhelpPlugin *self); 126 127 128 /* TODO: make properties for these */ 129 gboolean devhelp_plugin_get_devhelp_sidebar_visible(DevhelpPlugin *self); 130 void devhelp_plugin_set_devhelp_sidebar_visible(DevhelpPlugin *self, gboolean visible); 131 gboolean devhelp_plugin_get_use_devhelp(DevhelpPlugin *self); 132 void devhelp_plugin_set_use_devhelp(DevhelpPlugin *self, gboolean use); 133 gboolean devhelp_plugin_get_use_man(DevhelpPlugin *self); 134 void devhelp_plugin_set_use_man(DevhelpPlugin *self, gboolean use); 135 gboolean devhelp_plugin_get_use_codesearch(DevhelpPlugin *self); 136 void devhelp_plugin_set_use_codesearch(DevhelpPlugin *self, gboolean use); 137 138 139 G_END_DECLS 140 #endif /* DEVHELP_PLUGIN_H */ 141