summaryrefslogtreecommitdiff
path: root/libgnome-desktop/gnome-desktop-item.h
blob: 67c4fda0e2561f0a26d1a3b133e3800d5af9a0b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
/* -*- Mode: C; c-set-style: linux indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* gnome-ditem.h - GNOME Desktop File Representation 

   Copyright (C) 1999, 2000 Red Hat Inc.
   All rights reserved.

   This file is part of the Gnome Library.

   The Gnome Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public License as
   published by the Free Software Foundation; either version 2 of the
   License, or (at your option) any later version.
   
   The Gnome Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.
   
   You should have received a copy of the GNU Library General Public
   License along with the Gnome Library; see the file COPYING.LIB.  If not,
   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.  */
/*
  @NOTATION@
 */

#ifndef GNOME_DITEM_H
#define GNOME_DITEM_H

#include <glib.h>

G_BEGIN_DECLS

typedef enum {
	GNOME_DESKTOP_ITEM_TYPE_NULL = 0 /* This means its NULL, that is, not
					   * set */,
	GNOME_DESKTOP_ITEM_TYPE_OTHER /* This means it's not one of the below
					      strings types, and you must get the
					      Type attribute. */,

	/* These are the standard compliant types: */
	GNOME_DESKTOP_ITEM_TYPE_APPLICATION,
	GNOME_DESKTOP_ITEM_TYPE_LINK,
	GNOME_DESKTOP_ITEM_TYPE_FSDEVICE,
	GNOME_DESKTOP_ITEM_TYPE_MIME_TYPE,
	GNOME_DESKTOP_ITEM_TYPE_DIRECTORY,
	GNOME_DESKTOP_ITEM_TYPE_SERVICE,
	GNOME_DESKTOP_ITEM_TYPE_SERVICE_TYPE
} GnomeDesktopItemType;

typedef enum {
        GNOME_DESKTOP_ITEM_UNCHANGED = 0,
        GNOME_DESKTOP_ITEM_CHANGED = 1,
        GNOME_DESKTOP_ITEM_DISAPPEARED = 2
} GnomeDesktopItemStatus;

typedef struct _GnomeDesktopItem GnomeDesktopItem;

#define GNOME_DESKTOP_ITEM_ENCODING	"Encoding" /* string */
#define GNOME_DESKTOP_ITEM_VERSION	"Version"  /* numeric */
#define GNOME_DESKTOP_ITEM_NAME		"Name" /* localestring */
#define GNOME_DESKTOP_ITEM_TYPE		"Type" /* string */
#define GNOME_DESKTOP_ITEM_FILE_PATTERN "FilePattern" /* regexp(s) */
#define GNOME_DESKTOP_ITEM_TRY_EXEC	"TryExec" /* string */
#define GNOME_DESKTOP_ITEM_NO_DISPLAY	"NoDisplay" /* boolean */
#define GNOME_DESKTOP_ITEM_COMMENT	"Comment" /* localestring */
#define GNOME_DESKTOP_ITEM_EXEC		"Exec" /* string */
#define GNOME_DESKTOP_ITEM_ACTIONS	"Actions" /* strings */
#define GNOME_DESKTOP_ITEM_ICON		"Icon" /* string */
#define GNOME_DESKTOP_ITEM_MINI_ICON	"MiniIcon" /* string */
#define GNOME_DESKTOP_ITEM_HIDDEN	"Hidden" /* boolean */
#define GNOME_DESKTOP_ITEM_PATH		"Path" /* string */
#define GNOME_DESKTOP_ITEM_TERMINAL	"Terminal" /* boolean */
#define GNOME_DESKTOP_ITEM_TERMINAL_OPTIONS "TerminalOptions" /* string */
#define GNOME_DESKTOP_ITEM_SWALLOW_TITLE "SwallowTitle" /* string */
#define GNOME_DESKTOP_ITEM_SWALLOW_EXEC	"SwallowExec" /* string */
#define GNOME_DESKTOP_ITEM_MIME_TYPE	"MimeType" /* regexp(s) */
#define GNOME_DESKTOP_ITEM_PATTERNS	"Patterns" /* regexp(s) */
#define GNOME_DESKTOP_ITEM_DEFAULT_APP	"DefaultApp" /* string */
#define GNOME_DESKTOP_ITEM_DEV		"Dev" /* string */
#define GNOME_DESKTOP_ITEM_FS_TYPE	"FSType" /* string */
#define GNOME_DESKTOP_ITEM_MOUNT_POINT	"MountPoint" /* string */
#define GNOME_DESKTOP_ITEM_READ_ONLY	"ReadOnly" /* boolean */
#define GNOME_DESKTOP_ITEM_UNMOUNT_ICON "UnmountIcon" /* string */
#define GNOME_DESKTOP_ITEM_SORT_ORDER	"SortOrder" /* strings */
#define GNOME_DESKTOP_ITEM_URL		"URL" /* string */

