[gnome-commander] Maximizes the device list entry width according to the longest string inside the list



commit 350bbb5ecdfe4512c8843e00adb79693e1db5c5b
Author: Uwe Scholz <uwescholz src gnome org>
Date:   Sun Oct 30 21:06:10 2016 +0100

    Maximizes the device list entry width according to the longest string inside the list

 src/gnome-cmd-file-selector.cc |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/src/gnome-cmd-file-selector.cc b/src/gnome-cmd-file-selector.cc
index 8e1b0da..313e580 100644
--- a/src/gnome-cmd-file-selector.cc
+++ b/src/gnome-cmd-file-selector.cc
@@ -765,6 +765,9 @@ static void class_init (GnomeCmdFileSelectorClass *klass)
 
 static void init (GnomeCmdFileSelector *fs)
 {
+    gint string_size = 0;
+    gint max_string_size = 0;
+
     fs->list = NULL;
 
     fs->priv = new GnomeCmdFileSelector::Private;
@@ -780,11 +783,29 @@ static void init (GnomeCmdFileSelector *fs)
     // create the notebook and the first tab
     fs->notebook = new GnomeCmdNotebook;
 
+    for (GList *l=gnome_cmd_con_list_get_all (gnome_cmd_con_list_get ()); l; l = l->next)
+    {
+        gchar *text;
+        GnomeCmdCon *con = (GnomeCmdCon *) l->data;
+
+#ifdef HAVE_SAMBA
+        if (!gnome_cmd_con_is_open (con) && !GNOME_CMD_IS_CON_DEVICE (con)
+            && !GNOME_CMD_IS_CON_SMB (con))  continue;
+#else
+        if (!gnome_cmd_con_is_open (con) && !GNOME_CMD_IS_CON_DEVICE (con))  continue;
+#endif
+
+        text = g_strdup_printf("%s ",(gchar *) gnome_cmd_con_get_alias (con));
+        string_size = get_string_pixel_size (text, strlen(text));
+        max_string_size = string_size > max_string_size ? string_size : max_string_size;
+        g_free(text);
+    }
+
     // create the connection combo
     fs->con_combo = new GnomeCmdCombo(2, 1);
     g_object_ref (fs->con_combo);
     g_object_set_data_full (*fs, "con_combo", fs->con_combo, g_object_unref);
-    gtk_widget_set_size_request (*fs->con_combo, 150, -1);
+    gtk_widget_set_size_request (*fs->con_combo, max_string_size + 5, -1);
     gtk_clist_set_row_height (GTK_CLIST (fs->con_combo->list), 20);
     gtk_entry_set_editable (GTK_ENTRY (fs->con_combo->entry), FALSE);
     gtk_clist_set_column_width (GTK_CLIST (fs->con_combo->list), 0, 20);


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