From 318523f0bff428b5cf1a3e64a3a4d3aaca97d054 Mon Sep 17 00:00:00 2001 From: raveit65 Date: Sat, 6 Aug 2016 11:32:51 +0200 Subject: GTK+-3.0 baobab: port GtkTable to GtkGrid --- baobab/src/baobab-remote-connect-dialog.c | 140 ++++++++++++++++++++++++++++-- 1 file changed, 132 insertions(+), 8 deletions(-) (limited to 'baobab/src/baobab-remote-connect-dialog.c') diff --git a/baobab/src/baobab-remote-connect-dialog.c b/baobab/src/baobab-remote-connect-dialog.c index a1a95132..a8db624f 100644 --- a/baobab/src/baobab-remote-connect-dialog.c +++ b/baobab/src/baobab-remote-connect-dialog.c @@ -44,7 +44,11 @@ struct _BaobabRemoteConnectDialogDetails { +#if GTK_CHECK_VERSION (3, 0, 0) + GtkWidget *grid; +#else GtkWidget *table; +#endif GtkWidget *type_combo; GtkWidget *uri_entry; @@ -391,7 +395,11 @@ setup_for_type (BaobabRemoteConnectDialog *dialog) { struct MethodInfo *meth; int index, i; +#if GTK_CHECK_VERSION (3, 0, 0) + GtkWidget *label, *grid; +#else GtkWidget *label, *table; +#endif GtkTreeIter iter; /* Get our method info */ @@ -401,6 +409,42 @@ setup_for_type (BaobabRemoteConnectDialog *dialog) g_assert (index < G_N_ELEMENTS (methods) && index >= 0); meth = &(methods[index]); +#if GTK_CHECK_VERSION (3, 0, 0) + if (gtk_widget_get_parent (dialog->details->uri_entry) != NULL) { + gtk_container_remove (GTK_CONTAINER (dialog->details->grid), + dialog->details->uri_entry); + } + if (gtk_widget_get_parent (dialog->details->server_entry) != NULL) { + gtk_container_remove (GTK_CONTAINER (dialog->details->grid), + dialog->details->server_entry); + } + if (gtk_widget_get_parent (dialog->details->share_entry) != NULL) { + gtk_container_remove (GTK_CONTAINER (dialog->details->grid), + dialog->details->share_entry); + } + if (gtk_widget_get_parent (dialog->details->port_entry) != NULL) { + gtk_container_remove (GTK_CONTAINER (dialog->details->grid), + dialog->details->port_entry); + } + if (gtk_widget_get_parent (dialog->details->folder_entry) != NULL) { + gtk_container_remove (GTK_CONTAINER (dialog->details->grid), + dialog->details->folder_entry); + } + if (gtk_widget_get_parent (dialog->details->user_entry) != NULL) { + gtk_container_remove (GTK_CONTAINER (dialog->details->grid), + dialog->details->user_entry); + } + if (gtk_widget_get_parent (dialog->details->domain_entry) != NULL) { + gtk_container_remove (GTK_CONTAINER (dialog->details->grid), + dialog->details->domain_entry); + } + /* Destroy all labels */ + gtk_container_foreach (GTK_CONTAINER (dialog->details->grid), + (GtkCallback) gtk_widget_destroy, NULL); + + i = 1; + grid = dialog->details->grid; +#else if (gtk_widget_get_parent (dialog->details->uri_entry) != NULL) { gtk_container_remove (GTK_CONTAINER (dialog->details->table), dialog->details->uri_entry); @@ -433,9 +477,9 @@ setup_for_type (BaobabRemoteConnectDialog *dialog) gtk_container_foreach (GTK_CONTAINER (dialog->details->table), (GtkCallback) gtk_widget_destroy, NULL); - i = 1; table = dialog->details->table; +#endif if (meth->scheme == NULL) { label = gtk_label_new_with_mnemonic (_("_Location (URI):")); @@ -446,12 +490,20 @@ setup_for_type (BaobabRemoteConnectDialog *dialog) gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); #endif gtk_widget_show (label); +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_grid_attach (GTK_GRID (grid), label, 0, i, 1, 1); + + gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->uri_entry); + gtk_widget_set_hexpand (dialog->details->uri_entry, TRUE); + gtk_widget_show (dialog->details->uri_entry); + gtk_grid_attach (GTK_GRID (grid), dialog->details->uri_entry, 1, i, 1, 1); +#else gtk_table_attach (GTK_TABLE (table), label, 0, 1, i, i+1, GTK_FILL, GTK_FILL, 0, 0); - + gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->uri_entry); gtk_widget_show (dialog->details->uri_entry); gtk_table_attach (GTK_TABLE (table), dialog->details->uri_entry, @@ -459,6 +511,7 @@ setup_for_type (BaobabRemoteConnectDialog *dialog) i, i+1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); +#endif i++; @@ -473,12 +526,20 @@ setup_for_type (BaobabRemoteConnectDialog *dialog) gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); #endif gtk_widget_show (label); +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_grid_attach (GTK_GRID (grid), label, 0, i, 1, 1); + + gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->server_entry); + gtk_widget_set_hexpand (dialog->details->server_entry, TRUE); + gtk_widget_show (dialog->details->server_entry); + gtk_grid_attach (GTK_GRID (grid), dialog->details->server_entry, 1, i, 1, 1); +#else gtk_table_attach (GTK_TABLE (table), label, 0, 1, i, i+1, GTK_FILL, GTK_FILL, 0, 0); - + gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->server_entry); gtk_widget_show (dialog->details->server_entry); gtk_table_attach (GTK_TABLE (table), dialog->details->server_entry, @@ -486,6 +547,7 @@ setup_for_type (BaobabRemoteConnectDialog *dialog) i, i+1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); +#endif i++; @@ -497,11 +559,15 @@ setup_for_type (BaobabRemoteConnectDialog *dialog) gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); #endif gtk_widget_show (label); +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_grid_attach (GTK_GRID (grid), label, 0, i, 2, 1); +#else gtk_table_attach (GTK_TABLE (table), label, 0, 2, i, i+1, GTK_FILL, GTK_FILL, 0, 0); +#endif i++; @@ -514,12 +580,20 @@ setup_for_type (BaobabRemoteConnectDialog *dialog) gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); #endif gtk_widget_show (label); +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_grid_attach (GTK_GRID (grid), label, 0, i, 1, 1); + + gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->share_entry); + gtk_widget_set_hexpand (dialog->details->share_entry, TRUE); + gtk_widget_show (dialog->details->share_entry); + gtk_grid_attach (GTK_GRID (grid), dialog->details->share_entry, 1, i, 1, 1); +#else gtk_table_attach (GTK_TABLE (table), label, 0, 1, i, i+1, GTK_FILL, GTK_FILL, 0, 0); - + gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->share_entry); gtk_widget_show (dialog->details->share_entry); gtk_table_attach (GTK_TABLE (table), dialog->details->share_entry, @@ -527,6 +601,7 @@ setup_for_type (BaobabRemoteConnectDialog *dialog) i, i+1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); +#endif i++; } @@ -540,12 +615,20 @@ setup_for_type (BaobabRemoteConnectDialog *dialog) gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); #endif gtk_widget_show (label); +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_grid_attach (GTK_GRID (grid), label, 0, i, 1, 1); + + gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->port_entry); + gtk_widget_set_hexpand (dialog->details->port_entry, TRUE); + gtk_widget_show (dialog->details->port_entry); + gtk_grid_attach (GTK_GRID (grid), dialog->details->port_entry, 1, i, 1, 1); +#else gtk_table_attach (GTK_TABLE (table), label, 0, 1, i, i+1, GTK_FILL, GTK_FILL, 0, 0); - + gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->port_entry); gtk_widget_show (dialog->details->port_entry); gtk_table_attach (GTK_TABLE (table), dialog->details->port_entry, @@ -553,6 +636,7 @@ setup_for_type (BaobabRemoteConnectDialog *dialog) i, i+1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); +#endif i++; } @@ -565,12 +649,20 @@ setup_for_type (BaobabRemoteConnectDialog *dialog) gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); #endif gtk_widget_show (label); +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_grid_attach (GTK_GRID (grid), label, 0, i, 1, 1); + + gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->folder_entry); + gtk_widget_set_hexpand (dialog->details->folder_entry, TRUE); + gtk_widget_show (dialog->details->folder_entry); + gtk_grid_attach (GTK_GRID (grid), dialog->details->folder_entry, 1, i, 1, 1); +#else gtk_table_attach (GTK_TABLE (table), label, 0, 1, i, i+1, GTK_FILL, GTK_FILL, 0, 0); - + gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->folder_entry); gtk_widget_show (dialog->details->folder_entry); gtk_table_attach (GTK_TABLE (table), dialog->details->folder_entry, @@ -578,6 +670,7 @@ setup_for_type (BaobabRemoteConnectDialog *dialog) i, i+1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); +#endif i++; @@ -590,12 +683,20 @@ setup_for_type (BaobabRemoteConnectDialog *dialog) gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); #endif gtk_widget_show (label); +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_grid_attach (GTK_GRID (grid), label, 0, i, 1, 1); + + gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->user_entry); + gtk_widget_set_hexpand (dialog->details->user_entry, TRUE); + gtk_widget_show (dialog->details->user_entry); + gtk_grid_attach (GTK_GRID (grid), dialog->details->user_entry, 1, i, 1, 1); +#else gtk_table_attach (GTK_TABLE (table), label, 0, 1, i, i+1, GTK_FILL, GTK_FILL, 0, 0); - + gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->user_entry); gtk_widget_show (dialog->details->user_entry); gtk_table_attach (GTK_TABLE (table), dialog->details->user_entry, @@ -603,6 +704,7 @@ setup_for_type (BaobabRemoteConnectDialog *dialog) i, i+1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); +#endif i++; } @@ -616,6 +718,14 @@ setup_for_type (BaobabRemoteConnectDialog *dialog) gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); #endif gtk_widget_show (label); +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_grid_attach (GTK_GRID (grid), label, 0, i, 1, 1); + + gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->domain_entry); + gtk_widget_set_hexpand (dialog->details->user_entry, TRUE); + gtk_widget_show (dialog->details->domain_entry); + gtk_grid_attach (GTK_GRID (grid), dialog->details->domain_entry, 1, i, 1, 1); +#else gtk_table_attach (GTK_TABLE (table), label, 0, 1, i, i+1, @@ -629,6 +739,7 @@ setup_for_type (BaobabRemoteConnectDialog *dialog) i, i+1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); +#endif i++; } @@ -670,7 +781,11 @@ static void baobab_remote_connect_dialog_init (BaobabRemoteConnectDialog *dialog) { GtkWidget *label; +#if GTK_CHECK_VERSION (3, 0, 0) + GtkWidget *grid; +#else GtkWidget *table; +#endif GtkWidget *combo; GtkWidget *hbox; GtkWidget *vbox; @@ -789,13 +904,22 @@ baobab_remote_connect_dialog_init (BaobabRemoteConnectDialog *dialog) gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - + +#if GTK_CHECK_VERSION (3, 0, 0) + dialog->details->grid = grid = gtk_grid_new (); + gtk_grid_set_row_spacing (GTK_GRID (grid), 6); + gtk_grid_set_column_spacing (GTK_GRID (grid), 12); + gtk_widget_show (grid); + gtk_box_pack_start (GTK_BOX (hbox), + grid, TRUE, TRUE, 0); +#else dialog->details->table = table = gtk_table_new (5, 2, FALSE); gtk_table_set_row_spacings (GTK_TABLE (table), 6); gtk_table_set_col_spacings (GTK_TABLE (table), 12); gtk_widget_show (table); gtk_box_pack_start (GTK_BOX (hbox), table, TRUE, TRUE, 0); +#endif //dialog->details->uri_entry = caja_location_entry_new (); dialog->details->uri_entry = gtk_entry_new(); -- cgit v1.2.1