application: Move time format to GcalContext

It finally found its place under the sun.
This commit is contained in:
Georges Basile Stavracas Neto
2019-04-25 16:30:57 -03:00
parent ad21581d6f
commit c5b5023508
8 changed files with 100 additions and 163 deletions
-47
View File
@@ -24,7 +24,6 @@
#include "css-code.h"
#include "gcal-application.h"
#include "gcal-debug.h"
#include "gcal-enums.h"
#include "gcal-log.h"
#include "gcal-shell-search-provider.h"
#include "gcal-window.h"
@@ -46,9 +45,6 @@ struct _GcalApplication
gchar *uuid;
icaltimetype *initial_date;
GSettings *desktop_settings;
GcalTimeFormat time_format;
GcalShellSearchProvider *search_provider;
GcalContext *context;
@@ -115,7 +111,6 @@ enum
PROP_0,
PROP_CONTEXT,
PROP_MANAGER,
PROP_TIME_FORMAT,
N_PROPS
};
@@ -188,25 +183,6 @@ load_css_provider (GcalApplication *self)
gtk_css_provider_load_from_resource (self->provider, "/org/gnome/calendar/theme/Adwaita.css");
}
static void
load_time_format (GcalApplication *self)
{
g_autofree gchar *clock_format = NULL;
g_autofree gchar *enum_format = NULL;
clock_format = g_settings_get_string (self->desktop_settings, "clock-format");
if (g_strcmp0 (clock_format, "12h") == 0)
self->time_format = GCAL_TIME_FORMAT_12H;
else
self->time_format = GCAL_TIME_FORMAT_24H;
enum_format = g_enum_to_string (GCAL_TYPE_TIME_FORMAT, self->time_format);
g_debug ("Setting time format to %s", enum_format);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TIME_FORMAT]);
}
/*
* GObject overrides
@@ -223,7 +199,6 @@ gcal_application_finalize (GObject *object)
g_clear_pointer (&self->uuid, g_free);
g_clear_object (&self->context);
g_clear_object (&self->colors_provider);
g_clear_object (&self->desktop_settings);
g_clear_object (&self->provider);
g_clear_object (&self->search_provider);
@@ -250,10 +225,6 @@ gcal_application_get_property (GObject *object,
g_value_set_object (value, gcal_context_get_manager (self->context));
break;
case PROP_TIME_FORMAT:
g_value_set_enum (value, self->time_format);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -301,11 +272,8 @@ gcal_application_activate (GApplication *application)
"application", self,
"context", self->context,
"active-date", self->initial_date,
"time-format", self->time_format,
NULL);
g_object_bind_property (self, "time-format", self->window, "time-format", G_BINDING_DEFAULT);
g_signal_connect (self->window, "destroy", G_CALLBACK (gtk_widget_destroyed), &self->window);
gtk_widget_show (self->window);
}
@@ -347,14 +315,6 @@ gcal_application_startup (GApplication *app)
self->colors_provider = gtk_css_provider_new ();
/* Time format */
self->desktop_settings = g_settings_new ("org.gnome.desktop.interface");
g_signal_connect_swapped (self->desktop_settings,
"changed::clock-format",
G_CALLBACK (load_time_format),
self);
load_time_format (self);
/* Startup the manager */
gcal_manager_startup (gcal_context_get_manager (self->context));
@@ -513,13 +473,6 @@ gcal_application_class_init (GcalApplicationClass *klass)
GCAL_TYPE_MANAGER,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
properties[PROP_TIME_FORMAT] = g_param_spec_enum ("time-format",
"The time format of the computer",
"The time format of the computer",
GCAL_TYPE_TIME_FORMAT,
GCAL_TIME_FORMAT_24H,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, N_PROPS, properties);
}