1 #ifndef DYNOPTS_H
2 #define DYNOPTS_H
3 /*
4     roxterm - VTE/GTK terminal emulator with tabs
5     Copyright (C) 2004-2015 Tony Houghton <h@realh.co.uk>
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20 */
21 
22 
23 /* A sort of base class for "dynamic options" ie profiles, colour schemes and
24  * keyboard shortcuts, which can be looked up by name */
25 
26 #include "options.h"
27 
28 typedef struct DynamicOptions DynamicOptions;
29 
30 /* family is subdir in roxterm: Profiles, Colours, Shortcuts. This
31  * returns a reference to existing DynamicOptions if one has already been
32  * created for the given family */
33 DynamicOptions *dynamic_options_get(const char *family);
34 
35 /* profile_name may actually be a colour scheme or keyboard shortcut scheme;
36  * returns NULL if it hasn't already been opened with
37  * dynamic_options_lookup_and_ref */
38 Options *dynamic_options_lookup(DynamicOptions * dynopts,
39 	const char *profile_name);
40 
41 /* Creates Options if it hasn't already been opened */
42 Options *dynamic_options_lookup_and_ref(DynamicOptions * dynopts,
43 	const char *profile_name, const char *group_name);
44 
45 /* Removes profile from dynopts without unrefing profile */
46 void
47 dynamic_options_forget(DynamicOptions *dynopts, const char *profile_name);
48 
49 /* Calls options_unref on looked up profile and removes it from dynopts */
50 gboolean
51 dynamic_options_unref(DynamicOptions * dynopts, const char *profile_name);
52 
53 /* Renames a profile */
54 void dynamic_options_rename(DynamicOptions *dynopts,
55 		const char *old_name, const char *new_name);
56 
57 char **dynamic_options_list_full(DynamicOptions *, gboolean sorted);
58 
59 /* Returns a list of names (g_strfreev them) of files within family's subdir;
60  * the first item will always be "Default" even if no such file exists */
dynamic_options_list(DynamicOptions * dynopts)61 inline static char **dynamic_options_list(DynamicOptions *dynopts)
62 {
63     return dynamic_options_list_full(dynopts, FALSE);
64 }
65 
66 /* As above but the list is sorted (but Default comes first) */
dynamic_options_list_sorted(DynamicOptions * dynopts)67 inline static char **dynamic_options_list_sorted(DynamicOptions *dynopts)
68 {
69     return dynamic_options_list_full(dynopts, TRUE);
70 }
71 
72 /* Like g_strcmp0 but "Default" comes first */
73 int dynamic_options_strcmp(const char *s1, const char *s2);
74 
75 #endif /* DYNOPTS_H */
76 
77 /* vi:set sw=4 ts=4 noet cindent cino= */
78