Ejemplo n.º 1
0
PasteClip Ctrl::GtkDnd(GtkWidget *widget, GdkDragContext *context, gint x, gint y,
                       guint time, gpointer user_data, bool paste)
{
	DndTargets(context);
	g_object_ref(context); // make sure these always survive the action...
	g_object_ref(widget);
	dnd_context = context;
	dnd_widget = widget;
	dnd_time = time;
	PasteClip clip;
	clip.type = 1;
	clip.paste = paste;
	clip.accepted = false;
	clip.allowed = DND_MOVE|DND_COPY;
	gint dummy;
	GdkModifierType mod;
	gdk_window_get_pointer(gdk_get_default_root_window(), &dummy, &dummy, &mod);
	clip.action = mod & GDK_CONTROL_MASK ? DND_COPY : DND_MOVE;
	Ctrl *w = DragWnd(user_data);
	if(w) {
		gint mx, my;
		GdkModifierType mod;
		gdk_window_get_pointer(gdk_get_default_root_window(), &mx, &my, &mod);
		CurrentState = mod;
		CurrentMousePos = Point(x, y) + w->GetScreenRect().TopLeft();	
		w->DnD(CurrentMousePos, clip);
	}
	gdk_drag_status(context, clip.IsAccepted() ? clip.GetAction() == DND_MOVE ? GDK_ACTION_MOVE
	                                                                          : GDK_ACTION_COPY
	                                           : GdkDragAction(0), time);
	return clip;
}
Ejemplo n.º 2
0
int Ctrl::DoDragAndDrop(const char *fmts, const Image& sample, dword actions,
                        const VectorMap<String, ClipData>& data)
{
	LLOG("------------------------------");
	LLOG("DoDragAndDrop " << fmts);
	TopWindow *w = GetTopWindow();
	if(!w || !w->top)
		return DND_NONE;
	int gdk_actions = 0;
	if(actions & DND_MOVE)
		gdk_actions |= GDK_ACTION_MOVE;
	if(actions & DND_COPY)
		gdk_actions |= GDK_ACTION_COPY;
	GtkTargetList *list = CreateTargetList(data);
	dnd_fmts.Clear();
	for(int i = 0; i < data.GetCount(); i++)
		AddFmt(list, data.GetKey(i), i);
	Vector<String> f = Split(fmts, ';');
	for(int i = 0; i < f.GetCount(); i++) {
		AddFmt(list, f[i], data.GetCount() + i);
		dnd_fmts.Add(f[i]);
	}
	dnd_source_data = &data;
	dnd_result = DND_NONE;
	dnd_source = this;
	if(IsNull(sample))
		dnd_icon = Null;
	else {
		Size sz = sample.GetSize();
		if(sz.cx > 128)
			sz.cx = 128;
		if(sz.cy > 128)
			sz.cy = 128;
		sz += 2;
		ImageDraw iw(sz);
		iw.DrawRect(sz, White());
		DrawFrame(iw, sz, Black());
		iw.DrawImage(1, 1, sz.cx, sz.cy, sample);
		ImageBuffer b(128, 128);
		dnd_icon = iw;
	}
	gtk_drag_begin(w->top->window, list, GdkDragAction(gdk_actions),
	               GetMouseLeft() ? 1 : GetMouseMiddle() ? 2 : 3, CurrentEvent.event);
	while(dnd_source && GetTopCtrls().GetCount())
		ProcessEvents();
	dnd_source_data = NULL;
	gtk_target_list_unref (list);
	LLOG("-------- DoDragAndDrop");
	return dnd_result;
}
Ejemplo n.º 3
0
void Ctrl::DndInit()
{
	GtkWidget *w = top->window;
	gpointer id = (gpointer)(uintptr_t)top->id;
	g_signal_connect(w, "drag-begin", G_CALLBACK(GtkDragBegin), id);
	g_signal_connect(w, "drag-data-delete", G_CALLBACK(GtkDragDelete), id);
	g_signal_connect(w, "drag-data-get", G_CALLBACK(GtkDragGetData), id);
	g_signal_connect(w, "drag-data-received", G_CALLBACK(GtkDragDataReceived), id);
	g_signal_connect(w, "drag-drop", G_CALLBACK(GtkDragDrop), id);
	g_signal_connect(w, "drag-end", G_CALLBACK(GtkDragEnd), id);
	g_signal_connect(w, "drag-failed", G_CALLBACK(GtkDragFailed), id);
	g_signal_connect(w, "drag-leave", G_CALLBACK(GtkDragLeave), id);
	g_signal_connect(w, "drag-motion", G_CALLBACK(GtkDragMotion), id);
	gtk_drag_dest_set(w, GtkDestDefaults(0), NULL, 0, GdkDragAction(GDK_ACTION_COPY|GDK_ACTION_MOVE));
}
Ejemplo n.º 4
0
GtkWidget*
pp_layout_nup_pageview_new (Layout_NUp *layout)
{
	pp_Layout_NUp_PageView *pageview;

	pageview = PP_LAYOUT_NUP_PAGEVIEW(g_object_new (pp_layout_nup_pageview_get_type (), NULL));

	gtk_drag_dest_set(GTK_WIDGET(pageview),
			  GtkDestDefaults(GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP),
			  dnd_file_drop_types, dnd_file_drop_types_count,
                          GdkDragAction(GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK));
	g_signal_connect(G_OBJECT(pageview), "drag_data_received",
			 G_CALLBACK(get_dnd_data), NULL);

	pageview->layout=layout;

	return GTK_WIDGET (pageview);
}
Ejemplo n.º 5
0
GtkWidget *htoolbar_create()
{
    GtkWidget *htbar, *button;
    htbar = gtk_hbox_new(TRUE, 1);

    button = gtk_button_new_with_label("htbar0");
    gtk_box_pack_start(GTK_BOX(htbar), button, TRUE, FALSE, 0);

    button = gtk_button_new_with_label("htbar1");
    gtk_box_pack_start(GTK_BOX(htbar), button, TRUE, FALSE, 0);

    gtk_drag_dest_set(htbar, GTK_DEST_DEFAULT_ALL, target_table, n_targets,     /* no rootwin */
                      GdkDragAction(GDK_ACTION_COPY | GDK_ACTION_MOVE));
    g_signal_connect(htbar, "drag_drop", G_CALLBACK(target_drag_drop), htbar);

    g_signal_connect(htbar, "drag_data_received", G_CALLBACK(target_drag_data_received), NULL);

    gtk_widget_show_all(htbar);

    return htbar;
}
Ejemplo n.º 6
0
/**
 * \brief Create all the skel or container windows for modules but ui.
 *
 * ui, is only part of skel, all the content is filled later.
 *
 * content type:
 *      page, trigger, hbar, vbar
 *
 * main window.             p.ui.ui.window.main
 * optn window.             p.ui.ui.window.optn
 * info window.             p.ui.ui.window.info
 * media window             p.ui.ui.window.media
 */
