Hi! I'm trying to install property into main interface, but when I run program it always display me this warning:
(lt-goofysender:10709): GLib-GObject-WARNING **: When installing property: type `GoofyFileTransfer' already has a property named `transfer-status' Here you have some code: /*>>> Interface definition <<<*/ GType goofy_file_transfer_get_type (void) { static GType type = G_TYPE_INVALID; if (type == G_TYPE_INVALID) { static const GTypeInfo info = { sizeof (GoofyFileTransferIface), /* class_size */ goofy_file_transfer_base_init, /* base_init */ NULL, /* base_finalize */ NULL, NULL, /* class_finalize */ NULL, /* class_data */ 0, 0, /* n_preallocs */ NULL }; type = g_type_register_static (G_TYPE_INTERFACE, "GoofyFileTransfer", &info, 0); } return type; } /* cut */ static void goofy_file_transfer_base_init (gpointer g_iface) { g_object_interface_install_property (g_iface, g_param_spec_string ("transfer-status", "Transfer status", "Specify current transfer status", "lol", G_PARAM_READWRITE)); } /*>>> Class, which implement this interface <<<*/ /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >> >> Private variables and functions prototypes >> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ static void goofy_file_transfer_iface_init (gpointer g_iface, gpointer iface_data); G_DEFINE_TYPE_WITH_CODE (GoofySendFile, goofy_send_file, GOOFY_TYPE_FILE, G_IMPLEMENT_INTERFACE (GOOFY_TYPE_FILE_TRANSFER, goofy_file_transfer_iface_init)) enum { PROP_0, PROP_SENT_SIZE, PROP_TRANSFER_STATUS }; static void goofy_send_file_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); static void goofy_send_file_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); static void goofy_send_file_dispose (GObject *object); static void goofy_send_file_finalize (GObject *object); static gboolean goofy_send_file_start (GoofyFileTransfer *file_transfer, GError **error); static gboolean goofy_send_file_cancel (GoofyFileTransfer *file_transfer, GError **error); /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >> >> Public functions definitions >> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ GoofySendFile *goofy_send_file_new (gchar *file_path, gchar *dest_ip_address, guint dest_port_number, GError **error) { GoofySendFile *send_file = NULL; FILE *file_handler; gboolean status; gint return_val; gchar *file_name; struct stat file_info; /* Validate path to file */ status = g_file_test (file_path, G_FILE_TEST_EXISTS); if (!status) { goofy_set_error (error, GOOFY_FILE_ERROR_QUARK, GOOFY_FILE_ERROR_FILE_OPEN, _("There is no file under given path.")); return NULL; } /* We can't send symbolic links too */ status = g_file_test (file_path, G_FILE_TEST_IS_SYMLINK); if (status) { goofy_set_error (error, GOOFY_FILE_ERROR_QUARK, GOOFY_FILE_ERROR_FILE_OPEN, _("File, which you choosen is a symbolic link to other file. Please select file on which it's pointing on and try again.")); return NULL; } printf ("Yea!"); /* Try to open file */ file_handler = fopen (file_path, "r"); if (file_handler == NULL) { goofy_set_error (error, GOOFY_FILE_ERROR_QUARK, GOOFY_FILE_ERROR_FILE_OPEN, _("Failed to open file.")); fclose (file_handler); /* Doesn't check for errors here */ return NULL; } /* Validate IP address */ status = goofy_network_ip_address_validate (dest_ip_address); if (!status) { g_set_error (error, GOOFY_SEND_FILE_ERROR_QUARK, GOOFY_SEND_FILE_ERROR_INVALID_IP_ADDRESS, _("Given IP address is invalid.")); return NULL; } /* Validate port number */ status = goofy_network_port_number_validate (dest_port_number); if (!status) { g_set_error (error, GOOFY_SEND_FILE_ERROR_QUARK, GOOFY_SEND_FILE_ERROR_INVALID_PORT_NUMBER, _("Given port number is invalid, it must be number between 1024 and 65535.")); return NULL; } /* Obtain some base information */ file_name = g_path_get_basename (file_path); return_val = g_stat (file_path, &file_info); if (return_val == -1) { goofy_set_error (error, GOOFY_FILE_ERROR_QUARK, GOOFY_FILE_ERROR_FILE_OPEN, _("Unable to acces file information. Maybe you don't have premmision to read this file?.")); return NULL; } /* File can't be empty */ if (file_info.st_size == 0) { goofy_set_error (error, GOOFY_FILE_ERROR_QUARK, GOOFY_FILE_ERROR_EMPTY_FILE, _("File, which you are trying to send is empty. GoofySender can't send empty files.")); return NULL; } send_file = g_object_new (GOOFY_TYPE_SEND_FILE, "ip-address", dest_ip_address, "port-number", dest_port_number, "file-name", file_name, "file-path", file_path, "file-size", file_info.st_size, NULL); /* Set opened file handler*/ GOOFY_FILE (send_file)->file_handler = file_handler; g_free (file_name); return send_file; } /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >> >> Private functions definitions >> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ static void goofy_send_file_init (GoofySendFile *self) { /* Dummy function */ } static void goofy_send_file_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { GoofySendFile *send_file = GOOFY_SEND_FILE (object); switch (property_id) { case PROP_SENT_SIZE: send_file->sent_size = g_value_get_uint (value); break; case PROP_TRANSFER_STATUS: send_file->transfer_status = g_value_get_int (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } } static void goofy_send_file_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { GoofySendFile *send_file = GOOFY_SEND_FILE (object); switch (property_id) { case PROP_SENT_SIZE: g_value_set_uint (value, send_file->sent_size); break; case PROP_TRANSFER_STATUS: g_value_set_int (value, send_file->transfer_status); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } } static void goofy_send_file_dispose (GObject *object) { GoofySendFile *send_file = GOOFY_SEND_FILE (object); GoofyFileClass *client_class = g_type_class_peek (GOOFY_TYPE_FILE); G_OBJECT_CLASS (client_class)->dispose (object); } static void goofy_send_file_finalize (GObject *object) { GoofySendFile *send_file = GOOFY_SEND_FILE (object); GoofyFileClass *client_class = g_type_class_peek (GOOFY_TYPE_FILE); G_OBJECT_CLASS (client_class)->finalize (object); } static void goofy_send_file_class_init (GoofySendFileClass *klass) { GObjectClass *g_klass = G_OBJECT_CLASS (klass); GoofySendFileClass *send_file_class = GOOFY_SEND_FILE_CLASS (klass); g_klass->set_property = goofy_send_file_set_property; g_klass->get_property = goofy_send_file_get_property; g_klass->dispose = goofy_send_file_dispose; g_klass->finalize = goofy_send_file_finalize; /* Sent data size */ g_object_class_install_property (g_klass, PROP_SENT_SIZE, g_param_spec_uint ("sent-size", "Sent sizer", "Total amount of file's bytes, which were send.", 1, G_MAXUINT, 1, G_PARAM_READABLE)); /* Install interface's properties */ g_object_class_override_property (g_klass, PROP_TRANSFER_STATUS, "transfer-status"); /* Install signals */ send_file_class->file_send_step = g_signal_new ("file-send-setp", G_TYPE_FROM_CLASS (g_klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); send_file_class->file_send_finish = g_signal_new ("file-send-finish", G_TYPE_FROM_CLASS (g_klass), G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); send_file_class->file_send_cancel = g_signal_new ("file-send-cancel", G_TYPE_FROM_CLASS (g_klass), G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); send_file_class->file_send_error = g_signal_new ("file-send-error", G_TYPE_FROM_CLASS (g_klass), G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_POINTER, G_TYPE_NONE, 0); } static void goofy_file_transfer_iface_init (gpointer g_iface, gpointer iface_data) { GoofyFileTransferIface *iface = g_iface; iface->transfer_start = goofy_send_file_start; iface->transfer_cancel = goofy_send_file_cancel; } static gboolean goofy_send_file_start (GoofyFileTransfer *file_transfer, GError **error) { GoofySendFile *send_file = (GoofySendFile *) file_transfer; gboolean status; /* Emit signal "send-step" */ g_signal_emit (send_file, GOOFY_SEND_FILE_GET_CLASS (send_file)->file_send_step, 0, G_TYPE_NONE); return TRUE; } static gboolean goofy_send_file_cancel (GoofyFileTransfer *file_transfer, GError **error) { /* Emit signal "canceled" */ g_signal_emit_by_name (file_transfer, "transfer-canceled", G_TYPE_NONE); return TRUE; } -- Cya! Tom _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list