/** * physically add widgets to store window */ bool nsgtk_toolbar_add_store_widget(GtkWidget *widget) { if (window->numberh >= NSGTK_STORE_WIDTH) { window->currentbar = gtk_toolbar_new(); if (window->currentbar == NULL) { warn_user("NoMemory", 0); return false; } gtk_toolbar_set_style(GTK_TOOLBAR(window->currentbar), GTK_TOOLBAR_BOTH); gtk_toolbar_set_icon_size(GTK_TOOLBAR(window->currentbar), GTK_ICON_SIZE_LARGE_TOOLBAR); gtk_box_pack_start(GTK_BOX(window->widgetvbox), window->currentbar, FALSE, FALSE, 0); window->numberh = 0; } gtk_widget_set_size_request(widget, NSGTK_BUTTON_WIDTH, NSGTK_BUTTON_HEIGHT); gtk_toolbar_insert(GTK_TOOLBAR(window->currentbar), GTK_TOOL_ITEM( widget), window->numberh++); gtk_tool_item_set_use_drag_window(GTK_TOOL_ITEM(widget), TRUE); gtk_drag_source_set(widget, GDK_BUTTON1_MASK, &entry, 1, GDK_ACTION_COPY); gtk_widget_show_all(window->window); return true; }
JNIEXPORT void JNICALL Java_org_gnome_gtk_GtkToolItem_gtk_1tool_1item_1set_1use_1drag_1window ( JNIEnv* env, jclass cls, jlong _self, jboolean _useDragWindow ) { GtkToolItem* self; gboolean useDragWindow; // convert parameter self self = (GtkToolItem*) _self; // convert parameter useDragWindow useDragWindow = (gboolean) _useDragWindow; // call function gtk_tool_item_set_use_drag_window(self, useDragWindow); // cleanup parameter self // cleanup parameter useDragWindow }
static void configure_item_sensitivity (GtkToolItem *item, EggEditableToolbar *etoolbar) { GtkAction *action; char *name; name = g_object_get_data (G_OBJECT (item), EGG_ITEM_NAME); action = name ? find_action (etoolbar, name) : NULL; if (action) { g_object_notify (G_OBJECT (action), "sensitive"); } gtk_tool_item_set_use_drag_window (item, (etoolbar->priv->edit_mode > 0) || GTK_IS_SEPARATOR_TOOL_ITEM (item)); }
/** * when 'reload defaults' button is clicked */ gboolean nsgtk_toolbar_reset(GtkWidget *widget, gpointer data) { nsgtk_scaffolding *g = (nsgtk_scaffolding *)data; int i; for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) nsgtk_scaffolding_button(g, i)->location = (i <= THROBBER_ITEM) ? i : -1; nsgtk_toolbar_set_physical(g); for (i = BACK_BUTTON; i <= THROBBER_ITEM; i++) { if (i == URL_BAR_ITEM) continue; gtk_tool_item_set_use_drag_window(GTK_TOOL_ITEM( nsgtk_scaffolding_button(g, i)->button), TRUE); gtk_drag_source_set(GTK_WIDGET( nsgtk_scaffolding_button(g, i)->button), GDK_BUTTON1_MASK, &entry, 1, GDK_ACTION_COPY); nsgtk_toolbar_temp_connect(g, i); } return TRUE; }
/** * 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; }
/** * change behaviour of scaffoldings while editing toolbar; all buttons as * well as window clicks are desensitized; then buttons in the front window * are changed to movable buttons */ void nsgtk_toolbar_customization_init(nsgtk_scaffolding *g) { int i; nsgtk_scaffolding *list = scaf_list; edit_mode = true; while (list) { g_signal_handler_block(GTK_WIDGET( nsgtk_window_get_layout( nsgtk_scaffolding_top_level(list))), nsgtk_window_get_signalhandler( nsgtk_scaffolding_top_level(list), NSGTK_WINDOW_SIGNAL_CLICK)); g_signal_handler_block(GTK_WIDGET( nsgtk_window_get_layout( nsgtk_scaffolding_top_level(list))), nsgtk_window_get_signalhandler( nsgtk_scaffolding_top_level(list), NSGTK_WINDOW_SIGNAL_REDRAW)); nsgtk_widget_override_background_color( GTK_WIDGET(nsgtk_window_get_layout( nsgtk_scaffolding_top_level(list))), GTK_STATE_NORMAL, 0, 0xEEEE, 0xEEEE, 0xEEEE); if (list == g) { list = nsgtk_scaffolding_iterate(list); continue; } /* set sensitive for all gui_windows save g */ gtk_widget_set_sensitive(GTK_WIDGET(nsgtk_scaffolding_window( list)), FALSE); list = nsgtk_scaffolding_iterate(list); } /* set sensitive for all of g save toolbar */ gtk_widget_set_sensitive(GTK_WIDGET(nsgtk_scaffolding_menu_bar(g)), FALSE); gtk_widget_set_sensitive(GTK_WIDGET(nsgtk_scaffolding_notebook(g)), FALSE); /* set editable aspect for toolbar */ gtk_container_foreach(GTK_CONTAINER(nsgtk_scaffolding_toolbar(g)), nsgtk_toolbar_clear_toolbar, g); nsgtk_toolbar_set_physical(g); /* memorize button locations, set editable */ for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) { window->buttonlocations[i] = nsgtk_scaffolding_button(g, i) ->location; if ((window->buttonlocations[i] == -1) || (i == URL_BAR_ITEM)) continue; gtk_tool_item_set_use_drag_window(GTK_TOOL_ITEM( nsgtk_scaffolding_button(g, i)->button), TRUE); gtk_drag_source_set(GTK_WIDGET(nsgtk_scaffolding_button( g, i)->button), GDK_BUTTON1_MASK, &entry, 1, GDK_ACTION_COPY); nsgtk_toolbar_temp_connect(g, i); } /* add move button listeners */ g_signal_connect(GTK_WIDGET(nsgtk_scaffolding_toolbar(g)), "drag-drop", G_CALLBACK(nsgtk_toolbar_data), g); g_signal_connect(GTK_WIDGET(nsgtk_scaffolding_toolbar(g)), "drag-data-received", G_CALLBACK( nsgtk_toolbar_move_complete), g); g_signal_connect(GTK_WIDGET(nsgtk_scaffolding_toolbar(g)), "drag-motion", G_CALLBACK(nsgtk_toolbar_action), g); g_signal_connect(GTK_WIDGET(nsgtk_scaffolding_toolbar(g)), "drag-leave", G_CALLBACK( nsgtk_toolbar_clear), g); /* set data types */ gtk_drag_dest_set(GTK_WIDGET(nsgtk_scaffolding_toolbar(g)), GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, &entry, 1, GDK_ACTION_COPY); /* open toolbar window */ nsgtk_toolbar_window_open(g); }
static VALUE rg_set_use_drag_window(VALUE self, VALUE use_drag_window) { gtk_tool_item_set_use_drag_window(_SELF(self), RVAL2CBOOL(use_drag_window)); return self; }