diff --git a/VERSION.cmake b/VERSION.cmake index b4e3c84..e8715bc 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -1,3 +1,3 @@ SET(VERSION_MAJOR "2") SET(VERSION_MINOR "0") -SET(VERSION_PATCH "2") +SET(VERSION_PATCH "3") diff --git a/package/libyui-bindings.spec b/package/libyui-bindings.spec index 08f149d..cb4a58b 100644 --- a/package/libyui-bindings.spec +++ b/package/libyui-bindings.spec @@ -18,7 +18,7 @@ Name: libyui-bindings -Version: 2.0.2 +Version: 2.0.3 Release: 0 Summary: Bindings for libyui License: LGPL-2.1-only OR LGPL-3.0-only diff --git a/swig/python/examples/menubar.py b/swig/python/examples/menubar.py new file mode 100755 index 0000000..0f5565d --- /dev/null +++ b/swig/python/examples/menubar.py @@ -0,0 +1,132 @@ +#!/usr/bin/env python3 +# 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 +############################################################################# + +########### +# 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.mgafactory = yui.YMGAWidgetFactory.getYMGAWidgetFactory(yui.YExternalWidgets.externalWidgetFactory("mga")) + self.dialog = self.factory.createPopupDialog() + mainvbox = self.factory.createVBox(self.dialog) + self.menubar = self.mgafactory.createMenuBar(mainvbox) + + #Items must be "disowned" + mItem = yui.YMGAMenuItem("&File") + mItem.this.own(False) + tmi = yui.YMGAMenuItem(mItem, "&New") + tmi.this.own(False) + item = yui.YMGAMenuItem( tmi, "New &1" , "document-new") + item.this.own(False) + item = yui.YMGAMenuItem( tmi, "New &2" , "contact-new") + item.this.own(False) + item = yui.YMenuSeparator(mItem); + item.this.own(False) + item = yui.YMGAMenuItem(mItem, "&Open", "document-open.png") + item.this.own(False) + item = yui.YMenuSeparator(mItem); + item.this.own(False) + item = yui.YMGAMenuItem(mItem, "&Save", "document-save.png") + item.this.own(False) + item = yui.YMGAMenuItem(mItem, "&Save as", "document-save-as") + item.this.own(False) + item = yui.YMenuSeparator(mItem); + item.this.own(False) + self.quitMenu = yui.YMGAMenuItem(mItem, "&Quit", "application-exit") + self.quitMenu.this.own(False) + + self.menubar.addItem(mItem) + + mItem1 = yui.YMGAMenuItem("&Edit") + self.editMenu = { + 'menu' : mItem1, + 'undo' : yui.YMGAMenuItem(mItem1, "&Undo", "edit-undo.png"), + 'redo' : yui.YMGAMenuItem(mItem1, "&Redo", "edit-redo.png"), + 'sep0' : yui.YMenuSeparator(mItem1), + 'cut' : yui.YMGAMenuItem(mItem1, "Cu&t", "edit-cut.png"), + 'copy' : yui.YMGAMenuItem(mItem1, "&Copy", "edit-copy.png"), + 'paste' : yui.YMGAMenuItem(mItem1, "&Paste", "edit-paste.png"), + } + #Items must be "disowned" + for k in self.editMenu.keys(): + self.editMenu[k].this.own(False) + self.menubar.addItem(self.editMenu['menu']) + + HBox = self.factory.createHBox(mainvbox) + self.aboutbutton = self.factory.createPushButton(HBox,"&About") + self.closebutton = self.factory.createPushButton(self.factory.createRight(HBox), "&Close") + + + def aboutDialog(self): + dlg = self.mgafactory.createAboutDialog("About menu bar example", "1.0.0", "GPLv3", + "Angelo Naselli", "This simple example shows how a menubar can work using libyui bindings", "") + dlg.show(); + + + def handleevent(self): + """ + Event-handler for the 'widgets' demo + """ + while True: + event = self.dialog.waitForEvent() + eventType = event.eventType() + if eventType == yui.YEvent.CancelEvent: + break + elif (eventType == yui.YEvent.MenuEvent) : + item = event.item() + if (item) : + if item == self.quitMenu : + break + elif (eventType == yui.YEvent.WidgetEvent) : + # widget selected + widget = event.widget() + if (widget == self.closebutton) : + break + elif widget == self.aboutbutton: + self.aboutDialog() + + self.dialog.destroy() + +if __name__ == "__main__": + main_gui = mainGui() + main_gui.handleevent() + + yui.YDialog.deleteAllDialogs() + # next line seems to be a workaround to prevent the qt-app from crashing + # see /~https://github.com/libyui/libyui-qt/issues/41 + yui.YUILoader.deleteUI() + diff --git a/swig/python/examples/mga-dialogs.py b/swig/python/examples/mga-dialogs.py index 285590c..3415f1f 100644 --- a/swig/python/examples/mga-dialogs.py +++ b/swig/python/examples/mga-dialogs.py @@ -57,7 +57,8 @@ def ask_YesOrNo(self, info): 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 + ret_val = dlg.show() == yui.YMGAMessageBox.B_ONE + return ret_val def aboutDialog(self): yui.YUI.widgetFactory; @@ -74,16 +75,19 @@ def handleevent(self): 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?") + info = Info("Quit confirmation", True, "Are you sure you want to quit?") if self.ask_YesOrNo(info): - self.dialog.destroy() break if event.widget() == self.aboutbutton: self.aboutDialog() + yui.YDialog.deleteAllDialogs() + # next line seems to be a workaround to prevent the qt-app from crashing + # see /~https://github.com/libyui/libyui-qt/issues/41 + yui.YUILoader.deleteUI() + if __name__ == "__main__": main_gui = mainGui() main_gui.handleevent() diff --git a/swig/yui.i b/swig/yui.i index c5494b0..a035536 100644 --- a/swig/yui.i +++ b/swig/yui.i @@ -103,6 +103,8 @@ SWIGEXPORT void Init__yui(void) { #include "yui/mga/YMGA_CBTable.h" #include "yui/mga/YMGAMsgBox.h" #include "yui/mga/YMGAAboutDialog.h" +#include "yui/mga/YMGAMenuItem.h" +#include "yui/mga/YMGAMenuBar.h" #include "yui/mga/YMGAWidgetExtensionFactory.h" #endif @@ -265,6 +267,8 @@ class Exception; #if defined(WITH_MGA) %include yui/mga/YMGA_CBTable.h %include yui/mga/YMGAAboutDialog.h +%include yui/mga/YMGAMenuItem.h +%include yui/mga/YMGAMenuBar.h %include yui/mga/YMGAMsgBox.h %include yui/mga/YMGAWidgetExtensionFactory.h #endif