Re: [gnome-db] Gnome-DB SQL Window syntax hi-lighting of keywordsRo



Rodrigo,

Wow!  That easy?  Hmmm...

Warning, long-winded reply ahead... :-)

Since I was able to put the SQL editor into a new widget.  Is it okay if
I do the same for the output text widget that I'm working on for the SQL
Window?

For the text output widget, I was able to get it working, but there were
some problems I am having.

One of the problems has to do with GConf.  Sometimes, the keys just
reset themselves to 0, or they disappear.  This baffles me.  What am I
doing wrong?

In gnome-db's config.c:
if (!gda_config_has_key (SQL_WINDOW_CONFIG_RESULTSET_WIDGET))
	gda_config_set_int (SQL_WINDOW_CONFIG_RESULTSET_WIDGET,
		0);

Here is the define in gnome-db's gnome-db-defs.h

#define
SQL_WINDOW_CONFIG_RESULTSET_WIDGET
"/apps/gnome-db/SqlWindow/ResultSetWidget"

When creating the SQL Window, I use the following code to get the
setting:
	sql_view->priv->resultset_widget_setting = 
		gda_config_get_int (
			SQL_WINDOW_CONFIG_RESULTSET_WIDGET );

And based on that setting, I either use the grid widget or the text
output widget for display a result set in the SQL Window.

On another note, in the Settings dialog, I am trying to create a tab for
the Database tab's SQL Window settings.  What is the best way to do
this?

In gnome-db-shell-settings.c, I added database_sqlwindow_resultset
as a setting for which output widget to use.
database_sqlwindow_resultset
is a checkbox widget just like general_save_window_pos is.

struct _GnomeDbShellSettingsPrivate {
	GHashTable *loaded_widgets;
	GnomeDbShell *shell;
	GtkWidget *toolbar;
	GtkWidget *notebook;

	/* General tab widgets */
	GtkWidget *general_save_window_pos;

	/* Database tab widgets */
	GtkWidget *database_sqlwindow_ressultset;

};

In the callback for the shortcut (fancy tabbed bar on the left that
looks like the bar used in evolution), I added beginnings of some code:
static void
shortcut_button_clicked_cb (GnomeDbShortcut *shortcut,
			    const gchar *label,
			    const gchar *tooltip,
			    gpointer user_data)
{
	GnomeDbShellSettings * settings;
	gpointer *gp;
	GtkWidget *table;

        if(!user_date)
		return;
	if(!label)
		return;

	settings = (GnomeDbShellSettings *) user_date;

	gp = g_hash_table_lookup(settings->priv->loaded_widgets, label);

	if(!gp)
		return;

	table = (GtkWidget *) gp;

 	/* TODO: enable a table or disable a table */
    /*
     *	The table's are defined in another function.  Each table
     *  encapsulates various widgets for a settings tab.
     */
}

static void
gnome_db_shell_settings_init (GnomeDbShellSettings *settings,
			      GnomeDbShellSettingsClass *klass)
{
	GtkWidget *paned;
	GtkWidget *toolbar;
	GtkWidget *table;

	g_return_if_fail (GNOME_DB_IS_SHELL_SETTINGS (settings));

	/* allocate internal structure */
	settings->priv = g_new0 (GnomeDbShellSettingsPrivate, 1);
	settings->priv->shell = NULL;
	settings->priv->loaded_widgets = g_hash_table_new (g_str_hash,
g_str_equal);

	/* set up widgets */
	paned = gnome_db_new_hpaned_widget ();
	gtk_box_pack_start (GTK_BOX (settings), paned, TRUE, TRUE, 0);

	settings->priv->toolbar = gnome_db_shortcut_new ();
	gtk_paned_add1 (GTK_PANED (paned), settings->priv->toolbar);
	add_components_to_shortcut (settings);
	gtk_widget_show (settings->priv->toolbar);

	settings->priv->notebook = gnome_db_new_notebook_widget ();
	gtk_notebook_set_show_tabs (GTK_NOTEBOOK (settings->priv->notebook),
FALSE);
	gtk_notebook_set_show_border (GTK_NOTEBOOK (settings->priv->notebook),
FALSE);
	gtk_paned_add2 (GTK_PANED (paned), settings->priv->notebook);

	/* General tab */
	table = gnome_db_new_table_widget (10, 4, FALSE);

	settings->priv->general_save_window_pos =
gnome_db_new_check_button_widget (
		_("Save window position"));
	gtk_toggle_button_set_active (
		GTK_TOGGLE_BUTTON (settings->priv->general_save_window_pos),
		gda_config_get_boolean (GNOME_DB_SHELL_CONFIG_SAVE_WINDOW_POS));
	gtk_table_attach (GTK_TABLE (table),
settings->priv->general_save_window_pos,
			  0, 1, 0, 1, GTK_FILL, GTK_FILL, 2, 2);

	gtk_widget_show(table);
	gtk_notebook_append_page (GTK_NOTEBOOK (settings->priv->notebook),
				  table, gtk_label_new (_("General")));

	g_hash_table_insert (settings->priv->loaded_widgets, g_strdup
(_("General")), table);

	/* Database tab */
	table = gnome_db_new_table_widget (10, 4, FALSE);

	settings->priv->database_sqlwindow_ressultset =
gnome_db_new_check_button_widget (
		_("Out instead of Grid"));
	gtk_toggle_button_set_active (
		GTK_TOGGLE_BUTTON (settings->priv->database_sqlwindow_ressultset),
		gda_config_get_boolean (GNOME_DB_SHELL_CONFIG_SAVE_WINDOW_POS));
	gtk_table_attach (GTK_TABLE (table),
settings->priv->database_sqlwindow_ressultset,
			  0, 1, 0, 1, GTK_FILL, GTK_FILL, 2, 2);
	gtk_widget_show(table);
	gtk_notebook_append_page (GTK_NOTEBOOK (settings->priv->notebook),
				  table, gtk_label_new (_("Database")));

	g_hash_table_insert (settings->priv->loaded_widgets, g_strdup
(_("Database")), table);

}

On Fri, 2002-03-22 at 11:46, Rodrigo Moya wrote:
> On Fri, 2002-03-22 at 17:11, Daniel Morgan wrote:
> > The SQL Editor is working now, and I have put it into a new GTK 2.0
> > widget named GnomeDbSqlEditor. 
> > 
> > Now, how do I put it into libgnomedb?
> > 
> * add the files (.c and .h) to libgnomedb/libgnomedb
> * add them to libgnomedb/Makefile.am (in _HEADERS and _SOURCES)
> * #include the new .h in libgnomedb/libgnomedb.h
> 
> and that's all





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