JNIEXPORT void JNICALL Java_org_gnome_gtk_GtkToolbar_gtk_1toolbar_1set_1drop_1highlight_1item ( JNIEnv* env, jclass cls, jlong _self, jlong _toolItem, jint _index ) { GtkToolbar* self; GtkToolItem* toolItem; gint index; // convert parameter self self = (GtkToolbar*) _self; // convert parameter toolItem toolItem = (GtkToolItem*) _toolItem; // convert parameter index index = (gint) _index; // call function gtk_toolbar_set_drop_highlight_item(self, toolItem, index); // cleanup parameter self // cleanup parameter toolItem // cleanup parameter index }
static VALUE rg_set_drop_highlight_item(VALUE self, VALUE item, VALUE index) { gtk_toolbar_set_drop_highlight_item(_SELF(self), GTK_TOOL_ITEM(RVAL2GOBJ(item)), NUM2INT(index)); return self; }
/** * called when hovering an item above the toolbar */ gboolean nsgtk_toolbar_action(GtkWidget *widget, GdkDragContext *gdc, gint x, gint y, guint time, gpointer data) { nsgtk_scaffolding *g = (nsgtk_scaffolding *)data; GtkToolItem *item = gtk_tool_button_new(NULL, NULL); if (item != NULL) gtk_toolbar_set_drop_highlight_item( nsgtk_scaffolding_toolbar(g), GTK_TOOL_ITEM(item), gtk_toolbar_get_drop_index( nsgtk_scaffolding_toolbar(g), x, y)); return FALSE; }
static void toolbar_drag_leave (GtkToolbar *toolbar, GdkDragContext *context, guint time, gpointer null) { if (drag_item) { g_object_unref (drag_item); drag_item = NULL; } gtk_toolbar_set_drop_highlight_item (toolbar, NULL, 0); }
static void toolbar_drag_leave_cb (GtkToolbar *toolbar, GdkDragContext *context, guint time, EggEditableToolbar *etoolbar) { gtk_toolbar_set_drop_highlight_item (toolbar, NULL, 0); /* If we were the current dnd toolbar target, remove the item. */ if (etoolbar->priv->dnd_toolbar == toolbar) { etoolbar->priv->dnd_toolbar = NULL; etoolbar->priv->dnd_toolitem = NULL; } }
static gboolean toolbar_drag_motion_cb (GtkToolbar *toolbar, GdkDragContext *context, gint x, gint y, guint time, EggEditableToolbar *etoolbar) { GdkAtom target = gtk_drag_dest_find_target (GTK_WIDGET (toolbar), context, NULL); if (target == GDK_NONE) { gdk_drag_status (context, 0, time); return FALSE; } /* Make ourselves the current dnd toolbar, and request a highlight item. */ if (etoolbar->priv->dnd_toolbar != toolbar) { etoolbar->priv->dnd_toolbar = toolbar; etoolbar->priv->dnd_toolitem = NULL; etoolbar->priv->dnd_pending++; gtk_drag_get_data (GTK_WIDGET (toolbar), context, target, time); } /* If a highlight item is available, use it. */ else if (etoolbar->priv->dnd_toolitem) { gint ipos = gtk_toolbar_get_drop_index (etoolbar->priv->dnd_toolbar, x, y); gtk_toolbar_set_drop_highlight_item (etoolbar->priv->dnd_toolbar, etoolbar->priv->dnd_toolitem, ipos); } gdk_drag_status (context, context->suggested_action, time); return TRUE; }
static gboolean toolbar_drag_motion (GtkToolbar *toolbar, GdkDragContext *context, gint x, gint y, guint time, gpointer null) { gint index; if (!drag_item) { drag_item = gtk_tool_button_new (NULL, "A quite long button"); g_object_ref_sink (g_object_ref (drag_item)); } gdk_drag_status (context, GDK_ACTION_MOVE, time); index = gtk_toolbar_get_drop_index (toolbar, x, y); gtk_toolbar_set_drop_highlight_item (toolbar, drag_item, index); return TRUE; }
static void toolbar_drag_data_received_cb (GtkToolbar *toolbar, GdkDragContext *context, gint x, gint y, GtkSelectionData *selection_data, guint info, guint time, EggEditableToolbar *etoolbar) { /* This function can be called for two reasons * * (1) drag_motion() needs an item to pass to * gtk_toolbar_set_drop_highlight_item(). We can * recognize this case by etoolbar->priv->pending being TRUE * We should just create an item and return. * * (2) The drag has finished, and drag_drop() wants us to * actually add a new item to the toolbar. */ GdkAtom type = gtk_selection_data_get_data_type (selection_data); const char *data = (char *)gtk_selection_data_get_data (selection_data); int ipos = -1; char *name = NULL; gboolean used = FALSE; /* Find out where the drop is occuring, and the name of what is being dropped. */ if (gtk_selection_data_get_length (selection_data) >= 0) { ipos = gtk_toolbar_get_drop_index (toolbar, x, y); name = egg_toolbars_model_get_name (etoolbar->priv->model, type, data, FALSE); if (name != NULL) { used = ((egg_toolbars_model_get_name_flags (etoolbar->priv->model, name) & EGG_TB_MODEL_NAME_USED) != 0); } } /* If we just want a highlight item, then . */ if (etoolbar->priv->dnd_pending > 0) { etoolbar->priv->dnd_pending--; if (name != NULL && etoolbar->priv->dnd_toolbar == toolbar && !used) { etoolbar->priv->dnd_toolitem = create_item_from_action (etoolbar, name); gtk_toolbar_set_drop_highlight_item (etoolbar->priv->dnd_toolbar, etoolbar->priv->dnd_toolitem, ipos); } } else { gtk_toolbar_set_drop_highlight_item (toolbar, NULL, 0); etoolbar->priv->dnd_toolbar = NULL; etoolbar->priv->dnd_toolitem = NULL; /* If we don't have a name to use yet, try to create one. */ if (name == NULL && gtk_selection_data_get_length (selection_data) >= 0) { name = egg_toolbars_model_get_name (etoolbar->priv->model, type, data, TRUE); } if (name != NULL && !used) { gint tpos = get_toolbar_position (etoolbar, GTK_WIDGET (toolbar)); egg_toolbars_model_add_item (etoolbar->priv->model, tpos, ipos, name); gtk_drag_finish (context, TRUE, context->action == GDK_ACTION_MOVE, time); } else { gtk_drag_finish (context, FALSE, context->action == GDK_ACTION_MOVE, time); } } g_free (name); }
/** * called when hovering stops */ void nsgtk_toolbar_clear(GtkWidget *widget, GdkDragContext *gdc, guint time, gpointer data) { gtk_toolbar_set_drop_highlight_item(GTK_TOOLBAR(widget), NULL, 0); }