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

scale: Port to Gtk4

ShumateScale is now a simple widget composed of 2 labels.
It is now possible to show both metric and imperial units at the same time.
parent a2cc7b24
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/shumate/">
<file compressed="true">scale.css</file>
</gresource>
</gresources>
shumate_resources = gnome.compile_resources(
'shumate-resources',
'libshumate.gresource.xml',
c_name: 'shumate'
)
map-scale label {
border: 2px solid rgba(0, 0, 0, 0.5);
border-top: none;
background: rgba(255, 255, 255, 0.5);
padding: 3px;
}
map-scale {
margin: 6px;
}
......@@ -25,15 +25,26 @@ activate (GtkApplication* app,
gpointer user_data)
{
GtkWindow *window;
GtkWidget *overlay;
ShumateView *view;
ShumateScale *scale;
/* Create the map view */
overlay = gtk_overlay_new ();
view = shumate_view_new ();
gtk_overlay_set_child (GTK_OVERLAY (overlay), GTK_WIDGET (view));
scale = shumate_scale_new ();
g_object_set (G_OBJECT (scale),
"valign", GTK_ALIGN_END,
"halign", GTK_ALIGN_START,
NULL);
shumate_scale_connect_view (scale, view);
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), GTK_WIDGET (scale));
window = GTK_WINDOW (gtk_application_window_new (app));
gtk_window_set_title (window, "Window");
gtk_window_set_default_size (window, 200, 200);
gtk_window_set_child (window, GTK_WIDGET (view));
gtk_window_set_child (window, GTK_WIDGET (overlay));
gtk_window_present (window);
}
......
......@@ -100,6 +100,8 @@ if generate_vapi and not vapigen_dep.found()
generate_vapi = false
endif
subdir('data')
subdir('shumate')
subdir('docs')
......
......@@ -158,6 +158,7 @@ install_headers(
libshumate_lib = library(
package_string,
libshumate_sources,
shumate_resources,
version: lib_version,
include_directories: rootdir,
dependencies: libshumate_deps,
......@@ -201,6 +202,7 @@ if generate_gir == true
libshumate_dep_sources += [
libshumate_gir,
shumate_resources,
]
if generate_vapi == true and libshumate_gir.length() > 0
......
This diff is collapsed.
/*
* Copyright (C) 2011-2013 Jiri Techet <techet@gmail.com>
* Copyright (C) 2019 Marcus Lundblad <ml@update.uu.se>
* Copyright (C) 2020 Collabora Ltd. (https://www.collabora.com)
* Copyright (C) 2020 Corentin Noël <corentin.noel@collabora.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -27,23 +29,26 @@
#include <shumate/shumate-defines.h>
#include <glib-object.h>
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define SHUMATE_TYPE_SCALE shumate_scale_get_type ()
G_DECLARE_FINAL_TYPE (ShumateScale, shumate_scale, SHUMATE, SCALE, GObject)
G_DECLARE_FINAL_TYPE (ShumateScale, shumate_scale, SHUMATE, SCALE, GtkWidget)
/**
* ShumateUnit:
* @SHUMATE_UNIT_KM: kilometers
* @SHUMATE_UNIT_MILES: miles
* @SHUMATE_UNIT_BOTH: Both metric and imperial units
* @SHUMATE_UNIT_METRIC: Metric units (meters)
* @SHUMATE_UNIT_IMPERIAL: Imperial units (miles)
*
* Units used by the scale.
*/
typedef enum
{
SHUMATE_UNIT_KM,
SHUMATE_UNIT_MILES,
SHUMATE_UNIT_BOTH,
SHUMATE_UNIT_METRIC,
SHUMATE_UNIT_IMPERIAL,
} ShumateUnit;
/**
......@@ -55,17 +60,17 @@ typedef enum
ShumateScale *shumate_scale_new (void);
guint shumate_scale_get_max_width (ShumateScale *scale);
void shumate_scale_set_max_width (ShumateScale *scale,
guint value);
void shumate_scale_set_unit (ShumateScale *scale,
ShumateUnit unit);
guint value);
guint shumate_scale_get_max_width (ShumateScale *scale);
ShumateUnit shumate_scale_get_unit (ShumateScale *scale);
void shumate_scale_set_unit (ShumateScale *scale,
ShumateUnit unit);
void shumate_scale_connect_view (ShumateScale *scale,
ShumateView *view);
void shumate_scale_disconnect_view (ShumateScale *scale);
void shumate_scale_connect_view (ShumateScale *self,
ShumateView *view);
void shumate_scale_disconnect_view (ShumateScale *self);
G_END_DECLS
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment