aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--addressbook/ChangeLog7
-rw-r--r--addressbook/gui/widgets/addresstypes.xml67
-rw-r--r--calendar/ChangeLog9
-rw-r--r--calendar/gui/caltypes.xml70
-rw-r--r--calendar/gui/memotypes.xml70
-rw-r--r--calendar/gui/tasktypes.xml71
-rw-r--r--e-util/ChangeLog8
-rw-r--r--e-util/e-util.c22
-rw-r--r--e-util/e-util.h2
-rw-r--r--filter/ChangeLog12
-rw-r--r--filter/filter-label.c2
-rw-r--r--filter/filter-option.c102
-rw-r--r--filter/filter-option.h5
13 files changed, 167 insertions, 280 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 0465a19384..47b128090d 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,10 @@
+2008-12-05 Milan Crha <mcrha@redhat.com>
+
+ ** Part of fix for bug #332629
+
+ * gui/widgets/addresstypes.xml:
+ Use dynamically created list of categories in the option's widget.
+
2008-12-04 Milan Crha <mcrha@redhat.com>
** Fix for bug #263268
diff --git a/addressbook/gui/widgets/addresstypes.xml b/addressbook/gui/widgets/addresstypes.xml
index 813bf1c0ac..c93f9cac19 100644
--- a/addressbook/gui/widgets/addresstypes.xml
+++ b/addressbook/gui/widgets/addresstypes.xml
@@ -74,72 +74,7 @@
</option>
</input>
<input type="optionlist" name="category">
- <option value="Anniversary">
- <title>Anniversary</title>
- </option>
- <option value="Holiday">
- <title>Holiday</title>
- </option>
- <option value="Ideas">
- <title>Ideas</title>
- </option>
- <option value="Status">
- <title>Status</title>
- </option>
- <option value="Holiday Cards">
- <title>Holiday Cards</title>
- </option>
- <option value="Hot Contacts">
- <title>Hot Contacts</title>
- </option>
- <option value="International">
- <title>International</title>
- </option>
- <option value="Birthday">
- <title>Birthday</title>
- </option>
- <option value="VIP">
- <title>VIP</title>
- </option>
- <option value="Gifts">
- <title>Gifts</title>
- </option>
- <option value="Waiting">
- <title>Waiting</title>
- </option>
- <option value="Key Customer">
- <title>Key Customer</title>
- </option>
- <option value="Time &amp; Expenses">
- <title>Time &amp; Expenses </title>
- </option>
- <option value="Miscellaneous">
- <title>Miscellaneous</title>
- </option>
- <option value="Business">
- <title>Business</title>
- </option>
- <option value="Personal">
- <title>Personal</title>
- </option>
- <option value="Suppliers">
- <title>Suppliers</title>
- </option>
- <option value="Goals/Objectives">
- <title>Goals/Objectives</title>
- </option>
- <option value="Strategies">
- <title>Strategies</title>
- </option>
- <option value="Competition">
- <title>Competition</title>
- </option>
- <option value="Favourites">
- <title>Favourites</title>
- </option>
- <option value="Phone Calls">
- <title>Phone Calls</title>
- </option>
+ <dynamic func="e_util_get_category_filter_options"/>
</input>
</part>
<part name="sexp">
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 854f8649bd..58c6860eaf 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,12 @@
+2008-12-05 Milan Crha <mcrha@redhat.com>
+
+ ** Part of fix for bug #332629
+
+ * gui/caltypes.xml:
+ * gui/memotypes.xml:
+ * gui/tasktypes.xml:
+ Use dynamically created list of categories in the option's widget.
+
2008-12-03 Milan Crha <mcrha@redhat.com>
** Part of fix for bug #352287
diff --git a/calendar/gui/caltypes.xml b/calendar/gui/caltypes.xml
index 3f93daa8ee..c1997a4fb0 100644
--- a/calendar/gui/caltypes.xml
+++ b/calendar/gui/caltypes.xml
@@ -129,75 +129,7 @@
</option>
</input>
<input type="optionlist" name="category">
- <option value="Anniversary">
- <_title>Anniversary</_title>
- </option>
- <option value="Holiday">
- <_title>Holiday</_title>
- </option>
- <option value="Ideas">
- <_title>Ideas</_title>
- </option>
- <option value="Status">
- <_title>Status</_title>
- </option>
- <option value="Holiday Cards">
- <_title>Holiday Cards</_title>
- </option>
- <option value="Hot Contacts">
- <_title>Hot Contacts</_title>
- </option>
- <option value="International">
- <_title>International</_title>
- </option>
- <option value="Next 7 days">
- <_title>Next 7 days</_title>
- </option>
- <option value="Birthday">
- <_title>Birthday</_title>
- </option>
- <option value="VIP">
- <_title>VIP</_title>
- </option>
- <option value="Gifts">
- <_title>Gifts</_title>
- </option>
- <option value="Waiting">
- <_title>Waiting</_title>
- </option>
- <option value="Key Customer">
- <_title>Key Customer</_title>
- </option>
- <option value="Time &amp; Expenses">
- <_title>Time &amp; Expenses </_title>
- </option>
- <option value="Miscellaneous">
- <_title>Miscellaneous</_title>
- </option>
- <option value="Business">
- <_title>Business</_title>
- </option>
- <option value="Personal">
- <_title>Personal</_title>
- </option>
- <option value="Suppliers">
- <_title>Suppliers</_title>
- </option>
- <option value="Goals/Objectives">
- <_title>Goals/Objectives</_title>
- </option>
- <option value="Strategies">
- <_title>Strategies</_title>
- </option>
- <option value="Competition">
- <_title>Competition</_title>
- </option>
- <option value="Favourites">
- <_title>Favourites</_title>
- </option>
- <option value="Phone Calls">
- <_title>Phone Calls</_title>
- </option>
+ <dynamic func="e_util_get_category_filter_options"/>
</input>
</part>
diff --git a/calendar/gui/memotypes.xml b/calendar/gui/memotypes.xml
index 3b9a560a96..1872461ab4 100644
--- a/calendar/gui/memotypes.xml
+++ b/calendar/gui/memotypes.xml
@@ -99,75 +99,7 @@
</option>
</input>
<input type="optionlist" name="category">
- <option value="Anniversary">
- <_title>Anniversary</_title>
- </option>
- <option value="Holiday">
- <_title>Holiday</_title>
- </option>
- <option value="Ideas">
- <_title>Ideas</_title>
- </option>
- <option value="Status">
- <_title>Status</_title>
- </option>
- <option value="Holiday Cards">
- <_title>Holiday Cards</_title>
- </option>
- <option value="Hot Contacts">
- <_title>Hot Contacts</_title>
- </option>
- <option value="International">
- <_title>International</_title>
- </option>
- <option value="Next 7 days">
- <_title>Next 7 Days</_title>
- </option>
- <option value="Birthday">
- <_title>Birthday</_title>
- </option>
- <option value="VIP">
- <_title>VIP</_title>
- </option>
- <option value="Gifts">
- <_title>Gifts</_title>
- </option>
- <option value="Waiting">
- <_title>Waiting</_title>
- </option>
- <option value="Key Customer">
- <_title>Key Customer</_title>
- </option>
- <option value="Time &amp; Expenses">
- <_title>Time &amp; Expenses</_title>
- </option>
- <option value="Miscellaneous">
- <_title>Miscellaneous</_title>
- </option>
- <option value="Business">
- <_title>Business</_title>
- </option>
- <option value="Personal">
- <_title>Personal</_title>
- </option>
- <option value="Suppliers">
- <_title>Suppliers</_title>
- </option>
- <option value="Goals/Objectives">
- <_title>Goals/Objectives</_title>
- </option>
- <option value="Strategies">
- <_title>Strategies</_title>
- </option>
- <option value="Competition">
- <_title>Competition</_title>
- </option>
- <option value="Favourites">
- <_title>Favourites</_title>
- </option>
- <option value="Phone Calls">
- <_title>Phone Calls</_title>
- </option>
+ <dynamic func="e_util_get_category_filter_options"/>
</input>
</part>
diff --git a/calendar/gui/tasktypes.xml b/calendar/gui/tasktypes.xml
index 10515ad5bf..cd9876bd29 100644
--- a/calendar/gui/tasktypes.xml
+++ b/calendar/gui/tasktypes.xml
@@ -165,76 +165,7 @@
</option>
</input>
<input type="optionlist" name="category">
- <option value="Anniversary">
- <_title>Anniversary</_title>
- </option>
- <option value="Holiday">
- <_title>Holiday</_title>
- </option>
- <option value="Ideas">
- <_title>Ideas</_title>ke
- </option>
- <option value="Status">
- <_title>Status</_title>
- </option>
- <option value="Holiday Cards">
- <_title>Holiday Cards</_title>
- </option>
- <option value="Hot Contacts">
- <_title>Hot Contacts</_title>
- </option>
- <option value="International">
- <_title>International</_title>
- </option>
- <option value="Next 7 days">
- <_title>Next 7 days</_title>
- </option>
- <option value="Birthday">
- <_title>Birthday</_title>
- </option>
- <option value="VIP">
- <_title>VIP</_title>
- </option>
- <option value="Gifts">
- <_title>Gifts</_title>
- </option>
- <option value="Waiting">
- <_title>Waiting</_title>
- </option>
- <option value="Key Customer">
- <_title>Key Customer</_title>
- </option>
- <option value="Time &amp; Expenses">
- <_title>Time &amp; Expenses </_title>
- </option>
- <option value="Miscellaneous">
- <_title>Miscellaneous</_title>
- </option>
- <option value="Business">
- <_title>Business</_title>
- </option>
- <option value="Personal">
- ke
- <_title>Personal</_title>
- </option>
- <option value="Suppliers">
- <_title>Suppliers</_title>
- </option>
- <option value="Goals/Objectives">
- <_title>Goals/Objectives</_title>
- </option>
- <option value="Strategies">
- <_title>Strategies</_title>
- </option>
- <option value="Competition">
- <_title>Competition</_title>
- </option>
- <option value="Favourites">
- <_title>Favourites</_title>
- </option>
- <option value="Phone Calls">
- <_title>Phone Calls</_title>
- </option>
+ <dynamic func="e_util_get_category_filter_options"/>
</input>
</part>
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index d9701d49b3..18ab054e84 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,11 @@
+2008-12-05 Milan Crha <mcrha@redhat.com>
+
+ ** Part of fix for bug #332629
+
+ * e-util.h: (e_util_get_category_filter_options):
+ * e-util.c: (e_util_get_category_filter_options):
+ New helper function to be used in FilterOption.
+
2008-11-27 Milan Crha <mcrha@redhat.com>
** Fix for bug #332729
diff --git a/e-util/e-util.c b/e-util/e-util.c
index f05c9d907a..215a494df9 100644
--- a/e-util/e-util.c
+++ b/e-util/e-util.c
@@ -46,6 +46,8 @@
#endif
#include <libedataserver/e-data-server-util.h>
+#include <libedataserver/e-categories.h>
+#include "filter/filter-option.h"
#include "e-util.h"
#include "e-util-private.h"
@@ -1224,3 +1226,23 @@ e_util_read_file (const char *filename, gboolean filename_is_uri, char **buffer,
return res;
}
+GSList *
+e_util_get_category_filter_options (void)
+{
+ GSList *res = NULL;
+ GList *clist, *l;
+
+ clist = e_categories_get_list ();
+ for (l = clist; l; l = l->next) {
+ const char *cname = l->data;
+ struct _filter_option *fo = g_new0 (struct _filter_option, 1);
+
+ fo->title = g_strdup (cname);
+ fo->value = g_strdup (cname);
+ res = g_slist_prepend (res, fo);
+ }
+
+ g_list_free (clist);
+
+ return g_slist_reverse (res);
+}
diff --git a/e-util/e-util.h b/e-util/e-util.h
index b6ff33429d..a27602848c 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -125,6 +125,8 @@ gboolean e_util_read_file (const gchar *filename,
gsize *read,
GError **error);
+GSList *e_util_get_category_filter_options (void);
+
G_END_DECLS
#endif /* _E_UTIL_H_ */
diff --git a/filter/ChangeLog b/filter/ChangeLog
index 3534320543..740edb5ecd 100644
--- a/filter/ChangeLog
+++ b/filter/ChangeLog
@@ -1,3 +1,15 @@
+2008-12-05 Milan Crha <mcrha@redhat.com>
+
+ ** Fix for bug #332629
+
+ * filter-option.h: (struct _filter_option),
+ (struct _FilterOption), (filter_option_add):
+ * filter-option.c: (filter_option_init), (filter_option_finalise),
+ (filter_option_add), (xml_create), (get_widget), (clone):
+ Be able to define optionlist with dynamically created list of options.
+
+ * filter-label.c: (fill_options): Adapt.
+
2008-10-17 Matthew Barnes <mbarnes@redhat.com>
** Fix for bug #503898
diff --git a/filter/filter-label.c b/filter/filter-label.c
index 1d76300339..006d4822e8 100644
--- a/filter/filter-label.c
+++ b/filter/filter-label.c
@@ -192,7 +192,7 @@ fill_options (FilterOption *fo)
if (tag && strncmp (tag, "$Label", 6) == 0)
tag += 6;
- filter_option_add (fo, tag, title, NULL);
+ filter_option_add (fo, tag, title, NULL, FALSE);
g_free (title);
}
diff --git a/filter/filter-option.c b/filter/filter-option.c
index 1685fe06ce..e0827d4475 100644
--- a/filter/filter-option.c
+++ b/filter/filter-option.c
@@ -29,6 +29,7 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
+#include <dlfcn.h>
#include "filter-option.h"
#include "filter-part.h"
@@ -102,6 +103,7 @@ static void
filter_option_init (FilterOption *fo)
{
fo->type = "option";
+ fo->dynamic_func = NULL;
}
static void
@@ -120,6 +122,7 @@ filter_option_finalise (GObject *obj)
g_list_foreach (fo->options, (GFunc)free_option, NULL);
g_list_free (fo->options);
+ g_free (fo->dynamic_func);
G_OBJECT_CLASS (parent_class)->finalize (obj);
}
@@ -164,7 +167,7 @@ filter_option_set_current (FilterOption *option, const char *name)
/* used by implementers to add additional options */
struct _filter_option *
-filter_option_add(FilterOption *fo, const char *value, const char *title, const char *code)
+filter_option_add(FilterOption *fo, const char *value, const char *title, const char *code, gboolean is_dynamic)
{
struct _filter_option *op;
@@ -175,6 +178,7 @@ filter_option_add(FilterOption *fo, const char *value, const char *title, const
op->title = g_strdup(title);
op->value = g_strdup(value);
op->code = g_strdup(code);
+ op->is_dynamic = is_dynamic;
fo->options = g_list_append(fo->options, op);
if (fo->current == NULL)
@@ -253,10 +257,34 @@ xml_create (FilterElement *fe, xmlNodePtr node)
work = work->next;
}
- filter_option_add (fo, value, title, code);
+ filter_option_add (fo, value, title, code, FALSE);
xmlFree (value);
g_free (title);
g_free (code);
+ } else if (g_str_equal ((char *)n->name, "dynamic")) {
+ if (fo->dynamic_func) {
+ g_warning ("Only one 'dynamic' node is acceptable in the optionlist '%s'", fe->name);
+ } else {
+ /* Expecting only one <dynamic func="cb" /> in the option list,
+ The 'cb' should be of this prototype:
+ GSList *cb (void);
+ returning GSList of struct _filter_option, all newly allocated, because it'll
+ be freed with g_free and g_slist_free. 'is_dynamic' member is ignored here.
+ */
+ xmlChar *fn;
+
+ fn = xmlGetProp (n, (const unsigned char *)"func");
+ if (fn && *fn) {
+ fo->dynamic_func = g_strdup ((const char *)fn);
+
+ /* to remember where to place them */
+ filter_option_add (fo, "fake_dynamic", "fake_dynamic", NULL, TRUE);
+ } else {
+ g_warning ("Missing 'func' attribute within '%s' node in optionlist '%s'", n->name, fe->name);
+ }
+
+ xmlFree (fn);
+ }
} else if (n->type == XML_ELEMENT_NODE) {
g_warning ("Unknown xml node within optionlist: %s\n", n->name);
}
@@ -315,11 +343,75 @@ get_widget (FilterElement *fe)
GtkWidget *omenu;
GtkWidget *item;
GtkWidget *first = NULL;
- GList *l = fo->options;
+ GList *l;
struct _filter_option *op;
int index = 0, current = 0;
+ if (fo->dynamic_func) {
+ /* it is dynamically filled, thus remove all dynamics and put there the fresh ones */
+ GList *old_ops;
+ struct _filter_option *old_cur;
+ void *module;
+ GSList *(*get_func)(void);
+
+ old_ops = fo->options;
+ old_cur = fo->current;
+ l = old_ops;
+
+ /* start with an empty list */
+ fo->current = NULL;
+ fo->options = NULL;
+
+ for (l = fo->options; l; l = l->next) {
+ op = l->data;
+
+ if (op->is_dynamic) {
+ break;
+ } else {
+ filter_option_add (fo, op->value, op->title, op->code, FALSE);
+ }
+ }
+
+ module = dlopen (NULL, RTLD_LAZY);
+
+ get_func = dlsym (module, fo->dynamic_func);
+ if (get_func) {
+ GSList *items, *i;
+
+ items = get_func ();
+ for (i = items; i; i = i->next) {
+ op = i->data;
+
+ if (op) {
+ filter_option_add (fo, op->value, op->title, op->code, TRUE);
+ free_option (op, NULL);
+ }
+ }
+
+ g_slist_free (items);
+ } else
+ g_warning ("optionlist dynamic fill function '%s' not found", fo->dynamic_func);
+
+ dlclose (module);
+
+ /* maybe some static left after those dynamic, add them too */
+ for (; l; l = l->next) {
+ op = l->data;
+
+ if (!op->is_dynamic)
+ filter_option_add (fo, op->value, op->title, op->code, FALSE);
+ }
+
+ if (old_cur)
+ filter_option_set_current (fo, old_cur->value);
+
+ /* free old list */
+ g_list_foreach (old_ops, (GFunc)free_option, NULL);
+ g_list_free (old_ops);
+ }
+
menu = gtk_menu_new ();
+ l = fo->options;
while (l) {
op = l->data;
item = gtk_menu_item_new_with_label (_(op->title));
@@ -382,12 +474,14 @@ clone (FilterElement *fe)
l = fo->options;
while (l) {
op = l->data;
- newop = filter_option_add (new, op->value, op->title, op->code);
+ newop = filter_option_add (new, op->value, op->title, op->code, op->is_dynamic);
if (fo->current == op)
new->current = newop;
l = l->next;
}
+ new->dynamic_func = g_strdup (fo->dynamic_func);
+
d(printf ("cloning option code %p, current = %p\n", new, new->current));
return (FilterElement *) new;
diff --git a/filter/filter-option.h b/filter/filter-option.h
index 8cc6c052d4..6cf56645b8 100644
--- a/filter/filter-option.h
+++ b/filter/filter-option.h
@@ -40,6 +40,8 @@ struct _filter_option {
char *title; /* button title */
char *value; /* value, if it has one */
char *code; /* used to string code segments together */
+
+ gboolean is_dynamic; /* whether is the option dynamic, FALSE if static */
};
struct _FilterOption {
@@ -49,6 +51,7 @@ struct _FilterOption {
GList *options;
struct _filter_option *current;
+ char *dynamic_func; /* name of the dynamic fill func, called in get_widget */
};
struct _FilterOptionClass {
@@ -66,7 +69,7 @@ FilterOption *filter_option_new (void);
void filter_option_set_current (FilterOption *option, const char *name);
const char *filter_option_get_current (FilterOption *option);
-struct _filter_option *filter_option_add (FilterOption *fo, const char *name, const char *title, const char *code);
+struct _filter_option *filter_option_add (FilterOption *fo, const char *name, const char *title, const char *code, gboolean is_dynamic);
void filter_option_remove_all (FilterOption *fo);
#endif /* ! _FILTER_OPTION_H */