diff options
author | Elliott Sales de Andrade <quantum.analyst@gmail.com> | 2023-03-10 17:25:22 -0600 |
---|---|---|
committer | Elliott Sales de Andrade <quantum.analyst@gmail.com> | 2023-03-10 17:25:22 -0600 |
commit | 5c503c835674765e6bddb94ef34e931a02d930fe (patch) | |
tree | 4f332c4e57e27e643ae9e5fdda4a3b05f53b355e /libpurple | |
parent | ccbb2c5906dbec65954745ae50fc6dcf32a66151 (diff) | |
download | pidgin-5c503c835674765e6bddb94ef34e931a02d930fe.tar.gz |
Make PurpleRequestFieldLabel into a GObject
This also does an `hg cp`, though with this being so so short, maybe that wasn't as useful for tracking the diff.
Testing Done:
Compiled and opened Request Fields from the Demo protocol.
Reviewed at https://reviews.imfreedom.org/r/2337/
Diffstat (limited to 'libpurple')
-rw-r--r-- | libpurple/meson.build | 2 | ||||
-rw-r--r-- | libpurple/purplerequestfield.c | 13 | ||||
-rw-r--r-- | libpurple/purplerequestfield.h | 18 | ||||
-rw-r--r-- | libpurple/request/purplerequestfieldlabel.c | 58 | ||||
-rw-r--r-- | libpurple/request/purplerequestfieldlabel.h | 63 |
5 files changed, 123 insertions, 31 deletions
diff --git a/libpurple/meson.build b/libpurple/meson.build index 94991b8251..d395cb1ca1 100644 --- a/libpurple/meson.build +++ b/libpurple/meson.build @@ -101,6 +101,7 @@ purple_coresources = [ 'request/purplerequestfieldbool.c', 'request/purplerequestfieldchoice.c', 'request/purplerequestfieldint.c', + 'request/purplerequestfieldlabel.c', 'request/purplerequestfieldlist.c', 'request/purplerequestfieldstring.c', 'request-datasheet.c', @@ -230,6 +231,7 @@ purple_request_headers = [ 'request/purplerequestfieldbool.h', 'request/purplerequestfieldchoice.h', 'request/purplerequestfieldint.h', + 'request/purplerequestfieldlabel.h', 'request/purplerequestfieldlist.h', 'request/purplerequestfieldstring.h', ] diff --git a/libpurple/purplerequestfield.c b/libpurple/purplerequestfield.c index 0037d59109..596ec4e044 100644 --- a/libpurple/purplerequestfield.c +++ b/libpurple/purplerequestfield.c @@ -635,19 +635,6 @@ purple_request_field_is_sensitive(PurpleRequestField *field) } PurpleRequestField * -purple_request_field_label_new(const char *id, const char *text) -{ - PurpleRequestField *field; - - g_return_val_if_fail(id != NULL, NULL); - g_return_val_if_fail(text != NULL, NULL); - - field = purple_request_field_new(id, text, PURPLE_REQUEST_FIELD_LABEL); - - return field; -} - -PurpleRequestField * purple_request_field_image_new(const char *id, const char *text, const char *buf, gsize size) { PurpleRequestField *field; diff --git a/libpurple/purplerequestfield.h b/libpurple/purplerequestfield.h index 3d3c38b06e..a135e18097 100644 --- a/libpurple/purplerequestfield.h +++ b/libpurple/purplerequestfield.h @@ -64,7 +64,6 @@ struct _PurpleRequestFieldClass { /** * PurpleRequestFieldType: * @PURPLE_REQUEST_FIELD_NONE: No field. - * @PURPLE_REQUEST_FIELD_LABEL: Label field. * @PURPLE_REQUEST_FIELD_IMAGE: Image field. * @PURPLE_REQUEST_FIELD_DATASHEET: Datasheet field. * @@ -73,7 +72,6 @@ struct _PurpleRequestFieldClass { typedef enum { PURPLE_REQUEST_FIELD_NONE, - PURPLE_REQUEST_FIELD_LABEL, PURPLE_REQUEST_FIELD_IMAGE, PURPLE_REQUEST_FIELD_DATASHEET @@ -309,22 +307,6 @@ void purple_request_field_set_sensitive(PurpleRequestField *field, gboolean purple_request_field_is_sensitive(PurpleRequestField *field); /**************************************************************************/ -/* Label Field API */ -/**************************************************************************/ - -/** - * purple_request_field_label_new: - * @id: The field ID. - * @text: The label of the field. - * - * Creates a label field. - * - * Returns: (transfer full): The new field. - */ -PurpleRequestField *purple_request_field_label_new(const char *id, - const char *text); - -/**************************************************************************/ /* Image Field API */ /**************************************************************************/ diff --git a/libpurple/request/purplerequestfieldlabel.c b/libpurple/request/purplerequestfieldlabel.c new file mode 100644 index 0000000000..be44980db8 --- /dev/null +++ b/libpurple/request/purplerequestfieldlabel.c @@ -0,0 +1,58 @@ +/* purple + * + * Purple is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * source distribution. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA + */ + +#include <glib/gi18n-lib.h> + +#include "glibcompat.h" +#include "purplerequestfield.h" +#include "request/purplerequestfieldlabel.h" + +struct _PurpleRequestFieldLabel { + PurpleRequestField parent; +}; + +/****************************************************************************** + * GObject Implementation + *****************************************************************************/ +G_DEFINE_TYPE(PurpleRequestFieldLabel, purple_request_field_label, + PURPLE_TYPE_REQUEST_FIELD) + +static void +purple_request_field_label_init(G_GNUC_UNUSED PurpleRequestFieldLabel *field) { +} + +static void +purple_request_field_label_class_init(G_GNUC_UNUSED PurpleRequestFieldLabelClass *klass) { +} + +/****************************************************************************** + * Public API + *****************************************************************************/ +PurpleRequestField * +purple_request_field_label_new(const char *id, const char *text) { + g_return_val_if_fail(id != NULL, NULL); + g_return_val_if_fail(text != NULL, NULL); + + return g_object_new(PURPLE_TYPE_REQUEST_FIELD_LABEL, + "id", id, + "label", text, + NULL); +} diff --git a/libpurple/request/purplerequestfieldlabel.h b/libpurple/request/purplerequestfieldlabel.h new file mode 100644 index 0000000000..16939afe59 --- /dev/null +++ b/libpurple/request/purplerequestfieldlabel.h @@ -0,0 +1,63 @@ +/* + * Purple - Internet Messaging Library + * Copyright (C) Pidgin Developers <devel@pidgin.im> + * + * Purple is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * source distribution. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses/>. + */ + +#if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION) +# error "only <purple.h> may be included directly" +#endif + +#ifndef PURPLE_REQUEST_FIELD_LABEL_H +#define PURPLE_REQUEST_FIELD_LABEL_H + +#include <stdlib.h> + +#include <glib.h> +#include <glib-object.h> + +/** + * PurpleRequestFieldLabel: + * + * A label request field. + */ +typedef struct _PurpleRequestFieldLabel PurpleRequestFieldLabel; + +#include "purplerequestfield.h" + +G_BEGIN_DECLS + +#define PURPLE_TYPE_REQUEST_FIELD_LABEL (purple_request_field_label_get_type()) +G_DECLARE_FINAL_TYPE(PurpleRequestFieldLabel, purple_request_field_label, + PURPLE, REQUEST_FIELD_LABEL, PurpleRequestField) + +/** + * purple_request_field_label_new: + * @id: The field ID. + * @text: The label of the field. + * + * Creates a label field. + * + * Returns: (transfer full): The new field. + */ +PurpleRequestField *purple_request_field_label_new(const char *id, const char *text); + +G_END_DECLS + +#endif /* PURPLE_REQUEST_FIELD_LABEL_H */ |