View Single Post
TrueJournals's Avatar
Posts: 480 | Thanked: 378 times | Joined on Apr 2008 @ Chicago-ish
#229
Originally Posted by Bundyo View Post
This part kinda worries me, since you're assigning 1 to goal in the beginning, you can remove at least half of the method
Yeah, it's a quick and dirty hack, really. The code needs some cleanup. But it works

[edit]Here's some cleaner code... I just hope I didn't remove anything I shouldn't have. It seems to work for me:
Code:
Index: src/drawer.vala
===================================================================
--- src/drawer.vala	(revision 43)
+++ src/drawer.vala	(working copy)
@@ -78,11 +78,27 @@
 			this.timer_pending = true;
 		}
 	}
+
+	public bool show_drawer ( ) {
+		return_if_fail( this != null );
 	
+		if (this.goal == 1)
+	   		return false;
+	
+		on_before_show();
+			
+		this.goal = 1;
+		if (this.timer_pending == false) {
+			this.timer_id = Timeout.add( this.period, on_timer );
+			this.timer_pending = true;
+		}
+		return false;
+	}
+	
 	public uint get_close_time() {
 		return_val_if_fail ( this != null, 0 );
 	
 		return this.period * ((uint)(1 / this.step) + 1);
 	}
 
-}
\ No newline at end of file
+}
Index: src/tearwebview.vala
===================================================================
--- src/tearwebview.vala	(revision 43)
+++ src/tearwebview.vala	(working copy)
@@ -31,13 +31,11 @@
 
 		this.clicking = false;
 		this.menudown = false;
-		this.redo_keydown = false;
 	}
 	
 	public bool on_webview_keydown (Tear.BrowserWindow bw, Gdk.EventKey ev) {
 		
 		this.menudown = false;
-		this.enterdown = false;
  
 		switch (ev.keyval) {
 			case Gdk.KeySyms.F4:
@@ -48,17 +46,13 @@
 				break;
 
 			case Gdk.KeySyms.Return:
-				if (!redo_keydown) {
-					this.enterdown = true;
-					entertime.get_current_time();
-					if (options.get_option( "wake_toolbar_shortcut_speed" ) == "short") {
-						last_keydown = ev;
-						return true;
-					}
-				} else 
-					redo_keydown = false;
+				if (options.get_option( "wake_toolbar_shortcut_speed" ) == "short")
+					GLib.Timeout.add( 500, bw.drawer.show_drawer );
+				else
+					GLib.Timeout.add( 1000, bw.drawer.show_drawer );
 				
 				break;
+				
 			case Gdk.KeySyms.Escape:
 				if (bw.web_view.can_go_back ())
 			    	bw.web_view.go_back ();
@@ -88,7 +82,7 @@
 
 	public bool on_webview_keyup (Tear.BrowserWindow bw, Gdk.EventKey ev) {
 		
-		if ((ev.keyval == Gdk.KeySyms.F4) || (ev.keyval == Gdk.KeySyms.Return)) {
+		if (ev.keyval == Gdk.KeySyms.F4) {
 			var newtime = TimeVal();
 			newtime.get_current_time();
 			
@@ -96,25 +90,7 @@
 				if ((newtime.tv_sec - menutime.tv_sec) < 1.0) 
 					program.get_common_menu().popup(null, null, MenuPosition, 0, get_current_event_time());
 
-			if (this.enterdown && options.get_option( "wake_toolbar_shortcut_speed" ) == "short") {
-				if ((newtime.tv_sec - entertime.tv_sec) < 0.7)
-					bw.drawer.set_goal( 1 );
-				else {
-					redo_keydown = true;
-					this.enterdown = false;
-					main_do_event( (Gdk.Event) last_keydown );
-				}
-			} else
-				if (this.enterdown && options.get_option( "wake_toolbar_shortcut_speed" ) == "long")
-					if ((newtime.tv_sec - entertime.tv_sec) > 0.5) {
-						bw.drawer.set_goal( 1 );
-						this.menudown = false;
-						this.enterdown = false;
-						return true;
-					}
-
 			this.menudown = false;
-			this.enterdown = false;
 
 			if (DEBUG)
 				warning ( "keyup" );
__________________
Disclaimer: If a program I wrote doesn't work/breaks your tablet... It's not my fault
mcedit | Utility Calculators (WIP) | PyRDesktop
My Blog | Twitter

Last edited by TrueJournals; 2009-05-11 at 14:30.
 

The Following User Says Thank You to TrueJournals For This Useful Post: