forked from Mirrors/apostrophe
commit
d12f8b6ef7
|
@ -0,0 +1,4 @@
|
|||
@define-color dark_bg #353535;
|
||||
@define-color light_bg #F6F5F4;
|
||||
|
||||
@import url("style.css");
|
|
@ -0,0 +1,4 @@
|
|||
@define-color dark_bg #31373D;
|
||||
@define-color light_bg #EDEDED;
|
||||
|
||||
@import url("style.css");
|
|
@ -474,7 +474,7 @@ code {
|
|||
padding: 0.2em 0.4em;
|
||||
margin: 0;
|
||||
font-size: 85%;
|
||||
background-color: rgba(27,31,35,0.05);
|
||||
background-color: #fafbfc9d;
|
||||
color: #1b1f23;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
@ -508,7 +508,7 @@ pre {
|
|||
overflow: auto;
|
||||
font-size: 85%;
|
||||
line-height: 1.45;
|
||||
background-color: #f6f8fa;
|
||||
background-color: #f6f8faf1;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,6 @@
|
|||
inclusion in templates
|
||||
*/
|
||||
|
||||
@define-color dark_bg #31373D;
|
||||
@define-color light_bg #EDEDED;
|
||||
|
||||
@binding-set window-bindings {
|
||||
bind "<ctl>w" { "close-window" () };
|
||||
bind "<ctl><shift>b" { "toggle-bibtex" () };
|
||||
|
|
|
@ -40,9 +40,10 @@
|
|||
<object class="GtkLabel" id="Dark_mode_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">start</property>
|
||||
<property name="label" translatable="yes">Use dark mode</property>
|
||||
<property name="justify">right</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
|
@ -53,13 +54,28 @@
|
|||
<object class="GtkLabel" id="Spellcheck_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="label" translatable="yes">Autospellcheck</property>
|
||||
<property name="justify">right</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="Gradient_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="label" translatable="yes">Draw scroll gradient</property>
|
||||
<property name="justify">right</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSwitch" id="Dark_mode_switch">
|
||||
<property name="visible">True</property>
|
||||
|
@ -83,6 +99,18 @@
|
|||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSwitch" id="Gradient_switch">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="valign">start</property>
|
||||
<property name="action_name">app.draw_gradient</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="tab_expand">True</property>
|
||||
|
|
|
@ -153,7 +153,7 @@ class UberwriterWindow(Gtk.ApplicationWindow):
|
|||
# Let them disable it
|
||||
|
||||
if self.settings.get_value("gradient-overlay"):
|
||||
self.scrolled_window.connect_after("draw", self.draw_gradient)
|
||||
self.overlay = self.scrolled_window.connect_after("draw", self.draw_gradient)
|
||||
|
||||
self.smooth_scroll_starttime = 0
|
||||
self.smooth_scroll_endtime = 0
|
||||
|
@ -177,13 +177,13 @@ class UberwriterWindow(Gtk.ApplicationWindow):
|
|||
# Init file name with None
|
||||
self.set_filename()
|
||||
|
||||
self.style_provider = Gtk.CssProvider()
|
||||
self.style_provider.load_from_path(helpers.get_media_path('style.css'))
|
||||
# self.style_provider = Gtk.CssProvider()
|
||||
# self.style_provider.load_from_path(helpers.get_media_path('arc_style.css'))
|
||||
|
||||
Gtk.StyleContext.add_provider_for_screen(
|
||||
Gdk.Screen.get_default(), self.style_provider,
|
||||
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
|
||||
)
|
||||
# Gtk.StyleContext.add_provider_for_screen(
|
||||
# Gdk.Screen.get_default(), self.style_provider,
|
||||
# Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
|
||||
# )
|
||||
|
||||
# Markup and Shortcuts for the TextBuffer
|
||||
self.markup_buffer = MarkupBuffer(
|
||||
|
@ -715,8 +715,7 @@ class UberwriterWindow(Gtk.ApplicationWindow):
|
|||
dialog.add_button(_("Close without Saving"), Gtk.ResponseType.NO)
|
||||
dialog.add_button(_("Cancel"), Gtk.ResponseType.CANCEL)
|
||||
dialog.add_button(_("Save now"), Gtk.ResponseType.YES)
|
||||
dialog.set_title(_('Unsaved changes'))
|
||||
dialog.set_default_size(200, 150)
|
||||
# dialog.set_default_size(200, 60)
|
||||
dialog.set_default_response(Gtk.ResponseType.YES)
|
||||
response = dialog.run()
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ from collections import namedtuple
|
|||
from gettext import gettext as _
|
||||
from gi.repository import Gtk
|
||||
from uberwriter_lib.helpers import get_builder
|
||||
from uberwriter_lib.helpers import get_descendant
|
||||
|
||||
from uberwriter_lib.AppWindow import Application as app
|
||||
|
||||
|
@ -45,11 +46,8 @@ class MainHeaderbar: #pylint: disable=too-few-public-methods
|
|||
self.hb_container.show()
|
||||
|
||||
self.btns = buttons(app)
|
||||
self.rec = self.btns.recent
|
||||
pack_buttons(self.hb, self.btns)
|
||||
|
||||
# btns.recent.set_popup(self.generate_recent_files_menu())
|
||||
|
||||
self.hb.show_all()
|
||||
|
||||
|
||||
|
@ -107,26 +105,39 @@ def buttons(app):
|
|||
[NamedTupple] -- tupple of Gtk.Buttons
|
||||
"""
|
||||
|
||||
builder_window_menu = get_builder('Menu')
|
||||
model = builder_window_menu.get_object("Menu")
|
||||
recents_builder = get_builder('Recents')
|
||||
recents = recents_builder.get_object("recent_md_popover")
|
||||
recents_wd = recents_builder.get_object("recent_md_widget")
|
||||
recents_wd.connect('item-activated', app.on_open_recent)
|
||||
|
||||
Button = namedtuple("Button", "new open recent save search menu")
|
||||
Button = namedtuple("Button", "new open_recent save search menu")
|
||||
btn = Button(Gtk.Button().new_with_label(_("New")),
|
||||
Gtk.Button().new_with_label(_("Open")),
|
||||
Gtk.MenuButton().new(),
|
||||
Gtk.Box().new(0, 0),
|
||||
Gtk.Button().new_with_label(_("Save")),
|
||||
Gtk.Button().new_from_icon_name("system-search-symbolic",
|
||||
Gtk.IconSize.BUTTON),
|
||||
Gtk.MenuButton().new())
|
||||
|
||||
btn.recent.set_image(Gtk.Image.new_from_icon_name("go-down-symbolic",
|
||||
Gtk.IconSize.BUTTON))
|
||||
btn.recent.set_tooltip_text(_("Open Recent"))
|
||||
btn.recent.set_popover(recents)
|
||||
builder_window_menu = get_builder('Menu')
|
||||
model = builder_window_menu.get_object("Menu")
|
||||
|
||||
open_button = Gtk.Button().new_with_label(_("Open"))
|
||||
open_button.set_action_name("app.open")
|
||||
|
||||
recents_builder = get_builder('Recents')
|
||||
recents = recents_builder.get_object("recent_md_popover")
|
||||
|
||||
recents_treeview = get_descendant(recents, "recent_view", level=0)
|
||||
recents_treeview.set_activate_on_single_click(True)
|
||||
|
||||
recents_wd = recents_builder.get_object("recent_md_widget")
|
||||
recents_wd.connect('item-activated', app.on_open_recent)
|
||||
|
||||
recents_button = Gtk.MenuButton().new()
|
||||
recents_button.set_image(Gtk.Image.new_from_icon_name("pan-down-symbolic",
|
||||
Gtk.IconSize.BUTTON))
|
||||
recents_button.set_tooltip_text(_("Open Recent"))
|
||||
recents_button.set_popover(recents)
|
||||
|
||||
btn.open_recent.get_style_context().add_class("linked")
|
||||
btn.open_recent.pack_start(open_button, False, False, 0)
|
||||
btn.open_recent.pack_end(recents_button, False, False, 0)
|
||||
|
||||
btn.search.set_tooltip_text(_("Search and replace"))
|
||||
btn.menu.set_tooltip_text(_("Menu"))
|
||||
btn.menu.set_image(Gtk.Image.new_from_icon_name("open-menu-symbolic",
|
||||
|
@ -134,7 +145,6 @@ def buttons(app):
|
|||
btn.menu.set_use_popover(True)
|
||||
btn.menu.set_menu_model(model)
|
||||
btn.new.set_action_name("app.new")
|
||||
btn.open.set_action_name("app.open")
|
||||
btn.save.set_action_name("app.save")
|
||||
btn.search.set_action_name("app.search")
|
||||
|
||||
|
@ -152,8 +162,7 @@ def pack_buttons(headerbar, btn, btn_exit=None):
|
|||
"""
|
||||
|
||||
headerbar.pack_start(btn.new)
|
||||
headerbar.pack_start(btn.open)
|
||||
headerbar.pack_start(btn.recent)
|
||||
headerbar.pack_start(btn.open_recent)
|
||||
if btn_exit:
|
||||
headerbar.pack_end(btn_exit)
|
||||
headerbar.pack_end(btn.menu)
|
||||
|
|
|
@ -16,11 +16,12 @@ from gettext import gettext as _
|
|||
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0') # pylint: disable=wrong-import-position
|
||||
from gi.repository import GLib, Gio, Gtk, GdkPixbuf
|
||||
from gi.repository import GLib, Gio, Gtk, Gdk, GdkPixbuf
|
||||
|
||||
from uberwriter import UberwriterWindow
|
||||
from uberwriter.Settings import Settings
|
||||
from uberwriter_lib import set_up_logging
|
||||
from uberwriter_lib import helpers
|
||||
from uberwriter_lib.PreferencesDialog import PreferencesDialog
|
||||
from . helpers import get_builder, get_media_path
|
||||
|
||||
|
@ -36,9 +37,27 @@ class Application(Gtk.Application):
|
|||
def init(self):
|
||||
"""Init main application"""
|
||||
|
||||
# set theme variant (dark/light)
|
||||
dark = self.settings.get_value("dark-mode")
|
||||
Gtk.Settings.get_default().set_property("gtk-application-prefer-dark-theme", dark)
|
||||
|
||||
# set css for current theme
|
||||
self.style_provider = Gtk.CssProvider()
|
||||
|
||||
themes = {
|
||||
"Arc": "arc_style.css",
|
||||
"Arc-Dark": "arc_style.css",
|
||||
"Arc-Darker": "arc_style.css",
|
||||
}
|
||||
|
||||
theme = Gtk.Settings.get_default().get_property("gtk-theme-name")
|
||||
self.style_provider.load_from_path(helpers.get_media_path(themes.get(theme,"adwaita_style.css")))
|
||||
|
||||
Gtk.StyleContext.add_provider_for_screen(
|
||||
Gdk.Screen.get_default(), self.style_provider,
|
||||
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
|
||||
)
|
||||
|
||||
|
||||
|
||||
def do_startup(self, *args, **kwargs):
|
||||
|
@ -98,6 +117,13 @@ class Application(Gtk.Application):
|
|||
action.connect("change-state", self.on_spellcheck)
|
||||
self.add_action(action)
|
||||
|
||||
set_gradient_overlay = self.settings.get_value("gradient-overlay")
|
||||
action = Gio.SimpleAction.new_stateful("draw_gradient",
|
||||
None,
|
||||
GLib.Variant.new_boolean(set_gradient_overlay))
|
||||
action.connect("change-state", self.on_draw_gradient)
|
||||
self.add_action(action)
|
||||
|
||||
# Menu Actions
|
||||
|
||||
action = Gio.SimpleAction.new("new", None)
|
||||
|
@ -235,6 +261,16 @@ class Application(Gtk.Application):
|
|||
action.set_state(value)
|
||||
self.window.toggle_spellcheck(value)
|
||||
|
||||
def on_draw_gradient(self, action, value):
|
||||
action.set_state(value)
|
||||
self.settings.set_value("gradient-overlay",
|
||||
GLib.Variant("b", value))
|
||||
if value:
|
||||
self.window.overlay = self.window.scrolled_window.connect_after(
|
||||
"draw", self.window.draw_gradient)
|
||||
else:
|
||||
self.window.scrolled_window.disconnect(self.window.overlay)
|
||||
|
||||
def on_new(self, _action, _value):
|
||||
self.window.new_document()
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ import logging
|
|||
import os
|
||||
import shutil
|
||||
|
||||
from gi.repository import Gtk
|
||||
|
||||
from . uberwriterconfig import get_data_file
|
||||
from . Builder import Builder
|
||||
|
||||
|
@ -152,3 +154,32 @@ def exist_executable(command):
|
|||
"""
|
||||
|
||||
return shutil.which(command) is not None
|
||||
|
||||
def get_descendant(widget, child_name, level, doPrint=False):
|
||||
if widget is not None:
|
||||
if doPrint: print("-"*level + str(Gtk.Buildable.get_name(widget)) +
|
||||
" :: " + widget.get_name())
|
||||
else:
|
||||
if doPrint: print("-"*level + "None")
|
||||
return None
|
||||
#/*** If it is what we are looking for ***/
|
||||
if Gtk.Buildable.get_name(widget) == child_name: # not widget.get_name() !
|
||||
return widget
|
||||
#/*** If this widget has one child only search its child ***/
|
||||
if (hasattr(widget, 'get_child') and
|
||||
callable(getattr(widget, 'get_child')) and
|
||||
child_name != ""):
|
||||
child = widget.get_child()
|
||||
if child is not None:
|
||||
return get_descendant(child, child_name, level+1,doPrint)
|
||||
# /*** Ity might have many children, so search them ***/
|
||||
elif (hasattr(widget, 'get_children') and
|
||||
callable(getattr(widget, 'get_children')) and
|
||||
child_name != ""):
|
||||
children = widget.get_children()
|
||||
# /*** For each child ***/
|
||||
found = None
|
||||
for child in children:
|
||||
if child is not None:
|
||||
found = get_descendant(child, child_name, level+1, doPrint) # //search the child
|
||||
if found: return found
|
||||
|
|
Loading…
Reference in New Issue