[gnome-news/wip/gbsneto/improvements: 1/2] project: reorganize resources
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-news/wip/gbsneto/improvements: 1/2] project: reorganize resources
- Date: Thu, 3 Mar 2016 05:37:31 +0000 (UTC)
commit f581b0afc3fb76506d8aaa6aa634722c9e2f4cd3
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Mar 3 01:59:11 2016 -0300
project: reorganize resources
Currently, the resources are spread all around
data/ folder. This, per se, is not a problem, but
we can save some code by delegating to Gtk+ some
things like loading the app menu.
Fix that by better organizing the data/ folder, and
updating the application to reflect that.
data/gnome-news.gresource.xml | 8 ++++----
data/{Menu.ui => gtk/menus.ui} | 0
data/{application.css => theme/Adwaita.css} | 0
data/{aboutReaderContent.css => theme/reader.css} | 0
data/{HeaderBar.ui => ui/headerbar.ui} | 0
gnomenews/application.py | 19 ++++++++-----------
gnomenews/toolbar.py | 2 +-
gnomenews/view.py | 2 +-
8 files changed, 14 insertions(+), 17 deletions(-)
---
diff --git a/data/gnome-news.gresource.xml b/data/gnome-news.gresource.xml
index 3c700cf..277e4c7 100644
--- a/data/gnome-news.gresource.xml
+++ b/data/gnome-news.gresource.xml
@@ -4,9 +4,9 @@
<file compressed="true" alias="VERSION">../VERSION</file>
<file compressed="true" alias="ARTISTS">../ARTISTS</file>
<file compressed="true" alias="AUTHORS">../AUTHORS</file>
- <file compressed="true" preprocess="xml-stripblanks">Menu.ui</file>
- <file compressed="true" preprocess="xml-stripblanks">HeaderBar.ui</file>
- <file compressed="true">application.css</file>
- <file compressed="true">aboutReaderContent.css</file>
+ <file compressed="true" preprocess="xml-stripblanks">gtk/menus.ui</file>
+ <file compressed="true" preprocess="xml-stripblanks">ui/headerbar.ui</file>
+ <file compressed="true">theme/Adwaita.css</file>
+ <file compressed="true">theme/reader.css</file>
</gresource>
</gresources>
diff --git a/data/Menu.ui b/data/gtk/menus.ui
similarity index 100%
rename from data/Menu.ui
rename to data/gtk/menus.ui
diff --git a/data/application.css b/data/theme/Adwaita.css
similarity index 100%
rename from data/application.css
rename to data/theme/Adwaita.css
diff --git a/data/aboutReaderContent.css b/data/theme/reader.css
similarity index 100%
rename from data/aboutReaderContent.css
rename to data/theme/reader.css
diff --git a/data/HeaderBar.ui b/data/ui/headerbar.ui
similarity index 100%
rename from data/HeaderBar.ui
rename to data/ui/headerbar.ui
diff --git a/gnomenews/application.py b/gnomenews/application.py
index ee5165b..cd4e00f 100644
--- a/gnomenews/application.py
+++ b/gnomenews/application.py
@@ -37,7 +37,7 @@ class Application(Gtk.Application):
GLib.set_prgname('gnome-news')
self.settings = Gio.Settings.new('org.gnome.News')
- cssProviderFile = Gio.File.new_for_uri('resource:///org/gnome/News/application.css')
+ cssProviderFile = Gio.File.new_for_uri('resource:///org/gnome/News/theme/Adwaita.css')
cssProvider = Gtk.CssProvider()
cssProvider.load_from_file(cssProviderFile)
screen = Gdk.Screen.get_default()
@@ -61,6 +61,13 @@ class Application(Gtk.Application):
@log
def do_startup(self):
+ actions = ["about", "quit"]
+
+ for action_name in actions:
+ action = Gio.SimpleAction.new(action_name, None)
+ action.connect("activate", getattr(self, action_name))
+ self.add_action(action)
+
Gtk.Application.do_startup(self)
@log
@@ -79,16 +86,6 @@ class Application(Gtk.Application):
self._about_dialog.present()
def do_activate(self):
- if not self.get_app_menu():
- builder = Gtk.Builder()
- builder.add_from_resource("/org/gnome/News/Menu.ui")
- menu = builder.get_object("app-menu")
- self.set_app_menu(menu)
- for action_name in ["about", "quit"]:
- action = Gio.SimpleAction.new(action_name, None)
- action.connect("activate", getattr(self, action_name))
- self.add_action(action)
-
if not self._window:
self._window = Window(self)
diff --git a/gnomenews/toolbar.py b/gnomenews/toolbar.py
index 5bb14ae..32eb4c3 100644
--- a/gnomenews/toolbar.py
+++ b/gnomenews/toolbar.py
@@ -41,7 +41,7 @@ class Toolbar(GObject.GObject):
margin_top=2, margin_bottom=2, can_focus=False, halign="center")
self._ui = Gtk.Builder()
- self._ui.add_from_resource('/org/gnome/News/HeaderBar.ui')
+ self._ui.add_from_resource('/org/gnome/News/ui/headerbar.ui')
self.header_bar = self._ui.get_object('header-bar')
self.header_bar.set_show_close_button(True)
self.header_bar.set_custom_title(self._stack_switcher)
diff --git a/gnomenews/view.py b/gnomenews/view.py
index 1c7e3d8..21b5da0 100644
--- a/gnomenews/view.py
+++ b/gnomenews/view.py
@@ -173,7 +173,7 @@ class FeedView(Gtk.Stack):
def __init__(self, tracker, post):
Gtk.Stack.__init__(self,
transition_type=Gtk.StackTransitionType.CROSSFADE)
- stylesheet = Gio.File.new_for_uri('resource:///org/gnome/News/aboutReaderContent.css')
+ stylesheet = Gio.File.new_for_uri('resource:///org/gnome/News/theme/reader.css')
webview = WebKit2.WebView()
if post.content:
html = """
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]