00001 00002 #ifndef __CAIRO_DOCK_APPLET_FACTORY__ 00003 #define __CAIRO_DOCK_APPLET_FACTORY__ 00004 00005 #include <glib.h> 00006 00007 #include "cairo-dock-struct.h" 00008 00009 00010 cairo_surface_t *cairo_dock_create_applet_surface (gchar *cImageFilePath, cairo_t *pSourceContext, double fMaxScale, double *fWidth, double *fHeight); 00011 00012 00013 Icon *cairo_dock_create_icon_for_applet (CairoDock *pDock, int iWidth, int iHeight, gchar *cName, gchar *cIconName); 00014 00015 00016 00017 GKeyFile *cairo_dock_read_header_applet_conf_file (gchar *cConfFilePath, int *iWidth, int *iHeight, gchar **cName, gboolean *bFlushConfFileNeeded); 00018 00019 00020 GHashTable *cairo_dock_list_themes (gchar *cThemesDir, GHashTable *hProvidedTable, GError **erreur); 00021 00022 00023 gchar *cairo_dock_check_conf_file_exists (gchar *cUserDataDirName, gchar *cShareDataDir, gchar *cConfFileName); 00024 00025 00026 void cairo_dock_set_icon_surface (cairo_t *pIconContext, cairo_surface_t *pSurface); 00027 void cairo_dock_add_reflection_to_icon (cairo_t *pIconContext, Icon *pIcon, CairoDock *pDock); 00028 void cairo_dock_set_icon_surface_with_reflect (cairo_t *pIconContext, cairo_surface_t *pSurface, Icon *pIcon, CairoDock *pDock); 00029 00030 void cairo_dock_set_icon_name (cairo_t *pIconContext, const gchar *cIconName, Icon *pIcon, CairoDock *pDock); 00031 00032 void cairo_dock_set_quick_info (cairo_t *pIconContext, const gchar *cExtraInfo, Icon *pIcon); 00033 #define cairo_dock_remove_quick_info(pIcon) cairo_dock_set_quick_info (NULL, NULL, pIcon) 00034 00035 void cairo_dock_animate_icon (Icon *pIcon, CairoDock *pDock, CairoDockAnimationType iAnimationType, int iNbRounds); 00036 00037 int cairo_dock_get_number_from_name (gchar *cValue, gchar **cValuesList); 00038 00039 00040 00041 #define CD_CONFIG_APPLET \ 00042 void read_conf_file (gchar *cConfFilePath, int *iWidth, int *iHeight, gchar *cName) 00043 00044 #define CD_CONFIG_BEGIN \ 00045 GError *erreur = NULL; \ 00046 gboolean bFlushConfFileNeeded = FALSE; \ 00047 GKeyFile *pKeyFile = cairo_dock_read_header_applet_conf_file (cConfFilePath, iWidth, iHeight, &cName, &bFlushConfFileNeeded); \ 00048 g_return_if_fail (pKeyFile != NULL); 00049 #define CD_CONFIG_END \ 00050 if (bFlushConfFileNeeded) \ 00051 cairo_dock_write_keys_to_file (pKeyFile, cConfFilePath); \ 00052 g_key_file_free (pKeyFile); 00053 00054 #define CD_CONFIG_GET_BOOLEAN(cGroupName, cKeyName) cairo_dock_get_boolean_key_value (pKeyFile, cGroupName, cKeyName, &bFlushConfFileNeeded, TRUE) 00055 #define CD_CONFIG_GET_INTEGER(cGroupName, cKeyName) cairo_dock_get_integer_key_value (pKeyFile, cGroupName, cKeyName, &bFlushConfFileNeeded, 0) 00056 #define CD_CONFIG_GET_DOUBLE(cGroupName, cKeyName) cairo_dock_get_double_key_value (pKeyFile, cGroupName, cKeyName, &bFlushConfFileNeeded, 0.) 00057 #define CD_CONFIG_GET_STRING(cGroupName, cKeyName) cairo_dock_get_string_key_value (pKeyFile, cGroupName, cKeyName, &bFlushConfFileNeeded, NULL) 00058 #define CD_CONFIG_GET_ANIMATION(cGroupName, cKeyName) cairo_dock_get_animation_type_key_value (pKeyFile, cGroupName, cKeyName, &bFlushConfFileNeeded, NULL); 00059 00060 00061 #define CD_APPLET_DEFINITION(cName, iMajorVersion, iMinorVersion, iMicroVersion) \ 00062 CairoDockVisitCard *pre_init (void)\ 00063 {\ 00064 CairoDockVisitCard *pVisitCard = g_new0 (CairoDockVisitCard, 1);\ 00065 pVisitCard->cModuleName = g_strdup (cName);\ 00066 pVisitCard->cReadmeFilePath = g_strdup_printf ("%s/%s", MY_APPLET_SHARE_DATA_DIR, MY_APPLET_README_FILE);\ 00067 pVisitCard->iMajorVersionNeeded = iMajorVersion;\ 00068 pVisitCard->iMinorVersionNeeded = iMinorVersion;\ 00069 pVisitCard->iMicroVersionNeeded = iMicroVersion;\ 00070 return pVisitCard;\ 00071 } 00072 00073 #define CD_INIT_APPLET Icon *init (CairoDock *pDock, gchar **cConfFilePath, GError **erreur) 00074 #define CD_STOP_APPLET void stop (void) 00075 #define CD_PRE_INIT_APPLET gchar *pre_init (void) 00076 00077 #define CD_APPLET_INIT_BEGIN \ 00078 myDock = pDock; \ 00079 *cConfFilePath = cairo_dock_check_conf_file_exists (MY_APPLET_USER_DATA_DIR, MY_APPLET_SHARE_DATA_DIR, APPLET_CONF_FILE); \ 00080 int iOriginalWidth = 48, iOriginalHeight = 48; \ 00081 gchar *cAppletName = NULL; \ 00082 read_conf_file (*cConfFilePath, &iOriginalWidth, &iOriginalHeight, &cAppletName); \ 00083 myIcon = cairo_dock_create_icon_for_applet (pDock, iOriginalWidth, iOriginalHeight, conf_defaultTitle, NULL); \ 00084 myDrawContext = cairo_create (myIcon->pIconBuffer); 00085 00086 #define CD_APPLET_INIT_END \ 00087 g_free (cAppletName); \ 00088 return myIcon; 00089 00090 00091 #define CD_CLICK_ON_APPLET \ 00092 gboolean action_on_click (gpointer *data) 00093 00094 #define CD_CLICK_ON_APPLET_BEGIN \ 00095 if (data[0] == myIcon) \ 00096 { 00097 00098 #define CD_CLICK_ON_APPLET_END \ 00099 } \ 00100 return CAIRO_DOCK_LET_PASS_NOTIFICATION; 00101 00102 00103 #endif