[Pkg-privacy-commits] [torbrowser-launcher] 14/476: testing to switch from python gtk to javascript gtk

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 13:21:18 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch debian
in repository torbrowser-launcher.

commit f4c87aa5de188d4a2dfcedb8394bbe95a9c9e9ab
Author: Micah Lee <micahflee at riseup.net>
Date:   Sun Feb 10 13:45:18 2013 -0800

    testing to switch from python gtk to javascript gtk
---
 .gitignore                                         |  49 ++-----
 MANIFEST                                           |   7 -
 MANIFEST.in                                        |   1 -
 Makefile.am                                        |  12 ++
 README                                             |  31 ++--
 autogen.sh                                         |  18 +++
 build_and_install.sh                               |  21 ---
 configure.ac                                       |   5 +
 setup.py                                           |  23 ---
 src/torbrowser-launcher                            | 126 ++++++++++++++++
 torbrowser-launcher                                | 162 ---------------------
 ...owser.desktop => torbrowser-launcher.desktop.in |   6 +-
 12 files changed, 185 insertions(+), 276 deletions(-)

diff --git a/.gitignore b/.gitignore
index 990f40d..a9c3171 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,39 +1,12 @@
-*.py[cod]
-
-# C extensions
-*.so
-
-# Packages
-*.egg
-*.egg-info
-dist
-deb_dist
-build
-eggs
-parts
-bin
-var
-sdist
-develop-eggs
-.installed.cfg
-lib
-lib64
-
-# Installer logs
-pip-log.txt
-
-# Unit test / coverage reports
-.coverage
-.tox
-nosetests.xml
-
-# Translations
-*.mo
-
-# Mr Developer
-.mr.developer.cfg
-.project
-.pydevproject
-
-# vim
+aclocal.m4
+autom4te.cache
+config.log
+config.status
+configure
+hello.desktop
+install-sh
+missing
+Makefile.in
+Makefile
+*.tar.xz
 *.swp
