grumblr 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/Changelog +7 -0
  2. data/VERSION +1 -1
  3. data/lib/grumblr/ui.rb +184 -113
  4. metadata +2 -2
data/Changelog CHANGED
@@ -1,6 +1,13 @@
1
+ version 2.1.0 (2009-09-08)
2
+
3
+ * Removed labels for more efficient estate usage.
4
+ * Moved markdown checkbox to common place.
5
+ * Reduced minimum (default) window size.
6
+
1
7
  version 2.0.1 (2009-08-26)
2
8
 
3
9
  * Added Changelog file.
10
+ * Added external VERSION
4
11
  * Tags support. Separated by either comma or space.
5
12
 
6
13
  version 2.0.0 (2009-08-24)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.1
1
+ 2.1.0
data/lib/grumblr/ui.rb CHANGED
@@ -14,19 +14,18 @@ module Grumblr
14
14
  super Gtk::Window::TOPLEVEL
15
15
 
16
16
  filename = File.join(Grumblr::DATA_ROOT, 'pixmaps', 'grumblr.svg')
17
- self.logo = Gdk::Pixbuf.new filename, 128, 128
18
-
19
- self.set_size_request 480, 360
20
- self.set_allow_shrink false
21
- self.set_title 'Grumblr'
22
-
23
- self.set_icon self.logo
24
- self.set_default_width $cfg.get(:window_width).to_i
25
- self.set_default_height $cfg.get(:window_height).to_i
26
- self.move $cfg.get(:window_x_pos).to_i, $cfg.get(:window_y_pos).to_i
27
- self.signal_connect(:destroy) { quit }
28
- self.signal_connect(:delete_event) { minimize }
29
- self.signal_connect(:check_resize) do |widget|
17
+ self.logo = Gdk::Pixbuf.new(filename, 128, 128)
18
+
19
+ set_size_request 440, 320
20
+ set_allow_shrink false
21
+ set_title 'Grumblr'
22
+ set_icon self.logo
23
+ set_default_width $cfg.get(:window_width).to_i
24
+ set_default_height $cfg.get(:window_height).to_i
25
+ move $cfg.get(:window_x_pos).to_i, $cfg.get(:window_y_pos).to_i
26
+ signal_connect(:destroy) { quit }
27
+ signal_connect(:delete_event) { minimize }
28
+ signal_connect(:check_resize) do |widget|
30
29
  x, y = widget.position
31
30
  w, h = widget.size
32
31
  $cfg.set :window_x_pos, x
@@ -67,66 +66,59 @@ module Grumblr
67
66
  #
68
67
  # Text page
69
68
  #
70
- @text_title = Gtk::Entry.new
71
-
72
- @format = Gtk::CheckButton.new '_markdown'
73
- @format.set_active $cfg.get(:format_markdown)
74
- @format.signal_connect(:toggled) do |widget|
75
- $cfg.set :format_markdown, widget.active?
76
- end
77
-
78
- label = Gtk::Label.new 'Body'
69
+ @text_title = Gtk::LabeledEntry.new 'Title (optional)'
79
70
 
80
- box = Gtk::HBox.new false, 8
81
- box.pack_start label, false
82
- box.pack_start @format, false
71
+ @text_body = Gtk::LabeledTextView.new 'Body'
83
72
 
84
73
  page = Gtk::VBox.new false, 4
85
74
  page.set_border_width 8
86
- page.pack_with_label 'Title (optional)', @text_title
87
- page.pack_start box, false
88
- page.pack_start multiline_entry(:text_body), true
75
+ page.pack_start @text_title, false
76
+ page.pack_start scrollable(@text_body), true
89
77
 
90
78
  @notebook.add_page_with_tab page, 'Text'
91
79
 
92
80
  #
93
81
  # Link page
94
82
  #
95
- @link_url = Gtk::Entry.new
96
- @link_name = Gtk::Entry.new
97
- link_description = multiline_entry :link_description
83
+ @link_url = Gtk::LabeledEntry.new 'URL'
84
+ @link_name = Gtk::LabeledEntry.new 'Name (optional)'
85
+ @link_description = Gtk::LabeledTextView.new 'Description (optional)'
86
+ scroll = Gtk::ScrolledWindow.new
87
+ scroll.set_shadow_type Gtk::SHADOW_IN
88
+ scroll.set_policy Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC
89
+ scroll.add @link_description
98
90
 
99
91
  page = Gtk::VBox.new false, 4
100
92
  page.set_border_width 8
