From 288bbdbb0be01270fa3e07fe5670668932798f3b Mon Sep 17 00:00:00 2001 From: 183amir <183.amir@gmail.com> Date: Wed, 21 Jan 2015 15:19:33 +0200 Subject: [PATCH] adds compatibility code for Gtk 3.10 adds better debian packaging does not disable plugins when app crashes removed header bar from preferences dialog fixed a bug when external khayyam was being imported dialog window is used instead of popovers in gtk 3.10 fixes a bug when toolbar was not showing the today button --- .gitignore | 1 + Makefile.am | 33 +++---- configure.ac | 9 +- data/prefs.ui | 1 - debian/changelog | 6 +- debian/control | 9 +- debian/copyright | 23 ++++- debian/docs | 2 + debian/rules | 7 +- frontend/applet/gnome-shell/metadata.json.in | 2 +- intltool-extract.in | 0 intltool-merge.in | 0 intltool-update.in | 0 plugins/appindicator/appindicator.py | 2 +- plugins/main/main.py | 39 +++++---- po/POTFILES.in | 1 - src/c/gahshomar.c | 5 +- src/python/gahshomar/Makefile.am | 1 - src/python/gahshomar/indicator.py | 91 -------------------- src/python/gahshomar/settings_page.py | 2 +- src/python/gahshomar/widgets.py | 40 +++++++-- src/python/gahshomar/window.py | 11 +-- 22 files changed, 125 insertions(+), 160 deletions(-) create mode 100644 debian/docs delete mode 100644 intltool-extract.in delete mode 100644 intltool-merge.in delete mode 100644 intltool-update.in delete mode 100644 src/python/gahshomar/indicator.py diff --git a/.gitignore b/.gitignore index 0943c12..197b59e 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,4 @@ docs/_build/ # package and install script package_install.sh gahshomar/khayyam +push-to-virtual.sh \ No newline at end of file diff --git a/Makefile.am b/Makefile.am index c253b2f..fd2f488 100644 --- a/Makefile.am +++ b/Makefile.am @@ -12,22 +12,23 @@ dist_doc_DATA = \ NEWS -INTLTOOL_FILES = intltool-extract.in \ - intltool-merge.in \ - intltool-update.in - -DEBIAN_FILES = \ - debian/changelog \ - debian/compat \ - debian/control \ - debian/copyright \ - debian/rules \ - debian/source/format - - -EXTRA_DIST = \ - $(INTLTOOL_FILES) \ - $(DEBIAN_FILES) +# INTLTOOL_FILES = intltool-extract.in +# intltool-merge.in +# intltool-update.in + +# DEBIAN_FILES = +# debian/changelog +# debian/compat +# debian/control +# debian/copyright +# debian/rules +# debian/docs +# debian/source/format + + +# EXTRA_DIST = +# $(DEBIAN_FILES) +# $(INTLTOOL_FILES) DISTCLEANFILES = intltool-extract \ intltool-merge \ diff --git a/configure.ac b/configure.ac index 8d468a9..7766465 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT(gahshomar, 4.1.0) +AC_INIT(gahshomar, 4.2.6) AC_CONFIG_SRCDIR([Makefile.am]) AC_CONFIG_HEADERS([config.h]) @@ -19,13 +19,12 @@ dnl AC_CONFIG_MACRO_DIRS([m4]) dnl *************************************************************************** dnl Internationalization dnl *************************************************************************** -IT_PROG_INTLTOOL([0.35.0]) +IT_PROG_INTLTOOL([0.35]) GETTEXT_PACKAGE=gahshomar AC_SUBST(GETTEXT_PACKAGE) AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [The prefix for our gettext translation domains.]) -dnl IT_PROG_INTLTOOL(0.26) YELP_HELP_INIT @@ -59,7 +58,7 @@ AM_CONDITIONAL(NATIVE_WIN32, test x"$native_win32" = "xyes") LT_INIT([win32-dll]) -PKG_CHECK_MODULES(GAHSHOMAR, [gtk+-3.0, glib-2.0, libpeas-1.0, libpeas-gtk-1.0]) +PKG_CHECK_MODULES(GAHSHOMAR, [gtk+-3.0 >= 3.10.0, glib-2.0 >= 2.34, libpeas-1.0, libpeas-gtk-1.0]) dnl *************************************************************************** dnl GLIB_GSETTINGS and GLIB_COMPILE_RESOURCES @@ -72,7 +71,7 @@ GLIB_GSETTINGS GLIB_COMPILE_RESOURCES=`$PKG_CONFIG --variable glib_compile_resources gio-2.0` AC_SUBST(GLIB_COMPILE_RESOURCES) -AM_PATH_PYTHON([3]) +AM_PATH_PYTHON([3.3]) dnl GTK_DOC_CHECK([1.0]) diff --git a/data/prefs.ui b/data/prefs.ui index 289e9c2..3d04267 100644 --- a/data/prefs.ui +++ b/data/prefs.ui @@ -1,7 +1,6 @@ - True True diff --git a/debian/changelog b/debian/changelog index 9e12eac..b65fdb7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,5 @@ -gahshomar (4.1.0-1) UNRELEASED; urgency=medium +gahshomar (4.2.6-1~trusty) trusty; urgency=low - * Initial release. + * Initial release - -- Amir Mohammadi <183.amir@gmail.com> Tue, 13 Jan 2015 23:54:52 +0200 + -- Amir Mohammadi <183.amir@gmail.com> Mon, 19 Jan 2015 18:28:01 +0200 diff --git a/debian/control b/debian/control index d26b610..7786c0f 100644 --- a/debian/control +++ b/debian/control @@ -1,12 +1,15 @@ Source: gahshomar -Maintainer: Amir Mohammadi <183.amir@gmail.com> Section: misc Priority: optional +Maintainer: Amir Mohammadi <183.amir@gmail.com> +Build-Depends: debhelper (>= 9.0.0), autotools-dev, dh-python, intltool, itstool, libxml2-utils, libjalali-dev, libgtk-3-dev, libpeas-dev, libglib2.0-dev (>= 2.34), yelp, yelp-tools, libtool, libgirepository1.0-dev Standards-Version: 3.9.5 -Build-Depends: debhelper (>= 9) +Homepage: http://gahshomar.github.io/gahshomar +#Vcs-Git: git://git.debian.org/collab-maint/gahshomar.git +#Vcs-Browser: http://git.debian.org/?p=collab-maint/gahshomar.git;a=summary Package: gahshomar Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Description: A Persian/Jalali/Farsi Calendar - Provides a calendar interface which can be used to easily convert the dates. + Provides a calendar interface which can be used to easily convert the dates. \ No newline at end of file diff --git a/debian/copyright b/debian/copyright index 2939dbc..2e25aef 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1 +1,22 @@ -GPL3 \ No newline at end of file +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: gahshomar +Source: + +Files: * +Copyright: 2015 Amir Mohammadi <183.amir@gmail.com> +License: GPL-3+ + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + . + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this program. If not, see + . + On Debian systems, the complete text of the GNU General + Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000..50bd824 --- /dev/null +++ b/debian/docs @@ -0,0 +1,2 @@ +NEWS +README diff --git a/debian/rules b/debian/rules index cbe925d..c6d751b 100755 --- a/debian/rules +++ b/debian/rules @@ -1,3 +1,8 @@ #!/usr/bin/make -f +# -*- makefile -*- + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + %: - dh $@ + dh $@ --with autotools-dev diff --git a/frontend/applet/gnome-shell/metadata.json.in b/frontend/applet/gnome-shell/metadata.json.in index 7df5b6c..0fb167b 100644 --- a/frontend/applet/gnome-shell/metadata.json.in +++ b/frontend/applet/gnome-shell/metadata.json.in @@ -4,7 +4,7 @@ "description": "Gahshomar's Gnome Shell Applet.", "original-authors": "Amir Mohammadi", "name": "Gahshomar", - "shell-version": ["3.12", "3.14"], + "shell-version": ["3.10", "3.12", "3.14"], "localedir": "@LOCALEDIR@", "url": "@url@", "version": 1 diff --git a/intltool-extract.in b/intltool-extract.in deleted file mode 100644 index e69de29..0000000 diff --git a/intltool-merge.in b/intltool-merge.in deleted file mode 100644 index e69de29..0000000 diff --git a/intltool-update.in b/intltool-update.in deleted file mode 100644 index e69de29..0000000 diff --git a/plugins/appindicator/appindicator.py b/plugins/appindicator/appindicator.py index 41f9eac..56ebd95 100644 --- a/plugins/appindicator/appindicator.py +++ b/plugins/appindicator/appindicator.py @@ -6,7 +6,7 @@ from gi.repository import GObject, Peas, Gtk, Gio, GLib from gahshomar import log -from gahshomar import khayyam +import gahshomar.khayyam as khayyam class AppindicatorPlugin(GObject.Object, Peas.Activatable): diff --git a/plugins/main/main.py b/plugins/main/main.py index 08a2e12..c6b43b9 100644 --- a/plugins/main/main.py +++ b/plugins/main/main.py @@ -1,6 +1,7 @@ from os.path import abspath, join import sys -from gettext import gettext as _ +import gettext +gettext.install('gahshomar') from gi.repository import GObject, Peas, Gtk, Gio, GLib, Gdk @@ -114,28 +115,28 @@ def about_response(self, dialog, response): @log def load_plugins(self): engine = Peas.Engine.get_default() - crashed = bool(self.settings.get_value('app-crashed')) + # crashed = bool(self.settings.get_value('app-crashed')) names = str(self.settings.get_value('enabled-plugins')).replace("'", "") names = names.split(';') if '' in names: names.remove('') - if crashed: - if names: - logging.warn(_('Disabling all the plugins since ' - 'the app crashed last time!')) - warnmsg = Gtk.MessageDialog( - text=_('Disabling all the plugins since the app crashed ' - 'last time!'), - message_type=Gtk.MessageType.WARNING, - buttons=Gtk.ButtonsType.CLOSE, - transient_for=self.object._window) - warnmsg.run() - warnmsg.destroy() - self.settings.set_value('enabled-plugins', - GLib.Variant('s', '')) - self.settings.set_value('app-crashed', - GLib.Variant.new_boolean(False)) - return + # if crashed: + # if names: + # logging.warn(_('Disabling all the plugins since ' + # 'the app crashed last time!')) + # warnmsg = Gtk.MessageDialog( + # text=_('Disabling all the plugins since the app crashed ' + # 'last time!'), + # message_type=Gtk.MessageType.WARNING, + # buttons=Gtk.ButtonsType.CLOSE, + # transient_for=self.object._window) + # warnmsg.run() + # warnmsg.destroy() + # self.settings.set_value('enabled-plugins', + # GLib.Variant('s', '')) + # self.settings.set_value('app-crashed', + # GLib.Variant.new_boolean(False)) + # return self.settings.set_value('app-crashed', GLib.Variant.new_boolean(True)) diff --git a/po/POTFILES.in b/po/POTFILES.in index e93cde4..ed75e9d 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,7 +1,6 @@ # List of source files containing translatable strings. src/c/main.c -src/python/gahshomar/indicator.py src/python/gahshomar/settings_page.py src/python/gahshomar/widgets.py src/python/gahshomar/window.py diff --git a/src/c/gahshomar.c b/src/c/gahshomar.c index 84d60f2..b1e88fd 100644 --- a/src/c/gahshomar.c +++ b/src/c/gahshomar.c @@ -157,8 +157,10 @@ gah_shomar_startup (GApplication *app) { GtkBuilder *builder; GMenuModel *app_menu; +#if (GTK_MINOR_VERSION > 10) const gchar *quit_accels[2] = { "Q", NULL }; const gchar *today_accels[2] = { "T", NULL }; +#endif PeasExtensionSet *exten_set; G_APPLICATION_CLASS (gah_shomar_parent_class)->startup (app); @@ -169,6 +171,7 @@ gah_shomar_startup (GApplication *app) g_action_map_add_action_entries (G_ACTION_MAP (app), app_entries, G_N_ELEMENTS (app_entries), app); +#if (GTK_MINOR_VERSION > 10) gtk_application_set_accels_for_action (GTK_APPLICATION (app), "app.quit", quit_accels); @@ -176,7 +179,7 @@ gah_shomar_startup (GApplication *app) gtk_application_set_accels_for_action (GTK_APPLICATION (app), "win.today", today_accels); - +#endif builder = gtk_builder_new_from_resource ("/org/gahshomar/Gahshomar/app-menu.ui"); app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu")); gtk_application_set_app_menu (GTK_APPLICATION (app), app_menu); diff --git a/src/python/gahshomar/Makefile.am b/src/python/gahshomar/Makefile.am index e153474..b2de246 100644 --- a/src/python/gahshomar/Makefile.am +++ b/src/python/gahshomar/Makefile.am @@ -4,7 +4,6 @@ appdir = $(pythondir)/gahshomar/ app_PYTHON = \ calendar.py \ - indicator.py \ __init__.py \ settings_page.py \ widgets.py \ diff --git a/src/python/gahshomar/indicator.py b/src/python/gahshomar/indicator.py deleted file mode 100644 index 7738454..0000000 --- a/src/python/gahshomar/indicator.py +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/env python3 -# -*- Mode: Python; coding: utf-8; indent-tabs-mode: s; tab-width: 4 -*- -# -# Copyright (C) 2014 Amir Mohammadi <183.amir@gmail.com> -# -# Gahshomar is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Gahshomar is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . - -import datetime -from gettext import gettext as _ -import logging -logger = logging.getLogger(__name__) - -from gi.repository import Gtk, GObject, Gio, GLib -import gahshomar.khayyam as khayyam - - -class Indicator(GObject.GObject): - def __init__(self, app=None): - super().__init__() - try: - from gi.repository import AppIndicator3 as appindicator - except ImportError: - logger.exception(ImportError) - return - - self.date = datetime.date.today() - self.app = app - - self.settings = Gio.Settings.new('org.gahshomar.Gahshomar') - self.date_format = str(self.settings.get_value('persian-date-format')) - self.date_format = self.date_format.replace("'", "") - - self.ind = appindicator.Indicator.new( - "GahShomar-indicator", - 'gahshomar', - appindicator.IndicatorCategory.APPLICATION_STATUS) - self.ind.set_status(appindicator.IndicatorStatus.ACTIVE) - - self.menu_setup() - self.update() - - GLib.timeout_add_seconds(5, self.update) - - def menu_setup(self): - self.menu = Gtk.Menu() - self.menu.set_halign(Gtk.Align.CENTER) - - self.today_item = Gtk.MenuItem(_('Today')) - self.today_item.connect("activate", self.activate) - self.today_item.show() - - self.quit_item = Gtk.MenuItem(_('Quit')) - self.quit_item.connect("activate", self.quit) - self.quit_item.show() - - self.menu.append(self.today_item) - self.menu.append(self.quit_item) - self.ind.set_menu(self.menu) - - def get_date_formatted(self, frmt=None): - if frmt is None: - frmt = self.date_format - text = khayyam.JalaliDate.from_date(self.date).strftime(frmt) - if text[0] == '0' or text[0] == '۰': - text = text[1:] - return text - - def quit(self, widget): - self.app.quit() - - def update(self): - self.date = datetime.date.today() - self.today_item.set_label(_(self.get_date_formatted())) - self.ind.set_label(_(self.get_date_formatted('%d')), _('Gahshomar')) - - # make sure to return True so that it keeps updating - return True - - def activate(self, *args): - self.app.do_activate() diff --git a/src/python/gahshomar/settings_page.py b/src/python/gahshomar/settings_page.py index 655f4b1..999a72b 100644 --- a/src/python/gahshomar/settings_page.py +++ b/src/python/gahshomar/settings_page.py @@ -85,7 +85,7 @@ class SettingsWindow(Gtk.Dialog): """docstring for SettingsWindow""" @log def __init__(self, app): - super().__init__(title=_('Gahshomar Preferences'), use_header_bar=True) + super().__init__(title=_('Gahshomar Preferences')) self.app = app self.set_position(Gtk.WindowPosition.CENTER_ON_PARENT) self.resize(600, 480) diff --git a/src/python/gahshomar/widgets.py b/src/python/gahshomar/widgets.py index 88f5c3c..013d20b 100644 --- a/src/python/gahshomar/widgets.py +++ b/src/python/gahshomar/widgets.py @@ -21,8 +21,8 @@ logger = logging.getLogger(__name__) from gi.repository import Gtk, GLib, Gio -import khayyam +from . import khayyam from .calendar import PersianCalendar, GeorgianCalendar, \ add_months, add_years from . import log @@ -189,14 +189,32 @@ def __init__(self, date=None, rtl=None, app=None): self.MonthMenuButton = self.ui.get_object('MonthMenuButton') self.MonthMenuButton.set_size_request(150, -1) self.MonthMenuButton.connect('toggled', self.display_months) + self.MonthLabel = self.ui.get_object('MonthLabel') try: self.popover = Gtk.Popover.new(self.MonthMenuButton) + self.MonthMenuButton.set_popover(self.popover) + self.popover.add(self.months_widget) except AttributeError: - logger.error(_('You need at least Gtk 3.12!'), exc_info=True) - self.MonthMenuButton.set_popover(self.popover) - self.popover.add(self.months_widget) - - self.MonthLabel = self.ui.get_object('MonthLabel') + logger.warn(_('You need at least Gtk 3.12 for cool ui features!')) + # create a button + self.MonthButton = Gtk.Button(relief=Gtk.ReliefStyle.NORMAL) + self.MonthButton.set_size_request(150, -1) + self.MonthLabel = Gtk.Label() + self.MonthButton.set_image(self.MonthLabel) + self.MonthButton.connect('clicked', self.display_months) + # remove the menu button + self.ui.get_object('MonthYearHeader').remove(self.MonthMenuButton) + self.MonthMenuButton.destroy() + self.MonthMenuButton = None + # add button instead + self.ui.get_object('MonthYearHeader').pack_start(self.MonthButton, + False, False, 0) + self.popover = Gtk.Window( + transient_for=self.app._window, + window_position=Gtk.WindowPosition.MOUSE, + modal=True, + decorated=False) + self.popover.add(self.months_widget) self.YearEntry = self.ui.get_object('YearEntry') self.YearEntry.set_alignment(0.5) @@ -295,10 +313,14 @@ def year_arrow_pressed(self, year_entry, icon_pos, event): @log def display_months(self, *args): - if self.MonthMenuButton.get_active(): - self.popover.show_all() + if self.MonthMenuButton is not None: + if self.MonthMenuButton.get_active(): + self.popover.show_all() + else: + self.popover.hide() else: - self.popover.hide() + self.popover.show_all() + # win = Gtk.Window(Gtk.WindowType.TOPLEVEL) # POPUP or TOPLEVEL # win.set_transient_for(self.parent) # months = self.MonthWidget(date) diff --git a/src/python/gahshomar/window.py b/src/python/gahshomar/window.py index f4e76e2..6d86de1 100644 --- a/src/python/gahshomar/window.py +++ b/src/python/gahshomar/window.py @@ -30,10 +30,11 @@ class Window(Gtk.ApplicationWindow): @log def __init__(self, app): - self.app = app Gtk.ApplicationWindow.__init__(self, application=app, title=_("Gahshomar")) + self.app = app + self.app._window = self self.date = datetime.date.today() self.settings = Gio.Settings.new('org.gahshomar.Gahshomar') self.set_size_request(200, 100) @@ -119,11 +120,11 @@ def _setup_view(self): @log def setup_header_bar(self): hb_flag = bool(self.settings.get_value('header-bar')) + today_button = Gtk.Button(label=_('Today')) + self.today_button = today_button + today_button.set_action_name('win.today') if hb_flag: - today_button = Gtk.Button(label=_('Today')) - self.today_button = today_button - today_button.set_action_name('win.today') # set header bar self.hb = Gtk.HeaderBar() self.hb.props.title = _('Gahshomar') @@ -133,7 +134,7 @@ def setup_header_bar(self): self.set_titlebar(self.hb) else: toolbar = Gtk.Toolbar() - tb_today = Gtk.ToolButton(label=_('Today')) + tb_today = Gtk.ToolButton(icon_widget=today_button) tb_today.set_action_name('win.today') toolbar.add(tb_today) toolbar.show_all()