Mercurial > audlegacy-plugins
annotate src/skins/plugin.c @ 2676:096aa996e4fa
clean some more stuff at skins_cleanup()
| author | Tomasz Mon <desowin@gmail.com> |
|---|---|
| date | Sun, 01 Jun 2008 16:28:51 +0200 |
| parents | 4beebb0e82f8 |
| children | e540e041b34b |
| rev | line source |
|---|---|
|
2572
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
1 /* |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
2 * Audacious - a cross-platform multimedia player |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
3 * Copyright (c) 2008 Tomasz Moń |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
4 * |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
5 * This program is free software; you can redistribute it and/or modify |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
6 * it under the terms of the GNU General Public License as published by |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
7 * the Free Software Foundation; under version 3 of the License. |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
8 * |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
9 * This program is distributed in the hope that it will be useful, |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
12 * GNU General Public License for more details. |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
13 * |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
14 * You should have received a copy of the GNU General Public License |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
15 * along with this program. If not, see <http://www.gnu.org/licenses>. |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
16 * |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
17 * The Audacious team does not consider modular code linking to |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
18 * Audacious or using our public API to be a derived work. |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
19 */ |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
20 |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
21 |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
22 #include "plugin.h" |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
23 #include "skins_cfg.h" |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
24 #include "ui_skin.h" |
| 2579 | 25 #include "ui_skinned_window.h" |
|
2602
7cd898f08f31
work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
2592
diff
changeset
|
26 #include "ui_manager.h" |
|
7cd898f08f31
work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
2592
diff
changeset
|
27 #include "icons-stock.h" |
|
2633
8e4af29f7e17
dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents:
2608
diff
changeset
|
28 #include "ui_main_evlisteners.h" |
|
8e4af29f7e17
dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents:
2608
diff
changeset
|
29 #include "ui_playlist_evlisteners.h" |
|
2572
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
30 #include <audacious/i18n.h> |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
31 #include <libintl.h> |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
32 |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
33 #define PACKAGE "audacious-plugins" |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
34 |
| 2675 | 35 gchar *skins_paths[SKINS_PATH_COUNT] = {}; |
| 36 | |
|
2572
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
37 GeneralPlugin skins_gp = |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
38 { |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
39 .description= "Audacious Skinned GUI", |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
40 .init = skins_init, |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
41 .about = skins_about, |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
42 .configure = skins_configure, |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
43 .cleanup = skins_cleanup |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
44 }; |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
45 |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
46 GeneralPlugin *skins_gplist[] = { &skins_gp, NULL }; |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
47 SIMPLE_GENERAL_PLUGIN(skins, skins_gplist); |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
48 GtkWidget *mainwin; |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
49 gboolean plugin_is_active = FALSE; |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
50 |
| 2675 | 51 static void skins_free_paths(void) { |
| 52 int i; | |
| 53 | |
|
2676
096aa996e4fa
clean some more stuff at skins_cleanup()
Tomasz Mon <desowin@gmail.com>
parents:
2675
diff
changeset
|
54 for (i = 0; i < SKINS_PATH_COUNT; i++) { |
| 2675 | 55 g_free(skins_paths[i]); |
|
2676
096aa996e4fa
clean some more stuff at skins_cleanup()
Tomasz Mon <desowin@gmail.com>
parents:
2675
diff
changeset
|
56 skins_paths[i] = NULL; |
| 2675 | 57 } |
| 58 } | |
| 59 | |
| 60 static void skins_init_paths() { | |
| 61 char *xdg_data_home; | |
| 62 char *xdg_cache_home; | |
| 63 | |
| 64 xdg_data_home = (getenv("XDG_DATA_HOME") == NULL | |
| 65 ? g_build_filename(g_get_home_dir(), ".local", "share", NULL) | |
| 66 : g_strdup(getenv("XDG_DATA_HOME"))); | |
| 67 xdg_cache_home = (getenv("XDG_CACHE_HOME") == NULL | |
| 68 ? g_build_filename(g_get_home_dir(), ".cache", NULL) | |
| 69 : g_strdup(getenv("XDG_CACHE_HOME"))); | |
| 70 | |
| 71 skins_paths[SKINS_PATH_USER_SKIN_DIR] = | |
| 72 g_build_filename(xdg_data_home, "audacious", "Skins", NULL); | |
| 73 skins_paths[SKINS_PATH_SKIN_THUMB_DIR] = | |
| 74 g_build_filename(xdg_cache_home, "audacious", "thumbs", NULL); | |
| 75 | |
| 76 g_free(xdg_data_home); | |
| 77 g_free(xdg_cache_home); | |
| 78 } | |
| 79 | |
|
2572
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
80 void skins_init(void) { |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
81 plugin_is_active = TRUE; |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
82 g_log_set_handler(NULL, G_LOG_LEVEL_WARNING, g_log_default_handler, NULL); |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
83 |
| 2675 | 84 skins_init_paths(); |
|
2582
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2579
diff
changeset
|
85 skins_cfg_load(); |
|
2572
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
86 |
|
2602
7cd898f08f31
work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
2592
diff
changeset
|
87 register_aud_stock_icons(); |
|
7cd898f08f31
work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
2592
diff
changeset
|
88 ui_manager_init(); |
|
7cd898f08f31
work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
2592
diff
changeset
|
89 ui_manager_create_menus(); |
|
7cd898f08f31
work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
2592
diff
changeset
|
90 mainwin_setup_menus(); |
|
7cd898f08f31
work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
2592
diff
changeset
|
91 |
|
2592
8f5999909416
add ui_main - with huge amount of #if 0 to sort out later
Tomasz Mon <desowin@gmail.com>
parents:
2582
diff
changeset
|
92 init_skins(config.skin); |
|
2572
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
93 |
|
2635
b990e7eb0c25
save config on plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents:
2633
diff
changeset
|
94 if (config.player_visible) mainwin_real_show(); |
|
b990e7eb0c25
save config on plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents:
2633
diff
changeset
|
95 if (config.equalizer_visible) equalizerwin_show(TRUE); |
|
b990e7eb0c25
save config on plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents:
2633
diff
changeset
|
96 if (config.playlist_visible) playlistwin_show(); |
|
2572
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
97 |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
98 return; |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
99 } |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
100 |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
101 void skins_cleanup(void) { |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
102 if (plugin_is_active == TRUE) { |
|
2635
b990e7eb0c25
save config on plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents:
2633
diff
changeset
|
103 skins_cfg_save(); |
| 2675 | 104 skins_free_paths(); |
|
2633
8e4af29f7e17
dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents:
2608
diff
changeset
|
105 ui_main_evlistener_dissociate(); |
|
8e4af29f7e17
dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents:
2608
diff
changeset
|
106 ui_playlist_evlistener_dissociate(); |
|
2582
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2579
diff
changeset
|
107 skins_cfg_free(); |
|
2572
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
108 gtk_widget_destroy(mainwin); |
|
2608
857910a58188
don't quit audacious if skins plugin gets unloaded
Tomasz Mon <desowin@gmail.com>
parents:
2602
diff
changeset
|
109 gtk_widget_destroy(equalizerwin); |
|
2676
096aa996e4fa
clean some more stuff at skins_cleanup()
Tomasz Mon <desowin@gmail.com>
parents:
2675
diff
changeset
|
110 gtk_widget_destroy(playlistwin); |
|
096aa996e4fa
clean some more stuff at skins_cleanup()
Tomasz Mon <desowin@gmail.com>
parents:
2675
diff
changeset
|
111 ui_manager_destroy(); |
|
2608
857910a58188
don't quit audacious if skins plugin gets unloaded
Tomasz Mon <desowin@gmail.com>
parents:
2602
diff
changeset
|
112 skin_destroy(aud_active_skin); |
|
2572
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
113 aud_active_skin = NULL; |
|
2608
857910a58188
don't quit audacious if skins plugin gets unloaded
Tomasz Mon <desowin@gmail.com>
parents:
2602
diff
changeset
|
114 mainwin = NULL; |
|
857910a58188
don't quit audacious if skins plugin gets unloaded
Tomasz Mon <desowin@gmail.com>
parents:
2602
diff
changeset
|
115 equalizerwin = NULL; |
| 2637 | 116 playlistwin = NULL; |
| 117 mainwin_info = NULL; | |
|
2572
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
118 plugin_is_active = FALSE; |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
119 } |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
120 |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
121 return; |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
122 } |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
123 |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
124 |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
125 void skins_configure(void) { |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
126 return; |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
127 } |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
128 |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
129 void skins_about(void) { |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
130 static GtkWidget* about_window = NULL; |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
131 |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
132 if (about_window) { |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
133 gtk_window_present(GTK_WINDOW(about_window)); |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
134 return; |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
135 } |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
136 |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
137 about_window = audacious_info_dialog(_("About Skinned GUI"), |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
138 _("Copyright (c) 2008, by Tomasz Moń <desowin@gmail.com>\n\n"), |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
139 _("OK"), FALSE, NULL, NULL); |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
140 |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
141 g_signal_connect(G_OBJECT(about_window), "destroy", G_CALLBACK(gtk_widget_destroyed), &about_window); |
|
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
142 } |