static void ui_create_ui(KIM * im)
{
    char xmlpath[1024];
    sprintf(xmlpath, "%s\\ui\\main.glade", kim_getstr(im, "s.env.path.moduleDir", knil));
    kstr_subs(xmlpath, '\\', kvfs_path_sep());

    GladeXML *gxml = glade_xml_new(xmlpath, NULL, NULL);
    kim_addptr(im, "p.ui.ui.glade", (kvoid *) gxml, RF_AUTOSET, knil, knil);

    GtkWidget *window_main = glade_xml_get_widget(gxml, "window_main");
    kim_addptr(im, "p.ui.ui.window.main", (kvoid *) window_main, RF_AUTOSET, knil, knil);
    klog(("window_main: %s\n", GTK_OBJECT_TYPE_NAME(window_main)));

    GtkWidget *vbox_main = glade_xml_get_widget(gxml, "winmain_vbox_main");
    klog(("vbox_main: %s\n", GTK_OBJECT_TYPE_NAME(vbox_main)));

    gtk_drag_dest_set(vbox_main, GTK_DEST_DEFAULT_ALL, target_table, n_targets, /* no rootwin */
                      GdkDragAction(GDK_ACTION_COPY | GDK_ACTION_MOVE));
    g_signal_connect(vbox_main, "drag_drop", G_CALLBACK(target_drag_drop), vbox_main);

    g_signal_connect(vbox_main, "drag_data_received", G_CALLBACK(target_drag_data_received), NULL);


    if (0) {
        GtkWidget *button;
        button = gtk_button_new_with_label("xxyyyx");
        //button = gtk_viewport_new(NULL, NULL);//"GTK_WINDOW_TOPLEVEL");
        gtk_box_pack_start(GTK_BOX(vbox_main), button, TRUE, FALSE, 0);

        gtk_drag_source_set(button, GdkModifierType(GDK_BUTTON1_MASK | GDK_BUTTON3_MASK),
                            target_table, n_targets, GdkDragAction(GDK_ACTION_COPY | GDK_ACTION_MOVE));
    }

    GtkWidget *window_info = glade_xml_get_widget(gxml, "window_info");
    kim_addptr(im, "p.ui.ui.window.info", (kvoid *) window_info, RF_AUTOSET, knil, knil);

    GtkWidget *window_media = glade_xml_get_widget(gxml, "window_media");
    kim_addptr(im, "p.ui.ui.window.media", (kvoid *) window_media, RF_AUTOSET, knil, knil);

    // gtk_box_pack_start(GTK_BOX(vbox_main), window_media, TRUE, FALSE, 0);

    GtkWidget *window_pref = glade_xml_get_widget(gxml, "window_pref");
    kim_addptr(im, "p.ui.ui.window.optn", (kvoid *) window_pref, RF_AUTOSET, knil, knil);
    gtk_widget_show(window_pref);

    if (0) {
        GtkWidget *button;
        button = gtk_button_new_with_label("xxyyyx");
        gtk_box_pack_start(GTK_BOX(vbox_main), button, TRUE, TRUE, 0);
        kim_addptr(im, "p.ui.ui.window.optn", (kvoid *) button, RF_AUTOSET, knil, knil);
    }

    GtkWidget *window_tool = glade_xml_get_widget(gxml, "window_tool");
    kim_addptr(im, "p.ui.ui.window.tool", (kvoid *) window_tool, RF_AUTOSET, knil, knil);

    GtkWidget *window_tool_pool = glade_xml_get_widget(gxml, "wintool_viewport_tool_pool");
    kim_addptr(im, "p.ui.ui.window.tool_pool", (kvoid *) window_tool_pool, RF_AUTOSET, knil, knil);

    GtkWidget *window_layout_tool_pool = glade_xml_get_widget(gxml, "wintool_viewport_layout_tool_pool");
    kim_addptr(im, "p.ui.ui.window.layout_tool_pool", (kvoid *) window_layout_tool_pool, RF_AUTOSET, knil, knil);

    glade_xml_signal_autoconnect(gxml);

    glade_xml_signal_connect_data(gxml, "on_winmain_menu_item_about_activate",
                                  G_CALLBACK(on_winmain_menu_item_about_activate), NULL);
    glade_xml_signal_connect_data(gxml, "on_winmain_menu_item_tool_activate",
                                  G_CALLBACK(on_winmain_menu_item_tool_activate), NULL);
    glade_xml_signal_connect_data(gxml, "on_winmain_menu_item_pref_activate",
                                  G_CALLBACK(on_winmain_menu_item_pref_activate), NULL);
}
Ejemplo n.º 7
0
static void fill_tool_window()
{
    GtkWidget *window_tool_pool = (GtkWidget *) kim_getptr(__g_im, "p.ui.ui.window.tool_pool", knil);
    GtkWidget *window_layout_tool_pool = (GtkWidget *) kim_getptr(__g_im, "p.ui.ui.window.layout_tool_pool", knil);
    window_tool_pool = window_layout_tool_pool;

    GtkWidget *tool_box;
    GtkWidget *button;

    char label[22];
    gint i;
    GList *l;
    ToolEntry *te;

    mk_htoolbar(ktrue);
    mk_button_play(ktrue);

    mk_htoolbar(ktrue);
    mk_button_play(ktrue);

    mk_htoolbar(ktrue);
    mk_button_play(ktrue);
    mk_button_play(ktrue);
    mk_button_play(ktrue);
    mk_htoolbar(ktrue);
    mk_htoolbar(ktrue);

    gtk_widget_set_size_request(GTK_WIDGET(window_tool_pool), 200, 200);

    tool_box = glade_palette_box_new();

    /* FIXME: set border other than 0 can make layout mess some time */
    gtk_container_set_border_width(GTK_CONTAINER(tool_box), 0);

    for (l = __g_tool_list; l; l = l->next) {
        te = (ToolEntry *) l->data;
        button = create_tool_widget2(te);

        printf("fill_tool_window: button: %x\n", button);

#if 10                          /* TODO */
        gtk_drag_source_set(button, GdkModifierType(GDK_BUTTON1_MASK | GDK_BUTTON3_MASK),
                            target_table, n_targets, GdkDragAction(GDK_ACTION_COPY | GDK_ACTION_MOVE));
#endif

        g_signal_connect(button, "drag_data_get", G_CALLBACK(source_drag_data_get), te);

        gtk_container_add(GTK_CONTAINER(tool_box), button);
    }

#if 0
    for (i = 0; i < 15; i++) {
        sprintf(label, "NIU-NIU-NIU:%X\n", i);
        button = gtk_button_new_with_label(label);
        button = create_tool_widget();

#if 10                          /* TODO */
        gtk_drag_source_set(button, GdkModifierType(GDK_BUTTON1_MASK | GDK_BUTTON3_MASK),
                            target_table, n_targets, GdkDragAction(GDK_ACTION_COPY | GDK_ACTION_MOVE));
#endif

        gtk_container_add(GTK_CONTAINER(tool_box), button);
    }
#endif

    gtk_container_add(GTK_CONTAINER(window_tool_pool), tool_box);

    gtk_widget_show_all(GTK_WIDGET(window_tool_pool));
}