2
* Copyright (C) 2008 Rodney Cryderman <rcryderman@gmail.com>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24
#include <libawn/awn-cairo-utils.h>
25
#include <libawn/awn-applet-simple.h>
26
#include <libawn/awn-applet-dialog.h>
29
#include <glib/gi18n.h>
31
#include <libawn-extras/awn-extras.h>
33
#include "engine_html.h"
35
#include "configuration.h"
39
_send_dialog_response (GtkEntry *entry, GtkDialog *dialog)
41
gtk_dialog_response (dialog, GTK_RESPONSE_OK);
45
_show_location_dialog (GtkMenuItem *menuitem,WebApplet *webapplet)
47
static gboolean done_once = FALSE;
48
static GtkWidget *location_dialog;
49
static GtkWidget *entry;
53
location_dialog = gtk_dialog_new_with_buttons (_("Open Location"),
54
GTK_WINDOW (webapplet->mainwindow),
55
GTK_DIALOG_DESTROY_WITH_PARENT,
61
GtkWidget *hbox = gtk_hbox_new (FALSE, 5);
62
gtk_container_add (GTK_CONTAINER (hbox), gtk_label_new (_("URI:")));
63
entry = gtk_entry_new ();
64
g_signal_connect (G_OBJECT (entry), "activate",
65
G_CALLBACK (_send_dialog_response),
67
gtk_container_add (GTK_CONTAINER (hbox), entry);
68
gtk_widget_show_all (hbox);
69
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (location_dialog)->vbox),
73
response = gtk_dialog_run (GTK_DIALOG (location_dialog));
74
gtk_widget_hide (location_dialog);
75
if (response == GTK_RESPONSE_OK)
77
html_web_view_open (webapplet->viewer,
78
gtk_entry_get_text (GTK_ENTRY (entry)));
80
gchar * title = g_strdup_printf("%30s",gtk_entry_get_text (GTK_ENTRY (entry))); //FIXME put the URL or page title in here...
81
awn_applet_simple_set_title(AWN_APPLET_SIMPLE(webapplet->applet),title);
88
awn_html_dialog_new (WebApplet *webapplet)
91
webapplet->mainwindow = awn_applet_dialog_new (webapplet->applet);
92
webapplet->box = gtk_vbox_new (FALSE, 1);
93
gtk_widget_set_size_request (GTK_WIDGET (webapplet->box), config_get_width(webapplet),
94
config_get_height(webapplet) );
95
webapplet->viewer = html_web_view_new ();
96
gtk_container_add (GTK_CONTAINER (webapplet->box),webapplet->viewer);
97
gtk_container_add (GTK_CONTAINER (webapplet->mainwindow), webapplet->box);
98
html_web_view_open (webapplet->viewer, config_get_uri(webapplet));
103
_button_clicked_event (GtkWidget *widget,
104
GdkEventButton *event,
105
WebApplet *webapplet)
107
static GtkWidget *menu=NULL;
108
GdkEventButton *event_button;
109
event_button = (GdkEventButton *)event;
110
if (event->button == 1)
112
if (GTK_WIDGET_VISIBLE (webapplet->mainwindow))
114
gtk_widget_hide (webapplet->mainwindow);
118
gtk_widget_show_all (webapplet->mainwindow);
121
else if (event->button == 3)
126
menu = awn_applet_create_default_menu (webapplet->applet);
127
gtk_menu_set_screen (GTK_MENU (menu), NULL);
128
if (config_get_enable_location_dialog(webapplet))
130
item = gtk_image_menu_item_new_with_label (_("Open Location"));
131
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item),
132
gtk_image_new_from_stock (GTK_STOCK_OPEN,
133
GTK_ICON_SIZE_MENU));
134
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
135
gtk_widget_show_all (item);
136
g_signal_connect (G_OBJECT (item), "activate",
137
G_CALLBACK (_show_location_dialog), webapplet);
139
item = shared_menuitem_create_applet_prefs(webapplet->uid,APPLET_NAME,APPLET_NAME);
140
if (item) //generic preferences is enabled
142
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
144
item = shared_menuitem_about_applet_simple("2008 Rodney Cryderman <rcryderman@gmail.com>\n2008 Mark Lee <avant-wn@lazymalevolence.com>\n",
145
AWN_APPLET_LICENSE_GPLV2,
148
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
150
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
151
event_button->button, event_button->time);
157
_focus_out_event(GtkWidget *widget, GdkEventButton *event, void * null)
159
// gtk_widget_hide(webapplet->mainwindow);
165
_bloody_thing_has_style (GtkWidget *widget,WebApplet *webapplet)
168
gchar * title = g_strdup_printf("%30s",config_get_uri(webapplet)); //FIXME put the URL or page title in here...
169
awn_applet_simple_set_title(AWN_APPLET_SIMPLE(webapplet->applet),title);
171
g_signal_connect (G_OBJECT (webapplet->applet), "button-press-event",
172
G_CALLBACK (_button_clicked_event), webapplet);
173
g_signal_connect (G_OBJECT (webapplet->mainwindow), "focus-out-event",
174
G_CALLBACK (_focus_out_event), webapplet);
178
awn_applet_factory_initp (gchar *uid, gint orient, gint height)
180
g_on_error_stack_trace (NULL);
182
WebApplet *webapplet = g_malloc (sizeof (WebApplet));
183
webapplet->uid=g_strdup(uid);
184
init_config (webapplet, uid);
185
webapplet->applet = AWN_APPLET (awn_applet_simple_new (uid, orient, height));
186
gtk_widget_set_size_request (GTK_WIDGET (webapplet->applet), height, -1);
188
webapplet->applet_icon_name = g_strdup ("apple-green");
190
awn_applet_simple_set_awn_icon(AWN_APPLET_SIMPLE(webapplet->applet),
192
webapplet->applet_icon_name) ;
194
gtk_widget_show_all (GTK_WIDGET (webapplet->applet));
195
awn_html_dialog_new (webapplet);
196
gtk_window_set_focus_on_map (GTK_WINDOW (webapplet->mainwindow), TRUE);
197
g_signal_connect_after (G_OBJECT (webapplet->applet), "realize",
198
G_CALLBACK (_bloody_thing_has_style), webapplet);
199
return webapplet->applet;
201
/* vim: set et ts=2 sts=2 sw=2 : */