parasite: Some formatting cleanup

This commit is contained in:
Matthias Clasen 2014-05-05 00:06:07 -04:00
parent 36494dc8f4
commit d7c5b55846
2 changed files with 276 additions and 288 deletions

View File

@ -163,7 +163,8 @@ set_value (GtkCellRenderer *renderer,
}
static void
stop_editing(GtkCellEditable *editable, GtkCellRenderer *renderer)
stop_editing (GtkCellEditable *editable,
GtkCellRenderer *renderer)
{
GValue gvalue = {0};
GParamSpec *prop;
@ -174,6 +175,7 @@ stop_editing(GtkCellEditable *editable, GtkCellRenderer *renderer)
if (GTK_IS_ENTRY(editable))
{
gboolean canceled;
g_object_get (editable, "editing_canceled", &canceled, NULL);
gtk_cell_renderer_stop_editing (renderer, canceled);
@ -182,8 +184,7 @@ stop_editing(GtkCellEditable *editable, GtkCellRenderer *renderer)
if (GTK_IS_SPIN_BUTTON(editable))
{
double value =
g_ascii_strtod(gtk_entry_get_text(GTK_ENTRY(editable)), NULL);
gdouble value = g_ascii_strtod (gtk_entry_get_text (GTK_ENTRY (editable)), NULL);
if (G_IS_PARAM_SPEC_INT (prop))
g_value_set_int (&gvalue, (gint)value);
@ -204,23 +205,21 @@ stop_editing(GtkCellEditable *editable, GtkCellRenderer *renderer)
}
else
{
g_value_set_string(&gvalue,
gtk_entry_get_text(GTK_ENTRY(editable)));
g_value_set_string (&gvalue, gtk_entry_get_text (GTK_ENTRY (editable)));
}
}
else if (GTK_IS_COMBO_BOX (editable))
{
// We have no way of getting the canceled state for a GtkComboBox.
/* We have no way of getting the canceled state for a GtkComboBox */
gtk_cell_renderer_stop_editing (renderer, FALSE);
if (G_IS_PARAM_SPEC_BOOLEAN (prop))
{
g_value_set_boolean(&gvalue,
gtk_combo_box_get_active(GTK_COMBO_BOX(editable)) == 1);
g_value_set_boolean (&gvalue, gtk_combo_box_get_active (GTK_COMBO_BOX (editable)) == 1);
}
else if (G_IS_PARAM_SPEC_ENUM (prop))
{
char *enum_name = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (editable));
gchar *enum_name = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (editable));
GEnumClass *enum_class;
GEnumValue *enum_value;
@ -293,10 +292,12 @@ start_editing (GtkCellRenderer *renderer,
if (G_VALUE_HOLDS_ENUM (&gvalue) || G_VALUE_HOLDS_BOOLEAN (&gvalue))
{
GtkWidget *combobox = gtk_combo_box_text_new ();
GtkWidget *combobox;
GList *renderers;
combobox = gtk_combo_box_text_new ();
gtk_widget_show (combobox);
g_object_set (G_OBJECT (combobox), "has-frame", FALSE, NULL);
GList *renderers;
if (G_VALUE_HOLDS_BOOLEAN (&gvalue))
{
@ -321,7 +322,6 @@ start_editing (GtkCellRenderer *renderer,
if (enum_value->value == value)
gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), i);
}
}
renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (combobox));
@ -332,7 +332,9 @@ start_editing (GtkCellRenderer *renderer,
}
else if (G_VALUE_HOLDS_STRING (&gvalue))
{
GtkWidget *entry = gtk_entry_new();
GtkWidget *entry;
entry = gtk_entry_new ();
gtk_widget_show (entry);
gtk_entry_set_text (GTK_ENTRY (entry), g_value_get_string (&gvalue));
@ -346,7 +348,7 @@ start_editing (GtkCellRenderer *renderer,
G_VALUE_HOLDS_ULONG (&gvalue) ||
G_VALUE_HOLDS_DOUBLE (&gvalue))
{
double min, max, value;
gdouble min, max, value;
GtkWidget *spinbutton;
guint digits = 0;
@ -402,7 +404,7 @@ start_editing (GtkCellRenderer *renderer,
}
else
{
// Shouldn't really be able to happen.
/* Shouldn't really be able to happen. */
return NULL;
}
@ -414,6 +416,7 @@ start_editing (GtkCellRenderer *renderer,
editable = GTK_CELL_EDITABLE(spinbutton);
}
}
g_value_unset (&gvalue);
if (!editable)
@ -440,21 +443,13 @@ parasite_property_cell_renderer_class_init (ParasitePropertyCellRendererClass *k
cell_class->start_editing = start_editing;
g_object_class_install_property(object_class,
PROP_OBJECT,
g_param_spec_object ("object",
"Object",
"The object owning the property",
G_TYPE_OBJECT,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_OBJECT,
g_param_spec_object ("object", "Object", "The object owning the property",
G_TYPE_OBJECT, G_PARAM_READWRITE));
g_object_class_install_property(object_class,
PROP_NAME,
g_param_spec_string ("name",
"Name",
"The property name",
NULL,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_NAME,
g_param_spec_string ("name", "Name", "The property name",
NULL, G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_IS_CHILD_PROPERTY,
g_param_spec_boolean ("is-child-property", "Child property", "Child property",
@ -468,4 +463,4 @@ parasite_property_cell_renderer_new(void)
}
// vim: set et ts=4:
// vim: set et ts=2:

View File

@ -45,21 +45,14 @@ typedef struct
typedef struct
{
GtkCellRendererTextClass parent;
// Padding for future expansion
void (*reserved0)(void);
void (*reserved1)(void);
void (*reserved2)(void);
void (*reserved3)(void);
} ParasitePropertyCellRendererClass;
G_BEGIN_DECLS
GType parasite_property_cell_renderer_get_type();
GtkCellRenderer *parasite_property_cell_renderer_new();
GType parasite_property_cell_renderer_get_type (void);
GtkCellRenderer *parasite_property_cell_renderer_new (void);
G_END_DECLS
@ -67,4 +60,4 @@ G_END_DECLS
#endif // _GTKPARASITE_PROPERTY_CELL_RENDERER_H_
// vim: set et sw=4 ts=4:
// vim: set et sw=2 ts=2: