[gnome-color-manager] trivial: Ellipsize the dialog elements properly rather than just chopping off text
- From: Richard Hughes <rhughes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] trivial: Ellipsize the dialog elements properly rather than just chopping off text
- Date: Wed, 6 Jan 2010 12:01:28 +0000 (UTC)
commit a1990a002b2a552eb59b99481617502c4815767a
Author: Richard Hughes <richard hughsie com>
Date: Wed Jan 6 11:04:04 2010 +0000
trivial: Ellipsize the dialog elements properly rather than just chopping off text
data/gcm-prefs.ui | 4 --
src/gcm-prefs.c | 32 ++++++++++++-------
src/gcm-profile.c | 4 --
src/gcm-utils.c | 89 -----------------------------------------------------
4 files changed, 20 insertions(+), 109 deletions(-)
---
diff --git a/data/gcm-prefs.ui b/data/gcm-prefs.ui
index 530aa43..1e3785d 100644
--- a/data/gcm-prefs.ui
+++ b/data/gcm-prefs.ui
@@ -1363,7 +1363,6 @@
<object class="GtkHBox" id="hbox42">
<property name="visible">True</property>
<property name="spacing">9</property>
- <property name="homogeneous">True</property>
<child>
<object class="GtkHBox" id="hbox43">
<property name="visible">True</property>
@@ -1401,7 +1400,6 @@
<object class="GtkHBox" id="hbox44">
<property name="visible">True</property>
<property name="spacing">9</property>
- <property name="homogeneous">True</property>
<child>
<object class="GtkHBox" id="hbox46">
<property name="visible">True</property>
@@ -1479,7 +1477,6 @@
<object class="GtkHBox" id="hbox14">
<property name="visible">True</property>
<property name="spacing">9</property>
- <property name="homogeneous">True</property>
<child>
<object class="GtkHBox" id="hbox15">
<property name="visible">True</property>
@@ -1517,7 +1514,6 @@
<object class="GtkHBox" id="hbox16">
<property name="visible">True</property>
<property name="spacing">9</property>
- <property name="homogeneous">True</property>
<child>
<object class="GtkHBox" id="hbox17">
<property name="visible">True</property>
diff --git a/src/gcm-prefs.c b/src/gcm-prefs.c
index 555f389..1101d9b 100644
--- a/src/gcm-prefs.c
+++ b/src/gcm-prefs.c
@@ -1266,6 +1266,11 @@ gcm_prefs_add_devices_columns (GtkTreeView *treeview)
/* column for text */
renderer = gtk_cell_renderer_text_new ();
+ g_object_set (renderer,
+ "ellipsize", PANGO_ELLIPSIZE_END,
+ "wrap-mode", PANGO_WRAP_WORD_CHAR,
+ "width-chars", 40,
+ NULL);
column = gtk_tree_view_column_new_with_attributes ("", renderer,
"markup", GCM_DEVICES_COLUMN_TITLE, NULL);
gtk_tree_view_column_set_sort_column_id (column, GCM_DEVICES_COLUMN_SORT);
@@ -1292,6 +1297,11 @@ gcm_prefs_add_profiles_columns (GtkTreeView *treeview)
/* column for text */
renderer = gtk_cell_renderer_text_new ();
+ g_object_set (renderer,
+ "ellipsize", PANGO_ELLIPSIZE_END,
+ "wrap-mode", PANGO_WRAP_WORD_CHAR,
+ "width-chars", 50,
+ NULL);
column = gtk_tree_view_column_new_with_attributes ("", renderer,
"markup", GCM_PROFILES_COLUMN_TITLE, NULL);
gtk_tree_view_column_set_sort_column_id (column, GCM_PROFILES_COLUMN_SORT);
@@ -1919,16 +1929,21 @@ gcm_prefs_add_device_xrandr (GcmDevice *device)
static void
gcm_prefs_set_combo_simple_text (GtkWidget *combo_box)
{
- GtkCellRenderer *cell;
+ GtkCellRenderer *renderer;
GtkListStore *store;
store = gtk_list_store_new (2, G_TYPE_STRING, GCM_TYPE_PROFILE);
gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), GTK_TREE_MODEL (store));
g_object_unref (store);
- cell = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell, TRUE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell,
+ renderer = gtk_cell_renderer_text_new ();
+ g_object_set (renderer,
+ "ellipsize", PANGO_ELLIPSIZE_END,
+ "wrap-mode", PANGO_WRAP_WORD_CHAR,
+ "width-chars", 60,
+ NULL);
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, TRUE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), renderer,
"text", GCM_PREFS_COMBO_COLUMN_TEXT,
NULL);
}
@@ -2150,13 +2165,7 @@ gcm_prefs_add_device_type (GcmDevice *device)
/* italic for non-connected devices */
if (!connected) {
/* TRANSLATORS: this is where the device has been setup but is not connected */
- g_string_append_printf (string, " <i>[%s]</i>", _("disconnected"));
- }
-
- /* use a different title for stuff that won't work yet */
- if (type != GCM_DEVICE_TYPE_DISPLAY) {
- /* TRANSLATORS: this is where the required software has not been written yet */
- g_string_append_printf (string, "\n(%s)", _("No software support"));
+ g_string_append_printf (string, "\n<i>[%s]</i>", _("disconnected"));
}
/* create sort order */
@@ -2903,7 +2912,6 @@ main (int argc, char **argv)
gtk_box_pack_start (GTK_BOX(widget), info_bar, FALSE, FALSE, 0);
/* show main UI */
- gtk_window_set_default_size (GTK_WINDOW (main_window), 700, 280);
gtk_widget_show (main_window);
/* connect up sliders */
diff --git a/src/gcm-profile.c b/src/gcm-profile.c
index d60d158..7c80202 100644
--- a/src/gcm-profile.c
+++ b/src/gcm-profile.c
@@ -347,10 +347,6 @@ gcm_profile_set_property (GObject *object, guint prop_id, const GValue *value, G
if (priv->description != NULL)
gcm_utils_ensure_printable (priv->description);
- /* some profile_lcms1s have _really_ long titles - Microsoft, I'm looking at you... */
- if (priv->description != NULL)
- gcm_utils_ensure_sane_length (priv->description, 80);
-
/* there's nothing sensible to display */
if (priv->description == NULL || priv->description[0] == '\0') {
g_free (priv->description);
diff --git a/src/gcm-utils.c b/src/gcm-utils.c
index 8ffb5e3..32ac067 100644
--- a/src/gcm-utils.c
+++ b/src/gcm-utils.c
@@ -221,45 +221,6 @@ gcm_utils_output_is_lcd (const gchar *output_name)
}
/**
- * gcm_utils_ensure_sane_length:
- **/
-void
-gcm_utils_ensure_sane_length (gchar *text, guint max_length)
-{
- guint i;
- guint len;
-
- g_return_if_fail (text != NULL);
-
- /* get length */
- len = strlen (text);
-
- /* check we have room for ellipsis */
- if (len <= max_length - 4)
- return;
-
- /* already correct len */
- if (len == max_length)
- return;
-
- /* truncate, finding prior word break */
- for (i=max_length-1; i>0; i--) {
- if (text[i] == ' ')
- break;
- }
-
- /* one long string with no spaces */
- if (i == 0)
- i = max_length - 3;
-
- /* ellipsis */
- text[i+0] = '.';
- text[i+1] = '.';
- text[i+2] = '.';
- text[i+3] = '\0';
-}
-
-/**
* gcm_utils_ensure_printable:
**/
void
@@ -1062,56 +1023,6 @@ gcm_utils_test (EggTest *test)
g_free (text);
/************************************************************/
- egg_test_title (test, "check sane length high");
- text = g_strdup ("1234 67890");
- gcm_utils_ensure_sane_length (text, 1024);
- if (g_strcmp0 (text, "1234 67890") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value: %s", text);
- g_free (text);
-
- /************************************************************/
- egg_test_title (test, "check sane length limit");
- text = g_strdup ("1234 67890");
- gcm_utils_ensure_sane_length (text, 10);
- if (g_strcmp0 (text, "1234 67890") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value: %s", text);
- g_free (text);
-
- /************************************************************/
- egg_test_title (test, "check sane length truncate");
- text = g_strdup ("1234 67890");
- gcm_utils_ensure_sane_length (text, 8);
- if (g_strcmp0 (text, "1234...") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value: %s", text);
- g_free (text);
-
- /************************************************************/
- egg_test_title (test, "check sane length no spaces");
- text = g_strdup ("1234 67890");
- gcm_utils_ensure_sane_length (text, 4);
- if (g_strcmp0 (text, "1...") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value: %s", text);
- g_free (text);
-
- /************************************************************/
- egg_test_title (test, "check sane length no data");
- text = g_strdup ("");
- gcm_utils_ensure_sane_length (text, 4);
- if (g_strcmp0 (text, "") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value: %s", text);
- g_free (text);
-
- /************************************************************/
egg_test_title (test, "get default config location (when in make check)");
filename = gcm_utils_get_default_config_location ();
if (g_strcmp0 (filename, "/tmp/device-profiles.conf") == 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]