libegg r864 - in trunk: . libegg/toolpalette
- From: hasselmm svn gnome org
- To: svn-commits-list gnome org
- Subject: libegg r864 - in trunk: . libegg/toolpalette
- Date: Fri, 28 Mar 2008 21:28:18 +0000 (GMT)
Author: hasselmm
Date: Fri Mar 28 21:28:18 2008
New Revision: 864
URL: http://svn.gnome.org/viewvc/libegg?rev=864&view=rev
Log:
Support "ellipsize" property for EggToolItemGroup.
* libegg/toolpalette/eggenumaction.c,
libegg/toolpalette/eggenumaction.h:
Add egg_enum_action_connect().
* libegg/toolpalette/eggtoolitemgroup.c,
libegg/toolpalette/eggtoolitemgroup.h:
Add "ellipsize" property and accessors.
* libegg/toolpalette/testtoolpalette.c:
Allow adjustment for "ellipsize" property.
Modified:
trunk/ChangeLog
trunk/libegg/toolpalette/eggenumaction.c
trunk/libegg/toolpalette/eggenumaction.h
trunk/libegg/toolpalette/eggtoolitemgroup.c
trunk/libegg/toolpalette/eggtoolitemgroup.h
trunk/libegg/toolpalette/testtoolpalette.c
Modified: trunk/libegg/toolpalette/eggenumaction.c
==============================================================================
--- trunk/libegg/toolpalette/eggenumaction.c (original)
+++ trunk/libegg/toolpalette/eggenumaction.c Fri Mar 28 21:28:18 2008
@@ -35,11 +35,12 @@
GType enum_type;
GEnumClass *enum_class;
GSList *bindings;
+ GSList *callbacks;
GtkListStore *model;
EggEnumActionFilterFunc filter_func;
- GDestroyNotify filter_destroy;
- gpointer filter_data;
+ GDestroyNotify filter_destroy;
+ gpointer filter_data;
};
static GQuark egg_enum_action_child_quark;
@@ -135,6 +136,12 @@
action->priv->bindings->data);
}
+ if (action->priv->callbacks)
+ {
+ g_slist_free (action->priv->callbacks);
+ action->priv->callbacks = NULL;
+ }
+
if (action->priv->filter_destroy)
{
action->priv->filter_destroy (action->priv->filter_data);
@@ -226,18 +233,24 @@
static void
egg_enum_action_set_value (EggEnumAction *action,
- gint value)
+ GEnumValue *enum_value)
{
- GSList *binding = action->priv->bindings;
+ GSList *iter;
- while (binding)
+ for (iter = action->priv->bindings; iter; iter = iter->next->next)
{
- GParamSpec *property = binding->data;
- GObject *object = binding->next->data;
+ GParamSpec *property = iter->data;
+ GObject *object = iter->next->data;
- g_object_set (object, property->name, value, NULL);
+ g_object_set (object, property->name, enum_value->value, NULL);
+ }
+
+ for (iter = action->priv->callbacks; iter; iter = iter->next->next)
+ {
+ EggEnumActionCallback callback = iter->next->data;
+ gpointer user_data = iter->data;
- binding = binding->next->next;
+ callback (enum_value, user_data);
}
}
@@ -254,7 +267,7 @@
{
model = egg_enum_action_get_model (action);
gtk_tree_model_get (model, &iter, 1, &enum_value, -1);
- egg_enum_action_set_value (action, enum_value->value);
+ egg_enum_action_set_value (action, enum_value);
}
}
@@ -349,7 +362,7 @@
GEnumValue *enum_value;
enum_value = g_object_get_qdata (G_OBJECT (item), egg_enum_action_value_quark);
- egg_enum_action_set_value (EGG_ENUM_ACTION (data), enum_value->value);
+ egg_enum_action_set_value (EGG_ENUM_ACTION (data), enum_value);
}
static GtkWidget*
@@ -511,6 +524,18 @@
}
void
+egg_enum_action_connect (EggEnumAction *action,
+ EggEnumActionCallback callback,
+ gpointer data)
+{
+ g_return_if_fail (EGG_IS_ENUM_ACTION (action));
+ g_return_if_fail (NULL != callback);
+
+ action->priv->callbacks = g_slist_prepend (action->priv->callbacks, callback);
+ action->priv->callbacks = g_slist_prepend (action->priv->callbacks, data);
+}
+
+void
egg_enum_action_set_filter (EggEnumAction *action,
EggEnumActionFilterFunc filter,
gpointer user_data,
Modified: trunk/libegg/toolpalette/eggenumaction.h
==============================================================================
--- trunk/libegg/toolpalette/eggenumaction.h (original)
+++ trunk/libegg/toolpalette/eggenumaction.h Fri Mar 28 21:28:18 2008
@@ -37,6 +37,8 @@
typedef struct _EggEnumActionClass EggEnumActionClass;
typedef struct _EggEnumActionPrivate EggEnumActionPrivate;
+typedef void (*EggEnumActionCallback) (GEnumValue *enum_value,
+ gpointer user_data);
typedef gboolean (*EggEnumActionFilterFunc) (GEnumValue *enum_value,
gpointer user_data);
@@ -60,6 +62,9 @@
void egg_enum_action_bind (EggEnumAction *action,
GObject *object,
const gchar *property_name);
+void egg_enum_action_connect (EggEnumAction *action,
+ EggEnumActionCallback callback,
+ gpointer data);
void egg_enum_action_set_filter (EggEnumAction *action,
EggEnumActionFilterFunc filter,
Modified: trunk/libegg/toolpalette/eggtoolitemgroup.c
==============================================================================
--- trunk/libegg/toolpalette/eggtoolitemgroup.c (original)
+++ trunk/libegg/toolpalette/eggtoolitemgroup.c Fri Mar 28 21:28:18 2008
@@ -32,29 +32,36 @@
#define P_(msgid) (msgid)
+#define DEFAULT_NAME NULL
+#define DEFAULT_EXPANDED TRUE
+#define DEFAULT_ELLIPSIZE PANGO_ELLIPSIZE_NONE
+
enum
{
PROP_NONE,
PROP_NAME,
- PROP_EXPANED,
+ PROP_EXPANDED,
+ PROP_ELLIPSIZE,
};
struct _EggToolItemGroupPrivate
{
- GtkWidget *header;
+ GtkWidget *header;
+
+ GtkToolItem **items;
+ gsize items_size;
+ gsize items_length;
+
+ gint64 animation_start;
+ GSource *animation_timeout;
+ GtkExpanderStyle expander_style;
+ gint expander_size;
+ gint header_spacing;
+ PangoEllipsizeMode ellipsize;
- GtkToolItem **items;
- gsize items_size;
- gsize items_length;
-
- gint64 animation_start;
- GSource *animation_timeout;
- GtkExpanderStyle expander_style;
- gint expander_size;
- gint header_spacing;
+ guint sparse_items : 1;
+ guint expanded : 1;
- guint sparse_items : 1;
- guint expanded : 1;
};
#ifdef GTK_TYPE_TOOL_SHELL
@@ -227,11 +234,13 @@
{
case GTK_ORIENTATION_HORIZONTAL:
dy = group->priv->header_spacing + group->priv->expander_size;
+ gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_NONE);
gtk_label_set_angle (GTK_LABEL (label), 90);
break;
case GTK_ORIENTATION_VERTICAL:
dx = group->priv->header_spacing + group->priv->expander_size;
+ gtk_label_set_ellipsize (GTK_LABEL (label), group->priv->ellipsize);
gtk_label_set_angle (GTK_LABEL (label), 0);
break;
}
@@ -303,10 +312,14 @@
egg_tool_item_group_set_name (group, g_value_get_string (value));
break;
- case PROP_EXPANED:
+ case PROP_EXPANDED:
egg_tool_item_group_set_expanded (group, g_value_get_boolean (value));
break;
+ case PROP_ELLIPSIZE:
+ egg_tool_item_group_set_ellipsize (group, g_value_get_enum (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -327,10 +340,14 @@
g_value_set_string (value, egg_tool_item_group_get_name (group));
break;
- case PROP_EXPANED:
+ case PROP_EXPANDED:
g_value_set_boolean (value, egg_tool_item_group_get_expanded (group));
break;
+ case PROP_ELLIPSIZE:
+ g_value_set_enum (value, egg_tool_item_group_get_ellipsize (group));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -712,18 +729,26 @@
g_param_spec_string ("name",
P_("Name"),
P_("The name of this item group"),
- NULL,
+ DEFAULT_NAME,
G_PARAM_READWRITE | G_PARAM_STATIC_NAME |
G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
- g_object_class_install_property (oclass, PROP_EXPANED,
+ g_object_class_install_property (oclass, PROP_EXPANDED,
g_param_spec_boolean ("expanded",
P_("Expanded"),
P_("Wether the group has been expanded and items are shown"),
- TRUE,
+ DEFAULT_EXPANDED,
G_PARAM_READWRITE | G_PARAM_STATIC_NAME |
G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+ g_object_class_install_property (oclass, PROP_ELLIPSIZE,
+ g_param_spec_enum ("ellipsize",
+ P_("ellipsize"),
+ P_("Ellipsize for item group headers"),
+ PANGO_TYPE_ELLIPSIZE_MODE, DEFAULT_ELLIPSIZE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+
gtk_widget_class_install_style_property (wclass,
g_param_spec_int ("expander-size",
P_("Expander Size"),
@@ -885,12 +910,26 @@
}
}
+void
+egg_tool_item_group_set_ellipsize (EggToolItemGroup *group,
+ PangoEllipsizeMode ellipsize)
+{
+ g_return_if_fail (EGG_IS_TOOL_ITEM_GROUP (group));
+
+ if (ellipsize != group->priv->ellipsize)
+ {
+ group->priv->ellipsize = ellipsize;
+ egg_tool_item_group_header_adjust_style (group);
+ g_object_notify (G_OBJECT (group), "ellipsize");
+ }
+}
+
G_CONST_RETURN gchar*
egg_tool_item_group_get_name (EggToolItemGroup *group)
{
GtkWidget *label;
- g_return_val_if_fail (EGG_IS_TOOL_ITEM_GROUP (group), NULL);
+ g_return_val_if_fail (EGG_IS_TOOL_ITEM_GROUP (group), DEFAULT_NAME);
label = egg_tool_item_group_get_label (group);
return gtk_label_get_text (GTK_LABEL (label));
@@ -899,10 +938,17 @@
gboolean
egg_tool_item_group_get_expanded (EggToolItemGroup *group)
{
- g_return_val_if_fail (EGG_IS_TOOL_ITEM_GROUP (group), FALSE);
+ g_return_val_if_fail (EGG_IS_TOOL_ITEM_GROUP (group), DEFAULT_EXPANDED);
return group->priv->expanded;
}
+PangoEllipsizeMode
+egg_tool_item_group_get_ellipsize (EggToolItemGroup *group)
+{
+ g_return_val_if_fail (EGG_IS_TOOL_ITEM_GROUP (group), DEFAULT_ELLIPSIZE);
+ return group->priv->ellipsize;
+}
+
void
egg_tool_item_group_insert (EggToolItemGroup *group,
GtkToolItem *item,
Modified: trunk/libegg/toolpalette/eggtoolitemgroup.h
==============================================================================
--- trunk/libegg/toolpalette/eggtoolitemgroup.h (original)
+++ trunk/libegg/toolpalette/eggtoolitemgroup.h Fri Mar 28 21:28:18 2008
@@ -50,31 +50,34 @@
};
GType egg_tool_item_group_get_type (void) G_GNUC_CONST;
-GtkWidget* egg_tool_item_group_new (const gchar *name);
+GtkWidget* egg_tool_item_group_new (const gchar *name);
-void egg_tool_item_group_set_name (EggToolItemGroup *group,
- const gchar *name);
-void egg_tool_item_group_set_expanded (EggToolItemGroup *group,
- gboolean expanded);
-
-G_CONST_RETURN gchar* egg_tool_item_group_get_name (EggToolItemGroup *group);
-gboolean egg_tool_item_group_get_expanded (EggToolItemGroup *group);
-
-void egg_tool_item_group_insert (EggToolItemGroup *group,
- GtkToolItem *item,
- gint position);
-void egg_tool_item_group_set_item_position (EggToolItemGroup *group,
- GtkToolItem *item,
- gint position);
-gint egg_tool_item_group_get_item_position (EggToolItemGroup *group,
- GtkToolItem *item);
-
-guint egg_tool_item_group_get_n_items (EggToolItemGroup *group);
-GtkToolItem* egg_tool_item_group_get_nth_item (EggToolItemGroup *group,
- guint index);
-GtkToolItem* egg_tool_item_group_get_drop_item (EggToolItemGroup *group,
- gint x,
- gint y);
+void egg_tool_item_group_set_name (EggToolItemGroup *group,
+ const gchar *name);
+void egg_tool_item_group_set_expanded (EggToolItemGroup *group,
+ gboolean expanded);
+void egg_tool_item_group_set_ellipsize (EggToolItemGroup *group,
+ PangoEllipsizeMode ellipsize);
+
+G_CONST_RETURN gchar* egg_tool_item_group_get_name (EggToolItemGroup *group);
+gboolean egg_tool_item_group_get_expanded (EggToolItemGroup *group);
+PangoEllipsizeMode egg_tool_item_group_get_ellipsize (EggToolItemGroup *group);
+
+void egg_tool_item_group_insert (EggToolItemGroup *group,
+ GtkToolItem *item,
+ gint position);
+void egg_tool_item_group_set_item_position (EggToolItemGroup *group,
+ GtkToolItem *item,
+ gint position);
+gint egg_tool_item_group_get_item_position (EggToolItemGroup *group,
+ GtkToolItem *item);
+
+guint egg_tool_item_group_get_n_items (EggToolItemGroup *group);
+GtkToolItem* egg_tool_item_group_get_nth_item (EggToolItemGroup *group,
+ guint index);
+GtkToolItem* egg_tool_item_group_get_drop_item (EggToolItemGroup *group,
+ gint x,
+ gint y);
G_END_DECLS
Modified: trunk/libegg/toolpalette/testtoolpalette.c
==============================================================================
--- trunk/libegg/toolpalette/testtoolpalette.c (original)
+++ trunk/libegg/toolpalette/testtoolpalette.c Fri Mar 28 21:28:18 2008
@@ -492,6 +492,23 @@
g_object_unref (scroller);
}
+static void
+ellipsize_changed_cb (GtkWidget *widget,
+ gpointer data)
+{
+ GEnumValue *ellipsize = data;
+
+ egg_tool_item_group_set_ellipsize (EGG_TOOL_ITEM_GROUP (widget),
+ ellipsize->value);
+}
+
+static void
+ellipsize_changed (GEnumValue *value,
+ gpointer data)
+{
+ gtk_container_foreach (data, ellipsize_changed_cb, value);
+}
+
static GtkWidget*
create_ui (void)
{
@@ -513,6 +530,7 @@
<menuitem action='ViewIconSize' /> \
<menuitem action='ViewOrientation' /> \
<menuitem action='ViewStyle' /> \
+ <menuitem action='ViewEllipsize' /> \
</menu> \
\
<menu action='HelpMenu'> \
@@ -528,6 +546,7 @@
<toolitem action='ViewIconSize' /> \
<toolitem action='ViewOrientation' /> \
<toolitem action='ViewStyle' /> \
+ <toolitem action='ViewEllipsize' /> \
<separator /> \
<separator /> \
<toolitem action='HelpAbout' /> \
@@ -579,6 +598,10 @@
egg_enum_action_bind (EGG_ENUM_ACTION (action), G_OBJECT (palette), "toolbar-style");
gtk_action_group_add_action (group, action);
+ action = egg_enum_action_new ("ViewEllipsize", _("Ellipsize Headers"), NULL, PANGO_TYPE_ELLIPSIZE_MODE);
+ egg_enum_action_connect (EGG_ENUM_ACTION (action), ellipsize_changed, palette);
+ gtk_action_group_add_action (group, action);
+
gtk_ui_manager_insert_action_group (ui, group, -1);
if (!gtk_ui_manager_add_ui_from_string (ui, ui_spec, sizeof ui_spec - 1, &error))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]