1 /* 2 * xed-tab.h 3 * This file is part of xed 4 * 5 * Copyright (C) 2005 - Paolo Maggi 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, 20 * Boston, MA 02110-1301, USA. 21 */ 22 23 /* 24 * Modified by the xed Team, 2005. See the AUTHORS file for a 25 * list of people on the xed Team. 26 * See the ChangeLog files for a list of changes. 27 * 28 * $Id$ 29 */ 30 31 #ifndef __XED_TAB_H__ 32 #define __XED_TAB_H__ 33 34 #include <gtksourceview/gtksource.h> 35 #include <xed/xed-view.h> 36 #include <xed/xed-document.h> 37 38 G_BEGIN_DECLS 39 40 typedef enum 41 { 42 XED_TAB_STATE_NORMAL = 0, 43 XED_TAB_STATE_LOADING, 44 XED_TAB_STATE_REVERTING, 45 XED_TAB_STATE_SAVING, 46 XED_TAB_STATE_PRINTING, 47 XED_TAB_STATE_PRINT_PREVIEWING, 48 XED_TAB_STATE_SHOWING_PRINT_PREVIEW, 49 XED_TAB_STATE_GENERIC_NOT_EDITABLE, 50 XED_TAB_STATE_LOADING_ERROR, 51 XED_TAB_STATE_REVERTING_ERROR, 52 XED_TAB_STATE_SAVING_ERROR, 53 XED_TAB_STATE_GENERIC_ERROR, 54 XED_TAB_STATE_CLOSING, 55 XED_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION, 56 XED_TAB_NUM_OF_STATES /* This is not a valid state */ 57 } XedTabState; 58 59 #define XED_TYPE_TAB (xed_tab_get_type()) 60 #define XED_TAB(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XED_TYPE_TAB, XedTab)) 61 #define XED_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XED_TYPE_TAB, XedTabClass)) 62 #define XED_IS_TAB(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XED_TYPE_TAB)) 63 #define XED_IS_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_TAB)) 64 #define XED_TAB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XED_TYPE_TAB, XedTabClass)) 65 66 typedef struct _XedTab XedTab; 67 typedef struct _XedTabPrivate XedTabPrivate; 68 typedef struct _XedTabClass XedTabClass; 69 70 struct _XedTab 71 { 72 GtkBox vbox; 73 74 /*< private > */ 75 XedTabPrivate *priv; 76 }; 77 78 struct _XedTabClass 79 { 80 GtkBoxClass parent_class; 81 82 }; 83 84 GType xed_tab_get_type (void) G_GNUC_CONST; 85 86 XedView *xed_tab_get_view (XedTab *tab); 87 88 /* This is only an helper function */ 89 XedDocument *xed_tab_get_document (XedTab *tab); 90 XedTab *xed_tab_get_from_document (XedDocument *doc); 91 92 XedTabState xed_tab_get_state (XedTab *tab); 93 94 gboolean xed_tab_get_auto_save_enabled (XedTab *tab); 95 void xed_tab_set_auto_save_enabled (XedTab *tab, 96 gboolean enable); 97 98 gint xed_tab_get_auto_save_interval (XedTab *tab); 99 void xed_tab_set_auto_save_interval (XedTab *tab, 100 gint interval); 101 102 void xed_tab_set_info_bar (XedTab *tab, 103 GtkWidget *info_bar); 104 /* 105 * Non exported methods 106 */ 107 GtkWidget *_xed_tab_new (void); 108 109 /* Whether create is TRUE, creates a new empty document if location does 110 not refer to an existing file */ 111 GtkWidget *_xed_tab_new_from_location (GFile *location, 112 const GtkSourceEncoding *encoding, 113 gint line_pos, 114 gboolean create); 115 116 GtkWidget *_xed_tab_new_from_stream (GInputStream *stream, 117 const GtkSourceEncoding *encoding, 118 gint line_pos); 119 120 gchar *_xed_tab_get_name (XedTab *tab); 121 122 gchar *_xed_tab_get_tooltips (XedTab *tab); 123 124 GdkPixbuf *_xed_tab_get_icon (XedTab *tab); 125 126 void _xed_tab_load (XedTab *tab, 127 GFile *location, 128 const GtkSourceEncoding *encoding, 129 gint line_pos, 130 gboolean create); 131 132 void _xed_tab_load_stream (XedTab *tab, 133 GInputStream *location, 134 const GtkSourceEncoding *encoding, 135 gint line_pos); 136 137 void _xed_tab_revert (XedTab *tab); 138 139 void _xed_tab_save_async (XedTab *tab, 140 GCancellable *cancellable, 141 GAsyncReadyCallback callback, 142 gpointer user_data); 143 144 145 gboolean _xed_tab_save_finish (XedTab *tab, 146 GAsyncResult *result); 147 148 void _xed_tab_save_as_async (XedTab *tab, 149 GFile *location, 150 const GtkSourceEncoding *encoding, 151 GtkSourceNewlineType newline_type, 152 GCancellable *cancellable, 153 GAsyncReadyCallback callback, 154 gpointer user_data); 155 156 void _xed_tab_print (XedTab *tab, gboolean show_dialog); 157 void _xed_tab_print_preview (XedTab *tab); 158 void _xed_tab_mark_for_closing (XedTab *tab); 159 gboolean _xed_tab_get_can_close (XedTab *tab); 160 GtkWidget *_xed_tab_get_view_frame (XedTab *tab); 161 162 G_END_DECLS 163 164 #endif /* __XED_TAB_H__ */ 165