[gnome-todo] today-panel: Cleanup



commit 7fd71e8acc00e20c2eb492ae8a82fffea4fc4bf2
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri May 1 12:04:06 2020 -0300

    today-panel: Cleanup

 plugins/today-panel/gtd-panel-today.c              |  30 ++++
 plugins/today-panel/gtd-plugin-today-panel.c       | 160 ---------------------
 plugins/today-panel/meson.build                    |  12 +-
 ...d-plugin-today-panel.h => today-panel-plugin.c} |  31 ++--
 .../{today-panel.plugin.in => today-panel.plugin}  |   2 +-
 5 files changed, 47 insertions(+), 188 deletions(-)
---
diff --git a/plugins/today-panel/gtd-panel-today.c b/plugins/today-panel/gtd-panel-today.c
index a5a2707..71f438d 100644
--- a/plugins/today-panel/gtd-panel-today.c
+++ b/plugins/today-panel/gtd-panel-today.c
@@ -37,6 +37,8 @@ struct _GtdPanelToday
   GtkFilterListModel *filter_model;
   GtkFilterListModel *incomplete_model;
   GtkSortListModel   *sort_model;
+
+  GtkCssProvider     *css_provider;
 };
 
 static void          gtd_panel_iface_init                        (GtdPanelInterface  *iface);
@@ -67,6 +69,31 @@ enum
  * Auxiliary methods
  */
 
+static void
+load_css_provider (GtdPanelToday *self)
+{
+  g_autofree gchar *theme_name = NULL;
+  g_autofree gchar *theme_uri = NULL;
+  g_autoptr (GSettings) settings = NULL;
+  g_autoptr (GFile) css_file = 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/today-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/today-panel/Adwaita.css");
+}
+
 static gboolean
 is_overdue (GDateTime *today,
             GDateTime *dt)
@@ -315,6 +342,7 @@ gtd_panel_today_finalize (GObject *object)
 {
   GtdPanelToday *self = (GtdPanelToday *)object;
 
+  g_clear_object (&self->css_provider);
   g_clear_object (&self->icon);
   g_clear_object (&self->filter_model);
   g_clear_object (&self->incomplete_model);
@@ -431,6 +459,8 @@ gtd_panel_today_init (GtdPanelToday *self)
                            G_CALLBACK (on_clock_day_changed_cb),
                            self,
                            0);
+
+  load_css_provider (self);
 }
 
 GtkWidget*
diff --git a/plugins/today-panel/meson.build b/plugins/today-panel/meson.build
index fda5e23..fb33597 100644
--- a/plugins/today-panel/meson.build
+++ b/plugins/today-panel/meson.build
@@ -1,11 +1,11 @@
 plugin_name = 'today-panel'
 
-plugins_ldflags += ['-Wl,--undefined=gtd_plugin_today_panel_register_types']
+plugins_ldflags += ['-Wl,--undefined=today_panel_plugin_register_types']
 
 sources = files(
   'gtd-panel-today.c',
   'gtd-today-omni-area-addin.c',
-  'gtd-plugin-' + plugin_name + '.c'
+  'today-panel-plugin.c'
 )
 
 plugins_libs += static_library(
@@ -15,11 +15,3 @@ plugins_libs += static_library(
          dependencies: gnome_todo_deps,
                   pic: true,
 )
-
-plugin_data = plugin_name + '.plugin'
-
-plugins_confs += configure_file(
-          input: plugin_data + '.in',
-         output: plugin_data,
-  configuration: plugins_conf
-)
diff --git a/plugins/today-panel/gtd-plugin-today-panel.h b/plugins/today-panel/today-panel-plugin.c
similarity index 50%
rename from plugins/today-panel/gtd-plugin-today-panel.h
rename to plugins/today-panel/today-panel-plugin.c
index 0f61041..0d88d1e 100644
--- a/plugins/today-panel/gtd-plugin-today-panel.h
+++ b/plugins/today-panel/today-panel-plugin.c
@@ -1,6 +1,6 @@
-/* gtd-plugin-today-panel.h
+/* gtd-plugin-today-panel.c
  *
- * Copyright (C) 2016 Georges Basile Stavracas Neto <georges stavracas gmail com>
+ * Copyright (C) 2016-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
@@ -16,22 +16,19 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef GTD_PLUGIN_TODAY_PANEL_H
-#define GTD_PLUGIN_TODAY_PANEL_H
-
 #include "gnome-todo.h"
 
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-#define GTD_TYPE_PLUGIN_TODAY_PANEL (gtd_plugin_today_panel_get_type())
-
-G_DECLARE_FINAL_TYPE (GtdPluginTodayPanel, gtd_plugin_today_panel, GTD, PLUGIN_TODAY_PANEL, 
PeasExtensionBase)
-
-G_MODULE_EXPORT void gtd_plugin_today_panel_register_types       (PeasObjectModule   *module);
-
-G_END_DECLS
+#include "gtd-panel-today.h"
+#include "gtd-today-omni-area-addin.h"
 
-#endif /* GTD_PLUGIN_TODAY_PANEL_H */
+G_MODULE_EXPORT void
+today_panel_plugin_register_types (PeasObjectModule *module)
+{
+  peas_object_module_register_extension_type (module,
+                                              GTD_TYPE_PANEL,
+                                              GTD_TYPE_PANEL_TODAY);
 
+  peas_object_module_register_extension_type (module,
+                                              GTD_TYPE_OMNI_AREA_ADDIN,
+                                              GTD_TYPE_TODAY_OMNI_AREA_ADDIN);
+}
diff --git a/plugins/today-panel/today-panel.plugin.in b/plugins/today-panel/today-panel.plugin
similarity index 87%
rename from plugins/today-panel/today-panel.plugin.in
rename to plugins/today-panel/today-panel.plugin
index 0dd9059..b27df31 100644
--- a/plugins/today-panel/today-panel.plugin.in
+++ b/plugins/today-panel/today-panel.plugin
@@ -10,5 +10,5 @@ Builtin = true
 Hidden = true
 License = GPL
 Loader = C
-Embedded = gtd_plugin_today_panel_register_types
+Embedded = today_panel_plugin_register_types
 Depends =


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