diff --git a/MANIFEST b/MANIFEST
deleted file mode 100644
index a265677..0000000
--- a/MANIFEST
+++ /dev/null
@@ -1,7 +0,0 @@
-# file GENERATED by distutils, do NOT edit
-README
-setup.py
-torbrowser-launcher
-misc/torbrowser.desktop
-misc/torbrowser32.xpm
-misc/torbrowser80.xpm
diff --git a/MANIFEST.in b/MANIFEST.in
deleted file mode 100644
index bfef1b4..0000000
--- a/MANIFEST.in
+++ /dev/null
@@ -1 +0,0 @@
-include misc/*
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..d42b429
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,12 @@
+# The actual runnable program is set to the SCRIPTS primitive.
+# Prefix bin_ tells where to copy this
+bin_SCRIPTS = src/torbrowser-launcher
+
+# List of files to be distributed
+EXTRA_DIST=  \
+	$(bin_SCRIPTS)
+
+# The desktop files
+desktopdir = $(datadir)/applications
+desktop_DATA = \
+	torbrowser-launcher.desktop
diff --git a/README b/README
index 8134c5d..8541696 100644
--- a/README
+++ b/README
@@ -7,32 +7,19 @@ When you first launch Tor Browser Launcher, it will download TBB from https://ww
 
 Tor Browser Launcher will get updated each time a new version of TBB is released. When you open Tor Browser after an update, it will download the newer version of TBB for you and extract it over your old TBB directory in ~/.torproject, so you will maintain your TBB bookmarks. 
 
-Building a Debian package
-=========================
+Build Instructions
+==================
 
-You need to have stdeb installed. If you're using Debian or Ubuntu you can install it like this:
+To build and install this program:
 
-  sudo apt-get install python-stdeb
+./autogen.sh --prefix=$HOME/.local
+make install
 
-Here are other things you might need:
+To uninstall, type:
 
-  sudo apt-get install build-essential dpkg-dev debhelper devscripts fakeroot cdbs
+make uninstall
 
-First build a source distribution:
+To create a tarball:
 
-  python setup.py sdist
-
-Turn it into a Debian source package:
-
-  cd dist
-  py2dsc torbrowser-launcher-2.3.25-2-1.tar.gz
-
-Turn it into a Debian binary package:
-
-  cd deb_dist/torbrowser-launcher-2.3.25-2-1
-  dpkg-buildpackage -rfakeroot -uc -us
-
-Once you've made a .deb, you can install it like this:
-
-  sudo dpkg -i python-torbrowser-launcher_2.3.25-2-1-1_all.deb
+make distcheck
 
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..cb2570e
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+set -e
+
+test -n "$srcdir" || srcdir=`dirname "$0"`
+test -n "$srcdir" || srcdir=.
+
+olddir=`pwd`
+cd "$srcdir"
+
+# This will run autoconf, automake, etc. for us
+autoreconf --force --install
+
+cd "$olddir"
+
+if test -z "$NOCONFIGURE"; then
+  "$srcdir"/configure "$@"
+fi
diff --git a/build_and_install.sh b/build_and_install.sh
deleted file mode 100755
index c400dc0..0000000
--- a/build_and_install.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/sh
-
-# clean up from last time
-rm -rf ~/.torbrowser
-
-# build source dist
-python setup.py sdist
-
-# turn it into a debian source package
-cd dist
-py2dsc torbrowser-launcher-2.3.25-2-1.tar.gz
-
-# turn it into a debian binary package
-cd deb_dist/torbrowser-launcher-2.3.25-2-1
-dpkg-buildpackage -rfakeroot -uc -us
-
-# install it
-cd ..
-sudo dpkg -i python-torbrowser-launcher_2.3.25-2-1-1_all.deb
-cd ../..
-
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..83b2da2
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,5 @@
+# This file is processed by autoconf to create a configure script
+AC_INIT([Tor Browser Launcher], 1.0)
+AM_INIT_AUTOMAKE([1.10 no-define foreign dist-xz no-dist-gzip])
+AC_CONFIG_FILES([Makefile torbrowser-launcher.desktop])
+AC_OUTPUT
diff --git a/setup.py b/setup.py
deleted file mode 100644
index eecc01d..0000000
--- a/setup.py
+++ /dev/null
@@ -1,23 +0,0 @@
-from distutils.core import setup
-
-setup(name='torbrowser-launcher',
-      version='2.3.25-2-1',
-      author='Micah Lee',
-      author_email='micahflee at riseup.net',
-      url='https://www.github.com/micahflee/torbrowser-launcher',
-      platforms=['GNU/Linux'],
-      license='GPLv3',
-
-      description='A program to help you download, keep updated, and run the Tor Browser Bundle',
-      long_description="""
-Tor Browser Launcher is intended to make the Tor Browser Bundle (TBB) easier to maintain and use for GNU/Linux users. You install torbrowser-launcher from your distribution's package manager and it handles downloading the most recent version of TBB for you, in your language and for your architecture. It also adds a "Tor Browser" application launcher to your operating system's menu.
-
-When you first launch Tor Browser Launcher, it will download TBB from https://www.torproject.org/ and extract it in ~/.torproject, and then execute it. When you run it after that it will just execute TBB.
-
-Tor Browser Launcher will get updated each time a new version of TBB is released. When you open Tor Browser after an update, it will download the newer version of TBB for you and extract it over your old TBB directory in ~/.torproject, so you will maintain your TBB bookmarks. 
-""",
-
-      scripts=['torbrowser-launcher'],
-      data_files=[('/usr/share/applications', ['misc/torbrowser.desktop']),
-                  ('/usr/share/pixmaps', ['misc/torbrowser32.xpm', 'misc/torbrowser80.xpm'])]
-      )
diff --git a/src/torbrowser-launcher b/src/torbrowser-launcher
new file mode 100755
index 0000000..d950b02
--- /dev/null
+++ b/src/torbrowser-launcher
@@ -0,0 +1,126 @@
+#!/usr/bin/gjs
+
+const Gtk = imports.gi.Gtk;
+const GLib = imports.gi.GLib;
+const Lang = imports.lang;
+
+const TorBrowserLauncher = new Lang.Class({
+  Name: 'Tor Borwser Launcher',
+
+  // create the application
+  _init: function() {
+    this.application = new Gtk.Application();
+
+    // connect 'activate' and 'startup' signals to the callback functions
+    this.application.connect('activate', Lang.bind(this, function(){
+      this._window.present();
+    }));
+    this.application.connect('startup', Lang.bind(this, function(){
+      this.build_ui();
+    }));
+  },
+
+  // build the application's UI
+  build_ui: function() {
+
+    // create the application window
+    this._window = new Gtk.ApplicationWindow({
+      application: this.application,
+      window_position: Gtk.WindowPosition.CENTER,
+      border_width: 10,
+      title: "Tor Browser Launcher"
+    });
+
+    // create the Grid
+    this._grid = new Gtk.Grid ({
+      row_spacing: 20,
+      column_spacing: 20
+    });
+
+    // the label
+    this._label = new Gtk.Label({
+      label: 
+        "The first time you run the Tor Browser Launcher you \n"+
+        "need to download the Tor Browser Bundle. Would you \n"+
+        "like to download it from the following URL now?"
+    });
+
+    // progress bar
+    this._progress_bar = new Gtk.ProgressBar({
+      orientation: Gtk.Orientation.HORIZONTAL
+    });
+
+    // buttons
+    this._button_download = new Gtk.Button({
+      label: "Download"
+    });
+    this._button_exit = new Gtk.Button({
+      label: "Exit"
+    });
+    this._button_exit.connect('clicked', Lang.bind (this, function(){
+      this._window.destroy();
+    }));
+
+    // attach everything to the grid
+    this._grid.attach(this._label, 0, 0, 2, 1);
+    this._grid.attach(this._progress_bar, 0, 1, 2, 1);
+    this._grid.attach(this._button_download,  0, 2, 1, 1);
+    this._grid.attach(this._button_exit, 1, 2, 1, 1);
+
+    // add the grid to the window
+    this._window.add (this._grid);
+    this._window.show_all();
+  }
+});
+
+// initialize filesystem
+let tbb_version = '2.3.25-2';
+
+// get the architecture
+let[res, out] = GLib.spawn_sync(null, ['arch'], null, GLib.SpawnFlags.SEARCH_PATH, null);
+let architecture = (''+out).replace(/\s+/g, '');
+
+// figure out the language
+let available_languages = { 'en-US': true, 'ar': true, 'de': true, 'es-ES': true, 'fa': true, 'fr': true, 'it': true, 'ko': true, 'nl': true, 'pl': true, 'pt-PT': true, 'ru': true, 'vi': true, 'zh-CN': true};
+let language = GLib.getenv('LANG').split('.')[0].replace('_', '-');
+if(!available_languages[language]) {
+  language = language.split('-')[0];
+  if(!available_languages[language]) {
+    for(let i in available_languages) {
+      if(language.substring(0, 2) == available_languages[i]) {
+        language = available_languages[i];
+      }
+    }
+  }
+}
+// if language isn't available, default to english
+if(!available_languages[language]) {
+  language = 'en-US';
+}
+
+// make sure local directory structure is setup
+var data_dir = GLib.getenv('HOME')+'/.torbrowser';
+var download_dir = data_dir+'/download';
+var tbb_dir = data_dir+'/tbb/'+architecture+'/'+language;
+if(!GLib.file_test(download_dir, GLib.FileTest.EXISTS)) {
+  print('Making '+download_dir);
+  GLib.mkdir_with_parents(download_dir, 0x1c0); // 0x1c0 is 0700
+}
+if(!GLib.file_test(tbb_dir, GLib.FileTest.EXISTS)) {
+  print('Making '+tbb_dir);
+  GLib.mkdir_with_parents(tbb_dir, 0x1c0);
+}
+
+// is TBB already installed?
+var tbb_start = tbb_dir+'/start-tor-browser'
+if(GLib.file_test(tbb_start, GLib.FileTest.IS_EXECUTABLE)) {
+  print('Launching '+tbb_start);
+  GLib.spawn_sync(null, [tbb_start], null, GLib.SpawnFlags.SEARCH_PATH, null);
+} else {
+  // run the application
+  let app = new TorBrowserLauncher();
+  app.application.run(ARGV);
+}
+
+print('Tor Browser Launcher exiting');
+
diff --git a/torbrowser-launcher b/torbrowser-launcher
deleted file mode 100755
index 2b6d38c..0000000
--- a/torbrowser-launcher
+++ /dev/null
@@ -1,162 +0,0 @@
-#!/usr/bin/env python
-
-import os, sys, subprocess, locale, urllib2, gobject
-
-import pygtk
-pygtk.require('2.0')
-import gtk
-
-def download_chunk(base):
-  # download 10kb a time
-  chunk = base.dl_response.read(10240)
-  base.dl_bytes_so_far += len(chunk)
-  base.tarball_file.write(chunk)
-
-  if not chunk:
-    base.tarball_file.close()
-    return False
-
-  percent = float(base.dl_bytes_so_far) / base.dl_total_size
-  base.progressbar.set_fraction(percent)
-  percent = round(percent*100, 2)
-  base.progressbar.set_text("Downloaded %d" % (percent) + '%')
-  
-  sys.stdout.write("Downloaded %d of %d bytes (%0.2f%%)\r" % (base.dl_bytes_so_far, base.dl_total_size, percent))
-
-  if base.dl_bytes_so_far >= base.dl_total_size:
-    sys.stdout.write('\n')
-
-  return True
-
-class Base:
-  def delete_event(self, widget, event, data=None):
-    return False
-  
-  def destroy(self, widget, data=None):
-    if self.timer:
-      gobject.source_remove(self.timer)
-    self.timer = False
-
-    gtk.main_quit()
-   
-  def start_download(self, widget, data=None):
-    print 'Starting to download '+self.tarball_url
-
-    # disable the download button
-    self.download.set_sensitive(False)
-
-    # initialize the progress bar
-    self.progressbar.set_fraction(0) 
-    self.progressbar.set_text('Downloaded 0%')
-    self.progressbar.show()
-
-    # start the download
-    self.dl_response = urllib2.urlopen(self.tarball_url);
-    
-    self.dl_total_size = self.dl_response.info().getheader('Content-Length').strip()
-    self.dl_total_size = int(self.dl_total_size)
-    self.dl_bytes_so_far = 0
-
-    # set a timer to download more chunks
-    self.timer = gobject.timeout_add(1, download_chunk, self)
-
-    # open a file to write to
-    self.tarball_file = open(self.tarball_path, 'w')
-      
-  def __init__(self, tbb_version, tarball_path, tarball_url):
-    self.timer = False
-
-    self.tbb_version = tbb_version
-    self.tarball_path = tarball_path
-    self.tarball_url = tarball_url
-
-    self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
-    self.window.set_title("Tor Browser Launcher - First Run")
-    self.window.set_border_width(10)
-    
-    self.window.connect("delete_event", self.delete_event)
-    self.window.connect("destroy", self.destroy)
-
-    self.box = gtk.VBox(False, 20)
-    self.window.add(self.box)
-
-    self.label = gtk.Label("The first time you run the Tor Browser Launcher you need to download the Tor Browser Bundle. Would you like to download it from the following URL now?\n\n"+self.tarball_url)
-    self.label.set_line_wrap(True)
-    self.box.pack_start(self.label, True, True, 0)
-    self.label.show()
-
-    self.progressbar = gtk.ProgressBar(adjustment=None)
-    self.progressbar.set_orientation(gtk.PROGRESS_LEFT_TO_RIGHT)
-    self.box.pack_start(self.progressbar, True, True, 0)
-
-    self.button_box = gtk.HButtonBox()
-    self.button_box.set_layout(gtk.BUTTONBOX_SPREAD)
-    self.box.pack_start(self.button_box, True, True, 0)
-    self.button_box.show()
-
-    self.download = gtk.Button("Download")
-    self.download.connect("clicked", self.start_download, None)
-    self.button_box.add(self.download)
-    self.download.show()
-
-    self.exit = gtk.Button("Exit")
-    self.exit.connect("clicked", self.destroy, None)
-    self.button_box.add(self.exit)
-    self.exit.show()
-
-    self.box.show()
-    self.window.show();
-  
-  def main(self):
-    gtk.main()
-
-if __name__ == "__main__":
-  # current TBB version
-  tbb_version = '2.3.25-2'
-
-  # figure out the architecture
-  architecture = subprocess.check_output(['arch']).strip('\n')
-
-  # figure out the language
-  available_languages = ['en-US', 'ar', 'de', 'es-ES', 'fa', 'fr', 'it', 'ko', 'nl', 'pl', 'pt-PT', 'ru', 'vi', 'zh-CN']
-  language = locale.getdefaultlocale()[0].replace('_', '-')
-  if language not in available_languages:
-    language = language.split('-')[0]
-    if language not in available_languages:
-      for l in available_languages:
-        if l[0:2] == language:
-          language = l
-  # if language isn't available, default to english
-  if language not in available_languages:
-    language = 'en-US'
-
-  # make sure local directory structure is setup
-  data_dir = os.getenv('HOME')+'/.torbrowser'
-  download_dir = data_dir+'/download'
-  tbb_dir = data_dir+'/tbb/'+architecture+'/'+language
-  if os.path.exists(download_dir) == False:
-    print 'making '+download_dir
-    os.makedirs(download_dir)
-  if os.path.exists(tbb_dir) == False:
-    print 'making '+tbb_dir
-    os.makedirs(tbb_dir)
-
-  # is TBB already installed?
-  tbb_start = tbb_dir+'/start-tor-browser'
-  if os.path.isfile(tbb_start):
-    print 'Launching '+tbb_start
-    subprocess.call([tbb_start])
-
-  else:
-    tarball_filename = 'tor-browser-gnu-linux-'+architecture+'-'+tbb_version+'-dev-'+language+'.tar.gz'
-    tarball_path = download_dir+'/'+tarball_filename
-    if os.path.exists(tarball_path):
-      # already downloaded
-      print 'Already downloaded'
-    else:
-      # launch downloader
-      #tarball_url = 'https://www.torproject.org/dist/torbrowser/linux/'+tarball_filename
-      tarball_url = 'http://127.0.0.1/'+tarball_filename
-      base = Base(tbb_version, tarball_path, tarball_url)
-      base.main()
-
diff --git a/misc/torbrowser.desktop b/torbrowser-launcher.desktop.in
similarity index 58%
copy from misc/torbrowser.desktop
copy to torbrowser-launcher.desktop.in
index ed40f2b..2508099 100644
--- a/misc/torbrowser.desktop
+++ b/torbrowser-launcher.desktop.in
@@ -1,9 +1,11 @@
 [Desktop Entry]
+Version=1.0
 Encoding=UTF-8
 Name=Tor Browser
 Comment=Launch the Tor Browser Bundle
-Exec=/usr/bin/torbrowser-launcher
+Exec=@prefix@/bin/torbrowser-launcher
+Icon=application-default-icon
 Terminal=false
 Type=Application
-Icon=/usr/share/pixmaps/torbrowser80.xpm
+StartupNotify=true
 Categories=Internet;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/torbrowser-launcher.git



More information about the Pkg-privacy-commits mailing list