Lines Matching defs:button

2  * Generic button widget
17 #include "button.h"
35 static void sp_button_clicked(GtkButton *button);
36 static void sp_button_perform_action(SPButton *button, gpointer data);
37 static gint sp_button_process_event(SPButton *button, GdkEvent *event);
39 static void sp_button_set_action(SPButton *button, SPAction *action);
40 static void sp_button_set_doubleclick_action(SPButton *button, SPAction *action);
41 static void sp_button_action_set_active(SPButton *button, bool active);
62 static void sp_button_init(SPButton *button)
64 button->action = NULL;
65 button->doubleclick_action = NULL;
66 new (&button->c_set_active) sigc::connection();
67 new (&button->c_set_sensitive) sigc::connection();
69 gtk_container_set_border_width(GTK_CONTAINER(button), 0);
71 gtk_widget_set_can_focus(GTK_WIDGET(button), FALSE);
72 gtk_widget_set_can_default(GTK_WIDGET(button), FALSE);
74 g_signal_connect_after(G_OBJECT(button), "clicked", G_CALLBACK(sp_button_perform_action), NULL);
75 g_signal_connect_after(G_OBJECT(button), "event", G_CALLBACK(sp_button_process_event), NULL);
80 SPButton *button = SP_BUTTON(object);
82 if (button->action) {
83 sp_button_set_action(button, NULL);
85 if (button->doubleclick_action) {
86 sp_button_set_doubleclick_action(button, NULL);
89 button->c_set_active.~connection();
90 button->c_set_sensitive.~connection();
157 static void sp_button_clicked(GtkButton *button)
159 SPButton *sp_button = SP_BUTTON(button);
162 (GTK_BUTTON_CLASS(sp_button_parent_class))->clicked(button);
166 static gint sp_button_process_event(SPButton *button, GdkEvent *event)
170 if (button->doubleclick_action) {
171 sp_action_perform(button->doubleclick_action, NULL);
182 static void sp_button_perform_action(SPButton *button, gpointer /*data*/)
184 if (button->action) {
185 sp_action_perform(button->action, NULL);
191 SPButton *button = SP_BUTTON(g_object_new(SP_TYPE_BUTTON, NULL));
193 button->type = type;
194 button->lsize = CLAMP(size, Inkscape::ICON_SIZE_MENU, Inkscape::ICON_SIZE_DECORATION);
196 sp_button_set_action(button, action);
198 sp_button_set_doubleclick_action(button, doubleclick_action);
201 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
203 return GTK_WIDGET(button);
206 void sp_button_toggle_set_down(SPButton *button, gboolean down)
208 g_return_if_fail(button->type == SP_BUTTON_TYPE_TOGGLE);
209 g_signal_handlers_block_by_func(G_OBJECT(button), (gpointer)G_CALLBACK(sp_button_perform_action), NULL);
210 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), (unsigned int)down);
211 g_signal_handlers_unblock_by_func(G_OBJECT(button), (gpointer)G_CALLBACK(sp_button_perform_action), NULL);
214 static void sp_button_set_doubleclick_action(SPButton *button, SPAction *action)
216 if (button->doubleclick_action) {
217 g_object_unref(button->doubleclick_action);
219 button->doubleclick_action = action;
225 static void sp_button_set_action(SPButton *button, SPAction *action)
229 if (button->action) {
230 button->c_set_active.disconnect();
231 button->c_set_sensitive.disconnect();
232 child = gtk_bin_get_child(GTK_BIN(button));
234 gtk_container_remove(GTK_CONTAINER(button), child);
236 g_object_unref(button->action);
238 button->action = action;
241 button->c_set_active = action->signal_set_active.connect(
242 sigc::bind<0>(sigc::ptr_fun(&sp_button_action_set_active), SP_BUTTON(button)));
243 button->c_set_sensitive = action->signal_set_sensitive.connect(
244 sigc::bind<0>(sigc::ptr_fun(&gtk_widget_set_sensitive), GTK_WIDGET(button)));
246 child = sp_icon_new(button->lsize, action->image);
248 gtk_container_add(GTK_CONTAINER(button), child);
252 sp_button_set_composed_tooltip(GTK_WIDGET(button), action);
255 static void sp_button_action_set_active(SPButton *button, bool active)
257 if (button->type != SP_BUTTON_TYPE_TOGGLE) {
262 if (0 && !active != !SP_BUTTON_IS_DOWN(button)) {
263 sp_button_toggle_set_down(button, active);
293 GtkWidget *button;
295 button = sp_button_new(size, type, action, NULL);
297 return button;