[gtranslator/gtk4] Clean gtr-application.c



commit 5363decca29dff82b7d2a90a2aa3324d8d6656a8
Author: Daniel GarcĂ­a Moreno <dani danigm net>
Date:   Mon Oct 3 18:14:49 2022 +0200

    Clean gtr-application.c

 src/gtr-application.c | 102 +++++++++++---------------------------------------
 src/gtr-application.h |  40 +++++---------------
 src/gtr-dirs.c        |   9 -----
 src/gtr-dirs.h        |   2 -
 src/styles.css        |  53 --------------------------
 5 files changed, 31 insertions(+), 175 deletions(-)
---
diff --git a/src/gtr-application.c b/src/gtr-application.c
index ef1861cc..72708d75 100644
--- a/src/gtr-application.c
+++ b/src/gtr-application.c
@@ -1,23 +1,25 @@
 /*
  * Copyright (C) 2007  Ignacio Casal Quinteiro <icq gnome org>
- *               2008  Igalia 
+ *               2008  Igalia
+ *               2022  Daniel Garcia Moreno <danigm gnome org>
  *
  * 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
  * the Free Software Foundation, either version 3 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  * Authors:
  *   Ignacio Casal Quinteiro <icq gnome org>
  *   Pablo Sanxiao <psanxiao gmail com>
+ *   Daniel Garcia Moreno <danigm gnome org>
  */
 
 #ifdef HAVE_CONFIG_H
@@ -41,7 +43,6 @@
 #include <gio/gio.h>
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
-//#include <libhandy-1/handy.h>
 #include <adwaita.h>
 
 #ifdef ENABLE_INTROSPECTION
@@ -49,10 +50,19 @@
 #endif
 
 #ifdef GDK_WINDOWING_X11
-//#include <gdk/gdkx.h>
 #include <gdk/gdk.h>
 #endif
 
+struct _GtrApplication
+{
+  AdwApplication base_instance;
+};
+
+struct _GtrApplicationClass
+{
+  AdwApplicationClass parent_class;
+};
+
 typedef struct
 {
   GSettings *settings;
@@ -92,36 +102,6 @@ ensure_user_config_dir (void)
   return ret;
 }
 
-static void
-load_accels (void)
-{
-  gchar *filename;
-
-  filename = g_build_filename (gtr_dirs_get_user_config_dir (),
-                               "accels",
-                               NULL);
-  if (filename != NULL)
-    {
-      //gtk_accel_map_load (filename);
-      g_free (filename);
-    }
-}
-
-static void
-save_accels (void)
-{
-  gchar *filename;
-
-  filename = g_build_filename (gtr_dirs_get_user_config_dir (),
-                               "accels",
-                               NULL);
-  if (filename != NULL)
-    {
-      //gtk_accel_map_save (filename);
-      g_free (filename);
-    }
-}
-
 static gboolean
 on_window_delete_event_cb (GtrWindow * window,
                            GdkEvent * event, GtrApplication * app)
@@ -138,19 +118,6 @@ set_active_window (GtrApplication *app,
   priv->active_window = window;
 }
 