101
- page.pack_with_label 'URL', @link_url
102
- page.pack_with_label 'Name (optional)', @link_name
103
- page.pack_with_label'Description (optional)', link_description, true
93
+ page.pack_start @link_url, false
94
+ page.pack_start @link_name, false
95
+ page.pack_start scroll, true
104
96
 
105
97
  @notebook.add_page_with_tab page, 'Link'
106
98
 
107
99
  #
108
100
  # Chat page
109
101
  #
110
- @chat_title = Gtk::Entry.new
111
- chat_conversation = multiline_entry :chat_conversation
102
+ @chat_title = Gtk::LabeledEntry.new 'Title (optional)'
103
+ @chat_conversation = Gtk::LabeledTextView.new 'Conversation'
112
104
 
113
105
  page = Gtk::VBox.new false, 4
114
106
  page.set_border_width 8
115
- page.pack_with_label 'Title (optional)', @chat_title
116
- page.pack_with_label 'Conversation', chat_conversation, true
107
+ page.pack_start @chat_title, false
108
+ page.pack_start scrollable(@chat_conversation), true
117
109
 
118
110
  @notebook.add_page_with_tab page, 'Chat'
119
111
 
120
112
  #
121
113
  # Quote page
122
114
  #
123
- @quote_source = Gtk::Entry.new
124
- quote_quote = multiline_entry :quote_quote
115
+ @quote_source = Gtk::LabeledEntry.new 'Source (optional)'
116
+ @quote_quote = Gtk::LabeledTextView.new 'Quote'
125
117
 
126
118
  page = Gtk::VBox.new false, 4
127
119
  page.set_border_width 8
128
- page.pack_with_label 'Quote', quote_quote, true
129
- page.pack_with_label 'Source (optional)', @quote_source
120
+ page.pack_start scrollable(@quote_quote), true
121
+ page.pack_start @quote_source, false
130
122
 
131
123
  @notebook.add_page_with_tab page, 'Quote'
132
124
 
@@ -137,17 +129,17 @@ module Grumblr
137
129
  filter.set_name "Images"
138
130
  filter.add_mime_type "image/*"
139
131
 
140
- @photo_source = Gtk::Entry.new
141
- @photo_click_through_url = Gtk::Entry.new
142
132
  photo_data = file_chooser_button :photo_data, filter
143
- photo_caption = multiline_entry :photo_caption
133
+ @photo_source = Gtk::LabeledEntry.new 'Source'
134
+ @photo_click_through_url = Gtk::LabeledEntry.new 'Link (optional)'
135
+ @photo_caption = Gtk::LabeledTextView.new 'Caption'
144
136
 
145
137
  page = Gtk::VBox.new false, 4
146
138
  page.set_border_width 8
147
- page.pack_with_label 'File', photo_data
148
- page.pack_with_label 'Source', @photo_source
149
- page.pack_with_label 'Caption', photo_caption, true
150
- page.pack_with_label 'Link (optional)', @photo_click_through_url
139
+ page.pack_start photo_data, false
140
+ page.pack_start @photo_source, false
141
+ page.pack_start scrollable(@photo_caption), true
142
+ page.pack_start @photo_click_through_url, false
151
143
 
152
144
  @notebook.add_page_with_tab page, 'Photo'
153
145
 
@@ -160,12 +152,12 @@ module Grumblr
160
152
  filter.add_mime_type "audio/*"
161
153
 
162
154
  audio_data = file_chooser_button :audio_data, filter
163
- audio_caption = multiline_entry :audio_caption
155
+ @audio_caption = Gtk::LabeledTextView.new 'Caption (optional)'
164
156
 
165
157
  page = Gtk::VBox.new false, 4
166
158
  page.set_border_width 8
167
- page.pack_with_label 'File', audio_data
168
- page.pack_with_label 'Caption (optional)', audio_caption, true
159
+ page.pack_start audio_data, false
160
+ page.pack_start scrollable(@audio_caption), true
169
161
 
170
162
  @notebook.add_page_with_tab page, 'Audio'
171
163
  end
@@ -173,8 +165,8 @@ module Grumblr
173
165
  #
174
166
  # Video page
175
167
  #
176
- @video_embed = Gtk::Entry.new
177
- video_caption = multiline_entry :video_caption
168
+ @video_embed = Gtk::LabeledEntry.new 'Embed code / YouTube link'
169
+ @video_caption = Gtk::LabeledTextView.new 'Caption (optional)'
178
170
 
