aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2010-12-11 01:40:05 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2010-12-11 02:44:00 +0100
commit74e43ceee4aac43277526843436f653a6b932910 (patch)
treeb5790957637938bbd6416f1126cbd963cbc99de1
parentaeb6e7ed58c7f327a958d3b7f7d84152fa770219 (diff)
downloadlogdiag-74e43ceee4aac43277526843436f653a6b932910.tar.gz
logdiag-74e43ceee4aac43277526843436f653a6b932910.tar.xz
logdiag-74e43ceee4aac43277526843436f653a6b932910.zip
Add a "human-name" property to LdSymbolCategory.
Just as LdSymbol has a human name for localization purposes, LdSymbolCategory also needs to have this property. Use the human name in tooltips.
-rw-r--r--src/ld-library.c2
-rw-r--r--src/ld-symbol-category.c59
-rw-r--r--src/ld-symbol-category.h6
-rw-r--r--src/ld-window-main.c6
4 files changed, 66 insertions, 7 deletions
diff --git a/src/ld-library.c b/src/ld-library.c
index 12e01ec..a3f1e39 100644
--- a/src/ld-library.c
+++ b/src/ld-library.c
@@ -195,7 +195,7 @@ load_category (LdLibrary *self, const char *path, const char *name)
/* TODO: Search for category.json and read the category name from it. */
- cat = ld_symbol_category_new (name);
+ cat = ld_symbol_category_new (name, name);
ld_symbol_category_set_image_path (cat, icon_file);
data.self = self;
diff --git a/src/ld-symbol-category.c b/src/ld-symbol-category.c
index 784c8d3..6f0c673 100644
--- a/src/ld-symbol-category.c
+++ b/src/ld-symbol-category.c
@@ -34,6 +34,7 @@
struct _LdSymbolCategoryPrivate
{
gchar *name;
+ gchar *human_name;
gchar *image_path;
GSList *children;
};
@@ -44,6 +45,7 @@ enum
{
PROP_0,
PROP_NAME,
+ PROP_HUMAN_NAME,
PROP_IMAGE_PATH
};
@@ -81,6 +83,16 @@ ld_symbol_category_class_init (LdSymbolCategoryClass *klass)
g_object_class_install_property (object_class, PROP_NAME, pspec);
/**
+ * LdSymbolCategory:human-name:
+ *
+ * The localized human name of this symbol category.
+ */
+ pspec = g_param_spec_string ("human-name", "Human name",
+ "The localized human name of this symbol category.",
+ "", G_PARAM_READWRITE);
+ g_object_class_install_property (object_class, PROP_NAME, pspec);
+
+/**
* LdSymbolCategory:image-path:
*
* Path to an image file representing this category.
@@ -112,6 +124,9 @@ ld_symbol_category_get_property (GObject *object, guint property_id,
case PROP_NAME:
g_value_set_string (value, ld_symbol_category_get_name (self));
break;
+ case PROP_HUMAN_NAME:
+ g_value_set_string (value, ld_symbol_category_get_human_name (self));
+ break;
case PROP_IMAGE_PATH:
g_value_set_string (value, ld_symbol_category_get_image_path (self));
break;
@@ -132,6 +147,9 @@ ld_symbol_category_set_property (GObject *object, guint property_id,
case PROP_NAME:
ld_symbol_category_set_name (self, g_value_get_string (value));
break;
+ case PROP_HUMAN_NAME:
+ ld_symbol_category_set_human_name (self, g_value_get_string (value));
+ break;
case PROP_IMAGE_PATH:
ld_symbol_category_set_image_path (self, g_value_get_string (value));
break;
@@ -149,6 +167,8 @@ ld_symbol_category_finalize (GObject *gobject)
if (self->priv->name)
g_free (self->priv->name);
+ if (self->priv->human_name)
+ g_free (self->priv->human_name);
if (self->priv->image_path)
g_free (self->priv->image_path);
@@ -161,17 +181,22 @@ ld_symbol_category_finalize (GObject *gobject)
/**
* ld_symbol_category_new:
- * @name: The name of this category.
+ * @name: The name of the new category.
+ * @human_name: The localized human name of the new category.
*
* Create an instance.
*/
LdSymbolCategory *
-ld_symbol_category_new (const gchar *name)
+ld_symbol_category_new (const gchar *name, const gchar *human_name)
{
LdSymbolCategory *cat;
+ g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (human_name != NULL, NULL);
+
cat = g_object_new (LD_TYPE_SYMBOL_CATEGORY, NULL);
cat->priv->name = g_strdup (name);
+ cat->priv->human_name = g_strdup (human_name);
return cat;
}
@@ -206,6 +231,36 @@ ld_symbol_category_get_name (LdSymbolCategory *self)
}
/**
+ * ld_symbol_category_set_human_name:
+ * @self: An #LdSymbolCategory object.
+ * @name: The new localized human name for this category.
+ */
+void
+ld_symbol_category_set_human_name (LdSymbolCategory *self,
+ const gchar *human_name)
+{
+ g_return_if_fail (LD_IS_SYMBOL_CATEGORY (self));
+ g_return_if_fail (human_name != NULL);
+
+ if (self->priv->human_name)
+ g_free (self->priv->human_name);
+ self->priv->human_name = g_strdup (human_name);
+}
+
+/**
+ * ld_symbol_category_get_human_name:
+ * @self: An #LdSymbolCategory object.
+ *
+ * Return the localized human name of this category.
+ */
+const gchar *
+ld_symbol_category_get_human_name (LdSymbolCategory *self)
+{
+ g_return_val_if_fail (LD_IS_SYMBOL_CATEGORY (self), NULL);
+ return self->priv->human_name;
+}
+
+/**
* ld_symbol_category_set_image_path:
* @self: An #LdSymbolCategory object.
* @image_path: The new path to the image for this category. May be NULL.
diff --git a/src/ld-symbol-category.h b/src/ld-symbol-category.h
index 113bf83..3b1f05b 100644
--- a/src/ld-symbol-category.h
+++ b/src/ld-symbol-category.h
@@ -54,10 +54,14 @@ struct _LdSymbolCategoryClass
GType ld_symbol_category_get_type (void) G_GNUC_CONST;
-LdSymbolCategory *ld_symbol_category_new (const gchar *name);
+LdSymbolCategory *ld_symbol_category_new (const gchar *name,
+ const gchar *human_name);
void ld_symbol_category_set_name (LdSymbolCategory *self, const gchar *name);
const gchar *ld_symbol_category_get_name (LdSymbolCategory *self);
+void ld_symbol_category_set_human_name (LdSymbolCategory *self,
+ const gchar *human_name);
+const gchar *ld_symbol_category_get_human_name (LdSymbolCategory *self);
void ld_symbol_category_set_image_path (LdSymbolCategory *self,
const gchar *image_path);
const gchar *ld_symbol_category_get_image_path (LdSymbolCategory *self);
diff --git a/src/ld-window-main.c b/src/ld-window-main.c
index 99910d8..60129cf 100644
--- a/src/ld-window-main.c
+++ b/src/ld-window-main.c
@@ -367,7 +367,7 @@ load_category_cb (gpointer data, gpointer user_data)
{
LdWindowMain *self;
LdSymbolCategory *cat;
- const gchar *name;
+ const gchar *human_name;
GdkPixbuf *pbuf;
GtkWidget *img;
GtkToolItem *item;
@@ -379,7 +379,7 @@ load_category_cb (gpointer data, gpointer user_data)
self = user_data;
cat = data;
- name = ld_symbol_category_get_name (cat);
+ human_name = ld_symbol_category_get_human_name (cat);
pbuf = gdk_pixbuf_new_from_file_at_size
(ld_symbol_category_get_image_path (cat), TOOLBAR_ICON_WIDTH, -1, NULL);
@@ -401,7 +401,7 @@ load_category_cb (gpointer data, gpointer user_data)
/* Hook toggling of the button. */
g_signal_connect (button, "toggled", G_CALLBACK (on_category_toggle), self);
- gtk_tool_item_set_tooltip_text (item, name);
+ gtk_tool_item_set_tooltip_text (item, human_name);
gtk_toolbar_insert (GTK_TOOLBAR (self->priv->toolbar), item, 0);
}