Initial commit
[resorg.git] / main.c
blob1279f61e976440d6f88e935c9aa9287c4a83f977
1 /*
2 * This file is part of Resources Organizer.
4 * Copyright (C) 2014 Nikita Zlobin <nick87720z@gmail.com>
6 * Resource Organizer is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * Resource Organizer is distributed in the hope that it will be
12 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Resource Organizer. If not, see
18 * <http://www.gnu.org/licenses/>.
21 #define _GNU_SOURCE
23 #include "ladspa/search.h"
24 #include "dssi/search.h"
25 #include "lv2/search.h"
27 #include <resource.h>
28 #include <misc.h>
29 #include "ui.h"
31 #include <gtk/gtk.h>
32 #include <glib.h>
34 void gErrorReport (GError ** err)
36 fprintf (stderr, "gtkbuilder: %s\n", (*err)->message);
37 g_clear_error (err);
40 static inline
41 void escape_text (char ** t)
43 char * old = *t;
44 *t = g_markup_escape_text (*t, -1);
45 free (old);
48 void resourceAdd (Resource * r)
50 GtkTreeIter i, *prev_i = NULL;
51 gtk_list_store_insert_after (list, & i, prev_i);
52 gtk_list_store_set (list, & i,
53 COL_NAME, r->name,
54 COL_TYPE_NAME, r->type->name,
55 COL_AUTHOR, r->author,
56 COL_FILE, r->file,
57 COL_URL, r->url,
58 -1);
59 char * tip = NULL;
60 if (asprintf (& tip, "%s\n"
61 "%s\n"
62 "%s\n"
63 "%s",
64 r->name,
65 r->file,
66 r->author,
67 r->type->name) == -1)
69 fprintf (stderr, "ERROR: Failed to asprintf() tooltip text\n");
70 if (tip) free (tip);
71 } else {
72 escape_text (& tip);
73 gtk_list_store_set (list, & i, COL_TIP, tip, -1);
74 free (tip);
78 static inline
79 void setResourceHandler (ResourceHandlerFunc cb_func)
81 ladspaResourceHandler (cb_func);
82 dssiResourceHandler (cb_func);
83 lv2ResourceHandler (cb_func);
86 int main (int argc, char ** argv)
88 if (ui_init (argc, argv) != 0) return 0;
90 setResourceHandler (resourceAdd);
91 ladspaPathIterate ();
92 dssiPathIterate ();
93 lv2PluginsList ();
95 g_object_unref (G_OBJECT (builder));
96 gtk_widget_show_all (win);
98 gtk_main ();
99 return 0;