groove-dl 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e5f1cc467445d9a7c2926f69fadbcf5f1ddfcd22
4
- data.tar.gz: b30745ec05b108fa8c7255545c4d2e1ccc2946c0
3
+ metadata.gz: 5028c609beb9b031385ea3eb3a68241a291e3267
4
+ data.tar.gz: 093121e998733df06134ac4de8bbcb91ea576a3f
5
5
  SHA512:
6
- metadata.gz: 35dcb71a4e8de94f7cb94ade9c7150eb8a6964d3578950f604436f5c33a4d54826037f6dc079c7f9a04641fdeb1a09419528bba47a5cd2b4279f7fd90dd45bcb
7
- data.tar.gz: a74c931a9db535e0c209d220a8626ca327f76b05d1bce47ea48808348893461861c9cf2176d960a8102ffe2a52bd3be9dd76009b5cbccccb0d9c3fc586d6b4e3
6
+ metadata.gz: 197f460fe260071fe4e11a4a8722eddfce7ea5aa269e164d115b457f91cb96333b197d994e9034e8750b5e4a259ca32118e9b1599eba0d16097cf58231820b5c
7
+ data.tar.gz: bad6b3830e84dd377831990aec0f505bae9d3cf7c937a78054a025ab9148697a1e51668902318363d6099a145cea3de86cd8172e9e19d9f976af4a97ac248fd5
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  coverage
3
3
  Gemfile.lock
4
4
  .ruby-version
5
+ groove-dl-*.gem
data/MANIFEST CHANGED
@@ -23,6 +23,7 @@ lib/groove-dl/widgets/download/book.rb
23
23
  lib/groove-dl/widgets/download/list/failed.rb
24
24
  lib/groove-dl/widgets/download/list/queue.rb
25
25
  lib/groove-dl/widgets/download/list/success.rb
26
+ lib/groove-dl/widgets/menu/success.rb
26
27
  lib/groove-dl/widgets/search/bar.rb
27
28
  lib/groove-dl/widgets/search/list.rb
28
29
  spec/groove-dl/cli_spec.rb
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  #Grooveshark song downloader
2
2
 
