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
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
22
** Login : <chris.chapuis@gmail.com>
23
** Started on Thu Apr 03 18:21:35 2008 CHAPUIS Christophe
27
** - Christophe CHAPUIS <chris.chapuis@gmail.com>
29
** Copyright (C) 2008 CHAPUIS Christophe
30
** This program is free software; you can redistribute it and/or modify
31
** it under the terms of the GNU General Public License as published by
32
** the Free Software Foundation; either version 3 of the License, or
33
** (at your option) any later version.
35
** This program is distributed in the hope that it will be useful,
36
** but WITHOUT ANY WARRANTY; without even the implied warranty of
37
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38
** GNU General Public License for more details.
40
** You should have received a copy of the GNU General Public License
41
** along with this program; if not, write to the Free Software
42
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
45
#include "applet-struct.h"
46
#include "applet-widget.h"
52
void _cd_weblets_set_crop_position (CairoDockModuleInstance *myApplet)
54
GtkAdjustment *pGtkAdjustmentH = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW (myData.pGtkMozEmbed));
55
gtk_adjustment_set_value(pGtkAdjustmentH, 0);
56
gtk_adjustment_set_value(pGtkAdjustmentH, myConfig.iPosScrollX);
57
GtkAdjustment *pGtkAdjustmentV = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW (myData.pGtkMozEmbed));
58
gtk_adjustment_set_value(pGtkAdjustmentV, 0);
59
gtk_adjustment_set_value(pGtkAdjustmentV, myConfig.iPosScrollY);
62
// hide/show the scrollbars
63
static void show_hide_scrollbars(CairoDockModuleInstance *myApplet)
65
// First, set the position
66
_cd_weblets_set_crop_position (myApplet);
68
// Then, hide or show the scrollbars
69
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (myData.pGtkMozEmbed), myConfig.bShowScrollbars?GTK_POLICY_AUTOMATIC:GTK_POLICY_NEVER, myConfig.bShowScrollbars?GTK_POLICY_AUTOMATIC:GTK_POLICY_NEVER);
73
CairoDialog *cd_weblets_build_dialog(CairoDockModuleInstance *myApplet)
75
CairoDialogAttribute attr;
76
memset (&attr, 0, sizeof (CairoDialogAttribute));
77
attr.cText = D_ ("Weblets");
78
attr.pInteractiveWidget = myData.pGtkMozEmbed;
79
return cairo_dock_build_dialog (&attr, myIcon, myContainer);
82
/* Will be called when loading of the page is finished*/
83
void load_finished_cb(WebKitWebView *pWebKitView, WebKitWebFrame* widget
84
, CairoDockModuleInstance *myApplet)
86
g_print ("weblets : (re)load finished\n");
87
// update scrollbars status
88
show_hide_scrollbars(myApplet);
91
/* Build the embedded widget */
92
void weblet_build_and_show(CairoDockModuleInstance *myApplet)
94
myData.pGtkMozEmbed = gtk_scrolled_window_new (NULL, NULL);
95
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (myData.pGtkMozEmbed), myConfig.bShowScrollbars?GTK_POLICY_AUTOMATIC:GTK_POLICY_NEVER, myConfig.bShowScrollbars?GTK_POLICY_AUTOMATIC:GTK_POLICY_NEVER);
97
myData.pWebKitView = WEBKIT_WEB_VIEW (webkit_web_view_new ());
98
gtk_container_add (GTK_CONTAINER (myData.pGtkMozEmbed), GTK_WIDGET (myData.pWebKitView));
99
gtk_signal_connect(GTK_OBJECT(myData.pWebKitView),
101
GTK_SIGNAL_FUNC(load_finished_cb),
103
gtk_widget_show_all (myData.pGtkMozEmbed);
107
gtk_widget_set (GTK_WIDGET (myData.pWebKitView), "width-request", 600, "height-request", 400, NULL);
108
myData.dialog = cd_weblets_build_dialog(myApplet);
112
cairo_dock_add_interactive_widget_to_desklet_full (myData.pGtkMozEmbed, myDesklet, myConfig.iRightMargin);
113
cairo_dock_set_desklet_renderer_by_name (myDesklet, NULL, NULL, ! CAIRO_DOCK_LOAD_ICONS_FOR_DESKLET, NULL);
117
gboolean cd_weblets_refresh_page (CairoDockModuleInstance *myApplet)
119
cd_message( "weblets: refreshing page.\n" );
122
if(myData.pGtkMozEmbed)
124
cd_message( " >> weblets: refresh !\n" );
125
if (myConfig.cURI_to_load == NULL)
127
g_free (myConfig.cURI_to_load);
128
myConfig.cURI_to_load = g_strdup ("http://www.google.com");
132
if (g_strstr_len (myConfig.cURI_to_load, -1, "://") == NULL) // pas de protocole defini, on prend http par defaut.
134
gchar *tmp = myConfig.cURI_to_load;
135
myConfig.cURI_to_load = g_strconcat ("http://", (strncmp (myConfig.cURI_to_load, "www.", 4) ? "www." : ""), myConfig.cURI_to_load, NULL);
140
webkit_web_view_open(WEBKIT_WEB_VIEW(myData.pWebKitView), myConfig.cURI_to_load?myConfig.cURI_to_load:"http://www.google.com");
142
/* available since rev. 30985, from fev. 2008 */
143
webkit_web_view_set_transparent(myData.pWebKitView, myConfig.bIsTransparent);