1
0
Fork 0

Plugin.{Data,Object}.preferences(): show preferences window.

This commit is contained in:
Kolan Sh 2018-04-27 10:18:20 +03:00
parent 13f5cf753f
commit 473abfa1e3
4 changed files with 211 additions and 1 deletions

34
src/AppDirs.vala Normal file
View File

@ -0,0 +1,34 @@
namespace Get {
extern void library_path (string so_path, void *addr);
}
namespace LAview.Core.Plugins {
class AppDirs : Object {
public static File so_path;
public static File exec_dir;
public static File common_dir;
public static string ui_dir;
public static string settings_dir;
public static void init () {
char _so_path[256];
Get.library_path ((string)_so_path, (void*)init);
so_path = File.new_for_path ((string)_so_path);
exec_dir = so_path.get_parent ();
common_dir = exec_dir.get_parent ();
common_dir = common_dir.get_parent().get_parent().get_parent();
ui_dir = Path.build_path (Path.DIR_SEPARATOR_S, common_dir.get_path(),
"share/laview-plugin-data-example-"+Config.VERSION_MAJOR.to_string()+"/ui");
stdout.printf ("Vala:so_path=%s\n", so_path.get_path());
settings_dir = Path.build_path (Path.DIR_SEPARATOR_S, common_dir.get_path(), "share/glib-2.0/schemas");
stdout.printf ("ui_dir = %s\n", ui_dir);
stdout.printf ("settings_dir = %s\n", settings_dir);
}
public static void terminate () {
}
}
}

47
src/DataDialog.vala Normal file
View File

@ -0,0 +1,47 @@
namespace LAview.Core.Plugins {
using Gtk, LAview;
class DataExampleDialog : Object {
Dialog dialog;
public bool composed { get; private set; default = false; }
public DataExampleDialog (Object parent) throws Error {
var builder = new Builder ();
builder.add_from_file (AppDirs.ui_dir + "/laview-plugin-data-example.glade");
builder.connect_signals (this);
dialog = builder.get_object ("data_example_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

@ -8,6 +8,8 @@ namespace LAview.Core.Plugins {
*/ */
public class PluginDataExample : PluginData { public class PluginDataExample : PluginData {
DataExampleDialog data_dialog = null;
/** /**
* Constructs a new ``PluginDataExample``. * Constructs a new ``PluginDataExample``.
*/ */
@ -41,9 +43,13 @@ namespace LAview.Core.Plugins {
/** /**
* Open Preferences. * Open Preferences.
*/ */
public override void preferences () { public override void preferences (Object parent) throws Error {
// TODO: Open Preferences window. // TODO: Open Preferences window.
stdout.puts("Data Example preferences () called.\n"); stdout.puts("Data Example preferences () called.\n");
if (data_dialog == null) data_dialog = new DataExampleDialog (parent);
data_dialog.show_all ();
} }
/** /**

View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.19.0 -->
<interface>
<requires lib="gtk+" version="3.16"/>
<object class="GtkDialog" id="data_example_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_data_example_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_data_example_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_data_example_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">label</property>
</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">label</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">label</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface>