summaryrefslogtreecommitdiff
path: root/dash
diff options
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2014-07-07 15:42:22 +0200
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2014-07-07 15:42:22 +0200
commitcd8e1f0becec21b5910a30dbed087d17d430e82d (patch)
tree557a3b0bc392835c85a4b9a3a5dd806a9048f0f7 /dash
parent9460abbb1c58d066d67568b9bc8ebb3220716113 (diff)
StandaloneDash: add support for parsing arguments and setting default scope
(bzr r3830.3.14)
Diffstat (limited to 'dash')
-rw-r--r--dash/StandaloneDash.cpp33
1 files changed, 28 insertions, 5 deletions
diff --git a/dash/StandaloneDash.cpp b/dash/StandaloneDash.cpp
index eedd1c2b8..c603abb59 100644
--- a/dash/StandaloneDash.cpp
+++ b/dash/StandaloneDash.cpp
@@ -36,7 +36,10 @@
#include "unity-shared/DashStyle.h"
#include "unity-shared/PanelStyle.h"
#include "unity-shared/ThumbnailGenerator.h"
-#include "UnityCore/GSettingsScopes.h"
+#include "unity-shared/UBusMessages.h"
+#include "unity-shared/UBusServer.h"
+#include <UnityCore/GSettingsScopes.h>
+#include <UnityCore/ScopeProxyInterface.h>
const unity::RawPixel WIDTH(1024);
const unity::RawPixel HEIGHT(768);
@@ -46,12 +49,14 @@ using namespace unity::dash;
class TestRunner
{
public:
- TestRunner(double scale)
- : scale_(scale)
+ TestRunner(std::string const& scope, double scale)
+ : scope_(scope)
+ , scale_(scale)
{}
static void InitWindowThread (nux::NThread* thread, void* InitData);
void Init ();
+ std::string scope_;
double scale_;
nux::Layout *layout;
};
@@ -72,6 +77,9 @@ void TestRunner::Init ()
nux::GetWindowThread()->SetLayout (layout);
nux::GetWindowCompositor().SetKeyFocusArea(view->default_focus());
+
+ unity::UBusServer().SendMessage(UBUS_PLACE_ENTRY_ACTIVATE_REQUEST,
+ g_variant_new("(sus)", scope_.c_str(), GOTO_DASH_URI, ""));
}
void TestRunner::InitWindowThread(nux::NThread* thread, void* InitData)
@@ -96,9 +104,24 @@ int main(int argc, char **argv)
unity::Settings settings;
unity::dash::Style dash_style;
unity::panel::Style panel_style;
- double scale = argc > 1 ? atof(argv[1]) : 1.0f;
- TestRunner *test_runner = new TestRunner(scale);
+ double scale = 1.0;
+ unity::glib::String scope;
+ unity::glib::Error err;
+
+ GOptionEntry args_parsed[] =
+ {
+ { "scope", 's', 0, G_OPTION_ARG_STRING, &scope, "The default scope ", "S" },
+ { "scaling-factor", 'f', 0, G_OPTION_ARG_DOUBLE, &scale, "The dash scaling factor", "F" },
+ { NULL }
+ };
+
+ std::shared_ptr<GOptionContext> ctx(g_option_context_new("Standalone Dash"), g_option_context_free);
+ g_option_context_add_main_entries(ctx.get(), args_parsed, NULL);
+ if (!g_option_context_parse(ctx.get(), &argc, &argv, &err))
+ std::cerr << "Got error when parsing arguments: " << err << std::endl;
+
+ TestRunner *test_runner = new TestRunner(scope.Str(), scale);
wt = nux::CreateGUIThread(TEXT("Unity Dash"),
WIDTH.CP(scale), HEIGHT.CP(scale),
0,