END_HANDLER COMBO_CHANGED(comboTabPosition, position_tab) { nsgtk_scaffolding *current = scaf_list; nsoption_set_int(button_type, nsoption_int(button_type) + 1); /* value of 0 is reserved for 'unset' */ while (current) { nsgtk_scaffolding_reset_offset(current); nsgtk_reflow_all_windows(); current = nsgtk_scaffolding_iterate(current); } }
END_HANDLER COMBO_CHANGED(comboButtonType, button_type) { nsgtk_scaffolding *current = scaf_list; nsoption_set_int(button_type, nsoption_int(button_type) + 1); /* value of 0 is reserved for 'unset' */ while (current) { nsgtk_scaffolding_reset_offset(current); switch(nsoption_int(button_type)) { case 1: gtk_toolbar_set_style( GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)), GTK_TOOLBAR_ICONS); gtk_toolbar_set_icon_size( GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)), GTK_ICON_SIZE_SMALL_TOOLBAR); break; case 2: gtk_toolbar_set_style( GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)), GTK_TOOLBAR_ICONS); gtk_toolbar_set_icon_size( GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)), GTK_ICON_SIZE_LARGE_TOOLBAR); break; case 3: gtk_toolbar_set_style( GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)), GTK_TOOLBAR_BOTH); gtk_toolbar_set_icon_size( GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)), GTK_ICON_SIZE_LARGE_TOOLBAR); break; case 4: gtk_toolbar_set_style( GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)), GTK_TOOLBAR_TEXT); default: break; } current = nsgtk_scaffolding_iterate(current); } }
/** * called when a widget is dropped onto the toolbar */ gboolean nsgtk_toolbar_data(GtkWidget *widget, GdkDragContext *gdc, gint x, gint y, guint time, gpointer data) { nsgtk_scaffolding *g = (nsgtk_scaffolding *)data; int ind = gtk_toolbar_get_drop_index(nsgtk_scaffolding_toolbar(g), x, y); int q, i; if (window->currentbutton == -1) return TRUE; struct nsgtk_theme *theme = nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR); if (theme == NULL) { warn_user(messages_get("NoMemory"), 0); return TRUE; } if (nsgtk_scaffolding_button(g, window->currentbutton)->location != -1) { /* widget was already in the toolbar; so replace */ if (nsgtk_scaffolding_button(g, window->currentbutton)-> location < ind) ind--; gtk_container_remove(GTK_CONTAINER( nsgtk_scaffolding_toolbar(g)), GTK_WIDGET( nsgtk_scaffolding_button(g, window->currentbutton)->button)); /* 'move' all widgets further right than the original location, * one place to the left in logical schema */ for (i = nsgtk_scaffolding_button(g, window->currentbutton)-> location + 1; i < PLACEHOLDER_BUTTON; i++) { q = nsgtk_toolbar_get_id_at_location(g, i); if (q == -1) continue; nsgtk_scaffolding_button(g, q)->location--; } nsgtk_scaffolding_button(g, window->currentbutton)-> location = -1; } nsgtk_scaffolding_button(g, window->currentbutton)->button = GTK_TOOL_ITEM(nsgtk_toolbar_make_widget(g, window->currentbutton, theme)); free(theme); if (nsgtk_scaffolding_button(g, window->currentbutton)->button == NULL) { warn_user("NoMemory", 0); return TRUE; } /* update logical schema */ nsgtk_scaffolding_reset_offset(g); /* 'move' all widgets further right than the new location, one place to * the right in logical schema */ for (i = PLACEHOLDER_BUTTON - 1; i >= ind; i--) { q = nsgtk_toolbar_get_id_at_location(g, i); if (q == -1) continue; nsgtk_scaffolding_button(g, q)->location++; } nsgtk_scaffolding_button(g, window->currentbutton)->location = ind; /* complete action */ gtk_toolbar_insert(nsgtk_scaffolding_toolbar(g), nsgtk_scaffolding_button(g, window->currentbutton)->button, ind); gtk_tool_item_set_use_drag_window(GTK_TOOL_ITEM( nsgtk_scaffolding_button(g, window->currentbutton)->button), TRUE); gtk_drag_source_set(GTK_WIDGET( nsgtk_scaffolding_button(g, window->currentbutton)->button), GDK_BUTTON1_MASK, &entry, 1, GDK_ACTION_COPY); nsgtk_toolbar_temp_connect(g, window->currentbutton); gtk_widget_show_all(GTK_WIDGET( nsgtk_scaffolding_button(g, window->currentbutton)->button)); window->currentbutton = -1; return TRUE; }