]> Dogcows Code - chaz/openbox/blob - obt/link.c
figure out what type the value should be for each known .desktop key, and watch for...
[chaz/openbox] / obt / link.c
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3 obt/link.c for the Openbox window manager
4 Copyright (c) 2009 Dana Jansens
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 See the COPYING file for a copy of the GNU General Public License.
17 */
18
19 #include "obt/link.h"
20 #include "obt/ddparse.h"
21 #include <glib.h>
22
23 struct _ObtLink {
24 guint ref;
25
26 ObtLinkType type;
27 gchar *name; /*!< Specific name for the object (eg Firefox) */
28 gchar *generic; /*!< Generic name for the object (eg Web Browser) */
29 gchar *comment; /*!< Comment/description to display for the object */
30 gchar *icon; /*!< Name/path for an icon for the object */
31
32 union _ObtLinkData {
33 struct _ObtLinkApp {
34 gchar *exec; /*!< Executable to run for the app */
35 gchar *wdir; /*!< Working dir to run the app in */
36 gboolean term; /*!< Run the app in a terminal or not */
37 ObtLinkAppOpen open;
38
39 /* XXX gchar**? or something better, a mime struct.. maybe
40 glib has something i can use. */
41 gchar **mime; /*!< Mime types the app can open */
42
43 ObtLinkAppStartup startup;
44 gchar *startup_wmclass;
45 } app;
46 struct _ObtLinkLink {
47 gchar *url;
48 } link;
49 struct _ObtLinkDir {
50 } dir;
51 } d;
52 };
53
54 ObtLink* obt_link_from_ddfile(const gchar *name, GSList *paths)
55 {
56 ObtLink *lnk;
57 GHashTable *groups, *keys;
58 ObtDDParseGroup *g;
59
60 groups = obt_ddparse_file(name, paths);
61 if (!groups) return NULL;
62 g = g_hash_table_lookup(groups, "Desktop Entry");
63 if (!g) {
64 g_hash_table_destroy(groups);
65 return NULL;
66 }
67
68 keys = obt_ddparse_group_keys(g);
69
70 lnk = g_slice_new(ObtLink);
71 lnk->ref = 1;
72 /* XXX turn the values in the .desktop file into an ObtLink */
73
74 return lnk;
75 }
76
77 void obt_link_ref(ObtLink *dd)
78 {
79 ++dd->ref;
80 }
81
82 void obt_link_unref(ObtLink *dd)
83 {
84 if (--dd->ref < 1) {
85 g_slice_free(ObtLink, dd);
86 }
87 }
This page took 0.033815 seconds and 4 git commands to generate.