[haiku-commits] haiku: hrev47167 - src/apps/webpositive

  • From: jscipione@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 25 Apr 2014 02:05:05 +0200 (CEST)

hrev47167 adds 1 changeset to branch 'master'
old head: fd849a28d936a76e3e99c50426fa90e8791d2a45
new head: c620610b98ac26afed638fbccabee14d85dea41d
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=c620610+%5Efd849a2

----------------------------------------------------------------------------

c620610: WebPositive: Add support to show/hide bookmark bar
  
  Default is shown, a menu option in the View menu allows you to show
  or hide the bar.
  
  Also move the bookmark bar below the tab frame, it looks better
  here I think and matches other browsers (e.g. Firefox.)

                                     [ John Scipione <jscipione@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev47167
Commit:      c620610b98ac26afed638fbccabee14d85dea41d
URL:         http://cgit.haiku-os.org/haiku/commit/?id=c620610
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Fri Apr 25 00:02:31 2014 UTC

----------------------------------------------------------------------------

4 files changed, 68 insertions(+), 7 deletions(-)
src/apps/webpositive/BrowserWindow.cpp | 44 ++++++++++++++++++++++++++++--
src/apps/webpositive/BrowserWindow.h   | 10 +++++--
src/apps/webpositive/SettingsKeys.cpp  | 11 +++++++-
src/apps/webpositive/SettingsKeys.h    | 10 ++++++-

----------------------------------------------------------------------------

diff --git a/src/apps/webpositive/BrowserWindow.cpp 
b/src/apps/webpositive/BrowserWindow.cpp
index 0295c01..bbb2a91 100644
--- a/src/apps/webpositive/BrowserWindow.cpp
+++ b/src/apps/webpositive/BrowserWindow.cpp
@@ -5,7 +5,7 @@
  * Copyright (C) 2010 Stephan Aßmus <superstippi@xxxxxx>
  * Copyright (C) 2010 Michael Lotz <mmlr@xxxxxxxx>
  * Copyright (C) 2010 Rene Gollent <rene@xxxxxxxxxxx>
- * Copyright 2013 Haiku, Inc. All rights reserved.
+ * Copyright 2013-2014 Haiku, Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -101,6 +101,7 @@ enum {
        HOME                                                                    
        = 'home',
        GOTO_URL                                                                
        = 'goul',
        RELOAD                                                                  
        = 'reld',
+       SHOW_HIDE_BOOKMARK_BAR                                          = 
'shbb',
        CLEAR_HISTORY                                                           
= 'clhs',
 
        CREATE_BOOKMARK                                                         
= 'crbm',
@@ -572,6 +573,10 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* 
appSettings,
        menu = new BMenu(B_TRANSLATE("View"));
        menu->AddItem(new BMenuItem(B_TRANSLATE("Reload"), new BMessage(RELOAD),
                'R'));
+       // the label will be replaced with the appropriate text later on
+       fBookmarkBarMenuItem = new BMenuItem("Show/Hide bookmark bar",
+               new BMessage(SHOW_HIDE_BOOKMARK_BAR));
+       menu->AddItem(fBookmarkBarMenuItem);
        menu->AddSeparatorItem();
        menu->AddItem(new BMenuItem(B_TRANSLATE("Increase size"),
                new BMessage(ZOOM_FACTOR_INCREASE), '+'));
@@ -715,15 +720,23 @@ BrowserWindow::BrowserWindow(BRect frame, 
SettingsMessage* appSettings,
                .Add(toggleFullscreenButton, 0.0f)
        ;
 
+       fBookmarkBar = new BookmarkBar("Bookmarks", this, &bookmarkRef);
+       if (fAppSettings->GetValue(kSettingsShowBookmarkBar, true)) {
+               // We need to hide the bookmark bar and then show it again
+               // to save the setting and set the menu item label.
+               fBookmarkBar->Hide();
+               _ShowBookmarkBar(true);
+       } else
+               _ShowBookmarkBar(false);
+
        // Layout
        AddChild(BLayoutBuilder::Group<>(B_VERTICAL, 0.0)
 #if !INTEGRATE_MENU_INTO_TAB_BAR
                .Add(menuBarGroup)
 #endif
-               .Add(new BookmarkBar(B_TRANSLATE("Bookmarks"), this,
-                       &bookmarkRef))
                .Add(fTabManager->TabGroup())
                .Add(navigationGroup)
+               .Add(fBookmarkBar)
                .Add(fTabManager->ContainerView())
                .Add(findGroup)
                .Add(statusGroup)
@@ -917,6 +930,10 @@ BrowserWindow::MessageReceived(BMessage* message)
                        CurrentWebView()->Reload();
                        break;
 
+               case SHOW_HIDE_BOOKMARK_BAR:
+                       _ShowBookmarkBar(fBookmarkBar->IsHidden());
+                       break;
+
                case GOTO_URL:
                {
                        BString url;
@@ -1229,6 +1246,9 @@ BrowserWindow::MessageReceived(BMessage* message)
                                        fHomeButton->Show();
                                else
                                        fHomeButton->Hide();
+                       } else if (name == kSettingsShowBookmarkBar
+                               && message->FindBool("value", &flag) == B_OK) {
+                               _ShowBookmarkBar(flag);
                        }
                        break;
                }
@@ -2627,3 +2647,21 @@ BrowserWindow::_HandlePageSourceResult(const BMessage* 
message)
                alert->Go(NULL);
        }
 }
+
+
+void
+BrowserWindow::_ShowBookmarkBar(bool show)
+{
+       if (fBookmarkBar == NULL || fBookmarkBar->IsHidden() != show)
+               return;
+
+       fAppSettings->SetValue(kSettingsShowBookmarkBar, show);
+
+       fBookmarkBarMenuItem->SetLabel(show
+               ? B_TRANSLATE("Hide bookmark bar")
+               : B_TRANSLATE("Show bookmark bar"));
+       if (show)
+               fBookmarkBar->Show();
+       else
+               fBookmarkBar->Hide();
+}
diff --git a/src/apps/webpositive/BrowserWindow.h 
b/src/apps/webpositive/BrowserWindow.h
index a2d228f..3defae7 100644
--- a/src/apps/webpositive/BrowserWindow.h
+++ b/src/apps/webpositive/BrowserWindow.h
@@ -2,8 +2,7 @@
  * Copyright (C) 2007 Ryan Leavengood <leavengood@xxxxxxxxx>
  * Copyright (C) 2009 Maxime Simon <simon.maxime@xxxxxxxxx>
  * Copyright (C) 2010 Stephan Aßmus <superstippi@xxxxxx>
- *
- * All rights reserved.
+ * Copyright 2013-2014 Haiku, Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -48,6 +47,8 @@ class BStringView;
 class BTextControl;
 class BUrlContext;
 class BWebView;
+
+class BookmarkBar;
 class SettingsMessage;
 class TabManager;
 class URLInputGroup;
@@ -209,6 +210,8 @@ private:
                        void                            _HandlePageSourceResult(
                                                                        const 
BMessage* message);
 
+                       void                            _ShowBookmarkBar(bool 
show);
+
 private:
                        BMenu*                          fHistoryMenu;
                        int32                           
fHistoryMenuFixedItemCount;
@@ -266,6 +269,9 @@ private:
                        uint32                          fNewTabPolicy;
                        BString                         fStartPageURL;
                        BString                         fSearchPageURL;
+
+                       BMenuItem*                      fBookmarkBarMenuItem;
+                       BookmarkBar*            fBookmarkBar;
 };
 
 
