Ejemplo n.º 1
0
GtkWidget *
do_provider_sel (GtkWidget *do_widget)
{  
	if (!window) {
		GtkWidget *vbox, *psel, *label;

		window = gtk_dialog_new_with_buttons ("GdauiProviderSelector",
						      GTK_WINDOW (do_widget),
						      0,
						      GTK_STOCK_CLOSE,
						      GTK_RESPONSE_NONE,
						      NULL);
		gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
		g_signal_connect (window, "response",
				  G_CALLBACK (gtk_widget_destroy), NULL);
		g_signal_connect (window, "destroy",
				  G_CALLBACK (gtk_widget_destroyed), &window);
		
		vbox = gtk_dialog_get_content_area (GTK_DIALOG (window));

		/* Create the widget */
		label = gtk_label_new ("Provider selector:");
		gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

		psel = gdaui_provider_selector_new ();
		gtk_box_pack_start (GTK_BOX (vbox), psel, FALSE, FALSE, 0);
		g_signal_connect (psel, "selection-changed",
				  G_CALLBACK (selection_changed_cb), NULL);
	}

	gboolean visible;
	g_object_get (G_OBJECT (window), "visible", &visible, NULL);
	if (!visible)
		gtk_widget_show_all (window);
	else {
		gtk_widget_destroy (window);
		window = NULL;
	}

	return window;
}
Ejemplo n.º 2
0
static void
gdaui_dsn_editor_init (GdauiDsnEditor *config, G_GNUC_UNUSED GdauiDsnEditorClass *klass)
{
	GtkWidget *grid;
	GtkWidget *label;
	GtkWidget *exp;
	gchar *str;

	g_return_if_fail (GDAUI_IS_DSN_EDITOR (config));

	gtk_orientable_set_orientation (GTK_ORIENTABLE (config), GTK_ORIENTATION_VERTICAL);

	/* allocate private structure */
	config->priv = g_new0 (GdauiDsnEditorPrivate, 1);
	config->priv->dsn_info = g_new0 (GdaDsnInfo, 1);
	config->priv->no_change_signal = TRUE;

	/* data source's name and icon */
	GtkWidget *hbox_header;
	hbox_header = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_box_pack_start (GTK_BOX (config), hbox_header, FALSE, FALSE, 6);
	config->priv->icon = gtk_image_new ();
	gtk_widget_set_size_request (config->priv->icon, -1, SUPPORT_ICON_SIZE);
	gtk_box_pack_start (GTK_BOX (hbox_header), config->priv->icon, FALSE, FALSE, 0);
	config->priv->wname = gtk_label_new ("");
	gtk_box_pack_start (GTK_BOX (hbox_header), config->priv->wname, FALSE, FALSE, 10);

	GtkWidget *menu_button;
	menu_button = gtk_menu_button_new ();
	gtk_box_pack_end (GTK_BOX (hbox_header), menu_button, FALSE, FALSE, 0);

	GtkWidget *menu_icon;
        menu_icon = gtk_image_new_from_icon_name ("open-menu-symbolic", GTK_ICON_SIZE_MENU);
        gtk_button_set_image (GTK_BUTTON (menu_button), menu_icon);

	GMenu *smenu;
        smenu = g_menu_new ();
        gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (menu_button), G_MENU_MODEL (smenu));

	GMenuItem *mitem;
        mitem = g_menu_item_new ("Test data source", "win.DSNTest");
        g_menu_insert_item (smenu, -1, mitem);
        mitem = g_menu_item_new ("Reset data source's changes", "win.DSNReset");
        g_menu_insert_item (smenu, -1, mitem);
        mitem = g_menu_item_new ("Duplicate data source", "win.DSNCopy");
        g_menu_insert_item (smenu, -1, mitem);

	GtkWindow *win;
	win = gtk_application_get_active_window (GTK_APPLICATION (g_application_get_default ()));
	g_action_map_add_action_entries (G_ACTION_MAP (win), win_entries, G_N_ELEMENTS (win_entries), config);

	/* stack in a scrolled window */
	GtkWidget *sw;
	sw = gtk_scrolled_window_new (NULL, NULL);
	gtk_widget_set_vexpand (sw, TRUE);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_NONE);
	gtk_box_pack_start (GTK_BOX (config), sw, TRUE, TRUE, 6);

	/* Stack */
	config->priv->stack = gtk_stack_new ();
	gtk_stack_set_transition_type (GTK_STACK (config->priv->stack), GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT);
	gtk_container_add (GTK_CONTAINER (sw), config->priv->stack);
	
	/* set up widgets */
	grid = gtk_grid_new ();
	gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
	gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
	gtk_widget_show (grid);

	label = gtk_label_new_with_mnemonic (_("_System wide data source:"));
	gtk_widget_set_halign (label, GTK_ALIGN_START);
	gtk_widget_set_hexpand (label, FALSE);
	g_object_set (G_OBJECT (label), "xalign", 0., NULL);
	gtk_widget_show (label);
	gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1);
	config->priv->is_system = gtk_check_button_new ();
	gtk_widget_show (config->priv->is_system);
	g_signal_connect (G_OBJECT (config->priv->is_system), "toggled",
			  G_CALLBACK (field_toggled_cb), config);
	gtk_grid_attach (GTK_GRID (grid), config->priv->is_system, 1, 1, 1, 1);

	str = g_strdup_printf ("%s <span foreground='red' weight='bold'>*</span>", _("_Provider:"));
	label = gtk_label_new ("");
	gtk_label_set_markup_with_mnemonic (GTK_LABEL (label), str);
	g_free (str);
	gtk_widget_set_halign (label, GTK_ALIGN_START);
	gtk_widget_set_hexpand (label, FALSE);
	g_object_set (G_OBJECT (label), "xalign", 0., NULL);
	gtk_widget_show (label);
	gtk_grid_attach (GTK_GRID (grid), label, 0, 2, 1, 1);
	config->priv->wprovider = gdaui_provider_selector_new ();
	gtk_widget_set_hexpand (config->priv->wprovider, TRUE);
	gtk_label_set_mnemonic_widget (GTK_LABEL (label), config->priv->wprovider);
	gtk_widget_show (config->priv->wprovider);
	g_signal_connect (G_OBJECT (config->priv->wprovider), "changed",
			  G_CALLBACK (field_changed_cb), config);
	gtk_grid_attach (GTK_GRID (grid), config->priv->wprovider, 1, 2, 1, 1);

	label = gtk_label_new_with_mnemonic (_("_Description:"));
	gtk_widget_set_halign (label, GTK_ALIGN_START);
	gtk_widget_set_hexpand (label, FALSE);
	g_object_set (G_OBJECT (label), "xalign", 0., NULL);
	gtk_widget_show (label);
	gtk_grid_attach (GTK_GRID (grid), label, 0, 3, 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_AUTOMATIC, GTK_POLICY_NEVER);
	config->priv->wdesc = gtk_text_view_new ();
	gtk_container_add (GTK_CONTAINER (sw), config->priv->wdesc);
	gtk_text_view_set_editable (GTK_TEXT_VIEW (config->priv->wdesc), TRUE);
	gtk_widget_set_vexpand (config->priv->wdesc, TRUE);
	gtk_label_set_mnemonic_widget (GTK_LABEL (label), config->priv->wdesc);
	g_signal_connect (gtk_text_view_get_buffer (GTK_TEXT_VIEW (config->priv->wdesc)), "changed",
			  G_CALLBACK (field_changed_cb), config);
	gtk_grid_attach (GTK_GRID (grid), sw, 1, 3, 1, 1);

	config->priv->warning = gtk_label_new (NULL);
	gtk_label_set_markup (GTK_LABEL (config->priv->warning),
			      _("<span foreground='red'>The database provider used by this data source is not available,\n"
				"editing the data source's attributes is disabled</span>"));
	gtk_widget_set_halign (config->priv->warning, GTK_ALIGN_CENTER);
	gtk_widget_set_hexpand (config->priv->warning, TRUE);
	g_object_set (G_OBJECT (config->priv->warning), "xalign", 0.5, NULL);
	gtk_label_set_justify (GTK_LABEL (config->priv->warning), GTK_JUSTIFY_CENTER);
	gtk_label_set_line_wrap (GTK_LABEL (config->priv->warning), TRUE);
	gtk_grid_attach (GTK_GRID (grid), config->priv->warning, 0, 8, 2, 1);
	gtk_stack_add_named (GTK_STACK (config->priv->stack), grid, PANE_DEFINITION);

	/* connection's spec */
	config->priv->dsn_spec = _gdaui_provider_spec_editor_new (gdaui_provider_selector_get_provider 
								 (GDAUI_PROVIDER_SELECTOR (config->priv->wprovider)));
	g_signal_connect (G_OBJECT (config->priv->dsn_spec), "changed",
			  G_CALLBACK (field_changed_cb), config);
	gtk_widget_show (config->priv->dsn_spec);
	gtk_stack_add_named (GTK_STACK (config->priv->stack), config->priv->dsn_spec, PANE_PARAMS);

	/* connection's authentication */
	config->priv->dsn_auth = _gdaui_provider_auth_editor_new (gdaui_provider_selector_get_provider 
								 (GDAUI_PROVIDER_SELECTOR (config->priv->wprovider)));
	g_signal_connect (G_OBJECT (config->priv->dsn_auth), "changed",
			  G_CALLBACK (field_changed_cb), config);
	gtk_widget_show (config->priv->dsn_auth);
	gtk_stack_add_named (GTK_STACK (config->priv->stack), config->priv->dsn_auth, PANE_AUTH);

	config->priv->no_change_signal = FALSE;
}
Ejemplo n.º 3
0
static void
gdaui_dsn_assistant_init (GdauiDsnAssistant *assistant,
			     G_GNUC_UNUSED GdauiDsnAssistantClass *klass)
{
	GtkWidget *label, *vbox, *grid;
	GtkAssistant *assist;
	gchar *str;

	g_return_if_fail (GDAUI_IS_DSN_ASSISTANT (assistant));

	/* global assistant settings */
	assist = GTK_ASSISTANT (assistant);
	gtk_window_set_title (GTK_WINDOW (assist), _("New data source definition"));
	gtk_container_set_border_width (GTK_CONTAINER (assist), 0);
	g_signal_connect (assist, "cancel", G_CALLBACK (assistant_cancelled_cb), NULL);
	g_signal_connect (assist, "apply", G_CALLBACK (assistant_applied_cb), NULL);
	gtk_assistant_set_forward_page_func (assist, (GtkAssistantPageFunc) forward_page_function, 
					     assistant, NULL);

	/* create private structure */
	assistant->priv = g_new0 (GdauiDsnAssistantPrivate, 1);
	assistant->priv->dsn_info = g_new0 (GdaDsnInfo, 1);
	assistant->priv->provider_detail = NULL;
	assistant->priv->create_db_op = NULL;

	/* 
	 * start page
	 */
	label = gtk_label_new ("");
	gtk_label_set_markup (GTK_LABEL (label),
			      _("This assistant will guide you through the process of "
				"creating a new data source, and optionally will allow you to "
				"create a new database.\n\nJust follow the steps!"));
	gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
	gtk_widget_show (label);
	gtk_assistant_append_page (assist, label);
	gtk_assistant_set_page_title (assist, label, _("Add a new data source..."));
	
	/* TODO: This is deprecated. Add it to the main content instead: */
	gtk_assistant_set_page_type (assist, label, GTK_ASSISTANT_PAGE_INTRO);
	gtk_assistant_set_page_complete (assist, label, TRUE);

	/* 
	 * general info page 
	 */
	vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);

	grid = gtk_grid_new ();
	gtk_box_pack_start (GTK_BOX (vbox), grid, FALSE, FALSE, 0);
	gtk_container_set_border_width (GTK_CONTAINER (grid), 0);
	gtk_grid_set_row_spacing (GTK_GRID (grid), 3);
	gtk_grid_set_column_spacing (GTK_GRID (grid), 5);

	label = gtk_label_new (NULL);
	gtk_label_set_markup (GTK_LABEL (label),
			      _("The following fields represent the basic information "
				"items for your new data source. Mandatory fields are marked "
				"with a star. "
				"To create a local database in a file, select the 'SQLite' type "
				"of database."));
	gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
	gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 2, 1);

	str = _gdaui_utility_markup_title (_("Data source name"), FALSE);
	label = gtk_label_new ("");
	gtk_label_set_markup (GTK_LABEL (label), str);
	g_free (str);
	gtk_misc_set_alignment (GTK_MISC (label), 0., 0.);
	gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1);

	assistant->priv->general_name = gtk_entry_new ();
	gtk_editable_set_editable (GTK_EDITABLE (assistant->priv->general_name), TRUE);
        gtk_widget_show (assistant->priv->general_name);
	gtk_grid_attach (GTK_GRID (grid), assistant->priv->general_name, 1, 1, 1, 1);
	g_signal_connect (assistant->priv->general_name, "changed",
			  G_CALLBACK (dsn_name_changed_cb), assistant);

	if (gda_config_can_modify_system_config ()) {
		label = gtk_label_new (_("System wide data source:"));
		gtk_misc_set_alignment (GTK_MISC (label), 0., 0.);
		gtk_grid_attach (GTK_GRID (grid), label, 0, 2, 1, 1);

		assistant->priv->general_is_system = gtk_check_button_new ();
		gtk_grid_attach (GTK_GRID (grid), assistant->priv->general_is_system, 1, 2, 1, 1);
	}
	else
		assistant->priv->general_is_system = NULL;

	str = _gdaui_utility_markup_title (_("Database type"), FALSE);
	label = gtk_label_new ("");
	gtk_label_set_markup (GTK_LABEL (label), str);
	g_free (str);
	gtk_misc_set_alignment (GTK_MISC (label), 0., 0.);
	gtk_grid_attach (GTK_GRID (grid), label, 0, 3, 1, 1);
	
	assistant->priv->general_provider = gdaui_provider_selector_new ();
	gtk_grid_attach (GTK_GRID (grid), assistant->priv->general_provider, 1, 3, 1, 1);

	label = gtk_label_new (_("Description:"));
	gtk_misc_set_alignment (GTK_MISC (label), 0., 0.);
	gtk_grid_attach (GTK_GRID (grid), label, 0, 4, 1, 1);
	
	assistant->priv->general_description = gtk_entry_new ();
	gtk_editable_set_editable (GTK_EDITABLE (assistant->priv->general_description), TRUE);
        gtk_widget_show (assistant->priv->general_description);
	gtk_grid_attach (GTK_GRID (grid), assistant->priv->general_description, 1, 4, 1, 1);
	
	gtk_widget_show_all (vbox);

	gtk_assistant_append_page (assist, vbox);
	gtk_assistant_set_page_title (assist, vbox, _("General Information"));
	gtk_assistant_set_page_type (assist, vbox, GTK_ASSISTANT_PAGE_CONTENT);
	assistant->priv->general_page = vbox;

	/*
	 * Choose between existing database or create a new one
	 */
	vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);

	grid = gtk_grid_new ();
	gtk_box_pack_start (GTK_BOX (vbox), grid, FALSE, FALSE, 0);
	gtk_container_set_border_width (GTK_CONTAINER (grid), 0);
	gtk_grid_set_row_spacing (GTK_GRID (grid), 3);
	gtk_grid_set_column_spacing (GTK_GRID (grid), 5);

	label = gtk_label_new (NULL);
	gtk_label_set_markup (GTK_LABEL (label),
			      _("This page lets you choose between using an existing database "
				"or to create a new database to use with this new data source"));
	gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
	gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 2, 1);

	label = gtk_label_new (_("Create a new database:"));
	gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1);
	
	assistant->priv->choose_toggle = gtk_check_button_new ();
	gtk_grid_attach (GTK_GRID (grid), assistant->priv->choose_toggle, 1, 1, 1, 1);

	gtk_widget_show_all (vbox);

	gtk_assistant_append_page (assist, vbox);
	gtk_assistant_set_page_title (assist, vbox, _("Create a new database?"));
	gtk_assistant_set_page_type (assist, vbox, GTK_ASSISTANT_PAGE_CONTENT);
	gtk_assistant_set_page_complete (assist, vbox, TRUE);

	/*
	 * New database information page
	 */
	vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
	gtk_container_set_border_width (GTK_CONTAINER (vbox), 0);
	
	label = gtk_label_new (NULL);
	gtk_label_set_markup (GTK_LABEL (label),
			      _("The following fields represent the information needed "
				"to create a new database "
				"(mandatory fields are marked with a star)."
				"This information is database-specific, so check "
				"the manual for more information."));
	gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
	gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
	
	GtkWidget *sw, *vp;
	sw = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC,
					GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_NONE);
	vp = gtk_viewport_new (NULL, NULL);
	gtk_widget_set_name (vp, "gdaui-transparent-background");
	gtk_viewport_set_shadow_type (GTK_VIEWPORT (vp), GTK_SHADOW_NONE);
	gtk_container_add (GTK_CONTAINER (sw), vp);
	assistant->priv->newdb_box = vp;
	gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
	assistant->priv->newdb_params = NULL;

	gtk_widget_show_all (vbox);

	gtk_assistant_append_page (assist, vbox);
	gtk_assistant_set_page_title (assist, vbox, _("New database definition"));
	gtk_assistant_set_page_type (assist, vbox, GTK_ASSISTANT_PAGE_CONTENT);
	gtk_assistant_set_page_complete (assist, vbox, TRUE);

	/* 
	 * provider parameters to open connection page 
	 */
	vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
	gtk_container_set_border_width (GTK_CONTAINER (vbox), 0);
	
	label = gtk_label_new (NULL);
	gtk_label_set_markup (GTK_LABEL (label),
			      _("The following fields represent the information needed "
				"to open a connection (mandatory fields are marked with a star). "
				"This information is database-specific, so check "
				"the manual for more information."));
	gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
	gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

	assistant->priv->provider_container = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_box_pack_start (GTK_BOX (vbox), assistant->priv->provider_container, TRUE, TRUE, 0);

	gtk_widget_show_all (vbox);

	gtk_assistant_append_page (assist, vbox);
	gtk_assistant_set_page_title (assist, vbox, _("Connection's parameters"));
	gtk_assistant_set_page_type (assist, vbox, GTK_ASSISTANT_PAGE_CONTENT);
	assistant->priv->cnc_params_page = vbox;

	/* 
	 * authentication page 
	 */
	vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
	gtk_container_set_border_width (GTK_CONTAINER (vbox), 0);
	
	label = gtk_label_new (NULL);
	gtk_label_set_markup (GTK_LABEL (label),
			      _("The following fields represent the authentication information needed "
				"to open a connection."));
	gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
	gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

	assistant->priv->auth_container = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_box_pack_start (GTK_BOX (vbox), assistant->priv->auth_container, TRUE, TRUE, 0);

	gtk_widget_show_all (vbox);

	gtk_assistant_append_page (assist, vbox);
	gtk_assistant_set_page_title (assist, vbox, _("Authentication parameters"));
	gtk_assistant_set_page_type (assist, vbox, GTK_ASSISTANT_PAGE_CONTENT);
	assistant->priv->cnc_auth_page = vbox;

	/* 
	 * end page 
	 */
	vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
	gtk_container_set_border_width (GTK_CONTAINER (vbox), 0);

	label = gtk_label_new (NULL);
	gtk_label_set_markup (GTK_LABEL (label),
			      _("All information needed to create a new data source "
				"has been retrieved. Now, press 'Apply' to close "
				"this dialog."));
	gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
	gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);

	gtk_widget_show_all (vbox);

	gtk_assistant_append_page (assist, vbox);
	gtk_assistant_set_page_title (assist, vbox, _("Ready to add a new data source"));
	gtk_assistant_set_page_type (assist, vbox, GTK_ASSISTANT_PAGE_CONFIRM);
	gtk_assistant_set_page_complete (assist, vbox, TRUE);

	/* force correct init */
	provider_changed_cb (assistant->priv->general_provider, assistant);

	g_signal_connect (G_OBJECT (assistant->priv->general_provider), "changed",
			  G_CALLBACK (provider_changed_cb), assistant);
}
Ejemplo n.º 4
0
static void
gdaui_login_init (GdauiLogin *login)
{
	GtkWidget *grid;
	GtkWidget *wid;

	/* allocate the internal structure */
	GdauiLoginPrivate *priv = gdaui_login_get_instance_private (login);
	
	/* Init the properties*/
	priv->mode = GDA_UI_LOGIN_ENABLE_CONTROL_CENTRE_MODE;
	memset (&(priv->dsn_info), 0, sizeof (GdaDsnInfo));

	gtk_orientable_set_orientation (GTK_ORIENTABLE (login), GTK_ORIENTATION_VERTICAL);
	
	/* catch DSN definition changes */
	GdaConfig *conf = gda_config_get ();
	g_signal_connect (conf, "dsn-changed",
			  G_CALLBACK (config_dsn_changed_cb), login);
	g_object_unref (conf);

	/* table layout */
	grid = gtk_grid_new ();
	gtk_widget_show (grid);
	gtk_grid_set_column_spacing (GTK_GRID (grid), 5);
	gtk_grid_set_row_spacing (GTK_GRID (grid), 5);
	gtk_box_pack_start (GTK_BOX (login), grid, TRUE, TRUE, 0);
	
	/* radio buttons */
	wid = gtk_radio_button_new_with_label (NULL, _("Use data source:"));
	g_signal_connect (wid, "toggled",
			  G_CALLBACK (radio_button_use_dsn_toggled_cb), login);
	gtk_grid_attach (GTK_GRID (grid), wid, 0, 0, 1, 1);
	gtk_widget_show (wid);
	priv->rb_dsn = wid;

	wid = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (wid),
							   _("Specify connection:"));
	gtk_grid_attach (GTK_GRID (grid), wid, 0, 1, 1, 1);
	gtk_widget_show (wid);
	priv->rb_prov = wid;

	/* widget to specify a DSN to use */
	priv->dsn_selector = _gdaui_dsn_selector_new ();
	gtk_widget_show (priv->dsn_selector); /* Show the DSN selector */
	gtk_grid_attach (GTK_GRID (grid), priv->dsn_selector, 1, 0, 1, 1);
	g_signal_connect (G_OBJECT (priv->dsn_selector), "changed",
			  G_CALLBACK (dsn_entry_changed_cb), login);
			  
	/* Create the DSN add button */
	priv->cc_button = gtk_button_new_with_label (_("Data sources..."));
	gtk_button_set_image (GTK_BUTTON (priv->cc_button),
			      gtk_image_new_from_icon_name ("preferences-system", GTK_ICON_SIZE_BUTTON));
	g_signal_connect (G_OBJECT (priv->cc_button), "clicked",
			  G_CALLBACK (run_cc_cb), login);
	gtk_widget_show (priv->cc_button);
	gtk_grid_attach (GTK_GRID (grid), priv->cc_button, 2, 0, 1, 1);
		
	/* widget to specify a direct connection */
	priv->prov_selector = gdaui_provider_selector_new ();
	gtk_grid_attach (GTK_GRID (grid),priv->prov_selector, 1, 1, 2, 1);
	gtk_widget_show (priv->prov_selector);
	gtk_widget_set_sensitive (priv->prov_selector, FALSE);
	g_signal_connect (priv->prov_selector, "changed",
			  G_CALLBACK (prov_entry_changed_cb), login);

	priv->cnc_params_editor = _gdaui_provider_spec_editor_new (NULL);
	gtk_grid_attach (GTK_GRID (grid), priv->cnc_params_editor, 1, 2, 2, 1);
	gtk_widget_show (priv->cnc_params_editor);
	gtk_widget_set_sensitive (priv->cnc_params_editor, FALSE);
	g_signal_connect (priv->cnc_params_editor, "changed",
			  G_CALLBACK (cnc_params_editor_changed_cb), login);
	  
	/* Create the authentication part */
	priv->auth_widget = _gdaui_provider_auth_editor_new (NULL);
	gtk_grid_attach (GTK_GRID (grid), priv->auth_widget, 1, 3, 2, 1);
	gtk_widget_show (priv->auth_widget);
	g_signal_connect (priv->auth_widget, "changed",
			  G_CALLBACK (auth_data_changed_cb), login);

	prov_entry_changed_cb (GDAUI_PROVIDER_SELECTOR (priv->prov_selector), login);
}
Ejemplo n.º 5
0
GtkWidget *
do_ddl_queries (GtkWidget *do_widget)
{  
	if (!window) {
		GtkWidget *grid;
		GtkWidget *label;
		GtkWidget *wid;
		DemoData *data;
		GtkWidget *bbox;
		GtkWidget *sw, *vp;

                data = g_new0 (DemoData, 1);

		window = gtk_dialog_new_with_buttons ("DDL queries",
						      GTK_WINDOW (do_widget),
						      0,
						      "Close", GTK_RESPONSE_NONE,
						      NULL);
		data->top_window = window;
		
		g_signal_connect (window, "response",
				  G_CALLBACK (gtk_widget_destroy), NULL);
		g_signal_connect (window, "destroy",
				  G_CALLBACK (gtk_widget_destroyed), &window);
		
		grid = gtk_grid_new ();
		gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (window))),
				    grid, TRUE, TRUE, 0);
		gtk_container_set_border_width (GTK_CONTAINER (grid), 5);
		
		label = gtk_label_new ("<b>Tested provider and operation:</b>");
		gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
		gtk_widget_set_halign (label, GTK_ALIGN_START);
		gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 2, 1);
		
		/* provider selection */
		label = gtk_label_new ("Tested provider:");
		gtk_widget_set_halign (label, GTK_ALIGN_START);
		gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1);

		wid = gdaui_provider_selector_new ();
		gdaui_provider_selector_set_provider (GDAUI_PROVIDER_SELECTOR (wid),
								  "SQLite");
		gtk_grid_attach (GTK_GRID (grid), wid, 1, 1, 1, 1);
		data->prov_sel = GDAUI_PROVIDER_SELECTOR (wid);
		g_signal_connect (G_OBJECT (data->prov_sel), "changed", 
				  G_CALLBACK (tested_provider_changed_cb), data);

		/* operation selection */
		label = gtk_label_new ("Tested operation:");
		gtk_widget_set_halign (label, GTK_ALIGN_START);
		gtk_grid_attach (GTK_GRID (grid), label, 0, 2, 1, 1);
		
		wid = gdaui_combo_new ();
		gtk_grid_attach (GTK_GRID (grid), wid, 1, 2, 1, 1);
		g_signal_connect (G_OBJECT (wid), "changed",
				  G_CALLBACK (tested_operation_changed_cb), data);
		data->op_combo = wid;

		/* container for GdauiServerOperation */
		label = gtk_label_new ("<b>GdauiServerOperation widget:</b>");
		gtk_widget_set_halign (label, GTK_ALIGN_START);
		gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
		gtk_grid_attach (GTK_GRID (grid), label, 0, 3, 2, 1);

		sw = gtk_scrolled_window_new (FALSE, 0);
		gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
						GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
		gtk_widget_set_size_request (sw, 600, 450);
		gtk_grid_attach (GTK_GRID (grid), sw, 0, 4, 2, 1);
		vp = gtk_viewport_new (NULL, NULL);
		gtk_widget_set_name (vp, "gdaui-transparent-background");
		gtk_viewport_set_shadow_type (GTK_VIEWPORT (vp), GTK_SHADOW_NONE);
		gtk_container_add (GTK_CONTAINER (sw), vp);
		data->op_container = vp;
		
		/* bottom buttons */
		bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
		gtk_grid_attach (GTK_GRID (grid), bbox, 0, 5, 2, 1);

		wid = gtk_button_new_with_label ("Show named parameters");
		data->show_button = wid;
		gtk_box_pack_start (GTK_BOX (bbox), wid, TRUE, TRUE, 0);
		g_signal_connect (G_OBJECT (wid), "clicked",
				  G_CALLBACK (show_named_parameters), data);

		wid = gtk_button_new_with_label ("Show SQL");
		data->sql_button = wid;
		gtk_box_pack_start (GTK_BOX (bbox), wid, TRUE, TRUE, 0);
		g_signal_connect (G_OBJECT (wid), "clicked",
				  G_CALLBACK (show_sql), data);

		tested_provider_changed_cb (data->prov_sel, data);
		gtk_combo_box_set_active (GTK_COMBO_BOX (data->op_combo), 1);
	}

	gboolean visible;
	g_object_get (G_OBJECT (window), "visible", &visible, NULL);
	if (!visible)
		gtk_widget_show_all (window);
	else {
		gtk_widget_destroy (window);
		window = NULL;
	}

	return window;
}