示例#1
0
static gboolean
gda_report_rml_document_run_as_pdf (GdaReportDocument *doc, const gchar *filename, GError **error)
{
	static GMutex init_mutex;
	static gchar *converter = NULL;

	g_return_val_if_fail (GDA_IS_REPORT_RML_DOCUMENT (doc), FALSE);
	g_return_val_if_fail (filename && *filename, FALSE);

	g_mutex_lock (&init_mutex);
	if (!converter) {
		converter = g_find_program_in_path ("trml2pdf.py");
		if (!converter) {
			converter = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, "gda_trml2pdf", "trml2pdf.py", NULL);
			if (!g_file_test (converter, G_FILE_TEST_IS_EXECUTABLE)) {
				g_free (converter);
				converter = NULL;
			}
		}
		if (!converter) {
			g_set_error (error, 0, 0,
				     _("Could not find the '%s' program"), "trml2pdf.py");
			g_mutex_unlock (&init_mutex);
			return FALSE;
		}
	}
	g_mutex_unlock (&init_mutex);

	return _gda_report_document_run_converter_path (doc, filename, converter, "trml2pdf", error);
}
示例#2
0
/**
 * load_help_doc:
 */
static xmlDocPtr
load_help_doc (void)
{
	xmlDocPtr helpdoc = NULL;
	const gchar * const *langs = g_get_language_names ();
	gchar *dirname, *helpfile;
	gint i;
	dirname = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, "gda-sql", "help", NULL);
	for (i = 0; langs[i]; i++) {
		helpfile = g_build_filename (dirname, langs[i], "gda-sql-help.xml", NULL);
		if (g_file_test (helpfile, G_FILE_TEST_EXISTS))
			helpdoc = xmlParseFile (helpfile);
		g_free (helpfile);
		if (helpdoc)
			break;
	}

	if (!helpdoc) {
		/* default to the "C" one */
		helpfile = g_build_filename (dirname, "C", "gda-sql-help.xml", NULL);
		if (g_file_test (helpfile, G_FILE_TEST_EXISTS))
			helpdoc = xmlParseFile (helpfile);
		g_free (helpfile);
	}
	g_free (dirname);
	return helpdoc;
}
示例#3
0
文件: libmain.c 项目: UIKit0/libgda
gchar *
plugin_get_dsn_spec (void)
{
	gchar *ret, *dir;

	dir = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, NULL);
	ret = gda_server_provider_load_file_contents (module_path, dir, "postgres_specs_dsn.xml");
	g_free (dir);
	return ret;
}
示例#4
0
文件: libmain.c 项目: arthurnn/libgda
gchar *
plugin_get_auth_spec (void)
{
	gchar *ret, *dir;

        dir = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, NULL);
        ret = gda_server_provider_load_file_contents (module_path, dir, "sqlcipher_specs_auth.xml");
        g_free (dir);
	if (ret)
		return ret;
	else
		return gda_server_provider_load_resource_contents ("sqlcipher", "sqlcipher_specs_auth.raw.xml");
}
示例#5
0
/* hack to find the directory where Libgdaui's data pictures are stored */
static gchar *
get_data_path ()
{
    gchar *path;

    if (g_file_test ("demos.h", G_FILE_TEST_EXISTS))
        path = g_strdup ("../data");
    else {
        gchar *tmp;
        tmp = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, "pixmaps", "gdaui-generic.png", NULL);
        path = g_path_get_dirname (tmp);
        g_free (tmp);
        if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
            g_free (path);
            path = NULL;
        }
    }

    if (!path)
        path = g_strdup (".");

    return path;
}
示例#6
0
GtkWidget *
provider_config_new (void)
{
	ProviderConfigPrivate *priv;
	GtkWidget *provider;
	GtkWidget *box;
	GtkWidget *image;
	GtkWidget *label;
	GtkWidget *sw;
	gchar *title;
	GdaDataModel *model;

	priv = g_new0 (ProviderConfigPrivate, 1);
	provider = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_widget_show (provider);
        gtk_container_set_border_width (GTK_CONTAINER (provider), 6);
	g_object_set_data_full (G_OBJECT (provider), PROVIDER_CONFIG_DATA, priv,
				(GDestroyNotify) g_free);

	/* title */
	title = g_strdup_printf ("<b>%s</b>\n%s", _("Providers"),
				 _("Installed providers"));
	priv->title = gdaui_bar_new (title);
	g_free (title);

	gchar *path;
	path = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, "pixmaps", "gdaui-generic.png", NULL);
	gdaui_bar_set_icon_from_file (GDAUI_BAR (priv->title), path);
	g_free (path);

	gtk_box_pack_start (GTK_BOX (provider), priv->title, FALSE, FALSE, 0);
	gtk_widget_show (priv->title);

	/* create the provider list */
	sw = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC,
					GTK_POLICY_AUTOMATIC);
	gtk_box_pack_start (GTK_BOX (provider), sw, TRUE, TRUE, 0);

	model = gda_config_list_providers ();
	priv->provider_list = gdaui_raw_grid_new (model);
	g_object_unref (model);
	gdaui_data_proxy_column_set_editable (GDAUI_DATA_PROXY (priv->provider_list), 0, FALSE);
	gdaui_data_selector_set_column_visible (GDAUI_DATA_SELECTOR (priv->provider_list), 2, FALSE);
	g_object_set (G_OBJECT (priv->provider_list), "info-cell-visible", FALSE, NULL);
	gtk_container_add (GTK_CONTAINER (sw), priv->provider_list);
	
	gtk_widget_show_all (sw);

	/* add tip */
	box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	gtk_widget_show (box);
        gtk_container_set_border_width (GTK_CONTAINER (box), 6);
	gtk_box_pack_start (GTK_BOX (provider), box, FALSE, FALSE, 0);

	image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
	gtk_widget_show (image);
	gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);

	label = gtk_label_new (_("Providers are addons that actually implement the access "
				 "to each database using the means provided by each database vendor."));
	gtk_widget_show (label);
	gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
	gtk_box_pack_start (GTK_BOX (box), label, TRUE, FALSE, 0);

	return provider;
}
示例#7
0
int
main (G_GNUC_UNUSED int argc, G_GNUC_UNUSED char** argv)
{
        xmlDocPtr doc;
        xmlNodePtr node;
        gchar *fname;
	xmlNodePtr out_top_node;
	xmlBufferPtr buf;

        fname = g_build_filename (ROOT_DIR, "libgda", FILE_NAME, NULL);
	if (! g_file_test (fname, G_FILE_TEST_EXISTS)) {
		g_free (fname);
		fname = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, FILE_NAME, NULL);
		if (! g_file_test (fname, G_FILE_TEST_EXISTS)) {
			g_print ("Could not find '%s'.\n", FILE_NAME);
			exit (1);
		}
	}

	doc = xmlParseFile (fname);
	if (!doc) {
		g_print ("Missing or malformed file '%s', check your installation", fname);
		g_free (fname);
		exit (1);
        }
	
	node = xmlDocGetRootElement (doc);
	g_free (fname);
	if (strcmp ((gchar *) node->name, "schema")) {
		g_print ("Root node should be <schema>, got <%s>\n", (gchar *) node->name);
		xmlFreeDoc (doc);
		exit (1);
	}

	out_top_node = xmlNewNode (NULL, BAD_CAST "sect2");
	xmlAddChild (out_top_node, xmlNewComment (BAD_CAST 
						  "File generated by the tools/information-schema-doc program from the\n"
						  "libgda/information-schema.xml file,\ndo not modify"));
	xmlNewChild (out_top_node, NULL, BAD_CAST "title", BAD_CAST "Individual table description");
	xmlNewChild (out_top_node, NULL, BAD_CAST "para", BAD_CAST "This section individually describes each table.");
	
	for (node = node->children; node; node = node->next) {
		if (!strcmp ((gchar *) node->name, "table")) {
			xmlNodePtr snode, child, table, row, ref = NULL;
			xmlChar *prop;
			snode = xmlNewChild (out_top_node, NULL, BAD_CAST "sect3", NULL);
			prop = xmlGetProp (node, BAD_CAST "name");
			if (prop) {
				gchar *str;
				str = g_strdup_printf ("is:%s", (gchar *) prop);
				xmlSetProp (snode, BAD_CAST "id", BAD_CAST str);
				g_free (str);

				str = g_strdup_printf ("%s table", (gchar *) prop);
				xmlNewTextChild (snode, NULL, BAD_CAST "title", BAD_CAST str);
				g_free (str);
				xmlFree (prop);
			}
			else
				xmlNewChild (snode, NULL, BAD_CAST "title", BAD_CAST "FIXME: table not named");

			prop = xmlGetProp (node, BAD_CAST "descr");
			if (prop) {
				xmlNewTextChild (snode, NULL, BAD_CAST "para", prop);
				xmlFree (prop);
			}
			table = xmlNewChild (snode, NULL, BAD_CAST "para", BAD_CAST "The following table describes the columns:");
			table = xmlNewChild (table, NULL, BAD_CAST "informaltable", NULL);
			xmlSetProp (table, BAD_CAST "frame", BAD_CAST "all");
			table = xmlNewChild (table, NULL, BAD_CAST "tgroup", NULL);
			xmlSetProp (table, BAD_CAST "cols", BAD_CAST "5");
			xmlSetProp (table, BAD_CAST "colsep", BAD_CAST "1");
			xmlSetProp (table, BAD_CAST "rowsep", BAD_CAST "1");
			xmlSetProp (table, BAD_CAST "align", BAD_CAST "justify");
			
			child = xmlNewChild (table, NULL, BAD_CAST "thead", NULL);
			row = xmlNewChild (child, NULL, BAD_CAST "row", NULL);
			xmlNewChild (row, NULL, BAD_CAST "entry", BAD_CAST "Column name");
			xmlNewChild (row, NULL, BAD_CAST "entry", BAD_CAST "Type");
			xmlNewChild (row, NULL, BAD_CAST "entry", BAD_CAST "Key");
			xmlNewChild (row, NULL, BAD_CAST "entry", BAD_CAST "Can be NULL");
			xmlNewChild (row, NULL, BAD_CAST "entry", BAD_CAST "description");
			table = xmlNewChild (table, NULL, BAD_CAST "tbody", NULL);	
			for (child = node->children; child; child = child->next) {
				if (!strcmp ((gchar *) child->name, "column")) {
					row = xmlNewChild (table, NULL, BAD_CAST "row", NULL);
					
					prop = xmlGetProp (child, BAD_CAST "name");
					xmlNewChild (row, NULL, BAD_CAST "entry", prop ? prop : BAD_CAST "FIXME");
					if (prop) xmlFree (prop);
					
					prop = xmlGetProp (child, BAD_CAST "type");
					xmlNewChild (row, NULL, BAD_CAST "entry", prop ? prop : BAD_CAST "string");
					if (prop) xmlFree (prop);
					
					prop = xmlGetProp (child, BAD_CAST "pkey");
					xmlNewChild (row, NULL, BAD_CAST "entry", 
						     prop && ((*prop == 't') || (*prop == 'T')) ? 
						     BAD_CAST "Yes" : BAD_CAST "");
					if (prop) xmlFree (prop);

					prop = xmlGetProp (child, BAD_CAST "nullok");
					xmlNewChild (row, NULL, BAD_CAST "entry", 
						     prop && ((*prop == 't') || (*prop == 'T')) ? 
						     BAD_CAST "Yes" : BAD_CAST "No");
					if (prop) xmlFree (prop);

					prop = xmlGetProp (child, BAD_CAST "descr");
					xmlNewTextChild (row, NULL, BAD_CAST "entry", prop ? prop : BAD_CAST "");
					if (prop) xmlFree (prop);
				}
				else if (!strcmp ((gchar *) child->name, "fkey")) {
					xmlNodePtr fkey;
					if (!ref) {
						ref = xmlNewChild (snode, NULL, BAD_CAST "para", NULL);
						ref = xmlNewChild (ref, NULL, BAD_CAST "itemizedlist", NULL);
					}
					fkey = xmlNewChild (ref, NULL, BAD_CAST "listitem", NULL);

					prop = xmlGetProp (child, BAD_CAST "ref_table");
					if (prop) {
						gchar *str;
						GString *fk_str = NULL, *ref_pk_str = NULL;
						xmlNodePtr subnode, link;

						fkey = xmlNewChild (fkey, NULL, BAD_CAST "para", NULL);
						
						for (subnode = child->children; subnode; subnode = subnode->next) {
							xmlChar *column, *ref_column;
							if (strcmp ((gchar *) subnode->name, "part")) 
								continue;
							column = xmlGetProp (subnode, BAD_CAST "column");
							if (!column)
								continue;
							if (!fk_str) {
								fk_str = g_string_new ("(");
								ref_pk_str = g_string_new ("(");
							}
							else {
								g_string_append (fk_str, ", ");
								g_string_append (ref_pk_str, ", ");
							}
							g_string_append (fk_str, (gchar *) column);
							ref_column = xmlGetProp (subnode, BAD_CAST "ref_column");
							if (ref_column) {
								g_string_append (ref_pk_str, (gchar *) ref_column);
								xmlFree (ref_column);
							}
							else
								g_string_append (ref_pk_str, (gchar *) column);
							xmlFree (column);
						}
						if (fk_str) {
							g_string_append (fk_str, ") ");
							g_string_append (ref_pk_str, ") ");
						}

						if (fk_str) {
							xmlNodeAddContent (fkey, BAD_CAST fk_str->str);
							g_string_free (fk_str, TRUE);
						}
						xmlNodeAddContent (fkey, BAD_CAST "references ");
						link = xmlNewTextChild (fkey, NULL, BAD_CAST "link", prop);
						str = g_strdup_printf ("is:%s", prop);
						xmlSetProp (link, BAD_CAST "linkend", BAD_CAST str);
						g_free (str);
						if (ref_pk_str) {
							xmlNodeAddContent (fkey, BAD_CAST ref_pk_str->str);
							g_string_free (ref_pk_str, TRUE);
						}
						
						if (prop) xmlFree (prop);
					}
					else
						fkey = xmlNewChild (ref, NULL, BAD_CAST "para", BAD_CAST "FIXME");
				}
			}
			
		}
		else if (!strcmp ((gchar *) node->name, "view")) {
			xmlNodePtr snode, child, para;
			xmlChar *prop;
			snode = xmlNewChild (out_top_node, NULL, BAD_CAST "sect3", NULL);
			prop = xmlGetProp (node, BAD_CAST "name");
			if (prop) {
				gchar *str;
				str = g_strdup_printf ("is:%s", (gchar *) prop);
				xmlSetProp (snode, BAD_CAST "id", BAD_CAST str);
				g_free (str);

				str = g_strdup_printf ("%s view", (gchar *) prop);
				xmlNewTextChild (snode, NULL, BAD_CAST "title", BAD_CAST str);
				g_free (str);
				xmlFree (prop);
			}
			else
				xmlNewChild (snode, NULL, BAD_CAST "title", BAD_CAST "FIXME: view not named");

			prop = xmlGetProp (node, BAD_CAST "descr");
			if (prop) {
				xmlNewTextChild (snode, NULL, BAD_CAST "para", prop);
				xmlFree (prop);
			}
			for (child = node->children; child; child = child->next) {
				if (!strcmp ((gchar *) child->name, "definition")) {
					xmlChar *def;

					def = xmlNodeGetContent (child);
					para = xmlNewChild (snode, NULL, BAD_CAST "para", BAD_CAST "Definition is:");
					para = xmlNewTextChild (para, NULL, BAD_CAST "programlisting", def);
					xmlSetProp (para, BAD_CAST "width", BAD_CAST "80");
					xmlFree (def);
					break;
				}
			}
		}
	}
	xmlFreeDoc (doc);

	buf = xmlBufferCreate();
	xmlNodeDump (buf, NULL, out_top_node, 0, 1);
	if (! g_file_set_contents (OUT_FILE, (gchar*) xmlBufferContent (buf), -1, NULL)) 
		g_print ("Could not write output file '%s'\n", OUT_FILE);
	else
		g_print ("Doc. written to '%s'\n", OUT_FILE);
	xmlBufferFree (buf);
	
	return 0;
}
示例#8
0
static void
run_cc_cb (G_GNUC_UNUSED GtkButton *button, GdauiLogin *login)
{
	gboolean sresult = FALSE;
	GError *lerror = NULL;
	gchar *cmd;

	/* run gda-control-center tool */
#ifdef G_OS_WIN32
#define EXENAME "gda-control-center-" GDA_ABI_VERSION ".exe"
	gchar *argv[] = {EXENAME, NULL};
	cmd = gda_gbr_get_file_path (GDA_BIN_DIR, NULL);
	sresult = g_spawn_async (cmd, argv, NULL, 0, NULL, NULL, NULL, &lerror);
	g_free (cmd);
#else
#define EXENAME "gda-control-center-" GDA_ABI_VERSION
	GAppInfo *appinfo;
	GdkAppLaunchContext *context;
	GdkScreen *screen;
	cmd = gda_gbr_get_file_path (GDA_BIN_DIR, (char *) EXENAME, NULL);
	appinfo = g_app_info_create_from_commandline (cmd,
						      NULL,
						      G_APP_INFO_CREATE_NONE,
						      &lerror);
	g_free (cmd);
	if (!appinfo)
		goto checkerror;

	screen = gtk_widget_get_screen (GTK_WIDGET (login));
	context = gdk_display_get_app_launch_context (gdk_screen_get_display (screen));
	gdk_app_launch_context_set_screen (context, screen);
	sresult = g_app_info_launch (appinfo, NULL, G_APP_LAUNCH_CONTEXT (context), NULL);
	if (! sresult) {
		g_object_unref (appinfo);
		appinfo = g_app_info_create_from_commandline (EXENAME,
							      NULL,
							      G_APP_INFO_CREATE_NONE,
							      NULL);
		if (!appinfo) {
			g_object_unref (context);
			goto checkerror;
		}
		sresult = g_app_info_launch (appinfo, NULL, G_APP_LAUNCH_CONTEXT (context), &lerror);
	}
	g_object_unref (context);
	g_object_unref (appinfo);
#endif /* G_OS_WIN32 */

 checkerror:
	if (!sresult) {
		GtkWidget *msgdialog;
		GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (login));
		if (!gtk_widget_is_toplevel (toplevel))
			toplevel = NULL;
		msgdialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (toplevel), GTK_DIALOG_MODAL,
								GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
								"<b>%s:</b>\n%s",
								_("Could not execute the Database access control center"),
								lerror && lerror->message ? lerror->message : _("No detail"));

		if (lerror)
			g_error_free (lerror);
		gtk_dialog_run (GTK_DIALOG (msgdialog));
		gtk_widget_destroy (msgdialog);
	}
}
示例#9
0
/**
 * browser_connections_list_show
 * @current: (allow-none): a connection to select for displaed properties, or %NULL
 *
 * Creates a new #BrowserConnectionsList widget and displays it.
 * Only one is created and shown (singleton)
 *
 * Returns: the new object
 */
void
browser_connections_list_show (BrowserConnection *current)
{
	if (!_clist) {
		GtkWidget *clist, *sw, *grid, *treeview, *label, *wid;
		gchar *str;
		clist = GTK_WIDGET (g_object_new (BROWSER_TYPE_CONNECTIONS_LIST, 
						  NULL));
		gtk_window_set_default_size ((GtkWindow*) clist, 550, 450);
		_clist = (BrowserConnectionsList *) clist;
		gtk_window_set_title (GTK_WINDOW (clist), _("Opened connections"));
		gtk_container_set_border_width (GTK_CONTAINER (clist), 6);
		g_signal_connect (G_OBJECT (clist), "delete-event",
				  G_CALLBACK (delete_event), NULL);

		str = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, "pixmaps", "gda-browser-connected.png", NULL);
		gtk_window_set_icon_from_file (GTK_WINDOW (clist), str, NULL);
		g_free (str);

		/* table layout */
		grid = gtk_grid_new ();
		gtk_grid_set_column_spacing (GTK_GRID (grid), 10);
		gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
		gtk_container_add (GTK_CONTAINER (clist), grid);
		_clist->priv->layout_grid = GTK_GRID (grid);

		/* image and explaining label */
		GtkWidget *hbox;
		hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
		gtk_grid_attach (GTK_GRID (grid), hbox, 0, 0, 3, 1);

		str = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, "pixmaps", "gda-browser-connected-big.png", NULL);
		wid = gtk_image_new_from_file (str);
		g_free (str);
		gtk_box_pack_start (GTK_BOX (hbox), wid, FALSE, FALSE, 0);

		wid = gtk_label_new ("");
		str = g_strdup_printf ("<big><b>%s:\n</b></big>%s",
				       _("List of opened connections"),
				       "The connection properties are read-only.");
		gtk_label_set_markup (GTK_LABEL (wid), str);
		g_free (str);
		gtk_misc_set_alignment (GTK_MISC (wid), 0., -1);
		gtk_box_pack_start (GTK_BOX (hbox), wid, TRUE, FALSE, 6);

		/* left column */		
		label = gtk_label_new ("");
		str = g_strdup_printf ("<b>%s:</b>", _("Connections"));
		gtk_label_set_markup (GTK_LABEL (label), str);
		g_free (str);
		gtk_misc_set_alignment (GTK_MISC (label), 0., -1);
		gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1);

		sw = gtk_scrolled_window_new (NULL, NULL);
		gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
						     GTK_SHADOW_ETCHED_IN);
		gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
						GTK_POLICY_NEVER,
						GTK_POLICY_AUTOMATIC);
		gtk_grid_attach (GTK_GRID (grid), sw, 0, 2, 1, 2);
		
		/* connection's properties */
		label = gtk_label_new ("");
		str = g_strdup_printf ("<b>%s:</b>", _("Connection's properties"));
		gtk_label_set_markup (GTK_LABEL (label), str);
		g_free (str);
		gtk_misc_set_alignment (GTK_MISC (label), 0., -1);
		gtk_grid_attach (GTK_GRID (grid), label, 1, 1, 1, 1);

		/* buttons at the bottom*/
		GtkWidget *bbox, *button;
		bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
		gtk_grid_attach (GTK_GRID (grid), bbox, 1, 3, 1, 1);
		gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_END);
		button = gtk_button_new_with_label (_("Close connection"));
		gtk_box_pack_start (GTK_BOX (bbox), button, TRUE, TRUE, 0);
		g_signal_connect (button, "clicked",
				  G_CALLBACK (connection_close_cb), clist);
		gtk_widget_set_tooltip_text (button, _("Close selected connection"));
		_clist->priv->close_cnc_button = button;

		button = gtk_button_new_with_label (_("Connect"));
		gtk_box_pack_start (GTK_BOX (bbox), button, TRUE, TRUE, 0);
		g_signal_connect (button, "clicked",
				  G_CALLBACK (connection_new_cb), clist);
		gtk_widget_set_tooltip_text (button, _("Open a new connection"));

		/* GtkTreeModel and view */
		GtkListStore *store;
		store = gtk_list_store_new (NUM_COLUMNS,
					    BROWSER_TYPE_CONNECTION);
		
		treeview = browser_make_tree_view (GTK_TREE_MODEL (store));
		_clist->priv->treeview = GTK_TREE_VIEW (treeview);
		gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
		gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (treeview), TRUE);
		g_object_unref (G_OBJECT (store));
		gtk_container_add (GTK_CONTAINER (sw), treeview);

		/* treeview's columns */
		GtkTreeViewColumn *col;
		GtkCellRenderer *cell;
		cell = gtk_cell_renderer_text_new ();
		col = gtk_tree_view_column_new ();
		gtk_tree_view_column_pack_start (col, cell, TRUE);
		gtk_tree_view_column_set_cell_data_func (col, cell, 
							 (GtkTreeCellDataFunc) cell_name_data_func, NULL, NULL);
		gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), col);
		
		/* selection handling */
		GtkTreeSelection *select;
		select = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
		gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE);
		g_signal_connect (G_OBJECT (select), "changed",
				  G_CALLBACK (selection_changed_cb), clist);
		

		/* initial filling */
		GSList *connections, *list;
		connections =  browser_core_get_connections ();
		for (list = connections; list; list = list->next)
			connection_added_cb (browser_core_get(), BROWSER_CONNECTION (list->data),
					     (BrowserConnectionsList*) clist);
		g_slist_free (connections);

		_clist->priv->cnc_added_sigid = g_signal_connect (browser_core_get (), "connection-added",
								  G_CALLBACK (connection_added_cb), _clist);
		_clist->priv->cnc_removed_sigid = g_signal_connect (browser_core_get (), "connection-removed",
								    G_CALLBACK (connection_removed_cb), _clist);
		
		gtk_widget_show_all (clist);
	}
	else {
		gtk_window_set_screen (GTK_WINDOW (_clist), gdk_screen_get_default ()); /* FIXME: specify GdkScreen */
		gtk_window_present (GTK_WINDOW (_clist));
	}

	if (current) {
		GtkTreeModel *model;
		GtkTreeIter iter;
		model = gtk_tree_view_get_model (GTK_TREE_VIEW (_clist->priv->treeview));
		if (gtk_tree_model_get_iter_first (model, &iter)) {
			do {
				BrowserConnection *bcnc;
				gtk_tree_model_get (model, &iter, COLUMN_BCNC, &bcnc, -1);
				g_object_unref (bcnc);
				if (bcnc == current) {
					GtkTreeSelection *select;
					select = gtk_tree_view_get_selection (GTK_TREE_VIEW (_clist->priv->treeview));
					gtk_tree_selection_select_iter (select, &iter);
					break;
				}
			} while (gtk_tree_model_iter_next (model, &iter));
		}
	}
	else {
		/* select the 1st available */
		GtkTreeModel *model;
		GtkTreeIter iter;
		model = gtk_tree_view_get_model (GTK_TREE_VIEW (_clist->priv->treeview));
		if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter)) {
			GtkTreeSelection *select;
                        select = gtk_tree_view_get_selection (GTK_TREE_VIEW (_clist->priv->treeview));	
			gtk_tree_selection_select_iter (select, &iter);
		}
	}
}
示例#10
0
gint 
main (int argc, char **argv) {
	gchar *xml_dir;
	GOptionContext *context;
	GError *error = NULL;

	context = g_option_context_new (_("Gda server operations list"));
        g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
        if (!g_option_context_parse (context, &argc, &argv, &error)) {
                g_warning ("Can't parse arguments: %s", error->message);
		return 1;
        }
        g_option_context_free (context);

	gda_init ();
	xml_dir = gda_gbr_get_file_path (GDA_DATA_DIR, "libgda-6.0", NULL);
	g_print (_("Using XML descriptions in %s\n"), xml_dir);
	if (prov)
		g_print ("For provider %s\n", prov);

	if (prov) {
		prov_obj = gda_config_get_provider (prov, &error);
		if (!prov_obj) {
			g_print (_("Could not create provider object: %s\n"), 
				 error && error->message ? error->message : _("No detail"));
			return 1;
		}
	}

	if (list_ops) {
		GdaServerOperationType type;
		if (prov)
			g_print (_("Existing operation types for provider '%s':\n"), prov);
		else
			g_print (_("Existing operation types:\n"));
		for (type = GDA_SERVER_OPERATION_CREATE_DB; type < GDA_SERVER_OPERATION_LAST; type++) {
			if (! prov_obj ||
			    (prov_obj && gda_server_provider_supports_operation (prov_obj, NULL, type, NULL)))
				g_print ("%s\n", gda_server_operation_op_type_to_string (type));
		}
		return 0;
	}

	GdaServerOperationType type;
	for (type = GDA_SERVER_OPERATION_CREATE_DB; type != GDA_SERVER_OPERATION_LAST; type++) {
		xmlDocPtr doc;
		GError *error = NULL;
		gboolean op_supported;

		if (op && strcmp (op, gda_server_operation_op_type_to_string (type)))
			continue;

		g_print (_("Description for type: %s\n"), gda_server_operation_op_type_to_string (type));
		doc = merge_specs (xml_dir, type, &op_supported, &error);
		if (doc) {
			if (out_tree) {
				GdaTree *tree;
				GdaTreeManager *mgr;

				tree = gda_tree_new ();
				mgr = gda_tree_mgr_xml_new (xmlDocGetRootElement (doc), "prov_name|id|name|gdatype|node_type|descr");
				gda_tree_add_manager (tree,  mgr);
				gda_tree_manager_add_manager (mgr, mgr);
				g_object_unref (mgr);
				gda_tree_update_all (tree, NULL);
				gda_tree_dump (tree, NULL, NULL);
				g_object_unref (tree);
			}
			else {
				xmlChar *buf;
				gint len;
				xmlKeepBlanksDefault (0);
				xmlDocDumpFormatMemory (doc, &buf, &len, 1);
				g_print ("%s\n", buf);
				xmlFree (buf);
			}
			xmlFreeDoc (doc);
		}
		else {
			if (!op_supported)
				g_print (_("Operation not supported\n"));
			else
				g_print (_("Error: %s\n"), error && error->message ? error->message : _("No detail"));
			if (error)
				g_error_free (error);
		}
	}
	g_free (xml_dir);

	return 0;
}
示例#11
0
void
browser_stock_icons_init (void)
{
	GtkIconFactory *factory;
	GtkIconSet *icon_set;
	GtkIconSource *icon_source;
	int i;

	const char *icon_theme_items[] =
	{
		STOCK_NEW_WINDOW,
		STOCK_ADD_BOOKMARK,
	};

	static const GtkStockItem items[] =
	{
		{ BROWSER_STOCK_HISTORY, N_("History"), 0, 0, NULL },
		{ BROWSER_STOCK_BOOKMARKS, N_("Bookmarks"), 0, 0, NULL },
		{ BROWSER_STOCK_BEGIN, N_("Begin"), 0, 0, NULL },
		{ BROWSER_STOCK_COMMIT, N_("Commit"), 0, 0, NULL },
		{ BROWSER_STOCK_ROLLBACK, N_("Rollback"), 0, 0, NULL },
		{ BROWSER_STOCK_BUILDER, N_("Builder"), 0, 0, NULL },
		{ BROWSER_STOCK_LDAP_ENTRIES, N_("Ldap entries"), 0, 0, NULL },
		{ BROWSER_STOCK_TABLE_ADD, N_("Add table"), 0, 0, NULL},
		{ BROWSER_STOCK_GRID, N_("Grid"), 0, 0, NULL},
		{ BROWSER_STOCK_FORM, N_("Form"), 0, 0, NULL},
	};

	factory = gtk_icon_factory_new ();

	for (i = 0; i < (int) G_N_ELEMENTS (items); i++)
	{
		icon_source = gtk_icon_source_new ();
		gtk_icon_source_set_icon_name (icon_source, items[i].stock_id);

		icon_set = gtk_icon_set_new ();
		gtk_icon_set_add_source (icon_set, icon_source);
		gtk_icon_source_free (icon_source);

		gtk_icon_factory_add (factory, items[i].stock_id, icon_set);
		gtk_icon_set_unref (icon_set);
	}

	gtk_stock_add_static (items, G_N_ELEMENTS (items));

	for (i = 0; i < (int) G_N_ELEMENTS (icon_theme_items); i++)
	{
		icon_source = gtk_icon_source_new ();
		gtk_icon_source_set_icon_name (icon_source, icon_theme_items[i]);

		icon_set = gtk_icon_set_new ();
		gtk_icon_set_add_source (icon_set, icon_source);
		gtk_icon_source_free (icon_source);

		gtk_icon_factory_add (factory, icon_theme_items[i], icon_set);
		gtk_icon_set_unref (icon_set);
	}

	gtk_icon_factory_add_default (factory);
	g_object_unref (factory);

	/* GtkIconTheme will then look in Browser custom hicolor dir
	 * for icons as well as the standard search paths
	 */
	/* FIXME: multi-head! */
	gchar *path;
	path = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, "icons", NULL);
	gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), path);
	g_free (path);
}