2 * Copyright © 2003 Marco Pesenti Gritti
3 * Copyright © 2003 David Bordoley
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * $Id: ephy-go-action.c 7072 2007-06-05 20:20:24Z diegoe $
24 #include "ephy-go-action.h"
25 #include "ephy-debug.h"
27 #include <glib/gi18n.h>
28 #include <gtk/gtktoolitem.h>
29 #include <gtk/gtkbutton.h>
31 static void ephy_go_action_class_init (EphyGoActionClass
*class);
33 static GObjectClass
*parent_class
= NULL
;
36 ephy_go_action_get_type (void)
38 static GType type
= 0;
40 if (G_UNLIKELY (type
== 0))
42 const GTypeInfo type_info
=
44 sizeof (EphyGoActionClass
),
46 (GBaseFinalizeFunc
) NULL
,
47 (GClassInitFunc
) ephy_go_action_class_init
,
48 (GClassFinalizeFunc
) NULL
,
50 sizeof (EphyGoAction
),
52 (GInstanceInitFunc
) NULL
,
55 type
= g_type_register_static (EPHY_TYPE_LINK_ACTION
,
64 create_tool_item (GtkAction
*action
)
69 item
= GTK_WIDGET (gtk_tool_item_new ());
71 button
= gtk_button_new_with_label (_("Go"));
72 gtk_button_set_relief(GTK_BUTTON (button
), GTK_RELIEF_NONE
);
73 gtk_button_set_focus_on_click (GTK_BUTTON (button
), FALSE
);
75 gtk_container_add (GTK_CONTAINER (item
), button
);
76 gtk_widget_show (button
);
82 button_clicked_cb (GtkWidget
*widget
,
83 GdkEventButton
*event
,
86 if (event
->button
== 1 || event
->button
== 2)
87 gtk_action_activate (GTK_ACTION (user_data
));
91 connect_proxy (GtkAction
*action
,
94 GTK_ACTION_CLASS (parent_class
)->connect_proxy (action
, proxy
);
96 if (GTK_IS_TOOL_ITEM (proxy
))
98 g_signal_connect (GTK_BIN (proxy
)->child
, "button-release-event",
99 G_CALLBACK (button_clicked_cb
), action
105 disconnect_proxy (GtkAction
*action
,
108 g_signal_handlers_disconnect_by_func
109 (proxy
, G_CALLBACK (gtk_action_activate
), action
);
111 GTK_ACTION_CLASS (parent_class
)->disconnect_proxy (action
, proxy
);
115 ephy_go_action_class_init (EphyGoActionClass
*class)
117 GtkActionClass
*action_class
= GTK_ACTION_CLASS (class);
119 parent_class
= g_type_class_peek_parent (class);
121 action_class
->create_tool_item
= create_tool_item
;
122 action_class
->connect_proxy
= connect_proxy
;
123 action_class
->disconnect_proxy
= disconnect_proxy
;