[gnome-todo] next-week-panel: Cleanup



commit b2f851cea164075a8642f51f791832d2b89f1588
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri May 1 11:31:09 2020 -0300

    next-week-panel: Cleanup

 plugins/next-week-panel/gtd-next-week-panel.c      |  31 +++-
 .../next-week-panel/gtd-plugin-next-week-panel.c   | 158 ---------------------
 plugins/next-week-panel/meson.build                |  10 +-
 ...-next-week-panel.h => next-week-panel-plugin.c} |  26 ++--
 ...week-panel.plugin.in => next-week-panel.plugin} |   2 +-
 5 files changed, 45 insertions(+), 182 deletions(-)
---
diff --git a/plugins/next-week-panel/gtd-next-week-panel.c b/plugins/next-week-panel/gtd-next-week-panel.c
index 3d30dc8..9a4ea4a 100644
--- a/plugins/next-week-panel/gtd-next-week-panel.c
+++ b/plugins/next-week-panel/gtd-next-week-panel.c
@@ -1,6 +1,6 @@
 /* gtd-next-week-panel.c
  *
- * Copyright 2018 Georges Basile Stavracas Neto <georges stavracas gmail com>
+ * Copyright 2018-2020 Georges Basile Stavracas Neto <georges stavracas gmail com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -44,6 +44,8 @@ struct _GtdNextWeekPanel
   GtkFilterListModel *filter_model;
   GtkFilterListModel *incomplete_model;
   GtkSortListModel   *sort_model;
+
+  GtkCssProvider     *css_provider;
 };
 
 static void          gtd_panel_iface_init                        (GtdPanelInterface  *iface);
@@ -68,6 +70,31 @@ enum
  * Auxiliary methods
  */
 
+static void
+load_css_provider (GtdNextWeekPanel *self)
+{
+  g_autoptr (GSettings) settings = NULL;
+  g_autoptr (GFile) css_file = NULL;
+  g_autofree gchar *theme_name = NULL;
+  g_autofree gchar *theme_uri = NULL;
+
+  /* Load CSS provider */
+  settings = g_settings_new ("org.gnome.desktop.interface");
+  theme_name = g_settings_get_string (settings, "gtk-theme");
+  theme_uri = g_build_filename ("resource:///org/gnome/todo/theme/next-week-panel", theme_name, ".css", 
NULL);
+  css_file = g_file_new_for_uri (theme_uri);
+
+  self->css_provider = gtk_css_provider_new ();
+  gtk_style_context_add_provider_for_display (gdk_display_get_default (),
+                                              GTK_STYLE_PROVIDER (self->css_provider),
+                                              GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+
+  if (g_file_query_exists (css_file, NULL))
+    gtk_css_provider_load_from_file (self->css_provider, css_file);
+  else
+    gtk_css_provider_load_from_resource (self->css_provider, 
"/org/gnome/todo/theme/scheduled-panel/Adwaita.css");
+}
+
 static gboolean
 get_date_offset (GDateTime *dt,
                  gint      *days_diff,
@@ -413,6 +440,7 @@ gtd_next_week_panel_finalize (GObject *object)
 {
   GtdNextWeekPanel *self = (GtdNextWeekPanel *)object;
 
+  g_clear_object (&self->css_provider);
   g_clear_object (&self->icon);
   g_clear_object (&self->filter_model);
   g_clear_object (&self->incomplete_model);
@@ -525,6 +553,7 @@ gtd_next_week_panel_init (GtdNextWeekPanel *self)
                            G_CALLBACK (on_clock_day_changed_cb),
                            self,
                            0);
+  load_css_provider (self);
 }
 
 GtkWidget*
diff --git a/plugins/next-week-panel/meson.build b/plugins/next-week-panel/meson.build
index e883aa2..ad328da 100644
--- a/plugins/next-week-panel/meson.build
+++ b/plugins/next-week-panel/meson.build
@@ -1,8 +1,8 @@
-plugins_ldflags += ['-Wl,--undefined=gtd_plugin_next_week_panel_register_types']
+plugins_ldflags += ['-Wl,--undefined=next_week_panel_plugin_register_types']
 
 sources = files(
   'gtd-next-week-panel.c',
-  'gtd-plugin-next-week-panel.c'
+  'next-week-panel-plugin.c'
 )
 
 plugins_libs += static_library(
@@ -11,9 +11,3 @@ plugins_libs += static_library(
   include_directories: plugins_incs,
          dependencies: gnome_todo_deps
 )
-
-plugins_confs += configure_file(
-          input: 'next-week-panel.plugin.in',
-         output: 'next-week-panel.plugin',
-  configuration: plugins_conf
-)
diff --git a/plugins/next-week-panel/gtd-plugin-next-week-panel.h 
b/plugins/next-week-panel/next-week-panel-plugin.c
similarity index 60%
rename from plugins/next-week-panel/gtd-plugin-next-week-panel.h
rename to plugins/next-week-panel/next-week-panel-plugin.c
index e80eacd..332a215 100644
--- a/plugins/next-week-panel/gtd-plugin-next-week-panel.h
+++ b/plugins/next-week-panel/next-week-panel-plugin.c
@@ -1,6 +1,6 @@
-/* gtd-plugin-next-week-panel.h
+/* gtd-plugin-next-week-panel.c
  *
- * Copyright 2018 Georges Basile Stavracas Neto <georges stavracas gmail com>
+ * Copyright 2018-2020 Georges Basile Stavracas Neto <georges stavracas gmail com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -18,18 +18,16 @@
  * SPDX-License-Identifier: GPL-3.0-or-later
  */
 
-#pragma once
+#define G_LOG_DOMAIN "GtdPluginNextWeekPanel"
 
-#include "gnome-todo.h"
-
-#include <glib.h>
-
-G_BEGIN_DECLS
+#include "gtd-next-week-panel.h"
 
-#define GTD_TYPE_PLUGIN_NEXT_WEEK_PANEL (gtd_plugin_next_week_panel_get_type())
-
-G_DECLARE_FINAL_TYPE (GtdPluginNextWeekPanel, gtd_plugin_next_week_panel, GTD, PLUGIN_NEXT_WEEK_PANEL, 
PeasExtensionBase)
-
-G_MODULE_EXPORT void gtd_plugin_next_week_panel_register_types   (PeasObjectModule   *module);
+#include "gnome-todo.h"
 
-G_END_DECLS
+G_MODULE_EXPORT void
+next_week_panel_plugin_register_types (PeasObjectModule *module)
+{
+  peas_object_module_register_extension_type (module,
+                                              GTD_TYPE_PANEL,
+                                              GTD_TYPE_NEXT_WEEK_PANEL);
+}
diff --git a/plugins/next-week-panel/next-week-panel.plugin.in 
b/plugins/next-week-panel/next-week-panel.plugin
similarity index 86%
rename from plugins/next-week-panel/next-week-panel.plugin.in
rename to plugins/next-week-panel/next-week-panel.plugin
index 5707a26..4810935 100644
--- a/plugins/next-week-panel/next-week-panel.plugin.in
+++ b/plugins/next-week-panel/next-week-panel.plugin
@@ -9,5 +9,5 @@ Website = https://wiki.gnome.org/Apps/Todo
 Builtin = true
 License = GPL
 Loader = C
-Embedded = gtd_plugin_next_week_panel_register_types
+Embedded = next_week_panel_plugin_register_types
 Depends =


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]