shumate/shumate-point.c
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Copyright (C) 2011-2013 Jiri Techet <techet@gmail.com> | ||
| 3 | * Copyright (C) 2019 Marcus Lundblad <ml@update.uu.se> | ||
| 4 | * | ||
| 5 | * This library is free software; you can redistribute it and/or | ||
| 6 | * modify it under the terms of the GNU Lesser General Public | ||
| 7 | * License as published by the Free Software Foundation; either | ||
| 8 | * version 2.1 of the License, or (at your option) any later version. | ||
| 9 | * | ||
| 10 | * This library is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 13 | * Lesser General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU Lesser General Public | ||
| 16 | * License along with this library; if not, write to the Free Software | ||
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 18 | */ | ||
| 19 | |||
| 20 | /** | ||
| 21 | * ShumatePoint: | ||
| 22 | * | ||
| 23 | * A simple variant of [class@Marker] showing the location of the point as a | ||
| 24 | * circle on the map. | ||
| 25 | * | ||
| 26 | * ## CSS nodes | ||
| 27 | * | ||
| 28 | * `ShumatePoint` has a single CSS node with the name “map-point”. | ||
| 29 | */ | ||
| 30 | |||
| 31 | #include "shumate-point.h" | ||
| 32 | |||
| 33 | struct _ShumatePoint | ||
| 34 | { | ||
| 35 | ShumateMarker parent_instance; | ||
| 36 | }; | ||
| 37 | |||
| 38 |
4/6shumate_point_class_intern_init:
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 2 times.
shumate_point_get_type:
✓ Branch 2 → 3 taken 2 times.
✓ Branch 2 → 7 taken 103 times.
✓ Branch 4 → 5 taken 2 times.
✗ Branch 4 → 7 not taken.
|
109 | G_DEFINE_TYPE (ShumatePoint, shumate_point, SHUMATE_TYPE_MARKER); |
| 39 | |||
| 40 | static void | ||
| 41 | 2 | shumate_point_class_init (ShumatePointClass *klass) | |
| 42 | { | ||
| 43 | 2 | GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); | |
| 44 | 2 | GdkDisplay *display; | |
| 45 | |||
| 46 | 2 | gtk_widget_class_set_css_name (widget_class, "map-point"); | |
| 47 | |||
| 48 | 2 | display = gdk_display_get_default (); | |
| 49 |
2/2✓ Branch 4 → 5 taken 1 time.
✓ Branch 4 → 10 taken 1 time.
|
2 | if (display) |
| 50 | { | ||
| 51 | 1 | g_autoptr(GtkCssProvider) provider = gtk_css_provider_new (); | |
| 52 | 1 | gtk_css_provider_load_from_resource (provider, "/org/gnome/shumate/point.css"); | |
| 53 |
1/2✓ Branch 8 → 9 taken 1 time.
✗ Branch 8 → 10 not taken.
|
1 | gtk_style_context_add_provider_for_display (display, |
| 54 | GTK_STYLE_PROVIDER (provider), | ||
| 55 | GTK_STYLE_PROVIDER_PRIORITY_FALLBACK); | ||
| 56 | } | ||
| 57 | 2 | } | |
| 58 | |||
| 59 | static void | ||
| 60 | 104 | shumate_point_init (ShumatePoint *point) | |
| 61 | { | ||
| 62 | 104 | g_object_set (point, | |
| 63 | "halign", GTK_ALIGN_CENTER, | ||
| 64 | "valign", GTK_ALIGN_CENTER, | ||
| 65 | NULL); | ||
| 66 | 104 | } | |
| 67 | |||
| 68 | /** | ||
| 69 | * shumate_point_new: | ||
| 70 | * | ||
| 71 | * Creates an instance of #ShumatePoint. | ||
| 72 | * | ||
| 73 | * Returns: (type ShumatePoint): a new #ShumatePoint. | ||
| 74 | */ | ||
| 75 | ShumateMarker * | ||
| 76 | 104 | shumate_point_new (void) | |
| 77 | { | ||
| 78 | 104 | return SHUMATE_MARKER (g_object_new (SHUMATE_TYPE_POINT, NULL)); | |
| 79 | } | ||
| 80 |