Re-add rating.
[gmpc.git] / src / plugin.h
blob5d4ad7f6b0d60e2eb31ddd043039a26826d1fe69
1 /* Gnome Music Player Client (GMPC)
2 * Copyright (C) 2004-2012 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"
26 //#include "gmpc-paned-size-group.h"
28 #ifndef __PLUGIN_H__
29 #define __PLUGIN_H__
31 #define PLUGIN_ID_MARK 1024
32 #define PLUGIN_ID_INTERNALL 2048
33 /* Usefull signal objects. */
34 extern config_obj *config;
35 extern MpdObj *connection;
36 extern GmpcProfiles *gmpc_profiles;
37 extern GmpcConnection *gmpcconn;
40 typedef struct _gmpcPluginParent gmpcPluginParent;
41 /* Plugin Type's */
42 /* This is a bitmask.*/
43 typedef enum {
44 GMPC_PLUGIN_DUMMY = 1,
45 GMPC_PLUGIN_PL_BROWSER = 2,
46 GMPC_PLUGIN_NO_GUI = 4,
47 GMPC_INTERNALL = 8,
48 GMPC_DEPRECATED = 16,
49 GMPC_DEPRECATED2 = 32,
50 /* Make compiler happy about GMPC_PLUGIN_PL_BROWSER|GMPC_PLUGIN_METADATA */
51 GMPC_BROWSER_META = 34
52 } PluginType;
54 /* the gtk_tree_store row's */
55 typedef enum
57 PL3_CAT_TYPE, /** Plugin id */
58 PL3_CAT_TITLE, /** title that is showed */
59 PL3_CAT_INT_ID, /* id */
60 PL3_CAT_ICON_ID, /* icon id */
61 PL3_CAT_ORDER, /* int for sorting the list */
62 PL3_CAT_BOLD,
63 PL3_CAT_STOCK_ID,
64 PL3_CAT_SHOW_TEXT,
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) (GtkTreeView *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;
118 /* Unique number */
119 /* 16 == 0.14 release */
120 /* 17 == 0.15.5 release */
121 /* 18 == 16 december */
122 /* 19 == 0.16* 24 december */
123 /* 20 == 0.16.5 release */
124 /* 21 == 0.17.0 release -> adding padding so abi wont break next time */
125 #define PLUGIN_API_VERSION 21
127 /* sturcture */
128 typedef struct {
129 /* Name of the plugin */
130 const char *name;
131 /* Version number */
132 const int version[3];
133 /* Type of Plugin */
134 PluginType plugin_type;
135 /* unique plugin id */
136 /* do not fill in, is done by gmpc */
137 int id;
139 /* path where the plugin is (only directory) can be used to get location of f.e. glade/images
140 * Don't use this anymore use: gmpc_get.*_path */
141 /* Do not fill in, done by gmpc */
142 char *path;
143 /* function gets called on startup */
144 void (*init)(void);
145 /* Plugin should destroy all it's widgets and free all allocated space */
146 void (*destroy)(void);
147 /* Browser Plugins */
148 gmpcPlBrowserPlugin *browser;
149 /* plugin with one signal for changes on Mpd */
150 StatusChangedCallback mpd_status_changed;
151 /* (dis)connect signal */
152 ConnectionChangedCallback mpd_connection_changed;
153 /* structure to let the plugin intergrate it's preferences */
154 gmpcPrefPlugin *pref;
155 /** Meta data, this is deprecated, do not use.*/
156 void *padding;
158 /** Plugin control functions
160 int (*get_enabled)(void);
161 void (*set_enabled)(int enable);
162 /* Function that is called when the plugin is going to be destroyed,
163 * This is the place if you want to save settings
165 void (*save_yourself)(void);
167 /* Padding */
168 gint (*tool_menu_integration) (GtkMenu *menu);
169 const gchar* (*get_translation_domain) (void);
170 void (*padding3) (void);
171 } gmpcPlugin;
175 * Allows the plugin to access the EasyCommand
177 extern GmpcEasyCommand *gmpc_easy_command;
180 * Playlist function
184 * Get the treeview and tree_store of the category list on the left.
186 GtkListStore * playlist3_get_category_tree_store(void);
187 GtkTreeView * playlist3_get_category_tree_view(void);
190 * Get this GtkWindow of the playlist.
191 * Use this to set parent and so
193 GtkWidget * playlist3_get_window(void);
195 * indicates if the window is hidden to tray
197 gboolean playlist3_window_is_hidden(void);
199 /** plugin functions */
200 gmpcPluginParent * plugin_get_from_id(int id);
204 * Helper functions to get path to gmpc directory and metadata directory
207 char * gmpc_get_full_glade_path(const char *filename);
208 gchar * gmpc_get_covers_path(const gchar *filename);
209 gchar * gmpc_get_user_path(const gchar *filename);
210 gchar * gmpc_get_cache_directory(const gchar *filename);
211 void playlist3_insert_browser(GtkTreeIter *iter, gint position);
214 void pl3_option_menu_activate(void);
215 /* Tell mpd to reload the go menu */
216 void pl3_update_go_menu(void);
219 /* Used by plugins themself */
220 gchar * gmpc_plugin_get_data_path (gmpcPlugin *plug);
223 * Update parts of the gui
225 void pl3_tool_menu_update(void);
228 /***/
230 const char *connection_get_music_directory(void);
231 /* glue */
233 void info2_fill_song_view(mpd_Song *song);
234 void info2_activate(void);
236 void info2_fill_artist_view(const gchar *artist);
237 void info2_fill_album_view(const gchar *artist,const gchar *album);
239 extern GObject *paned_size_group;
241 /** Main window */
245 * show the main window
247 void create_playlist3(void);
249 * Get the state of the sidebar
251 GmpcPluginSidebarState playlist3_get_sidebar_state(void);
254 * hide the main window
256 int pl3_hide(void);
258 extern GmpcMetaWatcher *gmw;
259 #endif