/[gluid]/gluid.c
ViewVC logotype

Contents of /gluid.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations)
Fri Sep 25 18:47:59 2009 UTC (9 years, 11 months ago) by ben
File MIME type: text/plain
File size: 3101 byte(s)
first commit, version 0.1 working (basic)
1 /* gluid.c
2 *
3 * Copyright 2009 Benoit Rouits <brouits@free.fr>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 * MA 02110-1301, USA.
19 */
20
21 #include <stdlib.h>
22 #include <glib.h>
23 #include <gtk/gtk.h>
24 #include "callbacks.h"
25 #include "controller.h"
26 #include "menu.h"
27
28 int main(int argc, char** argv)
29 {
30 GtkStatusIcon* status_icon = NULL;
31 GtkMenu* right_menu = NULL;
32 const gchar* const * data_dirs;
33 gchar* icon_path = NULL;
34 AppData* app_data = NULL;
35 int i;
36
37 app_data = (AppData*) malloc (sizeof(AppData));
38 app_data->config_path = NULL;
39 app_data->right_menu = NULL;
40 app_data->status_icon = NULL;
41 app_data->pref_window = NULL;
42 app_data->settings = NULL;
43 app_data->synth = NULL;
44 app_data->adriver = NULL;
45 app_data->mdriver = NULL;
46 app_data->router = NULL;
47
48 /* set $HOME/.gluid as config file */
49 app_data->config_path = g_build_path ("/", g_get_home_dir(), ".gluid", NULL);
50 read_config(app_data);
51
52 gtk_init(&argc, &argv);
53
54 /* search for status icon */
55 data_dirs = g_get_system_data_dirs();
56 for (i = 0; data_dirs[i]; ++i) {
57 icon_path = g_strconcat (data_dirs[i],"/icons/gluid.png", NULL);
58 if (g_file_test (icon_path, G_FILE_TEST_EXISTS)) {
59 break;
60 }
61 g_free(icon_path);
62 icon_path = NULL;
63 }
64 if (!icon_path) {
65 g_error("no icon found");
66 return 1;
67 }
68
69 /* create right-click menu */
70 right_menu = menu_new();
71 app_data->right_menu = right_menu;
72
73 status_icon = gtk_status_icon_new();
74 app_data->status_icon = status_icon;
75 gtk_status_icon_set_from_file(status_icon, icon_path);
76 gtk_window_set_default_icon_from_file(icon_path, NULL);
77 g_free(icon_path);
78 gtk_status_icon_set_tooltip(status_icon, "Gluid");
79 gtk_status_icon_set_visible(status_icon, TRUE);
80
81 g_signal_connect(G_OBJECT(status_icon), "activate",
82 G_CALLBACK(status_icon_on_left_click), app_data);
83 g_signal_connect(G_OBJECT(status_icon), "popup-menu",
84 G_CALLBACK(status_icon_on_right_click), app_data);
85
86 /* right menu items callbacks */
87 menu_append_item(right_menu, "Start/Stop", G_CALLBACK(menu_item_on_startstop), app_data);
88 menu_append_item(right_menu, "Preferences", G_CALLBACK(menu_item_on_pref), app_data);
89 menu_append_item(right_menu, "About", G_CALLBACK(menu_item_on_about), app_data);
90 menu_append_item(right_menu, "Quit", G_CALLBACK(menu_item_on_quit), app_data);
91
92 gtk_main();
93 free (app_data);
94 return 0;
95 }

  ViewVC Help
Powered by ViewVC 1.1.26