diff --git a/src/apps/webpositive/SettingsKeys.cpp 
b/src/apps/webpositive/SettingsKeys.cpp
index c724682..1cb2a37 100644
--- a/src/apps/webpositive/SettingsKeys.cpp
+++ b/src/apps/webpositive/SettingsKeys.cpp
@@ -1,11 +1,18 @@
 /*
  * Copyright (C) 2010 Stephan Aßmus <superstippi@xxxxxx>
+ * Coptright 2014 Haiku, Inc. All rights reserved.
  *
- * All rights reserved. Distributed under the terms of the MIT License.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *             Stephan Aßmus, superstippi@xxxxxx
+ *             John Scipione, jscipione@xxxxxxxxx
  */
 
+
 #include "SettingsKeys.h"
 
+
 const char* kSettingsKeyDownloadPath = "download path";
 const char* kSettingsKeyShowTabsIfSinglePageOpen
        = "show tabs if single page open";
@@ -31,3 +38,5 @@ const char* kSettingsKeyProxyPort = "http proxy port";
 const char* kSettingsKeyUseProxyAuth = "use http proxy authentication";
 const char* kSettingsKeyProxyUsername = "http proxy username";
 const char* kSettingsKeyProxyPassword = "http proxy password";
+
+const char* kSettingsShowBookmarkBar = "show bookmarks bar";
\ No newline at end of file
diff --git a/src/apps/webpositive/SettingsKeys.h 
b/src/apps/webpositive/SettingsKeys.h
index 71a0999..21cbeb9 100644
--- a/src/apps/webpositive/SettingsKeys.h
+++ b/src/apps/webpositive/SettingsKeys.h
@@ -1,11 +1,17 @@
 /*
  * Copyright (C) 2010 Stephan Aßmus <superstippi@xxxxxx>
+ * Coptright 2014 Haiku, Inc. All rights reserved.
  *
- * All rights reserved. Distributed under the terms of the MIT License.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *             Stephan Aßmus, superstippi@xxxxxx
+ *             John Scipione, jscipione@xxxxxxxxx
  */
 #ifndef SETTINGS_KEYS_H
 #define SETTINGS_KEYS_H
 
+
 #include <SupportDefs.h>
 
 
@@ -31,4 +37,6 @@ extern const char* kSettingsKeyUseProxyAuth;
 extern const char* kSettingsKeyProxyUsername;
 extern const char* kSettingsKeyProxyPassword;
 
+extern const char* kSettingsShowBookmarkBar;
+
 #endif // SETTINGS_KEYS_H


Other related posts: