Misc. questions (and 'GtkSQL' announcement)



  I am writing a query tool for PostgreSQL using Gtk. The home page
for this project is at the following URL :
             http://www.mygale.org/~bbrox/GtkSQL/

  Its main features are :
   -  multiple SQL buffers
   -  SQL keywords, table names and fields autocompletion
   -  easy displaying of tables definitions
   -  exporting of query results

  In writing this application, I had some problems :

   1) I need to have access to the tab labels in a notebook and to
  the widget stored in it. What is the 'correct' thing to do :
     - hope that 'gtk_notebook_get_tab_label',
       'gtk_notebook_get_page', ... will be in a future version of Gtk
     - use GtkNotebook's "insides" to write them yourself (it is what
       I have done).
     - use (for the Widgets stored in the pages) a parallel data
       structure to store them

   2) is it possible with a gdk call to ask the window manager to put
  one window on the foreground ?

   3) how can we create a text zone with a cursor in it ? I needed
  this because I want to be able to do everything (well, almost
  everything) without the mouse. If you need to click on a new text
  zone before you can type in it, it is quite painful. To do this I
  added 'GTK_TEXT(current_query)->has_cursor = TRUE;'
  in my code. It works, but is it as ugly as I think it is :-) ?

   4) to do autocompletion with 'TAB', I wanted to use the
  "key_press_event" signal. But there is apparently a bug in the Text
  zone code. If you compile the following code, type some letters and
  then move with the arrows, the 'gtk_text_get_point' call does NOT
  return the position where the typed character will go...

#include <gtk/gtk.h>

GtkWidget *text;

void test(GtkWidget *widget, GdkEvent *event, gpointer data)
{
  g_print("%d\n", gtk_text_get_point(GTK_TEXT(text)));
}

int main (int argc, char *argv[])
{
  GtkWidget *window, *vbox;

  gtk_init (&argc, &argv);
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  vbox = gtk_vbox_new(FALSE, 0);
  text = gtk_text_new (NULL, NULL);
  gtk_text_set_editable (GTK_TEXT(text), TRUE);
  gtk_signal_connect (GTK_OBJECT (text), "key_press_event",
		      GTK_SIGNAL_FUNC (test), NULL);
  gtk_box_pack_start (GTK_BOX(vbox), text, TRUE, TRUE, 0);
  gtk_container_add (GTK_CONTAINER (window), vbox);
  gtk_widget_show (text);
  gtk_widget_show (vbox);
  gtk_widget_show (window);
  gtk_main ();
  
  return 0;
}

  Well, that's all for the moment :-)

--
  Lionel ULMER (ulmer@email.enst.fr / bbrox@mygale.org)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]