179
171
  page = Gtk::VBox.new false, 4
180
172
  page.set_border_width 8
@@ -185,14 +177,14 @@ module Grumblr
185
177
  filter.add_mime_type "video/*"
186
178
 
187
179
  video_data = file_chooser_button :video_data, filter
188
- @video_title = Gtk::Entry.new
180
+ @video_title = Gtk::LabeledEntry.new 'Title (optional)'
189
181
 
190
- page.pack_with_label 'File', video_data
191
- page.pack_with_label 'Title (optional)', @video_title
182
+ page.pack_start video_data, false
183
+ page.pack_start @video_title, true
192
184
  end
193
185
 
194
- page.pack_with_label 'Embed code / YouTube link', @video_embed
195
- page.pack_with_label 'Caption (optional)', video_caption, true
186
+ page.pack_start @video_embed, false
187
+ page.pack_start scrollable(@video_caption), true
196
188
 
197
189
  @notebook.add_page_with_tab page, 'Video'
198
190
 
@@ -266,13 +258,21 @@ module Grumblr
266
258
  post
267
259
  end
268
260
 
269
- @tags = Gtk::Entry.new
270
-
261
+ @tags = Gtk::LabeledEntry.new 'space/comma separated tags'
262
+
263
+ @format = Gtk::CheckButton.new '_markdown'
264
+ @format.set_active $cfg.get(:format_markdown)
265
+ @format.signal_connect(:toggled) do |widget|
266
+ $cfg.set :format_markdown, widget.active?
267
+ end
268
+ format_box = Gtk::HBox.new false, 8
269
+ format_box.pack_start @format, false
270
+
271
271
  button_box = Gtk::HBox.new false, 4
272
272
  button_box.pack_start clear_button, false
273
273
  button_box.pack_start @private_button, false
274
- button_box.pack_start Gtk::Label.new('Tags'), false
275
274
  button_box.pack_start @tags, true
275
+ button_box.pack_start format_box, false
276
276
  button_box.pack_start submit_button, true
277
277
 
278
278
  ##
@@ -356,22 +356,6 @@ module Grumblr
356
356
  instance_variable_set "@#{name}", button
357
357
  end
358
358
 
359
- def multiline_entry(name)
360
- instance_variable_set "@#{name}", Gtk::TextBuffer.new
361
-
362
- view = Gtk::TextView.new
363
- view.set_buffer instance_variable_get("@#{name}")
364
- view.set_wrap_mode Gtk::TextTag::WRAP_WORD
365
- view.set_right_margin 5
366
- view.set_left_margin 5
367
-
368
- window = Gtk::ScrolledWindow.new
369
- window.set_shadow_type Gtk::SHADOW_IN
370
- window.set_policy Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC
371
- window.add view
372
- window.show_all
373
- end
374
-
375
359
  def reset_fields_for(fieldset, message_type)
376
360
  for key in fieldset[message_type]
377
361
  name = "@#{message_type}_#{key.gsub(/-/,'_')}"
@@ -388,6 +372,15 @@ module Grumblr
388
372
  end
389
373
  @tags.clear
390
374
  end
375
+
376
+ def scrollable(widget)
377
+ scroll = Gtk::ScrolledWindow.new
378
+ scroll.set_shadow_type Gtk::SHADOW_IN
379
+ scroll.set_policy Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC
380
+ scroll.add widget
381
+ scroll.show_all
382
+ end
383
+
391
384
  end
392
385
 
393
386
  class MessageDialog < Gtk::Dialog
@@ -561,50 +554,128 @@ module Grumblr
561
554
  end
562
555
  end
563
556
 
564
- class Gtk::Box
565
- def pack_with_label(text, widget, expand = false)
566
- label = Gtk::Label.new text, true
567
- label.set_alignment 0.0, 0.5
568
- label.set_mnemonic_widget widget
569
- self.pack_start label, false
570
- self.pack_start widget, expand
557
+
558
+ module Gtk
559
+
560
+ DARK = Gdk::Color.parse("#000000")
561
+ PALE = Gdk::Color.parse("#999999")
562
+
563
+ class Box
564
+ def pack_with_label(text, widget, expand = false)
565
+ label = Gtk::Label.new text, true
566
+ label.set_alignment 0.0, 0.5
567
+ label.set_mnemonic_widget widget
568
+ self.pack_start label, false
569
+ self.pack_start widget, expand
570
+ end
571
+ end
572
+
573
+ class CheckButton
574
+ def get_value
575
+ self.active?
576
+ end
571
577
  end
