Commit cefad4e6 authored by Corentin Noël's avatar Corentin Noël
Browse files

Get rid of unneeded glib types

Do as GTK in commit gtk@ec9fd76c
and use pure C types when GLib types are not necessary.
parent 8e1eee83
......@@ -65,7 +65,7 @@ toggle_layer (GtkToggleButton *widget,
static gboolean
mouse_click_cb (ClutterActor *actor, ClutterButtonEvent *event, ChamplainView *view)
{
gdouble lat, lon;
double lat, lon;
lon = champlain_view_x_to_longitude (view, event->x);
lat = champlain_view_y_to_latitude (view, event->y);
......@@ -79,7 +79,7 @@ static void
map_source_changed (GtkWidget *widget,
ChamplainView *view)
{
gchar *id;
char *id;
ChamplainMapSource *source;
GtkTreeIter iter;
GtkTreeModel *model;
......@@ -103,7 +103,7 @@ static void
zoom_changed (GtkSpinButton *spinbutton,
ChamplainView *view)
{
gint zoom = gtk_spin_button_get_value_as_int (spinbutton);
int zoom = gtk_spin_button_get_value_as_int (spinbutton);
g_object_set (G_OBJECT (view), "zoom-level", zoom, NULL);
}
......@@ -114,7 +114,7 @@ map_zoom_changed (ChamplainView *view,
GParamSpec *gobject,
GtkSpinButton *spinbutton)
{
gint zoom;
int zoom;
g_object_get (G_OBJECT (view), "zoom-level", &zoom, NULL);
gtk_spin_button_set_value (spinbutton, zoom);
......@@ -190,8 +190,8 @@ build_combo_box (GtkComboBox *box)
while (iter != NULL)
{
ChamplainMapSourceDesc *desc = CHAMPLAIN_MAP_SOURCE_DESC (iter->data);
const gchar *id = champlain_map_source_desc_get_id (desc);
const gchar *name = champlain_map_source_desc_get_name (desc);
const char *id = champlain_map_source_desc_get_id (desc);
const char *name = champlain_map_source_desc_get_name (desc);
gtk_tree_store_append (store, &parent, NULL);
gtk_tree_store_set (store, &parent, COL_ID, id,
......@@ -213,7 +213,7 @@ build_combo_box (GtkComboBox *box)
static void
append_point (ChamplainPathLayer *layer, gdouble lon, gdouble lat)
append_point (ChamplainPathLayer *layer, double lon, double lat)
{
ChamplainCoordinate *coord;
......@@ -230,7 +230,7 @@ export_png (GtkButton *button,
GdkPixbuf *pixbuf;
GFileOutputStream *os;
GFile *file;
gint width, height;
int width, height;
if (champlain_view_get_state (view) != CHAMPLAIN_STATE_DONE)
return;
......
......@@ -26,12 +26,12 @@
static void
map_view_button_release_cb (GtkGestureClick *gesture,
gint n_press,
gdouble x,
gdouble y,
int n_press,
double x,
double y,
ShumateView *view)
{
gdouble lat, lon;
double lat, lon;
ShumateViewport *viewport;
viewport = shumate_view_get_viewport (view);
......
......@@ -47,7 +47,7 @@ make_button (char *text)
ClutterActor *button, *button_bg, *button_text;
ClutterColor white = { 0xff, 0xff, 0xff, 0xff };
ClutterColor black = { 0x00, 0x00, 0x00, 0xff };
gfloat width, height;
float width, height;
button = clutter_actor_new ();
......@@ -69,7 +69,7 @@ make_button (char *text)
static void
append_point (ShumatePathLayer *layer, gdouble lon, gdouble lat)
append_point (ShumatePathLayer *layer, double lon, double lat)
{
ShumateCoordinate *coord;
......@@ -84,7 +84,7 @@ main (int argc,
{
ClutterActor *actor, *stage, *buttons, *button;
ShumatePathLayer *layer;
gfloat width, total_width = 0;;
float width, total_width = 0;;
GList *dash = NULL;
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
......
......@@ -26,8 +26,8 @@ typedef struct
{
SoupMessage *message;
ShumateMarkerLayer *layer;
gdouble latitude;
gdouble longitude;
double latitude;
double longitude;
} MarkerData;
......@@ -50,7 +50,7 @@ image_downloaded_cb (GObject *source_object,
g_autoptr(GdkPixbuf) pixbuf = NULL;
g_autoptr(ShumateMarkerLayer) layer = g_steal_pointer (&marker_data->layer);
g_autoptr(SoupMessage) message = g_steal_pointer (&marker_data->message);
g_autofree gchar *url = soup_uri_to_string (soup_message_get_uri (message), FALSE);
g_autofree char *url = soup_uri_to_string (soup_message_get_uri (message), FALSE);
ShumateMarker *marker = NULL;
guint status_code = 0;
......@@ -92,9 +92,9 @@ image_downloaded_cb (GObject *source_object,
static void
create_marker_from_url (ShumateMarkerLayer *layer,
SoupSession *session,
gdouble latitude,
gdouble longitude,
const gchar *url)
double latitude,
double longitude,
const char *url)
{
MarkerData *data;
......
......@@ -103,8 +103,8 @@ shumate_bounding_box_free (ShumateBoundingBox *bbox)
*/
void
shumate_bounding_box_get_center (ShumateBoundingBox *bbox,
gdouble *latitude,
gdouble *longitude)
double *latitude,
double *longitude)
{
g_return_if_fail (SHUMATE_BOUNDING_BOX (bbox));
......@@ -122,7 +122,7 @@ shumate_bounding_box_get_center (ShumateBoundingBox *bbox,
*/
void
shumate_bounding_box_compose (ShumateBoundingBox *bbox,
ShumateBoundingBox *other)
ShumateBoundingBox *other)
{
g_return_if_fail (SHUMATE_BOUNDING_BOX (bbox));
......@@ -151,7 +151,8 @@ shumate_bounding_box_compose (ShumateBoundingBox *bbox,
*/
void
shumate_bounding_box_extend (ShumateBoundingBox *bbox,
gdouble latitude, gdouble longitude)
double latitude,
double longitude)
{
g_return_if_fail (SHUMATE_BOUNDING_BOX (bbox));
......@@ -201,8 +202,8 @@ shumate_bounding_box_is_valid (ShumateBoundingBox *bbox)
*/
gboolean
shumate_bounding_box_covers(ShumateBoundingBox *bbox,
gdouble latitude,
gdouble longitude)
double latitude,
double longitude)
{
g_return_val_if_fail (SHUMATE_BOUNDING_BOX (bbox), FALSE);
......
......@@ -44,10 +44,10 @@ typedef struct _ShumateBoundingBox ShumateBoundingBox;
struct _ShumateBoundingBox
{
/*< public >*/
gdouble left;
gdouble top;
gdouble right;
gdouble bottom;
double left;
double top;
double right;
double bottom;
};
GType shumate_bounding_box_get_type (void) G_GNUC_CONST;
......@@ -60,21 +60,21 @@ ShumateBoundingBox *shumate_bounding_box_copy (const ShumateBoundingBox *bbox);
void shumate_bounding_box_free (ShumateBoundingBox *bbox);
void shumate_bounding_box_get_center (ShumateBoundingBox *bbox,
gdouble *latitude,
gdouble *longitude);
double *latitude,
double *longitude);
void shumate_bounding_box_compose (ShumateBoundingBox *bbox,
ShumateBoundingBox *other);
ShumateBoundingBox *other);
void shumate_bounding_box_extend (ShumateBoundingBox *bbox,
gdouble latitude,
gdouble longitude);
double latitude,
double longitude);
gboolean shumate_bounding_box_is_valid (ShumateBoundingBox *bbox);
gboolean shumate_bounding_box_covers(ShumateBoundingBox *bbox,
gdouble latitude,
gdouble longitude);
double latitude,
double longitude);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ShumateBoundingBox, shumate_bounding_box_free)
......
......@@ -32,29 +32,28 @@
enum
{
PROP_0,
PROP_LONGITUDE,
PROP_LONGITUDE = 1,
PROP_LATITUDE,
};
static void set_location (ShumateLocation *location,
gdouble latitude,
gdouble longitude);
static gdouble get_latitude (ShumateLocation *location);
static gdouble get_longitude (ShumateLocation *location);
double latitude,
double longitude);
static double get_latitude (ShumateLocation *location);
static double get_longitude (ShumateLocation *location);
static void location_interface_init (ShumateLocationInterface *iface);
typedef struct
{
gdouble longitude;
gdouble latitude;
double longitude;
double latitude;
} ShumateCoordinatePrivate;
G_DEFINE_TYPE_WITH_CODE (ShumateCoordinate, shumate_coordinate, G_TYPE_INITIALLY_UNOWNED,
G_ADD_PRIVATE (ShumateCoordinate)
G_IMPLEMENT_INTERFACE (SHUMATE_TYPE_LOCATION, location_interface_init));
G_ADD_PRIVATE (ShumateCoordinate)
G_IMPLEMENT_INTERFACE (SHUMATE_TYPE_LOCATION, location_interface_init));
static void
shumate_coordinate_get_property (GObject *object,
......@@ -94,14 +93,14 @@ shumate_coordinate_set_property (GObject *object,
{
case PROP_LONGITUDE:
{
gdouble longitude = g_value_get_double (value);
double longitude = g_value_get_double (value);
set_location (SHUMATE_LOCATION (coordinate), priv->latitude, longitude);
break;
}
case PROP_LATITUDE:
{
gdouble latitude = g_value_get_double (value);
double latitude = g_value_get_double (value);
set_location (SHUMATE_LOCATION (coordinate), latitude, priv->longitude);
break;
}
......@@ -114,8 +113,8 @@ shumate_coordinate_set_property (GObject *object,
static void
set_location (ShumateLocation *location,
gdouble latitude,
gdouble longitude)
double latitude,
double longitude)
{
ShumateCoordinate *coordinate = SHUMATE_COORDINATE (location);
ShumateCoordinatePrivate *priv = shumate_coordinate_get_instance_private (coordinate);
......@@ -130,7 +129,7 @@ set_location (ShumateLocation *location,
}
static gdouble
static double
get_latitude (ShumateLocation *location)
{
ShumateCoordinate *coordinate = SHUMATE_COORDINATE (location);
......@@ -142,7 +141,7 @@ get_latitude (ShumateLocation *location)
}
static gdouble
static double
get_longitude (ShumateLocation *location)
{
ShumateCoordinate *coordinate = SHUMATE_COORDINATE (location);
......@@ -214,8 +213,8 @@ shumate_coordinate_new ()
* Returns: the created instance.
*/
ShumateCoordinate *
shumate_coordinate_new_full (gdouble latitude,
gdouble longitude)
shumate_coordinate_new_full (double latitude,
double longitude)
{
return SHUMATE_COORDINATE (g_object_new (SHUMATE_TYPE_COORDINATE,
"latitude", latitude,
......
......@@ -47,8 +47,8 @@ struct _ShumateCoordinateClass
ShumateCoordinate *shumate_coordinate_new (void);
ShumateCoordinate *shumate_coordinate_new_full (gdouble latitude,
gdouble longitude);
ShumateCoordinate *shumate_coordinate_new_full (double latitude,
double longitude);
G_END_DECLS
......
......@@ -54,7 +54,7 @@ debug_set_flags (ShumateDebugFlags new_flags)
void
shumate_debug_set_flags (const gchar *flags_string)
shumate_debug_set_flags (const char *flags_string)
{
guint nkeys;
......@@ -75,7 +75,7 @@ shumate_debug_flag_is_set (ShumateDebugFlags flag)
void
shumate_debug (ShumateDebugFlags flag,
const gchar *format,
const char *format,
...)
{
if (flag & flags)
......@@ -98,13 +98,13 @@ shumate_debug_flag_is_set (ShumateDebugFlags flag)
void
shumate_debug (ShumateDebugFlags flag, const gchar *format, ...)
shumate_debug (ShumateDebugFlags flag, const char *format, ...)
{
}
void
shumate_debug_set_flags (const gchar *flags_string)
shumate_debug_set_flags (const char *flags_string)
{
}
......
......@@ -42,9 +42,9 @@ typedef enum
gboolean shumate_debug_flag_is_set (ShumateDebugFlags flag);
void shumate_debug (ShumateDebugFlags flag,
const gchar *format,
const char *format,
...) G_GNUC_PRINTF (2, 3);
void shumate_debug_set_flags (const gchar *flags_string);
void shumate_debug_set_flags (const char *flags_string);
G_END_DECLS
#endif /* __SHUMATE_DEBUG_H__ */
......
......@@ -49,7 +49,7 @@ enum
typedef struct
{
guint size_limit;
gchar *cache_dir;
char *cache_dir;
sqlite3 *db;
sqlite3_stmt *stmt_select;
......@@ -60,13 +60,13 @@ G_DEFINE_TYPE_WITH_PRIVATE (ShumateFileCache, shumate_file_cache, SHUMATE_TYPE_T
static void finalize_sql (ShumateFileCache *file_cache);
static void init_cache (ShumateFileCache *file_cache);
static gchar *get_filename (ShumateFileCache *file_cache,
static char *get_filename (ShumateFileCache *file_cache,
ShumateTile *tile);
static gboolean tile_is_expired (ShumateFileCache *file_cache,
ShumateTile *tile);
static void delete_tile (ShumateFileCache *file_cache,
const gchar *filename);
static gboolean create_cache_dir (const gchar *dir_name);
const char *filename);
static gboolean create_cache_dir (const char *dir_name);
static void fill_tile (ShumateMapSource *map_source,
ShumateTile *tile,
......@@ -74,7 +74,7 @@ static void fill_tile (ShumateMapSource *map_source,
static void store_tile (ShumateTileCache *tile_cache,
ShumateTile *tile,
const gchar *contents,
const char *contents,
gsize size);
static void refresh_tile_time (ShumateTileCache *tile_cache,
ShumateTile *tile);
......@@ -141,7 +141,7 @@ finalize_sql (ShumateFileCache *file_cache)
if (priv->db)
{
gint error = sqlite3_close (priv->db);
int error = sqlite3_close (priv->db);
if (error != SQLITE_OK)
DEBUG ("Sqlite returned error %d when closing cache.db", error);
priv->db = NULL;
......@@ -164,7 +164,7 @@ shumate_file_cache_finalize (GObject *object)
static gboolean
create_cache_dir (const gchar *dir_name)
create_cache_dir (const char *dir_name)
{
/* If needed, create the cache's dirs */
if (dir_name)
......@@ -184,8 +184,8 @@ static void
init_cache (ShumateFileCache *file_cache)
{
ShumateFileCachePrivate *priv = shumate_file_cache_get_instance_private (file_cache);
gchar *filename = NULL;
gchar *error_msg = NULL;
char *filename = NULL;
char *error_msg = NULL;
gint error;
g_return_if_fail (create_cache_dir (priv->cache_dir));
......@@ -347,7 +347,7 @@ shumate_file_cache_init (ShumateFileCache *file_cache)
*/
ShumateFileCache *
shumate_file_cache_new_full (guint size_limit,
const gchar *cache_dir)
const char *cache_dir)
{
ShumateFileCache *cache;
......@@ -386,7 +386,7 @@ shumate_file_cache_get_size_limit (ShumateFileCache *file_cache)
*
* Returns: the directory
*/
const gchar *
const char *
shumate_file_cache_get_cache_dir (ShumateFileCache *file_cache)
{
ShumateFileCachePrivate *priv = shumate_file_cache_get_instance_private (file_cache);
......@@ -417,7 +417,7 @@ shumate_file_cache_set_size_limit (ShumateFileCache *file_cache,
}
static gchar *
static char *
get_filename (ShumateFileCache *file_cache,
ShumateTile *tile)
{
......@@ -429,7 +429,7 @@ get_filename (ShumateFileCache *file_cache,
ShumateMapSource *map_source = SHUMATE_MAP_SOURCE (file_cache);
gchar *filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S
char *filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S
"%s" G_DIR_SEPARATOR_S
"%d" G_DIR_SEPARATOR_S
"%d" G_DIR_SEPARATOR_S "%d.png",
......@@ -499,7 +499,7 @@ on_pixbuf_created (GObject *source_object,
g_autoptr(GdkTexture) texture = NULL;
g_autoptr(GError) error = NULL;
g_autoptr(GFile) file = NULL;
g_autofree gchar *filename = NULL;
g_autofree char *filename = NULL;
g_autoptr(GFileInfo) info = NULL;
pixbuf = gdk_pixbuf_new_from_stream_finish (res, &error);
......@@ -547,7 +547,7 @@ on_pixbuf_created (GObject *source_object,
sql_rc = sqlite3_step (priv->stmt_select);
if (sql_rc == SQLITE_ROW)
{
const gchar *etag = (const gchar *) sqlite3_column_text (priv->stmt_select, 0);
const char *etag = (const char *) sqlite3_column_text (priv->stmt_select, 0);
shumate_tile_set_etag (SHUMATE_TILE (tile), etag);
}
else if (sql_rc == SQLITE_DONE)
......@@ -599,7 +599,7 @@ on_file_loaded (GObject *source_object,
input_stream = G_INPUT_STREAM (g_file_read_finish (G_FILE (source_object), res, &error));
if (!input_stream)
{
g_autofree gchar *path = g_file_get_path (G_FILE (source_object));
g_autofree char *path = g_file_get_path (G_FILE (source_object));
ShumateMapSource *next_source = shumate_map_source_get_next_source (SHUMATE_MAP_SOURCE (self));
DEBUG ("Failed to load tile %s, error: %s", path, error->message);
......@@ -633,7 +633,7 @@ fill_tile (ShumateMapSource *map_source,
{
FileLoadedData *user_data;
g_autoptr(GFile) file = NULL;
g_autofree gchar *filename = NULL;
g_autofree char *filename = NULL;
filename = get_filename (self, tile);
file = g_file_new_for_path (filename);
......@@ -667,7 +667,7 @@ refresh_tile_time (ShumateTileCache *tile_cache,
ShumateMapSource *map_source = SHUMATE_MAP_SOURCE (tile_cache);
ShumateMapSource *next_source = shumate_map_source_get_next_source (map_source);
ShumateFileCache *file_cache = SHUMATE_FILE_CACHE (tile_cache);
gchar *filename = NULL;
char *filename = NULL;
GFile *file;
GFileInfo *info;
......@@ -699,7 +699,7 @@ refresh_tile_time (ShumateTileCache *tile_cache,
static void
store_tile (ShumateTileCache *tile_cache,
ShumateTile *tile,
const gchar *contents,
const char *contents,
gsize size)
{
g_return_if_fail (SHUMATE_IS_FILE_CACHE (tile_cache));
......@@ -708,10 +708,10 @@ store_tile (ShumateTileCache *tile_cache,
ShumateMapSource *next_source = shumate_map_source_get_next_source (map_source);
ShumateFileCache *file_cache = SHUMATE_FILE_CACHE (tile_cache);
ShumateFileCachePrivate *priv = shumate_file_cache_get_instance_private (file_cache);
gchar *query = NULL;
gchar *error = NULL;
gchar *path = NULL;
gchar *filename = NULL;
char *query = NULL;
char *error = NULL;
char *path = NULL;
char *filename = NULL;
GError *gerror = NULL;
GFile *file;
GFileOutputStream *ostream;
......@@ -790,7 +790,7 @@ on_tile_filled (ShumateTileCache *tile_cache,
ShumateFileCache *file_cache = SHUMATE_FILE_CACHE (tile_cache);
ShumateFileCachePrivate *priv = shumate_file_cache_get_instance_private (file_cache);
int sql_rc = SQLITE_OK;
gchar *filename = NULL;
char *filename = NULL;
filename = get_filename (file_cache, tile);
......@@ -820,12 +820,12 @@ call_next:
static void
delete_tile (ShumateFileCache *file_cache, const gchar *filename)
delete_tile (ShumateFileCache *file_cache, const char *filename)
{
ShumateFileCachePrivate *priv = shumate_file_cache_get_instance_private (file_cache);
g_return_if_fail (SHUMATE_IS_FILE_CACHE (file_cache));
gchar *query, *error = NULL;
char *query, *error = NULL;
GError *gerror = NULL;
GFile *file;
......@@ -887,12 +887,12 @@ shumate_file_cache_purge (ShumateFileCache *file_cache)
g_return_if_fail (SHUMATE_IS_FILE_CACHE (file_cache));
gchar *query;
char *query;
sqlite3_stmt *stmt;
int rc = 0;
guint current_size = 0;
guint highest_popularity = 0;
gchar *error;
char *error;
query = "SELECT SUM (size) FROM tiles";
rc = sqlite3_prepare (priv->db, query, strlen (query), &stmt, NULL);
......
......@@ -46,13 +46,13 @@ struct _ShumateFileCacheClass
};
ShumateFileCache *shumate_file_cache_new_full (guint size_limit,
const gchar *cache_dir);
const char *cache_dir);
guint shumate_file_cache_get_size_limit (ShumateFileCache *file_cache);
void shumate_file_cache_set_size_limit (ShumateFileCache *file_cache,
guint size_limit);
const gchar *shumate_file_cache_get_cache_dir (ShumateFileCache *file_cache);
const char *shumate_file_cache_get_cache_dir (ShumateFileCache *file_cache);
void shumate_file_cache_purge (ShumateFileCache *file_cache);
void shumate_file_cache_purge_on_idle (ShumateFileCache *file_cache);
......
......@@ -229,7 +229,7 @@ shumate_license_new (void)
*/
void
shumate_license_set_extra_text (ShumateLicense *license,
const gchar *text)
const char *text)
{
g_return_if_fail (SHUMATE_IS_LICENSE (license));
......@@ -248,7 +248,7 @@ shumate_license_set_extra_text (ShumateLicense *license,
*
* Returns: the additional license text
*/
const gchar *
const char *
shumate_license_get_extra_text (ShumateLicense *license)
{
g_return_val_if_fail (SHUMATE_IS_LICENSE (license), NULL);
......@@ -266,7 +266,7 @@ shumate_license_get_extra_text (ShumateLicense *license)
*/
void
shumate_license_set_xalign (ShumateLicense *license,
gfloat xalign)
float xalign)
{
g_return_if_fail (SHUMATE_IS_LICENSE (license));
......@@ -285,7 +285,7 @@ shumate_license_set_xalign (ShumateLicense *license,
*
* Returns: the license's text horizontal alignment.
*/
gfloat
float
shumate_license_get_xalign (ShumateLicense *license)
{
g_return_val_if_fail (SHUMATE_IS_LICENSE (license), 1.0f);
......