offset fixes, admit to textline, proper updating of height/font at attr set,
[dia.git] / lib / persistence.h
blobd410cfbd47f5256a4887a2abcaae7c593a6ce1a6
1 /* Dia -- an diagram creation/manipulation program
2 * Copyright (C) 2003 Lars Clausen
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 /* persistence.h -- definitions for persistent storage.
22 #ifndef PERSISTENCE_H
23 #define PERSISTENCE_H
24 #include "config.h"
25 #include "geometry.h"
27 #include <gtk/gtk.h>
29 typedef struct {
30 int x, y;
31 int width, height;
32 gboolean isopen;
33 GtkWindow *window;
34 } PersistentWindow;
36 typedef void (NullaryFunc)();
38 void persistence_load(void);
39 void persistence_save(void);
40 void persistence_register_window(GtkWindow *window);
41 void persistence_register_window_create(gchar *role, NullaryFunc *func);
42 void persistence_register_string_entry(gchar *role, GtkWidget *entry);
43 gboolean persistence_change_string_entry(gchar *role, gchar *string,
44 GtkWidget *widget);
46 /** A persistently stored list of strings.
47 * The list contains no duplicates.
48 * If sorted is FALSE, any string added will be placed in front of the list
49 * (possibly removing it from further down), thus making it an LRU list.
50 * The list is not tied to any particular GTK widget, as it has uses
51 * in a number of different places (though mostly in menus)
53 typedef struct _PersistentList {
54 const gchar *role;
55 gboolean sorted;
56 gint max_members;
57 GList *glist;
58 GList *listeners;
59 } PersistentList;
61 typedef void (*PersistenceCallback)(GObject *, gpointer);
63 PersistentList *persistence_register_list(const gchar *role);
64 PersistentList *persistent_list_get(const gchar *role);
65 GList *persistent_list_get_glist(const gchar *role);
66 gboolean persistent_list_add(const gchar *role, const gchar *item);
67 void persistent_list_set_max_length(const gchar *role, gint max);
68 gboolean persistent_list_remove(const gchar *role, const gchar *item);
69 void persistent_list_remove_all(const gchar *role);
70 void persistent_list_add_listener(const gchar *role, PersistenceCallback func,
71 GObject *watch, gpointer userdata);
73 gint persistence_register_integer(gchar *role, int defaultvalue);
74 gint persistence_get_integer(gchar *role);
75 void persistence_set_integer(gchar *role, gint newvalue);
77 real persistence_register_real(gchar *role, real defaultvalue);
78 real persistence_get_real(gchar *role);
79 void persistence_set_real(gchar *role, real newvalue);
81 gboolean persistence_register_boolean(gchar *role, gboolean defaultvalue);
82 gboolean persistence_get_boolean(gchar *role);
83 void persistence_set_boolean(gchar *role, gboolean newvalue);
85 gchar *persistence_register_string(gchar *role, gchar *defaultvalue);
86 gchar *persistence_get_string(gchar *role);
87 void persistence_set_string(gchar *role, gchar *newvalue);
89 Color *persistence_register_color(gchar *role, Color *defaultvalue);
90 Color *persistence_get_color(gchar *role);
91 void persistence_set_color(gchar *role, Color *newvalue);
93 #endif