Re: [gnome-db] getting GnomeDb widgets from Glade - FOUND PROBLEM



Marius Andreiana <mandreiana rdslink ro> writes:

> On Sat, 2003-12-06 at 15:33, Frédéric Logier wrote:
>> Sorry but i use glade_xml_get_widget to load a GnomeDbGrid and it
>> works perfectly. I populate it with a gnome_db_grid_set_model().
> Could you please give us the complete example? Source code + glade.
> It's in C?

Hi,

yes i use C. I can't paste to you all the source code, but this sample
will be enough.



/********* Interface.h *******
typedef struct
{
....

  GtkWidget *customer_grid;
....
}
Interface;
/****************************/



/********** Interface.c *************/
extern Interface gism_widget;

void gism_widget_load (GladeXML *glade_xml, gchar *glade_widget, GtkWidget **gism_widget) {
  gchar *msg_error;

  *gism_widget =  glade_xml_get_widget (glade_xml, glade_widget);

  if (!*gism_widget) {
    msg_error = g_strconcat ("error loading ", glade_widget, " widget", NULL);
    gism_gui_error(msg_error);
  }
}
/*****************************************/



/* somewhere in main */
...

Interface gism_widget;

/* load the interface */
gui_glade_xml = glade_xml_new(DATADIR "gism.glade", "main", NULL);
gism_widget_load (gui_glade_xml, "dbgrid_customer", &gism_widget.customer_grid);

...

/**********************/




// Sql execute command based on http://www.gnome-db.org/docs/libgda/main_example.html


gboolean execute_sql_command (GdaConnection *connection, const gchar * buffer)
{
  GdaCommand *command;
  GList *list;
  GList *node;
  gboolean errors=FALSE;
  GdaDataModel *dm;
  
  GtkTreeModel *model;

  
  command = gda_command_new (buffer, GDA_COMMAND_TYPE_SQL, GDA_COMMAND_OPTION_STOP_ON_ERRORS);
  list = gda_connection_execute_command (connection, command, NULL);
  if (list!=NULL)
    for (node=g_list_first(list); node != NULL; node=g_list_next(node))
      {
	dm=(GdaDataModel *) node->data;
	if (dm == NULL)
	  {
	    errors=TRUE;
	    get_errors (connection);
	  }
	else
	  {
	    //show_table (dm);
	    gnome_db_grid_set_model (GNOME_DB_GRID(gism_widget.customer_grid), dm);
	    g_object_unref(dm);
	    gnome_db_grid_set_title (GNOME_DB_GRID(gism_widget.customer_grid), "Customer");
	    gnome_db_grid_set_show_title (GNOME_DB_GRID(gism_widget.customer_grid), TRUE);

	  }
      }
  else
    {
      errors=TRUE;
    }
  gda_command_free (command);
  
  return (errors);
}
          


Attachment: gism.glade
Description: Binary data

-- 
fred taonix net
Taonix


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