changes in dialogues

This commit is contained in:
Dmitriy Yefremov
2018-01-11 17:59:59 +03:00
parent c82763081a
commit 98da7acd96
8 changed files with 96 additions and 19 deletions

View File

@@ -1234,7 +1234,7 @@ dmitry.v.yefremov@gmail.com
<property name="can_focus">True</property>
<property name="text" translatable="yes">/data/picons</property>
<property name="secondary_icon_name">folder-open-symbolic</property>
<property name="secondary_icon_activatable">False</property>
<signal name="icon-press" handler="on_picons_dir_field_icon_press" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>

View File

@@ -60,7 +60,7 @@ class DownloadDialog:
def destroy(self):
self._dialog.destroy()
def on_info_bar_close(self, *args):
def on_info_bar_close(self, bar=None, resp=None):
self._info_bar.set_visible(False)
@run_idle

View File

@@ -450,7 +450,7 @@ class MainAppWindow:
def on_data_open(self, model):
response = show_dialog(DialogType.CHOOSER, self.__main_window, options=self.__options.get(self.__profile))
if response == Gtk.ResponseType.CANCEL:
if response in (Gtk.ResponseType.CANCEL, Gtk.ResponseType.DELETE_EVENT):
return
self.open_data(response)

View File

@@ -272,5 +272,16 @@ def scroll_to(index, view, paths=None):
selection.select_path(index)
# ***************** Others *********************#
def update_entry_data(entry, dialog, options):
""" Updates value in text entry from chooser dialog """
response = show_dialog(dialog_type=DialogType.CHOOSER, transient=dialog, options=options)
if response not in (Gtk.ResponseType.CANCEL, Gtk.ResponseType.DELETE_EVENT):
entry.set_text(response)
return response
return False
if __name__ == "__main__":
pass

View File

@@ -3,6 +3,7 @@
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkDialog" id="picons_dialog">
<property name="width_request">400</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">Picons download tool</property>
<property name="resizable">False</property>
@@ -55,7 +56,7 @@
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkGrid" id="grid1">
<object class="GtkGrid" id="grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="column_spacing">2</property>
@@ -168,6 +169,7 @@
<property name="can_focus">True</property>
<property name="secondary_icon_name">folder-open-symbolic</property>
<property name="primary_icon_activatable">False</property>
<signal name="icon-press" handler="on_picons_dir_open" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
@@ -262,10 +264,21 @@
<property name="can_focus">True</property>
<property name="resize_toplevel">True</property>
<child>
<object class="GtkTextView" id="text_view">
<property name="height_request">100</property>
<object class="GtkScrolledWindow" id="scrolled_window">
<property name="height_request">150</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<property name="min_content_width">240</property>
<child>
<object class="GtkTextView" id="text_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="wrap_mode">word-char</property>
<property name="overwrite">True</property>
</object>
</child>
</object>
</child>
<child type="label">
@@ -284,10 +297,10 @@
</child>
<child>
<object class="GtkInfoBar" id="info_bar">
<property name="visible">True</property>
<property name="app_paintable">True</property>
<property name="can_focus">False</property>
<property name="show_close_button">True</property>
<signal name="response" handler="on_info_bar_close" swapped="no"/>
<child internal-child="action_area">
<object class="GtkButtonBox" id="infobar-action_area1">
<property name="can_focus">False</property>
@@ -317,7 +330,16 @@
<placeholder/>
</child>
<child>
<placeholder/>
<object class="GtkLabel" id="info_bar_message_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Info</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<placeholder/>
@@ -339,6 +361,17 @@
<property name="position">9</property>
</packing>
</child>
<child>
<object class="GtkSeparator" id="separator2">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">10</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>

View File

