Verified Commit 23a6a107 authored by tallero's avatar tallero

merge preferences

parent 8b863293
......@@ -51,6 +51,10 @@ class Daty(Application):
Application.do_startup(self)
# Set app menu
<<<<<<< HEAD
=======
>>>>>>> db00593... preferences window: initial commit
action = SimpleAction.new("preferences", None)
action.connect("activate", self.on_preferences)
self.set_accels_for_action("app.preferences", ["<Control>,"])
......@@ -134,6 +138,11 @@ class Daty(Application):
about_dialog = AboutDaty(transient_for=self.window, modal=True)
about_dialog.present()
def on_preferences(self, action, param):
from .preferences import Preferences
pref = Preferences()
pref.show()
def on_quit(self, action, param):
self.quit()
......
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Daty
#
# ----------------------------------------------------------------------
# Copyright © 2018 Pellegrino Prevete
#
# All rights reserved
# ----------------------------------------------------------------------
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
from gi import require_version
require_version('Gdk', '3.0')
require_version('Gtk', '3.0')
require_version('Handy', '0.0')
from gi.repository.Gdk import CURRENT_TIME
from gi.repository.GLib import OptionArg, OptionFlags
from gi.repository.Gio import ApplicationFlags, SimpleAction
from gi.repository.Gtk import Application, Builder, show_uri
from platform import system
from sys import argv
from .preferences import Preferences
name = "ml.prevete.Daty"
class Daty(Application):
def __init__(self, *args, new_session=True, entities=[], **kwargs):
super().__init__(*args, application_id=name,
flags=ApplicationFlags.HANDLES_COMMAND_LINE,
**kwargs)
self.entities=entities
self.window = None
self.add_main_option("test", ord("t"), OptionFlags.NONE,
OptionArg.NONE, "Command line test", None)
def do_startup(self):
Application.do_startup(self)
# Set app menu
<<<<<<< HEAD
=======
>>>>>>> 8b863293de75f0c6dde0d6419915689c9f756e8c
action = SimpleAction.new("preferences", None)
action.connect("activate", self.on_preferences)
self.set_accels_for_action("app.preferences", ["<Control>,"])
self.add_action(action)
action = SimpleAction.new("shortcuts", None)
action.connect("activate", self.on_shortcuts)
self.set_accels_for_action("app.shortcuts", ["<Control>F1"])
self.add_action(action)
# Set app menu
action = SimpleAction.new("help", None)
action.connect("activate", self.on_help)
self.set_accels_for_action("app.help", ["F1"])
self.add_action(action)
action = SimpleAction.new("about", None)
action.connect("activate", self.on_about)
self.add_action(action)
action = SimpleAction.new("quit", None)
action.connect("activate", self.on_quit)
self.set_accels_for_action("app.quit", ["<Control>q"])
self.add_action(action)
# Set entity menu
action = SimpleAction.new("entity_close", None)
action.connect("activate", self.on_entity_close)
self.set_accels_for_action("app.entity_close", ["<Control>w"])
self.add_action(action)
#builder = Builder()
#builder.add_from_resource("/ml/prevete/Daty/gtk/menus.ui")
#self.set_app_menu(builder.get_object("app-menu"))
def do_activate(self, new_session=True, **kwargs):
if not self.window:
from .editor import Editor
self.window = Editor(application=self, title="Daty", quit_cb=self.quit, entities=self.entities)
#self.window.present()
def do_command_line(self, command_line):
options = command_line.get_options_dict()
# convert GVariantDict -> GVariant -> dict
options = options.end().unpack()
if "test" in options:
print("Test argument received: %s" % options["test"])
self.activate()
return 0
def on_entity_close(self, action, param):
row = self.window.sidebar_list.get_selected_row()
sidebar_entity = row.child
self.window.entity_close_clicked_cb(row, sidebar_entity)
def on_help(self, action, param):
if system() == 'Linux':
show_uri (None, "help:daty", CURRENT_TIME)
if system() == 'Windows':
from webbrowser import open
open('http://daty.prevete.ml')
def on_preferences(self, action, param):
#builder = Builder()
#builder.add_from_resource('/ml/prevete/Daty/gtk/preferences.ui')
#window = builder.get_object("Preferences")
#window.show_all()
preferences = Preferences()
preferences.show_all()
def on_shortcuts(self, action, param):
builder = Builder()
builder.add_from_resource('/ml/prevete/Daty/gtk/shortcutswindow.ui')
window = builder.get_object("shortcuts")
window.show_all()
def on_about(self, action, param):
from .aboutdaty import AboutDaty
about_dialog = AboutDaty(transient_for=self.window, modal=True)
about_dialog.present()
def on_preferences(self, action, param):
from .preferences import Preferences
pref = Preferences()
pref.show()
def on_quit(self, action, param):
self.quit()
if __name__ == "__main__":
app = Daty()
app.run(argv)
......@@ -94,7 +94,7 @@ class Config:
bindtextdomain(self.appname, self.exec_path)
textdomain(self.appname)
self.lang = translation(self.appname, self.exec_path,
languages=langs, fallback=True)
languages=langs, fallback=True)
def create_pywikibot_config(self, user, bot_user, bot_password):
"""Create pywikibot configuration files
......
......@@ -487,7 +487,7 @@ class Editor(ApplicationWindow):
# Build entity
if not entity['Label']:
entity['Label'] = self.wikidata.get_label(entity['Data'])
entity['Label'] = self.wikidata.get_label(entity['Data'], language='en')
if not entity['Description']:
entity['Description'] = self.wikidata.get_description(entity['Data'])
......
......@@ -64,7 +64,7 @@
<property name="can_focus">False</property>
<property name="visible_child">single_column</property>
<property name="mode_transition_type">slide</property>
<property name="child_transition_type">over</property>
<property name="child_transition_type">slide</property>
<property name="interpolate_size">True</property>
<signal name="notify::folded" handler="on_content_box_folded_changed" after="yes" swapped="no"/>
<child>
......@@ -566,7 +566,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
<child>
......@@ -580,7 +580,11 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<<<<<<< HEAD
<property name="position">2</property>
=======
<property name="position">3</property>
>>>>>>> db00593... preferences window: initial commit
</packing>
</child>
<child>
......@@ -594,7 +598,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
<property name="position">4</property>
</packing>
</child>
</object>
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -15,6 +15,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="hhomogeneous_folded">False</property>
<property name="visible_child_name">sidebar</property>
<property name="mode_transition_type">slide</property>
<property name="child_transition_type">slide</property>
......@@ -22,9 +23,11 @@
<child>
<object class="GtkGrid" id="sidebar">
<property name="name">sidebar</property>
<property name="width_request">150</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">True</property>
<property name="halign">start</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow" id="sidebar_scrolled_window">
......@@ -37,6 +40,7 @@
<object class="GtkViewport" id="sidebar_viewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkStackSidebar">
<property name="visible">True</property>
......@@ -69,15 +73,6 @@
<property name="name">sidebar</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
<style>
<class name="sidebar"/>
</style>
</object>
</child>
<child>
<object class="GtkStack" id="content_stack">
<property name="name">content_stack</property>
......@@ -94,13 +89,17 @@
<property name="margin_top">18</property>
<property name="margin_bottom">18</property>
<property name="orientation">vertical</property>
<<<<<<< HEAD
<property name="spacing">18</property>
=======
<property name="spacing">12</property>
>>>>>>> db00593... preferences window: initial commit
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">User</property>
<property name="label" translatable="yes">Credentials</property>
<attributes>
<attribute name="font-desc" value="Cantarell Bold 10"/>
</attributes>
......@@ -112,9 +111,10 @@
</packing>
</child>
<child>
<object class="GtkGrid">
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can_focus">False</property>
<<<<<<< HEAD
<property name="halign">start</property>
<property name="valign">center</property>
<property name="margin_bottom">18</property>
......@@ -140,83 +140,20 @@
<property name="top_attach">0</property>
</packing>
</child>
=======
<property name="hexpand">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">out</property>
>>>>>>> db00593... preferences window: initial commit
<child>
<object class="GtkLabel" id="bot_username_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_markup" translatable="yes">_("Wikimedia username description")</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Bot username</property>
<property name="justify">right</property>
<attributes>
<attribute name="font-desc" value="Cantarell 10"/>
</attributes>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="bot_password_label">
<object class="GtkListBox" id="credentials">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_markup" translatable="yes">_("Wikimedia username description")</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Bot password</property>
<property name="justify">right</property>
<attributes>
<attribute name="font-desc" value="Cantarell 10"/>
</attributes>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="username">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">start</property>
<property name="placeholder_text" translatable="yes">es. Ogoorcs</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="bot_username">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">start</property>
<property name="placeholder_text" translatable="yes">es. Daty</property>
<property name="selection_mode">none</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="bot_password">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">start</property>
<property name="visibility">False</property>
<property name="placeholder_text" translatable="yes">es. D4t41Sc00L</property>
<property name="input_purpose">password</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
<child type="label_item">
<placeholder/>
</child>
</object>
<packing>
......@@ -225,22 +162,95 @@
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="name">general</property>
<property name="title" translatable="yes">General</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkListBox">
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">18</property>
<property name="margin_right">18</property>
<property name="margin_start">18</property>
<property name="margin_end">18</property>
<property name="margin_top">18</property>
<property name="margin_bottom">18</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Entities</property>
<attributes>
<attribute name="font-desc" value="Cantarell Bold 10"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">out</property>
<child>
<object class="GtkListBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
</object>
</child>
<child type="label_item">
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Add language</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="name">credentials</property>
<property name="title" translatable="yes">Credentials</property>
<property name="name">language</property>
<property name="title" translatable="yes">Language</property>
<property name="position">1</property>
</packing>
</child>
<child>
......@@ -295,6 +305,26 @@
<property name="name">content_stack</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
<child type="titlebar">
<object class="GtkHeaderBar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">Preferences</property>
<property name="show_close_button">True</property>
<child>
<object class="GtkButton" id="back">
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Close this window and come back to the editor</property>
<property name="image">back-icon</property>
<property name="always_show_image">True</property>
</object>
</child>
</object>
</child>
<child type="titlebar">
......@@ -315,4 +345,14 @@
</object>
</child>
</template>
<object class="GtkSizeGroup" id="end_pane_size_group">
<widgets>
<widget name="content_stack"/>
</widgets>
</object>
<object class="GtkSizeGroup" id="start_pane_size_group">
<widgets>
<widget name="sidebar"/>
</widgets>
</object>
</interface>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<template class="Preferences" parent="GtkWindow">
<property name="can_focus">False</property>
<<<<<<< HEAD
<property name="default_width">600</property>
<property name="default_height">400</property>
=======
>>>>>>> 8b863293de75f0c6dde0d6419915689c9f756e8c
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child>
<object class="GtkGrid" id="sidebar">
<property name="name">sidebar</property>
<property name="width_request">150</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">True</property>
<property name="halign">start</property>
<property name="hexpand">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow" id="sidebar_scrolled_window">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="hscrollbar_policy">never</property>
<child>
<object class="GtkViewport" id="sidebar_viewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkStackSidebar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stack">content_stack</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkSearchEntry">
<property name="can_focus">True</property>
<property name="primary_icon_name">edit-find-symbolic</property>
<property name="primary_icon_activatable">False</property>
<property name="primary_icon_sensitive">False</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkStack" id="content_stack">
<property name="name">content_stack</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="transition_type">slide-left</property>
<property name="interpolate_size">True</property>
<child>
<object class="GtkBox">