1
0
Fork 0

PreferencesDialog added

This commit is contained in:
Kolan Sh 2018-04-27 17:28:07 +03:00
parent acd8e1e6bf
commit d21729d16d
3 changed files with 187 additions and 2 deletions

View File

@ -0,0 +1,47 @@
namespace LAview.Core.Plugins {
using Gtk, LAview;
class ObjectExample.PreferencesDialog : Object {
Dialog dialog;
public bool composed { get; private set; default = false; }
public PreferencesDialog (Object parent) throws Error {
var builder = new Builder ();
builder.add_from_file (ObjectExample.AppDirs.ui_dir + "/laview-plugin-object-example.glade");
builder.connect_signals (this);
dialog = builder.get_object ("preferences_dialog") as Dialog;
if (parent is Window) {
dialog.destroy_with_parent = true;
dialog.transient_for = parent as Window;
dialog.modal = true;
dialog.delete_event.connect ((source) => {
dialog.hide_on_delete();
return true;
});
}
}
public void show_all () {
composed = false;
dialog.run ();
}
[CCode (instance_pos = -1)]
public void button_apply_clicked (Button button) {
composed = true;
}
[CCode (instance_pos = -1)]
public void button_ok_clicked (Button button) {
composed = true;
dialog.hide ();
}
[CCode (instance_pos = -1)]
public void button_cancel_clicked (Button button) {
dialog.hide ();
}
}
}

View File

@ -9,6 +9,7 @@ namespace LAview.Core.Plugins {
public class PluginObjectExample : PluginObject {
ObjectExampleDialog object_dialog = null;
ObjectExample.PreferencesDialog preferences_dialog = null;
/**
* Constructs a new ``PluginObjectExample``.
@ -89,8 +90,9 @@ namespace LAview.Core.Plugins {
* Open Preferences.
*/
public override void preferences (Object parent) throws Error {
// TODO: Open Preferences window.
stdout.puts("Object Example preferences () called.\n");
if (preferences_dialog == null) preferences_dialog = new ObjectExample.PreferencesDialog (parent);
preferences_dialog.show_all ();
}
}
}

View File

@ -138,4 +138,140 @@
<placeholder/>
</child>
</object>
<object class="GtkDialog" id="preferences_dialog">
<property name="can_focus">False</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area1">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="button_apply">
<property name="label">gtk-apply</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
<property name="always_show_image">True</property>
<signal name="clicked" handler="laview_core_plugins_object_example_preferences_dialog_button_apply_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button_ok">
<property name="label">gtk-ok</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
<property name="always_show_image">True</property>
<signal name="clicked" handler="laview_core_plugins_object_example_preferences_dialog_button_ok_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button_cancel">
<property name="label">gtk-undo</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
<property name="always_show_image">True</property>
<signal name="clicked" handler="laview_core_plugins_object_example_preferences_dialog_button_cancel_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</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="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Object Plugin Preferences</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">...settings...</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">...preferences...</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">...properties...</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<child>
<placeholder/>
</child>
</object>
</interface>