moo_command_type_data_equal()

This commit is contained in:
Yevgen Muntyan 2006-08-23 02:38:16 -05:00
parent 4aecb63ebb
commit c9b450e4e2
4 changed files with 52 additions and 0 deletions

View File

@ -679,6 +679,26 @@ exe_type_save_data (G_GNUC_UNUSED MooCommandType *type,
}
static gboolean
exe_type_data_equal (G_GNUC_UNUSED MooCommandType *type,
MooCommandData *data1,
MooCommandData *data2)
{
guint i;
const char *keys[] = {"cmd-line", "input", "output"};
for (i = 0; i < G_N_ELEMENTS (keys); ++i)
{
const char *val1 = moo_command_data_get (data1, keys[i]);
const char *val2 = moo_command_data_get (data2, keys[i]);
if (strcmp (val1 ? val1 : "", val2 ? val2 : "") != 0)
return FALSE;
}
return TRUE;
}
static void
_moo_command_type_exe_class_init (MooCommandTypeExeClass *klass)
{
@ -686,6 +706,7 @@ _moo_command_type_exe_class_init (MooCommandTypeExeClass *klass)
klass->create_widget = exe_type_create_widget;
klass->load_data = exe_type_load_data;
klass->save_data = exe_type_save_data;
klass->data_equal = exe_type_data_equal;
}

View File

@ -199,6 +199,17 @@ script_type_save_data (G_GNUC_UNUSED MooCommandType *type,
}
static gboolean
script_type_data_equal (G_GNUC_UNUSED MooCommandType *type,
MooCommandData *data1,
MooCommandData *data2)
{
const char *val1 = moo_command_data_get (data1, "code");
const char *val2 = moo_command_data_get (data2, "code");
return !strcmp (val1 ? val1 : "", val2 ? val2 : "");
}
static void
_moo_command_type_script_init (G_GNUC_UNUSED MooCommandType *type)
{
@ -211,6 +222,7 @@ _moo_command_type_script_class_init (MooCommandTypeClass *klass)
klass->create_widget = script_type_create_widget;
klass->load_data = script_type_load_data;
klass->save_data = script_type_save_data;
klass->data_equal = script_type_data_equal;
}

View File

@ -95,6 +95,7 @@ moo_command_type_register (const char *name,
g_return_if_fail (klass->create_widget != NULL);
g_return_if_fail (klass->load_data != NULL);
g_return_if_fail (klass->save_data != NULL);
g_return_if_fail (klass->data_equal != NULL);
if (registered_types != NULL)
{
@ -226,6 +227,18 @@ _moo_command_type_save_data (MooCommandType *type,
return MOO_COMMAND_TYPE_GET_CLASS (type)->save_data (type, widget, data);
}
gboolean
_moo_command_type_data_equal (MooCommandType *type,
MooCommandData *data1,
MooCommandData *data2)
{
g_return_val_if_fail (MOO_IS_COMMAND_TYPE (type), FALSE);
g_return_val_if_fail (MOO_COMMAND_TYPE_GET_CLASS(type)->data_equal != NULL, FALSE);
g_return_val_if_fail (data1 != NULL, FALSE);
g_return_val_if_fail (data2 != NULL, FALSE);
return MOO_COMMAND_TYPE_GET_CLASS (type)->data_equal (type, data1, data2);
}
static void
moo_command_set_property (GObject *object,

View File

@ -105,6 +105,9 @@ struct _MooCommandTypeClass {
gboolean (*save_data) (MooCommandType *type,
GtkWidget *widget,
MooCommandData *data);
gboolean (*data_equal) (MooCommandType *type,
MooCommandData *data1,
MooCommandData *data2);
};
@ -203,6 +206,9 @@ void _moo_command_type_load_data (MooCommandType *type,
gboolean _moo_command_type_save_data (MooCommandType *type,
GtkWidget *widget,
MooCommandData *data);
gboolean _moo_command_type_data_equal (MooCommandType *type,
MooCommandData *data1,
MooCommandData *data2);
G_END_DECLS