Verified Commit fc3f7c63 authored by Zander Brown's avatar Zander Brown
Browse files

general: use char instead of gchar

Usage of gchar is discouraged in projects such as glib/gtk

In gtk4 all usage of gchar has been dropped

Fix Librem5/phosh#364
parent 72e77046
......@@ -214,14 +214,14 @@ phosh_activity_constructed (GObject *object)
{
PhoshActivity *self = PHOSH_ACTIVITY (object);
PhoshActivityPrivate *priv = phosh_activity_get_instance_private (self);
g_autofree gchar *desktop_id = NULL;
g_autofree char *desktop_id = NULL;
desktop_id = g_strdup_printf ("%s.desktop", priv->app_id);
g_return_if_fail (desktop_id);
priv->info = g_desktop_app_info_new (desktop_id);
if (!priv->info) {
g_autofree gchar *name = phosh_fix_app_id (priv->app_id);
g_autofree char *name = phosh_fix_app_id (priv->app_id);
g_return_if_fail (name);
g_free (desktop_id);
desktop_id = g_strdup_printf ("%s.desktop", name);
......
......@@ -168,7 +168,7 @@ activate_cb (PhoshAppGridButton *self)
g_autoptr (GdkAppLaunchContext) context = NULL;
g_autoptr (GError) error = NULL;
PhoshToplevelManager *toplevel_manager = phosh_shell_get_toplevel_manager (phosh_shell_get_default ());
g_autofree gchar *app_id = g_strdup (g_app_info_get_id (G_APP_INFO (priv->info)));
g_autofree char *app_id = g_strdup (g_app_info_get_id (G_APP_INFO (priv->info)));
g_debug ("Launching %s", app_id);
......@@ -179,8 +179,8 @@ activate_cb (PhoshAppGridButton *self)
for (guint i=0; i < phosh_toplevel_manager_get_num_toplevels (toplevel_manager); i++) {
PhoshToplevel *toplevel = phosh_toplevel_manager_get_toplevel (toplevel_manager, i);
const gchar *window_id = phosh_toplevel_get_app_id (toplevel);
g_autofree gchar *fixed_id = phosh_fix_app_id (window_id);
const char *window_id = phosh_toplevel_get_app_id (toplevel);
g_autofree char *fixed_id = phosh_fix_app_id (window_id);
if (g_strcmp0 (app_id, window_id) == 0 || g_strcmp0 (app_id, fixed_id) == 0) {
// activate the first matching window for now, since we don't have toplevels sorted by last-focus yet
......@@ -452,7 +452,7 @@ phosh_app_grid_button_set_app_info (PhoshAppGridButton *self,
PhoshFavoriteListModel *list = NULL;
PhoshAppGridButtonPrivate *priv;
GIcon *icon;
const gchar* name;
const char *name;
g_return_if_fail (PHOSH_IS_APP_GRID_BUTTON (self));
g_return_if_fail (G_IS_APP_INFO (info) || info == NULL);
......
......@@ -27,7 +27,7 @@ struct _PhoshAppGridPrivate {
GtkWidget *favs_revealer;
GtkWidget *scrolled_window;
gchar *search_string;
char *search_string;
};
G_DEFINE_TYPE_WITH_PRIVATE (PhoshAppGrid, phosh_app_grid, GTK_TYPE_BOX)
......@@ -56,20 +56,20 @@ sort_apps (gconstpointer a,
GAppInfo *info1 = G_APP_INFO (a);
GAppInfo *info2 = G_APP_INFO (b);
g_autofree gchar *s1 = g_utf8_casefold (g_app_info_get_name (info1), -1);
g_autofree gchar *s2 = g_utf8_casefold (g_app_info_get_name (info2), -1);
g_autofree char *s1 = g_utf8_casefold (g_app_info_get_name (info1), -1);
g_autofree char *s2 = g_utf8_casefold (g_app_info_get_name (info2), -1);
return g_strcmp0 (s1, s2);
}
static const gchar *(*app_attr[]) (GAppInfo *info) = {
static const char *(*app_attr[]) (GAppInfo *info) = {
g_app_info_get_display_name,
g_app_info_get_name,
g_app_info_get_description,
g_app_info_get_executable,
};
static const gchar *(*desktop_attr[]) (GDesktopAppInfo *info) = {
static const char *(*desktop_attr[]) (GDesktopAppInfo *info) = {
g_desktop_app_info_get_generic_name,
g_desktop_app_info_get_categories,
};
......@@ -98,7 +98,7 @@ search_apps (gpointer item, gpointer data)
}
for (int i = 0; i < G_N_ELEMENTS (app_attr); i++) {
g_autofree gchar *folded = NULL;
g_autofree char *folded = NULL;
str = app_attr[i] (info);
......@@ -115,7 +115,7 @@ search_apps (gpointer item, gpointer data)
const char * const *kwds;
for (int i = 0; i < G_N_ELEMENTS (desktop_attr); i++) {
g_autofree gchar *folded = NULL;
g_autofree char *folded = NULL;
str = desktop_attr[i] (G_DESKTOP_APP_INFO (info));
......@@ -134,7 +134,7 @@ search_apps (gpointer item, gpointer data)
int i = 0;
while ((str = kwds[i])) {
g_autofree gchar *folded = g_utf8_casefold (str, -1);
g_autofree char *folded = g_utf8_casefold (str, -1);
if (strstr (folded, search))
return TRUE;
i++;
......@@ -288,7 +288,7 @@ search_changed (GtkSearchEntry *entry,
static void
search_preedit_changed (GtkSearchEntry *entry,
const gchar *preedit,
const char *preedit,
PhoshAppGrid *self)
{
PhoshAppGridPrivate *priv = phosh_app_grid_get_instance_private (self);
......
......@@ -70,12 +70,12 @@ pam_conversation_cb(int num_msg, const struct pam_message **msg,
/* return TRUE if pin is correct, FALSE otherwise */
static gboolean
authenticate (PhoshAuth *self, const gchar* number)
authenticate (PhoshAuth *self, const char *number)
{
PhoshAuthPrivate *priv = phosh_auth_get_instance_private (self);
int ret;
gboolean authenticated = FALSE;
const gchar *username;
const char *username;
const struct pam_conv conv = {
.conv = pam_conversation_cb,
.appdata_ptr = (void*)number,
......@@ -171,7 +171,7 @@ phosh_auth_new (void)
void
phosh_auth_authenticate_async_start (PhoshAuth *self,
const gchar *number,
const char *number,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer callback_data)
......
......@@ -17,7 +17,7 @@ G_DECLARE_FINAL_TYPE (PhoshAuth, phosh_auth, PHOSH, AUTH, GObject)
GObject *phosh_auth_new (void);
void phosh_auth_authenticate_async_start (PhoshAuth *self,
const gchar *number,
const char *number,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
......
......@@ -62,7 +62,7 @@ struct _PhoshBackground
{
PhoshLayerSurface parent;
gchar *uri;
char *uri;
GDesktopBackgroundStyle style;
GdkRGBA color;
......@@ -391,7 +391,7 @@ background_draw_cb (PhoshBackground *self,
static void
get_settings (PhoshBackground *self)
{
g_autofree gchar *color = NULL;
g_autofree char *color = NULL;
g_free (self->uri);
self->uri = g_settings_get_string (self->settings, BG_KEY_PICTURE_URI);
......@@ -402,7 +402,7 @@ get_settings (PhoshBackground *self)
static void
on_background_setting_changed (PhoshBackground *self,
const gchar *key,
const char *key,
GSettings *settings)
{
g_return_if_fail (PHOSH_IS_BACKGROUND (self));
......
......@@ -67,7 +67,7 @@ phosh_bt_info_get_property (GObject *object,
static void
update_icon (PhoshBtInfo *self, GParamSpec *pspec, PhoshBtManager *bt)
{
const gchar *icon_name;
const char *icon_name;
g_return_if_fail (PHOSH_IS_BT_INFO (self));
g_return_if_fail (PHOSH_IS_BT_MANAGER (bt));
......
......@@ -45,7 +45,7 @@ struct _PhoshBtManager {
gboolean enabled;
/* Whether we have a bt device is present */
gboolean present;
const gchar *icon_name;
const char *icon_name;
PhoshRfkillDbusRfkill *proxy;
};
......@@ -82,7 +82,7 @@ on_bt_airplane_mode_changed (PhoshBtManager *self,
PhoshRfkillDbusRfkill *proxy)
{
gboolean enabled;
const gchar *icon_name;
const char *icon_name;
g_return_if_fail (PHOSH_IS_BT_MANAGER (self));
g_return_if_fail (PHOSH_RFKILL_DBUS_IS_RFKILL (proxy));
......@@ -230,7 +230,7 @@ phosh_bt_manager_new (void)
}
const gchar*
const char *
phosh_bt_manager_get_icon_name (PhoshBtManager *self)
{
g_return_val_if_fail (PHOSH_IS_BT_MANAGER (self), NULL);
......
......@@ -15,7 +15,7 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (PhoshBtManager, phosh_bt_manager, PHOSH, BT_MANAGER, GObject)
PhoshBtManager *phosh_bt_manager_new (void);
const gchar *phosh_bt_manager_get_icon_name (PhoshBtManager *self);
const char *phosh_bt_manager_get_icon_name (PhoshBtManager *self);
gboolean phosh_bt_manager_get_enabled (PhoshBtManager *self);
gboolean phosh_bt_manager_get_present (PhoshBtManager *self);
......
......@@ -62,7 +62,7 @@ phosh_connectivity_info_get_property (GObject *object,
static void
on_connectivity_changed (PhoshConnectivityInfo *self, GParamSpec *pspec, NMClient *nmclient)
{
const gchar *icon_name;
const char *icon_name;
NMConnectivityState state;
gboolean connectivity = FALSE;
......
......@@ -39,10 +39,10 @@ typedef struct {
GCancellable * cancellable;
ShellNetworkAgent *self;
gchar *request_id;
char *request_id;
NMConnection *connection;
gchar *setting_name;
gchar **hints;
char *setting_name;
char **hints;
NMSecretAgentGetSecretsFlags flags;
NMSecretAgentOldGetSecretsFunc callback;
gpointer callback_data;
......@@ -51,7 +51,7 @@ typedef struct {
} ShellAgentRequest;
struct _ShellNetworkAgentPrivate {
/* <gchar *request_id, ShellAgentRequest *request> */
/* <char *request_id, ShellAgentRequest *request> */
GHashTable *requests;
};
......@@ -157,7 +157,7 @@ request_secrets_from_ui (ShellAgentRequest *request)
static void
check_always_ask_cb (NMSetting *setting,
const gchar *key,
const char *key,
const GValue *value,
GParamFlags flags,
gpointer user_data)
......@@ -188,7 +188,7 @@ static gboolean
is_connection_always_ask (NMConnection *connection)
{
NMSettingConnection *s_con;
const gchar *ctype;
const char *ctype;
NMSetting *setting;
/* For the given connection type, check if the secrets for that connection
......@@ -276,7 +276,7 @@ get_secrets_keyring_cb (GObject *source,
SecretItem *item = l->data;
GHashTable *attributes;
GHashTableIter iter;
const gchar *name, *attribute;
const char *name, *attribute;
SecretValue *secret = secret_item_get_secret (item);
/* This can happen if the user denied a request to unlock */
......@@ -338,9 +338,9 @@ get_secrets_keyring_cb (GObject *source,
static void
shell_network_agent_get_secrets (NMSecretAgentOld *agent,
NMConnection *connection,
const gchar *connection_path,
const gchar *setting_name,
const gchar **hints,
const char *connection_path,
const char *setting_name,
const char **hints,
NMSecretAgentGetSecretsFlags flags,
NMSecretAgentOldGetSecretsFunc callback,
gpointer callback_data)
......@@ -365,7 +365,7 @@ shell_network_agent_get_secrets (NMSecretAgentOld *agent,
request->cancellable = g_cancellable_new ();
request->connection = g_object_ref (connection);
request->setting_name = g_strdup (setting_name);
request->hints = g_strdupv ((gchar **)hints);
request->hints = g_strdupv ((char **) hints);
request->flags = flags;
request->callback = callback;
request->callback_data = callback_data;
......@@ -396,9 +396,9 @@ shell_network_agent_get_secrets (NMSecretAgentOld *agent,
void
shell_network_agent_set_password (ShellNetworkAgent *self,
gchar *request_id,
gchar *setting_key,
gchar *setting_value)
char *request_id,
char *setting_key,
char *setting_value)
{
ShellNetworkAgentPrivate *priv;
ShellAgentRequest *request;
......@@ -414,7 +414,7 @@ shell_network_agent_set_password (ShellNetworkAgent *self,
void
shell_network_agent_respond (ShellNetworkAgent *self,
gchar *request_id,
char *request_id,
ShellNetworkAgentResponse response)
{
ShellNetworkAgentPrivate *priv;
......@@ -480,12 +480,12 @@ shell_network_agent_respond (ShellNetworkAgent *self,
static void
shell_network_agent_cancel_get_secrets (NMSecretAgentOld *agent,
const gchar *connection_path,
const gchar *setting_name)
const char *connection_path,
const char *setting_name)
{
ShellNetworkAgent *self = SHELL_NETWORK_AGENT (agent);
ShellNetworkAgentPrivate *priv = self->priv;
gchar *request_id;
char *request_id;
ShellAgentRequest *request;
request_id = g_strdup_printf ("%s/%s", connection_path, setting_name);
......@@ -507,11 +507,11 @@ shell_network_agent_cancel_get_secrets (NMSecretAgentOld *agent,
static GHashTable *
create_keyring_add_attr_list (NMConnection *connection,
const gchar *connection_uuid,
const gchar *connection_id,
const gchar *setting_name,
const gchar *setting_key,
gchar **out_display_name)
const char *connection_uuid,
const char *connection_id,
const char *setting_name,
const char *setting_key,
char **out_display_name)
{
NMSettingConnection *s_con;
......@@ -584,13 +584,13 @@ save_secret_cb (GObject *source,
static void
save_one_secret (KeyringRequest *r,
NMSetting *setting,
const gchar *key,
const gchar *secret,
const gchar *display_name)
const char *key,
const char *secret,
const char *display_name)
{
GHashTable *attrs;
gchar *alt_display_name = NULL;
const gchar *setting_name;
char *alt_display_name = NULL;
const char *setting_name;
NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE;
/* Only save agent-owned secrets (not system-owned or always-ask) */
......@@ -616,14 +616,14 @@ save_one_secret (KeyringRequest *r,
}
static void
vpn_secret_iter_cb (const gchar *key,
const gchar *secret,
gpointer user_data)
vpn_secret_iter_cb (const char *key,
const char *secret,
gpointer user_data)
{
KeyringRequest *r = user_data;
NMSetting *setting;
const gchar *service_name, *id;
gchar *display_name;
const char *service_name, *id;
char *display_name;
if (secret && strlen (secret))
{
......@@ -645,13 +645,13 @@ vpn_secret_iter_cb (const gchar *key,
static void
write_one_secret_to_keyring (NMSetting *setting,
const gchar *key,
const char *key,
const GValue *value,
GParamFlags flags,
gpointer user_data)
{
KeyringRequest *r = user_data;
const gchar *secret;
const char *secret;
/* Non-secrets obviously don't get saved in the keyring */
if (!(flags & NM_SETTING_PARAM_SECRET))
......@@ -702,7 +702,7 @@ save_delete_cb (NMSecretAgentOld *agent,
static void
shell_network_agent_save_secrets (NMSecretAgentOld *agent,
NMConnection *connection,
const gchar *connection_path,
const char *connection_path,
NMSecretAgentOldSaveSecretsFunc callback,
gpointer callback_data)
{
......@@ -747,13 +747,13 @@ delete_items_cb (GObject *source,
static void
shell_network_agent_delete_secrets (NMSecretAgentOld *agent,
NMConnection *connection,
const gchar *connection_path,
const char *connection_path,
NMSecretAgentOldDeleteSecretsFunc callback,
gpointer callback_data)
{
KeyringRequest *r;
NMSettingConnection *s_con;
const gchar *uuid;
const char *uuid;
r = g_slice_new (KeyringRequest);
r->n_secrets = 0; /* ignored by delete secrets calls */
......
......@@ -44,11 +44,11 @@ struct _ShellNetworkAgentClass
GType shell_network_agent_get_type (void);
void shell_network_agent_set_password (ShellNetworkAgent *self,
gchar *request_id,
gchar *setting_key,
gchar *setting_value);
char *request_id,
char *setting_key,
char *setting_value);
void shell_network_agent_respond (ShellNetworkAgent *self,
gchar *request_id,
char *request_id,
ShellNetworkAgentResponse response);
/* If these are kept in sync with nm-applet, secrets will be shared */
......
......@@ -92,7 +92,7 @@ list_iface_init (GListModelInterface *iface)
static void
favorites_changed (GSettings *settings,
const gchar *key,
const char *key,
PhoshFavoriteListModel *self)
{
PhoshFavoriteListModelPrivate *priv = phosh_favorite_list_model_get_instance_private (self);
......@@ -115,7 +115,7 @@ favorites_changed (GSettings *settings,
while (priv->items_inc_missing[i]) {
g_autoptr (GDesktopAppInfo) info = NULL;
// We don't actually care about this value, just that it isn't NULL
info = g_desktop_app_info_new (priv->items_inc_missing[i]);
......@@ -192,7 +192,7 @@ phosh_favorite_list_model_app_is_favorite (PhoshFavoriteListModel *self,
return FALSE;
}
if (g_strv_contains ((const gchar* const*) priv->items_inc_missing, id)) {
if (g_strv_contains ((const char *const *) priv->items_inc_missing, id)) {
return TRUE;
}
......
......@@ -182,7 +182,7 @@ phosh_feedback_manager_new (void)
return g_object_new (PHOSH_TYPE_FEEDBACK_MANAGER, NULL);
}
const gchar*
const char *
phosh_feedback_manager_get_icon_name (PhoshFeedbackManager *self)
{
g_return_val_if_fail (PHOSH_IS_FEEDBACK_MANAGER (self), NULL);
......@@ -190,7 +190,7 @@ phosh_feedback_manager_get_icon_name (PhoshFeedbackManager *self)
return self->icon_name;
}
const gchar*
const char *
phosh_feedback_manager_get_profile (PhoshFeedbackManager *self)
{
g_return_val_if_fail (PHOSH_IS_FEEDBACK_MANAGER (self), NULL);
......
......@@ -19,8 +19,8 @@ G_DECLARE_FINAL_TYPE (PhoshFeedbackManager,
PhoshFeedbackManager *phosh_feedback_manager_new (void);
void phosh_feedback_manager_toggle (PhoshFeedbackManager *self);
const gchar* phosh_feedback_manager_get_icon_name (PhoshFeedbackManager *self);
const gchar* phosh_feedback_manager_get_profile (PhoshFeedbackManager *self);
const char * phosh_feedback_manager_get_icon_name (PhoshFeedbackManager *self);
const char * phosh_feedback_manager_get_profile (PhoshFeedbackManager *self);
void phosh_feedback_manager_trigger_feedback (PhoshFeedbackManager *self, const char *event);
void phosh_trigger_feedback (const char *name);
void phosh_connect_button_feedback (GtkButton *button);
......@@ -326,7 +326,7 @@ animate_cb(GtkWidget *widget,
void
phosh_home_set_state (PhoshHome *self, PhoshHomeState state)
{
g_autofree gchar *state_name = NULL;
g_autofree char *state_name = NULL;
gboolean enable_animations;
gboolean kbd_interactivity;
......
......@@ -368,7 +368,7 @@ on_bus_acquired (GDBusConnection *connection,
{
PhoshIdleManager *self = user_data;
PhoshMonitor *monitor;
g_autofree gchar *path = NULL;
g_autofree char *path = NULL;
/* We need to use Mutter's object path here to make gnome-session happy */
self->manager = g_dbus_object_manager_server_new ("/org/gnome/Mutter/IdleMonitor");
......
......@@ -199,7 +199,7 @@ phosh_keyboard_events_class_init (PhoshKeyboardEventsClass *klass)
void
phosh_keyboard_events_register_keys (PhoshKeyboardEvents *self,
gchar **accelerators,
char **accelerators,
size_t len)
{
g_return_if_fail (self->kbevent);
......
......@@ -21,5 +21,5 @@ G_DECLARE_FINAL_TYPE (PhoshKeyboardEvents,
PhoshKeyboardEvents *phosh_keyboard_events_new (void);
void phosh_keyboard_events_register_keys (PhoshKeyboardEvents *self,
gchar **keys,
char **keys,
size_t len);
......@@ -63,7 +63,7 @@ typedef struct {
gint margin_left, margin_right;
gint width, height;
gint configured_width, configured_height;
gchar *namespace;
char *namespace;
struct zwlr_layer_shell_v1 *layer_shell;
struct wl_output *wl_output;
} PhoshLayerSurfacePrivate;
......
......@@ -247,7 +247,7 @@ static void
submit_cb (PhoshLockscreen *self)
{
PhoshLockscreenPrivate *priv;
const gchar *input;
const char *input;
guint16 length;
g_assert (PHOSH_IS_LOCKSCREEN (self));
......@@ -329,7 +329,7 @@ key_press_event_cb (PhoshLockscreen *self, GdkEventKey *event, gpointer data)
* set to something different since LANGUAGE overrides
* LC_{ALL,MESSAGE}.
*/
static const gchar *
static const char *
date_fmt (void)
{
const char *locale;
......@@ -353,13 +353,13 @@ date_fmt (void)
* the user has LC_MESSAGES=en_US.UTF-8 but LC_TIME to their local
* time zone.
*/
static gchar*
static char *
local_date (void)
{
time_t current = time (NULL);
struct tm local;
g_autofree gchar *date = NULL;
const gchar *fmt;
g_autofree char *date = NULL;
const char *fmt;
const char *locale;
g_return_val_if_fail (current != (time_t) -1, NULL);
......@@ -385,8 +385,8 @@ wall_clock_notify_cb (PhoshLockscreen *self,
GnomeWallClock *wall_clock)
{
PhoshLockscreenPrivate *priv = phosh_lockscreen_get_instance_private (self);
const gchar *time;
g_autofree gchar *date = NULL;
const char *time;
g_autofree char *date = NULL;
time = gnome_wall_clock_get_clock(wall_clock);
gtk_label_set_text (GTK_LABEL (priv->lbl_clock), time);
......