Try something2
[gmpc.git] / src / plugin.h
blob2182170e7755a9920dabb713e4ae4a64b6cf306e
1 /* Gnome Music Player Client (GMPC)
2 * Copyright (C) 2004-2011 Qball Cow <qball@gmpclient.org>
3 * Project homepage: http://gmpclient.org/
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.
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.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include <gtk/gtk.h>
21 #include <libmpd/libmpd.h>
22 #include "metadata.h"
23 #include "config1.h"
24 #include "gmpc-extras.h"
25 #include "gmpc-profiles.h"
26 #include "gmpc-mpddata-treeview.h"
28 //#include "gmpc-paned-size-group.h"
30 #ifndef __PLUGIN_H__
31 #define __PLUGIN_H__
33 #define PLUGIN_ID_MARK 1024
34 #define PLUGIN_ID_INTERNALL 2048
35 /* Usefull signal objects. */
36 extern config_obj *config;
37 extern MpdObj *connection;
38 extern GmpcProfiles *gmpc_profiles;
39 extern GmpcConnection *gmpcconn;
42 typedef struct _gmpcPluginParent gmpcPluginParent;
43 /* Plugin Type's */
44 /* This is a bitmask.*/
45 typedef enum {
46 GMPC_PLUGIN_DUMMY = 1,
47 GMPC_PLUGIN_PL_BROWSER = 2,
48 GMPC_PLUGIN_NO_GUI = 4,
49 GMPC_INTERNALL = 8,
50 GMPC_DEPRECATED = 16,
51 GMPC_PLUGIN_META_DATA = 32,
52 /* Make compiler happy about GMPC_PLUGIN_PL_BROWSER|GMPC_PLUGIN_METADATA */
53 GMPC_BROWSER_META = 34
54 } PluginType;
56 /* the gtk_tree_store row's */
57 typedef enum
59 PL3_CAT_TYPE, /** Plugin id */
60 PL3_CAT_TITLE, /** title that is showed */
61 PL3_CAT_INT_ID, /* id */
62 PL3_CAT_ICON_ID, /* icon id */
63 PL3_CAT_ORDER, /* int for sorting the list */
64 PL3_CAT_BOLD,
65 PL3_CAT_NROWS
66 } pl3_cat_store;
68 typedef enum
70 PL3_CAT_BROWSER_TOP = 0,
71 PL3_CAT_BROWSER_LIBRARY = 1000,
72 PL3_CAT_BROWSER_ONLINE_MEDIA = 2000,
73 PL3_CAT_BROWSER_MISC = 3000
74 } Pl3CatBrowserType;
75 /* structures */
76 /** gmpcPrefPlugin: need to be instant apply.
77 * Plugin is expected to fill the container with it preferences widgets. (gtk_container_add)
78 * if destroy is called, it needs to detacht it from the container (gtk_container_remove)
80 typedef struct {
81 void (*construct)(GtkWidget *container);
82 void (*destroy)(GtkWidget *container);
83 /* Padding */
84 void (*padding1) (void);
85 void (*padding2) (void);
86 void (*padding3) (void);
87 } gmpcPrefPlugin;
89 /** gmpcPlBrowserPlugin, functions needed for intergration with the playlist browser
91 typedef struct {
92 /**
93 * Adding to the left side tree */
94 void (*add) (GtkWidget *cat_tree);
95 /**
96 * If selected, you need to fill the right screen */
97 void (*selected) (GtkWidget *container);
98 /**
99 * if unselected, you need to remove youself from the container
101 void (*unselected) (GtkWidget *container);
102 int (*cat_right_mouse_menu) (GtkWidget *menu, int type, GtkWidget *tree,GdkEventButton *event);
103 void (*cat_key_press) (GtkWidget *tree, GdkEventKey *event, int selected_type) G_GNUC_DEPRECATED;
104 /****** GO MENU ********/
105 int (*add_go_menu) (GtkWidget *menu);
106 /****** Key presses (in the whole window) **/
107 int (*key_press_event) (GtkWidget *mw, GdkEventKey *event, int type);
108 /** Song list right mouse menu intergration.
109 * This is only called (And allowed to be called) if the treeview is a GmpcMpdDataTreeview with songs
111 int (*song_list_option_menu) (GmpcMpdDataTreeview *tree, GtkMenu *menu);
112 /* Padding */
113 MpdData * (*integrate_search) (const int search_field,const gchar *search_query,GError **error);
114 gboolean (*integrate_search_field_supported) (const int search_field);
115 void (*padding3) (void);
116 } gmpcPlBrowserPlugin;
119 * Metadata fetching plugin.
120 * All fields required
123 typedef struct {
124 /* Set and get priority */
125 int (*get_priority) (void);
126 void (*set_priority) (int priority);
127 int (*get_image) (mpd_Song *song, MetaDataType type, char **path) G_GNUC_DEPRECATED;
129 /* Padding */
130 void (*get_uris) (mpd_Song *song, MetaDataType type, void (*callback)(GList *uris, gpointer data), gpointer data) G_GNUC_DEPRECATED;
131 /* New api, return linked list of MetaData Objects (see metadata.h) */
132 void (*get_metadata) (mpd_Song *song, MetaDataType, void (*callback)(GList *metadata, gpointer data), gpointer data);
133 void (*padding3) (void);
134 } gmpcMetaDataPlugin;
136 /* Unique number */
137 /* 16 == 0.14 release */
138 /* 17 == 0.15.5 release */
139 /* 18 == 16 december */
140 /* 19 == 0.16* 24 december */
141 /* 20 == 0.16.5 release */
142 /* 21 == 0.17.0 release -> adding padding so abi wont break next time */
143 #define PLUGIN_API_VERSION 21
145 /* sturcture */
146 typedef struct {
147 /* Name of the plugin */
148 const char *name;
149 /* Version number */
150 const int version[3];
151 /* Type of Plugin */
152 PluginType plugin_type;
153 /* unique plugin id */
154 /* do not fill in, is done by gmpc */
155 int id;
157 /* path where the plugin is (only directory) can be used to get location of f.e. glade/images
158 * Don't use this anymore use: gmpc_get.*_path */
159 /* Do not fill in, done by gmpc */
160 char *path;
161 /* function gets called on startup */
162 void (*init)(void);
163 /* Plugin should destroy all it's widgets and free all allocated space */
164 void (*destroy)(void);
165 /* Browser Plugins */
166 gmpcPlBrowserPlugin *browser;
167 /* plugin with one signal for changes on Mpd */
168 StatusChangedCallback mpd_status_changed;
169 /* (dis)connect signal */
170 ConnectionChangedCallback mpd_connection_changed;
171 /* structure to let the plugin intergrate it's preferences */
172 gmpcPrefPlugin *pref;
173 /** Meta data */
174 gmpcMetaDataPlugin *metadata;
176 /** Plugin control functions
178 int (*get_enabled)(void);
179 void (*set_enabled)(int enable);
180 /* Function that is called when the plugin is going to be destroyed,
181 * This is the place if you want to save settings
183 void (*save_yourself)(void);
185 /* Padding */
186 gint (*tool_menu_integration) (GtkMenu *menu);
187 const gchar* (*get_translation_domain) (void);
188 void (*padding3) (void);
189 } gmpcPlugin;
193 * Allows the plugin to access the EasyCommand
195 extern GmpcEasyCommand *gmpc_easy_command;
198 * Playlist function
202 * Get the treeview and tree_store of the category list on the left.
204 GtkListStore * playlist3_get_category_tree_store(void);
205 GtkTreeView * playlist3_get_category_tree_view(void);
208 * Get this GtkWindow of the playlist.
209 * Use this to set parent and so
211 GtkWidget * playlist3_get_window(void);
213 * indicates if the window is hidden to tray
215 gboolean playlist3_window_is_hidden(void);
217 /** plugin functions */
218 gmpcPluginParent * plugin_get_from_id(int id);
222 * Helper functions to get path to gmpc directory and metadata directory
225 char * gmpc_get_full_glade_path(const char *filename);
226 gchar * gmpc_get_covers_path(const gchar *filename);
227 gchar * gmpc_get_user_path(const gchar *filename);
228 gchar * gmpc_get_cache_directory(const gchar *filename);
229 void playlist3_insert_browser(GtkTreeIter *iter, gint position);
232 void pl3_option_menu_activate(void);
233 /* Tell mpd to reload the go menu */
234 void pl3_update_go_menu(void);
237 /* Used by plugins themself */
238 gchar * gmpc_plugin_get_data_path (gmpcPlugin *plug);
241 * Update parts of the gui
243 void pl3_tool_menu_update(void);
246 /***/
248 const char *connection_get_music_directory(void);
249 /* glue */
251 void info2_fill_song_view(mpd_Song *song);
252 void info2_activate(void);
254 void info2_fill_artist_view(const gchar *artist);
255 void info2_fill_album_view(const gchar *artist,const gchar *album);
257 extern GObject *paned_size_group;
259 /** Main window */
263 * show the main window
265 void create_playlist3(void);
267 * Get the state of the sidebar
269 GmpcPluginSidebarState playlist3_get_sidebar_state(void);
272 * hide the main window
274 int pl3_hide(void);
275 #endif