Mercurial > audlegacy
annotate src/audacious/tuple_formatter.c @ 3349:01a241d35146 trunk
add tuple_formatter_make_title_string(). it is a wrapper function to tuple_formatter_process_construct() to make title string. it falls back to the file name if the formatted string is blank or unavailable.
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Mon, 13 Aug 2007 19:45:52 +0900 |
parents | c23513d0ee17 |
children | 678ea77b6b1f |
rev | line source |
---|---|
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
1 /* |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
2 * Audacious |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
3 * Copyright (c) 2007 William Pitcock |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
4 * |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
5 * This program is free software; you can redistribute it and/or modify |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
6 * it under the terms of the GNU General Public License as published by |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
7 * the Free Software Foundation; under version 3 of the License. |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
8 * |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
9 * This program is distributed in the hope that it will be useful, |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
12 * GNU General Public License for more details. |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
13 * |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
14 * You should have received a copy of the GNU General Public License |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
15 * along with this program. If not, see <http://www.gnu.org/licenses>. |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
16 * |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
17 * The Audacious team does not consider modular code linking to |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
18 * Audacious or using our public API to be a derived work. |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
19 */ |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
20 |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
21 #include <glib.h> |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
22 #include <mowgli.h> |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
23 |
3292
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
24 #include "config.h" |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
25 #include "tuple.h" |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
26 #include "tuple_formatter.h" |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
27 |
3331
9c53688bb559
some debugging for giacomo
William Pitcock <nenolod@atheme-project.org>
parents:
3322
diff
changeset
|
28 #define _DEBUG |
9c53688bb559
some debugging for giacomo
William Pitcock <nenolod@atheme-project.org>
parents:
3322
diff
changeset
|
29 |
9c53688bb559
some debugging for giacomo
William Pitcock <nenolod@atheme-project.org>
parents:
3322
diff
changeset
|
30 #ifdef _DEBUG |
9c53688bb559
some debugging for giacomo
William Pitcock <nenolod@atheme-project.org>
parents:
3322
diff
changeset
|
31 # define _TRACE(fmt, ...) g_print("[tuple-fmt] %s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__); |
9c53688bb559
some debugging for giacomo
William Pitcock <nenolod@atheme-project.org>
parents:
3322
diff
changeset
|
32 #else |
9c53688bb559
some debugging for giacomo
William Pitcock <nenolod@atheme-project.org>
parents:
3322
diff
changeset
|
33 # define _TRACE(fmt, ...) |
9c53688bb559
some debugging for giacomo
William Pitcock <nenolod@atheme-project.org>
parents:
3322
diff
changeset
|
34 #endif |
9c53688bb559
some debugging for giacomo
William Pitcock <nenolod@atheme-project.org>
parents:
3322
diff
changeset
|
35 |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
36 /* |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
37 * the tuple formatter: |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
38 * |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
39 * this is a data-driven meta-language which eventually hopes to be |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
40 * turing complete. |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
41 * |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
42 * language constructs follow the following basic rules: |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
43 * - begin with ${ |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
44 * - end with } |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
45 * |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
46 * language constructs: |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
47 * - ${field}: prints a field |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
48 * - ${?field:expr}: evaluates expr if field exists |
3284
70789a2a5a65
documentation fixes
William Pitcock <nenolod@atheme-project.org>
parents:
3283
diff
changeset
|
49 * - ${=field,"value"}: defines field in the currently iterated |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
50 * tuple as string value of "value" |
3284
70789a2a5a65
documentation fixes
William Pitcock <nenolod@atheme-project.org>
parents:
3283
diff
changeset
|
51 * - ${=field,value}: defines field in the currently iterated |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
52 * tuple as integer value of "value" |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
53 * - ${==field,field:expr}: evaluates expr if both fields are the same |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
54 * - ${!=field,field:expr}: evaluates expr if both fields are not the same |
3290
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
55 * - ${(empty)?field:expr}: evaluates expr if field is empty or does not exist |
3292
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
56 * - %{function:args,arg2,...}: runs function and inserts the result. |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
57 * |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
58 * everything else is treated as raw text. |
3292
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
59 * additionally, plugins can add additional instructions and functions! |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
60 */ |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
61 |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
62 typedef struct { |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
63 Tuple *tuple; |
3285
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
64 GString *str; |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
65 } TupleFormatterContext; |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
66 |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
67 /* processes a construct, e.g. "${?artist:artist is defined}" would |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
68 return "artist is defined" if artist is defined. */ |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
69 gchar * |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
70 tuple_formatter_process_construct(Tuple *tuple, const gchar *string) |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
71 { |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
72 TupleFormatterContext *ctx; |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
73 const gchar *iter; |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
74 gchar *out; |
3314 | 75 gint level = 0; |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
76 |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
77 g_return_val_if_fail(tuple != NULL, NULL); |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
78 g_return_val_if_fail(string != NULL, NULL); |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
79 |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
80 ctx = g_new0(TupleFormatterContext, 1); |
3285
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
81 ctx->str = g_string_new(""); |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
82 |
3331
9c53688bb559
some debugging for giacomo
William Pitcock <nenolod@atheme-project.org>
parents:
3322
diff
changeset
|
83 _TRACE("parsing <%s>", string); |
9c53688bb559
some debugging for giacomo
William Pitcock <nenolod@atheme-project.org>
parents:
3322
diff
changeset
|
84 |
3285
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
85 /* parsers are ugly */ |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
86 for (iter = string; *iter != '\0'; iter++) |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
87 { |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
88 /* if it's raw text, just copy the byte */ |
3335
63d7947d7376
simplified the tuple formatter a bit
Giacomo Lozito <james@develia.org>
parents:
3331
diff
changeset
|
89 if (*iter != '$' && *iter != '%' && *iter != '}' ) |
63d7947d7376
simplified the tuple formatter a bit
Giacomo Lozito <james@develia.org>
parents:
3331
diff
changeset
|
90 { |
63d7947d7376
simplified the tuple formatter a bit
Giacomo Lozito <james@develia.org>
parents:
3331
diff
changeset
|
91 g_string_append_c(ctx->str, *iter); |
63d7947d7376
simplified the tuple formatter a bit
Giacomo Lozito <james@develia.org>
parents:
3331
diff
changeset
|
92 } |
63d7947d7376
simplified the tuple formatter a bit
Giacomo Lozito <james@develia.org>
parents:
3331
diff
changeset
|
93 else if (*iter == '}' && level > 0) |
3314 | 94 { |
95 level--; | |
96 } | |
3313
257c0d0c5806
use g_str_has_prefix() more.
William Pitcock <nenolod@atheme-project.org>
parents:
3292
diff
changeset
|
97 else if (g_str_has_prefix(iter, "${") == TRUE) |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
98 { |
3285
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
99 GString *expression = g_string_new(""); |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
100 GString *argument = g_string_new(""); |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
101 GString *sel = expression; |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
102 gchar *result; |
3335
63d7947d7376
simplified the tuple formatter a bit
Giacomo Lozito <james@develia.org>
parents:
3331
diff
changeset
|
103 level++; |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
104 |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
105 for (iter += 2; *iter != '\0'; iter++) |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
106 { |
3285
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
107 if (*iter == ':') |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
108 { |
3316 | 109 if (sel != argument) |
110 { | |
111 sel = argument; | |
112 continue; | |
113 } | |
114 else | |
115 g_string_append_c(sel, *iter); | |
3285
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
116 continue; |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
117 } |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
118 |
3292
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
119 if (g_str_has_prefix(iter, "${") == TRUE || g_str_has_prefix(iter, "%{") == TRUE) |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
120 { |
3285
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
121 if (sel == argument) |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
122 { |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
123 g_string_append_c(sel, *iter); |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
124 level++; |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
125 } |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
126 } |
3314 | 127 else if (*iter == '}' && (sel == argument)) |
3285
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
128 { |
3314 | 129 level--; |
3335
63d7947d7376
simplified the tuple formatter a bit
Giacomo Lozito <james@develia.org>
parents:
3331
diff
changeset
|
130 if (level == 0) |
63d7947d7376
simplified the tuple formatter a bit
Giacomo Lozito <james@develia.org>
parents:
3331
diff
changeset
|
131 break; |
63d7947d7376
simplified the tuple formatter a bit
Giacomo Lozito <james@develia.org>
parents:
3331
diff
changeset
|
132 else |
63d7947d7376
simplified the tuple formatter a bit
Giacomo Lozito <james@develia.org>
parents:
3331
diff
changeset
|
133 g_string_append_c(sel, *iter); |
3314 | 134 } |
135 else if (*iter == '}' && ((sel != argument))) | |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
136 break; |
3285
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
137 else |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
138 g_string_append_c(sel, *iter); |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
139 } |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
140 |
3285
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
141 if (expression->len == 0) |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
142 { |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
143 g_string_free(expression, TRUE); |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
144 g_string_free(argument, TRUE); |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
145 continue; |
3285
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
146 } |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
147 |
3285
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
148 result = tuple_formatter_process_expr(tuple, expression->str, argument->len ? argument->str : NULL); |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
149 if (result != NULL) |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
150 { |
3285
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
151 g_string_append(ctx->str, result); |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
152 g_free(result); |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
153 } |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
154 |
3285
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
155 g_string_free(expression, TRUE); |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
156 g_string_free(argument, TRUE); |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
157 |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
158 if (*iter == '\0') |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
159 break; |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
160 } |
3313
257c0d0c5806
use g_str_has_prefix() more.
William Pitcock <nenolod@atheme-project.org>
parents:
3292
diff
changeset
|
161 else if (g_str_has_prefix(iter, "%{") == TRUE) |
3292
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
162 { |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
163 GString *expression = g_string_new(""); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
164 GString *argument = g_string_new(""); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
165 GString *sel = expression; |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
166 gchar *result; |
3335
63d7947d7376
simplified the tuple formatter a bit
Giacomo Lozito <james@develia.org>
parents:
3331
diff
changeset
|
167 level++; |
3292
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
168 |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
169 for (iter += 2; *iter != '\0'; iter++) |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
170 { |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
171 if (*iter == ':') |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
172 { |
3322
de29bf952b77
fix recursion and combination of functions and expressions too
William Pitcock <nenolod@atheme-project.org>
parents:
3316
diff
changeset
|
173 if (sel != argument) |
de29bf952b77
fix recursion and combination of functions and expressions too
William Pitcock <nenolod@atheme-project.org>
parents:
3316
diff
changeset
|
174 { |
de29bf952b77
fix recursion and combination of functions and expressions too
William Pitcock <nenolod@atheme-project.org>
parents:
3316
diff
changeset
|
175 sel = argument; |
de29bf952b77
fix recursion and combination of functions and expressions too
William Pitcock <nenolod@atheme-project.org>
parents:
3316
diff
changeset
|
176 continue; |
de29bf952b77
fix recursion and combination of functions and expressions too
William Pitcock <nenolod@atheme-project.org>
parents:
3316
diff
changeset
|
177 } |
de29bf952b77
fix recursion and combination of functions and expressions too
William Pitcock <nenolod@atheme-project.org>
parents:
3316
diff
changeset
|
178 else |
de29bf952b77
fix recursion and combination of functions and expressions too
William Pitcock <nenolod@atheme-project.org>
parents:
3316
diff
changeset
|
179 g_string_append_c(sel, *iter); |
3292
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
180 continue; |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
181 } |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
182 |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
183 if (g_str_has_prefix(iter, "${") == TRUE || g_str_has_prefix(iter, "%{") == TRUE) |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
184 { |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
185 if (sel == argument) |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
186 { |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
187 g_string_append_c(sel, *iter); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
188 level++; |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
189 } |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
190 } |
3314 | 191 else if (*iter == '}' && (sel == argument)) |
3292
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
192 { |
3314 | 193 level--; |
3335
63d7947d7376
simplified the tuple formatter a bit
Giacomo Lozito <james@develia.org>
parents:
3331
diff
changeset
|
194 if (level == 0) |
63d7947d7376
simplified the tuple formatter a bit
Giacomo Lozito <james@develia.org>
parents:
3331
diff
changeset
|
195 break; |
63d7947d7376
simplified the tuple formatter a bit
Giacomo Lozito <james@develia.org>
parents:
3331
diff
changeset
|
196 else |
3322
de29bf952b77
fix recursion and combination of functions and expressions too
William Pitcock <nenolod@atheme-project.org>
parents:
3316
diff
changeset
|
197 g_string_append_c(sel, *iter); |
3314 | 198 } |
199 else if (*iter == '}' && ((sel != argument))) | |
3292
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
200 break; |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
201 else |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
202 g_string_append_c(sel, *iter); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
203 } |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
204 |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
205 if (expression->len == 0) |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
206 { |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
207 g_string_free(expression, TRUE); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
208 g_string_free(argument, TRUE); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
209 continue; |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
210 } |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
211 |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
212 result = tuple_formatter_process_function(tuple, expression->str, argument->len ? argument->str : NULL); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
213 if (result != NULL) |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
214 { |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
215 g_string_append(ctx->str, result); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
216 g_free(result); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
217 } |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
218 |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
219 g_string_free(expression, TRUE); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
220 g_string_free(argument, TRUE); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
221 |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
222 if (*iter == '\0') |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
223 break; |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
224 } |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
225 } |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
226 |
3285
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
227 out = g_strdup(ctx->str->str); |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
228 g_string_free(ctx->str, TRUE); |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
229 g_free(ctx); |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
230 |
3331
9c53688bb559
some debugging for giacomo
William Pitcock <nenolod@atheme-project.org>
parents:
3322
diff
changeset
|
231 _TRACE("parsed <%s> as <%s>", string, out); |
9c53688bb559
some debugging for giacomo
William Pitcock <nenolod@atheme-project.org>
parents:
3322
diff
changeset
|
232 |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
233 return out; |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
234 } |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
235 |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
236 static GList *tuple_formatter_expr_list = NULL; |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
237 |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
238 typedef struct { |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
239 const gchar *name; |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
240 gboolean (*func)(Tuple *tuple, const gchar *expression); |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
241 } TupleFormatterExpression; |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
242 |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
243 /* processes an expression and optional argument pair. */ |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
244 gchar * |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
245 tuple_formatter_process_expr(Tuple *tuple, const gchar *expression, |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
246 const gchar *argument) |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
247 { |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
248 TupleFormatterExpression *expr = NULL; |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
249 GList *iter; |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
250 |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
251 g_return_val_if_fail(tuple != NULL, NULL); |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
252 g_return_val_if_fail(expression != NULL, NULL); |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
253 |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
254 for (iter = tuple_formatter_expr_list; iter != NULL; iter = iter->next) |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
255 { |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
256 TupleFormatterExpression *tmp = (TupleFormatterExpression *) iter->data; |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
257 |
3285
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
258 if (g_str_has_prefix(expression, tmp->name) == TRUE) |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
259 { |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
260 expr = tmp; |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
261 expression += strlen(tmp->name); |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
262 } |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
263 } |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
264 |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
265 /* ${artist} */ |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
266 if (expr == NULL && argument == NULL) |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
267 { |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
268 TupleValueType type = tuple_get_value_type(tuple, expression); |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
269 |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
270 switch(type) |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
271 { |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
272 case TUPLE_STRING: |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
273 return g_strdup(tuple_get_string(tuple, expression)); |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
274 break; |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
275 case TUPLE_INT: |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
276 return g_strdup_printf("%d", tuple_get_int(tuple, expression)); |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
277 break; |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
278 case TUPLE_UNKNOWN: |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
279 default: |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
280 return NULL; |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
281 } |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
282 } |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
283 else if (expr != NULL) |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
284 { |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
285 if (expr->func(tuple, expression) == TRUE && argument != NULL) |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
286 return tuple_formatter_process_construct(tuple, argument); |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
287 } |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
288 |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
289 return NULL; |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
290 } |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
291 |
3292
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
292 static GList *tuple_formatter_func_list = NULL; |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
293 |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
294 typedef struct { |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
295 const gchar *name; |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
296 gchar *(*func)(Tuple *tuple, gchar **args); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
297 } TupleFormatterFunction; |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
298 |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
299 /* processes a function */ |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
300 gchar * |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
301 tuple_formatter_process_function(Tuple *tuple, const gchar *expression, |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
302 const gchar *argument) |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
303 { |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
304 TupleFormatterFunction *expr = NULL; |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
305 GList *iter; |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
306 |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
307 g_return_val_if_fail(tuple != NULL, NULL); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
308 g_return_val_if_fail(expression != NULL, NULL); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
309 |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
310 for (iter = tuple_formatter_func_list; iter != NULL; iter = iter->next) |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
311 { |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
312 TupleFormatterFunction *tmp = (TupleFormatterFunction *) iter->data; |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
313 |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
314 if (g_str_has_prefix(expression, tmp->name) == TRUE) |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
315 { |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
316 expr = tmp; |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
317 expression += strlen(tmp->name); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
318 } |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
319 } |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
320 |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
321 if (expr != NULL) |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
322 { |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
323 gchar **args; |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
324 gchar *ret; |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
325 |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
326 if (argument) |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
327 args = g_strsplit(argument, ",", 10); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
328 else |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
329 args = NULL; |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
330 |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
331 ret = expr->func(tuple, args); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
332 |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
333 if (args) |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
334 g_strfreev(args); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
335 |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
336 return ret; |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
337 } |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
338 |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
339 return NULL; |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
340 } |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
341 |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
342 /* registers a formatter */ |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
343 void |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
344 tuple_formatter_register_expression(const gchar *keyword, |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
345 gboolean (*func)(Tuple *tuple, const gchar *argument)) |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
346 { |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
347 TupleFormatterExpression *expr; |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
348 |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
349 g_return_if_fail(keyword != NULL); |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
350 g_return_if_fail(func != NULL); |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
351 |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
352 expr = g_new0(TupleFormatterExpression, 1); |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
353 expr->name = keyword; |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
354 expr->func = func; |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
355 |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
356 tuple_formatter_expr_list = g_list_append(tuple_formatter_expr_list, expr); |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
357 } |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
358 |
3292
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
359 /* registers a function */ |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
360 void |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
361 tuple_formatter_register_function(const gchar *keyword, |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
362 gchar *(*func)(Tuple *tuple, gchar **argument)) |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
363 { |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
364 TupleFormatterFunction *expr; |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
365 |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
366 g_return_if_fail(keyword != NULL); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
367 g_return_if_fail(func != NULL); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
368 |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
369 expr = g_new0(TupleFormatterFunction, 1); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
370 expr->name = keyword; |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
371 expr->func = func; |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
372 |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
373 tuple_formatter_func_list = g_list_append(tuple_formatter_func_list, expr); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
374 } |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
375 |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
376 /* builtin-keyword: ${?arg}, returns TRUE if <arg> exists. */ |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
377 static gboolean |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
378 tuple_formatter_expression_exists(Tuple *tuple, const gchar *expression) |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
379 { |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
380 return (tuple_get_value_type(tuple, expression) != TUPLE_UNKNOWN) ? TRUE : FALSE; |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
381 } |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
382 |
3339
c23513d0ee17
adjusted comments for == and != tuple operators
Giacomo Lozito <james@develia.org>
parents:
3338
diff
changeset
|
383 /* builtin-keyword: ${==arg1,arg2}, returns TRUE if <arg1> and <arg2> match. |
c23513d0ee17
adjusted comments for == and != tuple operators
Giacomo Lozito <james@develia.org>
parents:
3338
diff
changeset
|
384 <arg1> and <arg2> can also be raw text, which should be enclosed in "double quotes". */ |
3286
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
385 static gboolean |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
386 tuple_formatter_expression_match(Tuple *tuple, const gchar *expression) |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
387 { |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
388 gchar **args = g_strsplit(expression, ",", 2); |
3338
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
389 gchar *arg1 = NULL, *arg2 = NULL; |
3286
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
390 gint ret; |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
391 |
3338
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
392 if (args[0][0] == '\"') /* check if arg1 is "raw text" */ |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
393 { |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
394 if ( strlen(args[0]) > 1 ) |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
395 { |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
396 args[0][strlen(args[0]) - 1] = '\0'; |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
397 arg1 = g_strdup(&(args[0][1])); |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
398 args[0][strlen(args[0]) - 1] = '\"'; |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
399 } |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
400 else /* bad formatted arg */ |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
401 return FALSE; |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
402 } |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
403 else if (tuple_get_value_type(tuple, args[0]) == TUPLE_UNKNOWN) |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
404 { |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
405 g_strfreev(args); |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
406 return FALSE; |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
407 } |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
408 |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
409 if (args[1][0] == '\"') /* check if arg2 is "raw text" */ |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
410 { |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
411 if ( strlen(args[1]) > 1 ) |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
412 { |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
413 args[1][strlen(args[1]) - 1] = '\0'; |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
414 arg2 = g_strdup(&(args[1][1])); |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
415 args[1][strlen(args[1]) - 1] = '\"'; |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
416 } |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
417 else /* bad formatted arg */ |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
418 return FALSE; |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
419 } |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
420 else if (tuple_get_value_type(tuple, args[1]) == TUPLE_UNKNOWN) |
3286
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
421 { |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
422 g_strfreev(args); |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
423 return FALSE; |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
424 } |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
425 |
3338
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
426 if (!arg1) /* if arg1 is not "raw text", get the tuple value */ |
3286
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
427 { |
3338
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
428 if (tuple_get_value_type(tuple, args[0]) == TUPLE_STRING) |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
429 arg1 = g_strdup(tuple_get_string(tuple, args[0])); |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
430 else |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
431 arg1 = g_strdup_printf("%d", tuple_get_int(tuple, args[0])); |
3286
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
432 } |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
433 |
3338
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
434 if (!arg2) /* if arg2 is not "raw text", get the tuple value */ |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
435 { |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
436 if (tuple_get_value_type(tuple, args[1]) == TUPLE_STRING) |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
437 arg2 = g_strdup(tuple_get_string(tuple, args[1])); |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
438 else |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
439 arg2 = g_strdup_printf("%d", tuple_get_int(tuple, args[1])); |
07ed916b7176
added support for raw text comparisons in tuple == operator (and that means != as well)
Giacomo Lozito <james@develia.org>
parents:
3335
diff
changeset
|
440 } |
3286
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
441 |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
442 ret = g_ascii_strcasecmp(arg1, arg2); |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
443 g_free(arg1); |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
444 g_free(arg2); |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
445 g_strfreev(args); |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
446 |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
447 return ret ? FALSE : TRUE; |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
448 } |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
449 |
3339
c23513d0ee17
adjusted comments for == and != tuple operators
Giacomo Lozito <james@develia.org>
parents:
3338
diff
changeset
|
450 /* builtin-keyword: ${!=arg1,arg2}. returns TRUE if <arg1> and <arg2> don't match. |
c23513d0ee17
adjusted comments for == and != tuple operators
Giacomo Lozito <james@develia.org>
parents:
3338
diff
changeset
|
451 <arg1> and <arg2> can also be raw text, which should be enclosed in "double quotes". */ |
3286
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
452 static gboolean |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
453 tuple_formatter_expression_nonmatch(Tuple *tuple, const gchar *expression) |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
454 { |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
455 return tuple_formatter_expression_match(tuple, expression) ^ 1; |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
456 } |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
457 |
3290
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
458 /* builtin-keyword: ${empty?}. returns TRUE if <arg> is empty. */ |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
459 static gboolean |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
460 tuple_formatter_expression_empty(Tuple *tuple, const gchar *expression) |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
461 { |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
462 gboolean ret = TRUE; |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
463 const gchar *iter; |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
464 TupleValueType type = tuple_get_value_type(tuple, expression); |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
465 |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
466 if (type == TUPLE_UNKNOWN) |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
467 return TRUE; |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
468 |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
469 if (type == TUPLE_INT && tuple_get_int(tuple, expression) != 0) |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
470 return FALSE; |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
471 |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
472 iter = tuple_get_string(tuple, expression); |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
473 |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
474 while (ret && *iter != '\0') |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
475 { |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
476 if (*iter == ' ') |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
477 iter++; |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
478 else |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
479 ret = FALSE; |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
480 } |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
481 |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
482 return ret; |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
483 } |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
484 |
3292
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
485 /* builtin function: %{audacious-version} */ |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
486 static gchar * |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
487 tuple_formatter_function_version(Tuple *tuple, gchar **args) |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
488 { |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
489 return g_strdup(PACKAGE_NAME " " PACKAGE_VERSION); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
490 } |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
491 |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
492 /* processes a string containing instructions. does initialization phases |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
493 if not already done */ |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
494 gchar * |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
495 tuple_formatter_process_string(Tuple *tuple, const gchar *string) |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
496 { |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
497 static gboolean initialized = FALSE; |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
498 |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
499 if (initialized == FALSE) |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
500 { |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
501 tuple_formatter_register_expression("?", tuple_formatter_expression_exists); |
3286
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
502 tuple_formatter_register_expression("==", tuple_formatter_expression_match); |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
503 tuple_formatter_register_expression("!=", tuple_formatter_expression_nonmatch); |
3290
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
504 tuple_formatter_register_expression("(empty)?", tuple_formatter_expression_empty); |
3292
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
505 |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
506 tuple_formatter_register_function("audacious-version", tuple_formatter_function_version); |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
507 initialized = TRUE; |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
508 } |
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
509 |
3285
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
3284
diff
changeset
|
510 return tuple_formatter_process_construct(tuple, string); |
3283
6062ef95818b
Add first revision parser code. May or may not work, not hooked up, so I can't test it yet. ;)
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
511 } |
3349
01a241d35146
add tuple_formatter_make_title_string(). it is a wrapper function to tuple_formatter_process_construct() to make title string. it falls back to the file name if the formatted string is blank or unavailable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3339
diff
changeset
|
512 |
01a241d35146
add tuple_formatter_make_title_string(). it is a wrapper function to tuple_formatter_process_construct() to make title string. it falls back to the file name if the formatted string is blank or unavailable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3339
diff
changeset
|
513 /* wrapper function for making title string. it falls back to filename |
01a241d35146
add tuple_formatter_make_title_string(). it is a wrapper function to tuple_formatter_process_construct() to make title string. it falls back to the file name if the formatted string is blank or unavailable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3339
diff
changeset
|
514 * if process_string returns NULL or a blank string. */ |
01a241d35146
add tuple_formatter_make_title_string(). it is a wrapper function to tuple_formatter_process_construct() to make title string. it falls back to the file name if the formatted string is blank or unavailable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3339
diff
changeset
|
515 gchar * |
01a241d35146
add tuple_formatter_make_title_string(). it is a wrapper function to tuple_formatter_process_construct() to make title string. it falls back to the file name if the formatted string is blank or unavailable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3339
diff
changeset
|
516 tuple_formatter_make_title_string(Tuple *tuple, const gchar *string) |
01a241d35146
add tuple_formatter_make_title_string(). it is a wrapper function to tuple_formatter_process_construct() to make title string. it falls back to the file name if the formatted string is blank or unavailable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3339
diff
changeset
|
517 { |
01a241d35146
add tuple_formatter_make_title_string(). it is a wrapper function to tuple_formatter_process_construct() to make title string. it falls back to the file name if the formatted string is blank or unavailable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3339
diff
changeset
|
518 gchar *rv; |
01a241d35146
add tuple_formatter_make_title_string(). it is a wrapper function to tuple_formatter_process_construct() to make title string. it falls back to the file name if the formatted string is blank or unavailable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3339
diff
changeset
|
519 |
01a241d35146
add tuple_formatter_make_title_string(). it is a wrapper function to tuple_formatter_process_construct() to make title string. it falls back to the file name if the formatted string is blank or unavailable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3339
diff
changeset
|
520 g_return_val_if_fail(tuple != NULL, NULL); |
01a241d35146
add tuple_formatter_make_title_string(). it is a wrapper function to tuple_formatter_process_construct() to make title string. it falls back to the file name if the formatted string is blank or unavailable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3339
diff
changeset
|
521 |
01a241d35146
add tuple_formatter_make_title_string(). it is a wrapper function to tuple_formatter_process_construct() to make title string. it falls back to the file name if the formatted string is blank or unavailable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3339
diff
changeset
|
522 rv = tuple_formatter_process_construct(tuple, string); |
01a241d35146
add tuple_formatter_make_title_string(). it is a wrapper function to tuple_formatter_process_construct() to make title string. it falls back to the file name if the formatted string is blank or unavailable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3339
diff
changeset
|
523 |
01a241d35146
add tuple_formatter_make_title_string(). it is a wrapper function to tuple_formatter_process_construct() to make title string. it falls back to the file name if the formatted string is blank or unavailable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3339
diff
changeset
|
524 if(!rv || !strcmp(rv, "")) { |
01a241d35146
add tuple_formatter_make_title_string(). it is a wrapper function to tuple_formatter_process_construct() to make title string. it falls back to the file name if the formatted string is blank or unavailable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3339
diff
changeset
|
525 g_free(rv); |
01a241d35146
add tuple_formatter_make_title_string(). it is a wrapper function to tuple_formatter_process_construct() to make title string. it falls back to the file name if the formatted string is blank or unavailable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3339
diff
changeset
|
526 rv = g_strdup(tuple_get_string(tuple, "file-name")); |
01a241d35146
add tuple_formatter_make_title_string(). it is a wrapper function to tuple_formatter_process_construct() to make title string. it falls back to the file name if the formatted string is blank or unavailable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3339
diff
changeset
|
527 } |
01a241d35146
add tuple_formatter_make_title_string(). it is a wrapper function to tuple_formatter_process_construct() to make title string. it falls back to the file name if the formatted string is blank or unavailable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3339
diff
changeset
|
528 |
01a241d35146
add tuple_formatter_make_title_string(). it is a wrapper function to tuple_formatter_process_construct() to make title string. it falls back to the file name if the formatted string is blank or unavailable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3339
diff
changeset
|
529 return rv; |
01a241d35146
add tuple_formatter_make_title_string(). it is a wrapper function to tuple_formatter_process_construct() to make title string. it falls back to the file name if the formatted string is blank or unavailable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3339
diff
changeset
|
530 } |