Discard preferences dialog

This commit is contained in:
Sean Davis 2013-07-14 08:41:31 -04:00
parent 4300ba837b
commit 322b4858dc
7 changed files with 0 additions and 278 deletions

View File

@ -1,112 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<!-- interface-requires preferences_mugshot_dialog 1.0 -->
<object class="PreferencesMugshotDialog" id="preferences_mugshot_dialog">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Mugshot Preferences</property>
<property name="icon">../media/mugshot.svg</property>
<property name="type_hint">normal</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="btn_help">
<property name="label">gtk-help</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
<property name="secondary">True</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btn_close">
<property name="label">gtk-close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkGrid" id="table1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="row_spacing">6</property>
<property name="column_spacing">6</property>
<property name="n_rows">1</property>
<property name="n_columns">2</property>
<child>
<object class="GtkEntry" id="example_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="invisible_char">•</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="example_entry_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Example entry:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">example_entry</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-11">btn_help</action-widget>
<action-widget response="-7">btn_close</action-widget>
</action-widgets>
</object>
</interface>

View File

@ -1,9 +0,0 @@
<glade-catalog name="preferences_mugshot_dialog" domain="glade-3"
depends="gtk+" version="1.0">
<glade-widget-classes>
<glade-widget-class title="Mugshot Preferences Dialog" name="PreferencesMugshotDialog"
generic-name="PreferenceMugshotDialog" parent="GtkDialog"
icon-name="widget-gtk-dialog"/>
</glade-widget-classes>
</glade-catalog>

View File

@ -1,18 +0,0 @@
<page xmlns="http://projectmallard.org/1.0/"
type="topic"
id="preferences">
<info>
<link type="guide" xref="index#contents"/>
<credit type="author">
<name>Your Name</name>
<email>Your E-mail</email>
<years>2010</years>
</credit>
<desc>Optional short description of Preferences for contents page</desc>
</info>
<title>Preferences</title>
<p>This is the preferences page.</p>
</page>

View File

@ -28,7 +28,6 @@ logger = logging.getLogger('mugshot')
from mugshot_lib import Window from mugshot_lib import Window
from mugshot.AboutMugshotDialog import AboutMugshotDialog from mugshot.AboutMugshotDialog import AboutMugshotDialog
from mugshot.PreferencesMugshotDialog import PreferencesMugshotDialog
username = os.getenv('USER') username = os.getenv('USER')
if not username: if not username:
@ -77,7 +76,6 @@ class MugshotWindow(Window):
super(MugshotWindow, self).finish_initializing(builder) super(MugshotWindow, self).finish_initializing(builder)
self.AboutDialog = AboutMugshotDialog self.AboutDialog = AboutMugshotDialog
self.PreferencesDialog = PreferencesMugshotDialog
# User Image widgets # User Image widgets
self.image_button = builder.get_object('image_button') self.image_button = builder.get_object('image_button')

View File

@ -1,44 +0,0 @@
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
### BEGIN LICENSE
# Copyright (C) 2013 Sean Davis <smd.seandavis@gmail.com>
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, 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/>.
### END LICENSE
# This is your preferences dialog.
#
# Define your preferences in
# data/glib-2.0/schemas/net.launchpad.mugshot.gschema.xml
# See http://developer.gnome.org/gio/stable/GSettings.html for more info.
from gi.repository import Gio # pylint: disable=E0611
from locale import gettext as _
import logging
logger = logging.getLogger('mugshot')
from mugshot_lib.PreferencesDialog import PreferencesDialog
class PreferencesMugshotDialog(PreferencesDialog):
__gtype_name__ = "PreferencesMugshotDialog"
def finish_initializing(self, builder): # pylint: disable=E1002
"""Set up the preferences dialog"""
super(PreferencesMugshotDialog, self).finish_initializing(builder)
# Bind each preference widget to gsettings
settings = Gio.Settings("net.launchpad.mugshot")
widget = self.builder.get_object('example_entry')
settings.bind("example", widget, "text", Gio.SettingsBindFlags.DEFAULT)
# Code for other initialization actions should be added here.

View File

@ -1,64 +0,0 @@
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
### BEGIN LICENSE
# Copyright (C) 2013 Sean Davis <smd.seandavis@gmail.com>
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, 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/>.
### END LICENSE
### DO NOT EDIT THIS FILE ###
"""this dialog adjusts values in gsettings
"""
from gi.repository import Gtk # pylint: disable=E0611
import logging
logger = logging.getLogger('mugshot_lib')
from . helpers import get_builder, show_uri, get_help_uri
class PreferencesDialog(Gtk.Dialog):
__gtype_name__ = "PreferencesDialog"
def __new__(cls):
"""Special static method that's automatically called by Python when
constructing a new instance of this class.
Returns a fully instantiated PreferencesDialog object.
"""
builder = get_builder('PreferencesMugshotDialog')
new_object = builder.get_object("preferences_mugshot_dialog")
new_object.finish_initializing(builder)
return new_object
def finish_initializing(self, builder):
"""Called while initializing this instance in __new__
finish_initalizing should be called after parsing the ui definition
and creating a PreferencesDialog object with it in order to
finish initializing the start of the new PerferencesMugshotDialog
instance.
Put your initialization code in here and leave __init__ undefined.
"""
# Get a reference to the builder and set up the signals.
self.builder = builder
self.ui = builder.get_ui(self, True)
# code for other initialization actions should be added here
def on_btn_close_clicked(self, widget, data=None):
self.destroy()
def on_btn_help_clicked(self, widget, data=None):
show_uri(self, "ghelp:%s" % get_help_uri('preferences'))

View File

@ -58,8 +58,6 @@ class Window(Gtk.Window):
# Get a reference to the builder and set up the signals. # Get a reference to the builder and set up the signals.
self.builder = builder self.builder = builder
self.ui = builder.get_ui(self, True) self.ui = builder.get_ui(self, True)
self.PreferencesDialog = None # class
self.preferences_dialog = None # instance
self.AboutDialog = None # class self.AboutDialog = None # class
self.settings = Gio.Settings("apps.mugshot") self.settings = Gio.Settings("apps.mugshot")
@ -88,24 +86,6 @@ class Window(Gtk.Window):
response = about.run() response = about.run()
about.destroy() about.destroy()
def on_mnu_preferences_activate(self, widget, data=None):
"""Display the preferences window for mugshot."""
""" From the PyGTK Reference manual
Say for example the preferences dialog is currently open,
and the user chooses Preferences from the menu a second time;
use the present() method to move the already-open dialog
where the user can see it."""
if self.preferences_dialog is not None:
logger.debug('show existing preferences_dialog')
self.preferences_dialog.present()
elif self.PreferencesDialog is not None:
logger.debug('create new preferences_dialog')
self.preferences_dialog = self.PreferencesDialog() # pylint: disable=E1102
self.preferences_dialog.connect('destroy', self.on_preferences_dialog_destroyed)
self.preferences_dialog.show()
# destroy command moved into dialog to allow for a help button
def on_mnu_close_activate(self, widget, data=None): def on_mnu_close_activate(self, widget, data=None):
"""Signal handler for closing the MugshotWindow.""" """Signal handler for closing the MugshotWindow."""
self.destroy() self.destroy()
@ -118,12 +98,3 @@ class Window(Gtk.Window):
def on_preferences_changed(self, settings, key, data=None): def on_preferences_changed(self, settings, key, data=None):
logger.debug('preference changed: %s = %s' % (key, str(settings.get_value(key)))) logger.debug('preference changed: %s = %s' % (key, str(settings.get_value(key))))
def on_preferences_dialog_destroyed(self, widget, data=None):
'''only affects gui
logically there is no difference between the user closing,
minimising or ignoring the preferences dialog'''
logger.debug('on_preferences_dialog_destroyed')
# to determine whether to create or present preferences_dialog
self.preferences_dialog = None