From 63a4324a84bb87feacd2d4c95a473d38a72a1b78 Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Mar 01 2019 06:35:03 +0000 Subject: [PATCH 1/2] Fix build without intltool. It's gone in Fedora 30. The port is quite simple with recent gettext. Everything from https://wiki.gnome.org/MigratingFromIntltoolToGettext just worked. --- diff --git a/Makefile.am b/Makefile.am index 131ea75..36cd72b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,7 +13,7 @@ python_PYTHON = switch_java_functions.py switch_java_gui.py switch_java_tui.py \ dist_python_DATA = $(PACKAGE).glade $(PACKAGE).desktop: $(PACKAGE).desktop.in - @INTLTOOL_MERGE@ --desktop-style $(srcdir)/po $< $@ + $(AM_V_GEN)$(MSGFMT) --desktop --template $< -d $(top_srcdir)/po -o $@ EXTRA_DIST = switch_java_globals.py.in $(PACKAGE).desktop.in COPYING.icon diff --git a/autogen.sh b/autogen.sh index 41e8485..5a9b3b8 100755 --- a/autogen.sh +++ b/autogen.sh @@ -3,6 +3,5 @@ set -x -e glib-gettextize --force -intltoolize -f autoreconf --force --install diff --git a/configure.ac b/configure.ac index bd31005..b62b988 100644 --- a/configure.ac +++ b/configure.ac @@ -3,10 +3,10 @@ AC_INIT([system-switch-java], [1.1.8pre], [dbhole@redhat.com], , AM_INIT_AUTOMAKE([no-dist-gzip dist-xz -Wall]) +AM_GNU_GETTEXT_VERSION([0.19.7]) +AM_GNU_GETTEXT([external]) GETTEXT_PACKAGE=system-switch-java AC_SUBST([GETTEXT_PACKAGE]) -AM_GLIB_GNU_GETTEXT -IT_PROG_INTLTOOL AM_PATH_PYTHON diff --git a/po/Makevars b/po/Makevars new file mode 100644 index 0000000..9a95455 --- /dev/null +++ b/po/Makevars @@ -0,0 +1,78 @@ +# Makefile variables for PO directory in any package using GNU gettext. + +# Usually the message domain is the same as the package name. +DOMAIN = $(PACKAGE) + +# These two variables depend on the location of this directory. +subdir = po +top_builddir = .. + +# These options get passed to xgettext. +XGETTEXT_OPTIONS = --from-code=UTF-8 --keyword=_ --keyword=N_ --keyword=C_:1c,2 --keyword=NC_:1c,2 --keyword=g_dngettext:2,3 + +# This is the copyright holder that gets inserted into the header of the +# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding +# package. (Note that the msgstr strings, extracted from the package's +# sources, belong to the copyright holder of the package.) Translators are +# expected to transfer the copyright for their translations to this person +# or entity, or to disclaim their copyright. The empty string stands for +# the public domain; in this case the translators are expected to disclaim +# their copyright. +COPYRIGHT_HOLDER = Free Software Foundation, Inc. + +# This tells whether or not to prepend "GNU " prefix to the package +# name that gets inserted into the header of the $(DOMAIN).pot file. +# Possible values are "yes", "no", or empty. If it is empty, try to +# detect it automatically by scanning the files in $(top_srcdir) for +# "GNU packagename" string. +PACKAGE_GNU = + +# This is the email address or URL to which the translators shall report +# bugs in the untranslated strings: +# - Strings which are not entire sentences, see the maintainer guidelines +# in the GNU gettext documentation, section 'Preparing Strings'. +# - Strings which use unclear terms or require additional context to be +# understood. +# - Strings which make invalid assumptions about notation of date, time or +# money. +# - Pluralisation problems. +# - Incorrect English spelling. +# - Incorrect formatting. +# It can be your email address, or a mailing list address where translators +# can write to without being subscribed, or the URL of a web page through +# which the translators can contact you. +MSGID_BUGS_ADDRESS = + +# This is the list of locale categories, beyond LC_MESSAGES, for which the +# message catalogs shall be used. It is usually empty. +EXTRA_LOCALE_CATEGORIES = + +# This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt' +# context. Possible values are "yes" and "no". Set this to yes if the +# package uses functions taking also a message context, like pgettext(), or +# if in $(XGETTEXT_OPTIONS) you define keywords with a context argument. +USE_MSGCTXT = no + +# These options get passed to msgmerge. +# Useful options are in particular: +# --previous to keep previous msgids of translated messages, +# --quiet to reduce the verbosity. +MSGMERGE_OPTIONS = + +# These options get passed to msginit. +# If you want to disable line wrapping when writing PO files, add +# --no-wrap to MSGMERGE_OPTIONS, XGETTEXT_OPTIONS, and +# MSGINIT_OPTIONS. +MSGINIT_OPTIONS = + +# This tells whether or not to regenerate a PO file when $(DOMAIN).pot +# has changed. Possible values are "yes" and "no". Set this to no if +# the POT file is checked in the repository and the version control +# program ignores timestamps. +PO_DEPENDS_ON_POT = no + +# This tells whether or not to forcibly update $(DOMAIN).pot and +# regenerate PO files on "make dist". Possible values are "yes" and +# "no". Set this to no if the POT file and PO files are maintained +# externally. +DIST_DEPENDS_ON_UPDATE_PO = yes diff --git a/system-switch-java.desktop.in b/system-switch-java.desktop.in index 26c7dfe..812e67c 100644 --- a/system-switch-java.desktop.in +++ b/system-switch-java.desktop.in @@ -2,8 +2,8 @@ Encoding=UTF-8 X-Desktop-File-Install-Version=0.2 Categories=System;Settings; -_Name=Java Toolset -_Comment=Change the default Java toolset +Name=Java Toolset +Comment=Change the default Java toolset Exec=/usr/bin/system-switch-java Terminal=false Type=Application From 801cd26e46075fa822b789ff79e775bc9079ea53 Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Mar 01 2019 08:08:51 +0000 Subject: [PATCH 2/2] Port to Gtk3. * Update glade file to be gtk3 compatible. * Switch to use python-gobject. --- diff --git a/switch_java_gui.py b/switch_java_gui.py index 2081c6d..f3d3132 100644 --- a/switch_java_gui.py +++ b/switch_java_gui.py @@ -16,8 +16,9 @@ # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301 USA. -import gtk -import gtk.glade +import gi +gi.require_version("Gtk", "3.0") +from gi.repository import Gtk from switch_java_functions import * from switch_java_globals import DATA_ROOT_DIR, PACKAGE_NAME @@ -27,27 +28,27 @@ class mainDialog: def main(self, java_identifiers, default_java, pretty_names): # Initialize UI. - xml = gtk.glade.XML(DATA_ROOT_DIR + '/' + PACKAGE_NAME + '/' + - PACKAGE_NAME + '.glade', - None, domain=PACKAGE_NAME) - self.dialog = xml.get_widget('dialog') + builder = Gtk.Builder() + builder.add_from_file(DATA_ROOT_DIR + '/' + PACKAGE_NAME + '/' + + PACKAGE_NAME + '.glade') + self.dialog = builder.get_object('dialog') self.dialog.set_title(TITLE_MESSAGE) - radio_vbox = xml.get_widget('radio-vbox') - xml.get_widget('instruction-label').set_text(INSTRUCTION_MESSAGE) - xml.get_widget('selection-label').set_markup('' + radio_vbox = builder.get_object('radio-vbox') + builder.get_object('instruction-label').set_text(INSTRUCTION_MESSAGE) + builder.get_object('selection-label').set_markup('' + SELECTION_MESSAGE + '') - ok_button = xml.get_widget('ok-button') + ok_button = builder.get_object('ok-button') # Initialize alternatives list. self.radio_buttons = {} self.alternatives = {} for java in java_identifiers: if len(self.radio_buttons) == 0: - self.radio_buttons[java] = gtk.RadioButton(None, + self.radio_buttons[java] = Gtk.RadioButton.new_with_label_from_widget(None, pretty_names[java]) group_button = self.radio_buttons[java] else: - self.radio_buttons[java] = gtk.RadioButton(group_button, + self.radio_buttons[java] = Gtk.RadioButton.new_with_label_from_widget(group_button, pretty_names[java]) radio_vbox.pack_start(self.radio_buttons[java], False, False, 0) self.radio_buttons[java].set_use_underline(False); @@ -61,17 +62,17 @@ class mainDialog: self.radio_buttons[default_java].grab_focus() ok_button.connect('clicked', self.ok_button_clicked) ok_button.set_sensitive(False) - xml.get_widget('cancel-button').connect('clicked', + builder.get_object('cancel-button').connect('clicked', self.cancel_button_clicked) self.dialog.connect('delete-event', self.dialog_delete_event) - self.dialog.connect('hide', gtk.main_quit) + self.dialog.connect('hide', Gtk.main_quit) self.dialog.set_icon_from_file(DATA_ROOT_DIR + '/pixmaps/' + PACKAGE_NAME + '.png') self.dialog.show() - gtk.main() + Gtk.main() def dialog_delete_event(self, *args): - gtk.main_quit() + Gtk.main_quit() def ok_button_clicked(self, button): for radio_button in self.radio_buttons.values(): @@ -79,20 +80,25 @@ class mainDialog: switch_java(self.alternatives[radio_button]) break self.dialog.hide() - gtk.main_quit() + Gtk.main_quit() def cancel_button_clicked(self, button): self.dialog.hide() - gtk.main_quit() + Gtk.main_quit() def show_dialog(self, message): - dialog = gtk.MessageDialog(None, - gtk.DIALOG_MODAL - | gtk.DIALOG_DESTROY_WITH_PARENT, - gtk.MESSAGE_INFO, - gtk.BUTTONS_OK, + dialog = Gtk.MessageDialog(None, + Gtk.DialogFlags.MODAL + | Gtk.DialogFlags.DESTROY_WITH_PARENT, + Gtk.MessageType.INFO, + Gtk.ButtonsType.OK, message) dialog.set_title(TITLE_MESSAGE) dialog.set_icon_from_file(DATA_ROOT_DIR + '/pixmaps/' + PACKAGE_NAME + '.png') dialog.run() dialog.destroy() + + +if __name__ == '__main__': + mainDialog.show_dialog("test") + \ No newline at end of file diff --git a/system-switch-java.glade b/system-switch-java.glade index 0c34938..bfe7867 100644 --- a/system-switch-java.glade +++ b/system-switch-java.glade @@ -1,184 +1,155 @@ - - - - - + + + + + + + False 5 - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False False - False - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - True - False - False - + dialog + + + - - True - False - 2 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - True - + + True + False + 2 + + + True + False + end + + + gtk-ok + True + True + True + True + False + True + + + True + True + 0 + + + + + gtk-cancel + True + True + True + True + False + True + + + True + True + 1 + + + + + False + True + end + 0 + - - - True - True - True - True - gtk-cancel - True - GTK_RELIEF_NORMAL - True - - - - - - 0 - False - True - GTK_PACK_END - - - - - - 5 - True - False - 6 - - - - True - - - - True - False - False - GTK_JUSTIFY_LEFT - True - False - 0 - 0.5 - 0 - 6 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - - 0 - False - True - - - - - - True - False - 6 - - - - True - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - - True - 0.5 - 0.5 - 1 - 1 - 0 - 0 - 12 - 0 - - - - True - False - 6 - - - - - - - 0 - True - True - - - - - - 0 - True - True - - - - - - - + + True + False + 5 + vertical + 6 + + + True + False + + + True + False + 6 + 6 + True + 0 + 0.5 + + + False + False + 0 + + + + + False + True + 0 + + + + + True + False + vertical + 6 + + + True + False + True + 0 + 0.5 + + + False + False + 0 + + + + + True + False + 12 + + + True + False + vertical + 6 + + + + + True + True + 1 + + + + + True + True + 1 + + + + + False + True + 1 + + + - - - + +