1 /* Declarations for workspace.c. 2 */ 3 4 /* 5 6 Copyright (C) 1991-2003 The National Gallery 7 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 2 of the License, or 11 (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License along 19 with this program; if not, write to the Free Software Foundation, Inc., 20 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 22 */ 23 24 /* 25 26 These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk 27 28 */ 29 30 #define TYPE_WORKSPACE (workspace_get_type()) 31 #define WORKSPACE( obj ) \ 32 (G_TYPE_CHECK_INSTANCE_CAST( (obj), TYPE_WORKSPACE, Workspace )) 33 #define WORKSPACE_CLASS( klass ) \ 34 (G_TYPE_CHECK_CLASS_CAST( (klass), TYPE_WORKSPACE, WorkspaceClass)) 35 #define IS_WORKSPACE( obj ) \ 36 (G_TYPE_CHECK_INSTANCE_TYPE( (obj), TYPE_WORKSPACE )) 37 #define IS_WORKSPACE_CLASS( klass ) \ 38 (G_TYPE_CHECK_CLASS_TYPE( (klass), TYPE_WORKSPACE )) 39 #define WORKSPACE_GET_CLASS( obj ) \ 40 (G_TYPE_INSTANCE_GET_CLASS( (obj), TYPE_WORKSPACE, WorkspaceClass )) 41 42 /* Three sorts of workspace file load. 43 */ 44 typedef enum { 45 WORKSPACE_MODE_REGULAR, /* Vanilla! */ 46 WORKSPACE_MODE_FORMULA, /* Show formula, not values */ 47 WORKSPACE_MODE_NOEDIT /* Shut down all edits */ 48 } WorkspaceMode; 49 50 /* A workspace. 51 */ 52 struct _Workspace { 53 Model parent_object; 54 55 /* Our rows are part of this symbol. 56 */ 57 Symbol *sym; 58 59 /* We are using this set of toolkits. 60 */ 61 Toolkitgroup *kitg; 62 63 /* State. 64 */ 65 int next; /* Index for next column name */ 66 GSList *selected; /* Rows selected in this workspace */ 67 GSList *errors; /* Rows with errors */ 68 WorkspaceMode mode; /* Display mode */ 69 gboolean locked; /* WS has been locked */ 70 71 /* The nip2 version that made this workspace. 72 */ 73 int major; 74 int minor; 75 76 /* We may load some compat definitions to support this workspace, if it 77 * was written by an older version. 78 * 79 * The version number of the compat stuff we loaded. Zero for no compat 80 * stuff loaded. 81 */ 82 int compat_major; 83 int compat_minor; 84 85 /* The last row we scrolled to on next-error. 86 */ 87 Row *last_error; 88 89 Rect area; /* Rect enclosing the set of columns */ 90 Rect vp; /* Viewport hint ... set by views */ 91 gboolean lpane_open; /* Pane model */ 92 int lpane_position; 93 gboolean rpane_open; 94 int rpane_position; 95 96 char *status; /* Status message */ 97 98 /* Visualisation defaults for this ws. 99 */ 100 double scale; 101 double offset; 102 103 /* Workspace-local defs, displayed in the left pane. All in a private 104 * kitg and kit. 105 */ 106 char *local_defs; 107 Toolkitgroup *local_kitg; 108 Toolkit *local_kit; 109 110 /* Some view inside this ws has changed and this ws needs a relayout. 111 * Use in_dispose to stop relayout during ws shutdown. 112 */ 113 gboolean needs_layout; 114 gboolean in_dispose; 115 }; 116 117 typedef struct _WorkspaceClass { 118 ModelClass parent_class; 119 120 /* Methods. 121 */ 122 } WorkspaceClass; 123 124 void workspace_set_needs_layout( Workspace *ws, gboolean needs_layout ); 125 GSList *workspace_get_needs_layout(); 126 127 Workspacegroup *workspace_get_workspacegroup( Workspace *ws ); 128 Workspaceroot *workspace_get_workspaceroot( Workspace *ws ); 129 void workspace_set_modified( Workspace *ws, gboolean modified ); 130 131 void *workspace_map( workspace_map_fn fn, void *a, void *b ); 132 void *workspace_map_column( Workspace *ws, column_map_fn fn, void *a ); 133 void *workspace_map_symbol( Workspace *ws, symbol_map_fn fn, void *a ); 134 void *workspace_map_view( Workspace *ws, view_map_fn fn, void *a ); 135 136 gboolean workspace_is_empty( Workspace *ws ); 137 138 void *workspace_selected_map( Workspace *ws, row_map_fn fn, void *a, void *b ); 139 void *workspace_selected_map_sym( Workspace *ws, 140 symbol_map_fn fn, void *a, void *b ); 141 gboolean workspace_selected_any( Workspace *ws ); 142 int workspace_selected_num( Workspace *ws ); 143 gboolean workspace_selected_sym( Workspace *ws, Symbol *sym ); 144 Row *workspace_selected_one( Workspace *ws ); 145 void workspace_deselect_all( Workspace *ws ); 146 void workspace_selected_names( Workspace *ws, 147 VipsBuf *buf, const char *separator ); 148 void workspace_column_names( Column *col, 149 VipsBuf *buf, const char *separator ); 150 void workspace_select_all( Workspace *ws ); 151 Column *workspace_is_one_empty( Workspace *ws ); 152 153 Column *workspace_column_find( Workspace *ws, const char *name ); 154 Column *workspace_column_get( Workspace *ws, const char *name ); 155 void workspace_column_name_new( Workspace *ws, char *name ); 156 Column *workspace_column_pick( Workspace *ws ); 157 void workspace_column_select( Workspace *ws, Column *col ); 158 Column *workspace_column_new( Workspace *ws ); 159 160 Symbol *workspace_add_def( Workspace *ws, const char *str ); 161 Symbol *workspace_add_def_recalc( Workspace *ws, const char *str ); 162 gboolean workspace_load_file_buf( VipsBuf *buf, const char *filename ); 163 Symbol *workspace_load_file( Workspace *ws, const char *filename ); 164 165 void workspace_get_version( Workspace *ws, int *major, int *minor ); 166 int workspace_have_compat( int major, int minor, 167 int *best_major, int *best_minor ); 168 gboolean workspace_load_compat( Workspace *ws, int major, int minor ); 169 170 GType workspace_get_type( void ); 171 Workspace *workspace_new( Workspacegroup *wsg, const char *name ); 172 Workspace *workspace_new_blank( Workspacegroup *wsg ); 173 174 gboolean workspace_add_action( Workspace *ws, 175 const char *name, const char *action, int nparam ); 176 177 int workspace_number( void ); 178 179 gboolean workspace_selected_recalc( Workspace *ws ); 180 void workspace_selected_remove_yesno( Workspace *ws, GtkWidget *parent ); 181 gboolean workspace_selected_ungroup( Workspace *ws ); 182 gboolean workspace_selected_group( Workspace *ws ); 183 184 gboolean workspace_next_error( Workspace *ws ); 185 186 void workspace_set_status( Workspace *ws, const char *fmt, ... ) 187 __attribute__((format(printf, 2, 3))); 188 189 void workspace_set_mode( Workspace *ws, WorkspaceMode mode ); 190 191 gboolean workspace_local_set( Workspace *ws, const char *txt ); 192 gboolean workspace_local_set_from_file( Workspace *ws, const char *fname ); 193 194 void workspace_jump_update( Workspace *ws, GtkWidget *menu ); 195 196 gboolean workspace_merge_file( Workspace *ws, const char *filename ); 197 gboolean workspace_selected_duplicate( Workspace *ws ); 198 gboolean workspace_selected_save( Workspace *ws, const char *filename ); 199 200 gboolean workspace_rename( Workspace *ws, 201 const char *name, const char *caption ); 202 void workspace_set_locked( Workspace *ws, gboolean locked ); 203 gboolean workspace_duplicate( Workspace *ws ); 204