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 <glib/gi18n.h>
33
#include "applet-struct.h"
34
#include "applet-notifications.h"
35
#include "applet-widget.h"
37
static GList *s_pUriList = NULL;
40
void cd_weblet_free_uri_list (void)
42
if (s_pUriList == NULL)
44
g_list_foreach (s_pUriList, (GFunc) g_free, NULL);
45
g_list_free (s_pUriList);
50
//\___________ Define here the action to be taken when the user left-clicks on your icon or on its subdock or your desklet. The icon and the container that were clicked are available through the macros CD_APPLET_CLICKED_ICON and CD_APPLET_CLICKED_CONTAINER. CD_APPLET_CLICKED_ICON may be NULL if the user clicked in the container but out of icons.
51
CD_APPLET_ON_CLICK_BEGIN
54
if (myData.dialog == NULL)
55
weblet_build_and_show (myApplet);
57
cairo_dock_unhide_dialog (myData.dialog);
59
CD_APPLET_ON_CLICK_END
62
CD_APPLET_ON_MIDDLE_CLICK_BEGIN
63
if (myDock && myData.dialog != NULL)
65
cairo_dock_hide_dialog (myData.dialog);
67
CD_APPLET_ON_MIDDLE_CLICK_END
70
static void _cd_weblets_set_current_URI (CairoDockModuleInstance *myApplet, const gchar *cURI)
72
g_return_if_fail (cURI != NULL);
74
// on se souvient de la derniere URL chargee.
75
g_free (myConfig.cURI_to_load);
76
myConfig.cURI_to_load = g_strdup (cURI);
77
cairo_dock_update_conf_file (CD_APPLET_MY_CONF_FILE,
81
myConfig.cURI_to_load,
84
// on rafraichit le tout !
85
cairo_dock_relaunch_task_immediately (myData.pRefreshTimer, myConfig.iReloadTimeout);
88
static void _cd_weblets_open_URI (GtkMenuItem *menu_item, gpointer *data)
90
CairoDockModuleInstance *myApplet = data[0];
91
gint index_URI = GPOINTER_TO_INT(data[1]);
92
cd_message( "weblets: opening predefined URI %d (%s).", index_URI, myConfig.cListURI[index_URI] );
94
_cd_weblets_set_current_URI (myApplet, myConfig.cListURI[index_URI]);
96
cd_weblet_free_uri_list ();
99
static void _cd_weblets_reload_webpage (GtkMenuItem *menu_item, CairoDockModuleInstance *myApplet)
101
// on rafraichit le tout !
102
cairo_dock_relaunch_task_immediately (myData.pRefreshTimer, myConfig.iReloadTimeout);
105
//\___________ Define here the entries you want to add to the menu when the user right-clicks on your icon or on its subdock or your desklet. The icon and the container that were clicked are available through the macros CD_APPLET_CLICKED_ICON and CD_APPLET_CLICKED_CONTAINER. CD_APPLET_CLICKED_ICON may be NULL if the user clicked in the container but out of icons. The menu where you can add your entries is available throught the macro CD_APPLET_MY_MENU; you can add sub-menu to it if you want.
106
CD_APPLET_ON_BUILD_MENU_BEGIN
108
CD_APPLET_ADD_IN_MENU("Reload webpage", _cd_weblets_reload_webpage, CD_APPLET_MY_MENU);
109
GtkWidget *pSubMenu = CD_APPLET_CREATE_MY_SUB_MENU ();
110
if( myConfig.cListURI != NULL )
112
cd_weblet_free_uri_list ();
114
while (myConfig.cListURI[i] != NULL)
116
data = g_new (gpointer, 2);
118
data[1] = GINT_TO_POINTER (i);
119
CD_APPLET_ADD_IN_MENU_WITH_DATA (myConfig.cListURI[i], _cd_weblets_open_URI, pSubMenu, data);
120
s_pUriList = g_list_prepend (s_pUriList, data);
124
CD_APPLET_ADD_ABOUT_IN_MENU (pSubMenu);
125
CD_APPLET_ON_BUILD_MENU_END
128
CD_APPLET_ON_DROP_DATA_BEGIN
129
_cd_weblets_set_current_URI (myApplet, CD_APPLET_RECEIVED_DATA);
130
CD_APPLET_ON_DROP_DATA_END