typedef enum {
	/* Use the TryExec field to determine if this shoul dbe loaded */
        GNOME_DESKTOP_ITEM_LOAD_ONLY_IF_EXISTS = 1<<0
} GnomeDesktopItemLoadFlags;

/* Returned item from new*() and copy() methods have a refcount of 1 */
GnomeDesktopItem *      gnome_desktop_item_new               (void);
GnomeDesktopItem *      gnome_desktop_item_new_from_file     (const char                 *file,
							      GnomeDesktopItemLoadFlags   flags,
							      GError                    **error);
GnomeDesktopItem *      gnome_desktop_item_copy              (GnomeDesktopItem           *item);

/* if under is NULL save in original location */
gboolean                gnome_desktop_item_save              (GnomeDesktopItem           *item,
							      const char                 *under,
							      gboolean			  force,
							      GError                    **error);
GnomeDesktopItem *      gnome_desktop_item_ref               (GnomeDesktopItem           *item);
void                    gnome_desktop_item_unref             (GnomeDesktopItem           *item);
int                     gnome_desktop_item_launch            (GnomeDesktopItem           *item,
							      int                         argc,
							      const char                **argv,
							      GError                    **error);

/* A list of files or urls dropped onto an icon, the proper (Url or File
   exec is run you can pass directly the output of 
   gnome_uri_list_extract_filenames) */
int                     gnome_desktop_item_drop_uri_list     (GnomeDesktopItem           *item,
							      GList                      *uri_list,
							      GError                    **error);

gboolean                gnome_desktop_item_exists            (GnomeDesktopItem           *item);

GnomeDesktopItemType	gnome_desktop_item_get_type          (GnomeDesktopItem		 *item);
/* You could also just use the set_string on the TYPE argument */
void			gnome_desktop_item_set_type          (GnomeDesktopItem		 *item,
							      GnomeDesktopItemType	  type);

/* Get current location on disk */
char *                  gnome_desktop_item_get_location      (GnomeDesktopItem           *item);
void                    gnome_desktop_item_set_location      (GnomeDesktopItem           *item,
							      const char                 *location);
GnomeDesktopItemStatus  gnome_desktop_item_get_file_status   (GnomeDesktopItem           *item);



/*
 * Reading/Writing different sections, NULL is the standard section
 */
void                    gnome_desktop_item_push_section      (GnomeDesktopItem           *item,
							      const char                 *section);
void                    gnome_desktop_item_pop_section       (GnomeDesktopItem           *item);


gboolean                gnome_desktop_item_attr_exists       (GnomeDesktopItem           *item,
							      const char                 *attr);

/*
 * String type
 */
const char *            gnome_desktop_item_get_string        (GnomeDesktopItem           *item,
							      const char		 *attr);

void                    gnome_desktop_item_set_string        (GnomeDesktopItem           *item,
							      const char		 *attr,
							      const char                 *value);

/*
 * LocaleString type
 */
const char *            gnome_desktop_item_get_localestring  (GnomeDesktopItem           *item,
							      const char		 *attr);
const char *            gnome_desktop_item_get_localestring_lang (GnomeDesktopItem       *item,
								  const char		 *attr,
								  const char             *language);
/* use g_list_free only */
GList *                 gnome_desktop_item_get_languages     (GnomeDesktopItem           *item,
							      const char		 *attr);

void                    gnome_desktop_item_set_localestring  (GnomeDesktopItem           *item,
							      const char		 *attr,
							      const char                 *language,
							      const char                 *value);

/*
 * Strings, Regexps types
 */

/* use gnome_desktop_item_free_string_list */
char **                 gnome_desktop_item_get_strings       (GnomeDesktopItem           *item,
							      const char		 *attr);

void			gnome_desktop_item_set_strings       (GnomeDesktopItem           *item,
							      const char                 *attr,
							      char                      **strings);

/*
 * Boolean type
 */
gboolean                gnome_desktop_item_get_boolean       (GnomeDesktopItem           *item,
							      const char		 *attr);

void                    gnome_desktop_item_set_boolean       (GnomeDesktopItem           *item,
							      const char		 *attr,
							      gboolean                    value);

/*
 * Clearing attributes
 */
#define                 gnome_desktop_item_clear_attr(item,attr) \
				gnome_desktop_item_set_string(item,attr,NULL)
void			gnome_desktop_item_clear_section     (GnomeDesktopItem           *item,
							      const char                 *section);

G_END_DECLS

#endif /* GNOME_DITEM_H */