We now properly obtain the selection and report key presses. Much more
wiring up to be done. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1332 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
//
|
//
|
||||||
// $Id: lookuplet.cc,v 1.1 2003/11/28 21:34:59 mdb Exp $
|
// $Id: lookuplet.cc,v 1.2 2003/11/30 23:50:18 mdb Exp $
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
#include <gtk/gtk.h>
|
||||||
#include <libgnomemm/main.h>
|
#include <libgnomemm/main.h>
|
||||||
#include <libgnomeuimm/init.h>
|
#include <libgnomeuimm/init.h>
|
||||||
// #include <bonobomm/widgets/wrap_init.h>
|
// #include <bonobomm/widgets/wrap_init.h>
|
||||||
@@ -16,13 +17,21 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
bool lookuplet::on_query_key_press_event (GdkEventKey *ev)
|
static void got_clip_text (
|
||||||
|
GtkClipboard* clipboard, const gchar* text, gpointer data)
|
||||||
{
|
{
|
||||||
|
((lookuplet*)data)->on_clip_text_received(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool lookuplet::on_query_key_press_event (GdkEventKey* ev)
|
||||||
|
{
|
||||||
|
printf("key pressed %d %d\n", ev->type, ev->keyval);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lookuplet::on_query_selection_received (GtkSelectionData *data, guint time)
|
void lookuplet::on_clip_text_received (const gchar* text)
|
||||||
{
|
{
|
||||||
|
_query->set_text(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lookuplet::on_prefs_clicked ()
|
void lookuplet::on_prefs_clicked ()
|
||||||
@@ -39,16 +48,18 @@ bool Gtk::Widget::on_delete_event (GdkEventAny* event)
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main (int argc, char** argv)
|
||||||
{
|
{
|
||||||
Gnome::Main m(PACKAGE, VERSION, Gnome::UI::module_info_get(), argc, argv);
|
Gnome::Main m(PACKAGE, VERSION, Gnome::UI::module_info_get(), argc, argv);
|
||||||
// Gnome::Bonobo::wrap_init();
|
// Gnome::Bonobo::wrap_init();
|
||||||
|
|
||||||
lookuplet *lookuplet = new class lookuplet();
|
lookuplet* lookuplet = new class lookuplet();
|
||||||
// binding *binding = new class binding();
|
// binding *binding = new class binding();
|
||||||
// about *about = new class about();
|
// about *about = new class about();
|
||||||
// properties *properties = new class properties();
|
// properties *properties = new class properties();
|
||||||
|
|
||||||
|
GtkClipboard* clip = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
|
||||||
|
gtk_clipboard_request_text(clip, &got_clip_text, lookuplet);
|
||||||
m.run(*lookuplet);
|
m.run(*lookuplet);
|
||||||
|
|
||||||
delete lookuplet;
|
delete lookuplet;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: lookuplet.hh,v 1.1 2003/11/28 21:34:59 mdb Exp $
|
// $Id: lookuplet.hh,v 1.2 2003/11/30 23:50:18 mdb Exp $
|
||||||
|
|
||||||
#ifndef _LOOKUPLET_HH
|
#ifndef _LOOKUPLET_HH
|
||||||
#include "lookuplet_glade.hh"
|
#include "lookuplet_glade.hh"
|
||||||
@@ -9,9 +9,10 @@ class lookuplet : public lookuplet_glade
|
|||||||
{
|
{
|
||||||
friend class lookuplet_glade;
|
friend class lookuplet_glade;
|
||||||
bool on_query_key_press_event(GdkEventKey *ev);
|
bool on_query_key_press_event(GdkEventKey *ev);
|
||||||
void on_query_selection_received(GtkSelectionData *data, guint time);
|
|
||||||
void on_prefs_clicked();
|
void on_prefs_clicked();
|
||||||
void exit_lookuplet();
|
void exit_lookuplet();
|
||||||
|
public:
|
||||||
|
void on_clip_text_received(const gchar* text);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ lookuplet_glade::lookuplet_glade(
|
|||||||
mainbox->show();
|
mainbox->show();
|
||||||
lookuplet->show();
|
lookuplet->show();
|
||||||
_query->signal_key_press_event().connect(SigC::slot(*this, &lookuplet_glade::on_query_key_press_event));
|
_query->signal_key_press_event().connect(SigC::slot(*this, &lookuplet_glade::on_query_key_press_event));
|
||||||
_query->signal_selection_received().connect(SigC::slot(*this, &lookuplet_glade::on_query_selection_received), true);
|
|
||||||
prefs->signal_clicked().connect(SigC::slot(*this, &lookuplet_glade::on_prefs_clicked));
|
prefs->signal_clicked().connect(SigC::slot(*this, &lookuplet_glade::on_prefs_clicked));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ protected:
|
|||||||
~lookuplet_glade();
|
~lookuplet_glade();
|
||||||
private:
|
private:
|
||||||
virtual bool on_query_key_press_event(GdkEventKey *ev) = 0;
|
virtual bool on_query_key_press_event(GdkEventKey *ev) = 0;
|
||||||
virtual void on_query_selection_received(GtkSelectionData *selection_data,guint time) = 0;
|
|
||||||
virtual void on_prefs_clicked() = 0;
|
virtual void on_prefs_clicked() = 0;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user