572
- end
573
578
 
574
- class Gtk::Entry
575
- alias :get_value :text
576
- def clear
577
- self.set_text ''
579
+ class ComboBox
580
+ alias :get_value :active_text
578
581
  end
579
- end
580
582
 
581
- module Gtk::FileChooser
582
- alias :get_value :filename
583
- alias :clear :unselect_all
584
- end
583
+ class Entry
584
+ alias :get_value :text
585
+ def clear
586
+ self.set_text ''
587
+ end
588
+ end
589
+
590
+ module FileChooser
591
+ alias :get_value :filename
592
+ alias :clear :unselect_all
593
+ end
585
594
 
586
- class Gtk::Notebook
587
- def add_page_with_tab(page, text)
588
- filename = File.join(Grumblr::DATA_ROOT, 'pixmaps', '%s.bmp' % text.downcase)
589
- icon = Gtk::Image.new filename
590
- icon.set_padding 2, 4
595
+ class Notebook
596
+ def add_page_with_tab(page, text)
597
+ filename = File.join(Grumblr::DATA_ROOT, 'pixmaps', '%s.bmp' % text.downcase)
598
+ icon = Gtk::Image.new filename
599
+ icon.set_padding 4, 0
591
600
 
592
- label = Gtk::Label.new '_' + text, true
593
- label.set_alignment 0.0, 0.5
594
- label.set_padding 4, 2
601
+ label = Gtk::Label.new '_' + text, true
602
+ label.set_alignment 0.0, 0.5
603
+ label.set_padding 2, 2
595
604
 
596
- box = Gtk::HBox.new false, 4
597
- box.pack_start icon, false
598
- box.pack_start label, true
599
- box.show_all
605
+ box = Gtk::HBox.new false, 2
606
+ box.pack_start icon, false
607
+ box.pack_start label, true
608
+ box.show_all
600
609
 
601
- self.append_page_menu page, box, label
610
+ self.append_page_menu page, box, label
611
+ end
602
612
  end
603
- end
604
613
 
605
- class Gtk::TextBuffer
606
- alias :get_value :get_text
607
- def clear
608
- self.set_text ''
614
+ class TextView
615
+ def get_value
616
+ self.buffer.get_text
617
+ end
618
+ def clear
619
+ self.buffer.set_text ''
620
+ end
609
621
  end
622
+
623
+ class LabeledEntry < Entry
624
+ def initialize(label)
625
+ @label = label
626
+ super()
627
+ self.modify_text Gtk::STATE_NORMAL, PALE
628
+ self.set_text @label
629
+ self.signal_connect(:focus_in_event) do |widget, type|
630
+ if widget.text == @label
631
+ widget.modify_text Gtk::STATE_NORMAL, DARK
632
+ widget.set_text ''
633
+ end
634
+ false
635
+ end
636
+ self.signal_connect(:focus_out_event) do |widget, type|
637
+ if widget.text == ''
638
+ widget.modify_text Gtk::STATE_NORMAL, PALE
639
+ widget.set_text @label
640
+ end
641
+ false
642
+ end
643
+ self.show
644
+ end
645
+ def get_value
646
+ value = self.text
647
+ value == @label ? "" : value
648
+ end
649
+ end
650
+
651
+ class LabeledTextView < TextView
652
+ def initialize(label)
653
+ @label = label
654
+ super()
655
+ self.set_wrap_mode Gtk::TextTag::WRAP_WORD
656
+ self.set_right_margin 5
657
+ self.set_left_margin 5
658
+ self.modify_text Gtk::STATE_NORMAL, PALE
659
+ self.buffer.set_text @label
660
+ self.signal_connect(:focus_in_event) do |widget, type|
661
+ if widget.buffer.text == @label
662
+ widget.modify_text Gtk::STATE_NORMAL, DARK
663
+ widget.buffer.set_text ''
664
+ end
665
+ false
666
+ end
667
+ self.signal_connect(:focus_out_event) do |widget, type|
668
+ if widget.buffer.text == ''
669
+ widget.modify_text Gtk::STATE_NORMAL, PALE
670
+ widget.buffer.set_text @label
671
+ end
672
+ false
673
+ end
674
+ end
675
+ def get_value
676
+ value = self.buffer.get_text
677
+ value == @label ? "" : value
678
+ end
679
+ end
680
+
610
681
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grumblr
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Philippov
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-27 00:00:00 +07:00
12
+ date: 2009-09-08 00:00:00 +07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency