Commit c1f3b2af authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

fixed some issues with the new widget.

2007-02-12  Sven Neumann  <sven@gimp.org>

	* libgimpwidgets/gimpstringcombobox.c: fixed some issues with the
	new widget.

	* modules/controller_linux_input.c: define a property for the
	device store and use the device file as provided by the store.

	* modules/gimpinputdevicestore.c: removed debug output.


svn path=/trunk/; revision=21902
parent ace0321f
2007-02-12 Sven Neumann <sven@gimp.org>
* libgimpwidgets/gimpstringcombobox.c: fixed some issues with the
new widget.
* modules/controller_linux_input.c: define a property for the
device store and use the device file as provided by the store.
* modules/gimpinputdevicestore.c: removed debug output.
2007-02-12 Sven Neumann <sven@gimp.org>
* libgimpwidgets/gimpstringcombobox.c (gimp_string_model_lookup)
......@@ -143,37 +143,17 @@ gimp_string_combo_box_constructor (GType type,
GObjectConstructParam *params)
{
GObject *object;
GimpStringComboBox *combo;
GimpStringComboBoxPrivate *priv;
GtkTreeModel *model;
GtkCellRenderer *cell;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
combo = GIMP_STRING_COMBO_BOX (object);
priv = GIMP_STRING_COMBO_BOX_GET_PRIVATE (combo);
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
if (! g_type_is_a (gtk_tree_model_get_column_type (model, priv->id_column),
G_TYPE_STRING))
{
g_warning ("GimpStringComboBox: ID column must hold string values");
return object;
}
if (! g_type_is_a (gtk_tree_model_get_column_type (model, priv->label_column),
G_TYPE_STRING))
{
g_warning ("GimpStringComboBox: label column must hold string values");
return object;
}
priv = GIMP_STRING_COMBO_BOX_GET_PRIVATE (object);
priv->text_renderer = cell = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), cell,
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (object), cell, TRUE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (object), cell,
"text", priv->label_column,
NULL);
......@@ -317,24 +297,32 @@ gboolean
gimp_string_combo_box_set_active (GimpStringComboBox *combo_box,
const gchar *id)
{
GtkTreeModel *model;
GtkTreeIter iter;
gint column;
g_return_val_if_fail (GIMP_IS_STRING_COMBO_BOX (combo_box), FALSE);
g_return_val_if_fail (id != NULL, FALSE);
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
if (id)
{
GtkTreeModel *model;
GtkTreeIter iter;
gint column;
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
column = GIMP_STRING_COMBO_BOX_GET_PRIVATE (combo_box)->id_column;
column = GIMP_STRING_COMBO_BOX_GET_PRIVATE (combo_box)->id_column;
if (gimp_string_model_lookup (model, column, id, &iter))
if (gimp_string_model_lookup (model, column, id, &iter))
{
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter);
return TRUE;
}
return FALSE;
}
else
{
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter);
gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), -1);
return TRUE;
}
return FALSE;
}
/**
......
......@@ -113,7 +113,8 @@ static const LinuxInputEvent rel_events[] =
enum
{
PROP_0,
PROP_DEVICE
PROP_DEVICE,
PROP_DEVICE_STORE
};
......@@ -246,6 +247,11 @@ linux_input_class_init (ControllerLinuxInputClass *klass)
_("The name of the device to read Linux Input events from."),
NULL,
GIMP_CONFIG_PARAM_FLAGS));
g_object_class_install_property (object_class, PROP_DEVICE_STORE,
g_param_spec_object ("device-values",
NULL, NULL,
GIMP_TYPE_INPUT_DEVICE_STORE,
G_PARAM_READABLE));
controller_class->name = _("Linux Input");
controller_class->help_id = "gimp-controller-linux-input";
......@@ -318,6 +324,9 @@ linux_input_get_property (GObject *object,
case PROP_DEVICE:
g_value_set_string (value, controller->device);
break;
case PROP_DEVICE_STORE:
g_value_set_object (value, controller->store);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
......@@ -503,10 +512,17 @@ linux_input_set_device (ControllerLinuxInput *controller,
if (controller->device && strlen (controller->device))
{
gchar *filename;
gchar *state;
gint fd;
fd = g_open (controller->device, O_RDONLY, 0);
if (controller->store)
filename = gimp_input_device_store_get_device_file (controller->store,
controller->device);
else
filename = g_strdup (controller->device);
fd = g_open (filename, O_RDONLY, 0);
if (fd >= 0)
{
......@@ -522,10 +538,12 @@ linux_input_set_device (ControllerLinuxInput *controller,
linux_input_get_device_info (controller, fd);
state = g_strdup_printf (_("Reading from %s"), controller->device);
state = g_strdup_printf (_("Reading from %s"), filename);
g_object_set (controller, "state", state, NULL);
g_free (state);
g_free (filename);
controller->io = g_io_channel_unix_new (fd);
g_io_channel_set_close_on_unref (controller->io, TRUE);
g_io_channel_set_encoding (controller->io, NULL, NULL);
......@@ -543,6 +561,8 @@ linux_input_set_device (ControllerLinuxInput *controller,
g_object_set (controller, "state", state, NULL);
g_free (state);
}
g_free (filename);
}
else
{
......
......@@ -214,9 +214,6 @@ gimp_input_device_store_add (GimpInputDeviceStore *store,
GtkTreeIter iter;
gtk_list_store_append (GTK_LIST_STORE (store), &iter);
g_printerr ("%s\n", str);
gtk_list_store_set (GTK_LIST_STORE (store), &iter,
COLUMN_UDI, udi,
COLUMN_LABEL, str,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment