index 495c620ac8b00a01635b31f7124105a60335f5ef..b0ab387f097ab9b4afdf74b05fb43db12b4cfe22 100644 (file)
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
#include "../prefs-utils.h"
#include "../inkscape-stock.h"
#include "icon.h"
+#include "graphlayout/graphlayout.h"
#include "mod360.h"
//## Dropper ##
//########################
-static void toggle_dropper_color_pick (GtkWidget *button, gpointer data) {
+static void toggle_dropper_pick_alpha (GtkWidget *button, gpointer tbl) {
prefs_set_int_attribute ("tools.dropper", "pick",
- // 0 and 1 are backwards here because of pref
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) ? 0 : 1);
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)));
+ GtkWidget *set_checkbox = (GtkWidget*) g_object_get_data(G_OBJECT(tbl), "set_checkbox");
+ if (set_checkbox) {
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) {
+ gtk_widget_set_sensitive (GTK_WIDGET (set_checkbox), TRUE);
+ } else {
+ gtk_widget_set_sensitive (GTK_WIDGET (set_checkbox), FALSE);
+ }
+ }
+}
+
+static void toggle_dropper_set_alpha (GtkWidget *button, gpointer data) {
+ prefs_set_int_attribute ("tools.dropper", "setalpha",
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) ? 1 : 0);
}
{
GtkWidget *hb = gtk_hbox_new(FALSE, 1);
-
- GtkWidget *button =
- sp_button_new_from_data( Inkscape::ICON_SIZE_DECORATION,
- SP_BUTTON_TYPE_TOGGLE,
- NULL,
- "pick_color",
- _("When pressed, picks visible color "
- "without alpha and when not pressed, "
- "picks color including its "
- "alpha"),
- tt);
+ GtkWidget *button = gtk_check_button_new_with_label(_("Pick alpha"));
+ gtk_tooltips_set_tip(tt, button, _("Pick both the color and the alpha (transparency) under cursor; otherwise, pick only the visible color premultiplied by alpha"), NULL);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
+ prefs_get_int_attribute ("tools.dropper",
+ "pick", 1));
gtk_widget_show(button);
gtk_container_add (GTK_CONTAINER (hb), button);
+ gtk_object_set_data(GTK_OBJECT(tbl), "pick_checkbox", button);
+ g_signal_connect (G_OBJECT (button), "toggled", G_CALLBACK (toggle_dropper_pick_alpha), tbl);
+ gtk_box_pack_start(GTK_BOX(tbl), hb, FALSE, FALSE,
+ AUX_BETWEEN_BUTTON_GROUPS);
+ }
+
+ {
+ GtkWidget *hb = gtk_hbox_new(FALSE, 1);
- g_signal_connect_after (G_OBJECT (button), "clicked",
- G_CALLBACK (toggle_dropper_color_pick), NULL);
+ GtkWidget *button = gtk_check_button_new_with_label(_("Set alpha"));
+ gtk_tooltips_set_tip(tt, button, _("If alpha was picked, assign it to selection as fill or stroke transparency"), NULL);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
- !prefs_get_int_attribute ("tools.dropper",
- "pick", 0));
+ prefs_get_int_attribute ("tools.dropper",
+ "setalpha", 1));
+ gtk_widget_show(button);
+ gtk_container_add (GTK_CONTAINER (hb), button);
+ gtk_object_set_data(GTK_OBJECT(tbl), "set_checkbox", button);
+ g_signal_connect (G_OBJECT (button), "toggled", G_CALLBACK (toggle_dropper_set_alpha), tbl);
+
+ // make sure it's disabled if we're not picking alpha
+ GtkWidget *pick_checkbox = (GtkWidget*) g_object_get_data(G_OBJECT(tbl), "pick_checkbox");
+ if (pick_checkbox) {
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pick_checkbox))) {
+ gtk_widget_set_sensitive (GTK_WIDGET (button), TRUE);
+ } else {
+ gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE);
+ }
+ }
+
gtk_box_pack_start(GTK_BOX(tbl), hb, FALSE, FALSE,
AUX_BETWEEN_BUTTON_GROUPS);
}
}
+
static void connector_spacing_changed(GtkAdjustment *adj, GtkWidget *tbl)
{
// quit if run by the _changed callbacks
spinbutton_defocus(GTK_OBJECT(tbl));
}
+static void sp_connector_graph_layout(void)
+{
+ if (!SP_ACTIVE_DESKTOP) return;
+
+ // hack for clones, see comment in align-and-distribute.cpp
+ int saved_compensation = prefs_get_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
+ prefs_set_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
+
+ graphlayout(sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList());
+
+ prefs_set_int_attribute("options.clonecompensation", "value", saved_compensation);
+
+ sp_document_done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, /* TODO: annotate */ "toolbox.cpp:129");
+}
+
+static void
+sp_directed_graph_layout_toggled(GtkWidget *widget, GtkObject *tbl)
+{
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
+ prefs_set_string_attribute("tools.connector", "directedlayout",
+ "true");
+ } else {
+ prefs_set_string_attribute("tools.connector", "directedlayout",
+ "false");
+ }
+}
+static void
+sp_nooverlaps_graph_layout_toggled(GtkWidget *widget, GtkObject *tbl)
+{
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
+ prefs_set_string_attribute("tools.connector", "avoidoverlaplayout",
+ "true");
+ } else {
+ prefs_set_string_attribute("tools.connector", "avoidoverlaplayout",
+ "false");
+ }
+}
+
+
+static void connector_length_changed(GtkAdjustment *adj, GtkWidget *tbl)
+{
+ prefs_set_double_attribute("tools.connector", "length", adj->value);
+ spinbutton_defocus(GTK_OBJECT(tbl));
+}
static void connector_tb_event_attr_changed(Inkscape::XML::Node *repr,
gchar const *name, gchar const *old_value, gchar const *new_value,
gtk_box_pack_start(GTK_BOX(tbl), object_spacing, FALSE, FALSE,
AUX_SPACING);
}
+ // Graph (connector network) layout
+ sp_toolbox_button_new(tbl, Inkscape::ICON_SIZE_SMALL_TOOLBAR,
+ "graph_layout", GTK_SIGNAL_FUNC(sp_connector_graph_layout),
+ tt, _("Nicely arrange selected connector network"));
+ // Default connector length spinbox
+ {
+ GtkWidget *connector_length = sp_tb_spinbutton(_("Length:"),
+ _("Ideal length for connectors when layout is applied"),
+ "tools.connector", "length", 100, NULL, tbl, TRUE,
+ "inkscape:connector-length", 10, 1000, 10.0, 100.0,
+ connector_length_changed, 1, 0);
+
+ gtk_box_pack_start(GTK_BOX(tbl), connector_length, FALSE, FALSE,
+ AUX_SPACING);
+ }
+ gchar const *tbuttonstate;
+ // Directed edges toggle button
+ {
+ GtkWidget *tbutton = gtk_toggle_button_new ();
+ gtk_button_set_relief (GTK_BUTTON (tbutton), GTK_RELIEF_NONE);
+ gtk_container_add (GTK_CONTAINER (tbutton), sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, "directed_graph"));
+ gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (tbutton), FALSE);
+ gtk_tooltips_set_tip(tt, tbutton, _("Make connectors point downwards"), NULL);
+
+ gtk_box_pack_start (GTK_BOX (tbl), tbutton, FALSE, FALSE, 0);
+ g_signal_connect(G_OBJECT(tbutton), "toggled", GTK_SIGNAL_FUNC(sp_directed_graph_layout_toggled), tbl);
+ tbuttonstate = prefs_get_string_attribute("tools.connector", "directedlayout");
+ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(tbutton),
+ (tbuttonstate && !strcmp(tbuttonstate, "true"))?TRUE:FALSE );
+ }
+ // Avoid overlaps toggle button
+ {
+ GtkWidget *tbutton = gtk_toggle_button_new ();
+ gtk_button_set_relief (GTK_BUTTON (tbutton), GTK_RELIEF_NONE);
+ gtk_container_add (GTK_CONTAINER (tbutton), sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, "remove_overlaps"));
+ gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (tbutton), FALSE);
+ gtk_tooltips_set_tip(tt, tbutton, _("Do not allow overlapping shapes"), NULL);
+
+ gtk_box_pack_start (GTK_BOX (tbl), tbutton, FALSE, FALSE, 0);
+ g_signal_connect(G_OBJECT(tbutton), "toggled", GTK_SIGNAL_FUNC(sp_nooverlaps_graph_layout_toggled), tbl);
+ tbuttonstate = prefs_get_string_attribute("tools.connector", "avoidoverlaplayout");
+ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(tbutton),
+ (tbuttonstate && !strcmp(tbuttonstate, "true"))?TRUE:FALSE );
+ }
gtk_widget_show_all(tbl);
sp_set_font_size_smaller (tbl);