1 /*
2 * This file is a part of the Cairo-Dock project
3 *
4 * Copyright : (C) see the 'copyright' file.
5 * E-mail    : see the 'copyright' file.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 
21 #ifndef __CAIRO_DOCK_GUI_FACILITY__
22 #define  __CAIRO_DOCK_GUI_FACILITY__
23 
24 #include <gtk/gtk.h>
25 #include "cairo-dock-struct.h"
26 #include "cairo-dock-manager.h"
27 G_BEGIN_DECLS
28 
29 /** @file cairo-dock-gui-manager.h This class provides functions to act on configuration windows.
30 *
31 * It also defines the interface that a GUI backend should implement.
32 *
33 * Note: GUIs are built from a .conf file; .conf files are normal group/key files, but with some special indications in the comments. Each key will be represented by a pre-defined widget, that is defined by the first caracter of its comment. The comment also contains a description of the key, and an optionnal tooltip. See cairo-dock-gui-factory.h for the list of pre-defined widgets and a short explanation on how to use them inside a conf file. The file 'cairo-dock.conf' can be an useful example.
34 */
35 
36 /// Definition of the callback called when the user apply the config panel.
37 typedef gboolean (* CairoDockApplyConfigFunc) (gpointer data);
38 typedef void (* CairoDockLoadCustomWidgetFunc) (GtkWidget *pWindow, GKeyFile *pKeyFile, GSList *pWidgetList);
39 typedef void (* CairoDockSaveCustomWidgetFunc) (GtkWidget *pWindow, GKeyFile *pKeyFile, GSList *pWidgetList);
40 
41 
42 /// Definition of the GUI interface for modules.
43 struct _CairoDockGuiBackend {
44 	/// display a message on the GUI.
45 	void (*set_status_message_on_gui) (const gchar *cMessage);
46 	/// Reload the current config window from the conf file. iShowPage is the page that should be displayed in case the module has several pages, -1 means to keep the current page.
47 	void (*reload_current_widget) (GldiModuleInstance *pModuleInstance, int iShowPage);
48 	void (*show_module_instance_gui) (GldiModuleInstance *pModuleInstance, int iShowPage);
49 	/// retrieve the widgets in the current module window, corresponding to the (group,key) pair in its conf file.
50 	CairoDockGroupKeyWidget * (*get_widget_from_name) (GldiModuleInstance *pModuleInstance, const gchar *cGroupName, const gchar *cKeyName);
51 	} ;
52 typedef struct _CairoDockGuiBackend CairoDockGuiBackend;
53 
54 
55 #define CAIRO_DOCK_FRAME_MARGIN 6
56 
57 
58 void cairo_dock_register_gui_backend (CairoDockGuiBackend *pBackend);
59 
60 
61 void cairo_dock_reload_current_widget_full (GldiModuleInstance *pModuleInstance, int iShowPage);
62 
63 /**Reload the widget of a given module instance if it is currently opened (the current page is displayed). This is useful if the module has modified its conf file and wishes to display the changes.
64 @param pModuleInstance an instance of a module.
65 */
66 #define cairo_dock_reload_current_module_widget(pModuleInstance) cairo_dock_reload_current_widget_full (pModuleInstance, -1)
67 #define cairo_dock_reload_current_module_widget_full cairo_dock_reload_current_widget_full
68 
69 void cairo_dock_show_module_instance_gui (GldiModuleInstance *pModuleInstance, int iShowPage);
70 
71 /** Display a message on a given window that has a status-bar. If no window is provided, the current config panel will be used.
72 @param pWindow window where the message should be displayed, or NULL to target the config panel.
73 @param cMessage the message.
74 */
75 void cairo_dock_set_status_message (GtkWidget *pWindow, const gchar *cMessage);
76 /** Display a message on a given window that has a status-bar. If no window is provided, the current config panel will be used.
77 @param pWindow window where the message should be displayed, or NULL to target the config panel.
78 @param cFormat the message, in a printf-like format
79 @param ... arguments of the format.
80 */
81 void cairo_dock_set_status_message_printf (GtkWidget *pWindow, const gchar *cFormat, ...) G_GNUC_PRINTF (2, 3);
82 
83 
84 G_END_DECLS
85 #endif
86