-/*static gboolean
-window_focus_in_event (GtrWindow      *window,
-                      GdkFocusEvent  *event,
-                      GtrApplication *app)
-{
-  // updates active_view and active_child when a new toplevel receives focus //
-  g_return_val_if_fail (GTR_IS_WINDOW (window), FALSE);
-
-  set_active_window (app, window);
-
-  return FALSE;
-}*/
-
 static void
 on_window_destroy_cb (GtrWindow *window, GtrApplication *app)
 {
@@ -645,7 +612,7 @@ static void
 set_kb (GApplication *app, gchar *action, gchar *accel)
 {
   const gchar *keys[] = {accel, NULL};
-  gtk_application_set_accels_for_action(GTK_APPLICATION (app), action, keys);
+  gtk_application_set_accels_for_action (GTK_APPLICATION (app), action, keys);
 }
 
 static void
@@ -658,28 +625,16 @@ gtr_application_startup (GApplication *application)
   g_set_application_name (_("Translation Editor"));
   gtk_window_set_default_icon_name (PACKAGE_APPID);
 
-  load_accels ();
-
-  //CLEANUP: As we are now subclassing from AdwApplication thsese all are not needed
-  //adw_init();
-
   /* Custom css */
-  //priv->provider = gtk_css_provider_new ();
-  //gtk_css_provider_load_from_resource (priv->provider, "/org/gnome/translator/styles.css");
+  priv->provider = gtk_css_provider_new ();
+  gtk_css_provider_load_from_resource (priv->provider, "/org/gnome/translator/styles.css");
 
-  //gtk_style_context_add_provider_for_display (gdk_display_get_default (),
-                                             //GTK_STYLE_PROVIDER (priv->provider), 600);
+  gtk_style_context_add_provider_for_display (gdk_display_get_default (),
+                                              GTK_STYLE_PROVIDER (priv->provider), 600);
 
-  /* TODO Remove in GTK 4 port */
-  /*hdy_style_manager_set_color_scheme (hdy_style_manager_get_default (),
-                                      HDY_COLOR_SCHEME_PREFER_LIGHT);*/
   adw_style_manager_set_color_scheme (adw_style_manager_get_default (),
                                       ADW_COLOR_SCHEME_PREFER_LIGHT);
 
-  /* We set the default icon dir */
-  /*gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
-                                     gtr_dirs_get_gtr_pixmaps_dir ());*/
-
   g_action_map_add_action_entries (G_ACTION_MAP (application), app_entries,
                                    G_N_ELEMENTS (app_entries), application);
 
@@ -787,8 +742,6 @@ static void
 gtr_application_shutdown (GApplication *application)
 {
   ensure_user_config_dir ();
-  save_accels ();
-
   G_APPLICATION_CLASS (gtr_application_parent_class)->shutdown (application);
 }
 
@@ -821,14 +774,13 @@ gtr_application_new ()
  * @app: a #GtrApplication
  *
  * Creates a new #GtrWindow and shows it.
- * 
+ *
  * Returns: (transfer none):  the #GtrWindow to be opened
  */
 GtrWindow *
 gtr_application_create_window (GtrApplication *app)
 {
   GtrWindow *window;
-  //GdkWindowState state;
   GdkToplevelState state;
   gint w, h;
   GtrApplicationPrivate *priv = gtr_application_get_instance_private (app);
@@ -853,16 +805,6 @@ gtr_application_create_window (GtrApplication *app)
   else
     gtk_window_unmaximize (GTK_WINDOW (window));
 
-  if ((state & GDK_TOPLEVEL_STATE_STICKY ) != 0);
-    ///gtk_window_stick (GTK_WINDOW (window));
-  else;
-    //gtk_window_unstick (GTK_WINDOW (window));
-
-  /* both of these signals are not valid in gtk4
-  g_signal_connect (window, "focus_in_event",
-                    G_CALLBACK (window_focus_in_event), app);
-  */
-
   g_signal_connect (window, "close-request",
                     G_CALLBACK (on_window_delete_event_cb), app);
 
@@ -904,7 +846,7 @@ gtr_application_get_views (GtrApplication * app,
 /**
  * gtr_application_get_active_window:
  * @app: a #GtrApplication
- * 
+ *
  * Return value: (transfer none): the active #GtrWindow
  **/
 GtrWindow *
diff --git a/src/gtr-application.h b/src/gtr-application.h
index 1322fce7..b3d3e593 100644
--- a/src/gtr-application.h
+++ b/src/gtr-application.h
@@ -1,27 +1,28 @@
 /*
  * Copyright (C) 2007  Ignacio Casal Quinteiro <nacho resa gmail com>
- *               2008  Igalia 
+ *               2008  Igalia
+ *               2022  Daniel Garcia Moreno <danigm gnome org>
  *
  * 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
  * the Free Software Foundation, either version 3 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  * Authors:
  *   Ignacio Casal Quinteiro <nacho resa gmail com>
  *   Pablo Sanxiao <psanxiao gmail com>
+ *   Daniel Garcia Moreno <danigm gnome org>
  */
 
-#ifndef __APPLICATION_H__
-#define __APPLICATION_H__
+#pragma once
 
 #include <glib.h>
 #include <glib-object.h>
@@ -31,47 +32,24 @@
 
 G_BEGIN_DECLS
 
-#define GTR_TYPE_APPLICATION           (gtr_application_get_type ())
-#define GTR_APPLICATION(o)             (G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_APPLICATION, 
GtrApplication))
-#define GTR_APPLICATION_CLASS(k)       (G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_APPLICATION, 
GtrApplicationClass))
-#define GTR_IS_APPLICATION(o)          (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_APPLICATION))
-#define GTR_IS_APPLICATION_CLASS(k)    (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_APPLICATION))
-#define GTR_APPLICATION_GET_CLASS(o)   (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_APPLIAPPLICATION, 
GtrApplicationClass))
-
-#define GTR_APP                         (GTR_APPLICATION (g_application_get_default()))
+#define GTR_TYPE_APPLICATION (gtr_application_get_type ())
 
-typedef struct _GtrApplication        GtrApplication;
-typedef struct _GtrApplicationClass   GtrApplicationClass;
+G_DECLARE_FINAL_TYPE (GtrApplication, gtr_application, GTR, APPLICATION, AdwApplication)
 
-struct _GtrApplication
-{
-  AdwApplication base_instance;
-};
-
-struct _GtrApplicationClass
-{
-  AdwApplicationClass parent_class;
-};
+#define GTR_APP                         (GTR_APPLICATION (g_application_get_default ()))
 
 GType             gtr_application_get_type               (void)G_GNUC_CONST;
-
 GtrApplication  * gtr_application_new                    (void);
-
 GList *           gtr_application_get_views              (GtrApplication *app,
                                                           gboolean        original,
                                                           gboolean        translated);