3
3
  [![Build Status](https://travis-ci.org/PierreRambaud/groove-dl.png?branch=master)](https://travis-ci.org/PierreRambaud/groove-dl)
4
+ [![Gem Version](https://badge.fury.io/rb/groove-dl.svg)](http://badge.fury.io/rb/groove-dl)
4
5
 
5
6
  ##Requirements
6
7
 
@@ -4,7 +4,9 @@
4
4
  require File.expand_path('../../lib/groove-dl', __FILE__)
5
5
 
6
6
  require 'gtk3'
7
+ require 'shellwords'
7
8
  require 'groove-dl/app'
9
+ require 'groove-dl/widgets/menu/success'
8
10
  require 'groove-dl/widgets/download/bar'
9
11
  require 'groove-dl/widgets/download/list/queue'
10
12
  require 'groove-dl/widgets/download/list/failed'
@@ -3,6 +3,7 @@ module GrooveDl
3
3
  # Bootstraper for the application
4
4
  class App < Gtk::Window
5
5
  def initialize
6
+ Gtk::Settings.default.gtk_button_images = true
6
7
  super
7
8
 
8
9
  client = Grooveshark::Client.new
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # GrooveDl version
3
3
  module GrooveDl
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
@@ -19,13 +19,21 @@ module GrooveDl
19
19
 
20
20
  download_box = Gtk::Box.new(:horizontal, 6)
21
21
 
22
- add_button = Gtk::Button.new(label: 'Add to queue',
23
- stock_id: Gtk::Stock::SAVE)
22
+ add_button = Gtk::Button.new(stock_id: Gtk::Stock::ADD)
24
23
 
25
24
  add_button.signal_connect('released') do
26
25
  l = window.find_by_name('download_list')
27
26
  l.store.clear
28
- l.create_model(window.find_by_name('search_list').selection)
27
+ search_list = window.find_by_name('search_list')
28
+ selected = {}
29
+ column_id = GrooveDl::Widgets::Search::List::COLUMN_ID
30
+ column_checkbox = GrooveDl::Widgets::Search::List::COLUMN_CHECKBOX
31
+ search_list.store.each do |_model, _path, iter|
32
+ next unless iter[column_checkbox]
33
+ selected[iter[column_id]] = search_list.data[iter[column_id]]
34
+ end
35
+
36
+ l.create_model(selected)
29
37
  end
30
38
 
31
39
  download_box.pack_start(add_button,
@@ -64,12 +72,13 @@ module GrooveDl
64
72
  concurrency_entry.text = value.to_s unless value == 0
65
73
  end
66
74
 
67
- download_button = Gtk::Button.new(label: 'Download',
68
- stock_id: Gtk::Stock::SAVE)
75
+ download_button = Gtk::Button.new(stock_id: Gtk::Stock::SAVE)
69
76
 
70
77
  download_button.signal_connect('released') do
78
+ download_list = window.find_by_name('download_list')
79
+ next if download_list.queue.zero?
71
80
  download_button.sensitive = false
72
- window.find_by_name('download_list').download
81
+ download_list.download
73
82
  end
74
83
 
75
84
  download_box.pack_start(download_button,
@@ -32,11 +32,15 @@ module GrooveDl
32
32
  @download_label.set_name('download_label')
33
33
  append_page(download_list, @download_label)
34
34
 
35
+ # Success menu
36
+ menu_success = Widgets::Menu::Success.new
37
+ menu_success.load(client, window)
38
+
35
39
  # Success list
36
40
  download_success_list =
37
41
  Widgets::Download::List::Success.new(:vertical, 6)
38
42
  download_success_list.set_name('download_success_list')
39
- download_success_list.load(client, window)
43
+ download_success_list.load(client, window, menu_success)
40
44
 
41
45
  @download_success_label = Gtk::Label.new(SUCCESS % 0)
42
46
  @download_success_label.set_name('download_success_label')
@@ -11,7 +11,7 @@ module GrooveDl
11
11
  attr_reader :store, :data
12
12
 
13
13
  COLUMN_PATH,
14
- COLUMN_REASON = *(0..2).to_a
14
+ COLUMN_REASON = *(0..1).to_a
15
15
 
16
16
  ##
17
17
  # Initialize widgets
@@ -8,10 +8,11 @@ module GrooveDl
8
8
  module List
9
9
  # Success tree
10
10
  class Success < Gtk::Box
11
- attr_reader :store, :data
11
+ attr_reader :store, :data, :treeview
12
12
 
13
13
  COLUMN_PATH,
14
14
  COLUMN_SIZE = *(0..1).to_a
15
+ RIGHT_CLICK = 3
15
16
 
16
17
  ##
17
18
  # Initialize widgets
@@ -19,7 +20,7 @@ module GrooveDl
19
20
  # @param [Grooveshark::Client] client Grooveshark client
20
21
  # @param [Gtk::Window] window Gtk app
21
22
  #
22
- def load(_client, _window)
23
+ def load(_client, _window, menu)
23
24
  @data = {}
24
25
  sw = Gtk::ScrolledWindow.new
25
26
  sw.shadow_type = Gtk::ShadowType::ETCHED_IN
@@ -28,12 +29,20 @@ module GrooveDl
28
29
  pack_start(sw, expand: true, fill: true, padding: 0)
29
30
 
30
31
  @store = Gtk::ListStore.new(String, String)
31
- treeview = Gtk::TreeView.new(@store)
32
- treeview.rules_hint = true
32
+ @treeview = Gtk::TreeView.new(@store)
33
+ @treeview.rules_hint = true
33
34
 
34
- sw.add(treeview)
35
+ @treeview.signal_connect('button_press_event') do |widget, event|
36
+ if event.is_a?(Gdk::EventButton) && event.button == RIGHT_CLICK
37
+ path, _model = widget.get_path_at_pos(event.x, event.y)
38
+ widget.selection.select_path(path)
39
+ menu.popup(nil, nil, event.button, event.time)
40
+ end
41
+ end
35
42
 
36
- add_columns(treeview)
43
+ sw.add(@treeview)
44
+
45
+ add_columns
37
46
  end
38
47
 
39
48
  ##
@@ -52,22 +61,20 @@ module GrooveDl
52
61
  ##
53
62
  # Add columns on the treeview element
54
63
  #
55
- # @param [Gtk::Treeview] treeview Treeview
56
- #
57
- def add_columns(treeview)
64
+ def add_columns
58
65
  renderer = Gtk::CellRendererText.new
59
66
  column = Gtk::TreeViewColumn.new('Path',
60
67
  renderer,
61
68
  'text' => COLUMN_PATH)
62
69
  column.fixed_width = 650
63
- treeview.append_column(column)
70
+ @treeview.append_column(column)
64
71
 
65
72
  renderer = Gtk::CellRendererText.new
66
73
  column = Gtk::TreeViewColumn.new('Size',
67
74
  renderer,
68
75
  'text' => COLUMN_SIZE)
69
76
  column.fixed_width = 100
70
- treeview.append_column(column)
77
+ @treeview.append_column(column)
71
78
  end
72
79
  end
73
80
  end
@@ -0,0 +1,32 @@
1
+ # -*- coding: utf-8 -*-
2
+ module GrooveDl
3
+ # Widgets components
4
+ module Widgets
5
+ # Download section
6
+ module Menu
7
+ # Success menu
8
+ class Success < Gtk::Menu
9
+ ##
10
+ # Initialize widgets
11
+ #
12
+ # @param [Grooveshark::Client] client Grooveshark client
13
+ # @param [Gtk::Window] window Gtk app
14
+ #
15
+ def load(_client, window)
16
+ item = Gtk::ImageMenuItem.new(stock_id: Gtk::Stock::OPEN)
17
+ item.signal_connect('activate') do
18
+ treeview = window.find_by_name('download_success_list').treeview
19
+ iter = treeview.selection.selected
20
+ Thread.new do
21
+ path = iter[Download::List::Queue::COLUMN_PATH]
22
+ system("gnome-open #{Shellwords.escape(path)}")
23
+ end
24
+ end
25
+
26
+ append(item)
27
+ show_all
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -19,7 +19,8 @@ module GrooveDl
19
19
 
20
20
  search_bar = Gtk::Entry.new
21
21
  search_bar.set_name('search_bar')
22
- search_bar.text = 'CruciAGoT'
22
+ search_bar.set_placeholder_text('Search...')
23
+
23
24
  search_box.pack_start(search_bar,
24
25
  expand: true,
25
26
  fill: true,
@@ -36,7 +37,18 @@ module GrooveDl
36
37
  fill: true,
37
38
  padding: 5)
38
39
 
39
- button = Gtk::Button.new(label: 'Search', stock_id: Gtk::Stock::FIND)
40
+ button = Gtk::Button.new(stock_id: Gtk::Stock::FIND)
41
+ button.set_name('search_button')
42
+ search_box.pack_start(button,
43
+ expand: false,
44
+ fill: false,
45
+ padding: 10)
46
+
47
+ pack_start(search_box,
48
+ expand: false,
49
+ padding: 10)
50
+
51
+ # Signals
40
52
  button.signal_connect('released') do
41
53
  @type = search_type.active_text
42
54
  @query = search_bar.text
@@ -52,14 +64,9 @@ module GrooveDl
52
64
  window.find_by_name('search_list').create_model(results)
53
65
  end
54
66
 
55
- search_box.pack_start(button,
56
- expand: false,
57
- fill: false,
58
- padding: 10)
59
-
60
- pack_start(search_box,
61
- expand: false,
62
- padding: 10)
67
+ search_bar.signal_connect('activate') do
68
+ button.signal_emit('released')
69
+ end
63
70
  end
64
71
  end
65
72
  end
@@ -8,13 +8,12 @@ module GrooveDl
8
8
  class List < Gtk::Box
9
9
  attr_reader :data
10
10
  attr_reader :store
11
- attr_reader :selection
12
11
 
13
- COLUMN_FIXED,
12
+ COLUMN_CHECKBOX,
14
13
  COLUMN_ID,
15
14
  COLUMN_NAME,
16
15
  COLUMN_AUTHOR,
17
- COLUMN_SONG = *(0..5).to_a
16
+ COLUMN_SONG = *(0..4).to_a
18
17
 
19
18
  ##
20
19
  # Initialize widgets
@@ -25,7 +24,6 @@ module GrooveDl
25
24
  def load(_client, _window)
26
25
  set_name('search_list')
27
26
 
28
- @selection = {}
29
27
  sw = Gtk::ScrolledWindow.new
30
28
  sw.shadow_type = Gtk::ShadowType::ETCHED_IN
31
29
  sw.set_policy(Gtk::PolicyType::AUTOMATIC, Gtk::PolicyType::AUTOMATIC)
@@ -56,7 +54,7 @@ module GrooveDl
56
54
  @data = {}
57
55
  data.each do |element|
58
56
  iter = @store.append
59
- iter[COLUMN_FIXED] = false
57
+ iter[COLUMN_CHECKBOX] = false
60
58
  if element.is_a?(Grooveshark::Song)
61
59
  @data[element.id.to_i] = element
62
60
  iter[COLUMN_ID] = element.id.to_i
@@ -86,9 +84,18 @@ module GrooveDl
86
84
 
87
85
  column = Gtk::TreeViewColumn.new('X',
88
86
  renderer,
89
- 'active' => COLUMN_FIXED)
87
+ 'active' => COLUMN_CHECKBOX)
90
88
  column.sizing = Gtk::TreeViewColumn::Sizing::FIXED
91
89
  column.fixed_width = 30
90
+ column.set_clickable(true)
91
+ column.signal_connect('clicked') do
92
+ @store.each do |_model, _path, iter|
93
+ fixed = iter[COLUMN_CHECKBOX]
94
+ fixed ^= 1
95
+ iter[COLUMN_CHECKBOX] = fixed
96
+ end
97
+ end
98
+
92
99
  treeview.append_column(column)
93
100
 
94
101
  renderer = Gtk::CellRendererText.new
@@ -134,11 +141,9 @@ module GrooveDl
134
141
  def fixed_toggled(model, path_str)
135
142
  path = Gtk::TreePath.new(path_str)
136
143
  iter = model.get_iter(path)
137
- fixed = iter[COLUMN_FIXED]
144
+ fixed = iter[COLUMN_CHECKBOX]
138
145
  fixed ^= 1
139
- iter[COLUMN_FIXED] = fixed
140
- @selection[iter[COLUMN_ID]] = @data[iter[COLUMN_ID]] if fixed
141
- @selection.delete(iter[COLUMN_ID]) unless fixed
146
+ iter[COLUMN_CHECKBOX] = fixed
142
147
  end
143
148
  end
144
149
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: groove-dl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre Rambaud
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-20 00:00:00.000000000 Z
11
+ date: 2015-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slop
@@ -197,6 +197,7 @@ files:
197
197
  - lib/groove-dl/widgets/download/list/failed.rb
198
198
  - lib/groove-dl/widgets/download/list/queue.rb
199
199
  - lib/groove-dl/widgets/download/list/success.rb
200
+ - lib/groove-dl/widgets/menu/success.rb
200
201
  - lib/groove-dl/widgets/search/bar.rb
201
202
  - lib/groove-dl/widgets/search/list.rb
202
203
  - spec/groove-dl/cli_spec.rb
@@ -231,3 +232,4 @@ signing_key:
231
232
  specification_version: 4
232
233
  summary: Download grooveshark songs.
233
234
  test_files: []
235
+ has_rdoc: