[libgda] Partially reworked the Gda control center
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Partially reworked the Gda control center
- Date: Sun, 4 Jan 2015 16:10:28 +0000 (UTC)
commit 6e492252ace364c325a3ff5e9fc272578f19e635
Author: Vivien Malerba <malerba gnome-db org>
Date: Sun Jan 4 17:01:45 2015 +0100
Partially reworked the Gda control center
control-center/dsn-config.c | 26 +----
control-center/gdaui-bar.c | 1 +
control-center/main.c | 165 +++++++++++++++++++-------------
control-center/menus.ui | 41 +++-----
control-center/provider-config.c | 195 ++++++++++++++++++++++++++++++++++----
5 files changed, 296 insertions(+), 132 deletions(-)
---
diff --git a/control-center/dsn-config.c b/control-center/dsn-config.c
index cd4243e..9447ad2 100644
--- a/control-center/dsn-config.c
+++ b/control-center/dsn-config.c
@@ -127,7 +127,11 @@ dsn_config_new (void)
/* title */
title = g_strdup_printf ("<b>%s</b>\n%s", _("Data Sources"),
- _("Configured data sources in the system"));
+ _("Data sources are the means by which database "
+ "connections are identified: all "
+ "the information needed to open a connection to "
+ "a specific database using a 'provider' is referenced using "
+ "a unique name."));
priv->title = gdaui_bar_new (title);
g_free (title);
@@ -163,26 +167,6 @@ dsn_config_new (void)
g_signal_connect (priv->dsn_list, "populate-popup",
G_CALLBACK (list_popup_cb), dsn);
- /* add tip */
- box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
- gtk_container_set_border_width (GTK_CONTAINER (box), 6);
- gtk_box_pack_start (GTK_BOX (dsn), box, FALSE, FALSE, 0);
- gtk_widget_show (box);
-
- image = gtk_image_new_from_icon_name ("dialog-information", GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
- gtk_widget_show (image);
- gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);
-
- label = gtk_label_new (_("Data sources are the means by which database "
- "connections are identified: all "
- "the information needed to open a connection to "
- "a specific database using a 'provider' is referenced using "
- "a unique name."));
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
- gtk_widget_show (label);
-
return dsn;
}
diff --git a/control-center/gdaui-bar.c b/control-center/gdaui-bar.c
index a8d406e..8a440be 100644
--- a/control-center/gdaui-bar.c
+++ b/control-center/gdaui-bar.c
@@ -154,6 +154,7 @@ gdaui_bar_init (GdauiBar *bar)
gtk_misc_set_alignment (GTK_MISC (bar->priv->label), 0., 0.5);
gtk_box_pack_end (GTK_BOX (bar->priv->content_area), bar->priv->label,
TRUE, TRUE, 0);
+ gtk_label_set_line_wrap (GTK_LABEL (bar->priv->label), TRUE);
gtk_widget_show (bar->priv->label);
/* CSS theming */
diff --git a/control-center/main.c b/control-center/main.c
index 58f8227..626b33f 100644
--- a/control-center/main.c
+++ b/control-center/main.c
@@ -31,8 +31,9 @@ GtkApplication *app;
GtkWindow *main_window;
#define DSN_PAGE "DSN"
-#define NOTEBOOK "Nb"
-static GtkWidget *create_main_notebook (GtkApplicationWindow *app_window);
+#define PROV_PAGE "Prov"
+#define STACK "Nb"
+static GtkWidget *create_main_stack (GtkApplicationWindow *app_window);
static void
show_error (GtkWindow *parent, const gchar *format, ...)
@@ -109,7 +110,7 @@ file_properties_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gp
gint current;
dsn = g_object_get_data (G_OBJECT (app_window), DSN_PAGE);
- nb = g_object_get_data (G_OBJECT (app_window), NOTEBOOK);
+ nb = g_object_get_data (G_OBJECT (app_window), STACK);
current = gtk_notebook_get_current_page (GTK_NOTEBOOK (nb));
if (current == -1)
@@ -128,7 +129,7 @@ file_delete_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpoint
gint current;
dsn = g_object_get_data (G_OBJECT (app_window), DSN_PAGE);
- nb = g_object_get_data (G_OBJECT (app_window), NOTEBOOK);
+ nb = g_object_get_data (G_OBJECT (app_window), STACK);
current = gtk_notebook_get_current_page (GTK_NOTEBOOK (nb));
if (current == -1)
@@ -140,6 +141,38 @@ file_delete_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpoint
}
static void
+show_datasources_cb (G_GNUC_UNUSED GSimpleAction *unused_action, GVariant *parameter, gpointer user_data)
+{
+ GtkWidget *app_window;
+ GtkWidget *stack;
+ app_window = GTK_WIDGET (user_data);
+ stack = g_object_get_data (G_OBJECT (app_window), STACK);
+ gtk_stack_set_visible_child_name (GTK_STACK (stack), DSN_PAGE);
+
+ GAction *action;
+ action = g_action_map_lookup_action (G_ACTION_MAP (app_window), "ShowDatasources");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
+ action = g_action_map_lookup_action (G_ACTION_MAP (app_window), "ShowProviders");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), TRUE);
+}
+
+static void
+show_providers_cb (G_GNUC_UNUSED GSimpleAction *unused_action, GVariant *parameter, gpointer user_data)
+{
+ GtkWidget *app_window;
+ GtkWidget *stack;
+ app_window = GTK_WIDGET (user_data);
+ stack = g_object_get_data (G_OBJECT (app_window), STACK);
+ gtk_stack_set_visible_child_name (GTK_STACK (stack), PROV_PAGE);
+
+ GAction *action;
+ action = g_action_map_lookup_action (G_ACTION_MAP (app_window), "ShowDatasources");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), TRUE);
+ action = g_action_map_lookup_action (G_ACTION_MAP (app_window), "ShowProviders");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
+}
+
+static void
window_closed_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, G_GNUC_UNUSED gpointer user_data)
{
g_application_quit (G_APPLICATION (app));
@@ -169,9 +202,9 @@ about_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, G_GNUC_UNUSE
dialog = gtk_about_dialog_new ();
- gtk_about_dialog_set_program_name (GTK_ABOUT_DIALOG (dialog), _("Database access control center"));
+ gtk_about_dialog_set_program_name (GTK_ABOUT_DIALOG (dialog), _("Database sources control center"));
gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (dialog), PACKAGE_VERSION);
- gtk_about_dialog_set_copyright (GTK_ABOUT_DIALOG (dialog), "(C) 1998 - 2014 GNOME Foundation");
+ gtk_about_dialog_set_copyright (GTK_ABOUT_DIALOG (dialog), "© 1998 - 2014 GNOME Foundation");
gtk_about_dialog_set_comments (GTK_ABOUT_DIALOG (dialog), _("Database access services for the GNOME
Desktop"));
gtk_about_dialog_set_license (GTK_ABOUT_DIALOG (dialog), "GNU Lesser General Public License");
gtk_about_dialog_set_website (GTK_ABOUT_DIALOG (dialog), "http://www.gnome-db.org");
@@ -191,34 +224,35 @@ about_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, G_GNUC_UNUSE
static GActionEntry app_entries[] = {
{ "quit", window_closed_cb, NULL, NULL, NULL },
+ { "about", about_cb, NULL, NULL, NULL }
};
static GActionEntry win_entries[] = {
{ "DatasourceNew", file_new_cb, NULL, NULL, NULL },
{ "DatasourceDelete", file_delete_cb, NULL, NULL, NULL },
{ "DatasourceProperties", file_properties_cb, NULL, NULL, NULL },
- { "about", about_cb, NULL, NULL, NULL }
+ { "ShowDatasources", show_datasources_cb, NULL, NULL, NULL },
+ { "ShowProviders", show_providers_cb, NULL, NULL, NULL },
};
static void
startup (GApplication *app)
{
+ g_action_map_add_action_entries (G_ACTION_MAP (app),
+ app_entries, G_N_ELEMENTS (app_entries),
+ NULL);
GtkBuilder *builder;
- GMenuModel *appmenu;
- GMenuModel *menubar;
-
builder = gtk_builder_new ();
g_assert (gtk_builder_add_from_resource (builder, "/application/menus.ui", NULL));
- appmenu = (GMenuModel *)gtk_builder_get_object (builder, "appmenu");
- menubar = (GMenuModel *)gtk_builder_get_object (builder, "menubar");
+ GMenuModel *appmenu;
+ appmenu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu"));
gtk_application_set_app_menu (GTK_APPLICATION (app), appmenu);
- gtk_application_set_menubar (GTK_APPLICATION (app), menubar);
-
g_object_unref (builder);
}
+
static void
activate (GApplication *app)
{
@@ -236,16 +270,25 @@ activate (GApplication *app)
/* create the main window */
window = gtk_application_window_new (GTK_APPLICATION (app));
main_window = GTK_WINDOW (window);
- gtk_window_set_title (GTK_WINDOW (window), _("Datasource access control center"));
- gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
- gtk_window_set_default_size (GTK_WINDOW (window), 650, 600);
- /* actions */
- g_action_map_add_action_entries (G_ACTION_MAP (window),
- win_entries, G_N_ELEMENTS (win_entries),
- window);
+ GtkWidget *header;
+ header = gtk_header_bar_new ();
+ gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (header), TRUE);
+ gtk_header_bar_set_title (GTK_HEADER_BAR (header), _("Datasource access control center"));
+ gtk_header_bar_set_has_subtitle (GTK_HEADER_BAR (header), FALSE);
+
+ gtk_window_set_titlebar (GTK_WINDOW (window), header);
+ gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
+ gtk_window_set_default_size (GTK_WINDOW (window), 780, 500);
+ GtkWidget *menu_button;
+ menu_button = gtk_menu_button_new ();
+ gtk_header_bar_pack_end (GTK_HEADER_BAR (header), menu_button);
+ 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);
+
/* icon */
GdkPixbuf *icon;
icon = gdk_pixbuf_new_from_resource ("/images/gda-control-center.png", NULL);
@@ -254,24 +297,36 @@ activate (GApplication *app)
g_object_unref (icon);
}
- /* menu and contents */
+ /* contents */
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (window), vbox);
gtk_widget_show (vbox);
- nb = create_main_notebook (GTK_APPLICATION_WINDOW (window));
+ nb = create_main_stack (GTK_APPLICATION_WINDOW (window));
gtk_container_set_border_width (GTK_CONTAINER (nb), 6);
gtk_box_pack_start (GTK_BOX (vbox), nb, TRUE, TRUE, 0);
gtk_widget_show (nb);
- gtk_widget_show (window);
+ gtk_widget_show_all (window);
+
+ /* menus */
+ g_action_map_add_action_entries (G_ACTION_MAP (window),
+ win_entries, G_N_ELEMENTS (win_entries),
+ window);
+
+ GtkBuilder *builder;
+ GMenuModel *menubar;
+ builder = gtk_builder_new ();
+ g_assert (gtk_builder_add_from_resource (builder, "/application/menus.ui", NULL));
+
+ menubar = G_MENU_MODEL (gtk_builder_get_object (builder, "menubar"));
+
+ gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (menu_button), menubar);
+ g_object_unref (builder);
/* set actions start state */
GAction *action;
- action = g_action_map_lookup_action (G_ACTION_MAP (window), "DatasourceProperties");
- g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
-
- action = g_action_map_lookup_action (G_ACTION_MAP (window), "DatasourceDelete");
+ action = g_action_map_lookup_action (G_ACTION_MAP (window), "ShowDatasources");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
}
@@ -281,11 +336,14 @@ main (int argc, char *argv[])
gint status;
app = gtk_application_new ("org.Libgda.Preferences", G_APPLICATION_FLAGS_NONE);
- g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
g_signal_connect (app, "startup", G_CALLBACK (startup), NULL);
-
+ g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
+
+ g_action_map_add_action_entries (G_ACTION_MAP (app),
+ app_entries, G_N_ELEMENTS (app_entries),
+ app);
+
status = g_application_run (G_APPLICATION (app), argc, argv);
-
g_object_unref (app);
return status;
@@ -307,49 +365,23 @@ dsn_selection_changed_cb (GdauiRawGrid *dbrawgrid, GtkApplicationWindow *main_wi
g_array_free (selection, TRUE);
}
-static void
-main_nb_page_switched_cb (G_GNUC_UNUSED GtkNotebook *notebook, G_GNUC_UNUSED GtkWidget *page, guint page_num,
- GtkApplicationWindow *main_window)
-{
- gboolean show;
- show = page_num == 0 ? TRUE : FALSE;
-
- GAction *action;
- action = g_action_map_lookup_action (G_ACTION_MAP (main_window), "DatasourceProperties");
- //g_object_set (G_OBJECT (action), "visible", show, NULL);
- g_simple_action_set_enabled (G_SIMPLE_ACTION (action), show);
-
- action = g_action_map_lookup_action (G_ACTION_MAP (main_window), "DatasourceDelete");
- g_simple_action_set_enabled (G_SIMPLE_ACTION (action), show);
- //g_object_set (G_OBJECT (action), "visible", show, NULL);
-}
-
static GtkWidget *
-create_main_notebook (GtkApplicationWindow *app_window)
+create_main_stack (GtkApplicationWindow *app_window)
{
- GtkWidget *nb;
+ GtkWidget *stack;
GtkWidget *dsn;
GtkWidget *provider;
GdauiRawGrid *grid;
- nb = gtk_notebook_new ();
- g_object_set_data (G_OBJECT (app_window), NOTEBOOK, nb);
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nb), TRUE);
- gtk_notebook_set_scrollable (GTK_NOTEBOOK (nb), TRUE);
- gtk_notebook_popup_enable (GTK_NOTEBOOK (nb));
- gtk_widget_show (nb);
- g_signal_connect (G_OBJECT (nb), "switch-page",
- G_CALLBACK (main_nb_page_switched_cb), app_window);
-
- g_action_map_add_action_entries (G_ACTION_MAP (app),
- app_entries, G_N_ELEMENTS (app_entries),
- app);
+ stack = gtk_stack_new ();
+ g_object_set_data (G_OBJECT (app_window), STACK, stack);
+ gtk_widget_show (stack);
+ gtk_stack_set_transition_type (GTK_STACK (stack), GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT);
/* data source configuration page */
dsn = dsn_config_new ();
g_object_set_data (G_OBJECT (app_window), DSN_PAGE, dsn);
- gtk_notebook_append_page (GTK_NOTEBOOK (nb), dsn,
- gtk_label_new (_("Data Sources")));
+ gtk_stack_add_named (GTK_STACK (stack), dsn, DSN_PAGE);
grid = g_object_get_data (G_OBJECT (dsn), "grid");
g_signal_connect (G_OBJECT (grid), "selection-changed",
@@ -357,8 +389,7 @@ create_main_notebook (GtkApplicationWindow *app_window)
/* providers configuration page */
provider = provider_config_new ();
- gtk_notebook_append_page (GTK_NOTEBOOK (nb), provider,
- gtk_label_new (_("Providers")));
+ gtk_stack_add_named (GTK_STACK (stack), provider, PROV_PAGE);
- return nb;
+ return stack;
}
diff --git a/control-center/menus.ui b/control-center/menus.ui
index 4088a35..af6062a 100644
--- a/control-center/menus.ui
+++ b/control-center/menus.ui
@@ -7,35 +7,26 @@
<attribute name="action">app.quit</attribute>
<attribute name="accel"><Primary>q</attribute>
</item>
+ <item>
+ <attribute name="label" translatable="yes">_About</attribute>
+ <attribute name="action">app.about</attribute>
+ <attribute name="accel"><Primary>a</attribute>
+ </item>
</section>
</menu>
<menu id="menubar">
- <submenu>
- <attribute name="label" translatable="yes">_Data sources</attribute>
- <section>
- <item>
- <attribute name="label" translatable="yes">_New</attribute>
- <attribute name="action">win.DatasourceNew</attribute>
- <attribute name="accel"><Primary>n</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">_Properties</attribute>
- <attribute name="action">win.DatasourceProperties</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">_Delete</attribute>
- <attribute name="action">win.DatasourceDelete</attribute>
- <attribute name="accel"><Primary>d</attribute>
- </item>
- </section>
- </submenu>
- <submenu>
- <attribute name="label" translatable="yes">_Help</attribute>
+ <section>
+ <attribute name="display-hint">horizontal-buttons</attribute>
<item>
- <attribute name="label" translatable="yes">_About</attribute>
- <attribute name="action">win.about</attribute>
- <attribute name="accel"><Primary>a</attribute>
+ <attribute name="label" translatable="yes">_Data sources</attribute>
+ <attribute name="action">win.ShowDatasources</attribute>
+ <attribute name="accel"><Primary>D</attribute>
</item>
- </submenu>
+ <item>
+ <attribute name="label" translatable="yes">_Providers</attribute>
+ <attribute name="action">win.ShowProviders</attribute>
+ <attribute name="accel"><Primary>P</attribute>
+ </item>
+ </section>
</menu>
</interface>
diff --git a/control-center/provider-config.c b/control-center/provider-config.c
index 3ff4241..78ac6a4 100644
--- a/control-center/provider-config.c
+++ b/control-center/provider-config.c
@@ -31,18 +31,129 @@
typedef struct {
GtkWidget *title;
GtkWidget *provider_list;
+ GtkWidget *prov_image;
+ GtkWidget *prov_name;
+ GtkWidget *prov_loc;
} ProviderConfigPrivate;
/*
* Public functions
*/
+static void
+provider_selection_changed_cb (GtkTreeSelection *selection, ProviderConfigPrivate *priv)
+{
+ GdaDataModelIter *sel_iter;
+ sel_iter = gdaui_data_selector_get_data_set (GDAUI_DATA_SELECTOR (priv->provider_list));
+ GdkPixbuf *pix = NULL;
+ if (sel_iter) {
+ const GValue *cvalue;
+ cvalue = gda_data_model_iter_get_value_at (sel_iter, 0);
+ g_print ("Provider: %s\n", gda_value_stringify (cvalue));
+
+ GdaProviderInfo *pinfo;
+ pinfo = gda_config_get_provider_info (g_value_get_string (cvalue));
+ g_assert (pinfo);
+ pix = gdaui_get_icon_for_db_engine (pinfo->icon_id);
+
+ gchar *tmp, *tmp1, *tmp2;
+ tmp1 = g_markup_printf_escaped ("%s", pinfo->id);
+ tmp2 = g_markup_printf_escaped ("%s", pinfo->description);
+ tmp = g_strdup_printf ("<b><big>%s</big></b>\n%s", tmp1, tmp2);
+ g_free (tmp1);
+ g_free (tmp2);
+ gtk_label_set_markup (GTK_LABEL (priv->prov_name), tmp);
+ g_free (tmp);
+
+ GString *string;
+ string = g_string_new ("");
+
+ GdaSet *set;
+ set = pinfo->dsn_params;
+ if (set) {
+ tmp1 = g_markup_printf_escaped ("%s", _("Accepted connection parameters"));
+ g_string_append_printf (string, "<b><u>%s</u></b>:\n", tmp1);
+ g_free (tmp1);
+
+ GSList *list;
+ for (list = set->holders; list; list = list->next) {
+ GdaHolder *holder = GDA_HOLDER (list->data);
+ tmp1 = g_markup_printf_escaped ("%s", gda_holder_get_id (holder));
+ gchar *descr;
+ g_object_get (holder, "description", &descr, NULL);
+ tmp2 = descr ? g_markup_printf_escaped ("%s", descr) : NULL;
+ g_free (descr);
+ if (gda_holder_get_not_null (holder)) {
+ if (tmp2)
+ g_string_append_printf (string, "<b>%s</b>: %s\n", tmp1,
tmp2);
+ else
+ g_string_append_printf (string, "<b>%s</b>:\n", tmp1);
+ }
+ else {
+ if (tmp2)
+ g_string_append_printf (string, "<b>%s</b> (%s): %s\n",
+ tmp1, _("optional"), tmp2);
+ else
+ g_string_append_printf (string, "<b>%s</b> (%s):\n",
+ tmp1, _("optional"));
+ }
+ g_free (tmp1);
+ g_free (tmp2);
+ }
+ }
+
+ set = pinfo->auth_params;
+ if (set && set->holders) {
+ tmp1 = g_markup_printf_escaped ("%s", _("Authentication parameters"));
+ g_string_append_printf (string, "\n<b><u>%s</u></b>:\n", tmp1);
+ g_free (tmp1);
+
+ GSList *list;
+ for (list = set->holders; list; list = list->next) {
+ GdaHolder *holder = GDA_HOLDER (list->data);
+ tmp1 = g_markup_printf_escaped ("%s", gda_holder_get_id (holder));
+ gchar *descr;
+ g_object_get (holder, "description", &descr, NULL);
+ tmp2 = descr ? g_markup_printf_escaped ("%s", descr) : NULL;
+ g_free (descr);
+ if (gda_holder_get_not_null (holder)) {
+ if (tmp2)
+ g_string_append_printf (string, "<b>%s</b>: %s\n", tmp1,
tmp2);
+ else
+ g_string_append_printf (string, "<b>%s</b>\n", tmp1);
+ }
+ else {
+ if (tmp2)
+ g_string_append_printf (string, "<b>%s</b> (%s): %s\n",
+ tmp1, _("optional"), tmp2);
+ else
+ g_string_append_printf (string, "<b>%s</b> (%s)\n",
+ tmp1, _("optional"));
+ }
+ g_free (tmp1);
+ g_free (tmp2);
+ }
+ }
+
+ tmp1 = g_markup_printf_escaped ("%s", _("Shared object file"));
+ tmp2 = g_markup_printf_escaped ("%s", pinfo->location);
+ g_string_append_printf (string, "\n<b><u>%s</u></b>:\n%s", tmp1, tmp2);
+ g_free (tmp1);
+ g_free (tmp2);
+
+ gtk_label_set_markup (GTK_LABEL (priv->prov_loc), string->str);
+ g_string_free (string, TRUE);
+ }
+ gtk_image_set_from_pixbuf (GTK_IMAGE (priv->prov_image), pix);
+ gtk_widget_grab_focus (priv->provider_list);
+}
+
GtkWidget *
provider_config_new (void)
{
ProviderConfigPrivate *priv;
GtkWidget *provider;
- GtkWidget *box;
+ GtkWidget *box, *paned;
GtkWidget *image;
GtkWidget *label;
GtkWidget *sw;
@@ -58,7 +169,8 @@ provider_config_new (void)
/* title */
title = g_strdup_printf ("<b>%s</b>\n%s", _("Providers"),
- _("Installed providers"));
+ _("Providers are addons that actually implement the access "
+ "to each database using the means provided by each database vendor."));
priv->title = gdaui_bar_new (title);
g_free (title);
@@ -67,37 +179,82 @@ provider_config_new (void)
gtk_box_pack_start (GTK_BOX (provider), priv->title, FALSE, FALSE, 0);
gtk_widget_show (priv->title);
+ /* horizontal box for the provider list and its properties */
+ paned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
+ gtk_paned_set_position (GTK_PANED (paned), 200);
+ gtk_box_pack_start (GTK_BOX (provider), paned, TRUE, TRUE, 0);
+ gtk_widget_show (paned);
+
/* 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);
+ gtk_paned_add1 (GTK_PANED (paned), sw);
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);
+ gdaui_data_selector_set_column_visible (GDAUI_DATA_SELECTOR (priv->provider_list), -1, FALSE);
+ gdaui_data_selector_set_column_visible (GDAUI_DATA_SELECTOR (priv->provider_list), 0, TRUE);
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->provider_list), FALSE);
g_object_set (G_OBJECT (priv->provider_list), "info-cell-visible", FALSE, NULL);
+
+ GtkTreeSelection *selection;
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->provider_list));
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
+ g_signal_connect (selection, "changed",
+ G_CALLBACK (provider_selection_changed_cb), priv);
gtk_container_add (GTK_CONTAINER (sw), priv->provider_list);
-
gtk_widget_show_all (sw);
+ g_object_unref (model);
- /* 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);
+ /* properties */
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+ gtk_paned_add2 (GTK_PANED (paned), sw);
+
+ GtkWidget *grid;
+ grid = gtk_grid_new ();
+ gtk_paned_add2 (GTK_PANED (paned), grid);
+ g_object_set (grid, "margin-top", 20, NULL);
+ gtk_container_add (GTK_CONTAINER (sw), grid);
+ gtk_widget_show (sw);
- image = gtk_image_new_from_icon_name ("dialog-information", GTK_ICON_SIZE_DIALOG);
- gtk_widget_show (image);
- gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);
+ priv->prov_image = gtk_image_new ();
+ g_object_set (priv->prov_image,
+ "halign", GTK_ALIGN_END,
+ "valign", GTK_ALIGN_START,
+ "hexpand", TRUE,
+ "vexpand", FALSE, NULL);
+ gtk_grid_attach (GTK_GRID (grid), priv->prov_image, 1, 0, 1, 1);
- 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);
+ priv->prov_name = gtk_label_new ("");
+ g_object_set (priv->prov_name,
+ "xalign", 0.,
+ "yalign", 0.,
+ "halign", GTK_ALIGN_START,
+ "valign", GTK_ALIGN_START,
+ "hexpand", TRUE,
+ "margin-start", 20, NULL);
+ gtk_label_set_line_wrap (GTK_LABEL (priv->prov_name), TRUE);
+ gtk_label_set_selectable (GTK_LABEL (priv->prov_name), TRUE);
+ gtk_grid_attach (GTK_GRID (grid), priv->prov_name, 0, 0, 1, 1);
+ gtk_widget_set_size_request (priv->prov_name, -1, 96);
+
+ priv->prov_loc = gtk_label_new ("");
+ gtk_label_set_line_wrap (GTK_LABEL (priv->prov_loc), TRUE);
+ g_object_set (priv->prov_loc,
+ "xalign", 0.,
+ "halign", GTK_ALIGN_START,
+ "hexpand", TRUE,
+ "margin-start", 20, NULL);
+ gtk_widget_set_hexpand (priv->prov_loc, TRUE);
+ gtk_label_set_selectable (GTK_LABEL (priv->prov_loc), TRUE);
+ gtk_grid_attach (GTK_GRID (grid), priv->prov_loc, 0, 1, 2, 1);
+
+ gtk_widget_show_all (grid);
+ gdaui_data_selector_select_row (GDAUI_DATA_SELECTOR (priv->provider_list), 0);
return provider;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]