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

Re: c++ and gtk



Matt Adam wrote:
> 
> > can a c++ app use straight gtk? or does it have to use a wrapper like
> > gtk--?
> 
> it can use straight gtk (i've done so several times).  The only thing you
> have to keep in mind is that you can't use member functions as callbacks,
> since they'll be called with C-linking.  Your member function will be
> expecting the this pointer, won't get it, and all hell will break loose on
> your stack.
> 

Ok, but they can use 'static methods' as callbacks, i.e.:

class Dialog {
public:
  Dialog();
  ~Dialog() { gtk_widget_destroy(el_dialogo); }

  bool modal();
  virtual void mostrar();
  virtual void ocultar();

protected:
  GtkWidget *el_dialogo;
  GtkWidget *w_boton_aceptar;
  GtkWidget *w_boton_cancelar;
  GtkTooltips *tooltips;
  GdkColor fondo_tooltip, texto_tooltip;
  bool resultado; // Ok: true , Cancel: false

  // mine
  static bool cerrar_ventana(GtkWidget *w, gpointer p) { return true; }

  // from glade...
  static GtkWidget *get_widget(GtkWidget *widget, gchar *widget_name);
  static void set_notebook_tab (GtkWidget *notebook, gint page_num,
                                GtkWidget *widget);

  // mine
  static void boton_aceptar_pulsado(GtkWidget *w, gpointer p);
  static void boton_cancelar_pulsado(GtkWidget *w, gpointer p);

  ...

Hope this helps you.

A. Corbi.



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