@@ -1,10 +1,10 @@
import subprocess
import time
from gi.repository import GLib
from app.commons import run_idle, run_task
from . import Gtk, UI_RESOURCES_PATH
from .main_helper import update_entry_data
class PiconsDialog:
@@ -15,7 +15,9 @@ class PiconsDialog:
handlers = {"on_receive": self.on_receive,
"on_cancel": self.on_cancel,
"on_close": self.on_close,
"on_send": self.on_send}
"on_send": self.on_send,
"on_info_bar_close": self.on_info_bar_close,
"on_picons_dir_open": self.on_picons_dir_open}
builder = Gtk.Builder()
builder.add_objects_from_file(UI_RESOURCES_PATH + "picons_dialog.glade", ("picons_dialog", "receive_image"))
@@ -29,6 +31,9 @@ class PiconsDialog:
self._picons_entry = builder.get_object("picons_entry")
self._url_entry = builder.get_object("url_entry")
self._picons_dir_entry = builder.get_object("picons_dir_entry")
self._info_bar = builder.get_object("info_bar")
self._info_bar = builder.get_object("info_bar")
self._message_label = builder.get_object("info_bar_message_label")
self._ip_entry.set_text(options.get("host", ""))
self._picons_entry.set_text(options.get("picons_path", ""))
@@ -38,19 +43,34 @@ class PiconsDialog:
self._dialog.run()
self._dialog.destroy()
@run_idle
def on_receive(self, item):
self._current_process = subprocess.Popen("ls", stdout=subprocess.PIPE)
GLib.io_add_watch(self._current_process.stdout, GLib.IO_IN, self.write_to_buffer)
self.start_download()
def start_download(self):
self._expander.set_expanded(True)
self.show_info_message("Please, wait...", Gtk.MessageType.INFO)
# self._current_process = subprocess.Popen("ls",
# stdout=subprocess.PIPE,
# stderr=subprocess.PIPE,
# universal_newlines=True)
# GLib.io_add_watch(self._current_process.stderr, GLib.IO_IN, self.write_to_buffer)
@run_idle
def write_to_buffer(self, fd, condition):
if condition == GLib.IO_IN:
char = fd.read(1)
buf = self._text_view.get_buffer()
buf.insert_at_cursor(str(char))
buf.insert_at_cursor(char)
self.scroll_to_end(buf)
return True
else:
return False
def scroll_to_end(self, buf):
insert = buf.get_insert()
self._text_view.scroll_to_mark(insert, 0.0, True, 0.0, 1.0)
@run_task
def on_cancel(self, item):
if self._current_process:
@@ -65,6 +85,18 @@ class PiconsDialog:
def on_send(self, item):
pass
def on_info_bar_close(self, bar=None, resp=None):
self._info_bar.set_visible(False)
@run_idle
def show_info_message(self, text, message_type):
self._info_bar.set_visible(True)
self._info_bar.set_message_type(message_type)
self._message_label.set_text(text)
def on_picons_dir_open(self, entry, icon, event_button):
update_entry_data(entry, self._dialog, options={"data_dir_path": self._picons_path})
if __name__ == "__main__":
pass

View File

@@ -1,6 +1,6 @@
from app.properties import write_config, Profile, get_default_settings
from app.ui.dialogs import show_dialog, DialogType
from . import Gtk, UI_RESOURCES_PATH
from .main_helper import update_entry_data
def show_settings_dialog(transient, options):
@@ -10,6 +10,7 @@ def show_settings_dialog(transient, options):
class SettingsDialog:
def __init__(self, transient, options):
handlers = {"on_data_dir_field_icon_press": self.on_data_dir_field_icon_press,
"on_picons_dir_field_icon_press": self.on_picons_dir_field_icon_press,
"on_profile_changed": self.on_profile_changed,
"on_reset": self.on_reset,
"apply_settings": self.apply_settings}
@@ -53,10 +54,10 @@ class SettingsDialog:
return response
def on_data_dir_field_icon_press(self, entry, icon, event_button):
response = show_dialog(dialog_type=DialogType.CHOOSER,
transient=self._dialog, options=self._options.get(self._options.get("profile")))
if response != Gtk.ResponseType.CANCEL:
entry.set_text(response)
update_entry_data(entry, self._dialog, self._options.get(self._options.get("profile")))
def on_picons_dir_field_icon_press(self, entry, icon, event_button):
update_entry_data(entry, self._dialog, self._options.get(self._options.get("profile")))
def on_profile_changed(self, item):
self.set_profile(Profile.ENIGMA_2 if self._enigma_radio_button.get_active() else Profile.NEUTRINO_MP)

View File

@@ -1,5 +1,5 @@
#!/bin/env bash
VER="0.2.0_Pre-alpha"
VER="0.2.1_Pre-alpha"
B_PATH="dist/DemonEditor"
DEB_PATH="$B_PATH/usr/share/demoneditor"