148 lines
4.9 KiB
Diff
148 lines
4.9 KiB
Diff
From 3683b937c06bd1e4c813da3554898d95b2ecc6b9 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= <besser82@fedoraproject.org>
|
|
Date: Sun, 5 Feb 2017 17:02:49 +0100
|
|
Subject: [PATCH] Patches from MGA (anaselli) to support external plugins
|
|
|
|
---
|
|
CMakeLists.txt | 2 +-
|
|
swig/python/examples/mga-dialogs.py | 89 +++++++++++++++++++++++++++++++++++++
|
|
swig/yui.i | 9 ++++
|
|
3 files changed, 99 insertions(+), 1 deletion(-)
|
|
create mode 100644 swig/python/examples/mga-dialogs.py
|
|
|
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index 59c94af..c2e6a88 100644
|
|
--- a/CMakeLists.txt
|
|
+++ b/CMakeLists.txt
|
|
@@ -28,7 +28,7 @@ ENDIF()
|
|
SET( CMAKE_INSTALL_PREFIX "${YPREFIX}" )
|
|
|
|
SET( LIBYUI_INCLUDE_DIR "${YPREFIX}/include" )
|
|
-SET( LIBYUI_LIBRARY "yui" )
|
|
+SET( LIBYUI_LIBRARY yui yui-mga )
|
|
|
|
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Language Bindings for libyui")
|
|
SET(CPACK_PACKAGE_VENDOR "Novell Inc.")
|
|
diff --git a/swig/python/examples/mga-dialogs.py b/swig/python/examples/mga-dialogs.py
|
|
new file mode 100644
|
|
index 0000000..285590c
|
|
--- /dev/null
|
|
+++ b/swig/python/examples/mga-dialogs.py
|
|
@@ -0,0 +1,89 @@
|
|
+#!/usr/bin/env python
|
|
+# vim: set et ts=4 sw=4:
|
|
+#coding:utf-8
|
|
+#############################################################################
|
|
+#
|
|
+# mga-dialogs.py - Show mga msg dialog and about dialog.
|
|
+#
|
|
+# License: GPLv3
|
|
+# Author: Angelo Naselli <anaselli@linux.it>
|
|
+#############################################################################
|
|
+
|
|
+###########
|
|
+# imports #
|
|
+###########
|
|
+import sys
|
|
+sys.path.insert(0,'../../../build/swig/python')
|
|
+import os
|
|
+
|
|
+import yui
|
|
+
|
|
+log = yui.YUILog.instance()
|
|
+log.setLogFileName("/tmp/debug.log")
|
|
+log.enableDebugLogging( True )
|
|
+appl = yui.YUI.application()
|
|
+appl.setApplicationTitle("Show dialogs example")
|
|
+
|
|
+#################
|
|
+# class mainGui #
|
|
+#################
|
|
+class Info(object):
|
|
+ def __init__(self,title,richtext,text):
|
|
+ self.title=title
|
|
+ self.richtext=richtext
|
|
+ self.text=text
|
|
+
|
|
+class mainGui():
|
|
+ """
|
|
+ Main class
|
|
+ """
|
|
+
|
|
+ def __init__(self):
|
|
+ self.factory = yui.YUI.widgetFactory()
|
|
+ self.dialog = self.factory.createPopupDialog()
|
|
+ mainvbox = self.factory.createVBox(self.dialog)
|
|
+ frame = self.factory.createFrame(mainvbox,"Test frame")
|
|
+ HBox = self.factory.createHBox(frame)
|
|
+ self.aboutbutton = self.factory.createPushButton(HBox,"&About")
|
|
+ self.closebutton = self.factory.createPushButton(self.factory.createRight(HBox), "&Close")
|
|
+
|
|
+
|
|
+ def ask_YesOrNo(self, info):
|
|
+ yui.YUI.widgetFactory
|
|
+ mgafactory = yui.YMGAWidgetFactory.getYMGAWidgetFactory(yui.YExternalWidgets.externalWidgetFactory("mga"))
|
|
+ dlg = mgafactory.createDialogBox(yui.YMGAMessageBox.B_TWO)
|
|
+ dlg.setTitle(info.title)
|
|
+ dlg.setText(info.text, info.richtext)
|
|
+ dlg.setButtonLabel("Yes", yui.YMGAMessageBox.B_ONE)
|
|
+ dlg.setButtonLabel("No", yui.YMGAMessageBox.B_TWO)
|
|
+ dlg.setMinSize(50, 5);
|
|
+ return dlg.show() == yui.YMGAMessageBox.B_ONE
|
|
+
|
|
+ def aboutDialog(self):
|
|
+ yui.YUI.widgetFactory;
|
|
+ mgafactory = yui.YMGAWidgetFactory.getYMGAWidgetFactory(yui.YExternalWidgets.externalWidgetFactory("mga"))
|
|
+ dlg = mgafactory.createAboutDialog("About dialog title example", "1.0.0", "GPLv3",
|
|
+ "Angelo Naselli", "This beautiful test example shows how it is easy to play with libyui bindings", "")
|
|
+ dlg.show();
|
|
+
|
|
+
|
|
+ def handleevent(self):
|
|
+ """
|
|
+ Event-handler for the 'widgets' demo
|
|
+ """
|
|
+ while True:
|
|
+ event = self.dialog.waitForEvent()
|
|
+ if event.eventType() == yui.YEvent.CancelEvent:
|
|
+ self.dialog.destroy()
|
|
+ break
|
|
+ if event.widget() == self.closebutton:
|
|
+ info = Info("Quit confirmation", 1, "Are you sure you want to quit?")
|
|
+ if self.ask_YesOrNo(info):
|
|
+ self.dialog.destroy()
|
|
+ break
|
|
+ if event.widget() == self.aboutbutton:
|
|
+ self.aboutDialog()
|
|
+
|
|
+if __name__ == "__main__":
|
|
+ main_gui = mainGui()
|
|
+ main_gui.handleevent()
|
|
diff --git a/swig/yui.i b/swig/yui.i
|
|
index 0a44d27..5dd5f82 100644
|
|
--- a/swig/yui.i
|
|
+++ b/swig/yui.i
|
|
@@ -99,6 +99,11 @@ SWIGEXPORT void Init__yui(void) {
|
|
|
|
#include "yui/YUILoader.h"
|
|
|
|
+#include "yui/mga/YMGA_CBTable.h"
|
|
+#include "yui/mga/YMGAMsgBox.h"
|
|
+#include "yui/mga/YMGAAboutDialog.h"
|
|
+#include "yui/mga/YMGAWidgetExtensionFactory.h"
|
|
+
|
|
using namespace std;
|
|
|
|
extern void *start_ui_thread( void *ui_int );
|
|
@@ -254,6 +259,10 @@ class Exception;
|
|
%include yui/YWidgetID.h
|
|
%include yui/YExternalWidgetFactory.h
|
|
%include yui/YExternalWidgets.h
|
|
+%include yui/mga/YMGA_CBTable.h
|
|
+%include yui/mga/YMGAAboutDialog.h
|
|
+%include yui/mga/YMGAMsgBox.h
|
|
+%include yui/mga/YMGAWidgetExtensionFactory.h
|
|
|
|
#if defined(SWIGRUBY)
|
|
%extend YEvent {
|