Skip to content

Commit

Permalink
Merge pull request #50 from tobias47n9e/master
Browse files Browse the repository at this point in the history
Merge GSettings updates, compatiblitly
  • Loading branch information
tobias47n9e committed Aug 5, 2015
2 parents 757a8e3 + f5dccfb commit 4a08481
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 9 deletions.
5 changes: 5 additions & 0 deletions data/org.gtk.innstereo.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
<summary>Pixel Density (DPI)</summary>
<description>Sets the pixel density the plots will use in DPI.</description>
</key>
<key type="b" name="highlight-mode">
<default>false</default>
<summary>Highlight mode</summary>
<description>Sets whether selected layers or features should be highlighted.</description>
</key>
</schema>
</schemalist>

48 changes: 46 additions & 2 deletions innstereo/gui_layout.glade
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,16 @@ In Preperation (2015)</property>
<property name="website">http://innstereo.github.io</property>
<property name="website_label" translatable="yes">http://innstereo.github.io</property>
<property name="authors">Tobias Schönberg
Matteo Pasotti</property>
Matteo Pasotti


Special thanks to:
Tristan Van Berkom
Thomas Kluyver
Andreas Kositz
Hugo Ortner
Martin Reiser
</property>
<property name="logo">logo_about.svg</property>
<property name="license_type">gpl-2-0</property>
<signal name="close" handler="on_aboutdialog_close" swapped="no"/>
Expand Down Expand Up @@ -438,6 +447,41 @@ Use the same value as your primary display to get sharp drawing.</property>
<property name="top_attach">10</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="switch_def_highlight">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">start</property>
<property name="margin_left">30</property>
<property name="margin_right">5</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<signal name="state-set" handler="on_switch_def_highlight_state_set" swapped="no"/>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">11</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label85">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_left">5</property>
<property name="margin_right">5</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="label" translatable="yes">&lt;b&gt;Highlight Mode&lt;/b&gt;
Sets whether selected datasets and features should be highlighted.</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">11</property>
</packing>
</child>
</object>
</child>
</object>
Expand Down Expand Up @@ -4798,7 +4842,7 @@ customizable grid.</property>
<object class="GtkToolButton" id="toolbutton_layer_properties">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Layer properties</property>
<property name="label" translatable="yes">Layer Properties</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-color-picker</property>
<signal name="clicked" handler="on_toolbutton_layer_properties_clicked" swapped="no"/>
Expand Down
6 changes: 5 additions & 1 deletion innstereo/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ def __init__(self):

gettext.find(self.app_name, mo_location)

locale.bindtextdomain(self.app_name, locale_dir)
#This try-except is needed for platforms that have no access to locale.bindtextdomain()
try:
locale.bindtextdomain(self.app_name, locale_dir)
except:
pass

gettext.bindtextdomain (self.app_name, locale_dir)

Expand Down
6 changes: 3 additions & 3 deletions innstereo/main_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class MainWindow(object):
for individual functions of the GUI.
"""

def __init__(self, builder):
def __init__(self, builder, testing):
"""
Initializes the main window and connects different functions.
Expand Down Expand Up @@ -84,7 +84,7 @@ def __init__(self, builder):
self.clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)

#Set up default options class
self.settings = PlotSettings()
self.settings = PlotSettings(testing)
self.change_night_mode()

#Set up layer view and connect signals
Expand Down Expand Up @@ -2936,7 +2936,7 @@ def startup(testing=False):
"poles_to_lines", "image_linears_to_planes", "image_rotate",
"image_pt_axis", "image_mean_vector", "image_fisher"))

gui_instance = MainWindow(builder)
gui_instance = MainWindow(builder, testing)
builder.connect_signals(gui_instance)
if testing == False:
Gtk.main()
Expand Down
11 changes: 8 additions & 3 deletions innstereo/plot_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class PlotSettings(object):
one for either the Schmidt- or Wulff-Net.
"""

def __init__(self):
def __init__(self, testing):
"""
Initalizes the default values, colors and the matplotlib-figure.
Expand All @@ -58,8 +58,12 @@ def __init__(self):
}.items()))
self.night_mode = False
self.fig = Figure(dpi=self.props["pixel_density"])
self.g_settings = Gio.Settings.new("org.gtk.innstereo")
self.get_defaults()
if testing == False:
try:
self.g_settings = Gio.Settings.new("org.gtk.innstereo")
self.get_defaults()
except:
pass

def get_defaults(self):
"""
Expand All @@ -71,6 +75,7 @@ def get_defaults(self):
self.props["show_cross"] = self.g_settings.get_boolean("center-cross")
self.night_mode = self.g_settings.get_boolean("night-mode")
self.props["pixel_density"] = self.g_settings.get_value("pixel-density").get_int32()
self.props["highlight"] = self.g_settings.get_boolean("highlight-mode")

def get_fig(self):
"""
Expand Down
8 changes: 8 additions & 0 deletions innstereo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(self, main_window):
self.switch_def_night_mode = self.builder.get_object("switch_def_night_mode")
self.spinbutton_def_pixeldens = self.builder.get_object("spinbutton_def_pixeldens")
self.adjustment_def_pixeldens = self.builder.get_object("adjustment_def_pixeldens")
self.switch_def_highlight = self.builder.get_object("switch_def_highlight")
self.set_win.set_transient_for(main_window)
self.builder.connect_signals(self)

Expand All @@ -57,6 +58,7 @@ def get_defaults(self):
pixel_density = self.g_settings.get_value("pixel-density")
pixel_density = pixel_density.get_int32()
self.adjustment_def_pixeldens.set_value(pixel_density)
self.switch_def_highlight.set_active(self.g_settings.get_boolean("highlight-mode"))

def on_settings_window_destroy(self, widget):
"""
Expand Down Expand Up @@ -108,3 +110,9 @@ def on_spinbutton_def_pixeldens_value_changed(self, spinbutton):
value = spinbutton.get_value()
value = GLib.Variant.new_int32(value)
self.g_settings.set_value("pixel-density", value)

def on_switch_def_highlight_state_set(self, switch, state):
"""
Sets a new default for layer and feature highlighting.
"""
self.g_settings.set_boolean("highlight-mode", state)

0 comments on commit 4a08481

Please sign in to comment.