dnd bug?: dragging from clist causes selection
- From: Todd Dukes <tdukes ibmoto com>
- To: gtk <gtk-list redhat com>, "gtkmm modeemi cs tut fi" <gtkmm modeemi cs tut fi>
- Subject: dnd bug?: dragging from clist causes selection
- Date: Fri, 08 Jan 1999 16:29:39 -0600
The short program below creates a clist and sets it
as a drag source.
Open the list and scroll down about midway. Do a short drag.
The item at the top of the window becomes selected. Sometimes
I have seen a short drag actually scroll the window to the top
or bottom of the tree.
The program is for gtk--. But if someone would like I will try to
convert it to C.
Todd.
--
==============================================================
| Todd Dukes E-MAIL: tdukes@ibmoto.com |
| Motorola Somerset Phone: (512) 424-8008 |
| MS OE70 |
| 6300 Bridgepoint Parkway Building #3 |
| Austin, Texas 78730 |
==============================================================
/*
g++ -o ctreeTest -I. `gtk-config --cflags` `gtk-config --libs` -lgtkmm-1.1 ctreeTest.C
*/
#include <stream.h>
#include <gdk/gdkx.h>
#include <gtk--.h>
#include <string>
#include <list>
#include <set>
typedef list<string> StringL;
const int numberOfColumns = 3;
const int columnWithTree = 0;
gchar *titles[] = { "tree title 1",
"tree title 2",
"tree title 3" };
enum { TARGET_MACRO_ITEMS};
static GtkTargetEntry gte = { "macro items",
0, TARGET_MACRO_ITEMS};
class MyWindow : public Gtk_Window {
public:
MyWindow();
private:
Gtk_VBox vbox;
Gtk_ScrolledWindow scroller;
Gtk_CTree ctree;
Gtk_Button b;
};
MyWindow::MyWindow():
ctree( numberOfColumns, columnWithTree, titles),
b("Quit")
{
set_title("ctree test");
set_usize(300,400);
vbox.pack_start(scroller);
scroller.add(&ctree);
scroller.show();
ctree.show();
vbox.pack_start(b,false,false,false);
b.show();
connect_to_method( b.clicked, Gtk_Main::instance(), &Gtk_Main::quit);
ctree.drag_source_set( GDK_BUTTON1_MASK, // start_button_mask GdkModifierType
>e, // targets (GtkTargetEntry *)
1, // n_targets (gint)
GDK_ACTION_COPY // actions (GdkDragAction)
);
const char *text[3];
char buf1[100];
char buf2[100];
char buf3[100];
sprintf(buf1, "root");
sprintf(buf2, "2nd col");
sprintf(buf3, "3rd col");
text[0] = buf1;
text[1] = buf2;
text[2] = buf3;
Gtk_CTreeNode node = ctree.insert_node( Gtk_CTreeNode(0), Gtk_CTreeNode(0), text,
(guint8) 0,
(GdkPixmap*) 0,
(GdkPixmap*) 0,
(GdkPixmap*) 0,
(GdkPixmap*) 0,
false, false);
ctree.set_selection_mode(GTK_SELECTION_MULTIPLE);
for ( int i = 1; i < 100; i++) {
sprintf(buf1, "item %d" , i);
sprintf(buf2, "2nd col");
sprintf(buf3, "3rd col");
text[0] = buf1;
text[1] = buf2;
text[2] = buf3;
ctree.insert_node( node, Gtk_CTreeNode(0), text,
(guint8) 0,
(GdkPixmap*) 0,
(GdkPixmap*) 0,
(GdkPixmap*) 0,
(GdkPixmap*) 0,
true, false);
}
add(&vbox);
vbox.show();
}
int main(int argc, char *argv[]) {
Gtk_Main m(&argc, &argv);
MyWindow myWindow;
/* MyWindow */
myWindow.show();
m.run();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]