2
* This file is a part of the Cairo-Dock project
4
* Copyright : (C) see the 'copyright' file.
5
* E-mail : see the 'copyright' file.
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.
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/>.
20
/******************************************************************************
22
This file is a part of the cairo-dock program,
23
released under the terms of the GNU General Public License.
25
Written by Christophe Chapuis (for any bug report, please mail me to fabounet@users.berlios.de)
27
******************************************************************************/
31
#include "applet-config.h"
32
#include "applet-notifications.h"
33
#include "applet-struct.h"
34
#include "applet-widget.h"
35
#include "applet-init.h"
37
CD_APPLET_DEFINITION ("weblets",
39
CAIRO_DOCK_CATEGORY_ACCESSORY,
40
N_("The weblets applet allows you to show an interactive web page on your desktop.\n"
41
"You can select your web page, set the desired scrolling,\n"
42
"and hide the scrollbars to get a real 'crop' of the page."),
43
"Tofe (Christophe Chapuis)")
45
//\___________ Here is where you initiate your applet. myConfig is already set at this point, and also myIcon, myContainer, myDock, myDesklet (and myDrawContext if you're in dock mode). The macro CD_APPLET_MY_CONF_FILE and CD_APPLET_MY_KEY_FILE can give you access to the applet's conf-file and its corresponding key-file (also available during reload). If you're in desklet mode, myDrawContext is still NULL, and myIcon's buffers has not been filled, because you may not need them then (idem when reloading).
48
CD_APPLET_REGISTER_FOR_CLICK_EVENT;
49
CD_APPLET_REGISTER_FOR_MIDDLE_CLICK_EVENT;
50
CD_APPLET_REGISTER_FOR_BUILD_MENU_EVENT;
51
CD_APPLET_REGISTER_FOR_DROP_DATA_EVENT;
53
if (myDesklet != NULL) // on cree le weblet pour avoir qqch a afficher dans le desklet.
55
if( myData.pGtkMozEmbed == NULL )
57
weblet_build_and_show (myApplet);
59
CD_APPLET_SET_STATIC_DESKLET;
61
// mise en place du timer
62
myData.pRefreshTimer = cairo_dock_new_task (myConfig.iReloadTimeout,
64
(CairoDockUpdateSyncFunc) cd_weblets_refresh_page,
66
cairo_dock_launch_task (myData.pRefreshTimer); // ceci lance au moins une fois le chargement de la page
68
else // en desklet on n'affiche pas l'icone.
69
CD_APPLET_SET_DEFAULT_IMAGE_ON_MY_ICON_IF_NONE;
74
//\___________ Here is where you stop your applet. myConfig and myData are still valid, but will be reseted to 0 at the end of the function. In the end, your applet will go back to its original state, as if it had never been activated.
76
CD_APPLET_UNREGISTER_FOR_CLICK_EVENT;
77
CD_APPLET_UNREGISTER_FOR_MIDDLE_CLICK_EVENT;
78
CD_APPLET_UNREGISTER_FOR_BUILD_MENU_EVENT;
79
CD_APPLET_UNREGISTER_FOR_DROP_DATA_EVENT;
83
//\___________ The reload occurs in 2 occasions : when the user changes the applet's config, and when the user reload the cairo-dock's config or modify the desklet's size. The macro CD_APPLET_MY_CONFIG_CHANGED can tell you this. myConfig has already been reloaded at this point if you're in the first case, myData is untouched. You also have the macro CD_APPLET_MY_CONTAINER_TYPE_CHANGED that can tell you if you switched from dock/desklet to desklet/dock mode.
84
CD_APPLET_RELOAD_BEGIN
85
//\_______________ On recharge les donnees qui ont pu changer.
86
if (CD_APPLET_MY_CONFIG_CHANGED)
88
if( myData.pRefreshTimer )
90
cairo_dock_free_task( myData.pRefreshTimer );
91
myData.pRefreshTimer = NULL;
94
if (myDock) // en desklet on n'affiche pas l'icone.
95
CD_APPLET_SET_DEFAULT_IMAGE_ON_MY_ICON_IF_NONE;
97
if (myData.pGtkMozEmbed == NULL)
99
if (myDesklet != NULL) // on cree le terminal pour avoir qqch a afficher dans le desklet.
100
weblet_build_and_show (myApplet);
102
else if (CD_APPLET_MY_CONTAINER_TYPE_CHANGED)
104
if (myDesklet != NULL) // il faut passer du dialogue au desklet.
106
myData.pGtkMozEmbed = cairo_dock_steal_widget_from_its_container (myData.pGtkMozEmbed);
107
cairo_dock_dialog_unreference (myData.dialog);
108
myData.dialog = NULL;
109
cairo_dock_add_interactive_widget_to_desklet (myData.pGtkMozEmbed, myDesklet);
110
cairo_dock_set_desklet_renderer_by_name (myDesklet, NULL, NULL, ! CAIRO_DOCK_LOAD_ICONS_FOR_DESKLET, NULL); // pou rempecher le clignotement du au double-buffer.
111
CD_APPLET_SET_STATIC_DESKLET;
113
else // il faut passer du desklet au dialogue
115
myData.dialog = cd_weblets_build_dialog(myApplet);
117
cairo_dock_hide_dialog (myData.dialog);
122
cairo_dock_set_desklet_margin (myDesklet, myConfig.iRightMargin);
125
// on remet en place un timer tout frais
126
myData.pRefreshTimer = cairo_dock_new_task (myConfig.iReloadTimeout,
128
(CairoDockUpdateSyncFunc) cd_weblets_refresh_page,
130
cairo_dock_launch_task (myData.pRefreshTimer); // ceci lance au moins une fois le chargement de la page