-
 GtrWindow        *gtr_application_create_window          (GtrApplication *app);
-
 GtrWindow        *gtr_application_get_active_window      (GtrApplication *app);
 
 /* Non exported funcs */
 const gchar     *_gtr_application_get_last_dir           (GtrApplication *app);
-
 void             _gtr_application_set_last_dir           (GtrApplication *app,
                                                           const gchar    *last_dir);
-
 GSettings       *_gtr_application_get_settings           (GtrApplication *app);
 
 G_END_DECLS
-#endif /* __APPLICATION_H__ */
diff --git a/src/gtr-dirs.c b/src/gtr-dirs.c
index 8ce4e8c7..d71b4929 100644
--- a/src/gtr-dirs.c
+++ b/src/gtr-dirs.c
@@ -38,7 +38,6 @@ static gchar *gtr_locale_dir = NULL;
 static gchar *gtr_lib_dir = NULL;
 static gchar *gtr_plugins_dir = NULL;
 static gchar *gtr_plugins_data_dir = NULL;
-static gchar *gtr_pixmaps_dir = NULL;
 static gchar *gtr_sourceview_dir = NULL;
 
 void
@@ -91,7 +90,6 @@ gtr_dirs_init ()
   gtr_plugins_dir = g_build_filename (gtr_lib_dir, "plugins", NULL);
   gtr_plugins_data_dir = g_build_filename (gtr_data_dir, "plugins", NULL);
 
-  gtr_pixmaps_dir = g_build_filename (gtr_data_dir, "pixmaps", NULL);
   gtr_sourceview_dir = g_build_filename (gtr_data_dir, "sourceview", NULL);
 }
 
@@ -107,7 +105,6 @@ gtr_dirs_shutdown ()
   g_free (gtr_lib_dir);
   g_free (gtr_plugins_dir);
   g_free (gtr_plugins_data_dir);
-  g_free (gtr_pixmaps_dir);
   g_free (gtr_sourceview_dir);
 }
 
@@ -165,12 +162,6 @@ gtr_dirs_get_gtr_plugins_data_dir (void)
   return gtr_plugins_data_dir;
 }
 
-const gchar *
-gtr_dirs_get_gtr_pixmaps_dir (void)
-{
-  return gtr_pixmaps_dir;
-}
-
 const gchar *
 gtr_dirs_get_gtr_sourceview_dir (void)
 {
diff --git a/src/gtr-dirs.h b/src/gtr-dirs.h
index a49079b3..ecf92526 100644
--- a/src/gtr-dirs.h
+++ b/src/gtr-dirs.h
@@ -50,8 +50,6 @@ const gchar *gtr_dirs_get_gtr_plugins_dir (void);
 
 const gchar *gtr_dirs_get_gtr_plugins_data_dir (void);
 
-const gchar *gtr_dirs_get_gtr_pixmaps_dir (void);
-
 const gchar *gtr_dirs_get_gtr_sourceview_dir (void);
 
 gchar *gtr_dirs_get_ui_file (const gchar * file);
diff --git a/src/styles.css b/src/styles.css
index a1c6c648..8a0a0d4d 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -27,56 +27,3 @@
 #info_label.info {
   color: @theme_fg_color;
 }
-
-/* This file contains styling for various search widgets */
-.search-frame > box {
-  background-image: linear-gradient(shade(@theme_bg_color,1.05), @theme_bg_color);
-  padding: 6px;
-  border-style: solid;
-  border-color: @borders;
-  border-left-width: 1px;
-  border-right-width: 1px;
-  border-bottom-width: 1px;
-  border-bottom-left-radius: 5px;
-  border-bottom-right-radius: 5px;
-  box-shadow: 0px 0 3px @borders;
-  margin: 0 10px 20px 10px;
-}
-frame.search-frame border {
-  border: none;
-}
-.search-frame > box > grid:first-child > button.close:disabled,
-.search-frame > box > grid:first-child > button.close {
-  background: none;
-  border: none;
-  box-shadow: none;
-  padding-left: 4px;
-  padding-right: 4px;
-}
-.search-frame > box > grid:first-child > button.close image {
-  color: @theme_fg_color;
-  opacity: 0.3;
-  margin: 2px;
-  border: 1px solid transparent;
-  border-radius: 3px;
-}
-.search-frame > box > grid:first-child > button.close:hover image {
-  opacity: 0.75;
-  transition-duration: 250ms;
-  border: 1px solid @borders;
-}
-.search-frame > box > grid:first-child > button.close:active image {
-  opacity: 0.8;
-  background-image: linear-gradient(shade(@theme_bg_color, 0.9), @theme_bg_color);
-}
-.search-frame > box > grid:first-child > button.close:backdrop image {
-  opacity: 0.1;
-}
-.search-occurrences-tag {
-    color: shade(@theme_unfocused_fg_color, 0.8);
-    border: 0px;
-    margin: 2px;
-    padding: 2px;
-}
-
-


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