Example #1
0
static void sp_button_set_action(SPButton *button, SPAction *action)
{
    GtkWidget *child;

    if (button->action) {
        button->c_set_active.disconnect();
        button->c_set_sensitive.disconnect();
        child = gtk_bin_get_child(GTK_BIN(button));
        if (child) {
            gtk_container_remove(GTK_CONTAINER(button), child);
        }
        g_object_unref(button->action);
    }
    button->action = action;
    if (action) {
        g_object_ref(action);
        button->c_set_active = action->signal_set_active.connect(
            sigc::bind<0>(sigc::ptr_fun(&sp_button_action_set_active), SP_BUTTON(button)));
        button->c_set_sensitive = action->signal_set_sensitive.connect(
            sigc::bind<0>(sigc::ptr_fun(&gtk_widget_set_sensitive), GTK_WIDGET(button)));
        if (action->image) {
            child = sp_icon_new(button->lsize, action->image);
            gtk_widget_show(child);
            gtk_container_add(GTK_CONTAINER(button), child);
        }
    }

    sp_button_set_composed_tooltip(GTK_WIDGET(button), action);
}
Example #2
0
static void
sp_button_action_set_shortcut (SPAction *action, unsigned int /*shortcut*/, void *data)
{
	SPButton *button=SP_BUTTON (data);
	if (button->tooltips) {
		sp_button_set_composed_tooltip (button->tooltips, GTK_WIDGET (button), action);
	}
}
Example #3
0
static void sp_button_clicked(GtkButton *button)
{
    SPButton *sp_button = SP_BUTTON(button);

    if (sp_button->type == SP_BUTTON_TYPE_TOGGLE) {
        (GTK_BUTTON_CLASS(sp_button_parent_class))->clicked(button);
    }
}
Example #4
0
static void sp_button_dispose(GObject *object)
{
    SPButton *button = SP_BUTTON(object);

    if (button->action) {
        sp_button_set_action(button, NULL);
    }
    if (button->doubleclick_action) {
        sp_button_set_doubleclick_action(button, NULL);
    }

    button->c_set_active.~connection();
    button->c_set_sensitive.~connection();

    (G_OBJECT_CLASS(sp_button_parent_class))->dispose(object);
}
Example #5
0
GtkWidget *sp_button_new(Inkscape::IconSize size, SPButtonType type, SPAction *action, SPAction *doubleclick_action)
{
    SPButton *button = SP_BUTTON(g_object_new(SP_TYPE_BUTTON, NULL));

    button->type = type;
    button->lsize = CLAMP(size, Inkscape::ICON_SIZE_MENU, Inkscape::ICON_SIZE_DECORATION);

    sp_button_set_action(button, action);
    if (doubleclick_action)
        sp_button_set_doubleclick_action(button, doubleclick_action);

    // The Inkscape style is no-relief buttons
    gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);

    return GTK_WIDGET(button);
}
Example #6
0
static void
sp_button_destroy (GtkObject *object)
{
	SPButton *button;

	button = SP_BUTTON (object);

	if (button->tooltips) {
		g_object_unref (G_OBJECT (button->tooltips));
		button->tooltips = NULL;
	}

	if (button->action) {
		sp_button_set_action (button, NULL);
	}

	if (button->doubleclick_action) {
		sp_button_set_doubleclick_action (button, NULL);
	}

	((GtkObjectClass *) (parent_class))->destroy (object);
}