diff options
| author | Didier Roche <didier.roche@canonical.com> | 2010-06-07 12:20:59 +0200 |
|---|---|---|
| committer | Didier Roche <didier.roche@canonical.com> | 2010-06-07 12:20:59 +0200 |
| commit | c2609b6b468bc0765b4461598579483f0c6f2651 (patch) | |
| tree | 3c6619e865e4bb835147aa2b768fa4064c90294f | |
| parent | cc286ff738014c3ffd0134e3cef4211ed158f69e (diff) | |
| parent | 78a4d6e3f13753f96cf1cd1c0a401481fd942bf4 (diff) | |
Import upstream version 0.2.6upstream-0.2.6
(bzr r55.4.9)
94 files changed, 7030 insertions, 1704 deletions
@@ -1,5 +1,353 @@ # Generated by Makefile. Do not edit. +2010-06-03 Neil Jagdish Patel <neil.patel@canonical.com> + + Panel re-architcture + +2010-06-03 Neil Jagdish Patel <neil.patel@canonical.com> + + - Make show_unity in mutter show the window picker + - Home button should initiate on button-release + + modified: + targets/mutter/plugin.vala + unity-private/panel/panel-home-button.vala + +2010-06-03 Neil Jagdish Patel <neil.patel@canonical.com> + + - Add bits to enable testing of indicators independant of what's installed + - Add some unit tests for PanelIndicatorObjectEntryView + + added: + tests/unit/test-panel-indicator-object-entry-view.vala + modified: + .bzrignore + tests/unit/Makefile.am + tests/unit/test-unit.vala + unity-private/panel/panel-indicator-object-entry-view.vala + unity-private/unity-utils.c + vapi/indicator.vapi + +2010-06-03 Neil Jagdish Patel <neil.patel@canonical.com> + + - Make tests work + + modified: + .bzrignore + tests/ui/data/quicklist_controller_show_label.png + tests/ui/test-home-button.vala + tests/ui/test-quicklist.vala + tests/ui/test-ui.vala + unity-private/testing/test-utils.vala + +2010-06-03 Neil Jagdish Patel <neil.patel@canonical.com> + + Merge from trunk + +2010-06-03 Neil Jagdish Patel <neil.patel@canonical.com> + + Restore hilight on active menu entries + +2010-06-03 Neil Jagdish Patel <neil.patel@canonical.com> + + Scrolling support + +2010-06-02 Jay Taoko <jay.taoko@canonical.com> + + Merge + Work on indicator menu scrubbing + +2010-06-03 Mirco Müller <mirco.mueller@ubuntu.com> + + merged in branch unity.panel-home-button + +2010-06-03 Mirco Müller <mirco.mueller@ubuntu.com> + + finally made the added shell-interface-API work by adding/renaming the calls get_panel_height_foobar() and get_launcher_width_foobar() so they don't clash with what's already defined in unity/targets/mutter/main.c + +2010-06-02 Mirco Müller <mirco.mueller@ubuntu.com> + + added get_panel_height() to shell interface and implemented it for mutter-target and tests, used in PanelHomeButton + +2010-06-01 Mirco Müller <mirco.mueller@ubuntu.com> + + make sure the new test for the panel-home-button gets called + +2010-06-01 Mirco Müller <mirco.mueller@ubuntu.com> + + source files need to be specified in alphabetical order + +2010-06-01 Mirco Müller <mirco.mueller@ubuntu.com> + + added test for new panel-home-button + +2010-06-02 Jay Taoko <jay.taoko@canonical.com> + + Merge + +2010-06-02 Neil Jagdish Patel <neil.patel@canonical.com> + + - Make systray work + - Add background to panel, hack around bad asset + - Some extra clean-up + + removed: + unity-private/panel/panel-system-tray.vala + added: + unity-private/panel/panel-background.vala + modified: + unity-private/Makefile.am + unity-private/launcher/scroller-controller.vala + unity-private/panel/panel-menu-manager.vala + unity-private/panel/panel-tray.vala + unity-private/panel/panel-view.vala + +2010-06-02 Jay Taoko <jay.taoko@canonical.com> + + Indicator navigation with keyboard + Begin work on Indicator scrubbing with mouse + + [modified] + unity-private/panel/panel-indicator-bar.vala + unity-private/panel/panel-indicator-object-entry-view.vala + unity-private/panel/panel-indicator-object-view.vala + unity-private/panel/panel-menu-manager.vala + +2010-06-02 Jay Taoko <jay.taoko@canonical.com> + + Merged with neil panel work + +2010-06-02 Neil Jagdish Patel <neil.patel@canonical.com> + + Make the menubar rectangle transparent + +2010-06-02 Jay Taoko <jay.taoko@canonical.com> + + Start of work for showing the menu + +2010-06-02 Neil Jagdish Patel <neil.patel@canonical.com> + + - Make the MenuBar show the appmenu indicator + - Fix compile issue with mutter + + modified: + targets/mutter/plugin.vala + unity-private/panel/panel-indicator-bar.vala + unity-private/panel/panel-menubar.vala + +2010-06-02 Neil Jagdish Patel <neil.patel@canonical.com> + + - Add some basic appmenu support + - Remove unneeded code from panel-view + + modified: + unity-private/panel/panel-menubar.vala + unity-private/panel/panel-view.vala + +2010-06-02 Neil Jagdish Patel <neil.patel@canonical.com> + + - Gee.HashMap is unable to be sorted, which was an oversight on my behalf when + designing the API for the models. Hence I've made the 'get_indicator_list' + return an ordered list of Indicator.Object's and added a get_indicator_name + for the instances when the view needs to knoew the name of the object + (which I may add to libindicator itself sometime soon) + + - With the new API, I added support for ordering the list + + - Updated existing code to use new API and did some clean up of debug messages + + modified: + unity-private/panel/panel-indicator-bar.vala + unity-private/panel/panel-indicator-model.vala + unity-private/panel/panel-view.vala + +2010-06-02 Neil Jagdish Patel <neil.patel@canonical.com> + + Make targets us panel height from Unity.Panel.PANEL_HEIGHT + +2010-06-02 Neil Jagdish Patel <neil.patel@canonical.com> + + - Update indicator spacing + - Import work done to make indicator sizes better and the color of the entry + bg match the gtk theme + + modified: + unity-private/panel/panel-indicator-bar.vala + unity-private/panel/panel-indicator-object-entry-view.vala + unity-private/panel/panel-indicator-object-view.vala + +2010-06-02 Neil Jagdish Patel <neil.patel@canonical.com> + + - Bunch of fixes and cleanups + - Init and show home button, menubar and indicatorbar + - Start work on fixing padding of indicator bar + - Try and not override allocate + - Temporarily disable resizing the entry bg until we've figured out the cause + of the loop + + modified: + unity-private/panel/panel-home-button.vala + unity-private/panel/panel-indicator-bar.vala + unity-private/panel/panel-indicator-object-entry-view.vala + unity-private/panel/panel-indicator-object-view.vala + unity-private/panel/panel-menubar.vala + unity-private/panel/panel-system-tray.vala + unity-private/panel/panel-view.vala + +2010-06-01 Neil Jagdish Patel <neil.patel@canonical.com> + + Fix orientation + +2010-06-01 Jay Taoko <jay.taoko@canonical.com> + + Panel indicator cleanup + +2010-06-01 Jay Taoko <jay.taoko@canonical.com> + + Panel indicator + +2010-06-01 Jay Taoko <jay.taoko@canonical.com> + + fix from Neil + +2010-06-01 Neil Jagdish Patel <neil.patel@canonical.com> + + Remove public *void* FileIndicatorModel, as the void makes it mean something + else + + modified: + unity-private/panel/panel-indicator-model.vala + +2010-06-01 Jay Taoko <jay.taoko@canonical.com> + + Commit + +2010-06-01 Jay Taoko <jay.taoko@canonical.com> + + Adding additional files. + First attempt at rendering. + +2010-05-31 Jay Taoko <jay.taoko@canonical.com> + + Merge + +2010-05-31 Mirco Müller <mirco.mueller@ubuntu.com> + + panel-home-button added + +2010-05-31 Jay Taoko <jay.taoko@canonical.com> + + Panel indicator architecture + + [modified] + unity-private/panel/panel-indicator-object-entry-view.vala + + [added] + unity-private/panel/panel-menu-manager.vala + +2010-05-27 Neil Jagdish Patel <neil.patel@canonical.com> + + Work around libindicator weirdness + +2010-05-27 Jay Taoko <jay.taoko@canonical.com> + + Rearchitecture of panel indicator + + [added] + unity-private/panel/panel-indicator-model.vala + unity-private/panel/panel-indicator-object-entry-view.vala + unity-private/panel/panel-indicator-object-view.vala + +2010-06-02 Gord Allott <gord.allott@canonical.com> + + Updates the icon-rendering to the 10.10 cycle spec + + Modified: + unity-private/launcher/launcher-child.vala + - small value changes + unity-private/launcher/scroller-view.vala + - set icon spacing to 6 pixels and top padding to 10 pixels + unity/icon-postprocessor.vala + - updated to new icon rendering + +2010-06-02 Gord Allott <gord.allott@canonical.com> + + updated icon sizes to 50x50 to accomodate 1px transparent border + +2010-06-02 Gord Allott <gord.allott@canonical.com> + + updates icon rendering to the latest launcher spec + +2010-05-28 Gord Allott <gord.allott@canonical.com> + + stop trying to put items into -1 indexes on a list + +2010-05-28 Gord Allott <gord.allott@canonical.com> + + fixes small problem with expose ending triggered early. also removes a few debugs + +2010-05-28 Gord Allott <gord.allott@canonical.com> + + fix expose pre-maturely returning + +2010-05-27 Jay Taoko <jay.taoko@canonical.com> + + Merge + +2010-05-27 Neil Jagdish Patel <neil.patel@canonical.com> + + Bump version for next development cycle + +2010-05-27 Neil Jagdish Patel <neil.patel@canonical.com> + + [release] 0.2.4 + +2010-05-27 Jay Taoko <jay.taoko@canonical.com> + + UI Automation + + [modified] + tests/ui/Makefile.am + + tests/ui/test-ui.vala + - temporarily deactivated automation testing + + unity-private/panel/panel-indicators.vala + - disable the indicators with UNITY_PANEL_INDICATORS_SKIP="all" + + tests/ui/test-automate.vala + - Added timing mesure for animations + + unity-private/testing/test-director.vala + + [added] + tests/ui/test-automate.vala + - automation basic test + +2010-05-25 Jay Taoko <jay.taoko@canonical.com> + + UI Automation testing + + tests/ui/test-automate.vala + - Added timing mesure for animations + + tests/ui/test-ui.vala + - temporarily deactivated automation testing + +2010-05-07 Jay Taoko <jay.taoko@canonical.com> + + Unity Automation + + [modified] + tests/ui/Makefile.am + tests/ui/test-ui.vala + unity-private/panel/panel-indicators.vala + - disable the indicators with UNITY_PANEL_INDICATORS_SKIP="all" + unity-private/testing/test-director.vala + + [added] + tests/ui/test-automate.vala + - automation basic test + 2010-05-27 Neil Jagdish Patel <neil.patel@canonical.com> - Update bzr ignores @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.65 for unity 0.2.4. +# Generated by GNU Autoconf 2.65 for unity 0.2.6. # # Report bugs to <https://launchpad.net/unity>. # @@ -763,8 +763,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='unity' PACKAGE_TARNAME='unity' -PACKAGE_VERSION='0.2.4' -PACKAGE_STRING='unity 0.2.4' +PACKAGE_VERSION='0.2.6' +PACKAGE_STRING='unity 0.2.6' PACKAGE_BUGREPORT='https://launchpad.net/unity' PACKAGE_URL='' @@ -1569,7 +1569,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures unity 0.2.4 to adapt to many kinds of systems. +\`configure' configures unity 0.2.6 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1639,7 +1639,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of unity 0.2.4:";; + short | recursive ) echo "Configuration of unity 0.2.6:";; esac cat <<\_ACEOF @@ -1768,7 +1768,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -unity configure 0.2.4 +unity configure 0.2.6 generated by GNU Autoconf 2.65 Copyright (C) 2009 Free Software Foundation, Inc. @@ -2048,7 +2048,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by unity $as_me 0.2.4, which was +It was created by unity $as_me 0.2.6, which was generated by GNU Autoconf 2.65. Invocation command line was $ $0 $@ @@ -2875,7 +2875,7 @@ fi # Define the identity of the package. PACKAGE=unity - VERSION=0.2.4 + VERSION=0.2.6 cat >>confdefs.h <<_ACEOF @@ -2918,8 +2918,8 @@ am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' DL_MAJOR_VERSION=0 DL_MINOR_VERSION=2 -DL_MICRO_VERSION=4 -DL_VERSION=0.2.4 +DL_MICRO_VERSION=6 +DL_VERSION=0.2.6 @@ -13381,7 +13381,7 @@ MAINTAINER_CFLAGS="" MAINTAINER_VALAFLAGS="" if test "x$enable_maintainer_flags" = "xyes" && test "x$GCC" = "xyes"; then : - MAINTAINER_CFLAGS="-g -Werror -Wshadow -Wcast-align -Wno-uninitialized -Wempty-body -Wformat-security -Winit-self" + MAINTAINER_CFLAGS="-g -Werror -Wcast-align -Wno-uninitialized -Wempty-body -Wformat-security -Winit-self" MAINTAINER_VALAFLAGS="-g --save-temps" @@ -14451,7 +14451,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by unity $as_me 0.2.4, which was +This file was extended by unity $as_me 0.2.6, which was generated by GNU Autoconf 2.65. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -14517,7 +14517,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -unity config.status 0.2.4 +unity config.status 0.2.6 configured by $0, generated by GNU Autoconf 2.65, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 95ed54cff..27ddbe722 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ m4_define([unity_major], [0]) m4_define([unity_minor], [2]) -m4_define([unity_micro], [4]) +m4_define([unity_micro], [6]) m4_define([unity_api], [unity_major.unity_minor]) @@ -82,7 +82,7 @@ MAINTAINER_CFLAGS="" MAINTAINER_VALAFLAGS="" AS_IF([test "x$enable_maintainer_flags" = "xyes" && test "x$GCC" = "xyes"], [ - MAINTAINER_CFLAGS="-g -Werror -Wshadow -Wcast-align -Wno-uninitialized -Wempty-body -Wformat-security -Winit-self" + MAINTAINER_CFLAGS="-g -Werror -Wcast-align -Wno-uninitialized -Wempty-body -Wformat-security -Winit-self" MAINTAINER_VALAFLAGS="-g --save-temps" ] ) diff --git a/targets/mutter/expose-manager.c b/targets/mutter/expose-manager.c index d6f21b55c..eb6e6ace3 100644 --- a/targets/mutter/expose-manager.c +++ b/targets/mutter/expose-manager.c @@ -340,12 +340,16 @@ void unity_expose_clone_set_darken (UnityExposeClone* self, guint8 value) { static gboolean _unity_expose_clone_on_mouse_enter_clutter_actor_enter_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_expose_clone_on_mouse_enter (self, event); + gboolean result; + result = unity_expose_clone_on_mouse_enter (self, event); + return result; } static gboolean _unity_expose_clone_on_mouse_leave_clutter_actor_leave_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_expose_clone_on_mouse_leave (self, event); + gboolean result; + result = unity_expose_clone_on_mouse_leave (self, event); + return result; } @@ -511,7 +515,9 @@ static gboolean _lambda4_ (UnityExposeManager* self) { static gboolean __lambda4__clutter_actor_enter_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return _lambda4_ (self); + gboolean result; + result = _lambda4_ (self); + return result; } @@ -535,12 +541,16 @@ static gboolean _lambda5_ (UnityExposeManager* self) { static gboolean __lambda5__clutter_actor_leave_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return _lambda5_ (self); + gboolean result; + result = _lambda5_ (self); + return result; } static gboolean _unity_expose_manager_on_stage_captured_event_clutter_actor_captured_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_expose_manager_on_stage_captured_event (self, event); + gboolean result; + result = unity_expose_manager_on_stage_captured_event (self, event); + return result; } diff --git a/targets/mutter/plugin.c b/targets/mutter/plugin.c index a41779f1a..286cd5b56 100644 --- a/targets/mutter/plugin.c +++ b/targets/mutter/plugin.c @@ -214,7 +214,7 @@ enum { UNITY_PLUGIN_MENUS_SWALLOW_EVENTS, UNITY_PLUGIN_EXPOSE_SHOWING }; -#define UNITY_PLUGIN_PANEL_HEIGHT 23 +#define UNITY_PLUGIN_PANEL_HEIGHT 24 #define UNITY_PLUGIN_QUICKLAUNCHER_WIDTH 58 UnityWindowManagement* unity_window_management_new (UnityPlugin* p); UnityWindowManagement* unity_window_management_construct (GType object_type, UnityPlugin* p); @@ -284,6 +284,8 @@ static void _unity_plugin_topmost_size_changed_clutter_actor_allocation_changed void unity_plugin_topmost_changed (UnityPlugin* self, MutterWindow* old_window, MutterWindow* new_window); gint unity_plugin_get_panel_height (UnityPlugin* self); gint unity_plugin_get_launcher_width (UnityPlugin* self); +static gint unity_plugin_real_get_panel_height_foobar (UnityShell* base); +static gint unity_plugin_real_get_launcher_width_foobar (UnityShell* base); UnityPlugin* unity_plugin_new (void); UnityPlugin* unity_plugin_construct (GType object_type); void unity_plugin_set_plugin (UnityPlugin* self, MutterPlugin* value); @@ -468,7 +470,9 @@ static gboolean _lambda2_ (UnityPlugin* self) { static gboolean __lambda2__gsource_func (gpointer self) { - return _lambda2_ (self); + gboolean result; + result = _lambda2_ (self); + return result; } @@ -1066,10 +1070,7 @@ static void unity_plugin_real_show_unity (UnityShell* base) { UnityPlugin * self; self = (UnityPlugin*) base; if (self->priv->places_enabled == FALSE) { - WnckScreen* screen; - screen = _g_object_ref0 (wnck_screen_get_default ()); - wnck_screen_toggle_showing_desktop (screen, !wnck_screen_get_showing_desktop (screen)); - _g_object_unref0 (screen); + unity_shell_show_window_picker ((UnityShell*) self); return; } if (self->priv->places_showing) { @@ -1234,6 +1235,24 @@ gint unity_plugin_get_launcher_width (UnityPlugin* self) { } +static gint unity_plugin_real_get_panel_height_foobar (UnityShell* base) { + UnityPlugin * self; + gint result = 0; + self = (UnityPlugin*) base; + result = unity_plugin_get_panel_height (self); + return result; +} + + +static gint unity_plugin_real_get_launcher_width_foobar (UnityShell* base) { + UnityPlugin * self; + gint result = 0; + self = (UnityPlugin*) base; + result = unity_plugin_get_launcher_width (self); + return result; +} + + UnityPlugin* unity_plugin_construct (GType object_type) { UnityPlugin * self; self = g_object_newv (object_type, 0, NULL); @@ -1415,6 +1434,8 @@ static void unity_plugin_unity_shell_interface_init (UnityShellIface * iface) { iface->get_indicators_width = unity_plugin_real_get_indicators_width; iface->show_unity = unity_plugin_real_show_unity; iface->grab_keyboard = unity_plugin_real_grab_keyboard; + iface->get_panel_height_foobar = unity_plugin_real_get_panel_height_foobar; + iface->get_launcher_width_foobar = unity_plugin_real_get_launcher_width_foobar; iface->get_menus_swallow_events = unity_plugin_real_get_menus_swallow_events; } diff --git a/targets/mutter/plugin.vala b/targets/mutter/plugin.vala index 793370c0f..f5d0773ad 100644 --- a/targets/mutter/plugin.vala +++ b/targets/mutter/plugin.vala @@ -111,7 +111,7 @@ namespace Unity public bool expose_showing { get { return expose_manager.expose_showing; } } - private static const int PANEL_HEIGHT = 23; + private static const int PANEL_HEIGHT = 24; private static const int QUICKLAUNCHER_WIDTH = 58; private Clutter.Stage stage; @@ -688,9 +688,7 @@ namespace Unity { if (this.places_enabled == false) { - var screen = Wnck.Screen.get_default (); - - screen.toggle_showing_desktop (!screen.get_showing_desktop ()); + show_window_picker (); return; } if (this.places_showing) @@ -862,12 +860,25 @@ namespace Unity public int get_panel_height () { - return PANEL_HEIGHT; + return this.PANEL_HEIGHT; } public int get_launcher_width () { - return QUICKLAUNCHER_WIDTH; + return this.QUICKLAUNCHER_WIDTH; + } + + /* this is needed to avoid a symbol clash in unity/targets/mutter/main.c */ + public int get_panel_height_foobar () + { + return this.get_panel_height (); } + + /* this is needed to avoid a symbol clash in unity/targets/mutter/main.c */ + public int get_launcher_width_foobar () + { + return this.get_launcher_width (); + } + } } diff --git a/targets/mutter/window-management.c b/targets/mutter/window-management.c index 13fb7db3e..d6608c2a4 100644 --- a/targets/mutter/window-management.c +++ b/targets/mutter/window-management.c @@ -457,7 +457,9 @@ static gboolean unity_window_management_force_activate (UnityWindowManagement* s static gboolean _unity_window_management_force_activate_gsource_func (gpointer self) { - return unity_window_management_force_activate (self); + gboolean result; + result = unity_window_management_force_activate (self); + return result; } diff --git a/targets/unity/main.c b/targets/unity/main.c index 6eb769864..509b28008 100644 --- a/targets/unity/main.c +++ b/targets/unity/main.c @@ -114,7 +114,9 @@ static gboolean _lambda0_ (void) { static gboolean __lambda0__gsource_func (gpointer self) { - return _lambda0_ (); + gboolean result; + result = _lambda0_ (); + return result; } diff --git a/tests/ui/Makefile.am b/tests/ui/Makefile.am index fc1ef5a18..27218ae1f 100644 --- a/tests/ui/Makefile.am +++ b/tests/ui/Makefile.am @@ -47,6 +47,8 @@ test_ui_VALAFLAGS = \ $(MAINTAINER_VALAFLAGS) test_ui_SOURCES = \ + test-automate.vala \ + test-home-button.vala \ test-quicklist.vala \ test-ui.vala diff --git a/tests/ui/Makefile.in b/tests/ui/Makefile.in index 31318d592..445aeddf8 100644 --- a/tests/ui/Makefile.in +++ b/tests/ui/Makefile.in @@ -37,7 +37,8 @@ host_triplet = @host@ noinst_PROGRAMS = test-ui$(EXEEXT) subdir = tests/ui DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - test-quicklist.c test-ui.c test_ui_vala.stamp + test-automate.c test-home-button.c test-quicklist.c test-ui.c \ + test_ui_vala.stamp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \ $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \ @@ -55,8 +56,9 @@ CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = PROGRAMS = $(noinst_PROGRAMS) -am_test_ui_OBJECTS = test_ui-test-quicklist.$(OBJEXT) \ - test_ui-test-ui.$(OBJEXT) +am_test_ui_OBJECTS = test_ui-test-automate.$(OBJEXT) \ + test_ui-test-home-button.$(OBJEXT) \ + test_ui-test-quicklist.$(OBJEXT) test_ui-test-ui.$(OBJEXT) test_ui_OBJECTS = $(am_test_ui_OBJECTS) am__DEPENDENCIES_1 = test_ui_DEPENDENCIES = $(top_builddir)/unity/libunity.la \ @@ -343,6 +345,8 @@ test_ui_VALAFLAGS = \ $(MAINTAINER_VALAFLAGS) test_ui_SOURCES = \ + test-automate.vala \ + test-home-button.vala \ test-quicklist.vala \ test-ui.vala @@ -405,6 +409,8 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_ui-test-automate.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_ui-test-home-button.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_ui-test-quicklist.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_ui-test-ui.Po@am__quote@ @@ -432,6 +438,38 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< +test_ui-test-automate.o: test-automate.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_ui_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_ui-test-automate.o -MD -MP -MF $(DEPDIR)/test_ui-test-automate.Tpo -c -o test_ui-test-automate.o `test -f 'test-automate.c' || echo '$(srcdir)/'`test-automate.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_ui-test-automate.Tpo $(DEPDIR)/test_ui-test-automate.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='test-automate.c' object='test_ui-test-automate.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_ui_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_ui-test-automate.o `test -f 'test-automate.c' || echo '$(srcdir)/'`test-automate.c + +test_ui-test-automate.obj: test-automate.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_ui_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_ui-test-automate.obj -MD -MP -MF $(DEPDIR)/test_ui-test-automate.Tpo -c -o test_ui-test-automate.obj `if test -f 'test-automate.c'; then $(CYGPATH_W) 'test-automate.c'; else $(CYGPATH_W) '$(srcdir)/test-automate.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_ui-test-automate.Tpo $(DEPDIR)/test_ui-test-automate.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='test-automate.c' object='test_ui-test-automate.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_ui_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_ui-test-automate.obj `if test -f 'test-automate.c'; then $(CYGPATH_W) 'test-automate.c'; else $(CYGPATH_W) '$(srcdir)/test-automate.c'; fi` + +test_ui-test-home-button.o: test-home-button.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_ui_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_ui-test-home-button.o -MD -MP -MF $(DEPDIR)/test_ui-test-home-button.Tpo -c -o test_ui-test-home-button.o `test -f 'test-home-button.c' || echo '$(srcdir)/'`test-home-button.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_ui-test-home-button.Tpo $(DEPDIR)/test_ui-test-home-button.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='test-home-button.c' object='test_ui-test-home-button.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_ui_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_ui-test-home-button.o `test -f 'test-home-button.c' || echo '$(srcdir)/'`test-home-button.c + +test_ui-test-home-button.obj: test-home-button.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_ui_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_ui-test-home-button.obj -MD -MP -MF $(DEPDIR)/test_ui-test-home-button.Tpo -c -o test_ui-test-home-button.obj `if test -f 'test-home-button.c'; then $(CYGPATH_W) 'test-home-button.c'; else $(CYGPATH_W) '$(srcdir)/test-home-button.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_ui-test-home-button.Tpo $(DEPDIR)/test_ui-test-home-button.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='test-home-button.c' object='test_ui-test-home-button.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_ui_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_ui-test-home-button.obj `if test -f 'test-home-button.c'; then $(CYGPATH_W) 'test-home-button.c'; else $(CYGPATH_W) '$(srcdir)/test-home-button.c'; fi` + test_ui-test-quicklist.o: test-quicklist.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_ui_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_ui-test-quicklist.o -MD -MP -MF $(DEPDIR)/test_ui-test-quicklist.Tpo -c -o test_ui-test-quicklist.o `test -f 'test-quicklist.c' || echo '$(srcdir)/'`test-quicklist.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_ui-test-quicklist.Tpo $(DEPDIR)/test_ui-test-quicklist.Po @@ -463,6 +501,16 @@ test_ui-test-ui.obj: test-ui.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='test-ui.c' object='test_ui-test-ui.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_ui_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_ui-test-ui.obj `if test -f 'test-ui.c'; then $(CYGPATH_W) 'test-ui.c'; else $(CYGPATH_W) '$(srcdir)/test-ui.c'; fi` +$(srcdir)/test-automate.c: $(srcdir)/test_ui_vala.stamp + @if test -f $@; then :; else \ + rm -f $(srcdir)/test_ui_vala.stamp; \ + $(am__cd) $(srcdir) && $(MAKE) $(AM_MAKEFLAGS) test_ui_vala.stamp; \ + fi +$(srcdir)/test-home-button.c: $(srcdir)/test_ui_vala.stamp + @if test -f $@; then :; else \ + rm -f $(srcdir)/test_ui_vala.stamp; \ + $(am__cd) $(srcdir) && $(MAKE) $(AM_MAKEFLAGS) test_ui_vala.stamp; \ + fi $(srcdir)/test-quicklist.c: $(srcdir)/test_ui_vala.stamp @if test -f $@; then :; else \ rm -f $(srcdir)/test_ui_vala.stamp; \ @@ -708,6 +756,8 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." + -rm -f test-automate.c + -rm -f test-home-button.c -rm -f test-quicklist.c -rm -f test-ui.c -rm -f test_ui_vala.stamp diff --git a/tests/ui/data/quicklist_controller_show_label.png b/tests/ui/data/quicklist_controller_show_label.png Binary files differindex bfaf4e0a6..2fef5d5f6 100644 --- a/tests/ui/data/quicklist_controller_show_label.png +++ b/tests/ui/data/quicklist_controller_show_label.png diff --git a/tests/ui/test-automate.c b/tests/ui/test-automate.c new file mode 100644 index 000000000..2e7a05cef --- /dev/null +++ b/tests/ui/test-automate.c @@ -0,0 +1,244 @@ +/* test-automate.c generated by valac, the Vala compiler + * generated from test-automate.vala, do not modify */ + +/* + * Copyright (C) 2010 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by Neil Jagdish Patel <neil.patel@canonical.com> + * + */ + +#include <glib.h> +#include <glib-object.h> +#include <clutter/clutter.h> +#include <unity-private.h> +#include <stdlib.h> +#include <string.h> +#include <gtk/gtk.h> +#include <stdio.h> +#include <clutk/clutk.h> +#include <float.h> +#include <math.h> + + +#define UNITY_TESTS_UI_TYPE_AUTOMATION_BASIC_TEST_SUITE (unity_tests_ui_automation_basic_test_suite_get_type ()) +#define UNITY_TESTS_UI_AUTOMATION_BASIC_TEST_SUITE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_TESTS_UI_TYPE_AUTOMATION_BASIC_TEST_SUITE, UnityTestsUIAutomationBasicTestSuite)) +#define UNITY_TESTS_UI_AUTOMATION_BASIC_TEST_SUITE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_TESTS_UI_TYPE_AUTOMATION_BASIC_TEST_SUITE, UnityTestsUIAutomationBasicTestSuiteClass)) +#define UNITY_TESTS_UI_IS_AUTOMATION_BASIC_TEST_SUITE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_TESTS_UI_TYPE_AUTOMATION_BASIC_TEST_SUITE)) +#define UNITY_TESTS_UI_IS_AUTOMATION_BASIC_TEST_SUITE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_TESTS_UI_TYPE_AUTOMATION_BASIC_TEST_SUITE)) +#define UNITY_TESTS_UI_AUTOMATION_BASIC_TEST_SUITE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_TESTS_UI_TYPE_AUTOMATION_BASIC_TEST_SUITE, UnityTestsUIAutomationBasicTestSuiteClass)) + +typedef struct _UnityTestsUIAutomationBasicTestSuite UnityTestsUIAutomationBasicTestSuite; +typedef struct _UnityTestsUIAutomationBasicTestSuiteClass UnityTestsUIAutomationBasicTestSuiteClass; +typedef struct _UnityTestsUIAutomationBasicTestSuitePrivate UnityTestsUIAutomationBasicTestSuitePrivate; +#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) +#define _g_timer_destroy0(var) ((var == NULL) ? NULL : (var = (g_timer_destroy (var), NULL))) +#define _unity_launcher_scroller_model_iterator_unref0(var) ((var == NULL) ? NULL : (var = (unity_launcher_scroller_model_iterator_unref (var), NULL))) +#define _unity_testing_object_registry_unref0(var) ((var == NULL) ? NULL : (var = (unity_testing_object_registry_unref (var), NULL))) + +struct _UnityTestsUIAutomationBasicTestSuite { + GObject parent_instance; + UnityTestsUIAutomationBasicTestSuitePrivate * priv; +}; + +struct _UnityTestsUIAutomationBasicTestSuiteClass { + GObjectClass parent_class; +}; + +struct _UnityTestsUIAutomationBasicTestSuitePrivate { + UnityTestingWindow* window; + ClutterStage* stage; +}; + + +extern GTimer* gTimer; +GTimer* gTimer = NULL; +static gpointer unity_tests_ui_automation_basic_test_suite_parent_class = NULL; + +void on_animation_started (ClutterAnimation* anim); +void on_animation_completed (ClutterAnimation* anim); +GType unity_tests_ui_automation_basic_test_suite_get_type (void); +#define UNITY_TESTS_UI_AUTOMATION_BASIC_TEST_SUITE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UNITY_TESTS_UI_TYPE_AUTOMATION_BASIC_TEST_SUITE, UnityTestsUIAutomationBasicTestSuitePrivate)) +enum { + UNITY_TESTS_UI_AUTOMATION_BASIC_TEST_SUITE_DUMMY_PROPERTY +}; +#define UNITY_TESTS_UI_AUTOMATION_BASIC_TEST_SUITE_DOMAIN "/UI/Quicklist" +static void unity_tests_ui_automation_basic_test_suite_test_automation (UnityTestsUIAutomationBasicTestSuite* self); +static void _unity_tests_ui_automation_basic_test_suite_test_automation_gdata_test_func (gpointer self); +static void unity_tests_ui_automation_basic_test_suite_test_teardown (UnityTestsUIAutomationBasicTestSuite* self); +static void _unity_tests_ui_automation_basic_test_suite_test_teardown_gdata_test_func (gpointer self); +UnityTestsUIAutomationBasicTestSuite* unity_tests_ui_automation_basic_test_suite_new (void); +UnityTestsUIAutomationBasicTestSuite* unity_tests_ui_automation_basic_test_suite_construct (GType object_type); +static void _on_animation_completed_clutter_animation_completed (ClutterAnimation* _sender, gpointer self); +static void unity_tests_ui_automation_basic_test_suite_finalize (GObject* obj); + + + +void on_animation_started (ClutterAnimation* anim) { + g_timer_start (gTimer); +} + + +void on_animation_completed (ClutterAnimation* anim) { + g_timer_stop (gTimer); +} + + +static gpointer _g_object_ref0 (gpointer self) { + return self ? g_object_ref (self) : NULL; +} + + +static void _unity_tests_ui_automation_basic_test_suite_test_automation_gdata_test_func (gpointer self) { + unity_tests_ui_automation_basic_test_suite_test_automation (self); +} + + +static void _unity_tests_ui_automation_basic_test_suite_test_teardown_gdata_test_func (gpointer self) { + unity_tests_ui_automation_basic_test_suite_test_teardown (self); +} + + +UnityTestsUIAutomationBasicTestSuite* unity_tests_ui_automation_basic_test_suite_construct (GType object_type) { + UnityTestsUIAutomationBasicTestSuite * self; + UnityTestingWindow* _tmp0_; + ClutterStage* _tmp1_; + self = (UnityTestsUIAutomationBasicTestSuite*) g_object_new (object_type, NULL); + unity_testing_logging_init_fatal_handler (); + self->priv->window = (_tmp0_ = g_object_ref_sink (unity_testing_window_new (TRUE, 1024, 600)), _g_object_unref0 (self->priv->window), _tmp0_); + unity_testing_window_init_test_mode (self->priv->window); + self->priv->stage = (_tmp1_ = _g_object_ref0 (self->priv->window->stage), _g_object_unref0 (self->priv->stage), _tmp1_); + gtk_window_set_title ((GtkWindow*) self->priv->window, "Automation Tests"); + gtk_widget_show_all ((GtkWidget*) self->priv->window); + g_test_add_data_func (UNITY_TESTS_UI_AUTOMATION_BASIC_TEST_SUITE_DOMAIN "/Automation", self, _unity_tests_ui_automation_basic_test_suite_test_automation_gdata_test_func); + g_test_add_data_func (UNITY_TESTS_UI_AUTOMATION_BASIC_TEST_SUITE_DOMAIN "/Teardown", self, _unity_tests_ui_automation_basic_test_suite_test_teardown_gdata_test_func); + return self; +} + + +UnityTestsUIAutomationBasicTestSuite* unity_tests_ui_automation_basic_test_suite_new (void) { + return unity_tests_ui_automation_basic_test_suite_construct (UNITY_TESTS_UI_TYPE_AUTOMATION_BASIC_TEST_SUITE); +} + + +static void unity_tests_ui_automation_basic_test_suite_test_teardown (UnityTestsUIAutomationBasicTestSuite* self) { + ClutterStage* _tmp0_; + g_return_if_fail (self != NULL); + self->priv->stage = (_tmp0_ = NULL, _g_object_unref0 (self->priv->stage), _tmp0_); +} + + +static void _on_animation_completed_clutter_animation_completed (ClutterAnimation* _sender, gpointer self) { + on_animation_completed (_sender); +} + + +static void unity_tests_ui_automation_basic_test_suite_test_automation (UnityTestsUIAutomationBasicTestSuite* self) { + UnityTestingObjectRegistry* registry; + UnityLauncherQuicklistController* qlcontroller; + GeeArrayList* _tmp0_; + UnityLauncherScrollerModel* scroller; + GTimer* _tmp1_; + gint DT; + g_return_if_fail (self != NULL); + registry = unity_testing_object_registry_get_default (); + unity_testing_logging_init_fatal_handler (); + qlcontroller = _g_object_ref0 (unity_launcher_quicklist_controller_get_default ()); + scroller = (_tmp0_ = unity_testing_object_registry_lookup (registry, "UnityScrollerModel"), UNITY_LAUNCHER_IS_SCROLLER_MODEL (_tmp0_) ? ((UnityLauncherScrollerModel*) _tmp0_) : NULL); + gTimer = (_tmp1_ = g_timer_new (), _g_timer_destroy0 (gTimer), _tmp1_); + DT = 2500; + fprintf (stdout, "\n"); + { + UnityLauncherScrollerModelIterator* _launcher_it; + _launcher_it = unity_launcher_scroller_model_iterator (scroller); + while (TRUE) { + UnityLauncherScrollerChild* launcher; + ClutterActor* _tmp2_; + UnityTestingDirector* dir; + ClutterAnimation* anim; + ClutterAnimation* _tmp3_; + float dt; + float dt0; + ClutterAnimation* _tmp4_; + if (!unity_launcher_scroller_model_iterator_next (_launcher_it)) { + break; + } + launcher = unity_launcher_scroller_model_iterator_get (_launcher_it); + dir = unity_testing_director_new ((_tmp2_ = clutter_actor_get_stage ((ClutterActor*) launcher), CLUTTER_IS_STAGE (_tmp2_) ? ((ClutterStage*) _tmp2_) : NULL)); + unity_launcher_quicklist_controller_show_label (qlcontroller, "Ubuntu Software Centre", (CtkActor*) launcher); + anim = NULL; + clutter_actor_set_opacity ((ClutterActor*) launcher, (guint8) 255); + g_timer_start (gTimer); + anim = (_tmp3_ = _g_object_ref0 (clutter_actor_animate ((ClutterActor*) launcher, (gulong) CLUTTER_EASE_IN_SINE, (guint) 2500, "opacity", 0, NULL)), _g_object_unref0 (anim), _tmp3_); + g_signal_connect (anim, "completed", (GCallback) _on_animation_completed_clutter_animation_completed, NULL); + unity_testing_director_do_wait_for_animation (dir, (ClutterActor*) launcher); + dt = (float) g_timer_elapsed (gTimer, NULL); + dt0 = ((float) DT) / 1000.0f; + fprintf (stdout, "Expected Duration: %2.3f, Observed Duration: %2.3f, Error: %2.3f%%\n", (double) dt0, (double) dt, (double) (((dt - dt0) * 100.0f) / dt0)); + g_timer_start (gTimer); + anim = (_tmp4_ = _g_object_ref0 (clutter_actor_animate ((ClutterActor*) launcher, (gulong) CLUTTER_EASE_IN_SINE, (guint) 2500, "opacity", 255, NULL)), _g_object_unref0 (anim), _tmp4_); + g_signal_connect (anim, "completed", (GCallback) _on_animation_completed_clutter_animation_completed, NULL); + unity_testing_director_do_wait_for_animation (dir, (ClutterActor*) launcher); + dt = (float) g_timer_elapsed (gTimer, NULL); + dt0 = ((float) DT) / 1000.0f; + fprintf (stdout, "Expected Duration: %2.3f, Observed Duration: %2.3f, Error: %2.3f%%\n", (double) dt0, (double) dt, (double) (((dt - dt0) * 100.0f) / dt0)); + _g_object_unref0 (launcher); + _g_object_unref0 (dir); + _g_object_unref0 (anim); + } + _unity_launcher_scroller_model_iterator_unref0 (_launcher_it); + } + unity_launcher_quicklist_controller_close_menu (qlcontroller); + _unity_testing_object_registry_unref0 (registry); + _g_object_unref0 (qlcontroller); + _g_object_unref0 (scroller); +} + + +static void unity_tests_ui_automation_basic_test_suite_class_init (UnityTestsUIAutomationBasicTestSuiteClass * klass) { + unity_tests_ui_automation_basic_test_suite_parent_class = g_type_class_peek_parent (klass); + g_type_class_add_private (klass, sizeof (UnityTestsUIAutomationBasicTestSuitePrivate)); + G_OBJECT_CLASS (klass)->finalize = unity_tests_ui_automation_basic_test_suite_finalize; +} + + +static void unity_tests_ui_automation_basic_test_suite_instance_init (UnityTestsUIAutomationBasicTestSuite * self) { + self->priv = UNITY_TESTS_UI_AUTOMATION_BASIC_TEST_SUITE_GET_PRIVATE (self); +} + + +static void unity_tests_ui_automation_basic_test_suite_finalize (GObject* obj) { + UnityTestsUIAutomationBasicTestSuite * self; + self = UNITY_TESTS_UI_AUTOMATION_BASIC_TEST_SUITE (obj); + _g_object_unref0 (self->priv->window); + _g_object_unref0 (self->priv->stage); + G_OBJECT_CLASS (unity_tests_ui_automation_basic_test_suite_parent_class)->finalize (obj); +} + + +GType unity_tests_ui_automation_basic_test_suite_get_type (void) { + static volatile gsize unity_tests_ui_automation_basic_test_suite_type_id__volatile = 0; + if (g_once_init_enter (&unity_tests_ui_automation_basic_test_suite_type_id__volatile)) { + static const GTypeInfo g_define_type_info = { sizeof (UnityTestsUIAutomationBasicTestSuiteClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) unity_tests_ui_automation_basic_test_suite_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UnityTestsUIAutomationBasicTestSuite), 0, (GInstanceInitFunc) unity_tests_ui_automation_basic_test_suite_instance_init, NULL }; + GType unity_tests_ui_automation_basic_test_suite_type_id; + unity_tests_ui_automation_basic_test_suite_type_id = g_type_register_static (G_TYPE_OBJECT, "UnityTestsUIAutomationBasicTestSuite", &g_define_type_info, 0); + g_once_init_leave (&unity_tests_ui_automation_basic_test_suite_type_id__volatile, unity_tests_ui_automation_basic_test_suite_type_id); + } + return unity_tests_ui_automation_basic_test_suite_type_id__volatile; +} + + + + diff --git a/tests/ui/test-automate.vala b/tests/ui/test-automate.vala new file mode 100644 index 000000000..71b5f0cfd --- /dev/null +++ b/tests/ui/test-automate.vala @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2010 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by Neil Jagdish Patel <neil.patel@canonical.com> + * + */ + +using Unity; +using Unity.Testing; +using Unity.Launcher; + +GLib.Timer gTimer; +static void +on_animation_started (Clutter.Animation? anim) +{ + //stdout.printf("Animation Started\n"); + gTimer.start (); +} + +static void +on_animation_completed (Clutter.Animation? anim) +{ + //stdout.printf("Animation Completed\n"); + gTimer.stop (); +} + +namespace Unity.Tests.UI +{ + public class AutomationBasicTestSuite : Object + { + private const string DOMAIN = "/UI/Quicklist"; + + Unity.Testing.Window? window; + Clutter.Stage? stage; + + public AutomationBasicTestSuite () + { + Logging.init_fatal_handler (); + + /* Testup the test window */ + window = new Unity.Testing.Window (true, 1024, 600); + window.init_test_mode (); + stage = window.stage; + window.title = "Automation Tests"; + window.show_all (); + + Test.add_data_func (DOMAIN + "/Automation", + test_automation); + + + /* Keep this one last, it's a dummy to clean up the state as Vala cant + * deal with the standard TestSuite stuff properly + */ + Test.add_data_func (DOMAIN +"/Teardown", test_teardown); + } + + private void test_teardown () + { + //window.destroy (); + stage = null; + } + + private void test_automation () + { + ObjectRegistry registry = ObjectRegistry.get_default (); + + Logging.init_fatal_handler (); + + QuicklistController qlcontroller = QuicklistController.get_default (); + ScrollerModel scroller = registry.lookup ("UnityScrollerModel") as ScrollerModel; + + gTimer = new GLib.Timer(); + int DT = 2500; + stdout.printf("\n"); + + foreach (ScrollerChild launcher in scroller) + { + //launcher = scroller[i] as ScrollerChild; + var dir = new Director (launcher.get_stage() as Clutter.Stage); + + qlcontroller.show_label ("Ubuntu Software Centre", launcher); + + Clutter.Animation? anim; + launcher.opacity = 255; + + + gTimer.start (); + anim = launcher.animate (Clutter.AnimationMode.EASE_IN_SINE, 2500, "opacity", 0); + //anim.started.connect (on_animation_started); + anim.completed.connect (on_animation_completed); + dir.do_wait_for_animation (launcher); + + float dt = (float)gTimer.elapsed (); + float dt0 = (float)DT/1000.0f; + stdout.printf("Expected Duration: %2.3f, Observed Duration: %2.3f, Error: %2.3f%%\n", dt0, dt, + (dt - dt0)*100.0f/dt0); + + gTimer.start (); + anim = launcher.animate (Clutter.AnimationMode.EASE_IN_SINE, 2500, "opacity", 255); + //anim.started.connect (on_animation_started); + anim.completed.connect (on_animation_completed); + dir.do_wait_for_animation (launcher); + + dt = (float)gTimer.elapsed (); + dt0 = (float)DT/1000.0f; + stdout.printf("Expected Duration: %2.3f, Observed Duration: %2.3f, Error: %2.3f%%\n", dt0, dt, + (dt - dt0)*100.0f/dt0); + + + //dir.do_wait_for_timeout (5000); + } + + //debug ("After Animation"); + /* Clean up */ + qlcontroller.close_menu (); + } + } +} diff --git a/tests/ui/test-home-button.c b/tests/ui/test-home-button.c new file mode 100644 index 000000000..d9a47c514 --- /dev/null +++ b/tests/ui/test-home-button.c @@ -0,0 +1,339 @@ +/* test-home-button.c generated by valac, the Vala compiler + * generated from test-home-button.vala, do not modify */ + +/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */ +/* + * Copyright (C) 2010 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by Mirco Müller <mirco.mueller@canonical.com> + * + */ + +#include <glib.h> +#include <glib-object.h> +#include <unity.h> +#include <unity-private.h> +#include <clutter/clutter.h> +#include <stdlib.h> +#include <string.h> +#include <gtk/gtk.h> + + +#define UNITY_TESTS_UI_TYPE_HOME_BUTTON_SUITE (unity_tests_ui_home_button_suite_get_type ()) +#define UNITY_TESTS_UI_HOME_BUTTON_SUITE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_TESTS_UI_TYPE_HOME_BUTTON_SUITE, UnityTestsUIHomeButtonSuite)) +#define UNITY_TESTS_UI_HOME_BUTTON_SUITE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_TESTS_UI_TYPE_HOME_BUTTON_SUITE, UnityTestsUIHomeButtonSuiteClass)) +#define UNITY_TESTS_UI_IS_HOME_BUTTON_SUITE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_TESTS_UI_TYPE_HOME_BUTTON_SUITE)) +#define UNITY_TESTS_UI_IS_HOME_BUTTON_SUITE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_TESTS_UI_TYPE_HOME_BUTTON_SUITE)) +#define UNITY_TESTS_UI_HOME_BUTTON_SUITE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_TESTS_UI_TYPE_HOME_BUTTON_SUITE, UnityTestsUIHomeButtonSuiteClass)) + +typedef struct _UnityTestsUIHomeButtonSuite UnityTestsUIHomeButtonSuite; +typedef struct _UnityTestsUIHomeButtonSuiteClass UnityTestsUIHomeButtonSuiteClass; +typedef struct _UnityTestsUIHomeButtonSuitePrivate UnityTestsUIHomeButtonSuitePrivate; +#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) + +struct _UnityTestsUIHomeButtonSuite { + GObject parent_instance; + UnityTestsUIHomeButtonSuitePrivate * priv; +}; + +struct _UnityTestsUIHomeButtonSuiteClass { + GObjectClass parent_class; +}; + +struct _UnityTestsUIHomeButtonSuitePrivate { + UnityTestingWindow* window; + ClutterStage* stage; + UnityTestingDirector* director; + UnityPanelHomeButton* home_button; +}; + + +extern gboolean g_flag; +gboolean g_flag = FALSE; +static gpointer unity_tests_ui_home_button_suite_parent_class = NULL; +static UnityShellIface* unity_tests_ui_home_button_suite_unity_shell_parent_iface = NULL; + +GType unity_tests_ui_home_button_suite_get_type (void); +#define UNITY_TESTS_UI_HOME_BUTTON_SUITE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UNITY_TESTS_UI_TYPE_HOME_BUTTON_SUITE, UnityTestsUIHomeButtonSuitePrivate)) +enum { + UNITY_TESTS_UI_HOME_BUTTON_SUITE_DUMMY_PROPERTY, + UNITY_TESTS_UI_HOME_BUTTON_SUITE_MENUS_SWALLOW_EVENTS +}; +#define UNITY_TESTS_UI_HOME_BUTTON_SUITE_DOMAIN "/UI/HomeButton" +static void unity_tests_ui_home_button_suite_test_click_home_button (UnityTestsUIHomeButtonSuite* self); +static void _unity_tests_ui_home_button_suite_test_click_home_button_gdata_test_func (gpointer self); +UnityTestsUIHomeButtonSuite* unity_tests_ui_home_button_suite_new (void); +UnityTestsUIHomeButtonSuite* unity_tests_ui_home_button_suite_construct (GType object_type); +static UnityShellMode unity_tests_ui_home_button_suite_real_get_mode (UnityShell* base); +static ClutterStage* unity_tests_ui_home_button_suite_real_get_stage (UnityShell* base); +static void unity_tests_ui_home_button_suite_real_show_unity (UnityShell* base); +static gint unity_tests_ui_home_button_suite_real_get_indicators_width (UnityShell* base); +static gint unity_tests_ui_home_button_suite_real_get_launcher_width_foobar (UnityShell* base); +static gint unity_tests_ui_home_button_suite_real_get_panel_height_foobar (UnityShell* base); +static void unity_tests_ui_home_button_suite_real_ensure_input_region (UnityShell* base); +static void unity_tests_ui_home_button_suite_real_add_fullscreen_request (UnityShell* base, GObject* o); +static gboolean unity_tests_ui_home_button_suite_real_remove_fullscreen_request (UnityShell* base, GObject* o); +static void unity_tests_ui_home_button_suite_real_grab_keyboard (UnityShell* base, gboolean grab, guint32 timestamp); +static void unity_tests_ui_home_button_suite_real_show_window_picker (UnityShell* base); +static void unity_tests_ui_home_button_suite_real_close_xids (UnityShell* base, GArray* xids); +static void unity_tests_ui_home_button_suite_real_show_window (UnityShell* base, guint32 xid); +static void unity_tests_ui_home_button_suite_real_expose_xids (UnityShell* base, GArray* xids); +static void unity_tests_ui_home_button_suite_real_stop_expose (UnityShell* base); +static void unity_tests_ui_home_button_suite_finalize (GObject* obj); +static void unity_tests_ui_home_button_suite_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); + + + +static gpointer _g_object_ref0 (gpointer self) { + return self ? g_object_ref (self) : NULL; +} + + +static void _unity_tests_ui_home_button_suite_test_click_home_button_gdata_test_func (gpointer self) { + unity_tests_ui_home_button_suite_test_click_home_button (self); +} + + +UnityTestsUIHomeButtonSuite* unity_tests_ui_home_button_suite_construct (GType object_type) { + UnityTestsUIHomeButtonSuite * self; + UnityTestingWindow* _tmp0_; + ClutterStage* _tmp1_; + UnityPanelHomeButton* _tmp2_; + UnityTestingDirector* _tmp3_; + self = (UnityTestsUIHomeButtonSuite*) g_object_new (object_type, NULL); + unity_testing_logging_init_fatal_handler (); + self->priv->window = (_tmp0_ = g_object_ref_sink (unity_testing_window_new (TRUE, 1024, 600)), _g_object_unref0 (self->priv->window), _tmp0_); + unity_testing_window_init_test_mode (self->priv->window); + self->priv->stage = (_tmp1_ = _g_object_ref0 (self->priv->window->stage), _g_object_unref0 (self->priv->stage), _tmp1_); + gtk_window_set_title ((GtkWindow*) self->priv->window, "HomeButton Test"); + gtk_widget_show_all ((GtkWidget*) self->priv->window); + self->priv->home_button = (_tmp2_ = g_object_ref_sink (unity_panel_home_button_new ((UnityShell*) self)), _g_object_unref0 (self->priv->home_button), _tmp2_); + self->priv->director = (_tmp3_ = unity_testing_director_new (self->priv->stage), _g_object_unref0 (self->priv->director), _tmp3_); + g_test_add_data_func (UNITY_TESTS_UI_HOME_BUTTON_SUITE_DOMAIN "/HomeButton", self, _unity_tests_ui_home_button_suite_test_click_home_button_gdata_test_func); + return self; +} + + +UnityTestsUIHomeButtonSuite* unity_tests_ui_home_button_suite_new (void) { + return unity_tests_ui_home_button_suite_construct (UNITY_TESTS_UI_TYPE_HOME_BUTTON_SUITE); +} + + +static void unity_tests_ui_home_button_suite_test_click_home_button (UnityTestsUIHomeButtonSuite* self) { + g_return_if_fail (self != NULL); + unity_testing_director_button_press (self->priv->director, (ClutterActor*) self->priv->home_button, (guint32) 1, TRUE, 1.0f, 1.0f, FALSE); + unity_testing_logging_init_fatal_handler (); + g_assert (g_flag == TRUE); +} + + +static UnityShellMode unity_tests_ui_home_button_suite_real_get_mode (UnityShell* base) { + UnityTestsUIHomeButtonSuite * self; + UnityShellMode result = 0; + self = (UnityTestsUIHomeButtonSuite*) base; + result = UNITY_SHELL_MODE_UNDERLAY; + return result; +} + + +static ClutterStage* unity_tests_ui_home_button_suite_real_get_stage (UnityShell* base) { + UnityTestsUIHomeButtonSuite * self; + ClutterStage* result = NULL; + self = (UnityTestsUIHomeButtonSuite*) base; + result = _g_object_ref0 (self->priv->stage); + return result; +} + + +static void unity_tests_ui_home_button_suite_real_show_unity (UnityShell* base) { + UnityTestsUIHomeButtonSuite * self; + self = (UnityTestsUIHomeButtonSuite*) base; + g_flag = TRUE; +} + + +static gint unity_tests_ui_home_button_suite_real_get_indicators_width (UnityShell* base) { + UnityTestsUIHomeButtonSuite * self; + gint result = 0; + self = (UnityTestsUIHomeButtonSuite*) base; + result = 0; + return result; +} + + +static gint unity_tests_ui_home_button_suite_real_get_launcher_width_foobar (UnityShell* base) { + UnityTestsUIHomeButtonSuite * self; + gint result = 0; + self = (UnityTestsUIHomeButtonSuite*) base; + result = 0; + return result; +} + + +static gint unity_tests_ui_home_button_suite_real_get_panel_height_foobar (UnityShell* base) { + UnityTestsUIHomeButtonSuite * self; + gint result = 0; + self = (UnityTestsUIHomeButtonSuite*) base; + result = 0; + return result; +} + + +static void unity_tests_ui_home_button_suite_real_ensure_input_region (UnityShell* base) { + UnityTestsUIHomeButtonSuite * self; + self = (UnityTestsUIHomeButtonSuite*) base; +} + + +static void unity_tests_ui_home_button_suite_real_add_fullscreen_request (UnityShell* base, GObject* o) { + UnityTestsUIHomeButtonSuite * self; + self = (UnityTestsUIHomeButtonSuite*) base; + g_return_if_fail (o != NULL); +} + + +static gboolean unity_tests_ui_home_button_suite_real_remove_fullscreen_request (UnityShell* base, GObject* o) { + UnityTestsUIHomeButtonSuite * self; + gboolean result = FALSE; + self = (UnityTestsUIHomeButtonSuite*) base; + g_return_val_if_fail (o != NULL, FALSE); + result = FALSE; + return result; +} + + +static void unity_tests_ui_home_button_suite_real_grab_keyboard (UnityShell* base, gboolean grab, guint32 timestamp) { + UnityTestsUIHomeButtonSuite * self; + self = (UnityTestsUIHomeButtonSuite*) base; +} + + +static void unity_tests_ui_home_button_suite_real_show_window_picker (UnityShell* base) { + UnityTestsUIHomeButtonSuite * self; + self = (UnityTestsUIHomeButtonSuite*) base; +} + + +static void unity_tests_ui_home_button_suite_real_close_xids (UnityShell* base, GArray* xids) { + UnityTestsUIHomeButtonSuite * self; + self = (UnityTestsUIHomeButtonSuite*) base; + g_return_if_fail (xids != NULL); +} + + +static void unity_tests_ui_home_button_suite_real_show_window (UnityShell* base, guint32 xid) { + UnityTestsUIHomeButtonSuite * self; + self = (UnityTestsUIHomeButtonSuite*) base; +} + + +static void unity_tests_ui_home_button_suite_real_expose_xids (UnityShell* base, GArray* xids) { + UnityTestsUIHomeButtonSuite * self; + self = (UnityTestsUIHomeButtonSuite*) base; + g_return_if_fail (xids != NULL); +} + + +static void unity_tests_ui_home_button_suite_real_stop_expose (UnityShell* base) { + UnityTestsUIHomeButtonSuite * self; + self = (UnityTestsUIHomeButtonSuite*) base; +} + + +static gboolean unity_tests_ui_home_button_suite_real_get_menus_swallow_events (UnityShell* base) { + gboolean result; + UnityTestsUIHomeButtonSuite* self; + self = (UnityTestsUIHomeButtonSuite*) base; + result = TRUE; + return result; +} + + +static void unity_tests_ui_home_button_suite_class_init (UnityTestsUIHomeButtonSuiteClass * klass) { + unity_tests_ui_home_button_suite_parent_class = g_type_class_peek_parent (klass); + g_type_class_add_private (klass, sizeof (UnityTestsUIHomeButtonSuitePrivate)); + G_OBJECT_CLASS (klass)->get_property = unity_tests_ui_home_button_suite_get_property; + G_OBJECT_CLASS (klass)->finalize = unity_tests_ui_home_button_suite_finalize; + g_object_class_override_property (G_OBJECT_CLASS (klass), UNITY_TESTS_UI_HOME_BUTTON_SUITE_MENUS_SWALLOW_EVENTS, "menus-swallow-events"); +} + + +static void unity_tests_ui_home_button_suite_unity_shell_interface_init (UnityShellIface * iface) { + unity_tests_ui_home_button_suite_unity_shell_parent_iface = g_type_interface_peek_parent (iface); + iface->get_mode = unity_tests_ui_home_button_suite_real_get_mode; + iface->get_stage = unity_tests_ui_home_button_suite_real_get_stage; + iface->show_unity = unity_tests_ui_home_button_suite_real_show_unity; + iface->get_indicators_width = unity_tests_ui_home_button_suite_real_get_indicators_width; + iface->get_launcher_width_foobar = unity_tests_ui_home_button_suite_real_get_launcher_width_foobar; + iface->get_panel_height_foobar = unity_tests_ui_home_button_suite_real_get_panel_height_foobar; + iface->ensure_input_region = unity_tests_ui_home_button_suite_real_ensure_input_region; + iface->add_fullscreen_request = unity_tests_ui_home_button_suite_real_add_fullscreen_request; + iface->remove_fullscreen_request = unity_tests_ui_home_button_suite_real_remove_fullscreen_request; + iface->grab_keyboard = unity_tests_ui_home_button_suite_real_grab_keyboard; + iface->show_window_picker = unity_tests_ui_home_button_suite_real_show_window_picker; + iface->close_xids = unity_tests_ui_home_button_suite_real_close_xids; + iface->show_window = unity_tests_ui_home_button_suite_real_show_window; + iface->expose_xids = unity_tests_ui_home_button_suite_real_expose_xids; + iface->stop_expose = unity_tests_ui_home_button_suite_real_stop_expose; + iface->get_menus_swallow_events = unity_tests_ui_home_button_suite_real_get_menus_swallow_events; +} + + +static void unity_tests_ui_home_button_suite_instance_init (UnityTestsUIHomeButtonSuite * self) { + self->priv = UNITY_TESTS_UI_HOME_BUTTON_SUITE_GET_PRIVATE (self); +} + + +static void unity_tests_ui_home_button_suite_finalize (GObject* obj) { + UnityTestsUIHomeButtonSuite * self; + self = UNITY_TESTS_UI_HOME_BUTTON_SUITE (obj); + _g_object_unref0 (self->priv->window); + _g_object_unref0 (self->priv->stage); + _g_object_unref0 (self->priv->director); + _g_object_unref0 (self->priv->home_button); + G_OBJECT_CLASS (unity_tests_ui_home_button_suite_parent_class)->finalize (obj); +} + + +GType unity_tests_ui_home_button_suite_get_type (void) { + static volatile gsize unity_tests_ui_home_button_suite_type_id__volatile = 0; + if (g_once_init_enter (&unity_tests_ui_home_button_suite_type_id__volatile)) { + static const GTypeInfo g_define_type_info = { sizeof (UnityTestsUIHomeButtonSuiteClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) unity_tests_ui_home_button_suite_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UnityTestsUIHomeButtonSuite), 0, (GInstanceInitFunc) unity_tests_ui_home_button_suite_instance_init, NULL }; + static const GInterfaceInfo unity_shell_info = { (GInterfaceInitFunc) unity_tests_ui_home_button_suite_unity_shell_interface_init, (GInterfaceFinalizeFunc) NULL, NULL}; + GType unity_tests_ui_home_button_suite_type_id; + unity_tests_ui_home_button_suite_type_id = g_type_register_static (G_TYPE_OBJECT, "UnityTestsUIHomeButtonSuite", &g_define_type_info, 0); + g_type_add_interface_static (unity_tests_ui_home_button_suite_type_id, UNITY_TYPE_SHELL, &unity_shell_info); + g_once_init_leave (&unity_tests_ui_home_button_suite_type_id__volatile, unity_tests_ui_home_button_suite_type_id); + } + return unity_tests_ui_home_button_suite_type_id__volatile; +} + + +static void unity_tests_ui_home_button_suite_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { + UnityTestsUIHomeButtonSuite * self; + self = UNITY_TESTS_UI_HOME_BUTTON_SUITE (object); + switch (property_id) { + case UNITY_TESTS_UI_HOME_BUTTON_SUITE_MENUS_SWALLOW_EVENTS: + g_value_set_boolean (value, unity_shell_get_menus_swallow_events ((UnityShell*) self)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + + + + diff --git a/tests/ui/test-home-button.vala b/tests/ui/test-home-button.vala new file mode 100644 index 000000000..bbc5ea3bb --- /dev/null +++ b/tests/ui/test-home-button.vala @@ -0,0 +1,165 @@ +/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */ +/* + * Copyright (C) 2010 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by Mirco Müller <mirco.mueller@canonical.com> + * + */ + +using Unity; +using Unity.Testing; +using Unity.Panel; + +bool g_flag = false; + +namespace Unity.Tests.UI +{ + public class HomeButtonSuite : Object, Shell + { + private const string DOMAIN = "/UI/HomeButton"; + + Unity.Testing.Window? window; + Clutter.Stage? stage; + Unity.Testing.Director director; + Unity.Panel.HomeButton home_button; + + public HomeButtonSuite () + { + Logging.init_fatal_handler (); + + /* Testup the test window */ + window = new Unity.Testing.Window (true, 1024, 600); + window.init_test_mode (); + stage = window.stage; + window.title = "HomeButton Test"; + window.show_all (); + + home_button = new Unity.Panel.HomeButton (this); + director = new Unity.Testing.Director (stage); + + Test.add_data_func (DOMAIN + "/HomeButton", test_click_home_button); + } + + + private void test_click_home_button () + { + director.button_press (home_button, 1, true, 1.0f, 1.0f, false); + + Logging.init_fatal_handler (); + + assert (g_flag == true); + } + + // + // mostly a dummy shell-implementation to satisfy the interface + // + public bool menus_swallow_events { get { return true; } } + + public ShellMode + get_mode () + { + return ShellMode.UNDERLAY; + } + + public Clutter.Stage + get_stage () + { + return this.stage; + } + + public void + show_unity () + { + g_flag = true; + } + + public int + get_indicators_width () + { + // stub + return 0; + } + + public int + get_launcher_width_foobar () + { + // stub + return 0; + } + + public int + get_panel_height_foobar () + { + // stub + return 0; + } + + public void + ensure_input_region () + { + // stub + } + + public void + add_fullscreen_request (Object o) + { + // stub + } + + public bool + remove_fullscreen_request (Object o) + { + // stub + return false; + } + + public void + grab_keyboard (bool grab, uint32 timestamp) + { + // stub + } + + public void + show_window_picker () + { + // stub + } + + public void + close_xids (Array<uint32> xids) + { + // stub + } + + public void + show_window (uint32 xid) + { + // stub + } + + public void + expose_xids (Array<uint32> xids) + { + // stub + } + + public void + stop_expose () + { + // stub + } + } +} + diff --git a/tests/ui/test-quicklist.c b/tests/ui/test-quicklist.c index 1819ff27b..85948d90b 100644 --- a/tests/ui/test-quicklist.c +++ b/tests/ui/test-quicklist.c @@ -156,7 +156,13 @@ static void unity_tests_ui_quicklist_suite_test_controller_show_label (UnityTest first = (_tmp3_ = unity_launcher_scroller_model_get (scroller, 0), UNITY_LAUNCHER_IS_SCROLLER_CHILD (_tmp3_) ? ((UnityLauncherScrollerChild*) _tmp3_) : NULL); qlcontroller = _g_object_ref0 (unity_launcher_quicklist_controller_get_default ()); unity_launcher_quicklist_controller_show_label (qlcontroller, "Ubuntu Software Centre", (CtkActor*) first); - g_assert (utils_compare_snapshot (self->priv->stage, img, 54, 25, 200, 50, TRUE)); + while (TRUE) { + if (!gtk_events_pending ()) { + break; + } + gtk_main_iteration (); + } + g_assert (utils_compare_snapshot (self->priv->stage, img, 54, 30, 200, 50, TRUE)); unity_launcher_quicklist_controller_close_menu (qlcontroller); _g_free0 (img); _unity_testing_object_registry_unref0 (registry); diff --git a/tests/ui/test-quicklist.vala b/tests/ui/test-quicklist.vala index b38d13102..77378de0c 100644 --- a/tests/ui/test-quicklist.vala +++ b/tests/ui/test-quicklist.vala @@ -71,7 +71,10 @@ namespace Unity.Tests.UI QuicklistController qlcontroller = QuicklistController.get_default (); qlcontroller.show_label ("Ubuntu Software Centre", first); - assert (Utils.compare_snapshot (stage, img, 54, 25, 200, 50)); + while (Gtk.events_pending ()) + Gtk.main_iteration (); + + assert (Utils.compare_snapshot (stage, img, 54, 30, 200, 50)); /* Clean up */ qlcontroller.close_menu (); diff --git a/tests/ui/test-ui.c b/tests/ui/test-ui.c index 13197f527..785c383d9 100644 --- a/tests/ui/test-ui.c +++ b/tests/ui/test-ui.c @@ -66,6 +66,16 @@ typedef struct _MainPrivate MainPrivate; typedef struct _UnityTestsUIQuicklistSuite UnityTestsUIQuicklistSuite; typedef struct _UnityTestsUIQuicklistSuiteClass UnityTestsUIQuicklistSuiteClass; + +#define UNITY_TESTS_UI_TYPE_HOME_BUTTON_SUITE (unity_tests_ui_home_button_suite_get_type ()) +#define UNITY_TESTS_UI_HOME_BUTTON_SUITE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_TESTS_UI_TYPE_HOME_BUTTON_SUITE, UnityTestsUIHomeButtonSuite)) +#define UNITY_TESTS_UI_HOME_BUTTON_SUITE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_TESTS_UI_TYPE_HOME_BUTTON_SUITE, UnityTestsUIHomeButtonSuiteClass)) +#define UNITY_TESTS_UI_IS_HOME_BUTTON_SUITE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_TESTS_UI_TYPE_HOME_BUTTON_SUITE)) +#define UNITY_TESTS_UI_IS_HOME_BUTTON_SUITE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_TESTS_UI_TYPE_HOME_BUTTON_SUITE)) +#define UNITY_TESTS_UI_HOME_BUTTON_SUITE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_TESTS_UI_TYPE_HOME_BUTTON_SUITE, UnityTestsUIHomeButtonSuiteClass)) + +typedef struct _UnityTestsUIHomeButtonSuite UnityTestsUIHomeButtonSuite; +typedef struct _UnityTestsUIHomeButtonSuiteClass UnityTestsUIHomeButtonSuiteClass; #define _unity_testing_logging_unref0(var) ((var == NULL) ? NULL : (var = (unity_testing_logging_unref (var), NULL))) typedef struct _ParamSpecMain ParamSpecMain; @@ -126,8 +136,11 @@ enum { MAIN_DUMMY_PROPERTY }; GType unity_tests_ui_quicklist_suite_get_type (void); +GType unity_tests_ui_home_button_suite_get_type (void); UnityTestsUIQuicklistSuite* unity_tests_ui_quicklist_suite_new (void); UnityTestsUIQuicklistSuite* unity_tests_ui_quicklist_suite_construct (GType object_type); +UnityTestsUIHomeButtonSuite* unity_tests_ui_home_button_suite_new (void); +UnityTestsUIHomeButtonSuite* unity_tests_ui_home_button_suite_construct (GType object_type); static gboolean _lambda0_ (void); static gboolean __lambda0__gsource_func (gpointer self); gint main_main (char** args, int args_length1); @@ -310,7 +323,9 @@ static gboolean _lambda0_ (void) { static gboolean __lambda0__gsource_func (gpointer self) { - return _lambda0_ (); + gboolean result; + result = _lambda0_ (); + return result; } @@ -318,10 +333,13 @@ gint main_main (char** args, int args_length1) { gint result = 0; UnityTestingLogging* logger; UnityTestsUIQuicklistSuite* quicklist_suite; + UnityTestsUIHomeButtonSuite* home_button_suite; UnityTestingLogging* _tmp0_; UnityTestsUIQuicklistSuite* _tmp1_; + UnityTestsUIHomeButtonSuite* _tmp2_; logger = NULL; quicklist_suite = NULL; + home_button_suite = NULL; g_setenv ("UNITY_DISABLE_TRAY", "1", TRUE); g_setenv ("UNITY_DISABLE_IDLES", "1", TRUE); g_setenv ("UNITY_PANEL_INDICATORS_SKIP", "all", TRUE); @@ -331,11 +349,13 @@ gint main_main (char** args, int args_length1) { g_test_init (&args_length1, &args, NULL); logger = (_tmp0_ = unity_testing_logging_new (), _unity_testing_logging_unref0 (logger), _tmp0_); quicklist_suite = (_tmp1_ = unity_tests_ui_quicklist_suite_new (), _g_object_unref0 (quicklist_suite), _tmp1_); + home_button_suite = (_tmp2_ = unity_tests_ui_home_button_suite_new (), _g_object_unref0 (home_button_suite), _tmp2_); g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 3, __lambda0__gsource_func, NULL, NULL); gtk_main (); result = 0; _unity_testing_logging_unref0 (logger); _g_object_unref0 (quicklist_suite); + _g_object_unref0 (home_button_suite); return result; } diff --git a/tests/ui/test-ui.vala b/tests/ui/test-ui.vala index a17b71402..afdd74d7f 100644 --- a/tests/ui/test-ui.vala +++ b/tests/ui/test-ui.vala @@ -87,8 +87,11 @@ public class Main { public static int main (string[] args) { - Logging logger; - QuicklistSuite quicklist_suite; + Logging logger; + QuicklistSuite quicklist_suite; + HomeButtonSuite home_button_suite; + //AutomationBasicTestSuite basic_test_suite; + Environment.set_variable ("UNITY_DISABLE_TRAY", "1", true); Environment.set_variable ("UNITY_DISABLE_IDLES", "1", true); @@ -102,7 +105,9 @@ public class Main logger = new Logging (); + //basic_test_suite = new AutomationBasicTestSuite (); quicklist_suite = new QuicklistSuite (); + home_button_suite = new HomeButtonSuite (); Timeout.add_seconds (3, ()=> { Test.run (); diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am index 06ba23139..0a7f17e92 100644 --- a/tests/unit/Makefile.am +++ b/tests/unit/Makefile.am @@ -49,6 +49,7 @@ test_unit_VALAFLAGS = \ test_unit_SOURCES = \ test-launcher.vala \ + test-panel-indicator-object-entry-view.vala \ test-places.vala \ test-unit.vala diff --git a/tests/unit/Makefile.in b/tests/unit/Makefile.in index 5fce8de69..8933b4e01 100644 --- a/tests/unit/Makefile.in +++ b/tests/unit/Makefile.in @@ -37,7 +37,8 @@ host_triplet = @host@ noinst_PROGRAMS = test-unit$(EXEEXT) subdir = tests/unit DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - test-launcher.c test-places.c test-unit.c test_unit_vala.stamp + test-launcher.c test-panel-indicator-object-entry-view.c \ + test-places.c test-unit.c test_unit_vala.stamp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \ $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \ @@ -56,6 +57,7 @@ CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = PROGRAMS = $(noinst_PROGRAMS) am_test_unit_OBJECTS = test_unit-test-launcher.$(OBJEXT) \ + test_unit-test-panel-indicator-object-entry-view.$(OBJEXT) \ test_unit-test-places.$(OBJEXT) test_unit-test-unit.$(OBJEXT) test_unit_OBJECTS = $(am_test_unit_OBJECTS) am__DEPENDENCIES_1 = @@ -345,6 +347,7 @@ test_unit_VALAFLAGS = \ test_unit_SOURCES = \ test-launcher.vala \ + test-panel-indicator-object-entry-view.vala \ test-places.vala \ test-unit.vala @@ -408,6 +411,7 @@ distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_unit-test-launcher.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_unit-test-panel-indicator-object-entry-view.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_unit-test-places.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_unit-test-unit.Po@am__quote@ @@ -451,6 +455,22 @@ test_unit-test-launcher.obj: test-launcher.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_unit_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_unit-test-launcher.obj `if test -f 'test-launcher.c'; then $(CYGPATH_W) 'test-launcher.c'; else $(CYGPATH_W) '$(srcdir)/test-launcher.c'; fi` +test_unit-test-panel-indicator-object-entry-view.o: test-panel-indicator-object-entry-view.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_unit_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_unit-test-panel-indicator-object-entry-view.o -MD -MP -MF $(DEPDIR)/test_unit-test-panel-indicator-object-entry-view.Tpo -c -o test_unit-test-panel-indicator-object-entry-view.o `test -f 'test-panel-indicator-object-entry-view.c' || echo '$(srcdir)/'`test-panel-indicator-object-entry-view.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_unit-test-panel-indicator-object-entry-view.Tpo $(DEPDIR)/test_unit-test-panel-indicator-object-entry-view.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='test-panel-indicator-object-entry-view.c' object='test_unit-test-panel-indicator-object-entry-view.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_unit_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_unit-test-panel-indicator-object-entry-view.o `test -f 'test-panel-indicator-object-entry-view.c' || echo '$(srcdir)/'`test-panel-indicator-object-entry-view.c + +test_unit-test-panel-indicator-object-entry-view.obj: test-panel-indicator-object-entry-view.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_unit_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_unit-test-panel-indicator-object-entry-view.obj -MD -MP -MF $(DEPDIR)/test_unit-test-panel-indicator-object-entry-view.Tpo -c -o test_unit-test-panel-indicator-object-entry-view.obj `if test -f 'test-panel-indicator-object-entry-view.c'; then $(CYGPATH_W) 'test-panel-indicator-object-entry-view.c'; else $(CYGPATH_W) '$(srcdir)/test-panel-indicator-object-entry-view.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_unit-test-panel-indicator-object-entry-view.Tpo $(DEPDIR)/test_unit-test-panel-indicator-object-entry-view.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='test-panel-indicator-object-entry-view.c' object='test_unit-test-panel-indicator-object-entry-view.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_unit_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_unit-test-panel-indicator-object-entry-view.obj `if test -f 'test-panel-indicator-object-entry-view.c'; then $(CYGPATH_W) 'test-panel-indicator-object-entry-view.c'; else $(CYGPATH_W) '$(srcdir)/test-panel-indicator-object-entry-view.c'; fi` + test_unit-test-places.o: test-places.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_unit_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_unit-test-places.o -MD -MP -MF $(DEPDIR)/test_unit-test-places.Tpo -c -o test_unit-test-places.o `test -f 'test-places.c' || echo '$(srcdir)/'`test-places.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_unit-test-places.Tpo $(DEPDIR)/test_unit-test-places.Po @@ -487,6 +507,11 @@ $(srcdir)/test-launcher.c: $(srcdir)/test_unit_vala.stamp rm -f $(srcdir)/test_unit_vala.stamp; \ $(am__cd) $(srcdir) && $(MAKE) $(AM_MAKEFLAGS) test_unit_vala.stamp; \ fi +$(srcdir)/test-panel-indicator-object-entry-view.c: $(srcdir)/test_unit_vala.stamp + @if test -f $@; then :; else \ + rm -f $(srcdir)/test_unit_vala.stamp; \ + $(am__cd) $(srcdir) && $(MAKE) $(AM_MAKEFLAGS) test_unit_vala.stamp; \ + fi $(srcdir)/test-places.c: $(srcdir)/test_unit_vala.stamp @if test -f $@; then :; else \ rm -f $(srcdir)/test_unit_vala.stamp; \ @@ -733,6 +758,7 @@ maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -rm -f test-launcher.c + -rm -f test-panel-indicator-object-entry-view.c -rm -f test-places.c -rm -f test-unit.c -rm -f test_unit_vala.stamp diff --git a/tests/unit/test-panel-indicator-object-entry-view.c b/tests/unit/test-panel-indicator-object-entry-view.c new file mode 100644 index 000000000..127aad2a1 --- /dev/null +++ b/tests/unit/test-panel-indicator-object-entry-view.c @@ -0,0 +1,237 @@ +/* test-panel-indicator-object-entry-view.c generated by valac, the Vala compiler + * generated from test-panel-indicator-object-entry-view.vala, do not modify */ + +/* + * Copyright (C) 2009 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by Neil Jagdish Patel <neil.patel@canonical.com> + * + */ + +#include <glib.h> +#include <glib-object.h> +#include <gtk/gtk.h> +#include <libindicator/indicator.h> +#include <libindicator/indicator-object.h> +#include <libindicator/indicator-service.h> +#include <libindicator/indicator-service-manager.h> +#include <stdlib.h> +#include <string.h> +#include <unity-private.h> +#include <clutter/clutter.h> +#include <clutk/clutk.h> +#include <gdk-pixbuf/gdk-pixdata.h> + + +#define UNITY_TESTS_UNIT_TYPE_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE (unity_tests_unit_panel_indicator_object_entry_view_suite_get_type ()) +#define UNITY_TESTS_UNIT_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_TESTS_UNIT_TYPE_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE, UnityTestsUnitPanelIndicatorObjectEntryViewSuite)) +#define UNITY_TESTS_UNIT_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_TESTS_UNIT_TYPE_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE, UnityTestsUnitPanelIndicatorObjectEntryViewSuiteClass)) +#define UNITY_TESTS_UNIT_IS_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_TESTS_UNIT_TYPE_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE)) +#define UNITY_TESTS_UNIT_IS_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_TESTS_UNIT_TYPE_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE)) +#define UNITY_TESTS_UNIT_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_TESTS_UNIT_TYPE_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE, UnityTestsUnitPanelIndicatorObjectEntryViewSuiteClass)) + +typedef struct _UnityTestsUnitPanelIndicatorObjectEntryViewSuite UnityTestsUnitPanelIndicatorObjectEntryViewSuite; +typedef struct _UnityTestsUnitPanelIndicatorObjectEntryViewSuiteClass UnityTestsUnitPanelIndicatorObjectEntryViewSuiteClass; +typedef struct _UnityTestsUnitPanelIndicatorObjectEntryViewSuitePrivate UnityTestsUnitPanelIndicatorObjectEntryViewSuitePrivate; +#define _indicator_object_entry_free0(var) ((var == NULL) ? NULL : (var = (indicator_object_entry_free (var), NULL))) +#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) +#define _g_free0(var) (var = (g_free (var), NULL)) + +struct _UnityTestsUnitPanelIndicatorObjectEntryViewSuite { + GObject parent_instance; + UnityTestsUnitPanelIndicatorObjectEntryViewSuitePrivate * priv; +}; + +struct _UnityTestsUnitPanelIndicatorObjectEntryViewSuiteClass { + GObjectClass parent_class; +}; + +struct _UnityTestsUnitPanelIndicatorObjectEntryViewSuitePrivate { + IndicatorObjectEntry* entry; + GtkMenu* menu; + GtkLabel* label; + GtkImage* image; +}; + + +static gpointer unity_tests_unit_panel_indicator_object_entry_view_suite_parent_class = NULL; + +GType unity_tests_unit_panel_indicator_object_entry_view_suite_get_type (void); +#define UNITY_TESTS_UNIT_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UNITY_TESTS_UNIT_TYPE_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE, UnityTestsUnitPanelIndicatorObjectEntryViewSuitePrivate)) +enum { + UNITY_TESTS_UNIT_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE_DUMMY_PROPERTY +}; +#define UNITY_TESTS_UNIT_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE_DOMAIN "/Unit/Panel/Indicator/ObjectEntry" +static void unity_tests_unit_panel_indicator_object_entry_view_suite_test_allocation (UnityTestsUnitPanelIndicatorObjectEntryViewSuite* self); +static void _unity_tests_unit_panel_indicator_object_entry_view_suite_test_allocation_gdata_test_func (gpointer self); +static void unity_tests_unit_panel_indicator_object_entry_view_suite_test_label_sync (UnityTestsUnitPanelIndicatorObjectEntryViewSuite* self); +static void _unity_tests_unit_panel_indicator_object_entry_view_suite_test_label_sync_gdata_test_func (gpointer self); +static void unity_tests_unit_panel_indicator_object_entry_view_suite_test_image_sync (UnityTestsUnitPanelIndicatorObjectEntryViewSuite* self); +static void _unity_tests_unit_panel_indicator_object_entry_view_suite_test_image_sync_gdata_test_func (gpointer self); +UnityTestsUnitPanelIndicatorObjectEntryViewSuite* unity_tests_unit_panel_indicator_object_entry_view_suite_new (void); +UnityTestsUnitPanelIndicatorObjectEntryViewSuite* unity_tests_unit_panel_indicator_object_entry_view_suite_construct (GType object_type); +static void unity_tests_unit_panel_indicator_object_entry_view_suite_finalize (GObject* obj); +static int _vala_strcmp0 (const char * str1, const char * str2); + + + +static void _unity_tests_unit_panel_indicator_object_entry_view_suite_test_allocation_gdata_test_func (gpointer self) { + unity_tests_unit_panel_indicator_object_entry_view_suite_test_allocation (self); +} + + +static void _unity_tests_unit_panel_indicator_object_entry_view_suite_test_label_sync_gdata_test_func (gpointer self) { + unity_tests_unit_panel_indicator_object_entry_view_suite_test_label_sync (self); +} + + +static void _unity_tests_unit_panel_indicator_object_entry_view_suite_test_image_sync_gdata_test_func (gpointer self) { + unity_tests_unit_panel_indicator_object_entry_view_suite_test_image_sync (self); +} + + +UnityTestsUnitPanelIndicatorObjectEntryViewSuite* unity_tests_unit_panel_indicator_object_entry_view_suite_construct (GType object_type) { + UnityTestsUnitPanelIndicatorObjectEntryViewSuite * self; + IndicatorObjectEntry* _tmp0_; + GtkMenu* _tmp1_; + GtkLabel* _tmp2_; + GtkImage* _tmp3_; + self = (UnityTestsUnitPanelIndicatorObjectEntryViewSuite*) g_object_new (object_type, NULL); + unity_testing_logging_init_fatal_handler (); + self->priv->entry = (_tmp0_ = indicator_object_entry_new (), _indicator_object_entry_free0 (self->priv->entry), _tmp0_); + self->priv->menu = (_tmp1_ = g_object_ref_sink ((GtkMenu*) gtk_menu_new ()), _g_object_unref0 (self->priv->menu), _tmp1_); + self->priv->entry->menu = self->priv->menu; + self->priv->label = (_tmp2_ = g_object_ref_sink ((GtkLabel*) gtk_label_new ("Test Label")), _g_object_unref0 (self->priv->label), _tmp2_); + self->priv->entry->label = self->priv->label; + self->priv->image = (_tmp3_ = g_object_ref_sink ((GtkImage*) gtk_image_new_from_icon_name ("gtk-apply", GTK_ICON_SIZE_MENU)), _g_object_unref0 (self->priv->image), _tmp3_); + self->priv->entry->image = self->priv->image; + g_test_add_data_func (UNITY_TESTS_UNIT_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE_DOMAIN "/Allocation", self, _unity_tests_unit_panel_indicator_object_entry_view_suite_test_allocation_gdata_test_func); + g_test_add_data_func (UNITY_TESTS_UNIT_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE_DOMAIN "/LabelSync", self, _unity_tests_unit_panel_indicator_object_entry_view_suite_test_label_sync_gdata_test_func); + g_test_add_data_func (UNITY_TESTS_UNIT_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE_DOMAIN "/ImageSync", self, _unity_tests_unit_panel_indicator_object_entry_view_suite_test_image_sync_gdata_test_func); + return self; +} + + +UnityTestsUnitPanelIndicatorObjectEntryViewSuite* unity_tests_unit_panel_indicator_object_entry_view_suite_new (void) { + return unity_tests_unit_panel_indicator_object_entry_view_suite_construct (UNITY_TESTS_UNIT_TYPE_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE); +} + + +static void unity_tests_unit_panel_indicator_object_entry_view_suite_test_allocation (UnityTestsUnitPanelIndicatorObjectEntryViewSuite* self) { + UnityPanelIndicatorsIndicatorObjectEntryView* e; + g_return_if_fail (self != NULL); + e = g_object_ref_sink (unity_panel_indicators_indicator_object_entry_view_new (self->priv->entry)); + g_assert (UNITY_PANEL_INDICATORS_IS_INDICATOR_OBJECT_ENTRY_VIEW (e)); + _g_object_unref0 (e); +} + + +static void unity_tests_unit_panel_indicator_object_entry_view_suite_test_label_sync (UnityTestsUnitPanelIndicatorObjectEntryViewSuite* self) { + UnityPanelIndicatorsIndicatorObjectEntryView* e; + g_return_if_fail (self != NULL); + e = g_object_ref_sink (unity_panel_indicators_indicator_object_entry_view_new (self->priv->entry)); + g_assert (UNITY_PANEL_INDICATORS_IS_INDICATOR_OBJECT_ENTRY_VIEW (e)); + g_assert (_vala_strcmp0 (clutter_text_get_text ((ClutterText*) e->text), gtk_label_get_label (self->priv->label)) == 0); + gtk_label_set_label (self->priv->label, "Test Label 2"); + g_assert (_vala_strcmp0 (clutter_text_get_text ((ClutterText*) e->text), gtk_label_get_label (self->priv->label)) == 0); + gtk_label_set_label (self->priv->label, "Test Label"); + _g_object_unref0 (e); +} + + +static void unity_tests_unit_panel_indicator_object_entry_view_suite_test_image_sync (UnityTestsUnitPanelIndicatorObjectEntryViewSuite* self) { + UnityPanelIndicatorsIndicatorObjectEntryView* e; + char* _tmp3_; + char* _tmp1_; + char* _tmp0_ = NULL; + char* _tmp2_ = NULL; + char* _tmp7_; + char* _tmp5_; + char* _tmp4_ = NULL; + char* _tmp6_ = NULL; + GdkPixbuf* p; + GdkPixbuf* _tmp11_; + GdkPixbuf* _tmp9_; + GdkPixbuf* _tmp8_ = NULL; + GdkPixbuf* _tmp10_ = NULL; + g_return_if_fail (self != NULL); + e = g_object_ref_sink (unity_panel_indicators_indicator_object_entry_view_new (self->priv->entry)); + g_assert (UNITY_PANEL_INDICATORS_IS_INDICATOR_OBJECT_ENTRY_VIEW (e)); + g_assert (_vala_strcmp0 (_tmp1_ = (g_object_get (e->image, "stock-id", &_tmp0_, NULL), _tmp0_), _tmp3_ = (g_object_get (self->priv->image, "icon-name", &_tmp2_, NULL), _tmp2_)) == 0); + _g_free0 (_tmp3_); + _g_free0 (_tmp1_); + g_object_set (self->priv->image, "icon-name", "gtk-close", NULL); + g_assert (_vala_strcmp0 (_tmp5_ = (g_object_get (e->image, "stock-id", &_tmp4_, NULL), _tmp4_), _tmp7_ = (g_object_get (self->priv->image, "icon-name", &_tmp6_, NULL), _tmp6_)) == 0); + _g_free0 (_tmp7_); + _g_free0 (_tmp5_); + p = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 100, 100); + g_object_set (self->priv->image, "pixbuf", p, NULL); + g_assert ((_tmp9_ = (g_object_get (e->image, "pixbuf", &_tmp8_, NULL), _tmp8_)) == (_tmp11_ = (g_object_get (self->priv->image, "pixbuf", &_tmp10_, NULL), _tmp10_))); + _g_object_unref0 (_tmp11_); + _g_object_unref0 (_tmp9_); + g_object_set (self->priv->image, "icon-name", "gtk-apply", NULL); + _g_object_unref0 (e); + _g_object_unref0 (p); +} + + +static void unity_tests_unit_panel_indicator_object_entry_view_suite_class_init (UnityTestsUnitPanelIndicatorObjectEntryViewSuiteClass * klass) { + unity_tests_unit_panel_indicator_object_entry_view_suite_parent_class = g_type_class_peek_parent (klass); + g_type_class_add_private (klass, sizeof (UnityTestsUnitPanelIndicatorObjectEntryViewSuitePrivate)); + G_OBJECT_CLASS (klass)->finalize = unity_tests_unit_panel_indicator_object_entry_view_suite_finalize; +} + + +static void unity_tests_unit_panel_indicator_object_entry_view_suite_instance_init (UnityTestsUnitPanelIndicatorObjectEntryViewSuite * self) { + self->priv = UNITY_TESTS_UNIT_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE_GET_PRIVATE (self); +} + + +static void unity_tests_unit_panel_indicator_object_entry_view_suite_finalize (GObject* obj) { + UnityTestsUnitPanelIndicatorObjectEntryViewSuite * self; + self = UNITY_TESTS_UNIT_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE (obj); + _indicator_object_entry_free0 (self->priv->entry); + _g_object_unref0 (self->priv->menu); + _g_object_unref0 (self->priv->label); + _g_object_unref0 (self->priv->image); + G_OBJECT_CLASS (unity_tests_unit_panel_indicator_object_entry_view_suite_parent_class)->finalize (obj); +} + + +GType unity_tests_unit_panel_indicator_object_entry_view_suite_get_type (void) { + static volatile gsize unity_tests_unit_panel_indicator_object_entry_view_suite_type_id__volatile = 0; + if (g_once_init_enter (&unity_tests_unit_panel_indicator_object_entry_view_suite_type_id__volatile)) { + static const GTypeInfo g_define_type_info = { sizeof (UnityTestsUnitPanelIndicatorObjectEntryViewSuiteClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) unity_tests_unit_panel_indicator_object_entry_view_suite_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UnityTestsUnitPanelIndicatorObjectEntryViewSuite), 0, (GInstanceInitFunc) unity_tests_unit_panel_indicator_object_entry_view_suite_instance_init, NULL }; + GType unity_tests_unit_panel_indicator_object_entry_view_suite_type_id; + unity_tests_unit_panel_indicator_object_entry_view_suite_type_id = g_type_register_static (G_TYPE_OBJECT, "UnityTestsUnitPanelIndicatorObjectEntryViewSuite", &g_define_type_info, 0); + g_once_init_leave (&unity_tests_unit_panel_indicator_object_entry_view_suite_type_id__volatile, unity_tests_unit_panel_indicator_object_entry_view_suite_type_id); + } + return unity_tests_unit_panel_indicator_object_entry_view_suite_type_id__volatile; +} + + +static int _vala_strcmp0 (const char * str1, const char * str2) { + if (str1 == NULL) { + return -(str1 != str2); + } + if (str2 == NULL) { + return str1 != str2; + } + return strcmp (str1, str2); +} + + + + diff --git a/tests/unit/test-panel-indicator-object-entry-view.vala b/tests/unit/test-panel-indicator-object-entry-view.vala new file mode 100644 index 000000000..d6d20a87c --- /dev/null +++ b/tests/unit/test-panel-indicator-object-entry-view.vala @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2009 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by Neil Jagdish Patel <neil.patel@canonical.com> + * + */ +using Unity; +using Unity.Testing; +using Unity.Panel.Indicators; + +namespace Unity.Tests.Unit +{ + public class PanelIndicatorObjectEntryViewSuite : Object + { + public const string DOMAIN = "/Unit/Panel/Indicator/ObjectEntry"; + + private Indicator.ObjectEntry entry; + private Gtk.Menu menu; + private Gtk.Label label; + private Gtk.Image image; + + public PanelIndicatorObjectEntryViewSuite () + { + Logging.init_fatal_handler (); + + entry = new Indicator.ObjectEntry (); + + menu = new Gtk.Menu (); + entry.menu = menu; + + label = new Gtk.Label ("Test Label"); + entry.label = label; + + image = new Gtk.Image.from_icon_name ("gtk-apply", Gtk.IconSize.MENU); + entry.image = image; + + Test.add_data_func (DOMAIN + "/Allocation", test_allocation); + Test.add_data_func (DOMAIN + "/LabelSync", test_label_sync); + Test.add_data_func (DOMAIN + "/ImageSync", test_image_sync); + } + + private void test_allocation () + { + var e = new IndicatorObjectEntryView (entry); + + assert (e is IndicatorObjectEntryView); + } + + private void test_label_sync () + { + var e = new IndicatorObjectEntryView (entry); + + assert (e is IndicatorObjectEntryView); + + /* Make sure text is in sync */ + assert (e.text.text == label.label); + + /* Update the label and check again */ + label.label = "Test Label 2"; + assert (e.text.text == label.label); + + label.label = "Test Label"; + } + + private void test_image_sync () + { + var e = new IndicatorObjectEntryView (entry); + assert (e is IndicatorObjectEntryView); + + /* Test that the icon name has synced */ + assert (e.image.stock_id == image.icon_name); + + /* Test that if it changes entry keeps it in sync */ + image.icon_name = "gtk-close"; + assert (e.image.stock_id == image.icon_name); + + /* Test pixbuf */ + var p = new Gdk.Pixbuf (Gdk.Colorspace.RGB, true, 8, 100, 100); + image.pixbuf = p; + assert (e.image.pixbuf == image.pixbuf); + + image.icon_name = "gtk-apply"; + } + } +} diff --git a/tests/unit/test-unit.c b/tests/unit/test-unit.c index c87f07a27..af9af5f67 100644 --- a/tests/unit/test-unit.c +++ b/tests/unit/test-unit.c @@ -40,6 +40,16 @@ typedef struct _Main Main; typedef struct _MainClass MainClass; typedef struct _MainPrivate MainPrivate; +#define UNITY_TESTS_UNIT_TYPE_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE (unity_tests_unit_panel_indicator_object_entry_view_suite_get_type ()) +#define UNITY_TESTS_UNIT_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_TESTS_UNIT_TYPE_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE, UnityTestsUnitPanelIndicatorObjectEntryViewSuite)) +#define UNITY_TESTS_UNIT_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_TESTS_UNIT_TYPE_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE, UnityTestsUnitPanelIndicatorObjectEntryViewSuiteClass)) +#define UNITY_TESTS_UNIT_IS_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_TESTS_UNIT_TYPE_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE)) +#define UNITY_TESTS_UNIT_IS_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_TESTS_UNIT_TYPE_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE)) +#define UNITY_TESTS_UNIT_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_TESTS_UNIT_TYPE_PANEL_INDICATOR_OBJECT_ENTRY_VIEW_SUITE, UnityTestsUnitPanelIndicatorObjectEntryViewSuiteClass)) + +typedef struct _UnityTestsUnitPanelIndicatorObjectEntryViewSuite UnityTestsUnitPanelIndicatorObjectEntryViewSuite; +typedef struct _UnityTestsUnitPanelIndicatorObjectEntryViewSuiteClass UnityTestsUnitPanelIndicatorObjectEntryViewSuiteClass; + #define UNITY_TESTS_UNIT_TYPE_PLACES_SUITE (unity_tests_unit_places_suite_get_type ()) #define UNITY_TESTS_UNIT_PLACES_SUITE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_TESTS_UNIT_TYPE_PLACES_SUITE, UnityTestsUnitPlacesSuite)) #define UNITY_TESTS_UNIT_PLACES_SUITE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_TESTS_UNIT_TYPE_PLACES_SUITE, UnityTestsUnitPlacesSuiteClass)) @@ -59,6 +69,7 @@ typedef struct _UnityTestsUnitPlacesSuiteClass UnityTestsUnitPlacesSuiteClass; typedef struct _UnityTestsUnitLauncherSuite UnityTestsUnitLauncherSuite; typedef struct _UnityTestsUnitLauncherSuiteClass UnityTestsUnitLauncherSuiteClass; +#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) #define _unity_tests_unit_launcher_suite_unref0(var) ((var == NULL) ? NULL : (var = (unity_tests_unit_launcher_suite_unref (var), NULL))) #define _unity_tests_unit_places_suite_unref0(var) ((var == NULL) ? NULL : (var = (unity_tests_unit_places_suite_unref (var), NULL))) typedef struct _ParamSpecMain ParamSpecMain; @@ -91,6 +102,7 @@ GType main_get_type (void); enum { MAIN_DUMMY_PROPERTY }; +GType unity_tests_unit_panel_indicator_object_entry_view_suite_get_type (void); gpointer unity_tests_unit_places_suite_ref (gpointer instance); void unity_tests_unit_places_suite_unref (gpointer instance); GParamSpec* unity_tests_unit_param_spec_places_suite (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags); @@ -105,6 +117,8 @@ void unity_tests_unit_value_set_launcher_suite (GValue* value, gpointer v_object void unity_tests_unit_value_take_launcher_suite (GValue* value, gpointer v_object); gpointer unity_tests_unit_value_get_launcher_suite (const GValue* value); GType unity_tests_unit_launcher_suite_get_type (void); +UnityTestsUnitPanelIndicatorObjectEntryViewSuite* unity_tests_unit_panel_indicator_object_entry_view_suite_new (void); +UnityTestsUnitPanelIndicatorObjectEntryViewSuite* unity_tests_unit_panel_indicator_object_entry_view_suite_construct (GType object_type); UnityTestsUnitLauncherSuite* unity_tests_unit_launcher_suite_new (void); UnityTestsUnitLauncherSuite* unity_tests_unit_launcher_suite_construct (GType object_type); UnityTestsUnitPlacesSuite* unity_tests_unit_places_suite_new (void); @@ -118,21 +132,26 @@ static void main_finalize (Main* obj); gint main_main (char** args, int args_length1) { gint result = 0; + UnityTestsUnitPanelIndicatorObjectEntryViewSuite* panel_object_entry_view_suite; UnityTestsUnitPlacesSuite* places; - UnityTestsUnitLauncherSuite* Launcher; - UnityTestsUnitLauncherSuite* _tmp0_; - UnityTestsUnitPlacesSuite* _tmp1_; + UnityTestsUnitLauncherSuite* launcher; + UnityTestsUnitPanelIndicatorObjectEntryViewSuite* _tmp0_; + UnityTestsUnitLauncherSuite* _tmp1_; + UnityTestsUnitPlacesSuite* _tmp2_; + panel_object_entry_view_suite = NULL; places = NULL; - Launcher = NULL; + launcher = NULL; gtk_init (&args_length1, &args); ctk_init (&args_length1, &args); g_test_init (&args_length1, &args, NULL); - Launcher = (_tmp0_ = unity_tests_unit_launcher_suite_new (), _unity_tests_unit_launcher_suite_unref0 (Launcher), _tmp0_); - places = (_tmp1_ = unity_tests_unit_places_suite_new (), _unity_tests_unit_places_suite_unref0 (places), _tmp1_); + panel_object_entry_view_suite = (_tmp0_ = unity_tests_unit_panel_indicator_object_entry_view_suite_new (), _g_object_unref0 (panel_object_entry_view_suite), _tmp0_); + launcher = (_tmp1_ = unity_tests_unit_launcher_suite_new (), _unity_tests_unit_launcher_suite_unref0 (launcher), _tmp1_); + places = (_tmp2_ = unity_tests_unit_places_suite_new (), _unity_tests_unit_places_suite_unref0 (places), _tmp2_); g_test_run (); result = 0; + _g_object_unref0 (panel_object_entry_view_suite); _unity_tests_unit_places_suite_unref0 (places); - _unity_tests_unit_launcher_suite_unref0 (Launcher); + _unity_tests_unit_launcher_suite_unref0 (launcher); return result; } diff --git a/tests/unit/test-unit.vala b/tests/unit/test-unit.vala index 19bdaf725..f7fb87253 100644 --- a/tests/unit/test-unit.vala +++ b/tests/unit/test-unit.vala @@ -24,14 +24,16 @@ public class Main { public static int main (string[] args) { + PanelIndicatorObjectEntryViewSuite panel_object_entry_view_suite; PlacesSuite places; - LauncherSuite Launcher; + LauncherSuite launcher; Gtk.init (ref args); Ctk.init (ref args); Test.init (ref args); - Launcher = new LauncherSuite (); + panel_object_entry_view_suite = new PanelIndicatorObjectEntryViewSuite (); + launcher = new LauncherSuite (); places = new PlacesSuite (); Test.run (); diff --git a/unity-private/Makefile.am b/unity-private/Makefile.am index a2a2f174d..518fc6d8c 100644 --- a/unity-private/Makefile.am +++ b/unity-private/Makefile.am @@ -72,8 +72,15 @@ private_sources = \ utils.vala panel_sources = \ - panel/panel-home.vala \ + panel/panel-background.vala \ + panel/panel-home-button.vala \ + panel/panel-indicator-bar.vala \ + panel/panel-indicator-model.vala \ + panel/panel-indicator-object-entry-view.vala \ + panel/panel-indicator-object-view.vala \ panel/panel-indicators.vala \ + panel/panel-menu-manager.vala \ + panel/panel-menubar.vala \ panel/panel-tray.vala \ panel/panel-view.vala diff --git a/unity-private/Makefile.in b/unity-private/Makefile.in index c86cc9bff..1298d0f03 100644 --- a/unity-private/Makefile.in +++ b/unity-private/Makefile.in @@ -81,8 +81,15 @@ libunity_private_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/unity/libunity.la am__objects_1 = libunity_private_la-application.lo \ libunity_private_la-unity.lo libunity_private_la-utils.lo -am__objects_2 = libunity_private_la-panel-home.lo \ +am__objects_2 = libunity_private_la-panel-background.lo \ + libunity_private_la-panel-home-button.lo \ + libunity_private_la-panel-indicator-bar.lo \ + libunity_private_la-panel-indicator-model.lo \ + libunity_private_la-panel-indicator-object-entry-view.lo \ + libunity_private_la-panel-indicator-object-view.lo \ libunity_private_la-panel-indicators.lo \ + libunity_private_la-panel-menu-manager.lo \ + libunity_private_la-panel-menubar.lo \ libunity_private_la-panel-tray.lo \ libunity_private_la-panel-view.lo am__objects_3 = libunity_private_la-application-place.lo \ @@ -382,8 +389,15 @@ private_sources = \ utils.vala panel_sources = \ - panel/panel-home.vala \ + panel/panel-background.vala \ + panel/panel-home-button.vala \ + panel/panel-indicator-bar.vala \ + panel/panel-indicator-model.vala \ + panel/panel-indicator-object-entry-view.vala \ + panel/panel-indicator-object-view.vala \ panel/panel-indicators.vala \ + panel/panel-menu-manager.vala \ + panel/panel-menubar.vala \ panel/panel-tray.vala \ panel/panel-view.vala @@ -525,8 +539,15 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libunity_private_la-launcher-child.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libunity_private_la-launcher.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libunity_private_la-object-registry.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libunity_private_la-panel-home.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libunity_private_la-panel-background.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libunity_private_la-panel-home-button.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libunity_private_la-panel-indicator-bar.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libunity_private_la-panel-indicator-model.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libunity_private_la-panel-indicator-object-entry-view.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libunity_private_la-panel-indicator-object-view.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libunity_private_la-panel-indicators.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libunity_private_la-panel-menu-manager.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libunity_private_la-panel-menubar.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libunity_private_la-panel-tray.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libunity_private_la-panel-view.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libunity_private_la-perf-logger.Plo@am__quote@ @@ -608,13 +629,53 @@ libunity_private_la-utils.lo: utils.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunity_private_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libunity_private_la-utils.lo `test -f 'utils.c' || echo '$(srcdir)/'`utils.c -libunity_private_la-panel-home.lo: panel/panel-home.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunity_private_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libunity_private_la-panel-home.lo -MD -MP -MF $(DEPDIR)/libunity_private_la-panel-home.Tpo -c -o libunity_private_la-panel-home.lo `test -f 'panel/panel-home.c' || echo '$(srcdir)/'`panel/panel-home.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libunity_private_la-panel-home.Tpo $(DEPDIR)/libunity_private_la-panel-home.Plo +libunity_private_la-panel-background.lo: panel/panel-background.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunity_private_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libunity_private_la-panel-background.lo -MD -MP -MF $(DEPDIR)/libunity_private_la-panel-background.Tpo -c -o libunity_private_la-panel-background.lo `test -f 'panel/panel-background.c' || echo '$(srcdir)/'`panel/panel-background.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libunity_private_la-panel-background.Tpo $(DEPDIR)/libunity_private_la-panel-background.Plo @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='panel/panel-home.c' object='libunity_private_la-panel-home.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='panel/panel-background.c' object='libunity_private_la-panel-background.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunity_private_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libunity_private_la-panel-home.lo `test -f 'panel/panel-home.c' || echo '$(srcdir)/'`panel/panel-home.c +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunity_private_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libunity_private_la-panel-background.lo `test -f 'panel/panel-background.c' || echo '$(srcdir)/'`panel/panel-background.c + +libunity_private_la-panel-home-button.lo: panel/panel-home-button.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunity_private_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libunity_private_la-panel-home-button.lo -MD -MP -MF $(DEPDIR)/libunity_private_la-panel-home-button.Tpo -c -o libunity_private_la-panel-home-button.lo `test -f 'panel/panel-home-button.c' || echo '$(srcdir)/'`panel/panel-home-button.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libunity_private_la-panel-home-button.Tpo $(DEPDIR)/libunity_private_la-panel-home-button.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='panel/panel-home-button.c' object='libunity_private_la-panel-home-button.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunity_private_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libunity_private_la-panel-home-button.lo `test -f 'panel/panel-home-button.c' || echo '$(srcdir)/'`panel/panel-home-button.c + +libunity_private_la-panel-indicator-bar.lo: panel/panel-indicator-bar.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunity_private_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libunity_private_la-panel-indicator-bar.lo -MD -MP -MF $(DEPDIR)/libunity_private_la-panel-indicator-bar.Tpo -c -o libunity_private_la-panel-indicator-bar.lo `test -f 'panel/panel-indicator-bar.c' || echo '$(srcdir)/'`panel/panel-indicator-bar.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libunity_private_la-panel-indicator-bar.Tpo $(DEPDIR)/libunity_private_la-panel-indicator-bar.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='panel/panel-indicator-bar.c' object='libunity_private_la-panel-indicator-bar.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunity_private_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libunity_private_la-panel-indicator-bar.lo `test -f 'panel/panel-indicator-bar.c' || echo '$(srcdir)/'`panel/panel-indicator-bar.c + +libunity_private_la-panel-indicator-model.lo: panel/panel-indicator-model.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunity_private_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libunity_private_la-panel-indicator-model.lo -MD -MP -MF $(DEPDIR)/libunity_private_la-panel-indicator-model.Tpo -c -o libunity_private_la-panel-indicator-model.lo `test -f 'panel/panel-indicator-model.c' || echo '$(srcdir)/'`panel/panel-indicator-model.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libunity_private_la-panel-indicator-model.Tpo $(DEPDIR)/libunity_private_la-panel-indicator-model.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='panel/panel-indicator-model.c' object='libunity_private_la-panel-indicator-model.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunity_private_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libunity_private_la-panel-indicator-model.lo `test -f 'panel/panel-indicator-model.c' || echo '$(srcdir)/'`panel/panel-indicator-model.c + +libunity_private_la-panel-indicator-object-entry-view.lo: panel/panel-indicator-object-entry-view.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunity_private_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libunity_private_la-panel-indicator-object-entry-view.lo -MD -MP -MF $(DEPDIR)/libunity_private_la-panel-indicator-object-entry-view.Tpo -c -o libunity_private_la-panel-indicator-object-entry-view.lo `test -f 'panel/panel-indicator-object-entry-view.c' || echo '$(srcdir)/'`panel/panel-indicator-object-entry-view.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libunity_private_la-panel-indicator-object-entry-view.Tpo $(DEPDIR)/libunity_private_la-panel-indicator-object-entry-view.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='panel/panel-indicator-object-entry-view.c' object='libunity_private_la-panel-indicator-object-entry-view.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunity_private_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libunity_private_la-panel-indicator-object-entry-view.lo `test -f 'panel/panel-indicator-object-entry-view.c' || echo '$(srcdir)/'`panel/panel-indicator-object-entry-view.c + +libunity_private_la-panel-indicator-object-view.lo: panel/panel-indicator-object-view.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunity_private_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libunity_private_la-panel-indicator-object-view.lo -MD -MP -MF $(DEPDIR)/libunity_private_la-panel-indicator-object-view.Tpo -c -o libunity_private_la-panel-indicator-object-view.lo `test -f 'panel/panel-indicator-object-view.c' || echo '$(srcdir)/'`panel/panel-indicator-object-view.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libunity_private_la-panel-indicator-object-view.Tpo $(DEPDIR)/libunity_private_la-panel-indicator-object-view.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='panel/panel-indicator-object-view.c' object='libunity_private_la-panel-indicator-object-view.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunity_private_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libunity_private_la-panel-indicator-object-view.lo `test -f 'panel/panel-indicator-object-view.c' || echo '$(srcdir)/'`panel/panel-indicator-object-view.c libunity_private_la-panel-indicators.lo: panel/panel-indicators.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunity_private_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libunity_private_la-panel-indicators.lo -MD -MP -MF $(DEPDIR)/libunity_private_la-panel-indicators.Tpo -c -o libunity_private_la-panel-indicators.lo `test -f 'panel/panel-indicators.c' || echo '$(srcdir)/'`panel/panel-indicators.c @@ -624,6 +685,22 @@ libunity_private_la-panel-indicators.lo: panel/panel-indicators.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunity_private_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libunity_private_la-panel-indicators.lo `test -f 'panel/panel-indicators.c' || echo '$(srcdir)/'`panel/panel-indicators.c +libunity_private_la-panel-menu-manager.lo: panel/panel-menu-manager.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunity_private_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libunity_private_la-panel-menu-manager.lo -MD -MP -MF $(DEPDIR)/libunity_private_la-panel-menu-manager.Tpo -c -o libunity_private_la-panel-menu-manager.lo `test -f 'panel/panel-menu-manager.c' || echo '$(srcdir)/'`panel/panel-menu-manager.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libunity_private_la-panel-menu-manager.Tpo $(DEPDIR)/libunity_private_la-panel-menu-manager.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='panel/panel-menu-manager.c' object='libunity_private_la-panel-menu-manager.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunity_private_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libunity_private_la-panel-menu-manager.lo `test -f 'panel/panel-menu-manager.c' || echo '$(srcdir)/'`panel/panel-menu-manager.c + +libunity_private_la-panel-menubar.lo: panel/panel-menubar.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunity_private_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libunity_private_la-panel-menubar.lo -MD -MP -MF $(DEPDIR)/libunity_private_la-panel-menubar.Tpo -c -o libunity_private_la-panel-menubar.lo `test -f 'panel/panel-menubar.c' || echo '$(srcdir)/'`panel/panel-menubar.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libunity_private_la-panel-menubar.Tpo $(DEPDIR)/libunity_private_la-panel-menubar.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='panel/panel-menubar.c' object='libunity_private_la-panel-menubar.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunity_private_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libunity_private_la-panel-menubar.lo `test -f 'panel/panel-menubar.c' || echo '$(srcdir)/'`panel/panel-menubar.c + libunity_private_la-panel-tray.lo: panel/panel-tray.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunity_private_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libunity_private_la-panel-tray.lo -MD -MP -MF $(DEPDIR)/libunity_private_la-panel-tray.Tpo -c -o libunity_private_la-panel-tray.lo `test -f 'panel/panel-tray.c' || echo '$(srcdir)/'`panel/panel-tray.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libunity_private_la-panel-tray.Tpo $(DEPDIR)/libunity_private_la-panel-tray.Plo diff --git a/unity-private/application.c b/unity-private/application.c index 9f4b26b67..3309c2080 100644 --- a/unity-private/application.c +++ b/unity-private/application.c @@ -297,7 +297,9 @@ void unity_application_set_shell (UnityApplication* self, UnityShell* value) { static UniqueResponse _unity_application_on_message_received_unique_app_message_received (UniqueApp* _sender, gint command, UniqueMessageData* message_data, guint time_, gpointer self) { - return unity_application_on_message_received (self, command, message_data, time_); + UniqueResponse result; + result = unity_application_on_message_received (self, command, message_data, time_); + return result; } diff --git a/unity-private/launcher/application-controller.c b/unity-private/launcher/application-controller.c index 3bdefe774..dac8d6580 100644 --- a/unity-private/launcher/application-controller.c +++ b/unity-private/launcher/application-controller.c @@ -332,18 +332,18 @@ gboolean unity_launcher_application_controller_debug_is_application_attached (Un static void unity_launcher_application_controller_load_desktop_file_info (UnityLauncherApplicationController* self); static gboolean unity_launcher_application_controller_try_load_from_file (UnityLauncherApplicationController* self, const char* filepath); void unity_launcher_scroller_child_set_icon (UnityLauncherScrollerChild* self, GdkPixbuf* value); -static void _lambda8_ (UnityThemeFilePath* theme, const char* filepath, UnityLauncherApplicationController* self); -static void __lambda8__unity_theme_file_path_found_icon_path (UnityThemeFilePath* _sender, const char* filepath, gpointer self); -static void _lambda9_ (UnityLauncherApplicationController* self); -static void __lambda9__unity_theme_file_path_failed (UnityThemeFilePath* _sender, gpointer self); +static void _lambda11_ (UnityThemeFilePath* theme, const char* filepath, UnityLauncherApplicationController* self); +static void __lambda11__unity_theme_file_path_found_icon_path (UnityThemeFilePath* _sender, const char* filepath, gpointer self); +static void _lambda12_ (UnityLauncherApplicationController* self); +static void __lambda12__unity_theme_file_path_failed (UnityThemeFilePath* _sender, gpointer self); static void unity_launcher_application_controller_set_desktop_file (UnityLauncherApplicationController* self, const char* value); static void _unity_launcher_application_controller_on_favorite_added_unity_favorites_favorite_added (UnityFavorites* _sender, const char* uid, gpointer self); static void _unity_launcher_application_controller_on_favorite_removed_unity_favorites_favorite_removed (UnityFavorites* _sender, const char* uid, gpointer self); GType unity_launcher_quicklist_controller_get_type (void); UnityLauncherQuicklistController* unity_launcher_quicklist_controller_get_default (void); CtkActor* unity_launcher_quicklist_controller_get_attached_actor (UnityLauncherQuicklistController* self); -static void _lambda10_ (gboolean open, Block1Data* _data1_); -static void __lambda10__unity_launcher_quicklist_controller_menu_state_changed (UnityLauncherQuicklistController* _sender, gboolean open, gpointer self); +static void _lambda13_ (gboolean open, Block1Data* _data1_); +static void __lambda13__unity_launcher_quicklist_controller_menu_state_changed (UnityLauncherQuicklistController* _sender, gboolean open, gpointer self); static Block1Data* block1_data_ref (Block1Data* _data1_); static void block1_data_unref (Block1Data* _data1_); static GObject * unity_launcher_application_controller_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties); @@ -379,7 +379,7 @@ static void unity_launcher_application_shortcut_real_activated (UnityLauncherSho g_key_file_load_from_file (desktop_file, self->desktop_location, 0, &_inner_error_); if (_inner_error_ != NULL) { _g_key_file_free0 (desktop_file); - goto __catch13_g_error; + goto __catch10_g_error; } g_key_file_set_string (desktop_file, "Desktop Entry", "Exec", self->exec); appinfo = (GAppInfo*) g_desktop_app_info_new_from_keyfile (desktop_file); @@ -387,7 +387,7 @@ static void unity_launcher_application_shortcut_real_activated (UnityLauncherSho if (_inner_error_ != NULL) { _g_key_file_free0 (desktop_file); _g_object_unref0 (appinfo); - goto __catch13_g_error; + goto __catch10_g_error; } gdk_app_launch_context_set_screen (context, gdk_display_get_default_screen (gdk_display_get_default ())); gdk_app_launch_context_set_timestamp (context, (guint32) GDK_CURRENT_TIME); @@ -395,13 +395,13 @@ static void unity_launcher_application_shortcut_real_activated (UnityLauncherSho if (_inner_error_ != NULL) { _g_key_file_free0 (desktop_file); _g_object_unref0 (appinfo); - goto __catch13_g_error; + goto __catch10_g_error; } _g_key_file_free0 (desktop_file); _g_object_unref0 (appinfo); } - goto __finally13; - __catch13_g_error: + goto __finally10; + __catch10_g_error: { GError * e; e = _inner_error_; @@ -411,7 +411,7 @@ static void unity_launcher_application_shortcut_real_activated (UnityLauncherSho _g_error_free0 (e); } } - __finally13: + __finally10: if (_inner_error_ != NULL) { _g_object_unref0 (context); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); @@ -826,24 +826,24 @@ static GeeArrayList* unity_launcher_application_controller_real_get_menu_shortcu { g_key_file_load_from_file (desktop_keyfile, unity_launcher_application_controller_get_desktop_file (self), 0, &_inner_error_); if (_inner_error_ != NULL) { - goto __catch14_g_error; + goto __catch11_g_error; } } - goto __finally14; - __catch14_g_error: + goto __finally11; + __catch11_g_error: { GError * e; e = _inner_error_; _inner_error_ = NULL; { - g_warning ("application-controller.vala:263: Unable to load desktop file '%s': %s", unity_launcher_application_controller_get_desktop_file (self), e->message); + g_warning ("application-controller.vala:261: Unable to load desktop file '%s': %s", unity_launcher_application_controller_get_desktop_file (self), e->message); result = ret_list; _g_error_free0 (e); _g_key_file_free0 (desktop_keyfile); return result; } } - __finally14: + __finally11: if (_inner_error_ != NULL) { _g_object_unref0 (ret_list); _g_key_file_free0 (desktop_keyfile); @@ -882,30 +882,30 @@ static GeeArrayList* unity_launcher_application_controller_real_get_menu_shortcu char* _tmp6_; _tmp3_ = g_key_file_get_value (desktop_keyfile, groups[a], "Exec", &_inner_error_); if (_inner_error_ != NULL) { - goto __catch15_g_error; + goto __catch12_g_error; } exec = (_tmp4_ = _tmp3_, _g_free0 (exec), _tmp4_); _tmp5_ = g_key_file_get_locale_string (desktop_keyfile, groups[a], "Name", "", &_inner_error_); if (_inner_error_ != NULL) { - goto __catch15_g_error; + goto __catch12_g_error; } name = (_tmp6_ = _tmp5_, _g_free0 (name), _tmp6_); } - goto __finally15; - __catch15_g_error: + goto __finally12; + __catch12_g_error: { GError * e; e = _inner_error_; _inner_error_ = NULL; { - g_warning ("application-controller.vala:282: %s", e->message); + g_warning ("application-controller.vala:280: %s", e->message); _g_error_free0 (e); _g_free0 (exec); _g_free0 (name); continue; } } - __finally15: + __finally12: if (_inner_error_ != NULL) { _g_free0 (exec); _g_free0 (name); @@ -968,7 +968,9 @@ static GeeArrayList* unity_launcher_application_controller_real_get_menu_shortcu static gboolean _unity_launcher_application_controller_on_launch_timeout_gsource_func (gpointer self) { - return unity_launcher_application_controller_on_launch_timeout (self); + gboolean result; + result = unity_launcher_application_controller_on_launch_timeout (self); + return result; } @@ -1013,7 +1015,7 @@ static void unity_launcher_application_controller_real_activate (UnityLauncherSc g_key_file_load_from_file (desktop_keyfile, unity_launcher_application_controller_get_desktop_file (self), 0, &_inner_error_); if (_inner_error_ != NULL) { _g_key_file_free0 (desktop_keyfile); - goto __catch16_g_error; + goto __catch13_g_error; } appinfo = (GAppInfo*) g_desktop_app_info_new_from_keyfile (desktop_keyfile); gdk_app_launch_context_set_screen (context, gdk_display_get_default_screen (gdk_display_get_default ())); @@ -1022,25 +1024,25 @@ static void unity_launcher_application_controller_real_activate (UnityLauncherSc if (_inner_error_ != NULL) { _g_key_file_free0 (desktop_keyfile); _g_object_unref0 (appinfo); - goto __catch16_g_error; + goto __catch13_g_error; } unity_launcher_scroller_child_set_activating (unity_launcher_scroller_child_controller_get_child ((UnityLauncherScrollerChildController*) self), TRUE); g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 8, _unity_launcher_application_controller_on_launch_timeout_gsource_func, g_object_ref (self), g_object_unref); _g_key_file_free0 (desktop_keyfile); _g_object_unref0 (appinfo); } - goto __finally16; - __catch16_g_error: + goto __finally13; + __catch13_g_error: { GError * e; e = _inner_error_; _inner_error_ = NULL; { - g_warning ("application-controller.vala:348: %s", e->message); + g_warning ("application-controller.vala:346: %s", e->message); _g_error_free0 (e); } } - __finally16: + __finally13: if (_inner_error_ != NULL) { _g_object_unref0 (context); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); @@ -1106,13 +1108,13 @@ void unity_launcher_application_controller_attach_application (UnityLauncherAppl ((UnityLauncherScrollerChildController*) self)->name = (_tmp1_ = bamf_view_get_name ((BamfView*) self->priv->app), _g_free0 (((UnityLauncherScrollerChildController*) self)->name), _tmp1_); if (_vala_strcmp0 (((UnityLauncherScrollerChildController*) self)->name, "") == 0) { char* _tmp2_; - g_warning ("application-controller.vala:371: %s", _tmp2_ = g_strconcat ("Bamf returned null for app.get_name (): ", string_to_string (unity_launcher_application_controller_get_desktop_file (self)), NULL)); + g_warning ("application-controller.vala:369: %s", _tmp2_ = g_strconcat ("Bamf returned null for app.get_name (): ", string_to_string (unity_launcher_application_controller_get_desktop_file (self)), NULL)); _g_free0 (_tmp2_); } potential_icon_name = bamf_view_get_icon ((BamfView*) self->priv->app); if (_vala_strcmp0 (potential_icon_name, "") == 0) { char* _tmp3_; - g_warning ("application-controller.vala:375: %s", _tmp3_ = g_strconcat ("Bamf returned null for app.get_icon (): ", string_to_string (unity_launcher_application_controller_get_desktop_file (self)), NULL)); + g_warning ("application-controller.vala:373: %s", _tmp3_ = g_strconcat ("Bamf returned null for app.get_icon (): ", string_to_string (unity_launcher_application_controller_get_desktop_file (self)), NULL)); _g_free0 (_tmp3_); } else { _vala_strcmp0 (self->priv->icon_name, potential_icon_name) == 0; @@ -1183,21 +1185,21 @@ static void unity_launcher_application_controller_load_desktop_file_info (UnityL self->priv->desktop_keyfile = (_tmp0_ = g_key_file_new (), _g_key_file_free0 (self->priv->desktop_keyfile), _tmp0_); g_key_file_load_from_file (self->priv->desktop_keyfile, unity_launcher_application_controller_get_desktop_file (self), G_KEY_FILE_NONE, &_inner_error_); if (_inner_error_ != NULL) { - goto __catch17_g_error; + goto __catch14_g_error; } } - goto __finally17; - __catch17_g_error: + goto __finally14; + __catch14_g_error: { GError * e; e = _inner_error_; _inner_error_ = NULL; { - g_warning ("application-controller.vala:428: could not load desktop file: %s", e->message); + g_warning ("application-controller.vala:426: could not load desktop file: %s", e->message); _g_error_free0 (e); } } - __finally17: + __finally14: if (_inner_error_ != NULL) { g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); @@ -1208,24 +1210,24 @@ static void unity_launcher_application_controller_load_desktop_file_info (UnityL char* _tmp2_; _tmp1_ = g_key_file_get_string (self->priv->desktop_keyfile, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, &_inner_error_); if (_inner_error_ != NULL) { - goto __catch18_g_error; + goto __catch15_g_error; } self->priv->icon_name = (_tmp2_ = _tmp1_, _g_free0 (self->priv->icon_name), _tmp2_); unity_launcher_application_controller_load_icon_from_icon_name (self); } - goto __finally18; - __catch18_g_error: + goto __finally15; + __catch15_g_error: { GError * e; e = _inner_error_; _inner_error_ = NULL; { - g_warning ("application-controller.vala:438: could not load icon name from desktop" \ + g_warning ("application-controller.vala:436: could not load icon name from desktop" \ " file: %s", e->message); _g_error_free0 (e); } } - __finally18: + __finally15: if (_inner_error_ != NULL) { g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); @@ -1236,23 +1238,23 @@ static void unity_launcher_application_controller_load_desktop_file_info (UnityL char* _tmp4_; _tmp3_ = g_key_file_get_string (self->priv->desktop_keyfile, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_NAME, &_inner_error_); if (_inner_error_ != NULL) { - goto __catch19_g_error; + goto __catch16_g_error; } ((UnityLauncherScrollerChildController*) self)->name = (_tmp4_ = _tmp3_, _g_free0 (((UnityLauncherScrollerChildController*) self)->name), _tmp4_); } - goto __finally19; - __catch19_g_error: + goto __finally16; + __catch16_g_error: { GError * e; e = _inner_error_; _inner_error_ = NULL; { - g_warning ("application-controller.vala:447: could not load name from desktop file" \ + g_warning ("application-controller.vala:445: could not load name from desktop file" \ ": %s", e->message); _g_error_free0 (e); } } - __finally19: + __finally16: if (_inner_error_ != NULL) { g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); @@ -1261,7 +1263,7 @@ static void unity_launcher_application_controller_load_desktop_file_info (UnityL } -static void _lambda8_ (UnityThemeFilePath* theme, const char* filepath, UnityLauncherApplicationController* self) { +static void _lambda11_ (UnityThemeFilePath* theme, const char* filepath, UnityLauncherApplicationController* self) { GError * _inner_error_; g_return_if_fail (theme != NULL); g_return_if_fail (filepath != NULL); @@ -1271,25 +1273,25 @@ static void _lambda8_ (UnityThemeFilePath* theme, const char* filepath, UnityLau GdkPixbuf* _tmp1_; _tmp0_ = gdk_pixbuf_new_from_file (filepath, &_inner_error_); if (_inner_error_ != NULL) { - goto __catch20_g_error; + goto __catch17_g_error; } unity_launcher_scroller_child_set_icon (unity_launcher_scroller_child_controller_get_child ((UnityLauncherScrollerChildController*) self), _tmp1_ = _tmp0_); _g_object_unref0 (_tmp1_); } - goto __finally20; - __catch20_g_error: + goto __finally17; + __catch17_g_error: { GError * e; e = _inner_error_; _inner_error_ = NULL; { char* _tmp2_; - g_warning ("application-controller.vala:486: %s", _tmp2_ = g_strconcat ("Could not load from ", string_to_string (filepath), NULL)); + g_warning ("application-controller.vala:484: %s", _tmp2_ = g_strconcat ("Could not load from ", string_to_string (filepath), NULL)); _g_free0 (_tmp2_); _g_error_free0 (e); } } - __finally20: + __finally17: if (_inner_error_ != NULL) { g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); @@ -1298,12 +1300,12 @@ static void _lambda8_ (UnityThemeFilePath* theme, const char* filepath, UnityLau } -static void __lambda8__unity_theme_file_path_found_icon_path (UnityThemeFilePath* _sender, const char* filepath, gpointer self) { - _lambda8_ (_sender, filepath, self); +static void __lambda11__unity_theme_file_path_found_icon_path (UnityThemeFilePath* _sender, const char* filepath, gpointer self) { + _lambda11_ (_sender, filepath, self); } -static void _lambda9_ (UnityLauncherApplicationController* self) { +static void _lambda12_ (UnityLauncherApplicationController* self) { GError * _inner_error_; _inner_error_ = NULL; { @@ -1313,25 +1315,25 @@ static void _lambda9_ (UnityLauncherApplicationController* self) { _tmp0_ = gtk_icon_theme_load_icon (default_theme, GTK_STOCK_MISSING_IMAGE, 48, 0, &_inner_error_); if (_inner_error_ != NULL) { _g_object_unref0 (default_theme); - goto __catch21_g_error; + goto __catch18_g_error; } unity_launcher_scroller_child_set_icon (unity_launcher_scroller_child_controller_get_child ((UnityLauncherScrollerChildController*) self), _tmp0_); _g_object_unref0 (default_theme); } - goto __finally21; - __catch21_g_error: + goto __finally18; + __catch18_g_error: { GError * e; e = _inner_error_; _inner_error_ = NULL; { char* _tmp1_; - g_warning ("application-controller.vala:498: Could not load any icon for %s", _tmp1_ = bamf_view_get_name ((BamfView*) self->priv->app)); + g_warning ("application-controller.vala:496: Could not load any icon for %s", _tmp1_ = bamf_view_get_name ((BamfView*) self->priv->app)); _g_free0 (_tmp1_); _g_error_free0 (e); } } - __finally21: + __finally18: if (_inner_error_ != NULL) { g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); @@ -1340,8 +1342,8 @@ static void _lambda9_ (UnityLauncherApplicationController* self) { } -static void __lambda9__unity_theme_file_path_failed (UnityThemeFilePath* _sender, gpointer self) { - _lambda9_ (self); +static void __lambda12__unity_theme_file_path_failed (UnityThemeFilePath* _sender, gpointer self) { + _lambda12_ (self); } @@ -1366,8 +1368,8 @@ static void unity_launcher_application_controller_load_icon_from_icon_name (Unit unity_theme_file_path_add_icon_theme (self->priv->theme_file_path, theme); gtk_icon_theme_set_custom_theme (theme, "Web"); unity_theme_file_path_add_icon_theme (self->priv->theme_file_path, theme); - g_signal_connect_object (self->priv->theme_file_path, "found-icon-path", (GCallback) __lambda8__unity_theme_file_path_found_icon_path, self, 0); - g_signal_connect_object (self->priv->theme_file_path, "failed", (GCallback) __lambda9__unity_theme_file_path_failed, self, 0); + g_signal_connect_object (self->priv->theme_file_path, "found-icon-path", (GCallback) __lambda11__unity_theme_file_path_found_icon_path, self, 0); + g_signal_connect_object (self->priv->theme_file_path, "failed", (GCallback) __lambda12__unity_theme_file_path_failed, self, 0); unity_theme_file_path_get_icon_filepath (self->priv->theme_file_path, self->priv->icon_name, NULL, NULL); _g_object_unref0 (theme); } @@ -1387,23 +1389,23 @@ static gboolean unity_launcher_application_controller_try_load_from_file (UnityL GdkPixbuf* _tmp1_; _tmp0_ = gdk_pixbuf_new_from_file_at_scale (filepath, 48, 48, TRUE, &_inner_error_); if (_inner_error_ != NULL) { - goto __catch22_g_error; + goto __catch19_g_error; } pixbuf = (_tmp1_ = _tmp0_, _g_object_unref0 (pixbuf), _tmp1_); } - goto __finally22; - __catch22_g_error: + goto __finally19; + __catch19_g_error: { GError * e; e = _inner_error_; _inner_error_ = NULL; { - g_warning ("application-controller.vala:517: Unable to load image from file '%s': " \ + g_warning ("application-controller.vala:515: Unable to load image from file '%s': " \ "%s", filepath, e->message); _g_error_free0 (e); } } - __finally22: + __finally19: if (_inner_error_ != NULL) { _g_object_unref0 (pixbuf); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); @@ -1450,7 +1452,7 @@ static void _unity_launcher_application_controller_on_favorite_removed_unity_fav } -static void _lambda10_ (gboolean open, Block1Data* _data1_) { +static void _lambda13_ (gboolean open, Block1Data* _data1_) { UnityLauncherApplicationController * self; gboolean _tmp0_ = FALSE; CtkActor* _tmp1_; @@ -1464,19 +1466,17 @@ static void _lambda10_ (gboolean open, Block1Data* _data1_) { if (_tmp0_) { if (open) { GArray* _tmp3_; - g_debug ("application-controller.vala:213: starting expose"); unity_shell_expose_xids (unity_global_shell, _tmp3_ = bamf_application_get_xids (self->priv->app)); _g_array_free0 (_tmp3_); } else { - g_debug ("application-controller.vala:218: ending expose"); unity_shell_stop_expose (unity_global_shell); } } } -static void __lambda10__unity_launcher_quicklist_controller_menu_state_changed (UnityLauncherQuicklistController* _sender, gboolean open, gpointer self) { - _lambda10_ (open, self); +static void __lambda13__unity_launcher_quicklist_controller_menu_state_changed (UnityLauncherQuicklistController* _sender, gboolean open, gpointer self) { + _lambda13_ (open, self); } @@ -1539,7 +1539,7 @@ static GObject * unity_launcher_application_controller_constructor (GType type, _g_object_unref0 (_uid_it); } _data1_->controller = _g_object_ref0 (unity_launcher_quicklist_controller_get_default ()); - g_signal_connect_data (_data1_->controller, "menu-state-changed", (GCallback) __lambda10__unity_launcher_quicklist_controller_menu_state_changed, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0); + g_signal_connect_data (_data1_->controller, "menu-state-changed", (GCallback) __lambda13__unity_launcher_quicklist_controller_menu_state_changed, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0); _g_object_unref0 (favorites); block1_data_unref (_data1_); } diff --git a/unity-private/launcher/application-controller.vala b/unity-private/launcher/application-controller.vala index ce389aebd..81f1e87c4 100644 --- a/unity-private/launcher/application-controller.vala +++ b/unity-private/launcher/application-controller.vala @@ -210,12 +210,10 @@ namespace Unity.Launcher // this is a menu relating to us if (open) { - debug ("starting expose"); Unity.global_shell.expose_xids (app.get_xids ()); } else { - debug ("ending expose"); Unity.global_shell.stop_expose (); } } diff --git a/unity-private/launcher/launcher-child.c b/unity-private/launcher/launcher-child.c index d95f3ac31..613da24d9 100644 --- a/unity-private/launcher/launcher-child.c +++ b/unity-private/launcher/launcher-child.c @@ -231,12 +231,12 @@ static void unity_launcher_launcher_child_load_textures (UnityLauncherLauncherCh GdkPixbuf* _tmp3_; _tmp2_ = gdk_pixbuf_new_from_file (UNITY_LAUNCHER_HONEYCOMB_MASK_FILE, &_inner_error_); if (_inner_error_ != NULL) { - goto __catch23_g_error; + goto __catch20_g_error; } self->priv->honeycomb_mask = (_tmp3_ = _tmp2_, _g_object_unref0 (self->priv->honeycomb_mask), _tmp3_); } - goto __finally23; - __catch23_g_error: + goto __finally20; + __catch20_g_error: { GError * e; e = _inner_error_; @@ -246,7 +246,7 @@ static void unity_launcher_launcher_child_load_textures (UnityLauncherLauncherCh _g_error_free0 (e); } } - __finally23: + __finally20: if (_inner_error_ != NULL) { g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); @@ -429,7 +429,9 @@ static gboolean unity_launcher_launcher_child_check_continue_wiggle (UnityLaunch static gboolean _unity_launcher_launcher_child_check_continue_wiggle_gsource_func (gpointer self) { - return unity_launcher_launcher_child_check_continue_wiggle (self); + gboolean result; + result = unity_launcher_launcher_child_check_continue_wiggle (self); + return result; } @@ -458,6 +460,7 @@ static void unity_launcher_launcher_child_on_icon_changed (UnityLauncherLauncher g_return_if_fail (self != NULL); if (GDK_IS_PIXBUF (unity_launcher_scroller_child_get_icon ((UnityLauncherScrollerChild*) self))) { GdkPixbuf* scaled_buf; + gint max_size; gboolean _tmp0_ = FALSE; GdkPixbuf* color_buf; guint red = 0U; @@ -474,14 +477,18 @@ static void unity_launcher_launcher_child_on_icon_changed (UnityLauncherLauncher ClutterActor* _tmp5_; CtkEffectDropShadow* _tmp7_; scaled_buf = NULL; - if (gdk_pixbuf_get_width (unity_launcher_scroller_child_get_icon ((UnityLauncherScrollerChild*) self)) > 48) { + max_size = 48; + if (!unity_pixbuf_is_tile (unity_launcher_scroller_child_get_icon ((UnityLauncherScrollerChild*) self))) { + max_size = 40; + } + if (gdk_pixbuf_get_width (unity_launcher_scroller_child_get_icon ((UnityLauncherScrollerChild*) self)) > max_size) { _tmp0_ = TRUE; } else { - _tmp0_ = gdk_pixbuf_get_height (unity_launcher_scroller_child_get_icon ((UnityLauncherScrollerChild*) self)) > 48; + _tmp0_ = gdk_pixbuf_get_height (unity_launcher_scroller_child_get_icon ((UnityLauncherScrollerChild*) self)) > max_size; } if (_tmp0_) { GdkPixbuf* _tmp1_; - scaled_buf = (_tmp1_ = gdk_pixbuf_scale_simple (unity_launcher_scroller_child_get_icon ((UnityLauncherScrollerChild*) self), 48, 48, GDK_INTERP_HYPER), _g_object_unref0 (scaled_buf), _tmp1_); + scaled_buf = (_tmp1_ = gdk_pixbuf_scale_simple (unity_launcher_scroller_child_get_icon ((UnityLauncherScrollerChild*) self), max_size, max_size, GDK_INTERP_HYPER), _g_object_unref0 (scaled_buf), _tmp1_); } else { GdkPixbuf* _tmp2_; scaled_buf = (_tmp2_ = _g_object_ref0 (unity_launcher_scroller_child_get_icon ((UnityLauncherScrollerChild*) self)), _g_object_unref0 (scaled_buf), _tmp2_); @@ -492,7 +499,7 @@ static void unity_launcher_launcher_child_on_icon_changed (UnityLauncherLauncher pixels[0] = (guchar) red; pixels[1] = (guchar) green; pixels[2] = (guchar) blue; - pixels[3] = (guchar) 128; + pixels[3] = (guchar) 255; tex = _g_object_ref0 (gtk_clutter_texture_new_from_pixbuf (scaled_buf)); color = _g_object_ref0 (gtk_clutter_texture_new_from_pixbuf (color_buf)); self->priv->processed_icon = (_tmp6_ = (CtkActor*) g_object_ref_sink (unity_unity_icon_new ((_tmp4_ = tex, CLUTTER_IS_TEXTURE (_tmp4_) ? ((ClutterTexture*) _tmp4_) : NULL), (_tmp5_ = color, CLUTTER_IS_TEXTURE (_tmp5_) ? ((ClutterTexture*) _tmp5_) : NULL))), _g_object_unref0 (self->priv->processed_icon), _tmp6_); diff --git a/unity-private/launcher/launcher-child.vala b/unity-private/launcher/launcher-child.vala index eb40d4db6..d9ad752ec 100644 --- a/unity-private/launcher/launcher-child.vala +++ b/unity-private/launcher/launcher-child.vala @@ -290,10 +290,18 @@ namespace Unity.Launcher if (icon is Gdk.Pixbuf) { Gdk.Pixbuf scaled_buf; - if (icon.get_width () > 48 || icon.get_height () > 48) - scaled_buf = icon.scale_simple (48, 48, Gdk.InterpType.HYPER); + int max_size = 48; + if (!Unity.pixbuf_is_tile (icon)) + max_size = 40; + + if (icon.get_width () > max_size || icon.get_height () > max_size) + { + scaled_buf = icon.scale_simple (max_size, max_size, Gdk.InterpType.HYPER); + } else - scaled_buf = icon; + { + scaled_buf = icon; + } Gdk.Pixbuf color_buf = new Gdk.Pixbuf (Gdk.Colorspace.RGB, true, 8, 1, 1); uint red, green, blue; @@ -302,7 +310,7 @@ namespace Unity.Launcher pixels[0] = (uchar)red; pixels[1] = (uchar)green; pixels[2] = (uchar)blue; - pixels[3] = 128; + pixels[3] = 255; var tex = GtkClutter.texture_new_from_pixbuf (scaled_buf); var color = GtkClutter.texture_new_from_pixbuf (color_buf); diff --git a/unity-private/launcher/quicklist-controller.c b/unity-private/launcher/quicklist-controller.c index b87a4d61f..34fddc2a9 100644 --- a/unity-private/launcher/quicklist-controller.c +++ b/unity-private/launcher/quicklist-controller.c @@ -146,10 +146,10 @@ static void unity_launcher_quicklist_controller_on_unity_drag_start (UnityLaunch UnityLauncherQuicklistMenu* unity_launcher_quicklist_menu_new (void); UnityLauncherQuicklistMenu* unity_launcher_quicklist_menu_construct (GType object_type); GType unity_launcher_quicklist_menu_get_type (void); -static void _lambda6_ (UnityLauncherQuicklistController* self); -static void __lambda6__clutter_actor_destroy (ClutterActor* _sender, gpointer self); -static void _lambda7_ (UnityLauncherQuicklistController* self); -static void __lambda7__clutter_actor_destroy (ClutterActor* _sender, gpointer self); +static void _lambda9_ (UnityLauncherQuicklistController* self); +static void __lambda9__clutter_actor_destroy (ClutterActor* _sender, gpointer self); +static void _lambda10_ (UnityLauncherQuicklistController* self); +static void __lambda10__clutter_actor_destroy (ClutterActor* _sender, gpointer self); UnityLauncherQuicklistMenuItem* unity_launcher_quicklist_menu_item_new (const char* label); UnityLauncherQuicklistMenuItem* unity_launcher_quicklist_menu_item_construct (GType object_type, const char* label); GType unity_launcher_quicklist_menu_item_get_type (void); @@ -205,23 +205,25 @@ static void unity_launcher_quicklist_controller_on_unity_drag_start (UnityLaunch } -static void _lambda6_ (UnityLauncherQuicklistController* self) { - g_signal_emit_by_name (self, "menu-state-changed", FALSE); +static void _lambda9_ (UnityLauncherQuicklistController* self) { + if (self->is_in_menu) { + g_signal_emit_by_name (self, "menu-state-changed", FALSE); + } } -static void __lambda6__clutter_actor_destroy (ClutterActor* _sender, gpointer self) { - _lambda6_ (self); +static void __lambda9__clutter_actor_destroy (ClutterActor* _sender, gpointer self) { + _lambda9_ (self); } -static void _lambda7_ (UnityLauncherQuicklistController* self) { +static void _lambda10_ (UnityLauncherQuicklistController* self) { unity_shell_remove_fullscreen_request (unity_global_shell, (GObject*) self); } -static void __lambda7__clutter_actor_destroy (ClutterActor* _sender, gpointer self) { - _lambda7_ (self); +static void __lambda10__clutter_actor_destroy (ClutterActor* _sender, gpointer self) { + _lambda10_ (self); } @@ -244,9 +246,9 @@ void unity_launcher_quicklist_controller_show_label (UnityLauncherQuicklistContr clutter_actor_destroy ((ClutterActor*) self->menu); } menu = (_tmp0_ = g_object_ref_sink (unity_launcher_quicklist_menu_new ()), CTK_IS_MENU (_tmp0_) ? ((CtkMenu*) _tmp0_) : NULL); - g_signal_connect_object ((ClutterActor*) menu, "destroy", (GCallback) __lambda6__clutter_actor_destroy, self, 0); + g_signal_connect_object ((ClutterActor*) menu, "destroy", (GCallback) __lambda9__clutter_actor_destroy, self, 0); self->menu = menu; - g_signal_connect_object ((ClutterActor*) self->menu, "destroy", (GCallback) __lambda7__clutter_actor_destroy, self, 0); + g_signal_connect_object ((ClutterActor*) self->menu, "destroy", (GCallback) __lambda10__clutter_actor_destroy, self, 0); ctk_menu_set_swallow_clicks (self->menu, unity_shell_get_menus_swallow_events (unity_global_shell)); ctk_menu_set_detect_clicks (self->menu, FALSE); menuitem = g_object_ref_sink (unity_launcher_quicklist_menu_item_new (label)); @@ -341,11 +343,11 @@ void unity_launcher_quicklist_controller_show_menu (UnityLauncherQuicklistContro void unity_launcher_quicklist_controller_close_menu (UnityLauncherQuicklistController* self) { g_return_if_fail (self != NULL); - self->is_in_label = FALSE; - self->is_in_menu = FALSE; if (CTK_IS_MENU (self->menu)) { clutter_actor_destroy ((ClutterActor*) self->menu); } + self->is_in_label = FALSE; + self->is_in_menu = FALSE; } diff --git a/unity-private/launcher/quicklist-controller.vala b/unity-private/launcher/quicklist-controller.vala index 5c5b7ddbc..afefc1076 100644 --- a/unity-private/launcher/quicklist-controller.vala +++ b/unity-private/launcher/quicklist-controller.vala @@ -62,7 +62,10 @@ namespace Unity.Launcher this.menu.destroy (); var menu = new QuicklistMenu () as Ctk.Menu; - menu.destroy.connect (() => { menu_state_changed (false); }); + menu.destroy.connect (() => { + if (is_in_menu) + menu_state_changed (false); + }); this.menu = menu; this.menu.destroy.connect (() => { Unity.global_shell.remove_fullscreen_request (this); @@ -128,12 +131,12 @@ namespace Unity.Launcher public void close_menu () { - this.is_in_label = false; - this.is_in_menu = false; if (this.menu is Ctk.Menu) { this.menu.destroy (); } + this.is_in_label = false; + this.is_in_menu = false; } public bool menu_is_open () diff --git a/unity-private/launcher/quicklist-view.c b/unity-private/launcher/quicklist-view.c index 1059121fb..d0338ad31 100644 --- a/unity-private/launcher/quicklist-view.c +++ b/unity-private/launcher/quicklist-view.c @@ -486,17 +486,23 @@ static void __unity_launcher_quicklist_menu_item_on_label_changed_g_object_notif static gboolean __unity_launcher_quicklist_menu_item_on_enter_clutter_actor_enter_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return _unity_launcher_quicklist_menu_item_on_enter (self, event); + gboolean result; + result = _unity_launcher_quicklist_menu_item_on_enter (self, event); + return result; } static gboolean __unity_launcher_quicklist_menu_item_on_leave_clutter_actor_leave_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return _unity_launcher_quicklist_menu_item_on_leave (self, event); + gboolean result; + result = _unity_launcher_quicklist_menu_item_on_leave (self, event); + return result; } static gboolean __unity_launcher_quicklist_menu_item_on_mouse_down_clutter_actor_button_press_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return _unity_launcher_quicklist_menu_item_on_mouse_down (self, event); + gboolean result; + result = _unity_launcher_quicklist_menu_item_on_mouse_down (self, event); + return result; } diff --git a/unity-private/launcher/scroller-controller.c b/unity-private/launcher/scroller-controller.c index 928b5e6ae..c98454fd3 100644 --- a/unity-private/launcher/scroller-controller.c +++ b/unity-private/launcher/scroller-controller.c @@ -162,8 +162,8 @@ enum { UnityLauncherScrollerController* unity_launcher_scroller_controller_new (UnityLauncherScrollerModel* _model, UnityLauncherScrollerView* _view); UnityLauncherScrollerController* unity_launcher_scroller_controller_construct (GType object_type, UnityLauncherScrollerModel* _model, UnityLauncherScrollerView* _view); static void unity_launcher_scroller_controller_handle_bamf_view_opened (UnityLauncherScrollerController* self, GObject* object); -static void _lambda14_ (BamfView* a, gboolean changed, UnityLauncherScrollerController* self); -static void __lambda14__bamf_view_user_visible_changed (BamfView* _sender, gboolean object, gpointer self); +static void _lambda17_ (BamfView* a, gboolean changed, UnityLauncherScrollerController* self); +static void __lambda17__bamf_view_user_visible_changed (BamfView* _sender, gboolean object, gpointer self); GType unity_launcher_application_controller_get_type (void); static UnityLauncherApplicationController* unity_launcher_scroller_controller_find_controller_by_desktop_file (UnityLauncherScrollerController* self, const char* desktop_file); void unity_launcher_application_controller_attach_application (UnityLauncherApplicationController* self, BamfApplication* application); @@ -182,8 +182,8 @@ GType unity_launcher_pin_type_get_type (void); void unity_launcher_scroller_model_remove (UnityLauncherScrollerModel* self, UnityLauncherScrollerChild* child); static void unity_launcher_scroller_controller_build_favorites (UnityLauncherScrollerController* self); static void unity_launcher_scroller_controller_on_favorite_added (UnityLauncherScrollerController* self, const char* uid); -static void unity_launcher_scroller_controller_on_favorite_removed (UnityLauncherScrollerController* self, const char* uid); -static gboolean unity_launcher_scroller_controller_desktop_file_is_favorite (UnityLauncherScrollerController* self, const char* desktop_file); +void unity_launcher_scroller_controller_on_favorite_removed (UnityLauncherScrollerController* self, const char* uid); +gboolean unity_launcher_scroller_controller_desktop_file_is_favorite (UnityLauncherScrollerController* self, const char* desktop_file); const char* unity_launcher_application_controller_get_desktop_file (UnityLauncherApplicationController* self); static void unity_launcher_scroller_controller_on_unity_drag_motion (UnityLauncherScrollerController* self, UnityDragModel* drag_model, float x, float y); static void _unity_launcher_scroller_controller_on_unity_drag_motion_unity_drag_controller_drag_motion (UnityDragController* _sender, UnityDragModel* model, float x, float y, gpointer self); @@ -227,7 +227,7 @@ static gpointer _g_object_ref0 (gpointer self) { } -static void _lambda14_ (BamfView* a, gboolean changed, UnityLauncherScrollerController* self) { +static void _lambda17_ (BamfView* a, gboolean changed, UnityLauncherScrollerController* self) { g_return_if_fail (a != NULL); if (changed) { BamfView* _tmp0_; @@ -236,8 +236,8 @@ static void _lambda14_ (BamfView* a, gboolean changed, UnityLauncherScrollerCont } -static void __lambda14__bamf_view_user_visible_changed (BamfView* _sender, gboolean object, gpointer self) { - _lambda14_ (_sender, object, self); +static void __lambda17__bamf_view_user_visible_changed (BamfView* _sender, gboolean object, gpointer self) { + _lambda17_ (_sender, object, self); } @@ -259,7 +259,7 @@ static void unity_launcher_scroller_controller_handle_bamf_view_opened (UnityLau _g_object_unref0 (app); return; } - g_signal_connect_object ((BamfView*) app, "user-visible-changed", (GCallback) __lambda14__bamf_view_user_visible_changed, self, 0); + g_signal_connect_object ((BamfView*) app, "user-visible-changed", (GCallback) __lambda17__bamf_view_user_visible_changed, self, 0); if (bamf_view_user_visible ((BamfView*) app)) { char* desktop_file; desktop_file = g_strdup (bamf_application_get_desktop_file (app)); @@ -376,13 +376,13 @@ static void unity_launcher_scroller_controller_on_favorite_added (UnityLauncherS } -static void unity_launcher_scroller_controller_on_favorite_removed (UnityLauncherScrollerController* self, const char* uid) { +void unity_launcher_scroller_controller_on_favorite_removed (UnityLauncherScrollerController* self, const char* uid) { g_return_if_fail (self != NULL); g_return_if_fail (uid != NULL); } -static gboolean unity_launcher_scroller_controller_desktop_file_is_favorite (UnityLauncherScrollerController* self, const char* desktop_file) { +gboolean unity_launcher_scroller_controller_desktop_file_is_favorite (UnityLauncherScrollerController* self, const char* desktop_file) { gboolean result = FALSE; UnityFavorites* favorites; GeeArrayList* favorite_list; @@ -518,9 +518,9 @@ static void unity_launcher_scroller_controller_on_unity_drag_motion (UnityLaunch gint model_index; model_index = unity_launcher_scroller_view_get_model_index_at_y_pos (self->priv->_view, y); if (unity_launcher_scroller_model_contains (self->priv->_model, retcont)) { - unity_launcher_scroller_model_move (self->priv->_model, retcont, model_index - 1); + unity_launcher_scroller_model_move (self->priv->_model, retcont, MAX (model_index - 1, 0)); } else { - unity_launcher_scroller_model_insert (self->priv->_model, retcont, model_index - 1); + unity_launcher_scroller_model_insert (self->priv->_model, retcont, MAX (model_index - 1, 0)); } clutter_actor_queue_redraw ((ClutterActor*) self->priv->_view); } diff --git a/unity-private/launcher/scroller-controller.vala b/unity-private/launcher/scroller-controller.vala index c5545afb8..49df90677 100644 --- a/unity-private/launcher/scroller-controller.vala +++ b/unity-private/launcher/scroller-controller.vala @@ -171,11 +171,11 @@ namespace Unity.Launcher } } - private void on_favorite_removed (string uid) + public void on_favorite_removed (string uid) { } - private bool desktop_file_is_favorite (string desktop_file) + public bool desktop_file_is_favorite (string desktop_file) { var favorites = Unity.Favorites.get_default (); @@ -251,9 +251,9 @@ namespace Unity.Launcher // find the index at this position int model_index = view.get_model_index_at_y_pos (y); if (retcont in model) - model.move (retcont, model_index - 1); + model.move (retcont, int.max (model_index - 1, 0)); else - model.insert (retcont, model_index - 1); + model.insert (retcont, int.max (model_index - 1, 0)); view.do_queue_redraw (); } diff --git a/unity-private/launcher/scroller-view.c b/unity-private/launcher/scroller-view.c index e7763da7d..7470b1870 100644 --- a/unity-private/launcher/scroller-view.c +++ b/unity-private/launcher/scroller-view.c @@ -180,12 +180,12 @@ static void unity_launcher_scroller_view_disable_animations_on_children (UnityLa gint unity_launcher_scroller_model_index_of (UnityLauncherScrollerModel* self, UnityLauncherScrollerChild* child); gint unity_launcher_scroller_model_get_size (UnityLauncherScrollerModel* self); static void unity_launcher_scroller_view_order_children (UnityLauncherScrollerView* self, gboolean immediate); -static void _lambda11_ (UnityLauncherScrollerView* self); -static void __lambda11__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self); +static void _lambda14_ (UnityLauncherScrollerView* self); +static void __lambda14__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self); static void unity_launcher_scroller_view_model_child_added (UnityLauncherScrollerView* self, UnityLauncherScrollerChild* child); #define UNITY_LAUNCHER_SHORT_DELAY ((guint) 400) -static void _lambda12_ (Block2Data* _data2_); -static void __lambda12__clutter_animation_completed (ClutterAnimation* _sender, gpointer self); +static void _lambda15_ (Block2Data* _data2_); +static void __lambda15__clutter_animation_completed (ClutterAnimation* _sender, gpointer self); static Block2Data* block2_data_ref (Block2Data* _data2_); static void block2_data_unref (Block2Data* _data2_); static void unity_launcher_scroller_view_model_child_removed (UnityLauncherScrollerView* self, UnityLauncherScrollerChild* child); @@ -225,8 +225,8 @@ static void _unity_launcher_scroller_view_model_child_removed_unity_launcher_scr static void _unity_launcher_scroller_view_model_order_changed_unity_launcher_scroller_model_order_changed (UnityLauncherScrollerModel* _sender, gpointer self); static gboolean _unity_launcher_scroller_view_on_button_press_event_clutter_actor_button_press_event (ClutterActor* _sender, ClutterEvent* event, gpointer self); static void _unity_launcher_scroller_view_on_scroller_frame_clutter_timeline_new_frame (ClutterTimeline* _sender, gint msecs, gpointer self); -static void _lambda13_ (UnityLauncherScrollerView* self); -static void __lambda13__unity_drag_controller_drag_start (UnityDragController* _sender, UnityDragModel* model, gpointer self); +static void _lambda16_ (UnityLauncherScrollerView* self); +static void __lambda16__unity_drag_controller_drag_start (UnityDragController* _sender, UnityDragModel* model, gpointer self); static GObject * unity_launcher_scroller_view_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties); static void unity_launcher_scroller_view_finalize (GObject* obj); static void unity_launcher_scroller_view_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); @@ -353,13 +353,13 @@ static void unity_launcher_scroller_view_disable_animations_on_children (UnityLa } -static void _lambda11_ (UnityLauncherScrollerView* self) { +static void _lambda14_ (UnityLauncherScrollerView* self) { clutter_actor_queue_relayout ((ClutterActor*) self); } -static void __lambda11__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) { - _lambda11_ (self); +static void __lambda14__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) { + _lambda14_ (self); } @@ -374,7 +374,7 @@ static void unity_launcher_scroller_view_model_child_added (UnityLauncherScrolle unity_launcher_scroller_view_order_children (self, FALSE); } clutter_actor_queue_relayout ((ClutterActor*) self); - g_signal_connect_object ((GObject*) child, "notify::position", (GCallback) __lambda11__g_object_notify, self, 0); + g_signal_connect_object ((GObject*) child, "notify::position", (GCallback) __lambda14__g_object_notify, self, 0); } @@ -383,7 +383,7 @@ static gpointer _g_object_ref0 (gpointer self) { } -static void _lambda12_ (Block2Data* _data2_) { +static void _lambda15_ (Block2Data* _data2_) { UnityLauncherScrollerView * self; self = _data2_->self; clutter_actor_unparent ((ClutterActor*) _data2_->child); @@ -391,8 +391,8 @@ static void _lambda12_ (Block2Data* _data2_) { } -static void __lambda12__clutter_animation_completed (ClutterAnimation* _sender, gpointer self) { - _lambda12_ (self); +static void __lambda15__clutter_animation_completed (ClutterAnimation* _sender, gpointer self) { + _lambda15_ (self); } @@ -422,7 +422,7 @@ static void unity_launcher_scroller_view_model_child_removed (UnityLauncherScrol _data2_->child = _g_object_ref0 (child); gee_abstract_collection_add ((GeeAbstractCollection*) self->priv->child_refs, _data2_->child); anim = _g_object_ref0 (clutter_actor_animate ((ClutterActor*) _data2_->child, (gulong) CLUTTER_EASE_OUT_QUAD, UNITY_LAUNCHER_SHORT_DELAY, "opacity", 0, NULL)); - g_signal_connect_data (anim, "completed", (GCallback) __lambda12__clutter_animation_completed, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0); + g_signal_connect_data (anim, "completed", (GCallback) __lambda15__clutter_animation_completed, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0); unity_launcher_scroller_view_order_children (self, FALSE); clutter_actor_queue_relayout ((ClutterActor*) self); _g_object_unref0 (anim); @@ -438,7 +438,9 @@ static void unity_launcher_scroller_view_model_order_changed (UnityLauncherScrol static gboolean _unity_launcher_scroller_view_on_button_release_event_clutter_actor_button_release_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_launcher_scroller_view_on_button_release_event (self, event); + gboolean result; + result = unity_launcher_scroller_view_on_button_release_event (self, event); + return result; } @@ -459,7 +461,9 @@ static gboolean unity_launcher_scroller_view_on_button_press_event (UnityLaunche static gboolean _unity_launcher_scroller_view_on_motion_event_clutter_actor_motion_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_launcher_scroller_view_on_motion_event (self, event); + gboolean result; + result = unity_launcher_scroller_view_on_motion_event (self, event); + return result; } @@ -1044,7 +1048,9 @@ static void _unity_launcher_scroller_view_model_order_changed_unity_launcher_scr static gboolean _unity_launcher_scroller_view_on_button_press_event_clutter_actor_button_press_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_launcher_scroller_view_on_button_press_event (self, event); + gboolean result; + result = unity_launcher_scroller_view_on_button_press_event (self, event); + return result; } @@ -1053,14 +1059,14 @@ static void _unity_launcher_scroller_view_on_scroller_frame_clutter_timeline_new } -static void _lambda13_ (UnityLauncherScrollerView* self) { +static void _lambda16_ (UnityLauncherScrollerView* self) { self->priv->is_scrolling = FALSE; self->priv->button_down = FALSE; } -static void __lambda13__unity_drag_controller_drag_start (UnityDragController* _sender, UnityDragModel* model, gpointer self) { - _lambda13_ (self); +static void __lambda16__unity_drag_controller_drag_start (UnityDragController* _sender, UnityDragModel* model, gpointer self) { + _lambda16_ (self); } @@ -1083,7 +1089,7 @@ static GObject * unity_launcher_scroller_view_constructor (GType type, guint n_c mypadding = (ctk_actor_get_padding ((CtkActor*) self, &_tmp1_), _tmp1_); mypadding.left = 0.0f; mypadding.right = 0.0f; - mypadding.top = 5.0f; + mypadding.top = 10.0f; mypadding.bottom = 5.0f; ctk_actor_set_padding ((CtkActor*) self, &mypadding); unity_launcher_scroller_view_load_textures (self); @@ -1111,7 +1117,7 @@ static GObject * unity_launcher_scroller_view_constructor (GType type, guint n_c clutter_timeline_set_loop (self->priv->fling_timeline, TRUE); g_signal_connect_object (self->priv->fling_timeline, "new-frame", (GCallback) _unity_launcher_scroller_view_on_scroller_frame_clutter_timeline_new_frame, self, 0); drag_controller = _g_object_ref0 (unity_drag_controller_get_default ()); - g_signal_connect_object (drag_controller, "drag-start", (GCallback) __lambda13__unity_drag_controller_drag_start, self, 0); + g_signal_connect_object (drag_controller, "drag-start", (GCallback) __lambda16__unity_drag_controller_drag_start, self, 0); clutter_actor_set_reactive ((ClutterActor*) self, TRUE); self->priv->child_refs = (_tmp3_ = gee_array_list_new (UNITY_LAUNCHER_TYPE_SCROLLER_CHILD, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL), _g_object_unref0 (self->priv->child_refs), _tmp3_); unity_launcher_scroller_view_order_children (self, TRUE); @@ -1142,7 +1148,7 @@ static void unity_launcher_scroller_view_class_init (UnityLauncherScrollerViewCl static void unity_launcher_scroller_view_instance_init (UnityLauncherScrollerView * self) { self->priv = UNITY_LAUNCHER_SCROLLER_VIEW_GET_PRIVATE (self); - self->spacing = 2; + self->spacing = 6; self->drag_sensitivity = 7; self->friction = 0.9f; self->is_animating = FALSE; diff --git a/unity-private/launcher/scroller-view.vala b/unity-private/launcher/scroller-view.vala index 2374d9765..78b609dad 100644 --- a/unity-private/launcher/scroller-view.vala +++ b/unity-private/launcher/scroller-view.vala @@ -37,7 +37,7 @@ namespace Unity.Launcher public ScrollerModel model {get; construct;} /* our scroller constants */ - public int spacing = 2; + public int spacing = 6; public int drag_sensitivity = 7; public float friction = 0.9f; @@ -89,7 +89,7 @@ namespace Unity.Launcher mypadding.left = 0.0f; mypadding.right = 0.0f; - mypadding.top = 5.0f; + mypadding.top = 10.0f; mypadding.bottom = 5.0f; this.padding = mypadding; diff --git a/unity-private/launcher/scrollerchild-controller.c b/unity-private/launcher/scrollerchild-controller.c index 4c7324a13..ba8198ef0 100644 --- a/unity-private/launcher/scrollerchild-controller.c +++ b/unity-private/launcher/scrollerchild-controller.c @@ -128,7 +128,6 @@ struct _UnityLauncherQuicklistControllerClass { }; -extern gboolean* unity_panel_search_entry_has_focus; static gpointer unity_launcher_scroller_child_controller_parent_class = NULL; static UnityDragModelIface* unity_launcher_scroller_child_controller_unity_drag_model_parent_iface = NULL; @@ -160,7 +159,7 @@ static gboolean unity_launcher_scroller_child_controller_on_enter_event (UnityLa CtkActor* unity_launcher_quicklist_controller_get_attached_actor (UnityLauncherQuicklistController* self); UnityLauncherScrollerChild* unity_launcher_scroller_child_controller_get_child (UnityLauncherScrollerChildController* self); static void _unity_launcher_scroller_child_controller_ensure_menu_state_clutter_actor_destroy (ClutterActor* _sender, gpointer self); -static gboolean _bool_equal (const gboolean* s1, const gboolean* s2); +#define UNITY_PANEL_search_entry_has_focus FALSE void unity_launcher_quicklist_controller_show_label (UnityLauncherQuicklistController* self, const char* label, CtkActor* attached_widget); void unity_launcher_quicklist_controller_show_menu (UnityLauncherQuicklistController* self, GeeArrayList* prefix_shortcuts, GeeArrayList* affix_shortcuts, gboolean hide_on_leave); static ClutterActor* unity_launcher_scroller_child_controller_real_get_icon (UnityDragModel* base); @@ -336,20 +335,6 @@ static void _unity_launcher_scroller_child_controller_ensure_menu_state_clutter_ } -static gboolean _bool_equal (const gboolean* s1, const gboolean* s2) { - if (s1 == s2) { - return TRUE; - } - if (s1 == NULL) { - return FALSE; - } - if (s2 == NULL) { - return FALSE; - } - return (*s1) == (*s2); -} - - static void unity_launcher_scroller_child_controller_ensure_menu_state (UnityLauncherScrollerChildController* self) { UnityLauncherQuicklistController* controller; gboolean _tmp0_ = FALSE; @@ -383,8 +368,7 @@ static void unity_launcher_scroller_child_controller_ensure_menu_state (UnityLau } if (self->menu_state == UNITY_LAUNCHER_SCROLLER_CHILD_CONTROLLER_MENU_STATE_LABEL) { if (!unity_launcher_quicklist_controller_menu_is_open (controller)) { - gboolean _tmp3_; - if (_bool_equal (unity_panel_search_entry_has_focus, (_tmp3_ = FALSE, &_tmp3_)) == TRUE) { + if (UNITY_PANEL_search_entry_has_focus == FALSE) { unity_launcher_quicklist_controller_show_label (controller, self->name, (CtkActor*) self->priv->_child); } } @@ -393,15 +377,15 @@ static void unity_launcher_scroller_child_controller_ensure_menu_state (UnityLau if (controller->is_in_label) { GeeArrayList* shortcuts; GeeArrayList* actions; - gboolean _tmp4_ = FALSE; + gboolean _tmp3_ = FALSE; shortcuts = unity_launcher_scroller_child_controller_get_menu_shortcuts (self); actions = unity_launcher_scroller_child_controller_get_menu_shortcut_actions (self); if (gee_collection_get_size ((GeeCollection*) shortcuts) > 0) { - _tmp4_ = TRUE; + _tmp3_ = TRUE; } else { - _tmp4_ = gee_collection_get_size ((GeeCollection*) actions) > 0; + _tmp3_ = gee_collection_get_size ((GeeCollection*) actions) > 0; } - if (_tmp4_) { + if (_tmp3_) { unity_launcher_quicklist_controller_show_menu (controller, shortcuts, actions, FALSE); } else { self->menu_state = UNITY_LAUNCHER_SCROLLER_CHILD_CONTROLLER_MENU_STATE_LABEL; @@ -480,27 +464,37 @@ static void unity_launcher_scroller_child_controller_set_child (UnityLauncherScr static gboolean _unity_launcher_scroller_child_controller_on_press_event_clutter_actor_button_press_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_launcher_scroller_child_controller_on_press_event (self, event); + gboolean result; + result = unity_launcher_scroller_child_controller_on_press_event (self, event); + return result; } static gboolean _unity_launcher_scroller_child_controller_on_release_event_clutter_actor_button_release_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_launcher_scroller_child_controller_on_release_event (self, event); + gboolean result; + result = unity_launcher_scroller_child_controller_on_release_event (self, event); + return result; } static gboolean _unity_launcher_scroller_child_controller_on_enter_event_clutter_actor_enter_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_launcher_scroller_child_controller_on_enter_event (self, event); + gboolean result; + result = unity_launcher_scroller_child_controller_on_enter_event (self, event); + return result; } static gboolean _unity_launcher_scroller_child_controller_on_leave_event_clutter_actor_leave_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_launcher_scroller_child_controller_on_leave_event (self, event); + gboolean result; + result = unity_launcher_scroller_child_controller_on_leave_event (self, event); + return result; } static gboolean _unity_launcher_scroller_child_controller_on_motion_event_clutter_actor_motion_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_launcher_scroller_child_controller_on_motion_event (self, event); + gboolean result; + result = unity_launcher_scroller_child_controller_on_motion_event (self, event); + return result; } diff --git a/unity-private/panel/panel-background.c b/unity-private/panel/panel-background.c new file mode 100644 index 000000000..8c7ec5c4e --- /dev/null +++ b/unity-private/panel/panel-background.c @@ -0,0 +1,238 @@ +/* panel-background.c generated by valac, the Vala compiler + * generated from panel-background.vala, do not modify */ + +/* + * Copyright (C) 2010 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by Neil Jagdish Patel <neil.patel@canonical.com> + * + */ + +#include <glib.h> +#include <glib-object.h> +#include <clutter/clutter.h> +#include <gdk-pixbuf/gdk-pixdata.h> +#include <stdlib.h> +#include <string.h> +#include <cairo.h> +#include <float.h> +#include <math.h> +#include <gdk/gdk.h> + + +#define UNITY_PANEL_TYPE_BACKGROUND (unity_panel_background_get_type ()) +#define UNITY_PANEL_BACKGROUND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_TYPE_BACKGROUND, UnityPanelBackground)) +#define UNITY_PANEL_BACKGROUND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_TYPE_BACKGROUND, UnityPanelBackgroundClass)) +#define UNITY_PANEL_IS_BACKGROUND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_TYPE_BACKGROUND)) +#define UNITY_PANEL_IS_BACKGROUND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_TYPE_BACKGROUND)) +#define UNITY_PANEL_BACKGROUND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_TYPE_BACKGROUND, UnityPanelBackgroundClass)) + +typedef struct _UnityPanelBackground UnityPanelBackground; +typedef struct _UnityPanelBackgroundClass UnityPanelBackgroundClass; +typedef struct _UnityPanelBackgroundPrivate UnityPanelBackgroundPrivate; +#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) +#define _cairo_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_destroy (var), NULL))) +#define _cairo_pattern_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_pattern_destroy (var), NULL))) +#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL))) + +struct _UnityPanelBackground { + ClutterCairoTexture parent_instance; + UnityPanelBackgroundPrivate * priv; +}; + +struct _UnityPanelBackgroundClass { + ClutterCairoTextureClass parent_class; +}; + +struct _UnityPanelBackgroundPrivate { + gint last_width; + gint last_height; + GdkPixbuf* tile; +}; + + +static gpointer unity_panel_background_parent_class = NULL; + +GType unity_panel_background_get_type (void); +#define UNITY_PANEL_BACKGROUND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UNITY_PANEL_TYPE_BACKGROUND, UnityPanelBackgroundPrivate)) +enum { + UNITY_PANEL_BACKGROUND_DUMMY_PROPERTY +}; +#define UNITY_PANEL_BACKGROUND_BG "/usr/share/unity/themes/panel_background.png" +UnityPanelBackground* unity_panel_background_new (void); +UnityPanelBackground* unity_panel_background_construct (GType object_type); +static gboolean unity_panel_background_update_background (UnityPanelBackground* self); +static gboolean _unity_panel_background_update_background_gsource_func (gpointer self); +static void unity_panel_background_real_allocate (ClutterActor* base, const ClutterActorBox* box, ClutterAllocationFlags flags); +static GObject * unity_panel_background_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties); +static void unity_panel_background_finalize (GObject* obj); + + + +UnityPanelBackground* unity_panel_background_construct (GType object_type) { + UnityPanelBackground * self; + self = (UnityPanelBackground*) g_object_new (object_type, NULL); + return self; +} + + +UnityPanelBackground* unity_panel_background_new (void) { + return unity_panel_background_construct (UNITY_PANEL_TYPE_BACKGROUND); +} + + +static gboolean _unity_panel_background_update_background_gsource_func (gpointer self) { + gboolean result; + result = unity_panel_background_update_background (self); + return result; +} + + +static void unity_panel_background_real_allocate (ClutterActor* base, const ClutterActorBox* box, ClutterAllocationFlags flags) { + UnityPanelBackground * self; + gint width; + gint height; + gboolean _tmp0_ = FALSE; + self = (UnityPanelBackground*) base; + width = (gint) ((*box).x2 - (*box).x1); + height = (gint) ((*box).y2 - (*box).y1); + CLUTTER_ACTOR_CLASS (unity_panel_background_parent_class)->allocate ((ClutterActor*) CLUTTER_CAIRO_TEXTURE (self), box, flags); + if (width != self->priv->last_width) { + _tmp0_ = TRUE; + } else { + _tmp0_ = height != self->priv->last_height; + } + if (_tmp0_) { + self->priv->last_width = width; + self->priv->last_height = height; + g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, _unity_panel_background_update_background_gsource_func, g_object_ref (self), g_object_unref); + } +} + + +static gpointer _cairo_pattern_reference0 (gpointer self) { + return self ? cairo_pattern_reference (self) : NULL; +} + + +static gboolean unity_panel_background_update_background (UnityPanelBackground* self) { + gboolean result = FALSE; + cairo_t* cr; + cairo_t* _tmp0_; + g_return_val_if_fail (self != NULL, FALSE); + cr = NULL; + clutter_cairo_texture_set_surface_size ((ClutterCairoTexture*) self, (guint) self->priv->last_width, (guint) self->priv->last_height); + cr = (_tmp0_ = clutter_cairo_texture_create ((ClutterCairoTexture*) self), _cairo_destroy0 (cr), _tmp0_); + cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR); + cairo_paint (cr); + cairo_set_operator (cr, CAIRO_OPERATOR_OVER); + cairo_set_line_width (cr, 1.0); + cairo_rectangle (cr, (double) 0, (double) 0, (double) self->priv->last_width, (double) self->priv->last_height); + cairo_set_source_rgb (cr, 61 / 255.0, 60 / 255.0, 56 / 255.0); + cairo_fill (cr); + cairo_rectangle (cr, (double) 0, (double) 0, (double) self->priv->last_width, (double) (self->priv->last_height - 3)); + if (GDK_IS_PIXBUF (self->priv->tile)) { + cairo_pattern_t* pat; + gdk_cairo_set_source_pixbuf (cr, self->priv->tile, (double) 0, (double) 0); + pat = _cairo_pattern_reference0 (cairo_get_source (cr)); + cairo_pattern_set_extend (pat, CAIRO_EXTEND_REPEAT); + cairo_fill (cr); + _cairo_pattern_destroy0 (pat); + } + result = FALSE; + _cairo_destroy0 (cr); + return result; +} + + +static GObject * unity_panel_background_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) { + GObject * obj; + GObjectClass * parent_class; + UnityPanelBackground * self; + GError * _inner_error_; + parent_class = G_OBJECT_CLASS (unity_panel_background_parent_class); + obj = parent_class->constructor (type, n_construct_properties, construct_properties); + self = UNITY_PANEL_BACKGROUND (obj); + _inner_error_ = NULL; + { + { + GdkPixbuf* _tmp0_; + GdkPixbuf* _tmp1_; + _tmp0_ = gdk_pixbuf_new_from_file (UNITY_PANEL_BACKGROUND_BG, &_inner_error_); + if (_inner_error_ != NULL) { + goto __catch2_g_error; + } + self->priv->tile = (_tmp1_ = _tmp0_, _g_object_unref0 (self->priv->tile), _tmp1_); + } + goto __finally2; + __catch2_g_error: + { + GError * e; + e = _inner_error_; + _inner_error_ = NULL; + { + g_warning ("panel-background.vala:46: Unable to load panel background"); + _g_error_free0 (e); + } + } + __finally2: + if (_inner_error_ != NULL) { + g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); + g_clear_error (&_inner_error_); + } + } + return obj; +} + + +static void unity_panel_background_class_init (UnityPanelBackgroundClass * klass) { + unity_panel_background_parent_class = g_type_class_peek_parent (klass); + g_type_class_add_private (klass, sizeof (UnityPanelBackgroundPrivate)); + CLUTTER_ACTOR_CLASS (klass)->allocate = unity_panel_background_real_allocate; + G_OBJECT_CLASS (klass)->constructor = unity_panel_background_constructor; + G_OBJECT_CLASS (klass)->finalize = unity_panel_background_finalize; +} + + +static void unity_panel_background_instance_init (UnityPanelBackground * self) { + self->priv = UNITY_PANEL_BACKGROUND_GET_PRIVATE (self); + self->priv->last_width = 0; + self->priv->last_height = 0; + self->priv->tile = NULL; +} + + +static void unity_panel_background_finalize (GObject* obj) { + UnityPanelBackground * self; + self = UNITY_PANEL_BACKGROUND (obj); + _g_object_unref0 (self->priv->tile); + G_OBJECT_CLASS (unity_panel_background_parent_class)->finalize (obj); +} + + +GType unity_panel_background_get_type (void) { + static volatile gsize unity_panel_background_type_id__volatile = 0; + if (g_once_init_enter (&unity_panel_background_type_id__volatile)) { + static const GTypeInfo g_define_type_info = { sizeof (UnityPanelBackgroundClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) unity_panel_background_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UnityPanelBackground), 0, (GInstanceInitFunc) unity_panel_background_instance_init, NULL }; + GType unity_panel_background_type_id; + unity_panel_background_type_id = g_type_register_static (CLUTTER_TYPE_CAIRO_TEXTURE, "UnityPanelBackground", &g_define_type_info, 0); + g_once_init_leave (&unity_panel_background_type_id__volatile, unity_panel_background_type_id); + } + return unity_panel_background_type_id__volatile; +} + + + + diff --git a/unity-private/panel/panel-background.vala b/unity-private/panel/panel-background.vala new file mode 100644 index 000000000..450970cdc --- /dev/null +++ b/unity-private/panel/panel-background.vala @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2010 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by Neil Jagdish Patel <neil.patel@canonical.com> + * + */ + +namespace Unity.Panel +{ + public class Background : Clutter.CairoTexture + { + public const string BG = "/usr/share/unity/themes/panel_background.png"; + private int last_width = 0; + private int last_height = 0; + + Gdk.Pixbuf tile = null; + + public Background () + { + Object (); + } + + construct + { + try + { + /* I've loaded this in directly and not through theme due to use + * not having a good loader for pixbufs from the theme right now + */ + tile = new Gdk.Pixbuf.from_file (BG); + } + catch (Error e) + { + warning ("Unable to load panel background"); + } + } + + private override void allocate (Clutter.ActorBox box, + Clutter.AllocationFlags flags) + { + int width = (int)(box.x2 - box.x1); + int height = (int)(box.y2 - box.y1); + + base.allocate (box, flags); + + if (width != last_width || height != last_height) + { + last_width = width; + last_height = height; + + Idle.add (update_background); + } + } + + private bool update_background () + { + Cairo.Context cr; + + set_surface_size (last_width, last_height); + + cr = create (); + + cr.set_operator (Cairo.Operator.CLEAR); + cr.paint (); + + cr.set_operator (Cairo.Operator.OVER); + cr.set_line_width (1.0); + + cr.rectangle (0, 0, last_width, last_height); + cr.set_source_rgb (61/255.0, 60/255.0, 56/255.0); + cr.fill (); + + cr.rectangle (0, 0, last_width, last_height-3); + if (tile is Gdk.Pixbuf) + { + Gdk.cairo_set_source_pixbuf (cr, tile, 0, 0); + var pat = cr.get_source (); + pat.set_extend (Cairo.Extend.REPEAT); + cr.fill (); + } + + return false; + } + } +} diff --git a/unity-private/panel/panel-home.c b/unity-private/panel/panel-home-button.c index 6ca32530a..0019e30c7 100644 --- a/unity-private/panel/panel-home.c +++ b/unity-private/panel/panel-home-button.c @@ -1,5 +1,5 @@ -/* panel-home.c generated by valac, the Vala compiler - * generated from panel-home.vala, do not modify */ +/* panel-home-button.c generated by valac, the Vala compiler + * generated from panel-home-button.vala, do not modify */ /* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */ /* @@ -17,7 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * Authored by Neil Jagdish Patel <neil.patel@canonical.com> + * Authored by Mirco Müller <mirco.mueller@canonical.com> * */ @@ -56,13 +56,13 @@ typedef struct _UnityTestingObjectRegistryClass UnityTestingObjectRegistryClass; #define _unity_testing_object_registry_unref0(var) ((var == NULL) ? NULL : (var = (unity_testing_object_registry_unref (var), NULL))) struct _UnityPanelHomeButton { - CtkBin parent_instance; + CtkButton parent_instance; UnityPanelHomeButtonPrivate * priv; - UnityThemeImage* image; + UnityThemeImage* theme_image; }; struct _UnityPanelHomeButtonClass { - CtkBinClass parent_class; + CtkButtonClass parent_class; }; struct _UnityPanelHomeButtonPrivate { @@ -89,10 +89,13 @@ UnityTestingObjectRegistry* unity_testing_object_registry_get_default (void); void unity_testing_object_registry_register (UnityTestingObjectRegistry* self, const char* name, GObject* object); UnityPanelHomeButton* unity_panel_home_button_new (UnityShell* shell); UnityPanelHomeButton* unity_panel_home_button_construct (GType object_type, UnityShell* shell); +UnityShell* unity_panel_home_button_get_shell (UnityPanelHomeButton* self); static void unity_panel_home_button_real_allocate (ClutterActor* base, const ClutterActorBox* box, ClutterAllocationFlags flags); +static void unity_panel_home_button_real_get_preferred_width (ClutterActor* base, float for_height, float* min_width, float* nat_width); +static gboolean unity_panel_home_button_on_button_press (UnityPanelHomeButton* self, ClutterEvent* event); static gboolean unity_panel_home_button_on_button_release (UnityPanelHomeButton* self, ClutterEvent* event); -UnityShell* unity_panel_home_button_get_shell (UnityPanelHomeButton* self); static void unity_panel_home_button_set_shell (UnityPanelHomeButton* self, UnityShell* value); +static gboolean _unity_panel_home_button_on_button_press_clutter_actor_button_press_event (ClutterActor* _sender, ClutterEvent* event, gpointer self); static gboolean _unity_panel_home_button_on_button_release_clutter_actor_button_release_event (ClutterActor* _sender, ClutterEvent* event, gpointer self); static GObject * unity_panel_home_button_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties); static void unity_panel_home_button_finalize (GObject* obj); @@ -121,30 +124,54 @@ static void unity_panel_home_button_real_allocate (ClutterActor* base, const Clu UnityPanelHomeButton * self; float cwidth = 0.0F; float cheight = 0.0F; + float lwidth = 0.0F; + float pheight = 0.0F; CtkPadding _tmp0_ = {0}; CtkPadding pad; self = (UnityPanelHomeButton*) base; pad = (_tmp0_.top = (float) 0, _tmp0_); - clutter_actor_get_preferred_size ((ClutterActor*) self->image, &cwidth, &cheight, &cwidth, &cheight); - if (clutter_actor_get_width ((ClutterActor*) self) < 1) { - cwidth = (float) 19; + lwidth = (float) unity_shell_get_launcher_width_foobar (self->priv->_shell); + pheight = (float) unity_shell_get_panel_height_foobar (self->priv->_shell); + clutter_actor_get_preferred_size ((ClutterActor*) self->theme_image, &cwidth, &cheight, &cwidth, &cheight); + if ((lwidth - cwidth) <= 0.0f) { + pad.left = 0.0f; + pad.right = pad.left; + } else { + pad.left = (((*box).x2 - (*box).x1) - cwidth) / 2.0f; + pad.right = pad.left; } - if (clutter_actor_get_height ((ClutterActor*) self) < 1) { - cheight = (float) 19; + if ((pheight - cheight) <= 0.0f) { + pad.top = 0.0f; + pad.bottom = pad.top; + } else { + pad.top = (((*box).y2 - (*box).y1) - cheight) / 2.0f; + pad.bottom = pad.top; } - pad.left = (((*box).x2 - (*box).x1) - cwidth) / 2.0f; - pad.right = pad.left; - pad.top = (((*box).y2 - (*box).y1) - cheight) / 2.0f; - pad.bottom = pad.top; ctk_actor_set_padding ((CtkActor*) self, &pad); - CLUTTER_ACTOR_CLASS (unity_panel_home_button_parent_class)->allocate ((ClutterActor*) CTK_BIN (self), box, flags); + CLUTTER_ACTOR_CLASS (unity_panel_home_button_parent_class)->allocate ((ClutterActor*) CTK_BUTTON (self), box, flags); +} + + +static void unity_panel_home_button_real_get_preferred_width (ClutterActor* base, float for_height, float* min_width, float* nat_width) { + UnityPanelHomeButton * self; + self = (UnityPanelHomeButton*) base; + *min_width = (float) unity_shell_get_launcher_width_foobar (self->priv->_shell); + *nat_width = (float) unity_shell_get_launcher_width_foobar (self->priv->_shell); +} + + +static gboolean unity_panel_home_button_on_button_press (UnityPanelHomeButton* self, ClutterEvent* event) { + gboolean result = FALSE; + g_return_val_if_fail (self != NULL, FALSE); + result = TRUE; + return result; } static gboolean unity_panel_home_button_on_button_release (UnityPanelHomeButton* self, ClutterEvent* event) { gboolean result = FALSE; g_return_val_if_fail (self != NULL, FALSE); - g_signal_emit_by_name (self, "clicked", (*event).button.time); + unity_shell_show_unity (self->priv->_shell); result = TRUE; return result; } @@ -171,8 +198,17 @@ static void unity_panel_home_button_set_shell (UnityPanelHomeButton* self, Unity } +static gboolean _unity_panel_home_button_on_button_press_clutter_actor_button_press_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { + gboolean result; + result = unity_panel_home_button_on_button_press (self, event); + return result; +} + + static gboolean _unity_panel_home_button_on_button_release_clutter_actor_button_release_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_panel_home_button_on_button_release (self, event); + gboolean result; + result = unity_panel_home_button_on_button_release (self, event); + return result; } @@ -185,9 +221,10 @@ static GObject * unity_panel_home_button_constructor (GType type, guint n_constr self = UNITY_PANEL_HOME_BUTTON (obj); { UnityThemeImage* _tmp0_; - self->image = (_tmp0_ = g_object_ref_sink (unity_theme_image_new ("distributor-logo")), _g_object_unref0 (self->image), _tmp0_); - clutter_container_add_actor ((ClutterContainer*) self, (ClutterActor*) self->image); - clutter_actor_show ((ClutterActor*) self->image); + self->theme_image = (_tmp0_ = g_object_ref_sink (unity_theme_image_new ("distributor-logo")), _g_object_unref0 (self->theme_image), _tmp0_); + clutter_container_add_actor ((ClutterContainer*) self, (ClutterActor*) self->theme_image); + clutter_actor_show ((ClutterActor*) self->theme_image); + g_signal_connect_object ((ClutterActor*) self, "button-press-event", (GCallback) _unity_panel_home_button_on_button_press_clutter_actor_button_press_event, self, 0); g_signal_connect_object ((ClutterActor*) self, "button-release-event", (GCallback) _unity_panel_home_button_on_button_release_clutter_actor_button_release_event, self, 0); } return obj; @@ -198,12 +235,12 @@ static void unity_panel_home_button_class_init (UnityPanelHomeButtonClass * klas unity_panel_home_button_parent_class = g_type_class_peek_parent (klass); g_type_class_add_private (klass, sizeof (UnityPanelHomeButtonPrivate)); CLUTTER_ACTOR_CLASS (klass)->allocate = unity_panel_home_button_real_allocate; + CLUTTER_ACTOR_CLASS (klass)->get_preferred_width = unity_panel_home_button_real_get_preferred_width; G_OBJECT_CLASS (klass)->get_property = unity_panel_home_button_get_property; G_OBJECT_CLASS (klass)->set_property = unity_panel_home_button_set_property; G_OBJECT_CLASS (klass)->constructor = unity_panel_home_button_constructor; G_OBJECT_CLASS (klass)->finalize = unity_panel_home_button_finalize; g_object_class_install_property (G_OBJECT_CLASS (klass), UNITY_PANEL_HOME_BUTTON_SHELL, g_param_spec_object ("shell", "shell", "shell", UNITY_TYPE_SHELL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); - g_signal_new ("clicked", UNITY_PANEL_TYPE_HOME_BUTTON, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT); } @@ -216,7 +253,7 @@ static void unity_panel_home_button_finalize (GObject* obj) { UnityPanelHomeButton * self; self = UNITY_PANEL_HOME_BUTTON (obj); _g_object_unref0 (self->priv->_shell); - _g_object_unref0 (self->image); + _g_object_unref0 (self->theme_image); G_OBJECT_CLASS (unity_panel_home_button_parent_class)->finalize (obj); } @@ -226,7 +263,7 @@ GType unity_panel_home_button_get_type (void) { if (g_once_init_enter (&unity_panel_home_button_type_id__volatile)) { static const GTypeInfo g_define_type_info = { sizeof (UnityPanelHomeButtonClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) unity_panel_home_button_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UnityPanelHomeButton), 0, (GInstanceInitFunc) unity_panel_home_button_instance_init, NULL }; GType unity_panel_home_button_type_id; - unity_panel_home_button_type_id = g_type_register_static (CTK_TYPE_BIN, "UnityPanelHomeButton", &g_define_type_info, 0); + unity_panel_home_button_type_id = g_type_register_static (CTK_TYPE_BUTTON, "UnityPanelHomeButton", &g_define_type_info, 0); g_once_init_leave (&unity_panel_home_button_type_id__volatile, unity_panel_home_button_type_id); } return unity_panel_home_button_type_id__volatile; diff --git a/unity-private/panel/panel-home-button.vala b/unity-private/panel/panel-home-button.vala new file mode 100644 index 000000000..0f64a9e70 --- /dev/null +++ b/unity-private/panel/panel-home-button.vala @@ -0,0 +1,119 @@ +/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */ +/* + * Copyright (C) 2010 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by Mirco Müller <mirco.mueller@canonical.com> + * + */ + +namespace Unity.Panel +{ + public class HomeButton : Ctk.Button + { + public Shell shell { get; construct; } + public ThemeImage theme_image; + + public HomeButton (Shell shell) + { + Object (reactive:true, shell:shell); + + Unity.Testing.ObjectRegistry.get_default ().register ("PanelHomeButton", + this); + } + + private override void allocate (Clutter.ActorBox box, + Clutter.AllocationFlags flags) + { + float cwidth; + float cheight; + float lwidth; + float pheight; + Ctk.Padding pad = { 0 }; + + lwidth = (float) this.shell.get_launcher_width_foobar (); + pheight = (float) this.shell.get_panel_height_foobar (); + this.theme_image.get_preferred_size (out cwidth, out cheight, + out cwidth, out cheight); + + /* adapt icon-width to launcher-width with padding */ + if (lwidth - cwidth <= 0.0f) + { + /* icon is wider or as wide as launcher */ + pad.left = 0.0f; + pad.right = pad.left; + } + else + { + /* icon is narrower than launcher */ + pad.left = (box.x2 - box.x1 - cwidth) / 2.0f; + pad.right = pad.left; + } + + /* adapt icon-height to panel-height with padding */ + if (pheight - cheight <= 0.0f) + { + /* icon higher or as high as launcher */ + pad.top = 0.0f; + pad.bottom = pad.top; + } + else + { + /* icon is smaller than launcher */ + pad.top = (box.y2 - box.y1 - cheight) / 2.0f; + pad.bottom = pad.top; + } + + this.padding = pad; + + base.allocate (box, flags); + } + + construct + { + this.theme_image = new ThemeImage ("distributor-logo"); + this.add_actor (this.theme_image); + this.theme_image.show (); + + this.button_press_event.connect (this.on_button_press); + this.button_release_event.connect (this.on_button_release); + } + + /* We always want to be the width of the launcher */ + private override void get_preferred_width (float for_height, + out float min_width, + out float nat_width) + { + min_width = this.shell.get_launcher_width_foobar (); + nat_width = this.shell.get_launcher_width_foobar (); + } + + private bool on_button_press (Clutter.Event event) + { + return true; + } + + private bool on_button_release (Clutter.Event event) + { + shell.show_unity (); + return true; + } + } +} + +/* +you probably need to add a new function to unity.shell to do that, and then +implement in Unity.Plugin and testing/test-window.vala (for the two targets) +*/ + diff --git a/unity-private/panel/panel-home.vala b/unity-private/panel/panel-home.vala deleted file mode 100644 index 008e12ac3..000000000 --- a/unity-private/panel/panel-home.vala +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */ -/* - * Copyright (C) 2010 Canonical Ltd - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * Authored by Neil Jagdish Patel <neil.patel@canonical.com> - * - */ - -namespace Unity.Panel -{ - public class HomeButton : Ctk.Bin - { - public Shell shell { get; construct; } - public ThemeImage image; - - public signal void clicked (uint32 time_); - - public HomeButton (Shell shell) - { - Object (reactive:true, - shell:shell); - - Unity.Testing.ObjectRegistry.get_default ().register ("PanelHomeButton", - this); - } - - construct - { - this.image = new ThemeImage ("distributor-logo"); - this.add_actor (this.image); - this.image.show (); - - this.button_release_event.connect (this.on_button_release); - } - - private override void allocate (Clutter.ActorBox box, - Clutter.AllocationFlags flags) - { - float cwidth, cheight; - Ctk.Padding pad = { 0 }; - - this.image.get_preferred_size (out cwidth, out cheight, - out cwidth, out cheight); - - /* Just in case the loading is slow */ - if (width < 1) - cwidth = 19; - if (height < 1) - cheight = 19; - - pad.left = (box.x2 - box.x1 - cwidth) / 2.0f; - pad.right = pad.left; - pad.top = (box.y2 - box.y1 - cheight) / 2.0f; - pad.bottom = pad.top; - - this.padding = pad; - - base.allocate (box, flags); - } - - private bool on_button_release (Clutter.Event event) - { - this.clicked (event.button.time); - - return true; - } - } -} diff --git a/unity-private/panel/panel-indicator-bar.c b/unity-private/panel/panel-indicator-bar.c new file mode 100644 index 000000000..a26baa581 --- /dev/null +++ b/unity-private/panel/panel-indicator-bar.c @@ -0,0 +1,251 @@ +/* panel-indicator-bar.c generated by valac, the Vala compiler + * generated from panel-indicator-bar.vala, do not modify */ + +/* + * Copyright (C) 2010 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> + * Jay Taoko <jay.taoko@canonical.com> + * + */ + +#include <glib.h> +#include <glib-object.h> +#include <clutk/clutk.h> +#include <gee.h> +#include <gtk/gtk.h> +#include <libindicator/indicator-object.h> +#include <stdlib.h> +#include <string.h> +#include <clutter/clutter.h> + + +#define UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR (unity_panel_indicators_indicator_bar_get_type ()) +#define UNITY_PANEL_INDICATORS_INDICATOR_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR, UnityPanelIndicatorsIndicatorBar)) +#define UNITY_PANEL_INDICATORS_INDICATOR_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR, UnityPanelIndicatorsIndicatorBarClass)) +#define UNITY_PANEL_INDICATORS_IS_INDICATOR_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR)) +#define UNITY_PANEL_INDICATORS_IS_INDICATOR_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR)) +#define UNITY_PANEL_INDICATORS_INDICATOR_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR, UnityPanelIndicatorsIndicatorBarClass)) + +typedef struct _UnityPanelIndicatorsIndicatorBar UnityPanelIndicatorsIndicatorBar; +typedef struct _UnityPanelIndicatorsIndicatorBarClass UnityPanelIndicatorsIndicatorBarClass; +typedef struct _UnityPanelIndicatorsIndicatorBarPrivate UnityPanelIndicatorsIndicatorBarPrivate; + +#define UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW (unity_panel_indicators_indicator_object_view_get_type ()) +#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW, UnityPanelIndicatorsIndicatorObjectView)) +#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW, UnityPanelIndicatorsIndicatorObjectViewClass)) +#define UNITY_PANEL_INDICATORS_IS_INDICATOR_OBJECT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW)) +#define UNITY_PANEL_INDICATORS_IS_INDICATOR_OBJECT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW)) +#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW, UnityPanelIndicatorsIndicatorObjectViewClass)) + +typedef struct _UnityPanelIndicatorsIndicatorObjectView UnityPanelIndicatorsIndicatorObjectView; +typedef struct _UnityPanelIndicatorsIndicatorObjectViewClass UnityPanelIndicatorsIndicatorObjectViewClass; +#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) + +#define UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL (unity_panel_indicators_indicators_model_get_type ()) +#define UNITY_PANEL_INDICATORS_INDICATORS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL, UnityPanelIndicatorsIndicatorsModel)) +#define UNITY_PANEL_INDICATORS_INDICATORS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL, UnityPanelIndicatorsIndicatorsModelClass)) +#define UNITY_PANEL_INDICATORS_IS_INDICATORS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL)) +#define UNITY_PANEL_INDICATORS_IS_INDICATORS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL)) +#define UNITY_PANEL_INDICATORS_INDICATORS_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL, UnityPanelIndicatorsIndicatorsModelClass)) + +typedef struct _UnityPanelIndicatorsIndicatorsModel UnityPanelIndicatorsIndicatorsModel; +typedef struct _UnityPanelIndicatorsIndicatorsModelClass UnityPanelIndicatorsIndicatorsModelClass; +#define _g_free0(var) (var = (g_free (var), NULL)) + +struct _UnityPanelIndicatorsIndicatorBar { + CtkBox parent_instance; + UnityPanelIndicatorsIndicatorBarPrivate * priv; +}; + +struct _UnityPanelIndicatorsIndicatorBarClass { + CtkBoxClass parent_class; +}; + +struct _UnityPanelIndicatorsIndicatorBarPrivate { + GeeArrayList* indicator_array; +}; + + +static gpointer unity_panel_indicators_indicator_bar_parent_class = NULL; + +GType unity_panel_indicators_indicator_bar_get_type (void); +GType unity_panel_indicators_indicator_object_view_get_type (void); +#define UNITY_PANEL_INDICATORS_INDICATOR_BAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR, UnityPanelIndicatorsIndicatorBarPrivate)) +enum { + UNITY_PANEL_INDICATORS_INDICATOR_BAR_DUMMY_PROPERTY +}; +UnityPanelIndicatorsIndicatorBar* unity_panel_indicators_indicator_bar_new (void); +UnityPanelIndicatorsIndicatorBar* unity_panel_indicators_indicator_bar_construct (GType object_type); +void unity_panel_indicators_indicator_object_view_open_last_menu_entry (UnityPanelIndicatorsIndicatorObjectView* self); +void unity_panel_indicators_indicator_object_view_open_first_menu_entry (UnityPanelIndicatorsIndicatorObjectView* self); +static void unity_panel_indicators_indicator_bar_on_menu_moved (UnityPanelIndicatorsIndicatorBar* self, UnityPanelIndicatorsIndicatorObjectView* object_view, GtkMenuDirectionType type); +GType unity_panel_indicators_indicators_model_get_type (void); +UnityPanelIndicatorsIndicatorsModel* unity_panel_indicators_indicators_model_get_default (void); +GeeArrayList* unity_panel_indicators_indicators_model_get_indicators (UnityPanelIndicatorsIndicatorsModel* self); +char* unity_panel_indicators_indicators_model_get_indicator_name (UnityPanelIndicatorsIndicatorsModel* self, IndicatorObject* o); +UnityPanelIndicatorsIndicatorObjectView* unity_panel_indicators_indicator_object_view_new (IndicatorObject* _object); +UnityPanelIndicatorsIndicatorObjectView* unity_panel_indicators_indicator_object_view_construct (GType object_type, IndicatorObject* _object); +static void _unity_panel_indicators_indicator_bar_on_menu_moved_unity_panel_indicators_indicator_object_view_menu_moved (UnityPanelIndicatorsIndicatorObjectView* _sender, GtkMenuDirectionType type, gpointer self); +static GObject * unity_panel_indicators_indicator_bar_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties); +static void unity_panel_indicators_indicator_bar_finalize (GObject* obj); +static int _vala_strcmp0 (const char * str1, const char * str2); + + + +UnityPanelIndicatorsIndicatorBar* unity_panel_indicators_indicator_bar_construct (GType object_type) { + UnityPanelIndicatorsIndicatorBar * self; + self = (UnityPanelIndicatorsIndicatorBar*) g_object_new (object_type, "orientation", CTK_ORIENTATION_HORIZONTAL, "spacing", 0, "homogeneous", FALSE, NULL); + return self; +} + + +UnityPanelIndicatorsIndicatorBar* unity_panel_indicators_indicator_bar_new (void) { + return unity_panel_indicators_indicator_bar_construct (UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR); +} + + +static void unity_panel_indicators_indicator_bar_on_menu_moved (UnityPanelIndicatorsIndicatorBar* self, UnityPanelIndicatorsIndicatorObjectView* object_view, GtkMenuDirectionType type) { + gint pos; + UnityPanelIndicatorsIndicatorObjectView* next_object_view; + g_return_if_fail (self != NULL); + g_return_if_fail (object_view != NULL); + pos = gee_abstract_list_index_of ((GeeAbstractList*) self->priv->indicator_array, object_view); + if (pos == (-1)) { + return; + } + if (type == GTK_MENU_DIR_PARENT) { + if (pos == 0) { + pos = gee_collection_get_size ((GeeCollection*) self->priv->indicator_array) - 1; + } else { + pos = pos - 1; + } + } else { + if (type == GTK_MENU_DIR_CHILD) { + if (pos == (gee_collection_get_size ((GeeCollection*) self->priv->indicator_array) - 1)) { + pos = 0; + } else { + pos = pos + 1; + } + } + } + next_object_view = (UnityPanelIndicatorsIndicatorObjectView*) gee_abstract_list_get ((GeeAbstractList*) self->priv->indicator_array, pos); + if (type == GTK_MENU_DIR_PARENT) { + unity_panel_indicators_indicator_object_view_open_last_menu_entry (next_object_view); + } + if (type == GTK_MENU_DIR_CHILD) { + unity_panel_indicators_indicator_object_view_open_first_menu_entry (next_object_view); + } + _g_object_unref0 (next_object_view); +} + + +static void _unity_panel_indicators_indicator_bar_on_menu_moved_unity_panel_indicators_indicator_object_view_menu_moved (UnityPanelIndicatorsIndicatorObjectView* _sender, GtkMenuDirectionType type, gpointer self) { + unity_panel_indicators_indicator_bar_on_menu_moved (self, _sender, type); +} + + +static GObject * unity_panel_indicators_indicator_bar_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) { + GObject * obj; + GObjectClass * parent_class; + UnityPanelIndicatorsIndicatorBar * self; + parent_class = G_OBJECT_CLASS (unity_panel_indicators_indicator_bar_parent_class); + obj = parent_class->constructor (type, n_construct_properties, construct_properties); + self = UNITY_PANEL_INDICATORS_INDICATOR_BAR (obj); + { + GeeArrayList* _tmp0_; + UnityPanelIndicatorsIndicatorsModel* model; + GeeArrayList* indicators_list; + self->priv->indicator_array = (_tmp0_ = gee_array_list_new (UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL), _g_object_unref0 (self->priv->indicator_array), _tmp0_); + model = unity_panel_indicators_indicators_model_get_default (); + indicators_list = unity_panel_indicators_indicators_model_get_indicators (model); + { + GeeIterator* _o_it; + _o_it = gee_abstract_collection_iterator ((GeeAbstractCollection*) indicators_list); + while (TRUE) { + IndicatorObject* o; + char* name; + if (!gee_iterator_next (_o_it)) { + break; + } + o = (IndicatorObject*) gee_iterator_get (_o_it); + name = unity_panel_indicators_indicators_model_get_indicator_name (model, o); + if (_vala_strcmp0 (name, "libappmenu.so") != 0) { + UnityPanelIndicatorsIndicatorObjectView* indicator_object_view; + indicator_object_view = g_object_ref_sink (unity_panel_indicators_indicator_object_view_new (o)); + g_signal_connect_object (indicator_object_view, "menu-moved", (GCallback) _unity_panel_indicators_indicator_bar_on_menu_moved_unity_panel_indicators_indicator_object_view_menu_moved, self, 0); + gee_abstract_collection_add ((GeeAbstractCollection*) self->priv->indicator_array, indicator_object_view); + clutter_container_add_actor ((ClutterContainer*) self, (ClutterActor*) indicator_object_view); + clutter_actor_show ((ClutterActor*) indicator_object_view); + _g_object_unref0 (indicator_object_view); + } + _g_object_unref0 (o); + _g_free0 (name); + } + _g_object_unref0 (_o_it); + } + _g_object_unref0 (model); + _g_object_unref0 (indicators_list); + } + return obj; +} + + +static void unity_panel_indicators_indicator_bar_class_init (UnityPanelIndicatorsIndicatorBarClass * klass) { + unity_panel_indicators_indicator_bar_parent_class = g_type_class_peek_parent (klass); + g_type_class_add_private (klass, sizeof (UnityPanelIndicatorsIndicatorBarPrivate)); + G_OBJECT_CLASS (klass)->constructor = unity_panel_indicators_indicator_bar_constructor; + G_OBJECT_CLASS (klass)->finalize = unity_panel_indicators_indicator_bar_finalize; +} + + +static void unity_panel_indicators_indicator_bar_instance_init (UnityPanelIndicatorsIndicatorBar * self) { + self->priv = UNITY_PANEL_INDICATORS_INDICATOR_BAR_GET_PRIVATE (self); +} + + +static void unity_panel_indicators_indicator_bar_finalize (GObject* obj) { + UnityPanelIndicatorsIndicatorBar * self; + self = UNITY_PANEL_INDICATORS_INDICATOR_BAR (obj); + _g_object_unref0 (self->priv->indicator_array); + G_OBJECT_CLASS (unity_panel_indicators_indicator_bar_parent_class)->finalize (obj); +} + + +GType unity_panel_indicators_indicator_bar_get_type (void) { + static volatile gsize unity_panel_indicators_indicator_bar_type_id__volatile = 0; + if (g_once_init_enter (&unity_panel_indicators_indicator_bar_type_id__volatile)) { + static const GTypeInfo g_define_type_info = { sizeof (UnityPanelIndicatorsIndicatorBarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) unity_panel_indicators_indicator_bar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UnityPanelIndicatorsIndicatorBar), 0, (GInstanceInitFunc) unity_panel_indicators_indicator_bar_instance_init, NULL }; + GType unity_panel_indicators_indicator_bar_type_id; + unity_panel_indicators_indicator_bar_type_id = g_type_register_static (CTK_TYPE_BOX, "UnityPanelIndicatorsIndicatorBar", &g_define_type_info, 0); + g_once_init_leave (&unity_panel_indicators_indicator_bar_type_id__volatile, unity_panel_indicators_indicator_bar_type_id); + } + return unity_panel_indicators_indicator_bar_type_id__volatile; +} + + +static int _vala_strcmp0 (const char * str1, const char * str2) { + if (str1 == NULL) { + return -(str1 != str2); + } + if (str2 == NULL) { + return str1 != str2; + } + return strcmp (str1, str2); +} + + + + diff --git a/unity-private/panel/panel-indicator-bar.vala b/unity-private/panel/panel-indicator-bar.vala new file mode 100644 index 000000000..0befd8ced --- /dev/null +++ b/unity-private/panel/panel-indicator-bar.vala @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2010 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> + * Jay Taoko <jay.taoko@canonical.com> + * + */ + +namespace Unity.Panel.Indicators +{ + public class IndicatorBar : Ctk.Box + { + private Gee.ArrayList<Indicators.IndicatorObjectView> indicator_array; + + public IndicatorBar () + { + Object (orientation: Ctk.Orientation.HORIZONTAL, + spacing: 0, + homogeneous:false); + } + + construct + { + indicator_array = new Gee.ArrayList<Indicators.IndicatorObjectView> (); + + var model = IndicatorsModel.get_default (); + var indicators_list = model.get_indicators (); + + foreach (Indicator.Object o in indicators_list) + { + var name = model.get_indicator_name (o); + + if (name != "libappmenu.so") + { + IndicatorObjectView indicator_object_view = new IndicatorObjectView (o); + indicator_object_view.menu_moved.connect (this.on_menu_moved); + this.indicator_array.add (indicator_object_view); + + this.add_actor (indicator_object_view); + indicator_object_view.show (); + } + } + + // Create IndicatorObjectViews as necessary + // Connect to menu_moved signals + } + + private void on_menu_moved (IndicatorObjectView object_view, + Gtk.MenuDirectionType type) + { + int pos = this.indicator_array.index_of (object_view); + if (pos == -1) + return; + + if (type == Gtk.MenuDirectionType.PARENT) + { + if (pos == 0) + { + pos = this.indicator_array.size - 1; + } + else + pos -= 1; + } + else if (type == Gtk.MenuDirectionType.CHILD) + { + if (pos == this.indicator_array.size - 1) + { + pos = 0; + } + else + pos +=1; + } + + IndicatorObjectView next_object_view = this.indicator_array.get (pos); + + if (type == Gtk.MenuDirectionType.PARENT) + { + next_object_view.open_last_menu_entry (); + } + + if (type == Gtk.MenuDirectionType.CHILD) + { + next_object_view.open_first_menu_entry (); + } + } + } +} diff --git a/unity-private/panel/panel-indicator-model.c b/unity-private/panel/panel-indicator-model.c new file mode 100644 index 000000000..7ac34bf33 --- /dev/null +++ b/unity-private/panel/panel-indicator-model.c @@ -0,0 +1,458 @@ +/* panel-indicator-model.c generated by valac, the Vala compiler + * generated from panel-indicator-model.vala, do not modify */ + +/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */ +/* + * Copyright (C) 2010 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by canonical.com + * + */ + +#include <glib.h> +#include <glib-object.h> +#include <gee.h> +#include <libindicator/indicator-object.h> +#include <stdlib.h> +#include <string.h> +#include <unity-utils.h> +#include <gtk/gtk.h> +#include <gio/gio.h> + + +#define UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL (unity_panel_indicators_indicators_model_get_type ()) +#define UNITY_PANEL_INDICATORS_INDICATORS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL, UnityPanelIndicatorsIndicatorsModel)) +#define UNITY_PANEL_INDICATORS_INDICATORS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL, UnityPanelIndicatorsIndicatorsModelClass)) +#define UNITY_PANEL_INDICATORS_IS_INDICATORS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL)) +#define UNITY_PANEL_INDICATORS_IS_INDICATORS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL)) +#define UNITY_PANEL_INDICATORS_INDICATORS_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL, UnityPanelIndicatorsIndicatorsModelClass)) + +typedef struct _UnityPanelIndicatorsIndicatorsModel UnityPanelIndicatorsIndicatorsModel; +typedef struct _UnityPanelIndicatorsIndicatorsModelClass UnityPanelIndicatorsIndicatorsModelClass; +typedef struct _UnityPanelIndicatorsIndicatorsModelPrivate UnityPanelIndicatorsIndicatorsModelPrivate; + +#define UNITY_PANEL_INDICATORS_TYPE_INDICATORS_FILE_MODEL (unity_panel_indicators_indicators_file_model_get_type ()) +#define UNITY_PANEL_INDICATORS_INDICATORS_FILE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_FILE_MODEL, UnityPanelIndicatorsIndicatorsFileModel)) +#define UNITY_PANEL_INDICATORS_INDICATORS_FILE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_FILE_MODEL, UnityPanelIndicatorsIndicatorsFileModelClass)) +#define UNITY_PANEL_INDICATORS_IS_INDICATORS_FILE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_FILE_MODEL)) +#define UNITY_PANEL_INDICATORS_IS_INDICATORS_FILE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_FILE_MODEL)) +#define UNITY_PANEL_INDICATORS_INDICATORS_FILE_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_FILE_MODEL, UnityPanelIndicatorsIndicatorsFileModelClass)) + +typedef struct _UnityPanelIndicatorsIndicatorsFileModel UnityPanelIndicatorsIndicatorsFileModel; +typedef struct _UnityPanelIndicatorsIndicatorsFileModelClass UnityPanelIndicatorsIndicatorsFileModelClass; +#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) +typedef struct _UnityPanelIndicatorsIndicatorsFileModelPrivate UnityPanelIndicatorsIndicatorsFileModelPrivate; +#define _g_free0(var) (var = (g_free (var), NULL)) +#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL))) + +struct _UnityPanelIndicatorsIndicatorsModel { + GObject parent_instance; + UnityPanelIndicatorsIndicatorsModelPrivate * priv; +}; + +struct _UnityPanelIndicatorsIndicatorsModelClass { + GObjectClass parent_class; + GeeArrayList* (*get_indicators) (UnityPanelIndicatorsIndicatorsModel* self); + char* (*get_indicator_name) (UnityPanelIndicatorsIndicatorsModel* self, IndicatorObject* o); +}; + +struct _UnityPanelIndicatorsIndicatorsFileModel { + UnityPanelIndicatorsIndicatorsModel parent_instance; + UnityPanelIndicatorsIndicatorsFileModelPrivate * priv; + GeeHashMap* indicator_map; + GeeArrayList* indicator_list; +}; + +struct _UnityPanelIndicatorsIndicatorsFileModelClass { + UnityPanelIndicatorsIndicatorsModelClass parent_class; +}; + + +static UnityPanelIndicatorsIndicatorsModel* unity_panel_indicators_indicators_model__global_model; +static UnityPanelIndicatorsIndicatorsModel* unity_panel_indicators_indicators_model__global_model = NULL; +static gpointer unity_panel_indicators_indicators_model_parent_class = NULL; +extern GeeHashMap* unity_panel_indicators_indicators_file_model_indicator_order; +GeeHashMap* unity_panel_indicators_indicators_file_model_indicator_order = NULL; +static gpointer unity_panel_indicators_indicators_file_model_parent_class = NULL; + +GType unity_panel_indicators_indicators_model_get_type (void); +enum { + UNITY_PANEL_INDICATORS_INDICATORS_MODEL_DUMMY_PROPERTY +}; +UnityPanelIndicatorsIndicatorsFileModel* unity_panel_indicators_indicators_file_model_new (void); +UnityPanelIndicatorsIndicatorsFileModel* unity_panel_indicators_indicators_file_model_construct (GType object_type); +GType unity_panel_indicators_indicators_file_model_get_type (void); +UnityPanelIndicatorsIndicatorsModel* unity_panel_indicators_indicators_model_get_default (void); +void unity_panel_indicators_indicators_model_set_default (UnityPanelIndicatorsIndicatorsModel* model); +GeeArrayList* unity_panel_indicators_indicators_model_get_indicators (UnityPanelIndicatorsIndicatorsModel* self); +static GeeArrayList* unity_panel_indicators_indicators_model_real_get_indicators (UnityPanelIndicatorsIndicatorsModel* self); +char* unity_panel_indicators_indicators_model_get_indicator_name (UnityPanelIndicatorsIndicatorsModel* self, IndicatorObject* o); +static char* unity_panel_indicators_indicators_model_real_get_indicator_name (UnityPanelIndicatorsIndicatorsModel* self, IndicatorObject* o); +UnityPanelIndicatorsIndicatorsModel* unity_panel_indicators_indicators_model_construct (GType object_type); +static void unity_panel_indicators_indicators_model_finalize (GObject* obj); +enum { + UNITY_PANEL_INDICATORS_INDICATORS_FILE_MODEL_DUMMY_PROPERTY +}; +gint unity_panel_indicators_indicators_file_model_indicator_sort_func (const char* a, const char* b); +static void unity_panel_indicators_indicators_file_model_load_indicator (UnityPanelIndicatorsIndicatorsFileModel* self, const char* filename, const char* leaf); +static GeeArrayList* unity_panel_indicators_indicators_file_model_real_get_indicators (UnityPanelIndicatorsIndicatorsModel* base); +static char* unity_panel_indicators_indicators_file_model_real_get_indicator_name (UnityPanelIndicatorsIndicatorsModel* base, IndicatorObject* o); +static void unity_panel_indicators_indicators_file_model_finalize (GObject* obj); +static int _vala_strcmp0 (const char * str1, const char * str2); + + + +static gpointer _g_object_ref0 (gpointer self) { + return self ? g_object_ref (self) : NULL; +} + + +UnityPanelIndicatorsIndicatorsModel* unity_panel_indicators_indicators_model_get_default (void) { + UnityPanelIndicatorsIndicatorsModel* result = NULL; + if (unity_panel_indicators_indicators_model__global_model == NULL) { + UnityPanelIndicatorsIndicatorsModel* _tmp0_; + unity_panel_indicators_indicators_model__global_model = (_tmp0_ = (UnityPanelIndicatorsIndicatorsModel*) unity_panel_indicators_indicators_file_model_new (), _g_object_unref0 (unity_panel_indicators_indicators_model__global_model), _tmp0_); + } + result = _g_object_ref0 (unity_panel_indicators_indicators_model__global_model); + return result; +} + + +void unity_panel_indicators_indicators_model_set_default (UnityPanelIndicatorsIndicatorsModel* model) { + UnityPanelIndicatorsIndicatorsModel* _tmp0_; + g_return_if_fail (model != NULL); + unity_panel_indicators_indicators_model__global_model = (_tmp0_ = _g_object_ref0 (model), _g_object_unref0 (unity_panel_indicators_indicators_model__global_model), _tmp0_); +} + + +static GeeArrayList* unity_panel_indicators_indicators_model_real_get_indicators (UnityPanelIndicatorsIndicatorsModel* self) { + g_return_val_if_fail (self != NULL, NULL); + g_critical ("Type `%s' does not implement abstract method `unity_panel_indicators_indicators_model_get_indicators'", g_type_name (G_TYPE_FROM_INSTANCE (self))); + return NULL; +} + + +GeeArrayList* unity_panel_indicators_indicators_model_get_indicators (UnityPanelIndicatorsIndicatorsModel* self) { + return UNITY_PANEL_INDICATORS_INDICATORS_MODEL_GET_CLASS (self)->get_indicators (self); +} + + +static char* unity_panel_indicators_indicators_model_real_get_indicator_name (UnityPanelIndicatorsIndicatorsModel* self, IndicatorObject* o) { + g_return_val_if_fail (self != NULL, NULL); + g_critical ("Type `%s' does not implement abstract method `unity_panel_indicators_indicators_model_get_indicator_name'", g_type_name (G_TYPE_FROM_INSTANCE (self))); + return NULL; +} + + +char* unity_panel_indicators_indicators_model_get_indicator_name (UnityPanelIndicatorsIndicatorsModel* self, IndicatorObject* o) { + return UNITY_PANEL_INDICATORS_INDICATORS_MODEL_GET_CLASS (self)->get_indicator_name (self, o); +} + + +UnityPanelIndicatorsIndicatorsModel* unity_panel_indicators_indicators_model_construct (GType object_type) { + UnityPanelIndicatorsIndicatorsModel * self; + self = (UnityPanelIndicatorsIndicatorsModel*) g_object_new (object_type, NULL); + return self; +} + + +static void unity_panel_indicators_indicators_model_class_init (UnityPanelIndicatorsIndicatorsModelClass * klass) { + unity_panel_indicators_indicators_model_parent_class = g_type_class_peek_parent (klass); + UNITY_PANEL_INDICATORS_INDICATORS_MODEL_CLASS (klass)->get_indicators = unity_panel_indicators_indicators_model_real_get_indicators; + UNITY_PANEL_INDICATORS_INDICATORS_MODEL_CLASS (klass)->get_indicator_name = unity_panel_indicators_indicators_model_real_get_indicator_name; + G_OBJECT_CLASS (klass)->finalize = unity_panel_indicators_indicators_model_finalize; +} + + +static void unity_panel_indicators_indicators_model_instance_init (UnityPanelIndicatorsIndicatorsModel * self) { +} + + +static void unity_panel_indicators_indicators_model_finalize (GObject* obj) { + UnityPanelIndicatorsIndicatorsModel * self; + self = UNITY_PANEL_INDICATORS_INDICATORS_MODEL (obj); + G_OBJECT_CLASS (unity_panel_indicators_indicators_model_parent_class)->finalize (obj); +} + + +GType unity_panel_indicators_indicators_model_get_type (void) { + static volatile gsize unity_panel_indicators_indicators_model_type_id__volatile = 0; + if (g_once_init_enter (&unity_panel_indicators_indicators_model_type_id__volatile)) { + static const GTypeInfo g_define_type_info = { sizeof (UnityPanelIndicatorsIndicatorsModelClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) unity_panel_indicators_indicators_model_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UnityPanelIndicatorsIndicatorsModel), 0, (GInstanceInitFunc) unity_panel_indicators_indicators_model_instance_init, NULL }; + GType unity_panel_indicators_indicators_model_type_id; + unity_panel_indicators_indicators_model_type_id = g_type_register_static (G_TYPE_OBJECT, "UnityPanelIndicatorsIndicatorsModel", &g_define_type_info, G_TYPE_FLAG_ABSTRACT); + g_once_init_leave (&unity_panel_indicators_indicators_model_type_id__volatile, unity_panel_indicators_indicators_model_type_id); + } + return unity_panel_indicators_indicators_model_type_id__volatile; +} + + +static gboolean string_contains (const char* self, const char* needle) { + gboolean result = FALSE; + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (needle != NULL, FALSE); + result = strstr (self, needle) != NULL; + return result; +} + + +static char* string_slice (const char* self, glong start, glong end) { + char* result = NULL; + glong string_length; + gboolean _tmp0_ = FALSE; + gboolean _tmp1_ = FALSE; + const char* start_string; + g_return_val_if_fail (self != NULL, NULL); + string_length = g_utf8_strlen (self, -1); + if (start < 0) { + start = string_length + start; + } + if (end < 0) { + end = string_length + end; + } + if (start >= 0) { + _tmp0_ = start <= string_length; + } else { + _tmp0_ = FALSE; + } + g_return_val_if_fail (_tmp0_, NULL); + if (end >= 0) { + _tmp1_ = end <= string_length; + } else { + _tmp1_ = FALSE; + } + g_return_val_if_fail (_tmp1_, NULL); + g_return_val_if_fail (start <= end, NULL); + start_string = g_utf8_offset_to_pointer (self, start); + result = g_strndup (start_string, ((gchar*) g_utf8_offset_to_pointer (start_string, end - start)) - ((gchar*) start_string)); + return result; +} + + +UnityPanelIndicatorsIndicatorsFileModel* unity_panel_indicators_indicators_file_model_construct (GType object_type) { + GError * _inner_error_; + UnityPanelIndicatorsIndicatorsFileModel * self; + char* skip_list; + GeeHashMap* _tmp0_; + GeeHashMap* _tmp1_; + GeeArrayList* _tmp2_; + char* _tmp3_; + GFile* dir; + _inner_error_ = NULL; + self = (UnityPanelIndicatorsIndicatorsFileModel*) unity_panel_indicators_indicators_model_construct (object_type); + START_FUNCTION (); + skip_list = NULL; + self->indicator_map = (_tmp0_ = gee_hash_map_new (INDICATOR_TYPE_OBJECT, (GBoxedCopyFunc) g_object_ref, g_object_unref, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL), _g_object_unref0 (self->indicator_map), _tmp0_); + unity_panel_indicators_indicators_file_model_indicator_order = (_tmp1_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, G_TYPE_INT, NULL, NULL, NULL, NULL, NULL), _g_object_unref0 (unity_panel_indicators_indicators_file_model_indicator_order), _tmp1_); + self->indicator_list = (_tmp2_ = gee_array_list_new (INDICATOR_TYPE_OBJECT, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL), _g_object_unref0 (self->indicator_list), _tmp2_); + gee_abstract_map_set ((GeeAbstractMap*) unity_panel_indicators_indicators_file_model_indicator_order, "libappmenu.so", GINT_TO_POINTER (1)); + gee_abstract_map_set ((GeeAbstractMap*) unity_panel_indicators_indicators_file_model_indicator_order, "libapplication.so", GINT_TO_POINTER (2)); + gee_abstract_map_set ((GeeAbstractMap*) unity_panel_indicators_indicators_file_model_indicator_order, "libsoundmenu.so", GINT_TO_POINTER (3)); + gee_abstract_map_set ((GeeAbstractMap*) unity_panel_indicators_indicators_file_model_indicator_order, "libmessaging.so", GINT_TO_POINTER (4)); + gee_abstract_map_set ((GeeAbstractMap*) unity_panel_indicators_indicators_file_model_indicator_order, "libdatetime.so", GINT_TO_POINTER (5)); + gee_abstract_map_set ((GeeAbstractMap*) unity_panel_indicators_indicators_file_model_indicator_order, "libme.so", GINT_TO_POINTER (6)); + gee_abstract_map_set ((GeeAbstractMap*) unity_panel_indicators_indicators_file_model_indicator_order, "libsession.so", GINT_TO_POINTER (7)); + skip_list = (_tmp3_ = g_strdup (g_getenv ("UNITY_PANEL_INDICATORS_SKIP")), _g_free0 (skip_list), _tmp3_); + if (skip_list == NULL) { + char* _tmp4_; + skip_list = (_tmp4_ = g_strdup (""), _g_free0 (skip_list), _tmp4_); + } + if (_vala_strcmp0 (skip_list, "all") == 0) { + g_message ("panel-indicator-model.vala:88: Skipping all indicator loading"); + _g_free0 (skip_list); + return self; + } + gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), INDICATORICONSDIR); + dir = g_file_new_for_path (INDICATORDIR); + { + GFileEnumerator* e; + GeeArrayList* sos; + GFileInfo* file_info; + e = g_file_enumerate_children (dir, G_FILE_ATTRIBUTE_STANDARD_NAME, 0, NULL, &_inner_error_); + if (_inner_error_ != NULL) { + goto __catch3_g_error; + } + sos = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL); + file_info = NULL; + while (TRUE) { + GFileInfo* _tmp5_; + GFileInfo* _tmp6_; + char* leaf; + char* _tmp7_; + gboolean _tmp8_; + _tmp5_ = g_file_enumerator_next_file (e, NULL, &_inner_error_); + if (_inner_error_ != NULL) { + _g_object_unref0 (e); + _g_object_unref0 (sos); + _g_object_unref0 (file_info); + goto __catch3_g_error; + } + if (!((file_info = (_tmp6_ = _tmp5_, _g_object_unref0 (file_info), _tmp6_)) != NULL)) { + break; + } + leaf = g_strdup (g_file_info_get_name (file_info)); + if (string_contains (skip_list, leaf)) { + _g_free0 (leaf); + continue; + } + if ((_tmp8_ = _vala_strcmp0 (_tmp7_ = string_slice (leaf, g_utf8_strlen (leaf, -1) - 3, g_utf8_strlen (leaf, -1)), ".so") == 0, _g_free0 (_tmp7_), _tmp8_)) { + gee_abstract_collection_add ((GeeAbstractCollection*) sos, leaf); + } + _g_free0 (leaf); + } + gee_list_sort ((GeeList*) sos, (GCompareFunc) unity_panel_indicators_indicators_file_model_indicator_sort_func); + { + GeeIterator* _leaf_it; + _leaf_it = gee_abstract_collection_iterator ((GeeAbstractCollection*) sos); + while (TRUE) { + char* leaf; + char* _tmp9_; + if (!gee_iterator_next (_leaf_it)) { + break; + } + leaf = (char*) gee_iterator_get (_leaf_it); + unity_panel_indicators_indicators_file_model_load_indicator (self, _tmp9_ = g_strconcat (INDICATORDIR, leaf, NULL), leaf); + _g_free0 (_tmp9_); + _g_free0 (leaf); + } + _g_object_unref0 (_leaf_it); + } + _g_object_unref0 (e); + _g_object_unref0 (sos); + _g_object_unref0 (file_info); + } + goto __finally3; + __catch3_g_error: + { + GError * _error_; + _error_ = _inner_error_; + _inner_error_ = NULL; + { + g_print ("Unable to read indicators: %s\n", _error_->message); + _g_error_free0 (_error_); + } + } + __finally3: + if (_inner_error_ != NULL) { + _g_free0 (skip_list); + _g_object_unref0 (dir); + g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); + g_clear_error (&_inner_error_); + return NULL; + } + END_FUNCTION (); + _g_free0 (skip_list); + _g_object_unref0 (dir); + return self; +} + + +UnityPanelIndicatorsIndicatorsFileModel* unity_panel_indicators_indicators_file_model_new (void) { + return unity_panel_indicators_indicators_file_model_construct (UNITY_PANEL_INDICATORS_TYPE_INDICATORS_FILE_MODEL); +} + + +gint unity_panel_indicators_indicators_file_model_indicator_sort_func (const char* a, const char* b) { + gint result = 0; + g_return_val_if_fail (a != NULL, 0); + g_return_val_if_fail (b != NULL, 0); + result = GPOINTER_TO_INT (gee_abstract_map_get ((GeeAbstractMap*) unity_panel_indicators_indicators_file_model_indicator_order, a)) - GPOINTER_TO_INT (gee_abstract_map_get ((GeeAbstractMap*) unity_panel_indicators_indicators_file_model_indicator_order, b)); + return result; +} + + +static void unity_panel_indicators_indicators_file_model_load_indicator (UnityPanelIndicatorsIndicatorsFileModel* self, const char* filename, const char* leaf) { + IndicatorObject* o; + IndicatorObject* _tmp0_; + g_return_if_fail (self != NULL); + g_return_if_fail (filename != NULL); + g_return_if_fail (leaf != NULL); + o = NULL; + o = (_tmp0_ = indicator_object_new_from_file (filename), _g_object_unref0 (o), _tmp0_); + if (INDICATOR_IS_OBJECT (o)) { + gee_abstract_map_set ((GeeAbstractMap*) self->indicator_map, o, leaf); + gee_abstract_collection_add ((GeeAbstractCollection*) self->indicator_list, o); + } else { + g_warning ("panel-indicator-model.vala:149: Unable to load %s\n", filename); + } + _g_object_unref0 (o); +} + + +static GeeArrayList* unity_panel_indicators_indicators_file_model_real_get_indicators (UnityPanelIndicatorsIndicatorsModel* base) { + UnityPanelIndicatorsIndicatorsFileModel * self; + GeeArrayList* result = NULL; + self = (UnityPanelIndicatorsIndicatorsFileModel*) base; + result = _g_object_ref0 (self->indicator_list); + return result; +} + + +static char* unity_panel_indicators_indicators_file_model_real_get_indicator_name (UnityPanelIndicatorsIndicatorsModel* base, IndicatorObject* o) { + UnityPanelIndicatorsIndicatorsFileModel * self; + char* result = NULL; + self = (UnityPanelIndicatorsIndicatorsFileModel*) base; + g_return_val_if_fail (o != NULL, NULL); + result = (char*) gee_abstract_map_get ((GeeAbstractMap*) self->indicator_map, o); + return result; +} + + +static void unity_panel_indicators_indicators_file_model_class_init (UnityPanelIndicatorsIndicatorsFileModelClass * klass) { + unity_panel_indicators_indicators_file_model_parent_class = g_type_class_peek_parent (klass); + UNITY_PANEL_INDICATORS_INDICATORS_MODEL_CLASS (klass)->get_indicators = unity_panel_indicators_indicators_file_model_real_get_indicators; + UNITY_PANEL_INDICATORS_INDICATORS_MODEL_CLASS (klass)->get_indicator_name = unity_panel_indicators_indicators_file_model_real_get_indicator_name; + G_OBJECT_CLASS (klass)->finalize = unity_panel_indicators_indicators_file_model_finalize; +} + + +static void unity_panel_indicators_indicators_file_model_instance_init (UnityPanelIndicatorsIndicatorsFileModel * self) { +} + + +static void unity_panel_indicators_indicators_file_model_finalize (GObject* obj) { + UnityPanelIndicatorsIndicatorsFileModel * self; + self = UNITY_PANEL_INDICATORS_INDICATORS_FILE_MODEL (obj); + _g_object_unref0 (self->indicator_map); + _g_object_unref0 (self->indicator_list); + G_OBJECT_CLASS (unity_panel_indicators_indicators_file_model_parent_class)->finalize (obj); +} + + +GType unity_panel_indicators_indicators_file_model_get_type (void) { + static volatile gsize unity_panel_indicators_indicators_file_model_type_id__volatile = 0; + if (g_once_init_enter (&unity_panel_indicators_indicators_file_model_type_id__volatile)) { + static const GTypeInfo g_define_type_info = { sizeof (UnityPanelIndicatorsIndicatorsFileModelClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) unity_panel_indicators_indicators_file_model_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UnityPanelIndicatorsIndicatorsFileModel), 0, (GInstanceInitFunc) unity_panel_indicators_indicators_file_model_instance_init, NULL }; + GType unity_panel_indicators_indicators_file_model_type_id; + unity_panel_indicators_indicators_file_model_type_id = g_type_register_static (UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL, "UnityPanelIndicatorsIndicatorsFileModel", &g_define_type_info, 0); + g_once_init_leave (&unity_panel_indicators_indicators_file_model_type_id__volatile, unity_panel_indicators_indicators_file_model_type_id); + } + return unity_panel_indicators_indicators_file_model_type_id__volatile; +} + + +static int _vala_strcmp0 (const char * str1, const char * str2) { + if (str1 == NULL) { + return -(str1 != str2); + } + if (str2 == NULL) { + return str1 != str2; + } + return strcmp (str1, str2); +} + + + + diff --git a/unity-private/panel/panel-indicator-model.vala b/unity-private/panel/panel-indicator-model.vala new file mode 100644 index 000000000..665f7adcf --- /dev/null +++ b/unity-private/panel/panel-indicator-model.vala @@ -0,0 +1,164 @@ +/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */ +/* + * Copyright (C) 2010 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by canonical.com + * + */ + +using Gee; +using Utils; + +namespace Unity.Panel.Indicators +{ + public abstract class IndicatorsModel : Object + { + private static IndicatorsModel _global_model = null; + + public static IndicatorsModel get_default () + { + if (_global_model == null) + { + _global_model = new IndicatorsFileModel (); + } + + return _global_model; + } + + /* This is only for testing mode, so we can inject a test model before the + * program runs + */ + public static void set_default (IndicatorsModel model) + { + _global_model = model; + } + + /* The only method we really need */ + public abstract Gee.ArrayList<Indicator.Object> get_indicators (); + public abstract string get_indicator_name (Indicator.Object o); + } + + public class IndicatorsFileModel : IndicatorsModel + { + public static HashMap<string, int> indicator_order = null; + public HashMap<Indicator.Object, string> indicator_map; + public ArrayList<Indicator.Object> indicator_list; + + public IndicatorsFileModel () + { + START_FUNCTION (); + + string skip_list; + + indicator_map = new Gee.HashMap<Indicator.Object, string> (); + indicator_order = new Gee.HashMap<string, int> (); + indicator_list = new Gee.ArrayList<Indicator.Object> (); + + /* Static order of indicators. We always want the session indicators + * to be on the far right end of the panel. That is why it the session + * indicator is the last one set in indicator_order. + */ + indicator_order.set ("libappmenu.so", 1); + indicator_order.set ("libapplication.so", 2); + indicator_order.set ("libsoundmenu.so", 3); + indicator_order.set ("libmessaging.so", 4); + indicator_order.set ("libdatetime.so", 5); + indicator_order.set ("libme.so", 6); + indicator_order.set ("libsession.so", 7); + + /* Indicators we don't want to load */ + skip_list = Environment.get_variable ("UNITY_PANEL_INDICATORS_SKIP"); + if (skip_list == null) + skip_list = ""; + + if (skip_list == "all") + { + message ("Skipping all indicator loading"); + return; + } + + /* We need to look for icons in an specific location */ + Gtk.IconTheme.get_default ().append_search_path (INDICATORICONSDIR); + + /* Start loading 'em in. .so are located in INDICATORDIR*/ + var dir = File.new_for_path (INDICATORDIR); + try + { + var e = dir.enumerate_children (FILE_ATTRIBUTE_STANDARD_NAME, 0,null); + + ArrayList<string> sos = new ArrayList<string> (); + + FileInfo file_info; + while ((file_info = e.next_file (null)) != null) + { + string leaf = file_info.get_name (); + + if (leaf in skip_list) + continue; + + if (leaf[leaf.len()-3:leaf.len()] == ".so") + { + sos.add (leaf); + } + } + + /* Order the so's before we load them */ + sos.sort ((CompareFunc)indicator_sort_func); + + foreach (string leaf in sos) + this.load_indicator (INDICATORDIR + leaf, leaf); + } + catch (Error error) + { + print ("Unable to read indicators: %s\n", error.message); + } + + END_FUNCTION (); + } + + public static int indicator_sort_func (string a, string b) + { + return indicator_order[a] - indicator_order[b]; + } + + private void load_indicator (string filename, string leaf) + { + Indicator.Object o; + + o = new Indicator.Object.from_file (filename); + + if (o is Indicator.Object) + { + this.indicator_map[o] = leaf; + indicator_list.add (o); + } + else + { + warning ("Unable to load %s\n", filename); + } + } + + public override ArrayList<Indicator.Object> get_indicators () + { + return indicator_list; + } + + public override string get_indicator_name (Indicator.Object o) + { + return indicator_map[o]; + } + } +} + diff --git a/unity-private/panel/panel-indicator-object-entry-view.c b/unity-private/panel/panel-indicator-object-entry-view.c new file mode 100644 index 000000000..9900ca078 --- /dev/null +++ b/unity-private/panel/panel-indicator-object-entry-view.c @@ -0,0 +1,656 @@ +/* panel-indicator-object-entry-view.c generated by valac, the Vala compiler + * generated from panel-indicator-object-entry-view.vala, do not modify */ + +/* + * Copyright (C) 2010 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> + * Jay Taoko <jay.taoko@canonical.com> + */ + +#include <glib.h> +#include <glib-object.h> +#include <clutk/clutk.h> +#include <gtk/gtk.h> +#include <libindicator/indicator.h> +#include <libindicator/indicator-object.h> +#include <libindicator/indicator-service.h> +#include <libindicator/indicator-service-manager.h> +#include <clutter/clutter.h> +#include <float.h> +#include <math.h> +#include <cairo.h> +#include <gdk-pixbuf/gdk-pixdata.h> + + +#define UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_ENTRY_VIEW (unity_panel_indicators_indicator_object_entry_view_get_type ()) +#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_ENTRY_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_ENTRY_VIEW, UnityPanelIndicatorsIndicatorObjectEntryView)) +#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_ENTRY_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_ENTRY_VIEW, UnityPanelIndicatorsIndicatorObjectEntryViewClass)) +#define UNITY_PANEL_INDICATORS_IS_INDICATOR_OBJECT_ENTRY_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_ENTRY_VIEW)) +#define UNITY_PANEL_INDICATORS_IS_INDICATOR_OBJECT_ENTRY_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_ENTRY_VIEW)) +#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_ENTRY_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_ENTRY_VIEW, UnityPanelIndicatorsIndicatorObjectEntryViewClass)) + +typedef struct _UnityPanelIndicatorsIndicatorObjectEntryView UnityPanelIndicatorsIndicatorObjectEntryView; +typedef struct _UnityPanelIndicatorsIndicatorObjectEntryViewClass UnityPanelIndicatorsIndicatorObjectEntryViewClass; +typedef struct _UnityPanelIndicatorsIndicatorObjectEntryViewPrivate UnityPanelIndicatorsIndicatorObjectEntryViewPrivate; +#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) + +#define TYPE_MENU_MANAGER (menu_manager_get_type ()) +#define MENU_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MENU_MANAGER, MenuManager)) +#define MENU_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MENU_MANAGER, MenuManagerClass)) +#define IS_MENU_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MENU_MANAGER)) +#define IS_MENU_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MENU_MANAGER)) +#define MENU_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MENU_MANAGER, MenuManagerClass)) + +typedef struct _MenuManager MenuManager; +typedef struct _MenuManagerClass MenuManagerClass; + +#define UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW (unity_panel_indicators_indicator_object_view_get_type ()) +#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW, UnityPanelIndicatorsIndicatorObjectView)) +#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW, UnityPanelIndicatorsIndicatorObjectViewClass)) +#define UNITY_PANEL_INDICATORS_IS_INDICATOR_OBJECT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW)) +#define UNITY_PANEL_INDICATORS_IS_INDICATOR_OBJECT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW)) +#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW, UnityPanelIndicatorsIndicatorObjectViewClass)) + +typedef struct _UnityPanelIndicatorsIndicatorObjectView UnityPanelIndicatorsIndicatorObjectView; +typedef struct _UnityPanelIndicatorsIndicatorObjectViewClass UnityPanelIndicatorsIndicatorObjectViewClass; +#define _cairo_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_destroy (var), NULL))) +#define _cairo_pattern_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_pattern_destroy (var), NULL))) +#define _g_free0(var) (var = (g_free (var), NULL)) + +struct _UnityPanelIndicatorsIndicatorObjectEntryView { + CtkBox parent_instance; + UnityPanelIndicatorsIndicatorObjectEntryViewPrivate * priv; + CtkImage* image; + CtkText* text; +}; + +struct _UnityPanelIndicatorsIndicatorObjectEntryViewClass { + CtkBoxClass parent_class; +}; + +struct _UnityPanelIndicatorsIndicatorObjectEntryViewPrivate { + IndicatorObjectEntry* _entry; + ClutterCairoTexture* bg; + gboolean menu_is_open; + guint32 click_time; + float last_found_entry_x; + float last_width; + float last_height; +}; + + +static gpointer unity_panel_indicators_indicator_object_entry_view_parent_class = NULL; + +GType unity_panel_indicators_indicator_object_entry_view_get_type (void); +#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_ENTRY_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_ENTRY_VIEW, UnityPanelIndicatorsIndicatorObjectEntryViewPrivate)) +enum { + UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_ENTRY_VIEW_DUMMY_PROPERTY, + UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_ENTRY_VIEW_ENTRY +}; +UnityPanelIndicatorsIndicatorObjectEntryView* unity_panel_indicators_indicator_object_entry_view_new (IndicatorObjectEntry* _entry); +UnityPanelIndicatorsIndicatorObjectEntryView* unity_panel_indicators_indicator_object_entry_view_construct (GType object_type, IndicatorObjectEntry* _entry); +static void unity_panel_indicators_indicator_object_entry_view_position_menu (UnityPanelIndicatorsIndicatorObjectEntryView* self, GtkMenu* menu, gint* x, gint* y, gboolean* push_in); +IndicatorObjectEntry* unity_panel_indicators_indicator_object_entry_view_get_entry (UnityPanelIndicatorsIndicatorObjectEntryView* self); +GType menu_manager_get_type (void); +MenuManager* menu_manager_get_default (void); +void menu_manager_register_visible_menu (MenuManager* self, GtkMenu* menu); +static void _unity_panel_indicators_indicator_object_entry_view_position_menu_gtk_menu_position_func (GtkMenu* menu, gint* x, gint* y, gboolean* push_in, gpointer self); +void unity_panel_indicators_indicator_object_entry_view_menu_shown (UnityPanelIndicatorsIndicatorObjectEntryView* self); +void unity_panel_indicators_indicator_object_entry_view_show_menu (UnityPanelIndicatorsIndicatorObjectEntryView* self); +GType unity_panel_indicators_indicator_object_view_get_type (void); +IndicatorObject* unity_panel_indicators_indicator_object_view_get_indicator_object (UnityPanelIndicatorsIndicatorObjectView* self); +static gboolean unity_panel_indicators_indicator_object_entry_view_on_scroll_event (UnityPanelIndicatorsIndicatorObjectEntryView* self, ClutterEvent* e); +gboolean unity_panel_indicators_indicator_object_entry_view_on_button_press_event (UnityPanelIndicatorsIndicatorObjectEntryView* self, ClutterEvent* e); +gboolean menu_manager_menu_is_open (MenuManager* self); +gboolean unity_panel_indicators_indicator_object_entry_view_on_motion_event (UnityPanelIndicatorsIndicatorObjectEntryView* self, ClutterEvent* e); +void unity_panel_indicators_indicator_object_entry_view_menu_key_moved (UnityPanelIndicatorsIndicatorObjectEntryView* self, GtkMenuDirectionType type); +static void _unity_panel_indicators_indicator_object_entry_view_menu_key_moved_gtk_menu_shell_move_current (GtkMenuShell* _sender, GtkMenuDirectionType direction, gpointer self); +void unity_panel_indicators_indicator_object_entry_view_menu_vis_changed (UnityPanelIndicatorsIndicatorObjectEntryView* self); +static void _unity_panel_indicators_indicator_object_entry_view_menu_vis_changed_g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self); +static gboolean unity_panel_indicators_indicator_object_entry_view_update_bg (UnityPanelIndicatorsIndicatorObjectEntryView* self); +static gboolean _unity_panel_indicators_indicator_object_entry_view_update_bg_gsource_func (gpointer self); +static void unity_panel_indicators_indicator_object_entry_view_real_allocate (ClutterActor* base, const ClutterActorBox* box, ClutterAllocationFlags flags); +static void unity_panel_indicators_indicator_object_entry_view_real_paint (ClutterActor* base); +static void unity_panel_indicators_indicator_object_entry_view_real_map (ClutterActor* base); +static void unity_panel_indicators_indicator_object_entry_view_real_unmap (ClutterActor* base); +static void unity_panel_indicators_indicator_object_entry_view_set_entry (UnityPanelIndicatorsIndicatorObjectEntryView* self, IndicatorObjectEntry* value); +static gboolean _unity_panel_indicators_indicator_object_entry_view_on_button_press_event_clutter_actor_button_press_event (ClutterActor* _sender, ClutterEvent* event, gpointer self); +static gboolean _unity_panel_indicators_indicator_object_entry_view_on_motion_event_clutter_actor_motion_event (ClutterActor* _sender, ClutterEvent* event, gpointer self); +static gboolean _unity_panel_indicators_indicator_object_entry_view_on_scroll_event_clutter_actor_scroll_event (ClutterActor* _sender, ClutterEvent* event, gpointer self); +static void _lambda0_ (UnityPanelIndicatorsIndicatorObjectEntryView* self); +static void __lambda0__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self); +static void _lambda1_ (UnityPanelIndicatorsIndicatorObjectEntryView* self); +static void __lambda1__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self); +static void _lambda2_ (UnityPanelIndicatorsIndicatorObjectEntryView* self); +static void __lambda2__gtk_icon_theme_changed (GtkIconTheme* _sender, gpointer self); +static void _lambda3_ (UnityPanelIndicatorsIndicatorObjectEntryView* self); +static void __lambda3__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self); +static GObject * unity_panel_indicators_indicator_object_entry_view_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties); +static void unity_panel_indicators_indicator_object_entry_view_finalize (GObject* obj); +static void unity_panel_indicators_indicator_object_entry_view_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); +static void unity_panel_indicators_indicator_object_entry_view_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec); + + + +UnityPanelIndicatorsIndicatorObjectEntryView* unity_panel_indicators_indicator_object_entry_view_construct (GType object_type, IndicatorObjectEntry* _entry) { + UnityPanelIndicatorsIndicatorObjectEntryView * self; + g_return_val_if_fail (_entry != NULL, NULL); + self = (UnityPanelIndicatorsIndicatorObjectEntryView*) g_object_new (object_type, "entry", _entry, "orientation", CTK_ORIENTATION_HORIZONTAL, "spacing", 3, "homogeneous", FALSE, "reactive", TRUE, NULL); + return self; +} + + +UnityPanelIndicatorsIndicatorObjectEntryView* unity_panel_indicators_indicator_object_entry_view_new (IndicatorObjectEntry* _entry) { + return unity_panel_indicators_indicator_object_entry_view_construct (UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_ENTRY_VIEW, _entry); +} + + +static void unity_panel_indicators_indicator_object_entry_view_position_menu (UnityPanelIndicatorsIndicatorObjectEntryView* self, GtkMenu* menu, gint* x, gint* y, gboolean* push_in) { + g_return_if_fail (self != NULL); + g_return_if_fail (menu != NULL); + *y = (gint) clutter_actor_get_height ((ClutterActor*) self); + *x = (gint) self->priv->last_found_entry_x; +} + + +static void _unity_panel_indicators_indicator_object_entry_view_position_menu_gtk_menu_position_func (GtkMenu* menu, gint* x, gint* y, gboolean* push_in, gpointer self) { + unity_panel_indicators_indicator_object_entry_view_position_menu (self, menu, x, y, push_in); +} + + +void unity_panel_indicators_indicator_object_entry_view_show_menu (UnityPanelIndicatorsIndicatorObjectEntryView* self) { + g_return_if_fail (self != NULL); + if (GTK_IS_MENU (self->priv->_entry->menu)) { + MenuManager* _tmp0_; + self->priv->last_found_entry_x = (clutter_actor_get_x ((ClutterActor*) self) + clutter_actor_get_x (clutter_actor_get_parent ((ClutterActor*) self))) + clutter_actor_get_x (clutter_actor_get_parent (clutter_actor_get_parent ((ClutterActor*) self))); + menu_manager_register_visible_menu (_tmp0_ = menu_manager_get_default (), self->priv->_entry->menu); + _g_object_unref0 (_tmp0_); + gtk_menu_popup (self->priv->_entry->menu, NULL, NULL, _unity_panel_indicators_indicator_object_entry_view_position_menu_gtk_menu_position_func, self, (guint) 1, clutter_get_current_event_time ()); + self->priv->click_time = clutter_get_current_event_time (); + unity_panel_indicators_indicator_object_entry_view_menu_shown (self); + } +} + + +static gpointer _g_object_ref0 (gpointer self) { + return self ? g_object_ref (self) : NULL; +} + + +static gboolean unity_panel_indicators_indicator_object_entry_view_on_scroll_event (UnityPanelIndicatorsIndicatorObjectEntryView* self, ClutterEvent* e) { + gboolean result = FALSE; + ClutterScrollEvent event; + ClutterActor* _tmp0_; + UnityPanelIndicatorsIndicatorObjectView* parent; + IndicatorObject* object; + g_return_val_if_fail (self != NULL, FALSE); + event = (*e).scroll; + parent = _g_object_ref0 ((_tmp0_ = clutter_actor_get_parent ((ClutterActor*) self), UNITY_PANEL_INDICATORS_IS_INDICATOR_OBJECT_VIEW (_tmp0_) ? ((UnityPanelIndicatorsIndicatorObjectView*) _tmp0_) : NULL)); + object = unity_panel_indicators_indicator_object_view_get_indicator_object (parent); + g_signal_emit_by_name (object, "scroll", 1, event.direction, NULL); + result = TRUE; + _g_object_unref0 (parent); + return result; +} + + +gboolean unity_panel_indicators_indicator_object_entry_view_on_button_press_event (UnityPanelIndicatorsIndicatorObjectEntryView* self, ClutterEvent* e) { + gboolean result = FALSE; + g_return_val_if_fail (self != NULL, FALSE); + if (GTK_IS_MENU (self->priv->_entry->menu)) { + if (self->priv->menu_is_open) { + gtk_menu_popdown (self->priv->_entry->menu); + self->priv->menu_is_open = FALSE; + result = TRUE; + return result; + } else { + MenuManager* _tmp0_; + self->priv->last_found_entry_x = (clutter_actor_get_x ((ClutterActor*) self) + clutter_actor_get_x (clutter_actor_get_parent ((ClutterActor*) self))) + clutter_actor_get_x (clutter_actor_get_parent (clutter_actor_get_parent ((ClutterActor*) self))); + menu_manager_register_visible_menu (_tmp0_ = menu_manager_get_default (), self->priv->_entry->menu); + _g_object_unref0 (_tmp0_); + gtk_menu_popup (self->priv->_entry->menu, NULL, NULL, _unity_panel_indicators_indicator_object_entry_view_position_menu_gtk_menu_position_func, self, (guint) (*e).button.button, (*e).button.time); + self->priv->click_time = clutter_get_current_event_time (); + self->priv->menu_is_open = TRUE; + unity_panel_indicators_indicator_object_entry_view_menu_shown (self); + } + } + result = TRUE; + return result; +} + + +gboolean unity_panel_indicators_indicator_object_entry_view_on_motion_event (UnityPanelIndicatorsIndicatorObjectEntryView* self, ClutterEvent* e) { + gboolean result = FALSE; + gboolean _tmp0_ = FALSE; + g_return_val_if_fail (self != NULL, FALSE); + if (GTK_IS_MENU (self->priv->_entry->menu)) { + MenuManager* _tmp1_; + _tmp0_ = menu_manager_menu_is_open (_tmp1_ = menu_manager_get_default ()); + _g_object_unref0 (_tmp1_); + } else { + _tmp0_ = FALSE; + } + if (_tmp0_) { + unity_panel_indicators_indicator_object_entry_view_show_menu (self); + result = TRUE; + return result; + } + result = FALSE; + return result; +} + + +static void _unity_panel_indicators_indicator_object_entry_view_menu_key_moved_gtk_menu_shell_move_current (GtkMenuShell* _sender, GtkMenuDirectionType direction, gpointer self) { + unity_panel_indicators_indicator_object_entry_view_menu_key_moved (self, direction); +} + + +static void _unity_panel_indicators_indicator_object_entry_view_menu_vis_changed_g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) { + unity_panel_indicators_indicator_object_entry_view_menu_vis_changed (self); +} + + +void unity_panel_indicators_indicator_object_entry_view_menu_shown (UnityPanelIndicatorsIndicatorObjectEntryView* self) { + g_return_if_fail (self != NULL); + if (GTK_IS_MENU (self->priv->_entry->menu)) { + g_signal_connect_object ((GtkMenuShell*) self->priv->_entry->menu, "move-current", (GCallback) _unity_panel_indicators_indicator_object_entry_view_menu_key_moved_gtk_menu_shell_move_current, self, 0); + g_signal_connect_object ((GObject*) self->priv->_entry->menu, "notify::visible", (GCallback) _unity_panel_indicators_indicator_object_entry_view_menu_vis_changed_g_object_notify, self, 0); + clutter_actor_animate ((ClutterActor*) self->priv->bg, (gulong) CLUTTER_EASE_OUT_QUAD, (guint) 200, "opacity", 255, NULL); + } +} + + +void unity_panel_indicators_indicator_object_entry_view_menu_vis_changed (UnityPanelIndicatorsIndicatorObjectEntryView* self) { + gboolean vis; + g_return_if_fail (self != NULL); + vis = (GTK_WIDGET_FLAGS ((GtkWidget*) self->priv->_entry->menu) & GTK_VISIBLE) != 0; + if (vis == FALSE) { + guint _tmp0_; + GQuark _tmp2_; + guint _tmp1_; + clutter_actor_animate ((ClutterActor*) self->priv->bg, (gulong) CLUTTER_EASE_OUT_QUAD, (guint) 200, "opacity", 0, NULL); + g_signal_parse_name ("move-current", GTK_TYPE_MENU_SHELL, &_tmp0_, NULL, FALSE); + g_signal_handlers_disconnect_matched ((GtkMenuShell*) self->priv->_entry->menu, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp0_, 0, NULL, (GCallback) _unity_panel_indicators_indicator_object_entry_view_menu_key_moved_gtk_menu_shell_move_current, self); + g_signal_parse_name ("notify::visible", G_TYPE_OBJECT, &_tmp1_, &_tmp2_, TRUE); + g_signal_handlers_disconnect_matched ((GObject*) self->priv->_entry->menu, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DETAIL | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, _tmp2_, NULL, (GCallback) _unity_panel_indicators_indicator_object_entry_view_menu_vis_changed_g_object_notify, self); + self->priv->menu_is_open = FALSE; + } +} + + +void unity_panel_indicators_indicator_object_entry_view_menu_key_moved (UnityPanelIndicatorsIndicatorObjectEntryView* self, GtkMenuDirectionType type) { + gboolean _tmp0_ = FALSE; + g_return_if_fail (self != NULL); + if (type != GTK_MENU_DIR_PARENT) { + _tmp0_ = type != GTK_MENU_DIR_CHILD; + } else { + _tmp0_ = FALSE; + } + if (_tmp0_) { + return; + } + g_signal_emit_by_name (self, "menu-moved", type); +} + + +static gboolean _unity_panel_indicators_indicator_object_entry_view_update_bg_gsource_func (gpointer self) { + gboolean result; + result = unity_panel_indicators_indicator_object_entry_view_update_bg (self); + return result; +} + + +static void unity_panel_indicators_indicator_object_entry_view_real_allocate (ClutterActor* base, const ClutterActorBox* box, ClutterAllocationFlags flags) { + UnityPanelIndicatorsIndicatorObjectEntryView * self; + float width = 0.0F; + float height = 0.0F; + ClutterActorBox _tmp0_ = {0}; + ClutterActorBox child_box; + gboolean _tmp1_ = FALSE; + self = (UnityPanelIndicatorsIndicatorObjectEntryView*) base; + CLUTTER_ACTOR_CLASS (unity_panel_indicators_indicator_object_entry_view_parent_class)->allocate ((ClutterActor*) CTK_BOX (self), box, flags); + width = floorf ((*box).x2 - (*box).x1); + height = floorf ((*box).y2 - (*box).y1); + child_box = (_tmp0_.x1 = (float) 0, _tmp0_); + child_box.x1 = (float) 0; + child_box.x2 = width; + child_box.y1 = (float) 0; + child_box.y2 = height; + if (width != self->priv->last_width) { + _tmp1_ = TRUE; + } else { + _tmp1_ = height != self->priv->last_height; + } + if (_tmp1_) { + self->priv->last_width = width; + self->priv->last_height = height; + g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, _unity_panel_indicators_indicator_object_entry_view_update_bg_gsource_func, g_object_ref (self), g_object_unref); + } + clutter_actor_allocate ((ClutterActor*) self->priv->bg, &child_box, flags); +} + + +static void unity_panel_indicators_indicator_object_entry_view_real_paint (ClutterActor* base) { + UnityPanelIndicatorsIndicatorObjectEntryView * self; + self = (UnityPanelIndicatorsIndicatorObjectEntryView*) base; + clutter_actor_paint ((ClutterActor*) self->priv->bg); + CLUTTER_ACTOR_CLASS (unity_panel_indicators_indicator_object_entry_view_parent_class)->paint ((ClutterActor*) CTK_BOX (self)); +} + + +static void unity_panel_indicators_indicator_object_entry_view_real_map (ClutterActor* base) { + UnityPanelIndicatorsIndicatorObjectEntryView * self; + self = (UnityPanelIndicatorsIndicatorObjectEntryView*) base; + CLUTTER_ACTOR_CLASS (unity_panel_indicators_indicator_object_entry_view_parent_class)->map ((ClutterActor*) CTK_BOX (self)); + clutter_actor_map ((ClutterActor*) self->priv->bg); +} + + +static void unity_panel_indicators_indicator_object_entry_view_real_unmap (ClutterActor* base) { + UnityPanelIndicatorsIndicatorObjectEntryView * self; + self = (UnityPanelIndicatorsIndicatorObjectEntryView*) base; + CLUTTER_ACTOR_CLASS (unity_panel_indicators_indicator_object_entry_view_parent_class)->unmap ((ClutterActor*) CTK_BOX (self)); + clutter_actor_unmap ((ClutterActor*) self->priv->bg); +} + + +static gboolean unity_panel_indicators_indicator_object_entry_view_update_bg (UnityPanelIndicatorsIndicatorObjectEntryView* self) { + gboolean result = FALSE; + cairo_t* cr; + gint width; + gint height; + cairo_t* _tmp0_; + cairo_pattern_t* pat; + g_return_val_if_fail (self != NULL, FALSE); + cr = NULL; + width = (gint) self->priv->last_width; + height = (gint) self->priv->last_height; + clutter_cairo_texture_set_surface_size (self->priv->bg, (guint) width, (guint) height); + cr = (_tmp0_ = clutter_cairo_texture_create (self->priv->bg), _cairo_destroy0 (cr), _tmp0_); + cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR); + cairo_paint (cr); + cairo_set_operator (cr, CAIRO_OPERATOR_OVER); + cairo_set_line_width (cr, 1.0); + cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.2); + cairo_move_to (cr, (double) 1, (double) height); + cairo_line_to (cr, (double) 1, (double) 7); + cairo_curve_to (cr, (double) 1, (double) 2, (double) 1, (double) 2, (double) 10, (double) 2); + cairo_line_to (cr, (double) (width - 10), (double) 2); + cairo_curve_to (cr, (double) width, (double) 2, (double) width, (double) 2, (double) width, (double) 7); + cairo_line_to (cr, (double) width, (double) height); + cairo_line_to (cr, (double) 1, (double) height); + pat = cairo_pattern_create_linear ((double) 1, (double) 0, (double) 1, (double) height); + cairo_pattern_add_color_stop_rgba (pat, 0.0, (double) 0.8509f, (double) 0.8196f, (double) 0.7294f, (double) 1.0f); + cairo_pattern_add_color_stop_rgba (pat, 1.0, (double) 0.7019f, (double) 0.6509f, (double) 0.5137f, (double) 1.0f); + cairo_set_source (cr, pat); + cairo_fill (cr); + result = FALSE; + _cairo_destroy0 (cr); + _cairo_pattern_destroy0 (pat); + return result; +} + + +IndicatorObjectEntry* unity_panel_indicators_indicator_object_entry_view_get_entry (UnityPanelIndicatorsIndicatorObjectEntryView* self) { + IndicatorObjectEntry* result; + g_return_val_if_fail (self != NULL, NULL); + result = self->priv->_entry; + return result; +} + + +static void unity_panel_indicators_indicator_object_entry_view_set_entry (UnityPanelIndicatorsIndicatorObjectEntryView* self, IndicatorObjectEntry* value) { + g_return_if_fail (self != NULL); + self->priv->_entry = value; + g_object_notify ((GObject *) self, "entry"); +} + + +static gboolean _unity_panel_indicators_indicator_object_entry_view_on_button_press_event_clutter_actor_button_press_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { + gboolean result; + result = unity_panel_indicators_indicator_object_entry_view_on_button_press_event (self, event); + return result; +} + + +static gboolean _unity_panel_indicators_indicator_object_entry_view_on_motion_event_clutter_actor_motion_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { + gboolean result; + result = unity_panel_indicators_indicator_object_entry_view_on_motion_event (self, event); + return result; +} + + +static gboolean _unity_panel_indicators_indicator_object_entry_view_on_scroll_event_clutter_actor_scroll_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { + gboolean result; + result = unity_panel_indicators_indicator_object_entry_view_on_scroll_event (self, event); + return result; +} + + +static void _lambda0_ (UnityPanelIndicatorsIndicatorObjectEntryView* self) { + GdkPixbuf* _tmp1_; + GdkPixbuf* _tmp0_ = NULL; + gboolean _tmp2_; + if ((_tmp2_ = GDK_IS_PIXBUF (_tmp1_ = (g_object_get (self->priv->_entry->image, "pixbuf", &_tmp0_, NULL), _tmp0_)), _g_object_unref0 (_tmp1_), _tmp2_)) { + GdkPixbuf* _tmp4_; + GdkPixbuf* _tmp3_ = NULL; + GdkPixbuf* _tmp6_; + GdkPixbuf* _tmp5_ = NULL; + g_object_set (self->image, "pixbuf", _tmp4_ = (g_object_get (self->priv->_entry->image, "pixbuf", &_tmp3_, NULL), _tmp3_), NULL); + _g_object_unref0 (_tmp4_); + ctk_image_set_size (self->image, gdk_pixbuf_get_width (_tmp6_ = (g_object_get (self->priv->_entry->image, "pixbuf", &_tmp5_, NULL), _tmp5_))); + _g_object_unref0 (_tmp6_); + } +} + + +static void __lambda0__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) { + _lambda0_ (self); +} + + +static void _lambda1_ (UnityPanelIndicatorsIndicatorObjectEntryView* self) { + char* _tmp1_; + char* _tmp0_ = NULL; + gboolean _tmp2_; + if ((_tmp2_ = (_tmp1_ = (g_object_get (self->priv->_entry->image, "icon-name", &_tmp0_, NULL), _tmp0_)) != NULL, _g_free0 (_tmp1_), _tmp2_)) { + char* _tmp4_; + char* _tmp3_ = NULL; + g_object_set (self->image, "stock-id", _tmp4_ = (g_object_get (self->priv->_entry->image, "icon-name", &_tmp3_, NULL), _tmp3_), NULL); + _g_free0 (_tmp4_); + ctk_image_set_size (self->image, 22); + } +} + + +static void __lambda1__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) { + _lambda1_ (self); +} + + +static void _lambda2_ (UnityPanelIndicatorsIndicatorObjectEntryView* self) { + char* _tmp1_; + char* _tmp0_ = NULL; + gboolean _tmp2_; + if ((_tmp2_ = (_tmp1_ = (g_object_get (self->priv->_entry->image, "icon-name", &_tmp0_, NULL), _tmp0_)) != NULL, _g_free0 (_tmp1_), _tmp2_)) { + char* _tmp4_; + char* _tmp3_ = NULL; + g_object_set (self->image, "stock-id", _tmp4_ = (g_object_get (self->priv->_entry->image, "icon-name", &_tmp3_, NULL), _tmp3_), NULL); + _g_free0 (_tmp4_); + } +} + + +static void __lambda2__gtk_icon_theme_changed (GtkIconTheme* _sender, gpointer self) { + _lambda2_ (self); +} + + +static void _lambda3_ (UnityPanelIndicatorsIndicatorObjectEntryView* self) { + clutter_text_set_text ((ClutterText*) self->text, gtk_label_get_label (self->priv->_entry->label)); +} + + +static void __lambda3__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) { + _lambda3_ (self); +} + + +static GObject * unity_panel_indicators_indicator_object_entry_view_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) { + GObject * obj; + GObjectClass * parent_class; + UnityPanelIndicatorsIndicatorObjectEntryView * self; + parent_class = G_OBJECT_CLASS (unity_panel_indicators_indicator_object_entry_view_parent_class); + obj = parent_class->constructor (type, n_construct_properties, construct_properties); + self = UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_ENTRY_VIEW (obj); + { + CtkPadding _tmp0_ = {0}; + CtkPadding _tmp1_; + ClutterCairoTexture* _tmp2_; + GtkIconTheme* theme; + ctk_actor_set_padding ((CtkActor*) self, (_tmp1_ = (_tmp0_.top = (float) 0, _tmp0_.right = 4.0f, _tmp0_.bottom = (float) 0, _tmp0_.left = 4.0f, _tmp0_), &_tmp1_)); + g_signal_connect_object ((ClutterActor*) self, "button-press-event", (GCallback) _unity_panel_indicators_indicator_object_entry_view_on_button_press_event_clutter_actor_button_press_event, self, 0); + g_signal_connect_object ((ClutterActor*) self, "motion-event", (GCallback) _unity_panel_indicators_indicator_object_entry_view_on_motion_event_clutter_actor_motion_event, self, 0); + g_signal_connect_object ((ClutterActor*) self, "scroll-event", (GCallback) _unity_panel_indicators_indicator_object_entry_view_on_scroll_event_clutter_actor_scroll_event, self, 0); + self->priv->bg = (_tmp2_ = g_object_ref_sink ((ClutterCairoTexture*) clutter_cairo_texture_new ((guint) 10, (guint) 10)), _g_object_unref0 (self->priv->bg), _tmp2_); + clutter_actor_set_parent ((ClutterActor*) self->priv->bg, (ClutterActor*) self); + clutter_actor_set_opacity ((ClutterActor*) self->priv->bg, (guint8) 0); + clutter_actor_show ((ClutterActor*) self->priv->bg); + if (GTK_IS_IMAGE (self->priv->_entry->image)) { + CtkImage* _tmp3_; + char* _tmp5_; + char* _tmp4_ = NULL; + gboolean _tmp6_; + GdkPixbuf* _tmp10_; + GdkPixbuf* _tmp9_ = NULL; + gboolean _tmp11_; + self->image = (_tmp3_ = g_object_ref_sink ((CtkImage*) ctk_image_new ((guint) 22)), _g_object_unref0 (self->image), _tmp3_); + clutter_container_add_actor ((ClutterContainer*) self, (ClutterActor*) self->image); + clutter_actor_show ((ClutterActor*) self->image); + if ((_tmp6_ = (_tmp5_ = (g_object_get (self->priv->_entry->image, "icon-name", &_tmp4_, NULL), _tmp4_)) != NULL, _g_free0 (_tmp5_), _tmp6_)) { + char* _tmp8_; + char* _tmp7_ = NULL; + g_object_set (self->image, "stock-id", _tmp8_ = (g_object_get (self->priv->_entry->image, "icon-name", &_tmp7_, NULL), _tmp7_), NULL); + _g_free0 (_tmp8_); + } + if ((_tmp11_ = (_tmp10_ = (g_object_get (self->priv->_entry->image, "pixbuf", &_tmp9_, NULL), _tmp9_)) != NULL, _g_object_unref0 (_tmp10_), _tmp11_)) { + GdkPixbuf* _tmp13_; + GdkPixbuf* _tmp12_ = NULL; + GdkPixbuf* _tmp15_; + GdkPixbuf* _tmp14_ = NULL; + g_object_set (self->image, "pixbuf", _tmp13_ = (g_object_get (self->priv->_entry->image, "pixbuf", &_tmp12_, NULL), _tmp12_), NULL); + _g_object_unref0 (_tmp13_); + ctk_image_set_size (self->image, gdk_pixbuf_get_width (_tmp15_ = (g_object_get (self->priv->_entry->image, "pixbuf", &_tmp14_, NULL), _tmp14_))); + _g_object_unref0 (_tmp15_); + } + } + g_signal_connect_object ((GObject*) self->priv->_entry->image, "notify::pixbuf", (GCallback) __lambda0__g_object_notify, self, 0); + g_signal_connect_object ((GObject*) self->priv->_entry->image, "notify::icon-name", (GCallback) __lambda1__g_object_notify, self, 0); + theme = gtk_icon_theme_get_default (); + g_signal_connect_object (theme, "changed", (GCallback) __lambda2__gtk_icon_theme_changed, self, 0); + if (GTK_IS_LABEL (self->priv->_entry->label)) { + CtkText* _tmp16_; + ClutterColor _tmp17_ = {0}; + ClutterColor _tmp18_; + self->text = (_tmp16_ = g_object_ref_sink ((CtkText*) ctk_text_new ("")), _g_object_unref0 (self->text), _tmp16_); + clutter_text_set_color ((ClutterText*) self->text, (_tmp18_ = (_tmp17_.red = (guint8) 233, _tmp17_.green = (guint8) 216, _tmp17_.blue = (guint8) 200, _tmp17_.alpha = (guint8) 255, _tmp17_), &_tmp18_)); + clutter_container_add_actor ((ClutterContainer*) self, (ClutterActor*) self->text); + clutter_actor_show ((ClutterActor*) self->text); + clutter_text_set_text ((ClutterText*) self->text, gtk_label_get_label (self->priv->_entry->label)); + g_signal_connect_object ((GObject*) self->priv->_entry->label, "notify::label", (GCallback) __lambda3__g_object_notify, self, 0); + } + } + return obj; +} + + +static void unity_panel_indicators_indicator_object_entry_view_class_init (UnityPanelIndicatorsIndicatorObjectEntryViewClass * klass) { + unity_panel_indicators_indicator_object_entry_view_parent_class = g_type_class_peek_parent (klass); + g_type_class_add_private (klass, sizeof (UnityPanelIndicatorsIndicatorObjectEntryViewPrivate)); + CLUTTER_ACTOR_CLASS (klass)->allocate = unity_panel_indicators_indicator_object_entry_view_real_allocate; + CLUTTER_ACTOR_CLASS (klass)->paint = unity_panel_indicators_indicator_object_entry_view_real_paint; + CLUTTER_ACTOR_CLASS (klass)->map = unity_panel_indicators_indicator_object_entry_view_real_map; + CLUTTER_ACTOR_CLASS (klass)->unmap = unity_panel_indicators_indicator_object_entry_view_real_unmap; + G_OBJECT_CLASS (klass)->get_property = unity_panel_indicators_indicator_object_entry_view_get_property; + G_OBJECT_CLASS (klass)->set_property = unity_panel_indicators_indicator_object_entry_view_set_property; + G_OBJECT_CLASS (klass)->constructor = unity_panel_indicators_indicator_object_entry_view_constructor; + G_OBJECT_CLASS (klass)->finalize = unity_panel_indicators_indicator_object_entry_view_finalize; + g_object_class_install_property (G_OBJECT_CLASS (klass), UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_ENTRY_VIEW_ENTRY, g_param_spec_pointer ("entry", "entry", "entry", G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); + g_signal_new ("menu_moved", UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_ENTRY_VIEW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__ENUM, G_TYPE_NONE, 1, GTK_TYPE_MENU_DIRECTION_TYPE); +} + + +static void unity_panel_indicators_indicator_object_entry_view_instance_init (UnityPanelIndicatorsIndicatorObjectEntryView * self) { + self->priv = UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_ENTRY_VIEW_GET_PRIVATE (self); + self->priv->menu_is_open = FALSE; + self->priv->last_found_entry_x = 0.0f; + self->priv->last_width = (float) 0; + self->priv->last_height = (float) 0; +} + + +static void unity_panel_indicators_indicator_object_entry_view_finalize (GObject* obj) { + UnityPanelIndicatorsIndicatorObjectEntryView * self; + self = UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_ENTRY_VIEW (obj); + _g_object_unref0 (self->priv->bg); + _g_object_unref0 (self->image); + _g_object_unref0 (self->text); + G_OBJECT_CLASS (unity_panel_indicators_indicator_object_entry_view_parent_class)->finalize (obj); +} + + +GType unity_panel_indicators_indicator_object_entry_view_get_type (void) { + static volatile gsize unity_panel_indicators_indicator_object_entry_view_type_id__volatile = 0; + if (g_once_init_enter (&unity_panel_indicators_indicator_object_entry_view_type_id__volatile)) { + static const GTypeInfo g_define_type_info = { sizeof (UnityPanelIndicatorsIndicatorObjectEntryViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) unity_panel_indicators_indicator_object_entry_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UnityPanelIndicatorsIndicatorObjectEntryView), 0, (GInstanceInitFunc) unity_panel_indicators_indicator_object_entry_view_instance_init, NULL }; + GType unity_panel_indicators_indicator_object_entry_view_type_id; + unity_panel_indicators_indicator_object_entry_view_type_id = g_type_register_static (CTK_TYPE_BOX, "UnityPanelIndicatorsIndicatorObjectEntryView", &g_define_type_info, 0); + g_once_init_leave (&unity_panel_indicators_indicator_object_entry_view_type_id__volatile, unity_panel_indicators_indicator_object_entry_view_type_id); + } + return unity_panel_indicators_indicator_object_entry_view_type_id__volatile; +} + + +static void unity_panel_indicators_indicator_object_entry_view_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { + UnityPanelIndicatorsIndicatorObjectEntryView * self; + self = UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_ENTRY_VIEW (object); + switch (property_id) { + case UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_ENTRY_VIEW_ENTRY: + g_value_set_pointer (value, unity_panel_indicators_indicator_object_entry_view_get_entry (self)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + + +static void unity_panel_indicators_indicator_object_entry_view_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) { + UnityPanelIndicatorsIndicatorObjectEntryView * self; + self = UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_ENTRY_VIEW (object); + switch (property_id) { + case UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_ENTRY_VIEW_ENTRY: + unity_panel_indicators_indicator_object_entry_view_set_entry (self, g_value_get_pointer (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + + + + diff --git a/unity-private/panel/panel-indicator-object-entry-view.vala b/unity-private/panel/panel-indicator-object-entry-view.vala new file mode 100644 index 000000000..077b92391 --- /dev/null +++ b/unity-private/panel/panel-indicator-object-entry-view.vala @@ -0,0 +1,327 @@ +/* + * Copyright (C) 2010 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> + * Jay Taoko <jay.taoko@canonical.com> + */ + +namespace Unity.Panel.Indicators +{ + public class IndicatorObjectEntryView : Ctk.Box + { + public unowned Indicator.ObjectEntry entry { get; construct; } + public signal void menu_moved (Gtk.MenuDirectionType type); + + private Clutter.CairoTexture bg; + public Ctk.Image image; + public Ctk.Text text; + private bool menu_is_open = false; + + private uint32 click_time; + private float last_found_entry_x = 0.0f; + + private float last_width = 0; + private float last_height = 0; + + public IndicatorObjectEntryView (Indicator.ObjectEntry _entry) + { + Object (entry:_entry, + orientation: Ctk.Orientation.HORIZONTAL, + spacing:3, + homogeneous:false, + reactive:true); + } + + construct + { + /* Figure out if you need a label, text or both, create the ctk + * representations. + * Hook up the appropriate signals + */ + padding = { 0, 4.0f, 0, 4.0f }; + + button_press_event.connect (on_button_press_event); + + motion_event.connect (on_motion_event); + scroll_event.connect (on_scroll_event); + + bg = new Clutter.CairoTexture (10, 10); + bg.set_parent (this); + bg.opacity = 0; + bg.show (); + + if (entry.image is Gtk.Image) + { + image = new Ctk.Image (22); + add_actor (image); + image.show (); + + if (entry.image.icon_name != null) + { + image.stock_id = entry.image.icon_name; + } + + if (entry.image.pixbuf != null) + { + image.pixbuf = entry.image.pixbuf; + image.size = entry.image.pixbuf.width; + } + } + + entry.image.notify["pixbuf"].connect (() => + { + if (entry.image.pixbuf is Gdk.Pixbuf) + { + image.pixbuf = entry.image.pixbuf; + image.size = entry.image.pixbuf.width; + } + }); + + entry.image.notify["icon-name"].connect (() => + { + if (entry.image.icon_name != null) + { + image.stock_id = entry.image.icon_name; + image.size = 22; + } + }); + + unowned Gtk.IconTheme theme = Gtk.IconTheme.get_default (); + theme.changed.connect (() => + { + if (entry.image.icon_name != null) + image.stock_id = entry.image.icon_name; + }); + + if (entry.label is Gtk.Label) + { + text = new Ctk.Text (""); + text.color = { 233, 216, 200, 255 }; + add_actor (text); + text.show (); + + text.text = entry.label.label; + + entry.label.notify["label"].connect (() => + { + text.text = entry.label.label; + }); + } + } + + private void position_menu (Gtk.Menu menu, + out int x, + out int y, + out bool push_in) + { + y = (int)height; + x = (int)last_found_entry_x; + } + + public void show_menu () + { + if (entry.menu is Gtk.Menu) + { + last_found_entry_x = x + get_parent ().x + get_parent ().get_parent ().x; + MenuManager.get_default ().register_visible_menu (entry.menu); + entry.menu.popup (null, + null, + position_menu, + 1, + Clutter.get_current_event_time ()); + click_time = Clutter.get_current_event_time (); + menu_shown (); + } + } + + private bool on_scroll_event (Clutter.Event e) + { + Clutter.ScrollEvent event = e.scroll; + + IndicatorObjectView parent = get_parent () as IndicatorObjectView; + unowned Indicator.Object object = parent.indicator_object; + + Signal.emit_by_name (object, "scroll", 1, event.direction); + + return true; + } + + public bool on_button_press_event (Clutter.Event e) + { + if (entry.menu is Gtk.Menu) + { + if(menu_is_open) + { + entry.menu.popdown(); + menu_is_open = false; + return true; + } + else + { + last_found_entry_x = x + get_parent ().x + get_parent ().get_parent ().x; + MenuManager.get_default ().register_visible_menu (entry.menu); + entry.menu.popup (null, + null, + position_menu, + e.button.button, + e.button.time); + click_time = Clutter.get_current_event_time (); + menu_is_open = true; + menu_shown (); + } + } + return true; + } + + public bool on_motion_event (Clutter.Event e) + { + if ((entry.menu is Gtk.Menu) && MenuManager.get_default ().menu_is_open ()) + { + show_menu (); + return true; + } + return false; + } + + public void menu_shown() + { + if (entry.menu is Gtk.Menu) + { + /* Show the menu and connect various signal to update the menu if + * necessary. + */ + entry.menu.move_current.connect (menu_key_moved); + entry.menu.notify["visible"].connect (menu_vis_changed); + bg.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 200, "opacity", 255); + } + } + + public void menu_vis_changed () + { + bool vis = (entry.menu.get_flags () & Gtk.WidgetFlags.VISIBLE) != 0; + if (vis == false) + { + /* The menu isn't visible anymore. Disconnect some signals. */ + bg.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 200, "opacity", 0); + entry.menu.move_current.disconnect (menu_key_moved); + entry.menu.notify["visible"].disconnect (menu_vis_changed); + menu_is_open = false; + } + } + + public void menu_key_moved (Gtk.MenuDirectionType type) + { + if (type != Gtk.MenuDirectionType.PARENT && + type != Gtk.MenuDirectionType.CHILD) + return; + + menu_moved (type); + } + + /* + * CLUTTER OVERRIDES + */ + private override void allocate (Clutter.ActorBox box, + Clutter.AllocationFlags flags) + { + float width; + float height; + + base.allocate (box, flags); + + width = Math.floorf (box.x2 - box.x1); + height = Math.floorf (box.y2 - box.y1); + + Clutter.ActorBox child_box = { 0 }; + child_box.x1 = 0; + child_box.x2 = width; + child_box.y1 = 0; + child_box.y2 = height; + + if (width != last_width || height != last_height) + { + last_width = width; + last_height = height; + Idle.add (update_bg); + } + + bg.allocate (child_box, flags); + } + + private override void paint () + { + bg.paint (); + base.paint (); + } + + private override void map () + { + base.map (); + bg.map (); + } + + private override void unmap () + { + base.unmap (); + bg.unmap (); + } + + private bool update_bg () + { + Cairo.Context cr; + int width = (int)last_width; + int height = (int)last_height; + + bg.set_surface_size (width, height); + + cr = bg.create (); + + cr.set_operator (Cairo.Operator.CLEAR); + cr.paint (); + + cr.set_operator (Cairo.Operator.OVER); + + cr.set_line_width (1.0); + + cr.set_source_rgba (1.0, 1.0, 1.0, 0.2); + + cr.move_to (1, height); + + cr.line_to (1, 7); + + cr.curve_to (1, 2, + 1, 2, + 10, 2); + + cr.line_to (width-10, 2); + + cr.curve_to (width, 2, + width, 2, + width, 7); + + cr.line_to (width, height); + + cr.line_to (1, height); + + var pat = new Cairo.Pattern.linear (1, 0, 1, height); + pat.add_color_stop_rgba (0.0, 0.8509f, 0.8196f, 0.7294f, 1.0f); + pat.add_color_stop_rgba (1.0, 0.7019f, 0.6509f, 0.5137f, 1.0f); + cr.set_source (pat); + cr.fill (); + + return false; + } + } +} diff --git a/unity-private/panel/panel-indicator-object-view.c b/unity-private/panel/panel-indicator-object-view.c new file mode 100644 index 000000000..fbb407068 --- /dev/null +++ b/unity-private/panel/panel-indicator-object-view.c @@ -0,0 +1,394 @@ +/* panel-indicator-object-view.c generated by valac, the Vala compiler + * generated from panel-indicator-object-view.vala, do not modify */ + +/* + * Copyright (C) 2010 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> + * Jay Taoko <jay.taoko@canonical.com> + */ + +#include <glib.h> +#include <glib-object.h> +#include <clutk/clutk.h> +#include <libindicator/indicator-object.h> +#include <gee.h> +#include <gtk/gtk.h> +#include <libindicator/indicator.h> +#include <libindicator/indicator-service.h> +#include <libindicator/indicator-service-manager.h> +#include <clutter/clutter.h> +#include <unity-utils.h> + + +#define UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW (unity_panel_indicators_indicator_object_view_get_type ()) +#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW, UnityPanelIndicatorsIndicatorObjectView)) +#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW, UnityPanelIndicatorsIndicatorObjectViewClass)) +#define UNITY_PANEL_INDICATORS_IS_INDICATOR_OBJECT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW)) +#define UNITY_PANEL_INDICATORS_IS_INDICATOR_OBJECT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW)) +#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW, UnityPanelIndicatorsIndicatorObjectViewClass)) + +typedef struct _UnityPanelIndicatorsIndicatorObjectView UnityPanelIndicatorsIndicatorObjectView; +typedef struct _UnityPanelIndicatorsIndicatorObjectViewClass UnityPanelIndicatorsIndicatorObjectViewClass; +typedef struct _UnityPanelIndicatorsIndicatorObjectViewPrivate UnityPanelIndicatorsIndicatorObjectViewPrivate; + +#define UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_ENTRY_VIEW (unity_panel_indicators_indicator_object_entry_view_get_type ()) +#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_ENTRY_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_ENTRY_VIEW, UnityPanelIndicatorsIndicatorObjectEntryView)) +#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_ENTRY_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_ENTRY_VIEW, UnityPanelIndicatorsIndicatorObjectEntryViewClass)) +#define UNITY_PANEL_INDICATORS_IS_INDICATOR_OBJECT_ENTRY_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_ENTRY_VIEW)) +#define UNITY_PANEL_INDICATORS_IS_INDICATOR_OBJECT_ENTRY_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_ENTRY_VIEW)) +#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_ENTRY_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_ENTRY_VIEW, UnityPanelIndicatorsIndicatorObjectEntryViewClass)) + +typedef struct _UnityPanelIndicatorsIndicatorObjectEntryView UnityPanelIndicatorsIndicatorObjectEntryView; +typedef struct _UnityPanelIndicatorsIndicatorObjectEntryViewClass UnityPanelIndicatorsIndicatorObjectEntryViewClass; +#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) + +struct _UnityPanelIndicatorsIndicatorObjectView { + CtkBox parent_instance; + UnityPanelIndicatorsIndicatorObjectViewPrivate * priv; +}; + +struct _UnityPanelIndicatorsIndicatorObjectViewClass { + CtkBoxClass parent_class; +}; + +struct _UnityPanelIndicatorsIndicatorObjectViewPrivate { + IndicatorObject* _indicator_object; + GeeArrayList* indicator_entry_array; +}; + + +static gpointer unity_panel_indicators_indicator_object_view_parent_class = NULL; + +GType unity_panel_indicators_indicator_object_view_get_type (void); +GType unity_panel_indicators_indicator_object_entry_view_get_type (void); +#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW, UnityPanelIndicatorsIndicatorObjectViewPrivate)) +enum { + UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW_DUMMY_PROPERTY, + UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW_INDICATOR_OBJECT +}; +UnityPanelIndicatorsIndicatorObjectView* unity_panel_indicators_indicator_object_view_new (IndicatorObject* _object); +UnityPanelIndicatorsIndicatorObjectView* unity_panel_indicators_indicator_object_view_construct (GType object_type, IndicatorObject* _object); +void unity_panel_indicators_indicator_object_view_show_entry_menu (UnityPanelIndicatorsIndicatorObjectView* self, gint entry); +void unity_panel_indicators_indicator_object_entry_view_show_menu (UnityPanelIndicatorsIndicatorObjectEntryView* self); +static void unity_panel_indicators_indicator_object_view_on_menu_moved (UnityPanelIndicatorsIndicatorObjectView* self, UnityPanelIndicatorsIndicatorObjectEntryView* object_entry_view, GtkMenuDirectionType type); +IndicatorObjectEntry* unity_panel_indicators_indicator_object_entry_view_get_entry (UnityPanelIndicatorsIndicatorObjectEntryView* self); +UnityPanelIndicatorsIndicatorObjectEntryView* unity_panel_indicators_indicator_object_entry_view_new (IndicatorObjectEntry* _entry); +UnityPanelIndicatorsIndicatorObjectEntryView* unity_panel_indicators_indicator_object_entry_view_construct (GType object_type, IndicatorObjectEntry* _entry); +static void _unity_panel_indicators_indicator_object_view_on_menu_moved_unity_panel_indicators_indicator_object_entry_view_menu_moved (UnityPanelIndicatorsIndicatorObjectEntryView* _sender, GtkMenuDirectionType type, gpointer self); +static void unity_panel_indicators_indicator_object_view_on_entry_added (UnityPanelIndicatorsIndicatorObjectView* self, IndicatorObject* object, IndicatorObjectEntry* indicator_object_entry); +static void unity_panel_indicators_indicator_object_view_remove_entry (UnityPanelIndicatorsIndicatorObjectView* self, IndicatorObjectEntry* entry); +void unity_panel_indicators_indicator_object_view_open_first_menu_entry (UnityPanelIndicatorsIndicatorObjectView* self); +void unity_panel_indicators_indicator_object_view_open_last_menu_entry (UnityPanelIndicatorsIndicatorObjectView* self); +IndicatorObject* unity_panel_indicators_indicator_object_view_get_indicator_object (UnityPanelIndicatorsIndicatorObjectView* self); +static void unity_panel_indicators_indicator_object_view_set_indicator_object (UnityPanelIndicatorsIndicatorObjectView* self, IndicatorObject* value); +static void _unity_panel_indicators_indicator_object_view_on_entry_added_indicator_object_entry_added (IndicatorObject* _sender, IndicatorObjectEntry* entry, gpointer self); +static void _unity_panel_indicators_indicator_object_view_remove_entry_indicator_object_entry_removed (IndicatorObject* _sender, IndicatorObjectEntry* entry, gpointer self); +static GObject * unity_panel_indicators_indicator_object_view_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties); +static void unity_panel_indicators_indicator_object_view_finalize (GObject* obj); +static void unity_panel_indicators_indicator_object_view_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); +static void unity_panel_indicators_indicator_object_view_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec); + + + +UnityPanelIndicatorsIndicatorObjectView* unity_panel_indicators_indicator_object_view_construct (GType object_type, IndicatorObject* _object) { + UnityPanelIndicatorsIndicatorObjectView * self; + g_return_val_if_fail (_object != NULL, NULL); + self = (UnityPanelIndicatorsIndicatorObjectView*) g_object_new (object_type, "indicator-object", _object, "orientation", CTK_ORIENTATION_HORIZONTAL, "spacing", 0, "homogeneous", FALSE, NULL); + return self; +} + + +UnityPanelIndicatorsIndicatorObjectView* unity_panel_indicators_indicator_object_view_new (IndicatorObject* _object) { + return unity_panel_indicators_indicator_object_view_construct (UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW, _object); +} + + +void unity_panel_indicators_indicator_object_view_show_entry_menu (UnityPanelIndicatorsIndicatorObjectView* self, gint entry) { + g_return_if_fail (self != NULL); +} + + +static void unity_panel_indicators_indicator_object_view_on_menu_moved (UnityPanelIndicatorsIndicatorObjectView* self, UnityPanelIndicatorsIndicatorObjectEntryView* object_entry_view, GtkMenuDirectionType type) { + gint pos; + UnityPanelIndicatorsIndicatorObjectEntryView* next_object_entry_view; + g_return_if_fail (self != NULL); + g_return_if_fail (object_entry_view != NULL); + pos = gee_abstract_list_index_of ((GeeAbstractList*) self->priv->indicator_entry_array, object_entry_view); + if (pos == (-1)) { + return; + } + if (type == GTK_MENU_DIR_PARENT) { + if (pos == 0) { + g_signal_emit_by_name (self, "menu-moved", type); + return; + } + pos = pos - 1; + } else { + if (type == GTK_MENU_DIR_CHILD) { + if (pos == (gee_collection_get_size ((GeeCollection*) self->priv->indicator_entry_array) - 1)) { + g_signal_emit_by_name (self, "menu-moved", type); + return; + } + pos = pos + 1; + } + } + next_object_entry_view = (UnityPanelIndicatorsIndicatorObjectEntryView*) gee_abstract_list_get ((GeeAbstractList*) self->priv->indicator_entry_array, pos); + unity_panel_indicators_indicator_object_entry_view_show_menu (next_object_entry_view); + _g_object_unref0 (next_object_entry_view); +} + + +static void _unity_panel_indicators_indicator_object_view_on_menu_moved_unity_panel_indicators_indicator_object_entry_view_menu_moved (UnityPanelIndicatorsIndicatorObjectEntryView* _sender, GtkMenuDirectionType type, gpointer self) { + unity_panel_indicators_indicator_object_view_on_menu_moved (self, _sender, type); +} + + +static void unity_panel_indicators_indicator_object_view_on_entry_added (UnityPanelIndicatorsIndicatorObjectView* self, IndicatorObject* object, IndicatorObjectEntry* indicator_object_entry) { + UnityPanelIndicatorsIndicatorObjectEntryView* object_entry_view; + g_return_if_fail (self != NULL); + g_return_if_fail (object != NULL); + g_return_if_fail (indicator_object_entry != NULL); + { + gint i; + i = 0; + { + gboolean _tmp0_; + _tmp0_ = TRUE; + while (TRUE) { + UnityPanelIndicatorsIndicatorObjectEntryView* _tmp1_; + UnityPanelIndicatorsIndicatorObjectEntryView* entry_view; + if (!_tmp0_) { + i++; + } + _tmp0_ = FALSE; + if (!(i < gee_collection_get_size ((GeeCollection*) self->priv->indicator_entry_array))) { + break; + } + entry_view = (_tmp1_ = (UnityPanelIndicatorsIndicatorObjectEntryView*) gee_abstract_list_get ((GeeAbstractList*) self->priv->indicator_entry_array, i), UNITY_PANEL_INDICATORS_IS_INDICATOR_OBJECT_ENTRY_VIEW (_tmp1_) ? ((UnityPanelIndicatorsIndicatorObjectEntryView*) _tmp1_) : NULL); + if (unity_panel_indicators_indicator_object_entry_view_get_entry (entry_view) == indicator_object_entry) { + _g_object_unref0 (entry_view); + return; + } + _g_object_unref0 (entry_view); + } + } + } + object_entry_view = g_object_ref_sink (unity_panel_indicators_indicator_object_entry_view_new (indicator_object_entry)); + g_signal_connect_object (object_entry_view, "menu-moved", (GCallback) _unity_panel_indicators_indicator_object_view_on_menu_moved_unity_panel_indicators_indicator_object_entry_view_menu_moved, self, 0); + gee_abstract_collection_add ((GeeAbstractCollection*) self->priv->indicator_entry_array, object_entry_view); + clutter_container_add_actor ((ClutterContainer*) self, (ClutterActor*) object_entry_view); + _g_object_unref0 (object_entry_view); +} + + +static void unity_panel_indicators_indicator_object_view_remove_entry (UnityPanelIndicatorsIndicatorObjectView* self, IndicatorObjectEntry* entry) { + g_return_if_fail (self != NULL); + g_return_if_fail (entry != NULL); + { + gint i; + i = 0; + { + gboolean _tmp0_; + _tmp0_ = TRUE; + while (TRUE) { + UnityPanelIndicatorsIndicatorObjectEntryView* _tmp1_; + UnityPanelIndicatorsIndicatorObjectEntryView* object_entry_view; + if (!_tmp0_) { + i++; + } + _tmp0_ = FALSE; + if (!(i < gee_collection_get_size ((GeeCollection*) self->priv->indicator_entry_array))) { + break; + } + object_entry_view = (_tmp1_ = (UnityPanelIndicatorsIndicatorObjectEntryView*) gee_abstract_list_get ((GeeAbstractList*) self->priv->indicator_entry_array, i), UNITY_PANEL_INDICATORS_IS_INDICATOR_OBJECT_ENTRY_VIEW (_tmp1_) ? ((UnityPanelIndicatorsIndicatorObjectEntryView*) _tmp1_) : NULL); + if (unity_panel_indicators_indicator_object_entry_view_get_entry (object_entry_view) == entry) { + clutter_container_remove_actor ((ClutterContainer*) self, (ClutterActor*) object_entry_view); + gee_abstract_collection_remove ((GeeAbstractCollection*) self->priv->indicator_entry_array, object_entry_view); + } + _g_object_unref0 (object_entry_view); + } + } + } +} + + +void unity_panel_indicators_indicator_object_view_open_first_menu_entry (UnityPanelIndicatorsIndicatorObjectView* self) { + g_return_if_fail (self != NULL); + if (gee_collection_get_size ((GeeCollection*) self->priv->indicator_entry_array) > 0) { + UnityPanelIndicatorsIndicatorObjectEntryView* object_entry_view; + object_entry_view = (UnityPanelIndicatorsIndicatorObjectEntryView*) gee_abstract_list_get ((GeeAbstractList*) self->priv->indicator_entry_array, 0); + unity_panel_indicators_indicator_object_entry_view_show_menu (object_entry_view); + _g_object_unref0 (object_entry_view); + } +} + + +void unity_panel_indicators_indicator_object_view_open_last_menu_entry (UnityPanelIndicatorsIndicatorObjectView* self) { + g_return_if_fail (self != NULL); + if (gee_collection_get_size ((GeeCollection*) self->priv->indicator_entry_array) > 0) { + UnityPanelIndicatorsIndicatorObjectEntryView* object_entry_view; + object_entry_view = (UnityPanelIndicatorsIndicatorObjectEntryView*) gee_abstract_list_get ((GeeAbstractList*) self->priv->indicator_entry_array, gee_collection_get_size ((GeeCollection*) self->priv->indicator_entry_array) - 1); + unity_panel_indicators_indicator_object_entry_view_show_menu (object_entry_view); + _g_object_unref0 (object_entry_view); + } +} + + +IndicatorObject* unity_panel_indicators_indicator_object_view_get_indicator_object (UnityPanelIndicatorsIndicatorObjectView* self) { + IndicatorObject* result; + g_return_val_if_fail (self != NULL, NULL); + result = self->priv->_indicator_object; + return result; +} + + +static gpointer _g_object_ref0 (gpointer self) { + return self ? g_object_ref (self) : NULL; +} + + +static void unity_panel_indicators_indicator_object_view_set_indicator_object (UnityPanelIndicatorsIndicatorObjectView* self, IndicatorObject* value) { + IndicatorObject* _tmp0_; + g_return_if_fail (self != NULL); + self->priv->_indicator_object = (_tmp0_ = _g_object_ref0 (value), _g_object_unref0 (self->priv->_indicator_object), _tmp0_); + g_object_notify ((GObject *) self, "indicator-object"); +} + + +static void _unity_panel_indicators_indicator_object_view_on_entry_added_indicator_object_entry_added (IndicatorObject* _sender, IndicatorObjectEntry* entry, gpointer self) { + unity_panel_indicators_indicator_object_view_on_entry_added (self, _sender, entry); +} + + +static void _unity_panel_indicators_indicator_object_view_remove_entry_indicator_object_entry_removed (IndicatorObject* _sender, IndicatorObjectEntry* entry, gpointer self) { + unity_panel_indicators_indicator_object_view_remove_entry (self, entry); +} + + +static GObject * unity_panel_indicators_indicator_object_view_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) { + GObject * obj; + GObjectClass * parent_class; + UnityPanelIndicatorsIndicatorObjectView * self; + parent_class = G_OBJECT_CLASS (unity_panel_indicators_indicator_object_view_parent_class); + obj = parent_class->constructor (type, n_construct_properties, construct_properties); + self = UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW (obj); + { + GeeArrayList* _tmp0_; + GList* list; + START_FUNCTION (); + self->priv->indicator_entry_array = (_tmp0_ = gee_array_list_new (UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_ENTRY_VIEW, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL), _g_object_unref0 (self->priv->indicator_entry_array), _tmp0_); + g_signal_connect_object (self->priv->_indicator_object, "entry-added", (GCallback) _unity_panel_indicators_indicator_object_view_on_entry_added_indicator_object_entry_added, self, 0); + g_signal_connect_object (self->priv->_indicator_object, "entry-removed", (GCallback) _unity_panel_indicators_indicator_object_view_remove_entry_indicator_object_entry_removed, self, 0); + list = indicator_object_get_entries (self->priv->_indicator_object); + { + gint i; + i = 0; + { + gboolean _tmp1_; + _tmp1_ = TRUE; + while (TRUE) { + IndicatorObjectEntry* indicator_object_entry; + UnityPanelIndicatorsIndicatorObjectEntryView* object_entry_view; + if (!_tmp1_) { + i++; + } + _tmp1_ = FALSE; + if (!(i < g_list_length (list))) { + break; + } + indicator_object_entry = (IndicatorObjectEntry*) ((IndicatorObjectEntry*) g_list_nth_data (list, (guint) i)); + object_entry_view = g_object_ref_sink (unity_panel_indicators_indicator_object_entry_view_new (indicator_object_entry)); + g_signal_connect_object (object_entry_view, "menu-moved", (GCallback) _unity_panel_indicators_indicator_object_view_on_menu_moved_unity_panel_indicators_indicator_object_entry_view_menu_moved, self, 0); + gee_abstract_collection_add ((GeeAbstractCollection*) self->priv->indicator_entry_array, object_entry_view); + clutter_container_add_actor ((ClutterContainer*) self, (ClutterActor*) object_entry_view); + _g_object_unref0 (object_entry_view); + } + } + } + END_FUNCTION (); + } + return obj; +} + + +static void unity_panel_indicators_indicator_object_view_class_init (UnityPanelIndicatorsIndicatorObjectViewClass * klass) { + unity_panel_indicators_indicator_object_view_parent_class = g_type_class_peek_parent (klass); + g_type_class_add_private (klass, sizeof (UnityPanelIndicatorsIndicatorObjectViewPrivate)); + G_OBJECT_CLASS (klass)->get_property = unity_panel_indicators_indicator_object_view_get_property; + G_OBJECT_CLASS (klass)->set_property = unity_panel_indicators_indicator_object_view_set_property; + G_OBJECT_CLASS (klass)->constructor = unity_panel_indicators_indicator_object_view_constructor; + G_OBJECT_CLASS (klass)->finalize = unity_panel_indicators_indicator_object_view_finalize; + g_object_class_install_property (G_OBJECT_CLASS (klass), UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW_INDICATOR_OBJECT, g_param_spec_object ("indicator-object", "indicator-object", "indicator-object", INDICATOR_TYPE_OBJECT, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); + g_signal_new ("menu_moved", UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__ENUM, G_TYPE_NONE, 1, GTK_TYPE_MENU_DIRECTION_TYPE); +} + + +static void unity_panel_indicators_indicator_object_view_instance_init (UnityPanelIndicatorsIndicatorObjectView * self) { + self->priv = UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW_GET_PRIVATE (self); +} + + +static void unity_panel_indicators_indicator_object_view_finalize (GObject* obj) { + UnityPanelIndicatorsIndicatorObjectView * self; + self = UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW (obj); + _g_object_unref0 (self->priv->_indicator_object); + _g_object_unref0 (self->priv->indicator_entry_array); + G_OBJECT_CLASS (unity_panel_indicators_indicator_object_view_parent_class)->finalize (obj); +} + + +GType unity_panel_indicators_indicator_object_view_get_type (void) { + static volatile gsize unity_panel_indicators_indicator_object_view_type_id__volatile = 0; + if (g_once_init_enter (&unity_panel_indicators_indicator_object_view_type_id__volatile)) { + static const GTypeInfo g_define_type_info = { sizeof (UnityPanelIndicatorsIndicatorObjectViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) unity_panel_indicators_indicator_object_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UnityPanelIndicatorsIndicatorObjectView), 0, (GInstanceInitFunc) unity_panel_indicators_indicator_object_view_instance_init, NULL }; + GType unity_panel_indicators_indicator_object_view_type_id; + unity_panel_indicators_indicator_object_view_type_id = g_type_register_static (CTK_TYPE_BOX, "UnityPanelIndicatorsIndicatorObjectView", &g_define_type_info, 0); + g_once_init_leave (&unity_panel_indicators_indicator_object_view_type_id__volatile, unity_panel_indicators_indicator_object_view_type_id); + } + return unity_panel_indicators_indicator_object_view_type_id__volatile; +} + + +static void unity_panel_indicators_indicator_object_view_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { + UnityPanelIndicatorsIndicatorObjectView * self; + self = UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW (object); + switch (property_id) { + case UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW_INDICATOR_OBJECT: + g_value_set_object (value, unity_panel_indicators_indicator_object_view_get_indicator_object (self)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + + +static void unity_panel_indicators_indicator_object_view_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) { + UnityPanelIndicatorsIndicatorObjectView * self; + self = UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW (object); + switch (property_id) { + case UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW_INDICATOR_OBJECT: + unity_panel_indicators_indicator_object_view_set_indicator_object (self, g_value_get_object (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + + + + diff --git a/unity-private/panel/panel-indicator-object-view.vala b/unity-private/panel/panel-indicator-object-view.vala new file mode 100644 index 000000000..4f18afc72 --- /dev/null +++ b/unity-private/panel/panel-indicator-object-view.vala @@ -0,0 +1,170 @@ +/* + * Copyright (C) 2010 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> + * Jay Taoko <jay.taoko@canonical.com> + */ + +using Gee; +using Utils; + +namespace Unity.Panel.Indicators +{ + public class IndicatorObjectView : Ctk.Box + { + public Indicator.Object indicator_object { get; construct; } + + public signal void menu_moved (Gtk.MenuDirectionType type); + + private Gee.ArrayList<IndicatorObjectEntryView> indicator_entry_array; + + public IndicatorObjectView (Indicator.Object _object) + { + Object (indicator_object: _object, + orientation:Ctk.Orientation.HORIZONTAL, + spacing:0, + homogeneous:false); + } + + construct + { + START_FUNCTION (); + + /* Read through the entries in the object, creating an + * IndicatorObjectEntryView for each one and appending it to self. + * Connect to IndicatorObjectEntryView's menu_moved signal so we can show + * the previous or next menu when the user presses the left or right + * arrows on their keyboard. + * If we're at the first or last entry, and the user want previous or + * next, when we emit the same signal, so our parent can pass it on to + * the IndicatorObjectView to the left of right of us. + * Connect to the entry_added/removed/moved signals and do the right + * thing for them + */ + indicator_entry_array = new Gee.ArrayList<IndicatorObjectEntryView> (); + + indicator_object.entry_added.connect (this.on_entry_added); + indicator_object.entry_removed.connect (this.remove_entry); + + unowned GLib.List<Indicator.ObjectEntry> list = indicator_object.get_entries (); + + for (int i = 0; i < list.length (); i++) + { + unowned Indicator.ObjectEntry indicator_object_entry = (Indicator.ObjectEntry) list.nth_data (i); + + IndicatorObjectEntryView object_entry_view = new IndicatorObjectEntryView (indicator_object_entry); + + object_entry_view.menu_moved.connect (this.on_menu_moved); + + this.indicator_entry_array.add (object_entry_view); + this.add_actor (object_entry_view); + } + + END_FUNCTION (); + } + + public void show_entry_menu (int entry) + { + /* Sometimes parent will want to force showing of an entry's menu, + * for instance when the user is moving between menus using the arrow + * keys. + * TODO + */ + } + + private void on_menu_moved (IndicatorObjectEntryView object_entry_view, Gtk.MenuDirectionType type) + { + int pos = this.indicator_entry_array.index_of (object_entry_view); + if (pos == -1) + return; + + if (type == Gtk.MenuDirectionType.PARENT) + { + if (pos == 0) + { + this.menu_moved (type); + return; + } + pos -= 1; + } + else if (type == Gtk.MenuDirectionType.CHILD) + { + if (pos == this.indicator_entry_array.size - 1) + { + this.menu_moved (type); + return; + } + pos +=1; + } + + IndicatorObjectEntryView next_object_entry_view = this.indicator_entry_array.get (pos); + next_object_entry_view.show_menu (); + /* Signal to be picked up by IndicatorBar */ + //this.menu_moved (type); + } + + private void on_entry_added (Indicator.Object object, Indicator.ObjectEntry indicator_object_entry) + { + /* First, make sure that this entry is not already in */ + for (int i = 0; i < indicator_entry_array.size; i++) + { + IndicatorObjectEntryView entry_view = this.indicator_entry_array.get (i) as IndicatorObjectEntryView; + if (entry_view.entry == indicator_object_entry) + { + return; + } + } + + IndicatorObjectEntryView object_entry_view = new IndicatorObjectEntryView (indicator_object_entry); + + object_entry_view.menu_moved.connect (this.on_menu_moved); + + this.indicator_entry_array.add (object_entry_view); + this.add_actor (object_entry_view); + + } + + private void remove_entry (Indicator.ObjectEntry entry) + { + for (int i = 0; i < indicator_entry_array.size; i++) + { + IndicatorObjectEntryView object_entry_view = this.indicator_entry_array.get (i) as IndicatorObjectEntryView; + if (object_entry_view.entry == entry) + { + this.remove_actor (object_entry_view); + this.indicator_entry_array.remove (object_entry_view); + } + } + } + + public void open_first_menu_entry () + { + if (indicator_entry_array.size > 0) + { + IndicatorObjectEntryView object_entry_view = this.indicator_entry_array.get (0); + object_entry_view.show_menu (); + } + } + + public void open_last_menu_entry () + { + if (indicator_entry_array.size > 0) + { + IndicatorObjectEntryView object_entry_view = this.indicator_entry_array.get (indicator_entry_array.size-1); + object_entry_view.show_menu (); + } + } + } +} diff --git a/unity-private/panel/panel-indicators.c b/unity-private/panel/panel-indicators.c index 2f011ddd4..12ae4bef1 100644 --- a/unity-private/panel/panel-indicators.c +++ b/unity-private/panel/panel-indicators.c @@ -216,14 +216,14 @@ static void unity_panel_indicators_indicator_entry_real_paint (ClutterActor* bas static void unity_panel_indicators_indicator_entry_real_map (ClutterActor* base); static void unity_panel_indicators_indicator_entry_real_unmap (ClutterActor* base); static void unity_panel_indicators_indicator_entry_set_entry (UnityPanelIndicatorsIndicatorEntry* self, IndicatorObjectEntry* value); -static void _lambda0_ (UnityPanelIndicatorsIndicatorEntry* self); -static void __lambda0__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self); -static void _lambda1_ (UnityPanelIndicatorsIndicatorEntry* self); -static void __lambda1__gtk_icon_theme_changed (GtkIconTheme* _sender, gpointer self); -static void _lambda2_ (UnityPanelIndicatorsIndicatorEntry* self); -static void __lambda2__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self); -static void _lambda3_ (UnityPanelIndicatorsIndicatorEntry* self); -static void __lambda3__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self); +static void _lambda4_ (UnityPanelIndicatorsIndicatorEntry* self); +static void __lambda4__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self); +static void _lambda5_ (UnityPanelIndicatorsIndicatorEntry* self); +static void __lambda5__gtk_icon_theme_changed (GtkIconTheme* _sender, gpointer self); +static void _lambda6_ (UnityPanelIndicatorsIndicatorEntry* self); +static void __lambda6__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self); +static void _lambda7_ (UnityPanelIndicatorsIndicatorEntry* self); +static void __lambda7__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self); static GObject * unity_panel_indicators_indicator_entry_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties); static void unity_panel_indicators_indicator_entry_finalize (GObject* obj); static void unity_panel_indicators_indicator_entry_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); @@ -309,6 +309,11 @@ static gboolean unity_panel_indicators_view_load_indicators (UnityPanelIndicator char* _tmp1_; skip_list = (_tmp1_ = g_strdup (""), _g_free0 (skip_list), _tmp1_); } + if (_vala_strcmp0 (skip_list, "all") == 0) { + result = FALSE; + _g_free0 (skip_list); + return result; + } gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), INDICATORICONSDIR); dir = g_file_new_for_path (INDICATORDIR); { @@ -316,7 +321,7 @@ static gboolean unity_panel_indicators_view_load_indicators (UnityPanelIndicator GFileInfo* file_info; e = g_file_enumerate_children (dir, G_FILE_ATTRIBUTE_STANDARD_NAME, 0, NULL, &_inner_error_); if (_inner_error_ != NULL) { - goto __catch2_g_error; + goto __catch4_g_error; } file_info = NULL; while (TRUE) { @@ -330,7 +335,7 @@ static gboolean unity_panel_indicators_view_load_indicators (UnityPanelIndicator if (_inner_error_ != NULL) { _g_object_unref0 (e); _g_object_unref0 (file_info); - goto __catch2_g_error; + goto __catch4_g_error; } if (!((file_info = (_tmp3_ = _tmp2_, _g_object_unref0 (file_info), _tmp3_)) != NULL)) { break; @@ -355,8 +360,8 @@ static gboolean unity_panel_indicators_view_load_indicators (UnityPanelIndicator _g_object_unref0 (e); _g_object_unref0 (file_info); } - goto __finally2; - __catch2_g_error: + goto __finally4; + __catch4_g_error: { GError * _error_; _error_ = _inner_error_; @@ -366,7 +371,7 @@ static gboolean unity_panel_indicators_view_load_indicators (UnityPanelIndicator _g_error_free0 (_error_); } } - __finally2: + __finally4: if (_inner_error_ != NULL) { _g_free0 (skip_list); _g_object_unref0 (dir); @@ -414,7 +419,7 @@ static void unity_panel_indicators_view_load_indicator (UnityPanelIndicatorsView i->position = (gint) GPOINTER_TO_INT (gee_abstract_map_get ((GeeAbstractMap*) self->priv->indicator_order, leaf)); _g_object_unref0 (i); } else { - g_warning ("panel-indicators.vala:134: Unable to load %s\n", filename); + g_warning ("panel-indicators.vala:137: Unable to load %s\n", filename); } _g_object_unref0 (o); } @@ -687,27 +692,37 @@ static void unity_panel_indicators_view_on_menu_moved (UnityPanelIndicatorsView* static gboolean _unity_panel_indicators_view_on_button_press_event_clutter_actor_button_press_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_panel_indicators_view_on_button_press_event (self, event); + gboolean result; + result = unity_panel_indicators_view_on_button_press_event (self, event); + return result; } static gboolean _unity_panel_indicators_view_on_button_release_event_clutter_actor_button_release_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_panel_indicators_view_on_button_release_event (self, event); + gboolean result; + result = unity_panel_indicators_view_on_button_release_event (self, event); + return result; } static gboolean _unity_panel_indicators_view_on_motion_event_clutter_actor_motion_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_panel_indicators_view_on_motion_event (self, event); + gboolean result; + result = unity_panel_indicators_view_on_motion_event (self, event); + return result; } static gboolean _unity_panel_indicators_view_on_scroll_event_clutter_actor_scroll_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_panel_indicators_view_on_scroll_event (self, event); + gboolean result; + result = unity_panel_indicators_view_on_scroll_event (self, event); + return result; } static gboolean _unity_panel_indicators_view_load_indicators_gsource_func (gpointer self) { - return unity_panel_indicators_view_load_indicators (self); + gboolean result; + result = unity_panel_indicators_view_load_indicators (self); + return result; } @@ -1156,7 +1171,7 @@ GtkMenu* unity_panel_indicators_indicator_entry_get_menu (UnityPanelIndicatorsIn } -static void _lambda0_ (UnityPanelIndicatorsIndicatorEntry* self) { +static void _lambda4_ (UnityPanelIndicatorsIndicatorEntry* self) { char* _tmp1_; char* _tmp0_ = NULL; g_object_set (self->priv->image, "stock-id", _tmp1_ = (g_object_get (self->priv->_entry->image, "icon-name", &_tmp0_, NULL), _tmp0_), NULL); @@ -1164,12 +1179,12 @@ static void _lambda0_ (UnityPanelIndicatorsIndicatorEntry* self) { } -static void __lambda0__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) { - _lambda0_ (self); +static void __lambda4__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) { + _lambda4_ (self); } -static void _lambda1_ (UnityPanelIndicatorsIndicatorEntry* self) { +static void _lambda5_ (UnityPanelIndicatorsIndicatorEntry* self) { char* _tmp1_; char* _tmp0_ = NULL; g_object_set (self->priv->image, "stock-id", _tmp1_ = (g_object_get (self->priv->_entry->image, "icon-name", &_tmp0_, NULL), _tmp0_), NULL); @@ -1177,12 +1192,12 @@ static void _lambda1_ (UnityPanelIndicatorsIndicatorEntry* self) { } -static void __lambda1__gtk_icon_theme_changed (GtkIconTheme* _sender, gpointer self) { - _lambda1_ (self); +static void __lambda5__gtk_icon_theme_changed (GtkIconTheme* _sender, gpointer self) { + _lambda5_ (self); } -static void _lambda2_ (UnityPanelIndicatorsIndicatorEntry* self) { +static void _lambda6_ (UnityPanelIndicatorsIndicatorEntry* self) { GdkPixbuf* _tmp1_; GdkPixbuf* _tmp0_ = NULL; GdkPixbuf* _tmp3_; @@ -1194,18 +1209,18 @@ static void _lambda2_ (UnityPanelIndicatorsIndicatorEntry* self) { } -static void __lambda2__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) { - _lambda2_ (self); +static void __lambda6__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) { + _lambda6_ (self); } -static void _lambda3_ (UnityPanelIndicatorsIndicatorEntry* self) { +static void _lambda7_ (UnityPanelIndicatorsIndicatorEntry* self) { clutter_text_set_text ((ClutterText*) self->priv->text, gtk_label_get_label (self->priv->_entry->label)); } -static void __lambda3__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) { - _lambda3_ (self); +static void __lambda7__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) { + _lambda7_ (self); } @@ -1242,9 +1257,9 @@ static GObject * unity_panel_indicators_indicator_entry_constructor (GType type, GtkIconTheme* theme; g_object_set (self->priv->image, "stock-id", _tmp9_ = (g_object_get (self->priv->_entry->image, "icon-name", &_tmp8_, NULL), _tmp8_), NULL); _g_free0 (_tmp9_); - g_signal_connect_object ((GObject*) self->priv->_entry->image, "notify::icon-name", (GCallback) __lambda0__g_object_notify, self, 0); + g_signal_connect_object ((GObject*) self->priv->_entry->image, "notify::icon-name", (GCallback) __lambda4__g_object_notify, self, 0); theme = gtk_icon_theme_get_default (); - g_signal_connect_object (theme, "changed", (GCallback) __lambda1__gtk_icon_theme_changed, self, 0); + g_signal_connect_object (theme, "changed", (GCallback) __lambda5__gtk_icon_theme_changed, self, 0); } if ((_tmp12_ = (_tmp11_ = (g_object_get (self->priv->_entry->image, "pixbuf", &_tmp10_, NULL), _tmp10_)) != NULL, _g_object_unref0 (_tmp11_), _tmp12_)) { GdkPixbuf* _tmp14_; @@ -1255,7 +1270,7 @@ static GObject * unity_panel_indicators_indicator_entry_constructor (GType type, _g_object_unref0 (_tmp14_); ctk_image_set_size (self->priv->image, gdk_pixbuf_get_width (_tmp16_ = (g_object_get (self->priv->_entry->image, "pixbuf", &_tmp15_, NULL), _tmp15_))); _g_object_unref0 (_tmp16_); - g_signal_connect_object ((GObject*) self->priv->_entry->image, "notify::pixbuf", (GCallback) __lambda2__g_object_notify, self, 0); + g_signal_connect_object ((GObject*) self->priv->_entry->image, "notify::pixbuf", (GCallback) __lambda6__g_object_notify, self, 0); } } if (GTK_IS_LABEL (self->priv->_entry->label)) { @@ -1267,7 +1282,7 @@ static GObject * unity_panel_indicators_indicator_entry_constructor (GType type, clutter_container_add_actor ((ClutterContainer*) self, (ClutterActor*) self->priv->text); clutter_actor_show ((ClutterActor*) self->priv->text); clutter_text_set_text ((ClutterText*) self->priv->text, gtk_label_get_label (self->priv->_entry->label)); - g_signal_connect_object ((GObject*) self->priv->_entry->label, "notify::label", (GCallback) __lambda3__g_object_notify, self, 0); + g_signal_connect_object ((GObject*) self->priv->_entry->label, "notify::label", (GCallback) __lambda7__g_object_notify, self, 0); } } return obj; diff --git a/unity-private/panel/panel-indicators.vala b/unity-private/panel/panel-indicators.vala index 4e6173211..9ebf3e695 100644 --- a/unity-private/panel/panel-indicators.vala +++ b/unity-private/panel/panel-indicators.vala @@ -73,6 +73,9 @@ namespace Unity.Panel.Indicators skip_list = Environment.get_variable ("UNITY_PANEL_INDICATORS_SKIP"); if (skip_list == null) skip_list = ""; + + if (skip_list == "all") + return false; /* We need to look for icons in an specific location */ Gtk.IconTheme.get_default ().append_search_path (INDICATORICONSDIR); diff --git a/unity-private/panel/panel-menu-manager.c b/unity-private/panel/panel-menu-manager.c new file mode 100644 index 000000000..4834137ec --- /dev/null +++ b/unity-private/panel/panel-menu-manager.c @@ -0,0 +1,175 @@ +/* panel-menu-manager.c generated by valac, the Vala compiler + * generated from panel-menu-manager.vala, do not modify */ + +/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */ +/* + * Copyright (C) 2010 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by canonical.com + * + */ + +#include <glib.h> +#include <glib-object.h> +#include <gtk/gtk.h> + + +#define TYPE_MENU_MANAGER (menu_manager_get_type ()) +#define MENU_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MENU_MANAGER, MenuManager)) +#define MENU_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MENU_MANAGER, MenuManagerClass)) +#define IS_MENU_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MENU_MANAGER)) +#define IS_MENU_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MENU_MANAGER)) +#define MENU_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MENU_MANAGER, MenuManagerClass)) + +typedef struct _MenuManager MenuManager; +typedef struct _MenuManagerClass MenuManagerClass; +typedef struct _MenuManagerPrivate MenuManagerPrivate; +#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) + +struct _MenuManager { + GObject parent_instance; + MenuManagerPrivate * priv; +}; + +struct _MenuManagerClass { + GObjectClass parent_class; +}; + +struct _MenuManagerPrivate { + GtkMenu* current_menu; +}; + + +static MenuManager* menu_manager__menu_manager_global; +static MenuManager* menu_manager__menu_manager_global = NULL; +static gpointer menu_manager_parent_class = NULL; + +GType menu_manager_get_type (void); +#define MENU_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_MENU_MANAGER, MenuManagerPrivate)) +enum { + MENU_MANAGER_DUMMY_PROPERTY +}; +MenuManager* menu_manager_new (void); +MenuManager* menu_manager_construct (GType object_type); +MenuManager* menu_manager_get_default (void); +void menu_manager_register_visible_menu (MenuManager* self, GtkMenu* menu); +gboolean menu_manager_menu_is_open (MenuManager* self); +static void menu_manager_finalize (GObject* obj); + + + +static gpointer _g_object_ref0 (gpointer self) { + return self ? g_object_ref (self) : NULL; +} + + +MenuManager* menu_manager_get_default (void) { + MenuManager* result = NULL; + if (menu_manager__menu_manager_global == NULL) { + MenuManager* _tmp0_; + menu_manager__menu_manager_global = (_tmp0_ = menu_manager_new (), _g_object_unref0 (menu_manager__menu_manager_global), _tmp0_); + } + result = _g_object_ref0 (menu_manager__menu_manager_global); + return result; +} + + +void menu_manager_register_visible_menu (MenuManager* self, GtkMenu* menu) { + gboolean _tmp0_ = FALSE; + gboolean _tmp1_ = FALSE; + GtkMenu* _tmp2_; + g_return_if_fail (self != NULL); + g_return_if_fail (menu != NULL); + if (GTK_IS_MENU (self->priv->current_menu)) { + _tmp1_ = gtk_widget_get_visible ((GtkWidget*) self->priv->current_menu) == TRUE; + } else { + _tmp1_ = FALSE; + } + if (_tmp1_) { + _tmp0_ = self->priv->current_menu != menu; + } else { + _tmp0_ = FALSE; + } + if (_tmp0_) { + gtk_menu_popdown (self->priv->current_menu); + } + self->priv->current_menu = (_tmp2_ = _g_object_ref0 (menu), _g_object_unref0 (self->priv->current_menu), _tmp2_); +} + + +gboolean menu_manager_menu_is_open (MenuManager* self) { + gboolean result = FALSE; + gboolean _tmp0_ = FALSE; + g_return_val_if_fail (self != NULL, FALSE); + if (GTK_IS_MENU (self->priv->current_menu)) { + _tmp0_ = gtk_widget_get_visible ((GtkWidget*) self->priv->current_menu) == TRUE; + } else { + _tmp0_ = FALSE; + } + if (_tmp0_) { + result = TRUE; + return result; + } + result = FALSE; + return result; +} + + +MenuManager* menu_manager_construct (GType object_type) { + MenuManager * self; + self = (MenuManager*) g_object_new (object_type, NULL); + return self; +} + + +MenuManager* menu_manager_new (void) { + return menu_manager_construct (TYPE_MENU_MANAGER); +} + + +static void menu_manager_class_init (MenuManagerClass * klass) { + menu_manager_parent_class = g_type_class_peek_parent (klass); + g_type_class_add_private (klass, sizeof (MenuManagerPrivate)); + G_OBJECT_CLASS (klass)->finalize = menu_manager_finalize; +} + + +static void menu_manager_instance_init (MenuManager * self) { + self->priv = MENU_MANAGER_GET_PRIVATE (self); +} + + +static void menu_manager_finalize (GObject* obj) { + MenuManager * self; + self = MENU_MANAGER (obj); + _g_object_unref0 (self->priv->current_menu); + G_OBJECT_CLASS (menu_manager_parent_class)->finalize (obj); +} + + +GType menu_manager_get_type (void) { + static volatile gsize menu_manager_type_id__volatile = 0; + if (g_once_init_enter (&menu_manager_type_id__volatile)) { + static const GTypeInfo g_define_type_info = { sizeof (MenuManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) menu_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MenuManager), 0, (GInstanceInitFunc) menu_manager_instance_init, NULL }; + GType menu_manager_type_id; + menu_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "MenuManager", &g_define_type_info, 0); + g_once_init_leave (&menu_manager_type_id__volatile, menu_manager_type_id); + } + return menu_manager_type_id__volatile; +} + + + + diff --git a/unity-private/panel/panel-menu-manager.vala b/unity-private/panel/panel-menu-manager.vala new file mode 100644 index 000000000..671f86ad9 --- /dev/null +++ b/unity-private/panel/panel-menu-manager.vala @@ -0,0 +1,52 @@ +/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */ +/* + * Copyright (C) 2010 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by canonical.com + * + */ + +public class MenuManager : Object +{ + private Gtk.Menu current_menu; + private static MenuManager _menu_manager_global = null; + + public static MenuManager get_default () + { + if (_menu_manager_global == null) + _menu_manager_global = new MenuManager (); + + return _menu_manager_global; + } + + public void register_visible_menu (Gtk.Menu menu) + { + if (current_menu is Gtk.Menu && (current_menu.visible == true) && (current_menu != menu)) + current_menu.popdown (); + + current_menu = menu; + } + + + public bool menu_is_open () + { + if (current_menu is Gtk.Menu && current_menu.visible == true) + { + return true; + } + return false; + } +} + diff --git a/unity-private/panel/panel-menubar.c b/unity-private/panel/panel-menubar.c new file mode 100644 index 000000000..d43a565c0 --- /dev/null +++ b/unity-private/panel/panel-menubar.c @@ -0,0 +1,210 @@ +/* panel-menubar.c generated by valac, the Vala compiler + * generated from panel-menubar.vala, do not modify */ + +/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */ +/* + * Copyright (C) 2010 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by canonical.com + * + */ + +#include <glib.h> +#include <glib-object.h> +#include <clutk/clutk.h> +#include <gtk/gtk.h> +#include <gee.h> +#include <libindicator/indicator-object.h> +#include <stdlib.h> +#include <string.h> +#include <clutter/clutter.h> + + +#define UNITY_PANEL_INDICATORS_TYPE_MENU_BAR (unity_panel_indicators_menu_bar_get_type ()) +#define UNITY_PANEL_INDICATORS_MENU_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_INDICATORS_TYPE_MENU_BAR, UnityPanelIndicatorsMenuBar)) +#define UNITY_PANEL_INDICATORS_MENU_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_INDICATORS_TYPE_MENU_BAR, UnityPanelIndicatorsMenuBarClass)) +#define UNITY_PANEL_INDICATORS_IS_MENU_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_INDICATORS_TYPE_MENU_BAR)) +#define UNITY_PANEL_INDICATORS_IS_MENU_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_INDICATORS_TYPE_MENU_BAR)) +#define UNITY_PANEL_INDICATORS_MENU_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_INDICATORS_TYPE_MENU_BAR, UnityPanelIndicatorsMenuBarClass)) + +typedef struct _UnityPanelIndicatorsMenuBar UnityPanelIndicatorsMenuBar; +typedef struct _UnityPanelIndicatorsMenuBarClass UnityPanelIndicatorsMenuBarClass; +typedef struct _UnityPanelIndicatorsMenuBarPrivate UnityPanelIndicatorsMenuBarPrivate; + +#define UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW (unity_panel_indicators_indicator_object_view_get_type ()) +#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW, UnityPanelIndicatorsIndicatorObjectView)) +#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW, UnityPanelIndicatorsIndicatorObjectViewClass)) +#define UNITY_PANEL_INDICATORS_IS_INDICATOR_OBJECT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW)) +#define UNITY_PANEL_INDICATORS_IS_INDICATOR_OBJECT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW)) +#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW, UnityPanelIndicatorsIndicatorObjectViewClass)) + +typedef struct _UnityPanelIndicatorsIndicatorObjectView UnityPanelIndicatorsIndicatorObjectView; +typedef struct _UnityPanelIndicatorsIndicatorObjectViewClass UnityPanelIndicatorsIndicatorObjectViewClass; + +#define UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL (unity_panel_indicators_indicators_model_get_type ()) +#define UNITY_PANEL_INDICATORS_INDICATORS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL, UnityPanelIndicatorsIndicatorsModel)) +#define UNITY_PANEL_INDICATORS_INDICATORS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL, UnityPanelIndicatorsIndicatorsModelClass)) +#define UNITY_PANEL_INDICATORS_IS_INDICATORS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL)) +#define UNITY_PANEL_INDICATORS_IS_INDICATORS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL)) +#define UNITY_PANEL_INDICATORS_INDICATORS_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL, UnityPanelIndicatorsIndicatorsModelClass)) + +typedef struct _UnityPanelIndicatorsIndicatorsModel UnityPanelIndicatorsIndicatorsModel; +typedef struct _UnityPanelIndicatorsIndicatorsModelClass UnityPanelIndicatorsIndicatorsModelClass; +#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) +#define _g_free0(var) (var = (g_free (var), NULL)) + +struct _UnityPanelIndicatorsMenuBar { + CtkBox parent_instance; + UnityPanelIndicatorsMenuBarPrivate * priv; +}; + +struct _UnityPanelIndicatorsMenuBarClass { + CtkBoxClass parent_class; +}; + + +static gpointer unity_panel_indicators_menu_bar_parent_class = NULL; + +GType unity_panel_indicators_menu_bar_get_type (void); +enum { + UNITY_PANEL_INDICATORS_MENU_BAR_DUMMY_PROPERTY +}; +UnityPanelIndicatorsMenuBar* unity_panel_indicators_menu_bar_new (void); +UnityPanelIndicatorsMenuBar* unity_panel_indicators_menu_bar_construct (GType object_type); +GType unity_panel_indicators_indicator_object_view_get_type (void); +static void unity_panel_indicators_menu_bar_on_menu_moved (UnityPanelIndicatorsMenuBar* self, UnityPanelIndicatorsIndicatorObjectView* object_view, GtkMenuDirectionType type); +GType unity_panel_indicators_indicators_model_get_type (void); +UnityPanelIndicatorsIndicatorsModel* unity_panel_indicators_indicators_model_get_default (void); +GeeArrayList* unity_panel_indicators_indicators_model_get_indicators (UnityPanelIndicatorsIndicatorsModel* self); +char* unity_panel_indicators_indicators_model_get_indicator_name (UnityPanelIndicatorsIndicatorsModel* self, IndicatorObject* o); +UnityPanelIndicatorsIndicatorObjectView* unity_panel_indicators_indicator_object_view_new (IndicatorObject* _object); +UnityPanelIndicatorsIndicatorObjectView* unity_panel_indicators_indicator_object_view_construct (GType object_type, IndicatorObject* _object); +static void _unity_panel_indicators_menu_bar_on_menu_moved_unity_panel_indicators_indicator_object_view_menu_moved (UnityPanelIndicatorsIndicatorObjectView* _sender, GtkMenuDirectionType type, gpointer self); +static GObject * unity_panel_indicators_menu_bar_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties); +static int _vala_strcmp0 (const char * str1, const char * str2); + + + +UnityPanelIndicatorsMenuBar* unity_panel_indicators_menu_bar_construct (GType object_type) { + UnityPanelIndicatorsMenuBar * self; + self = (UnityPanelIndicatorsMenuBar*) g_object_new (object_type, "spacing", 0, "homogeneous", FALSE, "orientation", CTK_ORIENTATION_HORIZONTAL, NULL); + return self; +} + + +UnityPanelIndicatorsMenuBar* unity_panel_indicators_menu_bar_new (void) { + return unity_panel_indicators_menu_bar_construct (UNITY_PANEL_INDICATORS_TYPE_MENU_BAR); +} + + +static void unity_panel_indicators_menu_bar_on_menu_moved (UnityPanelIndicatorsMenuBar* self, UnityPanelIndicatorsIndicatorObjectView* object_view, GtkMenuDirectionType type) { + g_return_if_fail (self != NULL); + g_return_if_fail (object_view != NULL); +} + + +static void _unity_panel_indicators_menu_bar_on_menu_moved_unity_panel_indicators_indicator_object_view_menu_moved (UnityPanelIndicatorsIndicatorObjectView* _sender, GtkMenuDirectionType type, gpointer self) { + unity_panel_indicators_menu_bar_on_menu_moved (self, _sender, type); +} + + +static GObject * unity_panel_indicators_menu_bar_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) { + GObject * obj; + GObjectClass * parent_class; + UnityPanelIndicatorsMenuBar * self; + parent_class = G_OBJECT_CLASS (unity_panel_indicators_menu_bar_parent_class); + obj = parent_class->constructor (type, n_construct_properties, construct_properties); + self = UNITY_PANEL_INDICATORS_MENU_BAR (obj); + { + UnityPanelIndicatorsIndicatorsModel* model; + GeeArrayList* indicators_list; + ClutterColor _tmp1_; + ClutterColor _tmp0_ = {0}; + ClutterRectangle* rect; + model = unity_panel_indicators_indicators_model_get_default (); + indicators_list = unity_panel_indicators_indicators_model_get_indicators (model); + { + GeeIterator* _o_it; + _o_it = gee_abstract_collection_iterator ((GeeAbstractCollection*) indicators_list); + while (TRUE) { + IndicatorObject* o; + char* name; + if (!gee_iterator_next (_o_it)) { + break; + } + o = (IndicatorObject*) gee_iterator_get (_o_it); + name = unity_panel_indicators_indicators_model_get_indicator_name (model, o); + if (_vala_strcmp0 (name, "libappmenu.so") == 0) { + UnityPanelIndicatorsIndicatorObjectView* indicator_object_view; + indicator_object_view = g_object_ref_sink (unity_panel_indicators_indicator_object_view_new (o)); + g_signal_connect_object (indicator_object_view, "menu-moved", (GCallback) _unity_panel_indicators_menu_bar_on_menu_moved_unity_panel_indicators_indicator_object_view_menu_moved, self, 0); + ctk_box_pack ((CtkBox*) self, (ClutterActor*) indicator_object_view, FALSE, TRUE); + clutter_actor_show ((ClutterActor*) indicator_object_view); + _g_object_unref0 (indicator_object_view); + _g_object_unref0 (o); + _g_free0 (name); + break; + } + _g_object_unref0 (o); + _g_free0 (name); + } + _g_object_unref0 (_o_it); + } + rect = g_object_ref_sink ((ClutterRectangle*) clutter_rectangle_new_with_color ((_tmp1_ = (_tmp0_.red = (guint8) 255, _tmp0_.green = (guint8) 0, _tmp0_.blue = (guint8) 0, _tmp0_.alpha = (guint8) 0, _tmp0_), &_tmp1_))); + ctk_box_pack ((CtkBox*) self, (ClutterActor*) rect, TRUE, TRUE); + clutter_actor_show ((ClutterActor*) rect); + _g_object_unref0 (model); + _g_object_unref0 (indicators_list); + _g_object_unref0 (rect); + } + return obj; +} + + +static void unity_panel_indicators_menu_bar_class_init (UnityPanelIndicatorsMenuBarClass * klass) { + unity_panel_indicators_menu_bar_parent_class = g_type_class_peek_parent (klass); + G_OBJECT_CLASS (klass)->constructor = unity_panel_indicators_menu_bar_constructor; +} + + +static void unity_panel_indicators_menu_bar_instance_init (UnityPanelIndicatorsMenuBar * self) { +} + + +GType unity_panel_indicators_menu_bar_get_type (void) { + static volatile gsize unity_panel_indicators_menu_bar_type_id__volatile = 0; + if (g_once_init_enter (&unity_panel_indicators_menu_bar_type_id__volatile)) { + static const GTypeInfo g_define_type_info = { sizeof (UnityPanelIndicatorsMenuBarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) unity_panel_indicators_menu_bar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UnityPanelIndicatorsMenuBar), 0, (GInstanceInitFunc) unity_panel_indicators_menu_bar_instance_init, NULL }; + GType unity_panel_indicators_menu_bar_type_id; + unity_panel_indicators_menu_bar_type_id = g_type_register_static (CTK_TYPE_BOX, "UnityPanelIndicatorsMenuBar", &g_define_type_info, 0); + g_once_init_leave (&unity_panel_indicators_menu_bar_type_id__volatile, unity_panel_indicators_menu_bar_type_id); + } + return unity_panel_indicators_menu_bar_type_id__volatile; +} + + +static int _vala_strcmp0 (const char * str1, const char * str2) { + if (str1 == NULL) { + return -(str1 != str2); + } + if (str2 == NULL) { + return str1 != str2; + } + return strcmp (str1, str2); +} + + + + diff --git a/unity-private/panel/panel-menubar.vala b/unity-private/panel/panel-menubar.vala new file mode 100644 index 000000000..70e555599 --- /dev/null +++ b/unity-private/panel/panel-menubar.vala @@ -0,0 +1,65 @@ +/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */ +/* + * Copyright (C) 2010 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by canonical.com + * + */ + +namespace Unity.Panel.Indicators +{ + public class MenuBar : Ctk.Box + { + public MenuBar () + { + Object (spacing:0, + homogeneous:false, + orientation:Ctk.Orientation.HORIZONTAL); + } + + construct + { + var model = IndicatorsModel.get_default (); + var indicators_list = model.get_indicators (); + + foreach (Indicator.Object o in indicators_list) + { + var name = model.get_indicator_name (o); + + if (name == "libappmenu.so") + { + IndicatorObjectView indicator_object_view = new IndicatorObjectView (o); + indicator_object_view.menu_moved.connect (this.on_menu_moved); + + pack (indicator_object_view, false, true); + indicator_object_view.show (); + + break; + } + } + + /* Now let's add a rect as a hill-billy expander */ + var rect = new Clutter.Rectangle.with_color ({255, 0, 0, 0}); + pack (rect, true, true); + rect.show (); + } + + private void on_menu_moved (IndicatorObjectView object_view, + Gtk.MenuDirectionType type) + { + // Todo: Open left or right indicator, or circule back to the first or last indicator + } + } +} diff --git a/unity-private/panel/panel-tray.c b/unity-private/panel/panel-tray.c index 53db873e8..bc83b8112 100644 --- a/unity-private/panel/panel-tray.c +++ b/unity-private/panel/panel-tray.c @@ -32,16 +32,16 @@ #include <math.h> -#define UNITY_PANEL_TRAY_TYPE_VIEW (unity_panel_tray_view_get_type ()) -#define UNITY_PANEL_TRAY_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_TRAY_TYPE_VIEW, UnityPanelTrayView)) -#define UNITY_PANEL_TRAY_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_TRAY_TYPE_VIEW, UnityPanelTrayViewClass)) -#define UNITY_PANEL_TRAY_IS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_TRAY_TYPE_VIEW)) -#define UNITY_PANEL_TRAY_IS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_TRAY_TYPE_VIEW)) -#define UNITY_PANEL_TRAY_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_TRAY_TYPE_VIEW, UnityPanelTrayViewClass)) - -typedef struct _UnityPanelTrayView UnityPanelTrayView; -typedef struct _UnityPanelTrayViewClass UnityPanelTrayViewClass; -typedef struct _UnityPanelTrayViewPrivate UnityPanelTrayViewPrivate; +#define UNITY_PANEL_TYPE_SYSTEM_TRAY (unity_panel_system_tray_get_type ()) +#define UNITY_PANEL_SYSTEM_TRAY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_TYPE_SYSTEM_TRAY, UnityPanelSystemTray)) +#define UNITY_PANEL_SYSTEM_TRAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_TYPE_SYSTEM_TRAY, UnityPanelSystemTrayClass)) +#define UNITY_PANEL_IS_SYSTEM_TRAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_TYPE_SYSTEM_TRAY)) +#define UNITY_PANEL_IS_SYSTEM_TRAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_TYPE_SYSTEM_TRAY)) +#define UNITY_PANEL_SYSTEM_TRAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_TYPE_SYSTEM_TRAY, UnityPanelSystemTrayClass)) + +typedef struct _UnityPanelSystemTray UnityPanelSystemTray; +typedef struct _UnityPanelSystemTrayClass UnityPanelSystemTrayClass; +typedef struct _UnityPanelSystemTrayPrivate UnityPanelSystemTrayPrivate; #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) #define UNITY_TESTING_TYPE_OBJECT_REGISTRY (unity_testing_object_registry_get_type ()) @@ -56,28 +56,28 @@ typedef struct _UnityTestingObjectRegistryClass UnityTestingObjectRegistryClass; #define _unity_testing_object_registry_unref0(var) ((var == NULL) ? NULL : (var = (unity_testing_object_registry_unref (var), NULL))) #define _g_free0(var) (var = (g_free (var), NULL)) -struct _UnityPanelTrayView { +struct _UnityPanelSystemTray { CtkBox parent_instance; - UnityPanelTrayViewPrivate * priv; + UnityPanelSystemTrayPrivate * priv; }; -struct _UnityPanelTrayViewClass { +struct _UnityPanelSystemTrayClass { CtkBoxClass parent_class; }; -struct _UnityPanelTrayViewPrivate { +struct _UnityPanelSystemTrayPrivate { UnityTrayManager* manager; ClutterStage* stage; gint n_icons; }; -static gpointer unity_panel_tray_view_parent_class = NULL; +static gpointer unity_panel_system_tray_parent_class = NULL; -GType unity_panel_tray_view_get_type (void); -#define UNITY_PANEL_TRAY_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UNITY_PANEL_TRAY_TYPE_VIEW, UnityPanelTrayViewPrivate)) +GType unity_panel_system_tray_get_type (void); +#define UNITY_PANEL_SYSTEM_TRAY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UNITY_PANEL_TYPE_SYSTEM_TRAY, UnityPanelSystemTrayPrivate)) enum { - UNITY_PANEL_TRAY_VIEW_DUMMY_PROPERTY + UNITY_PANEL_SYSTEM_TRAY_DUMMY_PROPERTY }; gpointer unity_testing_object_registry_ref (gpointer instance); void unity_testing_object_registry_unref (gpointer instance); @@ -88,33 +88,33 @@ gpointer unity_testing_value_get_object_registry (const GValue* value); GType unity_testing_object_registry_get_type (void); UnityTestingObjectRegistry* unity_testing_object_registry_get_default (void); void unity_testing_object_registry_register (UnityTestingObjectRegistry* self, const char* name, GObject* object); -UnityPanelTrayView* unity_panel_tray_view_new (void); -UnityPanelTrayView* unity_panel_tray_view_construct (GType object_type); -static gboolean unity_panel_tray_view_manage_tray_idle (UnityPanelTrayView* self); -static gboolean _unity_panel_tray_view_manage_tray_idle_gsource_func (gpointer self); -void unity_panel_tray_view_manage_stage (UnityPanelTrayView* self, ClutterStage* stage); -static gint unity_panel_tray_view_order_icons (ClutterActor* a, ClutterActor* b); -static void unity_panel_tray_view_on_tray_icon_added (UnityPanelTrayView* self, ClutterActor* icon); -static void unity_panel_tray_view_on_tray_icon_removed (UnityPanelTrayView* self, ClutterActor* icon); -static void _unity_panel_tray_view_on_tray_icon_added_unity_tray_manager_tray_icon_added (UnityTrayManager* _sender, ClutterActor* icon, gpointer self); -static void _unity_panel_tray_view_on_tray_icon_removed_unity_tray_manager_tray_icon_removed (UnityTrayManager* _sender, ClutterActor* icon, gpointer self); -static GObject * unity_panel_tray_view_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties); -static void unity_panel_tray_view_finalize (GObject* obj); - - - -UnityPanelTrayView* unity_panel_tray_view_construct (GType object_type) { - UnityPanelTrayView * self; +UnityPanelSystemTray* unity_panel_system_tray_new (void); +UnityPanelSystemTray* unity_panel_system_tray_construct (GType object_type); +static gboolean unity_panel_system_tray_manage_tray_idle (UnityPanelSystemTray* self); +static gboolean _unity_panel_system_tray_manage_tray_idle_gsource_func (gpointer self); +void unity_panel_system_tray_manage_stage (UnityPanelSystemTray* self, ClutterStage* stage); +static gint unity_panel_system_tray_order_icons (ClutterActor* a, ClutterActor* b); +static void unity_panel_system_tray_on_tray_icon_added (UnityPanelSystemTray* self, ClutterActor* icon); +static void unity_panel_system_tray_on_tray_icon_removed (UnityPanelSystemTray* self, ClutterActor* icon); +static void _unity_panel_system_tray_on_tray_icon_added_unity_tray_manager_tray_icon_added (UnityTrayManager* _sender, ClutterActor* icon, gpointer self); +static void _unity_panel_system_tray_on_tray_icon_removed_unity_tray_manager_tray_icon_removed (UnityTrayManager* _sender, ClutterActor* icon, gpointer self); +static GObject * unity_panel_system_tray_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties); +static void unity_panel_system_tray_finalize (GObject* obj); + + + +UnityPanelSystemTray* unity_panel_system_tray_construct (GType object_type) { + UnityPanelSystemTray * self; UnityTestingObjectRegistry* _tmp0_; - self = (UnityPanelTrayView*) g_object_new (object_type, "orientation", CTK_ORIENTATION_HORIZONTAL, "spacing", 12, NULL); - unity_testing_object_registry_register (_tmp0_ = unity_testing_object_registry_get_default (), "PanelTray", (GObject*) self); + self = (UnityPanelSystemTray*) g_object_new (object_type, "orientation", CTK_ORIENTATION_HORIZONTAL, "spacing", 8, NULL); + unity_testing_object_registry_register (_tmp0_ = unity_testing_object_registry_get_default (), "PanelSystemTray", (GObject*) self); _unity_testing_object_registry_unref0 (_tmp0_); return self; } -UnityPanelTrayView* unity_panel_tray_view_new (void) { - return unity_panel_tray_view_construct (UNITY_PANEL_TRAY_TYPE_VIEW); +UnityPanelSystemTray* unity_panel_system_tray_new (void) { + return unity_panel_system_tray_construct (UNITY_PANEL_TYPE_SYSTEM_TRAY); } @@ -123,21 +123,23 @@ static gpointer _g_object_ref0 (gpointer self) { } -static gboolean _unity_panel_tray_view_manage_tray_idle_gsource_func (gpointer self) { - return unity_panel_tray_view_manage_tray_idle (self); +static gboolean _unity_panel_system_tray_manage_tray_idle_gsource_func (gpointer self) { + gboolean result; + result = unity_panel_system_tray_manage_tray_idle (self); + return result; } -void unity_panel_tray_view_manage_stage (UnityPanelTrayView* self, ClutterStage* stage) { +void unity_panel_system_tray_manage_stage (UnityPanelSystemTray* self, ClutterStage* stage) { ClutterStage* _tmp0_; g_return_if_fail (self != NULL); g_return_if_fail (stage != NULL); self->priv->stage = (_tmp0_ = _g_object_ref0 (stage), _g_object_unref0 (self->priv->stage), _tmp0_); - g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, _unity_panel_tray_view_manage_tray_idle_gsource_func, g_object_ref (self), g_object_unref); + g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, _unity_panel_system_tray_manage_tray_idle_gsource_func, g_object_ref (self), g_object_unref); } -static gboolean unity_panel_tray_view_manage_tray_idle (UnityPanelTrayView* self) { +static gboolean unity_panel_system_tray_manage_tray_idle (UnityPanelSystemTray* self) { gboolean result = FALSE; char* disable_tray; g_return_val_if_fail (self != NULL, FALSE); @@ -151,7 +153,7 @@ static gboolean unity_panel_tray_view_manage_tray_idle (UnityPanelTrayView* self } -static gint unity_panel_tray_view_order_icons (ClutterActor* a, ClutterActor* b) { +static gint unity_panel_system_tray_order_icons (ClutterActor* a, ClutterActor* b) { gint result = 0; const char* stra; const char* strb; @@ -178,84 +180,84 @@ static gint unity_panel_tray_view_order_icons (ClutterActor* a, ClutterActor* b) } -static void unity_panel_tray_view_on_tray_icon_added (UnityPanelTrayView* self, ClutterActor* icon) { +static void unity_panel_system_tray_on_tray_icon_added (UnityPanelSystemTray* self, ClutterActor* icon) { g_return_if_fail (self != NULL); g_return_if_fail (icon != NULL); clutter_container_add_actor ((ClutterContainer*) self, icon); clutter_actor_set_size (icon, (float) 22, (float) 22); clutter_actor_show (icon); g_object_set_data_full ((GObject*) icon, "n_icon", (void*) g_strdup_printf ("%d", self->priv->n_icons), NULL); - ctk_box_sort_children ((CtkBox*) self, (GCompareFunc) unity_panel_tray_view_order_icons); + ctk_box_sort_children ((CtkBox*) self, (GCompareFunc) unity_panel_system_tray_order_icons); self->priv->n_icons++; } -static void unity_panel_tray_view_on_tray_icon_removed (UnityPanelTrayView* self, ClutterActor* icon) { +static void unity_panel_system_tray_on_tray_icon_removed (UnityPanelSystemTray* self, ClutterActor* icon) { g_return_if_fail (self != NULL); g_return_if_fail (icon != NULL); clutter_container_remove_actor ((ClutterContainer*) self, icon); } -static void _unity_panel_tray_view_on_tray_icon_added_unity_tray_manager_tray_icon_added (UnityTrayManager* _sender, ClutterActor* icon, gpointer self) { - unity_panel_tray_view_on_tray_icon_added (self, icon); +static void _unity_panel_system_tray_on_tray_icon_added_unity_tray_manager_tray_icon_added (UnityTrayManager* _sender, ClutterActor* icon, gpointer self) { + unity_panel_system_tray_on_tray_icon_added (self, icon); } -static void _unity_panel_tray_view_on_tray_icon_removed_unity_tray_manager_tray_icon_removed (UnityTrayManager* _sender, ClutterActor* icon, gpointer self) { - unity_panel_tray_view_on_tray_icon_removed (self, icon); +static void _unity_panel_system_tray_on_tray_icon_removed_unity_tray_manager_tray_icon_removed (UnityTrayManager* _sender, ClutterActor* icon, gpointer self) { + unity_panel_system_tray_on_tray_icon_removed (self, icon); } -static GObject * unity_panel_tray_view_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) { +static GObject * unity_panel_system_tray_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) { GObject * obj; GObjectClass * parent_class; - UnityPanelTrayView * self; - parent_class = G_OBJECT_CLASS (unity_panel_tray_view_parent_class); + UnityPanelSystemTray * self; + parent_class = G_OBJECT_CLASS (unity_panel_system_tray_parent_class); obj = parent_class->constructor (type, n_construct_properties, construct_properties); - self = UNITY_PANEL_TRAY_VIEW (obj); + self = UNITY_PANEL_SYSTEM_TRAY (obj); { UnityTrayManager* _tmp0_; self->priv->manager = (_tmp0_ = unity_tray_manager_new (), _g_object_unref0 (self->priv->manager), _tmp0_); - g_signal_connect_object (self->priv->manager, "tray-icon-added", (GCallback) _unity_panel_tray_view_on_tray_icon_added_unity_tray_manager_tray_icon_added, self, 0); - g_signal_connect_object (self->priv->manager, "tray-icon-removed", (GCallback) _unity_panel_tray_view_on_tray_icon_removed_unity_tray_manager_tray_icon_removed, self, 0); + g_signal_connect_object (self->priv->manager, "tray-icon-added", (GCallback) _unity_panel_system_tray_on_tray_icon_added_unity_tray_manager_tray_icon_added, self, 0); + g_signal_connect_object (self->priv->manager, "tray-icon-removed", (GCallback) _unity_panel_system_tray_on_tray_icon_removed_unity_tray_manager_tray_icon_removed, self, 0); } return obj; } -static void unity_panel_tray_view_class_init (UnityPanelTrayViewClass * klass) { - unity_panel_tray_view_parent_class = g_type_class_peek_parent (klass); - g_type_class_add_private (klass, sizeof (UnityPanelTrayViewPrivate)); - G_OBJECT_CLASS (klass)->constructor = unity_panel_tray_view_constructor; - G_OBJECT_CLASS (klass)->finalize = unity_panel_tray_view_finalize; +static void unity_panel_system_tray_class_init (UnityPanelSystemTrayClass * klass) { + unity_panel_system_tray_parent_class = g_type_class_peek_parent (klass); + g_type_class_add_private (klass, sizeof (UnityPanelSystemTrayPrivate)); + G_OBJECT_CLASS (klass)->constructor = unity_panel_system_tray_constructor; + G_OBJECT_CLASS (klass)->finalize = unity_panel_system_tray_finalize; } -static void unity_panel_tray_view_instance_init (UnityPanelTrayView * self) { - self->priv = UNITY_PANEL_TRAY_VIEW_GET_PRIVATE (self); +static void unity_panel_system_tray_instance_init (UnityPanelSystemTray * self) { + self->priv = UNITY_PANEL_SYSTEM_TRAY_GET_PRIVATE (self); self->priv->n_icons = 1; } -static void unity_panel_tray_view_finalize (GObject* obj) { - UnityPanelTrayView * self; - self = UNITY_PANEL_TRAY_VIEW (obj); +static void unity_panel_system_tray_finalize (GObject* obj) { + UnityPanelSystemTray * self; + self = UNITY_PANEL_SYSTEM_TRAY (obj); _g_object_unref0 (self->priv->manager); _g_object_unref0 (self->priv->stage); - G_OBJECT_CLASS (unity_panel_tray_view_parent_class)->finalize (obj); + G_OBJECT_CLASS (unity_panel_system_tray_parent_class)->finalize (obj); } -GType unity_panel_tray_view_get_type (void) { - static volatile gsize unity_panel_tray_view_type_id__volatile = 0; - if (g_once_init_enter (&unity_panel_tray_view_type_id__volatile)) { - static const GTypeInfo g_define_type_info = { sizeof (UnityPanelTrayViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) unity_panel_tray_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UnityPanelTrayView), 0, (GInstanceInitFunc) unity_panel_tray_view_instance_init, NULL }; - GType unity_panel_tray_view_type_id; - unity_panel_tray_view_type_id = g_type_register_static (CTK_TYPE_BOX, "UnityPanelTrayView", &g_define_type_info, 0); - g_once_init_leave (&unity_panel_tray_view_type_id__volatile, unity_panel_tray_view_type_id); +GType unity_panel_system_tray_get_type (void) { + static volatile gsize unity_panel_system_tray_type_id__volatile = 0; + if (g_once_init_enter (&unity_panel_system_tray_type_id__volatile)) { + static const GTypeInfo g_define_type_info = { sizeof (UnityPanelSystemTrayClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) unity_panel_system_tray_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UnityPanelSystemTray), 0, (GInstanceInitFunc) unity_panel_system_tray_instance_init, NULL }; + GType unity_panel_system_tray_type_id; + unity_panel_system_tray_type_id = g_type_register_static (CTK_TYPE_BOX, "UnityPanelSystemTray", &g_define_type_info, 0); + g_once_init_leave (&unity_panel_system_tray_type_id__volatile, unity_panel_system_tray_type_id); } - return unity_panel_tray_view_type_id__volatile; + return unity_panel_system_tray_type_id__volatile; } diff --git a/unity-private/panel/panel-tray.vala b/unity-private/panel/panel-tray.vala index dd63eb919..601c483bc 100644 --- a/unity-private/panel/panel-tray.vala +++ b/unity-private/panel/panel-tray.vala @@ -20,21 +20,21 @@ using Gee; -namespace Unity.Panel.Tray +namespace Unity.Panel { - public class View : Ctk.Box + public class SystemTray : Ctk.Box { private TrayManager manager; private Clutter.Stage stage; private int n_icons = 1; - public View () + public SystemTray () { Object (orientation:Ctk.Orientation.HORIZONTAL, - spacing:12); + spacing:8); - Unity.Testing.ObjectRegistry.get_default ().register ("PanelTray", + Unity.Testing.ObjectRegistry.get_default ().register ("PanelSystemTray", this); } diff --git a/unity-private/panel/panel-view.c b/unity-private/panel/panel-view.c index 150265fda..ac7cf8530 100644 --- a/unity-private/panel/panel-view.c +++ b/unity-private/panel/panel-view.c @@ -1,7 +1,6 @@ /* panel-view.c generated by valac, the Vala compiler * generated from panel-view.vala, do not modify */ -/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */ /* * Copyright (C) 2010 Canonical Ltd * @@ -23,15 +22,9 @@ #include <glib.h> #include <glib-object.h> -#include <stdlib.h> -#include <string.h> #include <clutk/clutk.h> #include <unity.h> -#include <gconf/gconf-client.h> #include <clutter/clutter.h> -#include <gconf/gconf.h> -#include <float.h> -#include <math.h> #include <unity-utils.h> @@ -46,15 +39,15 @@ typedef struct _UnityPanelView UnityPanelView; typedef struct _UnityPanelViewClass UnityPanelViewClass; typedef struct _UnityPanelViewPrivate UnityPanelViewPrivate; -#define UNITY_PANEL_TRAY_TYPE_VIEW (unity_panel_tray_view_get_type ()) -#define UNITY_PANEL_TRAY_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_TRAY_TYPE_VIEW, UnityPanelTrayView)) -#define UNITY_PANEL_TRAY_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_TRAY_TYPE_VIEW, UnityPanelTrayViewClass)) -#define UNITY_PANEL_TRAY_IS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_TRAY_TYPE_VIEW)) -#define UNITY_PANEL_TRAY_IS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_TRAY_TYPE_VIEW)) -#define UNITY_PANEL_TRAY_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_TRAY_TYPE_VIEW, UnityPanelTrayViewClass)) +#define UNITY_PANEL_TYPE_BACKGROUND (unity_panel_background_get_type ()) +#define UNITY_PANEL_BACKGROUND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_TYPE_BACKGROUND, UnityPanelBackground)) +#define UNITY_PANEL_BACKGROUND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_TYPE_BACKGROUND, UnityPanelBackgroundClass)) +#define UNITY_PANEL_IS_BACKGROUND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_TYPE_BACKGROUND)) +#define UNITY_PANEL_IS_BACKGROUND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_TYPE_BACKGROUND)) +#define UNITY_PANEL_BACKGROUND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_TYPE_BACKGROUND, UnityPanelBackgroundClass)) -typedef struct _UnityPanelTrayView UnityPanelTrayView; -typedef struct _UnityPanelTrayViewClass UnityPanelTrayViewClass; +typedef struct _UnityPanelBackground UnityPanelBackground; +typedef struct _UnityPanelBackgroundClass UnityPanelBackgroundClass; #define UNITY_PANEL_TYPE_HOME_BUTTON (unity_panel_home_button_get_type ()) #define UNITY_PANEL_HOME_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_TYPE_HOME_BUTTON, UnityPanelHomeButton)) @@ -66,157 +59,117 @@ typedef struct _UnityPanelTrayViewClass UnityPanelTrayViewClass; typedef struct _UnityPanelHomeButton UnityPanelHomeButton; typedef struct _UnityPanelHomeButtonClass UnityPanelHomeButtonClass; -#define UNITY_PANEL_INDICATORS_TYPE_VIEW (unity_panel_indicators_view_get_type ()) -#define UNITY_PANEL_INDICATORS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_INDICATORS_TYPE_VIEW, UnityPanelIndicatorsView)) -#define UNITY_PANEL_INDICATORS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_INDICATORS_TYPE_VIEW, UnityPanelIndicatorsViewClass)) -#define UNITY_PANEL_INDICATORS_IS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_INDICATORS_TYPE_VIEW)) -#define UNITY_PANEL_INDICATORS_IS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_INDICATORS_TYPE_VIEW)) -#define UNITY_PANEL_INDICATORS_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_INDICATORS_TYPE_VIEW, UnityPanelIndicatorsViewClass)) - -typedef struct _UnityPanelIndicatorsView UnityPanelIndicatorsView; -typedef struct _UnityPanelIndicatorsViewClass UnityPanelIndicatorsViewClass; - -#define UNITY_PLACES_CAIRO_DRAWING_TYPE_ENTRY_BACKGROUND (unity_places_cairo_drawing_entry_background_get_type ()) -#define UNITY_PLACES_CAIRO_DRAWING_ENTRY_BACKGROUND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PLACES_CAIRO_DRAWING_TYPE_ENTRY_BACKGROUND, UnityPlacesCairoDrawingEntryBackground)) -#define UNITY_PLACES_CAIRO_DRAWING_ENTRY_BACKGROUND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PLACES_CAIRO_DRAWING_TYPE_ENTRY_BACKGROUND, UnityPlacesCairoDrawingEntryBackgroundClass)) -#define UNITY_PLACES_CAIRO_DRAWING_IS_ENTRY_BACKGROUND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PLACES_CAIRO_DRAWING_TYPE_ENTRY_BACKGROUND)) -#define UNITY_PLACES_CAIRO_DRAWING_IS_ENTRY_BACKGROUND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PLACES_CAIRO_DRAWING_TYPE_ENTRY_BACKGROUND)) -#define UNITY_PLACES_CAIRO_DRAWING_ENTRY_BACKGROUND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PLACES_CAIRO_DRAWING_TYPE_ENTRY_BACKGROUND, UnityPlacesCairoDrawingEntryBackgroundClass)) - -typedef struct _UnityPlacesCairoDrawingEntryBackground UnityPlacesCairoDrawingEntryBackground; -typedef struct _UnityPlacesCairoDrawingEntryBackgroundClass UnityPlacesCairoDrawingEntryBackgroundClass; +#define UNITY_PANEL_INDICATORS_TYPE_MENU_BAR (unity_panel_indicators_menu_bar_get_type ()) +#define UNITY_PANEL_INDICATORS_MENU_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_INDICATORS_TYPE_MENU_BAR, UnityPanelIndicatorsMenuBar)) +#define UNITY_PANEL_INDICATORS_MENU_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_INDICATORS_TYPE_MENU_BAR, UnityPanelIndicatorsMenuBarClass)) +#define UNITY_PANEL_INDICATORS_IS_MENU_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_INDICATORS_TYPE_MENU_BAR)) +#define UNITY_PANEL_INDICATORS_IS_MENU_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_INDICATORS_TYPE_MENU_BAR)) +#define UNITY_PANEL_INDICATORS_MENU_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_INDICATORS_TYPE_MENU_BAR, UnityPanelIndicatorsMenuBarClass)) + +typedef struct _UnityPanelIndicatorsMenuBar UnityPanelIndicatorsMenuBar; +typedef struct _UnityPanelIndicatorsMenuBarClass UnityPanelIndicatorsMenuBarClass; + +#define UNITY_PANEL_TYPE_SYSTEM_TRAY (unity_panel_system_tray_get_type ()) +#define UNITY_PANEL_SYSTEM_TRAY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_TYPE_SYSTEM_TRAY, UnityPanelSystemTray)) +#define UNITY_PANEL_SYSTEM_TRAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_TYPE_SYSTEM_TRAY, UnityPanelSystemTrayClass)) +#define UNITY_PANEL_IS_SYSTEM_TRAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_TYPE_SYSTEM_TRAY)) +#define UNITY_PANEL_IS_SYSTEM_TRAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_TYPE_SYSTEM_TRAY)) +#define UNITY_PANEL_SYSTEM_TRAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_TYPE_SYSTEM_TRAY, UnityPanelSystemTrayClass)) + +typedef struct _UnityPanelSystemTray UnityPanelSystemTray; +typedef struct _UnityPanelSystemTrayClass UnityPanelSystemTrayClass; + +#define UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR (unity_panel_indicators_indicator_bar_get_type ()) +#define UNITY_PANEL_INDICATORS_INDICATOR_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR, UnityPanelIndicatorsIndicatorBar)) +#define UNITY_PANEL_INDICATORS_INDICATOR_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR, UnityPanelIndicatorsIndicatorBarClass)) +#define UNITY_PANEL_INDICATORS_IS_INDICATOR_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR)) +#define UNITY_PANEL_INDICATORS_IS_INDICATOR_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR)) +#define UNITY_PANEL_INDICATORS_INDICATOR_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR, UnityPanelIndicatorsIndicatorBarClass)) + +typedef struct _UnityPanelIndicatorsIndicatorBar UnityPanelIndicatorsIndicatorBar; +typedef struct _UnityPanelIndicatorsIndicatorBarClass UnityPanelIndicatorsIndicatorBarClass; #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) -#define UNITY_TESTING_TYPE_OBJECT_REGISTRY (unity_testing_object_registry_get_type ()) -#define UNITY_TESTING_OBJECT_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_TESTING_TYPE_OBJECT_REGISTRY, UnityTestingObjectRegistry)) -#define UNITY_TESTING_OBJECT_REGISTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_TESTING_TYPE_OBJECT_REGISTRY, UnityTestingObjectRegistryClass)) -#define UNITY_TESTING_IS_OBJECT_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_TESTING_TYPE_OBJECT_REGISTRY)) -#define UNITY_TESTING_IS_OBJECT_REGISTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_TESTING_TYPE_OBJECT_REGISTRY)) -#define UNITY_TESTING_OBJECT_REGISTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_TESTING_TYPE_OBJECT_REGISTRY, UnityTestingObjectRegistryClass)) - -typedef struct _UnityTestingObjectRegistry UnityTestingObjectRegistry; -typedef struct _UnityTestingObjectRegistryClass UnityTestingObjectRegistryClass; -#define _unity_testing_object_registry_unref0(var) ((var == NULL) ? NULL : (var = (unity_testing_object_registry_unref (var), NULL))) -#define _g_free0(var) ((var == NULL) ? NULL : (var = (g_free (var), NULL))) -#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL))) -#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL))) -typedef struct _UnityPlacesCairoDrawingEntryBackgroundPrivate UnityPlacesCairoDrawingEntryBackgroundPrivate; +#define UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL (unity_panel_indicators_indicators_model_get_type ()) +#define UNITY_PANEL_INDICATORS_INDICATORS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL, UnityPanelIndicatorsIndicatorsModel)) +#define UNITY_PANEL_INDICATORS_INDICATORS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL, UnityPanelIndicatorsIndicatorsModelClass)) +#define UNITY_PANEL_INDICATORS_IS_INDICATORS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL)) +#define UNITY_PANEL_INDICATORS_IS_INDICATORS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL)) +#define UNITY_PANEL_INDICATORS_INDICATORS_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL, UnityPanelIndicatorsIndicatorsModelClass)) + +typedef struct _UnityPanelIndicatorsIndicatorsModel UnityPanelIndicatorsIndicatorsModel; +typedef struct _UnityPanelIndicatorsIndicatorsModelClass UnityPanelIndicatorsIndicatorsModelClass; struct _UnityPanelView { - CtkActor parent_instance; + CtkBox parent_instance; UnityPanelViewPrivate * priv; + gboolean expanded; }; struct _UnityPanelViewClass { - CtkActorClass parent_class; + CtkBoxClass parent_class; }; struct _UnityPanelViewPrivate { UnityShell* _shell; - UnityThemeImage* rect; - UnityPanelTrayView* tray; - UnityPanelHomeButton* home; - UnityPanelIndicatorsView* indicators; - UnityThemeImage* entry_icon; - UnityEntry* entry; - UnityPlacesCairoDrawingEntryBackground* entry_background; - gint indicators_width; - GConfClient* client; - gboolean places_enabled; -}; - -struct _UnityPlacesCairoDrawingEntryBackground { - CtkBin parent_instance; - UnityPlacesCairoDrawingEntryBackgroundPrivate * priv; - gint Width; - gint Height; - ClutterCairoTexture* cairotxt; -}; - -struct _UnityPlacesCairoDrawingEntryBackgroundClass { - CtkBinClass parent_class; + UnityPanelBackground* bground; + UnityPanelHomeButton* home_button; + UnityPanelIndicatorsMenuBar* menu_bar; + UnityPanelSystemTray* system_tray; + UnityPanelIndicatorsIndicatorBar* indicator_bar; }; -extern gboolean* unity_panel_search_entry_has_focus; -gboolean* unity_panel_search_entry_has_focus = NULL; static gpointer unity_panel_view_parent_class = NULL; #define UNITY_PANEL_PANEL_HEIGHT 24 -#define UNITY_PANEL_SEARCH_TEMPLATE "xdg-open http://search.yahoo.com/search?p=%s&fr=ubuntu&ei=UTF-8" -#define UNITY_PANEL_SEARCH_HINT "Yahoo!" +#define UNITY_PANEL_search_entry_has_focus FALSE GType unity_panel_view_get_type (void); -GType unity_panel_tray_view_get_type (void); +GType unity_panel_background_get_type (void); GType unity_panel_home_button_get_type (void); -GType unity_panel_indicators_view_get_type (void); -GType unity_places_cairo_drawing_entry_background_get_type (void); +GType unity_panel_indicators_menu_bar_get_type (void); +GType unity_panel_system_tray_get_type (void); +GType unity_panel_indicators_indicator_bar_get_type (void); #define UNITY_PANEL_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UNITY_PANEL_TYPE_VIEW, UnityPanelViewPrivate)) enum { UNITY_PANEL_VIEW_DUMMY_PROPERTY, UNITY_PANEL_VIEW_SHELL }; -void unity_panel_tray_view_manage_stage (UnityPanelTrayView* self, ClutterStage* stage); -UnityShell* unity_panel_view_get_shell (UnityPanelView* self); -gpointer unity_testing_object_registry_ref (gpointer instance); -void unity_testing_object_registry_unref (gpointer instance); -GParamSpec* unity_testing_param_spec_object_registry (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags); -void unity_testing_value_set_object_registry (GValue* value, gpointer v_object); -void unity_testing_value_take_object_registry (GValue* value, gpointer v_object); -gpointer unity_testing_value_get_object_registry (const GValue* value); -GType unity_testing_object_registry_get_type (void); -UnityTestingObjectRegistry* unity_testing_object_registry_get_default (void); -void unity_testing_object_registry_register (UnityTestingObjectRegistry* self, const char* name, GObject* object); +void unity_panel_system_tray_manage_stage (UnityPanelSystemTray* self, ClutterStage* stage); UnityPanelView* unity_panel_view_new (UnityShell* shell); UnityPanelView* unity_panel_view_construct (GType object_type, UnityShell* shell); -static void unity_panel_view_on_home_clicked (UnityPanelView* self); -static gboolean* _bool_dup (gboolean* self); -static void unity_panel_view_on_entry_focus_in (UnityPanelView* self); -static void unity_panel_view_on_entry_focus_out (UnityPanelView* self); -static void unity_panel_view_on_search_hint_changed (UnityPanelView* self); -static void _unity_panel_view_on_search_hint_changed_gconf_client_notify_func (GConfClient* client, guint cnxn_id, GConfEntry* entry, gpointer self); -static char* unity_panel_view_get_search_hint (UnityPanelView* self); -static void unity_panel_view_on_entry_activated (UnityPanelView* self); -void unity_places_cairo_drawing_entry_background_create_search_entry_background (UnityPlacesCairoDrawingEntryBackground* self, gint W, gint H); -static void unity_panel_view_real_allocate (ClutterActor* base, const ClutterActorBox* box, ClutterAllocationFlags flags); -static void unity_panel_view_real_paint (ClutterActor* base); -static void unity_panel_view_real_pick (ClutterActor* base, const ClutterColor* color); -static void unity_panel_view_real_map (ClutterActor* base); -static void unity_panel_view_real_unmap (ClutterActor* base); gint unity_panel_view_get_indicators_width (UnityPanelView* self); +void unity_panel_view_set_expanded (UnityPanelView* self, gboolean _expanded); +gint unity_panel_view_get_panel_height (UnityPanelView* self); void unity_panel_view_set_indicator_mode (UnityPanelView* self, gboolean mode); +UnityShell* unity_panel_view_get_shell (UnityPanelView* self); static void unity_panel_view_set_shell (UnityPanelView* self, UnityShell* value); -UnityPanelIndicatorsView* unity_panel_indicators_view_new (void); -UnityPanelIndicatorsView* unity_panel_indicators_view_construct (GType object_type); -UnityPanelTrayView* unity_panel_tray_view_new (void); -UnityPanelTrayView* unity_panel_tray_view_construct (GType object_type); +GType unity_panel_indicators_indicators_model_get_type (void); +UnityPanelIndicatorsIndicatorsModel* unity_panel_indicators_indicators_model_get_default (void); +UnityPanelBackground* unity_panel_background_new (void); +UnityPanelBackground* unity_panel_background_construct (GType object_type); UnityPanelHomeButton* unity_panel_home_button_new (UnityShell* shell); UnityPanelHomeButton* unity_panel_home_button_construct (GType object_type, UnityShell* shell); -static void _unity_panel_view_on_home_clicked_unity_panel_home_button_clicked (UnityPanelHomeButton* _sender, guint32 time_, gpointer self); -UnityPlacesCairoDrawingEntryBackground* unity_places_cairo_drawing_entry_background_new (void); -UnityPlacesCairoDrawingEntryBackground* unity_places_cairo_drawing_entry_background_construct (GType object_type); -static gboolean _lambda4_ (ClutterEvent* e, UnityPanelView* self); -static gboolean __lambda4__clutter_actor_button_press_event (ClutterActor* _sender, ClutterEvent* event, gpointer self); -static void _unity_panel_view_on_entry_activated_clutter_text_activate (ClutterText* _sender, gpointer self); -static void _unity_panel_view_on_entry_focus_in_clutter_actor_key_focus_in (ClutterActor* _sender, gpointer self); -static void _unity_panel_view_on_entry_focus_out_clutter_actor_key_focus_out (ClutterActor* _sender, gpointer self); +UnityPanelIndicatorsMenuBar* unity_panel_indicators_menu_bar_new (void); +UnityPanelIndicatorsMenuBar* unity_panel_indicators_menu_bar_construct (GType object_type); +UnityPanelSystemTray* unity_panel_system_tray_new (void); +UnityPanelSystemTray* unity_panel_system_tray_construct (GType object_type); +UnityPanelIndicatorsIndicatorBar* unity_panel_indicators_indicator_bar_new (void); +UnityPanelIndicatorsIndicatorBar* unity_panel_indicators_indicator_bar_construct (GType object_type); static GObject * unity_panel_view_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties); static void unity_panel_view_finalize (GObject* obj); static void unity_panel_view_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); static void unity_panel_view_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec); -static int _vala_strcmp0 (const char * str1, const char * str2); UnityPanelView* unity_panel_view_construct (GType object_type, UnityShell* shell) { UnityPanelView * self; ClutterStage* _tmp0_; - UnityTestingObjectRegistry* _tmp1_; g_return_val_if_fail (shell != NULL, NULL); - self = (UnityPanelView*) g_object_new (object_type, "shell", shell, "reactive", FALSE, NULL); - unity_panel_tray_view_manage_stage (self->priv->tray, _tmp0_ = unity_shell_get_stage (self->priv->_shell)); + self = (UnityPanelView*) g_object_new (object_type, "shell", shell, "reactive", FALSE, "orientation", CTK_ORIENTATION_HORIZONTAL, "homogeneous", FALSE, "spacing", 0, NULL); + unity_panel_system_tray_manage_stage (self->priv->system_tray, _tmp0_ = unity_shell_get_stage (shell)); _g_object_unref0 (_tmp0_); - unity_testing_object_registry_register (_tmp1_ = unity_testing_object_registry_get_default (), "PanelView", (GObject*) self); - _unity_testing_object_registry_unref0 (_tmp1_); return self; } @@ -226,464 +179,30 @@ UnityPanelView* unity_panel_view_new (UnityShell* shell) { } -static void unity_panel_view_on_home_clicked (UnityPanelView* self) { - g_return_if_fail (self != NULL); - unity_shell_show_window_picker (unity_global_shell); -} - - -static gboolean* _bool_dup (gboolean* self) { - gboolean* dup; - dup = g_new0 (gboolean, 1); - memcpy (dup, self, sizeof (gboolean)); - return dup; -} - - -static gpointer __bool_dup0 (gpointer self) { - return self ? _bool_dup (self) : NULL; -} - - -static void unity_panel_view_on_entry_focus_in (UnityPanelView* self) { - gboolean* _tmp1_; - gboolean _tmp0_; - g_return_if_fail (self != NULL); - unity_panel_search_entry_has_focus = (_tmp1_ = __bool_dup0 ((_tmp0_ = TRUE, &_tmp0_)), _g_free0 (unity_panel_search_entry_has_focus), _tmp1_); -} - - -static void unity_panel_view_on_entry_focus_out (UnityPanelView* self) { - gboolean* _tmp1_; - gboolean _tmp0_; - g_return_if_fail (self != NULL); - unity_panel_search_entry_has_focus = (_tmp1_ = __bool_dup0 ((_tmp0_ = FALSE, &_tmp0_)), _g_free0 (unity_panel_search_entry_has_focus), _tmp1_); -} - - -static gpointer _g_object_ref0 (gpointer self) { - return self ? g_object_ref (self) : NULL; -} - - -static void _unity_panel_view_on_search_hint_changed_gconf_client_notify_func (GConfClient* client, guint cnxn_id, GConfEntry* entry, gpointer self) { - unity_panel_view_on_search_hint_changed (self); -} - - -static char* unity_panel_view_get_search_hint (UnityPanelView* self) { - char* result = NULL; - GError * _inner_error_; - char* hint; - GConfClient* _tmp0_; - g_return_val_if_fail (self != NULL, NULL); - _inner_error_ = NULL; - hint = g_strdup (""); - self->priv->client = (_tmp0_ = _g_object_ref0 (gconf_client_get_default ()), _g_object_unref0 (self->priv->client), _tmp0_); - { - char* _tmp1_; - char* _tmp2_; - gboolean _tmp3_ = FALSE; - _tmp1_ = gconf_client_get_string (self->priv->client, "/desktop/unity/panel/search_hint", &_inner_error_); - if (_inner_error_ != NULL) { - goto __catch3_g_error; - } - hint = (_tmp2_ = _tmp1_, _g_free0 (hint), _tmp2_); - { - gconf_client_add_dir (self->priv->client, "/desktop/unity/panel", GCONF_CLIENT_PRELOAD_NONE, &_inner_error_); - if (_inner_error_ != NULL) { - goto __catch4_g_error; - } - gconf_client_notify_add (self->priv->client, "/desktop/unity/panel/search_hint", _unity_panel_view_on_search_hint_changed_gconf_client_notify_func, g_object_ref (self), g_object_unref, &_inner_error_); - if (_inner_error_ != NULL) { - goto __catch4_g_error; - } - } - goto __finally4; - __catch4_g_error: - { - GError * e; - e = _inner_error_; - _inner_error_ = NULL; - { - g_warning ("panel-view.vala:143: Unable to monitor gconf for search hint changes: " \ -"%s", e->message); - _g_error_free0 (e); - } - } - __finally4: - if (_inner_error_ != NULL) { - goto __catch3_g_error; - } - if (_vala_strcmp0 (hint, "") == 0) { - _tmp3_ = TRUE; - } else { - _tmp3_ = hint == NULL; - } - if (_tmp3_) { - char* _tmp4_; - hint = (_tmp4_ = g_strdup (UNITY_PANEL_SEARCH_HINT), _g_free0 (hint), _tmp4_); - } - } - goto __finally3; - __catch3_g_error: - { - GError * e; - e = _inner_error_; - _inner_error_ = NULL; - { - char* _tmp5_; - hint = (_tmp5_ = g_strdup (UNITY_PANEL_SEARCH_HINT), _g_free0 (hint), _tmp5_); - _g_error_free0 (e); - } - } - __finally3: - if (_inner_error_ != NULL) { - _g_free0 (hint); - g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); - g_clear_error (&_inner_error_); - return NULL; - } - result = hint; +gint unity_panel_view_get_indicators_width (UnityPanelView* self) { + gint result = 0; + g_return_val_if_fail (self != NULL, 0); + result = (gint) clutter_actor_get_width ((ClutterActor*) self->priv->indicator_bar); return result; } -static void unity_panel_view_on_search_hint_changed (UnityPanelView* self) { - GError * _inner_error_; - g_return_if_fail (self != NULL); - _inner_error_ = NULL; - { - char* hint; - hint = gconf_client_get_string (self->priv->client, "/desktop/unity/panel/search_hint", &_inner_error_); - if (_inner_error_ != NULL) { - goto __catch5_g_error; - } - unity_entry_set_static_text (self->priv->entry, hint); - _g_free0 (hint); - } - goto __finally5; - __catch5_g_error: - { - GError * e; - e = _inner_error_; - _inner_error_ = NULL; - { - g_warning ("panel-view.vala:168: Unable to get search hint: %s", e->message); - _g_error_free0 (e); - } - } - __finally5: - if (_inner_error_ != NULL) { - g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); - g_clear_error (&_inner_error_); - return; - } -} - - -static char* string_replace (const char* self, const char* old, const char* replacement) { - char* result = NULL; - GError * _inner_error_; - g_return_val_if_fail (self != NULL, NULL); - g_return_val_if_fail (old != NULL, NULL); - g_return_val_if_fail (replacement != NULL, NULL); - _inner_error_ = NULL; - { - char* _tmp0_; - GRegex* _tmp1_; - GRegex* regex; - char* _tmp2_; - regex = (_tmp1_ = g_regex_new (_tmp0_ = g_regex_escape_string (old, -1), 0, 0, &_inner_error_), _g_free0 (_tmp0_), _tmp1_); - if (_inner_error_ != NULL) { - if (_inner_error_->domain == G_REGEX_ERROR) { - goto __catch7_g_regex_error; - } - g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); - g_clear_error (&_inner_error_); - return NULL; - } - _tmp2_ = g_regex_replace_literal (regex, self, (gssize) (-1), 0, replacement, 0, &_inner_error_); - if (_inner_error_ != NULL) { - _g_regex_unref0 (regex); - if (_inner_error_->domain == G_REGEX_ERROR) { - goto __catch7_g_regex_error; - } - _g_regex_unref0 (regex); - g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); - g_clear_error (&_inner_error_); - return NULL; - } - result = _tmp2_; - _g_regex_unref0 (regex); - return result; - } - goto __finally7; - __catch7_g_regex_error: - { - GError * e; - e = _inner_error_; - _inner_error_ = NULL; - { - g_assert_not_reached (); - _g_error_free0 (e); - } - } - __finally7: - if (_inner_error_ != NULL) { - g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); - g_clear_error (&_inner_error_); - return NULL; - } -} - - -static void unity_panel_view_on_entry_activated (UnityPanelView* self) { - GError * _inner_error_; - char* template; - GConfClient* client; - char* _tmp5_; - char* _tmp6_; - char* command; +void unity_panel_view_set_expanded (UnityPanelView* self, gboolean _expanded) { g_return_if_fail (self != NULL); - _inner_error_ = NULL; - template = g_strdup (""); - client = _g_object_ref0 (gconf_client_get_default ()); - { - char* _tmp0_; - char* _tmp1_; - gboolean _tmp2_ = FALSE; - _tmp0_ = gconf_client_get_string (client, "/desktop/unity/panel/search_template", &_inner_error_); - if (_inner_error_ != NULL) { - goto __catch6_g_error; - } - template = (_tmp1_ = _tmp0_, _g_free0 (template), _tmp1_); - if (_vala_strcmp0 (template, "") == 0) { - _tmp2_ = TRUE; - } else { - _tmp2_ = template == NULL; - } - if (_tmp2_) { - char* _tmp3_; - template = (_tmp3_ = g_strdup (UNITY_PANEL_SEARCH_TEMPLATE), _g_free0 (template), _tmp3_); - } - } - goto __finally6; - __catch6_g_error: - { - GError * e; - e = _inner_error_; - _inner_error_ = NULL; - { - char* _tmp4_; - template = (_tmp4_ = g_strdup (UNITY_PANEL_SEARCH_TEMPLATE), _g_free0 (template), _tmp4_); - _g_error_free0 (e); - } - } - __finally6: - if (_inner_error_ != NULL) { - _g_free0 (template); - _g_object_unref0 (client); - g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); - g_clear_error (&_inner_error_); - return; - } - command = (_tmp6_ = string_replace (template, "%s", _tmp5_ = g_uri_escape_string (clutter_text_get_text ((ClutterText*) self->priv->entry), "", TRUE)), _g_free0 (_tmp5_), _tmp6_); - { - g_spawn_command_line_async (command, &_inner_error_); - if (_inner_error_ != NULL) { - goto __catch8_g_error; - } - } - goto __finally8; - __catch8_g_error: - { - GError * e; - e = _inner_error_; - _inner_error_ = NULL; - { - g_warning ("panel-view.vala:198: Unable to search for '%s': %s", clutter_text_get_text ((ClutterText*) self->priv->entry), e->message); - _g_error_free0 (e); - } - } - __finally8: - if (_inner_error_ != NULL) { - _g_free0 (template); - _g_object_unref0 (client); - _g_free0 (command); - g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); - g_clear_error (&_inner_error_); - return; - } - _g_free0 (template); - _g_object_unref0 (client); - _g_free0 (command); -} - - -static void unity_panel_view_real_allocate (ClutterActor* base, const ClutterActorBox* box, ClutterAllocationFlags flags) { - UnityPanelView * self; - ClutterActorBox _tmp0_ = {0}; - ClutterActorBox child_box; - float width = 0.0F; - float child_width = 0.0F; - float i_width = 0.0F; - self = (UnityPanelView*) base; - child_box = (_tmp0_.x1 = (float) 0, _tmp0_.y1 = (float) 0, _tmp0_.x2 = (*box).x2 - (*box).x1, _tmp0_.y2 = (*box).y2 - (*box).y1, _tmp0_); - CLUTTER_ACTOR_CLASS (unity_panel_view_parent_class)->allocate ((ClutterActor*) CTK_ACTOR (self), box, flags); - width = (*box).x2 - (*box).x1; - clutter_actor_set_clip ((ClutterActor*) self->priv->rect, (float) 0, (float) 0, width, (*box).y2 - (*box).y1); - child_box.y2 = child_box.y2 + 3.0f; - clutter_actor_allocate ((ClutterActor*) self->priv->rect, &child_box, flags); - child_box.x1 = (float) 0; - child_box.x2 = (float) 60; - child_box.y1 = (float) 0; - child_box.y2 = (float) UNITY_PANEL_PANEL_HEIGHT; - clutter_actor_allocate ((ClutterActor*) self->priv->home, &child_box, flags); - if (self->priv->places_enabled == FALSE) { - gboolean _tmp1_ = FALSE; - child_box.x1 = floorf (child_box.x2 + 12); - child_box.x2 = floorf (child_box.x1 + 170); - child_box.y1 = floorf ((float) 2); - child_box.y2 = floorf ((float) UNITY_PANEL_PANEL_HEIGHT); - clutter_actor_allocate ((ClutterActor*) self->priv->entry_background, &child_box, flags); - if (self->priv->entry_background->Width != ((gint) (child_box.x2 - child_box.x1))) { - _tmp1_ = clutter_actor_get_height ((ClutterActor*) self->priv->entry_background) != ((gint) ((child_box.y2 - child_box.y1) - 2)); - } else { - _tmp1_ = FALSE; - } - if (_tmp1_) { - unity_places_cairo_drawing_entry_background_create_search_entry_background (self->priv->entry_background, (gint) (child_box.x2 - child_box.x1), (gint) ((child_box.y2 - child_box.y1) - 2)); - } - child_box.x1 = child_box.x1 + ((float) 6); - child_box.x2 = child_box.x1 + 16; - child_box.y1 = floorf ((UNITY_PANEL_PANEL_HEIGHT - 16) / 2.0f); - child_box.y2 = child_box.y1 + 16; - clutter_actor_allocate ((ClutterActor*) self->priv->entry_icon, &child_box, flags); - child_box.x1 = child_box.x2 + 4; - child_box.x2 = (child_box.x1 + 150) - 16; - child_box.y1 = (float) 9; - child_box.y2 = (float) 15; - clutter_actor_allocate ((ClutterActor*) self->priv->entry, &child_box, flags); - child_box.y1 = (float) 0; - child_box.y2 = (float) UNITY_PANEL_PANEL_HEIGHT; - } - clutter_actor_get_preferred_width ((ClutterActor*) self->priv->indicators, (float) UNITY_PANEL_PANEL_HEIGHT, &child_width, &child_width); - child_box.x1 = width - child_width; - child_box.x2 = width; - clutter_actor_allocate ((ClutterActor*) self->priv->indicators, &child_box, flags); - width = width - (child_width + 12); - clutter_actor_get_preferred_width ((ClutterActor*) self->priv->tray, (float) UNITY_PANEL_PANEL_HEIGHT, &child_width, &child_width); - child_box.x1 = width - child_width; - child_box.x2 = width; - clutter_actor_allocate ((ClutterActor*) self->priv->tray, &child_box, flags); - width = width - (child_box.x2 - child_box.x1); - i_width = ((*box).x2 - (*box).x1) - width; - if (self->priv->indicators_width != ((gint) i_width)) { - self->priv->indicators_width = (gint) i_width; - g_signal_emit_by_name (self->priv->_shell, "indicators-changed", self->priv->indicators_width); - } -} - - -static void unity_panel_view_real_paint (ClutterActor* base) { - UnityPanelView * self; - self = (UnityPanelView*) base; - CLUTTER_ACTOR_CLASS (unity_panel_view_parent_class)->paint ((ClutterActor*) CTK_ACTOR (self)); - clutter_actor_paint ((ClutterActor*) self->priv->rect); - clutter_actor_paint ((ClutterActor*) self->priv->tray); - clutter_actor_paint ((ClutterActor*) self->priv->home); - clutter_actor_paint ((ClutterActor*) self->priv->indicators); - if (self->priv->places_enabled == TRUE) { - return; - } - clutter_actor_paint ((ClutterActor*) self->priv->entry_background); - clutter_actor_paint ((ClutterActor*) self->priv->entry_icon); - clutter_actor_paint ((ClutterActor*) self->priv->entry); -} - - -static void unity_panel_view_real_pick (ClutterActor* base, const ClutterColor* color) { - UnityPanelView * self; - self = (UnityPanelView*) base; - CLUTTER_ACTOR_CLASS (unity_panel_view_parent_class)->pick ((ClutterActor*) CTK_ACTOR (self), color); - clutter_actor_paint ((ClutterActor*) self->priv->tray); - clutter_actor_paint ((ClutterActor*) self->priv->home); - clutter_actor_paint ((ClutterActor*) self->priv->indicators); - if (self->priv->places_enabled == TRUE) { - return; - } - clutter_actor_paint ((ClutterActor*) self->priv->entry_background); - clutter_actor_paint ((ClutterActor*) self->priv->entry_icon); - clutter_actor_paint ((ClutterActor*) self->priv->entry); -} - - -static void unity_panel_view_real_map (ClutterActor* base) { - UnityPanelView * self; - self = (UnityPanelView*) base; - CLUTTER_ACTOR_CLASS (unity_panel_view_parent_class)->map ((ClutterActor*) CTK_ACTOR (self)); - clutter_actor_map ((ClutterActor*) self->priv->rect); - clutter_actor_map ((ClutterActor*) self->priv->tray); - clutter_actor_map ((ClutterActor*) self->priv->home); - clutter_actor_map ((ClutterActor*) self->priv->indicators); - if (self->priv->places_enabled == TRUE) { - return; - } - clutter_actor_map ((ClutterActor*) self->priv->entry_background); - clutter_actor_map ((ClutterActor*) self->priv->entry_icon); - clutter_actor_map ((ClutterActor*) self->priv->entry); -} - - -static void unity_panel_view_real_unmap (ClutterActor* base) { - UnityPanelView * self; - self = (UnityPanelView*) base; - CLUTTER_ACTOR_CLASS (unity_panel_view_parent_class)->unmap ((ClutterActor*) CTK_ACTOR (self)); - clutter_actor_unmap ((ClutterActor*) self->priv->rect); - clutter_actor_unmap ((ClutterActor*) self->priv->tray); - clutter_actor_unmap ((ClutterActor*) self->priv->home); - clutter_actor_unmap ((ClutterActor*) self->priv->indicators); - if (self->priv->places_enabled == TRUE) { - return; - } - clutter_actor_unmap ((ClutterActor*) self->priv->entry_background); - clutter_actor_unmap ((ClutterActor*) self->priv->entry_icon); - clutter_actor_unmap ((ClutterActor*) self->priv->entry); + self->expanded = _expanded; } -gint unity_panel_view_get_indicators_width (UnityPanelView* self) { +gint unity_panel_view_get_panel_height (UnityPanelView* self) { gint result = 0; g_return_val_if_fail (self != NULL, 0); - result = (gint) self->priv->indicators_width; + result = UNITY_PANEL_PANEL_HEIGHT; return result; } void unity_panel_view_set_indicator_mode (UnityPanelView* self, gboolean mode) { - float x = 0.0F; - float _tmp0_ = 0.0F; - float _tmp1_ = 0.0F; - gint _tmp2_ = 0; g_return_if_fail (self != NULL); - if (mode) { - _tmp0_ = clutter_actor_get_width ((ClutterActor*) self) - unity_panel_view_get_indicators_width (self); - } else { - _tmp0_ = (float) 0; - } - x = _tmp0_; - if (mode) { - _tmp1_ = (float) unity_panel_view_get_indicators_width (self); - } else { - _tmp1_ = clutter_actor_get_width ((ClutterActor*) self); - } - if (mode) { - _tmp2_ = UNITY_PANEL_PANEL_HEIGHT - 1; - } else { - _tmp2_ = UNITY_PANEL_PANEL_HEIGHT; - } - clutter_actor_set_clip ((ClutterActor*) self->priv->rect, x, (float) 0, _tmp1_, (float) _tmp2_); } @@ -695,6 +214,11 @@ UnityShell* unity_panel_view_get_shell (UnityPanelView* self) { } +static gpointer _g_object_ref0 (gpointer self) { + return self ? g_object_ref (self) : NULL; +} + + static void unity_panel_view_set_shell (UnityPanelView* self, UnityShell* value) { UnityShell* _tmp0_; g_return_if_fail (self != NULL); @@ -703,39 +227,6 @@ static void unity_panel_view_set_shell (UnityPanelView* self, UnityShell* value) } -static void _unity_panel_view_on_home_clicked_unity_panel_home_button_clicked (UnityPanelHomeButton* _sender, guint32 time_, gpointer self) { - unity_panel_view_on_home_clicked (self); -} - - -static gboolean _lambda4_ (ClutterEvent* e, UnityPanelView* self) { - gboolean result = FALSE; - clutter_actor_event ((ClutterActor*) self->priv->entry, e, FALSE); - clutter_actor_grab_key_focus ((ClutterActor*) self->priv->entry); - unity_shell_grab_keyboard (unity_global_shell, TRUE, (*e).button.time); -} - - -static gboolean __lambda4__clutter_actor_button_press_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return _lambda4_ (event, self); -} - - -static void _unity_panel_view_on_entry_activated_clutter_text_activate (ClutterText* _sender, gpointer self) { - unity_panel_view_on_entry_activated (self); -} - - -static void _unity_panel_view_on_entry_focus_in_clutter_actor_key_focus_in (ClutterActor* _sender, gpointer self) { - unity_panel_view_on_entry_focus_in (self); -} - - -static void _unity_panel_view_on_entry_focus_out_clutter_actor_key_focus_out (ClutterActor* _sender, gpointer self) { - unity_panel_view_on_entry_focus_out (self); -} - - static GObject * unity_panel_view_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) { GObject * obj; GObjectClass * parent_class; @@ -744,51 +235,30 @@ static GObject * unity_panel_view_constructor (GType type, guint n_construct_pro obj = parent_class->constructor (type, n_construct_properties, construct_properties); self = UNITY_PANEL_VIEW (obj); { - UnityThemeImage* _tmp0_; - UnityPanelIndicatorsView* _tmp1_; - UnityPanelTrayView* _tmp2_; - UnityPanelHomeButton* _tmp3_; + UnityPanelIndicatorsIndicatorsModel* _tmp0_; + UnityPanelBackground* _tmp1_; + UnityPanelHomeButton* _tmp2_; + UnityPanelIndicatorsMenuBar* _tmp3_; + UnityPanelSystemTray* _tmp4_; + UnityPanelIndicatorsIndicatorBar* _tmp5_; START_FUNCTION (); - self->priv->places_enabled = g_getenv ("UNITY_ENABLE_PLACES") != NULL; - self->priv->rect = (_tmp0_ = g_object_ref_sink (unity_theme_image_new ("panel_background")), _g_object_unref0 (self->priv->rect), _tmp0_); - clutter_texture_set_repeat ((ClutterTexture*) self->priv->rect, TRUE, FALSE); - clutter_actor_set_parent ((ClutterActor*) self->priv->rect, (ClutterActor*) self); - clutter_actor_show ((ClutterActor*) self->priv->rect); - self->priv->indicators = (_tmp1_ = g_object_ref_sink (unity_panel_indicators_view_new ()), _g_object_unref0 (self->priv->indicators), _tmp1_); - clutter_actor_set_parent ((ClutterActor*) self->priv->indicators, (ClutterActor*) self); - clutter_actor_show ((ClutterActor*) self->priv->indicators); - self->priv->tray = (_tmp2_ = g_object_ref_sink (unity_panel_tray_view_new ()), _g_object_unref0 (self->priv->tray), _tmp2_); - clutter_actor_set_parent ((ClutterActor*) self->priv->tray, (ClutterActor*) self); - clutter_actor_show ((ClutterActor*) self->priv->tray); - self->priv->home = (_tmp3_ = g_object_ref_sink (unity_panel_home_button_new (self->priv->_shell)), _g_object_unref0 (self->priv->home), _tmp3_); - clutter_actor_set_parent ((ClutterActor*) self->priv->home, (ClutterActor*) self); - clutter_actor_show ((ClutterActor*) self->priv->home); - g_signal_connect_object (self->priv->home, "clicked", (GCallback) _unity_panel_view_on_home_clicked_unity_panel_home_button_clicked, self, 0); - if (self->priv->places_enabled == FALSE) { - UnityPlacesCairoDrawingEntryBackground* _tmp4_; - UnityThemeImage* _tmp5_; - UnityEntry* _tmp6_; - char* _tmp7_; - gboolean* _tmp9_; - gboolean _tmp8_; - self->priv->entry_background = (_tmp4_ = g_object_ref_sink (unity_places_cairo_drawing_entry_background_new ()), _g_object_unref0 (self->priv->entry_background), _tmp4_); - clutter_actor_set_parent ((ClutterActor*) self->priv->entry_background, (ClutterActor*) self); - clutter_actor_show ((ClutterActor*) self->priv->entry_background); - self->priv->entry_icon = (_tmp5_ = g_object_ref_sink (unity_theme_image_new ("search_field")), _g_object_unref0 (self->priv->entry_icon), _tmp5_); - clutter_actor_set_reactive ((ClutterActor*) self->priv->entry_icon, TRUE); - g_signal_connect_object ((ClutterActor*) self->priv->entry_icon, "button-press-event", (GCallback) __lambda4__clutter_actor_button_press_event, self, 0); - clutter_actor_set_parent ((ClutterActor*) self->priv->entry_icon, (ClutterActor*) self); - clutter_actor_show ((ClutterActor*) self->priv->entry_icon); - self->priv->entry = (_tmp6_ = g_object_ref_sink (unity_entry_new ("")), _g_object_unref0 (self->priv->entry), _tmp6_); - unity_entry_set_static_text (self->priv->entry, _tmp7_ = unity_panel_view_get_search_hint (self)); - _g_free0 (_tmp7_); - clutter_actor_set_parent ((ClutterActor*) self->priv->entry, (ClutterActor*) self); - clutter_actor_show ((ClutterActor*) self->priv->entry); - g_signal_connect_object ((ClutterText*) self->priv->entry, "activate", (GCallback) _unity_panel_view_on_entry_activated_clutter_text_activate, self, 0); - g_signal_connect_object ((ClutterActor*) self->priv->entry, "key-focus-in", (GCallback) _unity_panel_view_on_entry_focus_in_clutter_actor_key_focus_in, self, 0); - g_signal_connect_object ((ClutterActor*) self->priv->entry, "key-focus-out", (GCallback) _unity_panel_view_on_entry_focus_out_clutter_actor_key_focus_out, self, 0); - unity_panel_search_entry_has_focus = (_tmp9_ = __bool_dup0 ((_tmp8_ = FALSE, &_tmp8_)), _g_free0 (unity_panel_search_entry_has_focus), _tmp9_); - } + _tmp0_ = unity_panel_indicators_indicators_model_get_default (); + _g_object_unref0 (_tmp0_); + self->priv->bground = (_tmp1_ = g_object_ref_sink (unity_panel_background_new ()), _g_object_unref0 (self->priv->bground), _tmp1_); + ctk_actor_set_background ((CtkActor*) self, (ClutterActor*) self->priv->bground); + clutter_actor_show ((ClutterActor*) self->priv->bground); + self->priv->home_button = (_tmp2_ = g_object_ref_sink (unity_panel_home_button_new (self->priv->_shell)), _g_object_unref0 (self->priv->home_button), _tmp2_); + ctk_box_pack ((CtkBox*) self, (ClutterActor*) self->priv->home_button, FALSE, TRUE); + clutter_actor_show ((ClutterActor*) self->priv->home_button); + self->priv->menu_bar = (_tmp3_ = g_object_ref_sink (unity_panel_indicators_menu_bar_new ()), _g_object_unref0 (self->priv->menu_bar), _tmp3_); + ctk_box_pack ((CtkBox*) self, (ClutterActor*) self->priv->menu_bar, TRUE, TRUE); + clutter_actor_show ((ClutterActor*) self->priv->menu_bar); + self->priv->system_tray = (_tmp4_ = g_object_ref_sink (unity_panel_system_tray_new ()), _g_object_unref0 (self->priv->system_tray), _tmp4_); + ctk_box_pack ((CtkBox*) self, (ClutterActor*) self->priv->system_tray, FALSE, TRUE); + clutter_actor_show ((ClutterActor*) self->priv->system_tray); + self->priv->indicator_bar = (_tmp5_ = g_object_ref_sink (unity_panel_indicators_indicator_bar_new ()), _g_object_unref0 (self->priv->indicator_bar), _tmp5_); + ctk_box_pack ((CtkBox*) self, (ClutterActor*) self->priv->indicator_bar, FALSE, TRUE); + clutter_actor_show ((ClutterActor*) self->priv->indicator_bar); END_FUNCTION (); } return obj; @@ -798,11 +268,6 @@ static GObject * unity_panel_view_constructor (GType type, guint n_construct_pro static void unity_panel_view_class_init (UnityPanelViewClass * klass) { unity_panel_view_parent_class = g_type_class_peek_parent (klass); g_type_class_add_private (klass, sizeof (UnityPanelViewPrivate)); - CLUTTER_ACTOR_CLASS (klass)->allocate = unity_panel_view_real_allocate; - CLUTTER_ACTOR_CLASS (klass)->paint = unity_panel_view_real_paint; - CLUTTER_ACTOR_CLASS (klass)->pick = unity_panel_view_real_pick; - CLUTTER_ACTOR_CLASS (klass)->map = unity_panel_view_real_map; - CLUTTER_ACTOR_CLASS (klass)->unmap = unity_panel_view_real_unmap; G_OBJECT_CLASS (klass)->get_property = unity_panel_view_get_property; G_OBJECT_CLASS (klass)->set_property = unity_panel_view_set_property; G_OBJECT_CLASS (klass)->constructor = unity_panel_view_constructor; @@ -813,8 +278,7 @@ static void unity_panel_view_class_init (UnityPanelViewClass * klass) { static void unity_panel_view_instance_init (UnityPanelView * self) { self->priv = UNITY_PANEL_VIEW_GET_PRIVATE (self); - self->priv->indicators_width = 0; - self->priv->places_enabled = FALSE; + self->expanded = TRUE; } @@ -822,14 +286,11 @@ static void unity_panel_view_finalize (GObject* obj) { UnityPanelView * self; self = UNITY_PANEL_VIEW (obj); _g_object_unref0 (self->priv->_shell); - _g_object_unref0 (self->priv->rect); - _g_object_unref0 (self->priv->tray); - _g_object_unref0 (self->priv->home); - _g_object_unref0 (self->priv->indicators); - _g_object_unref0 (self->priv->entry_icon); - _g_object_unref0 (self->priv->entry); - _g_object_unref0 (self->priv->entry_background); - _g_object_unref0 (self->priv->client); + _g_object_unref0 (self->priv->bground); + _g_object_unref0 (self->priv->home_button); + _g_object_unref0 (self->priv->menu_bar); + _g_object_unref0 (self->priv->system_tray); + _g_object_unref0 (self->priv->indicator_bar); G_OBJECT_CLASS (unity_panel_view_parent_class)->finalize (obj); } @@ -839,7 +300,7 @@ GType unity_panel_view_get_type (void) { if (g_once_init_enter (&unity_panel_view_type_id__volatile)) { static const GTypeInfo g_define_type_info = { sizeof (UnityPanelViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) unity_panel_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UnityPanelView), 0, (GInstanceInitFunc) unity_panel_view_instance_init, NULL }; GType unity_panel_view_type_id; - unity_panel_view_type_id = g_type_register_static (CTK_TYPE_ACTOR, "UnityPanelView", &g_define_type_info, 0); + unity_panel_view_type_id = g_type_register_static (CTK_TYPE_BOX, "UnityPanelView", &g_define_type_info, 0); g_once_init_leave (&unity_panel_view_type_id__volatile, unity_panel_view_type_id); } return unity_panel_view_type_id__volatile; @@ -874,16 +335,5 @@ static void unity_panel_view_set_property (GObject * object, guint property_id, } -static int _vala_strcmp0 (const char * str1, const char * str2) { - if (str1 == NULL) { - return -(str1 != str2); - } - if (str2 == NULL) { - return str1 != str2; - } - return strcmp (str1, str2); -} - - diff --git a/unity-private/panel/panel-view.vala b/unity-private/panel/panel-view.vala index f757dacf2..2e44da241 100644 --- a/unity-private/panel/panel-view.vala +++ b/unity-private/panel/panel-view.vala @@ -1,4 +1,3 @@ -/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */ /* * Copyright (C) 2010 Canonical Ltd * @@ -17,350 +16,126 @@ * Authored by Neil Jagdish Patel <neil.patel@canonical.com> * */ +using Unity.Panel.Indicators; + namespace Unity.Panel { static const int PANEL_HEIGHT = 24; - static const string SEARCH_TEMPLATE = "xdg-open http://search.yahoo.com/search?p=%s&fr=ubuntu&ei=UTF-8"; - static const string SEARCH_HINT = "Yahoo!"; - - public bool? search_entry_has_focus = null; + static const bool search_entry_has_focus = false; - public class View : Ctk.Actor + public class View : Ctk.Box { + public bool expanded = true; public Shell shell { get; construct;} - private ThemeImage rect; - private Tray.View tray; - private HomeButton home; - private Indicators.View indicators; - - private ThemeImage entry_icon; - private Entry entry; - private Unity.Places.CairoDrawing.EntryBackground entry_background; - - private int indicators_width = 0; - - private GConf.Client client; - - private bool places_enabled = false; + Background bground; + HomeButton home_button; + MenuBar menu_bar; + SystemTray system_tray; + IndicatorBar indicator_bar; public View (Shell shell) { - Object (shell:shell, reactive:false); - this.tray.manage_stage (this.shell.get_stage ()); - - Unity.Testing.ObjectRegistry.get_default ().register ("PanelView", this); + Object (shell:shell, + reactive:false, + orientation:Ctk.Orientation.HORIZONTAL, + homogeneous:false, + spacing:0); + system_tray.manage_stage (shell.get_stage ()); } construct { START_FUNCTION (); - this.places_enabled = Environment.get_variable ("UNITY_ENABLE_PLACES") != null; - - this.rect = new ThemeImage ("panel_background"); - this.rect.set_repeat (true, false); - this.rect.set_parent (this); - this.rect.show (); - - this.indicators = new Indicators.View (); - this.indicators.set_parent (this); - this.indicators.show (); + /* Initialize the models */ + Indicators.IndicatorsModel.get_default(); - this.tray = new Tray.View (); - this.tray.set_parent (this); - this.tray.show (); + /* Create the background and become it's parent */ + //rect = new ThemeImage ("panel_background"); + bground = new Background (); + set_background (bground); + bground.show (); - this.home = new HomeButton (this.shell); - this.home.set_parent (this); - this.home.show (); - this.home.clicked.connect (this.on_home_clicked); + /* Create the views and add them to the box */ + home_button = new HomeButton (shell); + pack (home_button, false, true); + home_button.show (); - if (this.places_enabled == false) - { - this.entry_background = new Unity.Places.CairoDrawing.EntryBackground (); - this.entry_background.set_parent (this); - this.entry_background.show (); + menu_bar = new MenuBar (); + pack (menu_bar, true, true); + menu_bar.show (); - this.entry_icon = new ThemeImage ("search_field"); - this.entry_icon.reactive = true; - this.entry_icon.button_press_event.connect ((e) => - { - this.entry.do_event (e, false); - this.entry.grab_key_focus (); - Unity.global_shell.grab_keyboard (true, e.button.time); - }); - this.entry_icon.set_parent (this); - this.entry_icon.show (); + system_tray = new SystemTray (); + pack (system_tray, false, true); + system_tray.show (); - this.entry = new Unity.Entry (""); - this.entry.static_text = this.get_search_hint (); - this.entry.set_parent (this); - this.entry.show (); - this.entry.activate.connect (this.on_entry_activated); - - this.entry.key_focus_in.connect (this.on_entry_focus_in); - this.entry.key_focus_out.connect (this.on_entry_focus_out); - Unity.Panel.search_entry_has_focus = false; - } + indicator_bar = new IndicatorBar (); + pack (indicator_bar, false, true); + indicator_bar.show (); END_FUNCTION (); } - private void on_home_clicked () - { - Unity.global_shell.show_window_picker (); - } - - private void on_entry_focus_in () - { - Unity.Panel.search_entry_has_focus = true; - } - - private void on_entry_focus_out () - { - Unity.Panel.search_entry_has_focus = false; - } - - private string get_search_hint () - { - string hint = ""; - this.client = GConf.Client.get_default (); - - try - { - hint = client.get_string ("/desktop/unity/panel/search_hint"); - - try - { - client.add_dir ("/desktop/unity/panel", - GConf.ClientPreloadType.NONE); - client.notify_add ("/desktop/unity/panel/search_hint", - this.on_search_hint_changed); - } - catch (Error e) - { - warning ("Unable to monitor gconf for search hint changes: %s", - e.message); - } - - if (hint == "" || hint == null) - hint = SEARCH_HINT; - } - catch (Error e) - { - hint = SEARCH_HINT; - } - - return hint; - } - - private void on_search_hint_changed () - { - try - { - var hint = client.get_string ("/desktop/unity/panel/search_hint"); - - this.entry.static_text = hint; - } - catch (Error e) - { - warning ("Unable to get search hint: %s", e.message); - } - } - - private void on_entry_activated () - { - string template = ""; - - var client = GConf.Client.get_default (); - try - { - template = client.get_string ("/desktop/unity/panel/search_template"); - - if (template == "" || template == null) - template = SEARCH_TEMPLATE; - } - catch (Error e) - { - template = SEARCH_TEMPLATE; - } - - var command=template.replace ("%s", - Uri.escape_string (this.entry.text, "", true)); - - try - { - Process.spawn_command_line_async (command); - } - catch (Error e) - { - warning ("Unable to search for '%s': %s", - this.entry.text, - e.message); - } - } - - private override void allocate (Clutter.ActorBox box, - Clutter.AllocationFlags flags) - { - Clutter.ActorBox child_box = { 0, 0, box.x2 - box.x1, box.y2 - box.y1 }; - float width; - float child_width; - float i_width; - - base.allocate (box, flags); - - width = box.x2 - box.x1; - - this.rect.set_clip (0, 0, width, box.y2 - box.y1); - - /* First the background */ - child_box.y2 += 3.0f; - this.rect.allocate (child_box, flags); - - /* Home button */ - child_box.x1 = 0; - child_box.x2 = 60; - child_box.y1 = 0; - child_box.y2 = PANEL_HEIGHT; - this.home.allocate (child_box, flags); - - if (this.places_enabled == false) - { - /* Entry */ - child_box.x1 = Math.floorf (child_box.x2 + 12); - child_box.x2 = Math.floorf (child_box.x1 + 170); /* Random width */ - child_box.y1 = Math.floorf (2); - child_box.y2 = Math.floorf (PANEL_HEIGHT); - - this.entry_background.allocate (child_box, flags); - if ((this.entry_background.Width != (int)(child_box.x2 - child_box.x1)) && (this.entry_background.height != (int)(child_box.y2 - child_box.y1-2))) - { - this.entry_background.create_search_entry_background ((int)(child_box.x2 - child_box.x1), (int)(child_box.y2 - child_box.y1-2)); - } - - child_box.x1 += 6; - child_box.x2 = child_box.x1 + 16; - child_box.y1 = Math.floorf ((PANEL_HEIGHT-16)/2.0f); - child_box.y2 = child_box.y1 + 16; - this.entry_icon.allocate (child_box, flags); - - child_box.x1 = child_box.x2 + 4; /* (QL_width - logo_width)/2.0 */ - child_box.x2 = child_box.x1 + 150 - 16; - child_box.y1 = 9; - child_box.y2 = 15; - this.entry.allocate (child_box, flags); - - child_box.y1 = 0; - child_box.y2 = PANEL_HEIGHT; - } - - /* Indicators */ - this.indicators.get_preferred_width (PANEL_HEIGHT, - out child_width, - out child_width); - child_box.x1 = width - child_width; - child_box.x2 = width; - this.indicators.allocate (child_box, flags); - - width -= child_width + 12; /* 12 = space between icons */ - - /* Systray */ - this.tray.get_preferred_width (PANEL_HEIGHT, - out child_width, - out child_width); - child_box.x1 = width - child_width; - child_box.x2 = width; - this.tray.allocate (child_box, flags); - - width -= child_box.x2 - child_box.x1; - i_width = box.x2 - box.x1 - width; - if (this.indicators_width != (int)i_width) - { - this.indicators_width = (int)i_width; - this.shell.indicators_changed (this.indicators_width); - } - } - - private override void paint () - { - base.paint (); - this.rect.paint (); - this.tray.paint (); - this.home.paint (); - this.indicators.paint (); - - if (this.places_enabled == true) - return; - - this.entry_background.paint (); - this.entry_icon.paint (); - this.entry.paint (); - } - - private override void pick (Clutter.Color color) - { - base.pick (color); - this.tray.paint (); - this.home.paint (); - this.indicators.paint (); - - if (this.places_enabled == true) - return; - - this.entry_background.paint (); - this.entry_icon.paint (); - this.entry.paint (); - } - - private override void map () + public int get_indicators_width () { - base.map (); - this.rect.map (); - this.tray.map (); - this.home.map (); - this.indicators.map (); - - if (this.places_enabled == true) - return; - - this.entry_background.map (); - this.entry_icon.map (); - this.entry.map (); + return (int) this.indicator_bar.get_width (); + //this.system_tray.width + this.indicator_bar.width; } - private override void unmap () + public void set_expanded (bool _expanded) { - base.unmap (); - this.rect.unmap (); - this.tray.unmap (); - this.home.unmap (); - this.indicators.unmap (); - - if (this.places_enabled == true) - return; - - this.entry_background.unmap (); - this.entry_icon.unmap (); - this.entry.unmap (); + // Hide menubar + // Put background into expanded mode + this.expanded = _expanded; } - public int get_indicators_width () +// private override void allocate (Clutter.ActorBox box, +// Clutter.AllocationFlags flags) +// { +// Clutter.ActorBox child_box = { 0, 0, box.x2 - box.x1, box.y2 - box.y1 }; +// float width; +// float child_width; +// +// base.allocate (box, flags); +// +// width = box.x2 - box.x1; +// +// this.rect.set_clip (0, 0, width, box.y2 - box.y1); +// +// First the background +// child_box.y2 += 3.0f; +// this.rect.allocate (child_box, flags); +// // +// // Home button +// // child_box.x1 = 0; +// // child_box.x2 = 60; +// // child_box.y1 = 0; +// // child_box.y2 = PANEL_HEIGHT; +// // this.home.allocate (child_box, flags); +// +// this.indicator_bar.get_preferred_width (PANEL_HEIGHT, +// out child_width, +// out child_width); +// child_box.x1 = width - child_width; +// child_box.x2 = width; +// this.indicator_bar.allocate (child_box, flags); +// } + + + public int get_panel_height () { - return (int)this.indicators_width; + return Unity.Panel.PANEL_HEIGHT; } public void set_indicator_mode (bool mode) { - float x; - - x = mode ? this.width - this.get_indicators_width () : 0; - - this.rect.set_clip (x, - 0, - mode ? this.get_indicators_width () : this.width, - mode ? PANEL_HEIGHT -1 : PANEL_HEIGHT); +// float x; +// x = mode ? this.width - this.get_indicators_width () : 0; +// this.rect.set_clip (x, +// 0, +// mode ? this.get_indicators_width () : this.width, +// mode ? PANEL_HEIGHT -1 : PANEL_HEIGHT); } } } diff --git a/unity-private/places/application-place.c b/unity-private/places/application-place.c index 10b7845d0..7b7eecc02 100644 --- a/unity-private/places/application-place.c +++ b/unity-private/places/application-place.c @@ -58,6 +58,7 @@ typedef struct _UnityPlacesBarModelClass UnityPlacesBarModelClass; #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) #define _g_free0(var) (var = (g_free (var), NULL)) #define _gtk_icon_info_free0(var) ((var == NULL) ? NULL : (var = (gtk_icon_info_free (var), NULL))) +#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL))) typedef struct _UnityPlacesApplicationParamSpecApplicationIcon UnityPlacesApplicationParamSpecApplicationIcon; #define UNITY_PLACES_APPLICATION_TYPE_APPLICATION_GROUP (unity_places_application_application_group_get_type ()) @@ -235,7 +236,7 @@ UnityPlacesApplicationApplicationIcon* unity_places_application_application_icon GError * _inner_error_; UnityPlacesApplicationApplicationIcon* self; UnityPlacesBarModel* _tmp0_; - CtkText* _tmp8_; + CtkText* _tmp10_; g_return_val_if_fail (name != NULL, NULL); g_return_val_if_fail (icon_name != NULL, NULL); g_return_val_if_fail (tooltip != NULL, NULL); @@ -254,36 +255,58 @@ UnityPlacesApplicationApplicationIcon* unity_places_application_application_icon } else { if (g_utf8_get_char (g_utf8_offset_to_pointer (icon_name, 0)) == '.') { GIcon* icon; - GtkIconInfo* info; - icon = _g_object_ref0 (g_icon_new_for_string (icon_name, &_inner_error_)); + icon = NULL; + { + GIcon* _tmp4_; + GIcon* _tmp5_; + GtkIconInfo* info; + _tmp4_ = g_icon_new_for_string (icon_name, &_inner_error_); + if (_inner_error_ != NULL) { + goto __catch5_g_error; + } + icon = (_tmp5_ = _g_object_ref0 (_tmp4_), _g_object_unref0 (icon), _tmp5_); + info = gtk_icon_theme_lookup_by_gicon (gtk_icon_theme_get_default (), icon, 48, 0); + if (info != NULL) { + CtkImage* _tmp6_; + self->view = (_tmp6_ = g_object_ref_sink ((CtkImage*) ctk_image_new_from_filename ((guint) width, gtk_icon_info_get_filename (info))), _g_object_unref0 (self->view), _tmp6_); + } else { + CtkImage* _tmp7_; + self->view = (_tmp7_ = g_object_ref_sink ((CtkImage*) ctk_image_new_from_stock ((guint) width, icon_name)), _g_object_unref0 (self->view), _tmp7_); + } + if (self->view == NULL) { + char* _tmp8_; + g_warning ("application-place.vala:56: %s", _tmp8_ = g_strconcat ("Failed to load icon for ", string_to_string (icon_name), NULL)); + _g_free0 (_tmp8_); + } + _gtk_icon_info_free0 (info); + } + goto __finally5; + __catch5_g_error: + { + GError * _error_; + _error_ = _inner_error_; + _inner_error_ = NULL; + { + g_warning ("application-place.vala:60: Failed to load icon: %s", _error_->message); + _g_error_free0 (_error_); + } + } + __finally5: if (_inner_error_ != NULL) { + _g_object_unref0 (icon); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return NULL; } - info = gtk_icon_theme_lookup_by_gicon (gtk_icon_theme_get_default (), icon, 48, 0); - if (info != NULL) { - CtkImage* _tmp4_; - self->view = (_tmp4_ = g_object_ref_sink ((CtkImage*) ctk_image_new_from_filename ((guint) width, gtk_icon_info_get_filename (info))), _g_object_unref0 (self->view), _tmp4_); - } else { - CtkImage* _tmp5_; - self->view = (_tmp5_ = g_object_ref_sink ((CtkImage*) ctk_image_new_from_stock ((guint) width, icon_name)), _g_object_unref0 (self->view), _tmp5_); - } - if (self->view == NULL) { - char* _tmp6_; - g_warning ("application-place.vala:52: %s", _tmp6_ = g_strconcat ("Failed to load icon for ", string_to_string (icon_name), NULL)); - _g_free0 (_tmp6_); - } _g_object_unref0 (icon); - _gtk_icon_info_free0 (info); } else { - CtkImage* _tmp7_; - self->view = (_tmp7_ = g_object_ref_sink ((CtkImage*) ctk_image_new_from_stock ((guint) width, icon_name)), _g_object_unref0 (self->view), _tmp7_); + CtkImage* _tmp9_; + self->view = (_tmp9_ = g_object_ref_sink ((CtkImage*) ctk_image_new_from_stock ((guint) width, icon_name)), _g_object_unref0 (self->view), _tmp9_); } } } clutter_actor_set_reactive ((ClutterActor*) self->view, TRUE); - self->label = (_tmp8_ = g_object_ref_sink ((CtkText*) ctk_text_new (name)), _g_object_unref0 (self->label), _tmp8_); + self->label = (_tmp10_ = g_object_ref_sink ((CtkText*) ctk_text_new (name)), _g_object_unref0 (self->label), _tmp10_); clutter_text_set_line_wrap ((ClutterText*) self->label, TRUE); clutter_text_set_line_alignment ((ClutterText*) self->label, PANGO_ALIGN_CENTER); return self; @@ -564,12 +587,16 @@ static void unity_places_application_application_group_real_get_preferred_height static gboolean _unity_places_application_application_group_on_maximize_clutter_actor_button_release_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_places_application_application_group_on_maximize (self, event); + gboolean result; + result = unity_places_application_application_group_on_maximize (self, event); + return result; } static gboolean _unity_places_application_application_group_on_minimize_clutter_actor_button_release_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_places_application_application_group_on_minimize (self, event); + gboolean result; + result = unity_places_application_application_group_on_minimize (self, event); + return result; } diff --git a/unity-private/places/application-place.vala b/unity-private/places/application-place.vala index 936338c65..c07f0ca2d 100644 --- a/unity-private/places/application-place.vala +++ b/unity-private/places/application-place.vala @@ -42,14 +42,23 @@ namespace Unity.Places.Application "/usr/share/pixmaps/" + icon_name); else if (icon_name[0] == '.') { - GLib.Icon icon = GLib.Icon.new_for_string(icon_name); - Gtk.IconInfo info = Gtk.IconTheme.get_default().lookup_by_gicon(icon, 48, 0); - if (info != null) - view = new Ctk.Image.from_filename (width, info.get_filename()); - else - view = new Ctk.Image.from_stock (width, icon_name); - if (view == null) - warning (@"Failed to load icon for $icon_name"); + GLib.Icon icon; + + try + { + icon = GLib.Icon.new_for_string(icon_name); + Gtk.IconInfo info = Gtk.IconTheme.get_default().lookup_by_gicon (icon, 48, 0); + if (info != null) + view = new Ctk.Image.from_filename (width, info.get_filename()); + else + view = new Ctk.Image.from_stock (width, icon_name); + if (view == null) + warning (@"Failed to load icon for $icon_name"); + } + catch (GLib.Error error) + { + warning (@"Failed to load icon: %s", error.message); + } } else view = new Ctk.Image.from_stock (width, icon_name); diff --git a/unity-private/places/bar-view.c b/unity-private/places/bar-view.c index af53d64ad..375f8701c 100644 --- a/unity-private/places/bar-view.c +++ b/unity-private/places/bar-view.c @@ -205,7 +205,9 @@ static void _unity_places_bar_view_on_place_added_unity_places_model_place_added static gboolean _unity_places_bar_view_on_button_release_clutter_actor_button_release_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_places_bar_view_on_button_release (self, event); + gboolean result; + result = unity_places_bar_view_on_button_release (self, event); + return result; } @@ -389,7 +391,7 @@ gboolean unity_places_bar_view_on_button_release (UnityPlacesBarView* self, Clut g_spawn_command_line_async ("xdg-open trash:///", &_inner_error_); if (_inner_error_ != NULL) { if (_inner_error_->domain == G_SPAWN_ERROR) { - goto __catch9_g_spawn_error; + goto __catch6_g_spawn_error; } _g_object_unref0 (icon); _g_object_unref0 (actor); @@ -398,8 +400,8 @@ gboolean unity_places_bar_view_on_button_release (UnityPlacesBarView* self, Clut return FALSE; } } - goto __finally9; - __catch9_g_spawn_error: + goto __finally6; + __catch6_g_spawn_error: { GError * e; e = _inner_error_; @@ -409,7 +411,7 @@ gboolean unity_places_bar_view_on_button_release (UnityPlacesBarView* self, Clut _g_error_free0 (e); } } - __finally9: + __finally6: if (_inner_error_ != NULL) { _g_object_unref0 (icon); _g_object_unref0 (actor); diff --git a/unity-private/places/default-view.c b/unity-private/places/default-view.c index 2bc450352..0a81752cc 100644 --- a/unity-private/places/default-view.c +++ b/unity-private/places/default-view.c @@ -144,12 +144,16 @@ static void unity_places_default_view_finalize (GObject* obj); static gboolean _unity_places_default_activity_widget_on_enter_clutter_actor_enter_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_places_default_activity_widget_on_enter (self); + gboolean result; + result = unity_places_default_activity_widget_on_enter (self); + return result; } static gboolean _unity_places_default_activity_widget_on_leave_clutter_actor_leave_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_places_default_activity_widget_on_leave (self); + gboolean result; + result = unity_places_default_activity_widget_on_leave (self); + return result; } diff --git a/unity-private/places/file-place.c b/unity-private/places/file-place.c index d40826154..0aca9905f 100644 --- a/unity-private/places/file-place.c +++ b/unity-private/places/file-place.c @@ -482,12 +482,16 @@ static void unity_places_file_file_group_real_get_preferred_height (ClutterActor static gboolean _unity_places_file_file_group_on_maximize_clutter_actor_button_release_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_places_file_file_group_on_maximize (self, event); + gboolean result; + result = unity_places_file_file_group_on_maximize (self, event); + return result; } static gboolean _unity_places_file_file_group_on_minimize_clutter_actor_button_release_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_places_file_file_group_on_minimize (self, event); + gboolean result; + result = unity_places_file_file_group_on_minimize (self, event); + return result; } diff --git a/unity-private/places/places-controller.c b/unity-private/places/places-controller.c index 6136e5fc6..c6351773d 100644 --- a/unity-private/places/places-controller.c +++ b/unity-private/places/places-controller.c @@ -306,7 +306,7 @@ void unity_places_controller_load_remote_places (UnityPlacesController* self) { GFileInfo* file_info; enumerator = g_file_enumerate_children (dir, G_FILE_ATTRIBUTE_STANDARD_NAME, 0, NULL, &_inner_error_); if (_inner_error_ != NULL) { - goto __catch10_g_error; + goto __catch7_g_error; } file_info = NULL; while (TRUE) { @@ -319,7 +319,7 @@ void unity_places_controller_load_remote_places (UnityPlacesController* self) { if (_inner_error_ != NULL) { _g_object_unref0 (enumerator); _g_object_unref0 (file_info); - goto __catch10_g_error; + goto __catch7_g_error; } if (!((file_info = (_tmp1_ = _tmp0_, _g_object_unref0 (file_info), _tmp1_)) != NULL)) { break; @@ -331,8 +331,8 @@ void unity_places_controller_load_remote_places (UnityPlacesController* self) { _g_object_unref0 (enumerator); _g_object_unref0 (file_info); } - goto __finally10; - __catch10_g_error: + goto __finally7; + __catch7_g_error: { GError * _error_; _error_ = _inner_error_; @@ -344,7 +344,7 @@ void unity_places_controller_load_remote_places (UnityPlacesController* self) { _g_error_free0 (_error_); } } - __finally10: + __finally7: if (_inner_error_ != NULL) { _g_free0 (placesdir); _g_object_unref0 (dir); @@ -375,29 +375,29 @@ static void unity_places_controller_load_place (UnityPlacesController* self, con UnityPlacesPlace* place; g_key_file_load_from_file (file, filename, G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, &_inner_error_); if (_inner_error_ != NULL) { - goto __catch11_g_error; + goto __catch8_g_error; } name = g_key_file_get_string (file, group, "Name", &_inner_error_); if (_inner_error_ != NULL) { - goto __catch11_g_error; + goto __catch8_g_error; } comment = g_key_file_get_string (file, group, "Comment", &_inner_error_); if (_inner_error_ != NULL) { _g_free0 (name); - goto __catch11_g_error; + goto __catch8_g_error; } icon_name = g_key_file_get_string (file, group, "Icon", &_inner_error_); if (_inner_error_ != NULL) { _g_free0 (name); _g_free0 (comment); - goto __catch11_g_error; + goto __catch8_g_error; } dbus_name = g_key_file_get_string (file, group, "DBusName", &_inner_error_); if (_inner_error_ != NULL) { _g_free0 (name); _g_free0 (comment); _g_free0 (icon_name); - goto __catch11_g_error; + goto __catch8_g_error; } dbus_path = g_key_file_get_string (file, group, "DBusObjectPath", &_inner_error_); if (_inner_error_ != NULL) { @@ -405,7 +405,7 @@ static void unity_places_controller_load_place (UnityPlacesController* self, con _g_free0 (comment); _g_free0 (icon_name); _g_free0 (dbus_name); - goto __catch11_g_error; + goto __catch8_g_error; } place = (UnityPlacesPlace*) unity_places_place_proxy_new (name, icon_name, comment, dbus_name, dbus_path); if (UNITY_PLACES_IS_PLACE (place)) { @@ -419,8 +419,8 @@ static void unity_places_controller_load_place (UnityPlacesController* self, con _g_free0 (dbus_path); _g_object_unref0 (place); } - goto __finally11; - __catch11_g_error: + goto __finally8; + __catch8_g_error: { GError * e; e = _inner_error_; @@ -432,7 +432,7 @@ static void unity_places_controller_load_place (UnityPlacesController* self, con _g_error_free0 (e); } } - __finally11: + __finally8: if (_inner_error_ != NULL) { _g_free0 (group); _g_key_file_free0 (file); @@ -484,7 +484,9 @@ static void unity_places_controller_set_shell (UnityPlacesController* self, Unit static gboolean _unity_places_controller_load_places_gsource_func (gpointer self) { - return unity_places_controller_load_places (self); + gboolean result; + result = unity_places_controller_load_places (self); + return result; } diff --git a/unity-private/places/places-place-proxy.c b/unity-private/places/places-place-proxy.c index 6854a9e64..6d419fdc3 100644 --- a/unity-private/places/places-place-proxy.c +++ b/unity-private/places/places-place-proxy.c @@ -190,18 +190,18 @@ static void unity_places_place_proxy_setup_service (UnityPlacesPlaceProxy* self) DBusGProxy* _tmp2_; _tmp0_ = dbus_g_bus_get (DBUS_BUS_SESSION, &_inner_error_); if (_inner_error_ != NULL) { - goto __catch12_g_error; + goto __catch9_g_error; } self->priv->conn = (_tmp1_ = _tmp0_, _dbus_g_connection_unref0 (self->priv->conn), _tmp1_); self->priv->service = (_tmp2_ = dbus_g_proxy_new_for_name (self->priv->conn, self->priv->_dbus_name, self->priv->_dbus_path, "com.canonical.Unity.Place"), _g_object_unref0 (self->priv->service), _tmp2_); _dynamic_ViewChanged1_connect (self->priv->service, "ViewChanged", (GCallback) _unity_places_place_proxy_on_view_changed_dynamic_ViewChanged0_, self); _dynamic_set_active0 (self->priv->service, FALSE, &_inner_error_); if (_inner_error_ != NULL) { - goto __catch12_g_error; + goto __catch9_g_error; } } - goto __finally12; - __catch12_g_error: + goto __finally9; + __catch9_g_error: { GError * e; e = _inner_error_; @@ -211,7 +211,7 @@ static void unity_places_place_proxy_setup_service (UnityPlacesPlaceProxy* self) _g_error_free0 (e); } } - __finally12: + __finally9: if (_inner_error_ != NULL) { g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); diff --git a/unity-private/places/search-field.c b/unity-private/places/search-field.c index d25b8fb7f..422c7e0e0 100644 --- a/unity-private/places/search-field.c +++ b/unity-private/places/search-field.c @@ -95,8 +95,8 @@ void unity_places_cairo_drawing_rectangle_box_CreateRectangleBox (UnityPlacesCai static void unity_places_search_field_view_real_allocate (ClutterActor* base, const ClutterActorBox* box, ClutterAllocationFlags flags); UnityPlacesCairoDrawingRectangleBox* unity_places_cairo_drawing_rectangle_box_new (void); UnityPlacesCairoDrawingRectangleBox* unity_places_cairo_drawing_rectangle_box_construct (GType object_type); -static gboolean _lambda5_ (ClutterEvent* e, UnityPlacesSearchFieldView* self); -static gboolean __lambda5__clutter_actor_button_press_event (ClutterActor* _sender, ClutterEvent* event, gpointer self); +static gboolean _lambda8_ (ClutterEvent* e, UnityPlacesSearchFieldView* self); +static gboolean __lambda8__clutter_actor_button_press_event (ClutterActor* _sender, ClutterEvent* event, gpointer self); UnityPlacesSearchFieldView* unity_places_search_field_view_new (void); UnityPlacesSearchFieldView* unity_places_search_field_view_construct (GType object_type); static void unity_places_search_field_view_real_map (ClutterActor* base); @@ -137,7 +137,7 @@ static void unity_places_search_field_view_real_allocate (ClutterActor* base, co } -static gboolean _lambda5_ (ClutterEvent* e, UnityPlacesSearchFieldView* self) { +static gboolean _lambda8_ (ClutterEvent* e, UnityPlacesSearchFieldView* self) { gboolean result = FALSE; unity_shell_grab_keyboard (unity_global_shell, TRUE, (*e).button.time); result = FALSE; @@ -145,8 +145,10 @@ static gboolean _lambda5_ (ClutterEvent* e, UnityPlacesSearchFieldView* self) { } -static gboolean __lambda5__clutter_actor_button_press_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return _lambda5_ (event, self); +static gboolean __lambda8__clutter_actor_button_press_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { + gboolean result; + result = _lambda8_ (event, self); + return result; } @@ -163,7 +165,7 @@ UnityPlacesSearchFieldView* unity_places_search_field_view_construct (GType obje clutter_container_add_actor ((ClutterContainer*) self, (ClutterActor*) self->priv->search_icon); clutter_container_add_actor ((ClutterContainer*) self, (ClutterActor*) self->priv->text_field); clutter_actor_show_all ((ClutterActor*) self); - g_signal_connect_object ((ClutterActor*) self->priv->text_field, "button-press-event", (GCallback) __lambda5__clutter_actor_button_press_event, self, 0); + g_signal_connect_object ((ClutterActor*) self->priv->text_field, "button-press-event", (GCallback) __lambda8__clutter_actor_button_press_event, self, 0); return self; } diff --git a/unity-private/testing/background.c b/unity-private/testing/background.c index e5712dd9e..8f381f7e9 100644 --- a/unity-private/testing/background.c +++ b/unity-private/testing/background.c @@ -125,11 +125,11 @@ static void unity_testing_background_ensure_layout (UnityTestingBackground* self { clutter_texture_set_from_file (self->priv->bg, self->priv->filename, &_inner_error_); if (_inner_error_ != NULL) { - goto __catch24_g_error; + goto __catch21_g_error; } } - goto __finally24; - __catch24_g_error: + goto __finally21; + __catch21_g_error: { GError * e; e = _inner_error_; @@ -139,7 +139,7 @@ static void unity_testing_background_ensure_layout (UnityTestingBackground* self _g_error_free0 (e); } } - __finally24: + __finally21: if (_inner_error_ != NULL) { g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); @@ -193,11 +193,11 @@ static GObject * unity_testing_background_constructor (GType type, guint n_const { gconf_client_add_dir (client, self->priv->BG_DIR, GCONF_CLIENT_PRELOAD_NONE, &_inner_error_); if (_inner_error_ != NULL) { - goto __catch25_g_error; + goto __catch22_g_error; } } - goto __finally25; - __catch25_g_error: + goto __finally22; + __catch22_g_error: { GError * e; e = _inner_error_; @@ -207,7 +207,7 @@ static GObject * unity_testing_background_constructor (GType type, guint n_const _g_error_free0 (e); } } - __finally25: + __finally22: if (_inner_error_ != NULL) { _g_object_unref0 (client); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); @@ -218,12 +218,12 @@ static GObject * unity_testing_background_constructor (GType type, guint n_const char* _tmp1_; _tmp0_ = gconf_client_get_string (client, self->priv->BG_FILE, &_inner_error_); if (_inner_error_ != NULL) { - goto __catch26_g_error; + goto __catch23_g_error; } self->priv->filename = (_tmp1_ = _tmp0_, _g_free0 (self->priv->filename), _tmp1_); } - goto __finally26; - __catch26_g_error: + goto __finally23; + __catch23_g_error: { GError * e; e = _inner_error_; @@ -234,7 +234,7 @@ static GObject * unity_testing_background_constructor (GType type, guint n_const _g_error_free0 (e); } } - __finally26: + __finally23: if (_inner_error_ != NULL) { _g_object_unref0 (client); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); @@ -243,11 +243,11 @@ static GObject * unity_testing_background_constructor (GType type, guint n_const { gconf_client_notify_add (client, self->priv->BG_FILE, _unity_testing_background_on_filename_changed_gconf_client_notify_func, g_object_ref (self), g_object_unref, &_inner_error_); if (_inner_error_ != NULL) { - goto __catch27_g_error; + goto __catch24_g_error; } } - goto __finally27; - __catch27_g_error: + goto __finally24; + __catch24_g_error: { GError * e; e = _inner_error_; @@ -258,7 +258,7 @@ static GObject * unity_testing_background_constructor (GType type, guint n_const _g_error_free0 (e); } } - __finally27: + __finally24: if (_inner_error_ != NULL) { _g_object_unref0 (client); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); @@ -269,12 +269,12 @@ static GObject * unity_testing_background_constructor (GType type, guint n_const char* _tmp4_; _tmp3_ = gconf_client_get_string (client, self->priv->BG_OPTION, &_inner_error_); if (_inner_error_ != NULL) { - goto __catch28_g_error; + goto __catch25_g_error; } self->priv->option = (_tmp4_ = _tmp3_, _g_free0 (self->priv->option), _tmp4_); } - goto __finally28; - __catch28_g_error: + goto __finally25; + __catch25_g_error: { GError * e; e = _inner_error_; @@ -285,7 +285,7 @@ static GObject * unity_testing_background_constructor (GType type, guint n_const _g_error_free0 (e); } } - __finally28: + __finally25: if (_inner_error_ != NULL) { _g_object_unref0 (client); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); @@ -294,11 +294,11 @@ static GObject * unity_testing_background_constructor (GType type, guint n_const { gconf_client_notify_add (client, self->priv->BG_OPTION, _unity_testing_background_on_option_changed_gconf_client_notify_func, g_object_ref (self), g_object_unref, &_inner_error_); if (_inner_error_ != NULL) { - goto __catch29_g_error; + goto __catch26_g_error; } } - goto __finally29; - __catch29_g_error: + goto __finally26; + __catch26_g_error: { GError * e; e = _inner_error_; @@ -309,7 +309,7 @@ static GObject * unity_testing_background_constructor (GType type, guint n_const _g_error_free0 (e); } } - __finally29: + __finally26: if (_inner_error_ != NULL) { _g_object_unref0 (client); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); diff --git a/unity-private/testing/perf-logger.c b/unity-private/testing/perf-logger.c index 483949601..80cbb71ad 100644 --- a/unity-private/testing/perf-logger.c +++ b/unity-private/testing/perf-logger.c @@ -367,7 +367,7 @@ void unity_timeline_logger_write_log (UnityTimelineLogger* self, const char* fil GFileOutputStream* _tmp1_; _tmp0_ = g_file_create (log_file, G_FILE_CREATE_NONE, NULL, &_inner_error_); if (_inner_error_ != NULL) { - goto __catch30_g_error; + goto __catch27_g_error; } file_stream = (_tmp1_ = _tmp0_, _g_object_unref0 (file_stream), _tmp1_); } else { @@ -375,7 +375,7 @@ void unity_timeline_logger_write_log (UnityTimelineLogger* self, const char* fil GFileOutputStream* _tmp3_; _tmp2_ = g_file_replace (log_file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, &_inner_error_); if (_inner_error_ != NULL) { - goto __catch30_g_error; + goto __catch27_g_error; } file_stream = (_tmp3_ = _tmp2_, _g_object_unref0 (file_stream), _tmp3_); } @@ -399,7 +399,7 @@ void unity_timeline_logger_write_log (UnityTimelineLogger* self, const char* fil _g_free0 (outline); _g_object_unref0 (_info_it); _g_object_unref0 (output_stream); - goto __catch30_g_error; + goto __catch27_g_error; } _unity_process_info_unref0 (info); _g_free0 (outline); @@ -409,12 +409,12 @@ void unity_timeline_logger_write_log (UnityTimelineLogger* self, const char* fil g_output_stream_close ((GOutputStream*) file_stream, NULL, &_inner_error_); if (_inner_error_ != NULL) { _g_object_unref0 (output_stream); - goto __catch30_g_error; + goto __catch27_g_error; } _g_object_unref0 (output_stream); } - goto __finally30; - __catch30_g_error: + goto __finally27; + __catch27_g_error: { GError * e; e = _inner_error_; @@ -424,7 +424,7 @@ void unity_timeline_logger_write_log (UnityTimelineLogger* self, const char* fil _g_error_free0 (e); } } - __finally30: + __finally27: if (_inner_error_ != NULL) { _g_object_unref0 (log_file); _g_object_unref0 (file_stream); diff --git a/unity-private/testing/test-director.c b/unity-private/testing/test-director.c index 0bb818064..ba6c822a8 100644 --- a/unity-private/testing/test-director.c +++ b/unity-private/testing/test-director.c @@ -52,6 +52,7 @@ struct _UnityTestingDirectorClass { struct _UnityTestingDirectorPrivate { ClutterStage* _stage; + gboolean break_loop; }; @@ -66,7 +67,11 @@ enum { UnityTestingDirector* unity_testing_director_new (ClutterStage* stage); UnityTestingDirector* unity_testing_director_construct (GType object_type, ClutterStage* stage); static void unity_testing_director_do_event (UnityTestingDirector* self, ClutterActor* actor, ClutterEvent* event, gboolean capture_phase); -void unity_testing_director_button_press (UnityTestingDirector* self, ClutterActor* actor, guint32 button, gboolean autorelease, float relative_x, float relative_y); +void unity_testing_director_do_wait_for_animation (UnityTestingDirector* self, ClutterActor* actor); +static gboolean _lambda18_ (UnityTestingDirector* self); +static gboolean __lambda18__gsource_func (gpointer self); +void unity_testing_director_do_wait_for_timeout (UnityTestingDirector* self, guint32 msecs); +void unity_testing_director_button_press (UnityTestingDirector* self, ClutterActor* actor, guint32 button, gboolean autorelease, float relative_x, float relative_y, gboolean wait_for_animation); void unity_testing_director_button_release (UnityTestingDirector* self, ClutterActor* actor, guint32 button, float relative_x, float relative_y); void unity_testing_director_enter_event (UnityTestingDirector* self, ClutterActor* actor, float relative_x, float relative_y); void unity_testing_director_leave_event (UnityTestingDirector* self, ClutterActor* actor, float relative_x, float relative_y); @@ -106,7 +111,61 @@ static void unity_testing_director_do_event (UnityTestingDirector* self, Clutter } -void unity_testing_director_button_press (UnityTestingDirector* self, ClutterActor* actor, guint32 button, gboolean autorelease, float relative_x, float relative_y) { +static gpointer _g_object_ref0 (gpointer self) { + return self ? g_object_ref (self) : NULL; +} + + +void unity_testing_director_do_wait_for_animation (UnityTestingDirector* self, ClutterActor* actor) { + ClutterAnimation* anim; + g_return_if_fail (self != NULL); + g_return_if_fail (actor != NULL); + anim = _g_object_ref0 (clutter_actor_get_animation (actor)); + while (TRUE) { + gboolean _tmp0_ = FALSE; + if (CLUTTER_IS_ANIMATION (anim)) { + _tmp0_ = clutter_timeline_is_playing (clutter_animation_get_timeline (anim)); + } else { + _tmp0_ = FALSE; + } + if (!_tmp0_) { + break; + } + gtk_main_iteration (); + } + _g_object_unref0 (anim); +} + + +static gboolean _lambda18_ (UnityTestingDirector* self) { + gboolean result = FALSE; + self->priv->break_loop = TRUE; + result = FALSE; + return result; +} + + +static gboolean __lambda18__gsource_func (gpointer self) { + gboolean result; + result = _lambda18_ (self); + return result; +} + + +void unity_testing_director_do_wait_for_timeout (UnityTestingDirector* self, guint32 msecs) { + g_return_if_fail (self != NULL); + self->priv->break_loop = FALSE; + g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) msecs, __lambda18__gsource_func, g_object_ref (self), g_object_unref); + while (TRUE) { + if (!(self->priv->break_loop != TRUE)) { + break; + } + gtk_main_iteration (); + } +} + + +void unity_testing_director_button_press (UnityTestingDirector* self, ClutterActor* actor, guint32 button, gboolean autorelease, float relative_x, float relative_y, gboolean wait_for_animation) { float actor_x = 0.0F; float actor_y = 0.0F; ClutterButtonEvent event = {0}; @@ -125,11 +184,17 @@ void unity_testing_director_button_press (UnityTestingDirector* self, ClutterAct event.y = actor_y + relative_y; event.button = button; unity_testing_director_do_event (self, actor, (_tmp1_ = (ClutterEvent) event, &_tmp1_), FALSE); + if (wait_for_animation) { + unity_testing_director_do_wait_for_animation (self, actor); + } if (autorelease) { ClutterEvent _tmp2_; event.type = CLUTTER_BUTTON_RELEASE; event.time = clutter_get_current_event_time (); unity_testing_director_do_event (self, actor, (_tmp2_ = (ClutterEvent) event, &_tmp2_), FALSE); + if (wait_for_animation) { + unity_testing_director_do_wait_for_animation (self, actor); + } } } @@ -212,11 +277,6 @@ ClutterStage* unity_testing_director_get_stage (UnityTestingDirector* self) { } -static gpointer _g_object_ref0 (gpointer self) { - return self ? g_object_ref (self) : NULL; -} - - static void unity_testing_director_set_stage (UnityTestingDirector* self, ClutterStage* value) { ClutterStage* _tmp0_; g_return_if_fail (self != NULL); @@ -251,6 +311,7 @@ static void unity_testing_director_class_init (UnityTestingDirectorClass * klass static void unity_testing_director_instance_init (UnityTestingDirector * self) { self->priv = UNITY_TESTING_DIRECTOR_GET_PRIVATE (self); + self->priv->break_loop = FALSE; } diff --git a/unity-private/testing/test-director.vala b/unity-private/testing/test-director.vala index f995b1d0b..fe040f54a 100644 --- a/unity-private/testing/test-director.vala +++ b/unity-private/testing/test-director.vala @@ -25,6 +25,8 @@ namespace Unity.Testing get; construct; } + + private bool break_loop = false; public Director (Clutter.Stage stage) { @@ -45,11 +47,34 @@ namespace Unity.Testing Gtk.main_iteration (); } + public void do_wait_for_animation (Clutter.Actor actor) + { + Clutter.Animation? anim = actor.get_animation (); + + while (anim is Clutter.Animation + && anim.timeline.is_playing ()) + { + Gtk.main_iteration (); + } + } + + public void do_wait_for_timeout (uint32 msecs) + { + break_loop = false; + GLib.Timeout.add (msecs, + () => { this.break_loop = true; return false; }); + while (break_loop != true) + { + Gtk.main_iteration (); + } + } + public void button_press (Clutter.Actor actor, uint32 button, bool autorelease, float relative_x, - float relative_y) + float relative_y, + bool wait_for_animation) { float actor_x, actor_y; Clutter.ButtonEvent event = Clutter.ButtonEvent (); @@ -66,13 +91,20 @@ namespace Unity.Testing event.button = button; do_event (actor, (Clutter.Event)event, false); - + + if (wait_for_animation) + do_wait_for_animation(actor); + if (autorelease) { event.type = Clutter.EventType.BUTTON_RELEASE; event.time = Clutter.get_current_event_time (); do_event (actor, (Clutter.Event)event, false); + + if (wait_for_animation) + do_wait_for_animation(actor); + } } diff --git a/unity-private/testing/test-utils.c b/unity-private/testing/test-utils.c index 50d7e5d74..caea7b544 100644 --- a/unity-private/testing/test-utils.c +++ b/unity-private/testing/test-utils.c @@ -323,28 +323,40 @@ static gboolean string_contains (const char* self, const char* needle) { gboolean unity_testing_logging_fatal_handler (const char* log_domain, GLogLevelFlags flags, const char* message) { gboolean result = FALSE; - if (string_contains (log_domain, "ndicator")) { + if (log_domain == NULL) { + result = TRUE; + return result; + } + if (string_contains (log_domain, "liblauncher")) { result = FALSE; return result; } - if (string_contains (message, "widget class `GtkImage' has no property named `x-ayatana-indicator-dyn" \ -"amic'")) { + if (string_contains (log_domain, "bamfdaemon")) { result = FALSE; return result; } - if (string_contains (message, "is currently inside an allocation cycle")) { + if (string_contains (log_domain, "Gtk")) { result = FALSE; return result; } - if (string_contains (log_domain, "liblauncher")) { + if (string_contains (log_domain, "ndicator")) { result = FALSE; return result; } - if (string_contains (log_domain, "bamfdaemon")) { + if (message == NULL) { + result = TRUE; + return result; + } + if (string_contains (message, "widget class `GtkImage' has no property named `x-ayatana-indicator-dyn" \ +"amic'")) { result = FALSE; return result; } - if (string_contains (log_domain, "Gtk")) { + if (string_contains (message, "is currently inside an allocation cycle")) { + result = FALSE; + return result; + } + if (string_contains (message, "Bamf r")) { result = FALSE; return result; } @@ -354,7 +366,9 @@ gboolean unity_testing_logging_fatal_handler (const char* log_domain, GLogLevelF static gboolean _unity_testing_logging_fatal_handler_gtest_log_log_fatal_func (const char* log_domain, GLogLevelFlags flags, const char* message, gpointer self) { - return unity_testing_logging_fatal_handler (log_domain, flags, message); + gboolean result; + result = unity_testing_logging_fatal_handler (log_domain, flags, message); + return result; } diff --git a/unity-private/testing/test-utils.vala b/unity-private/testing/test-utils.vala index f55543703..4b8530f75 100644 --- a/unity-private/testing/test-utils.vala +++ b/unity-private/testing/test-utils.vala @@ -45,24 +45,31 @@ namespace Unity.Testing LogLevelFlags flags, string? message) { - if ("ndicator" in log_domain) + if (log_domain == null) + return true; + + if ("liblauncher" in log_domain) return false; - if ("widget class `GtkImage' has no property named `x-ayatana-indicator-dynamic'" in message) + if ("bamfdaemon" in log_domain) return false; - if ("is currently inside an allocation cycle" in message) + if ("Gtk" in log_domain) return false; + if ("ndicator" in log_domain) + return false; - // ignore liblauncher - we don't want to test liblauncher its going away - if ("liblauncher" in log_domain) + if (message == null) + return true; + + if ("widget class `GtkImage' has no property named `x-ayatana-indicator-dynamic'" in message) return false; - if ("bamfdaemon" in log_domain) + if ("is currently inside an allocation cycle" in message) return false; - if ("Gtk" in log_domain) + if ("Bamf r" in message) return false; return true; diff --git a/unity-private/testing/test-window.c b/unity-private/testing/test-window.c index c7335a60b..57c738287 100644 --- a/unity-private/testing/test-window.c +++ b/unity-private/testing/test-window.c @@ -193,6 +193,7 @@ gint unity_testing_window_get_popup_width (UnityTestingWindow* self); gint unity_testing_window_get_popup_height (UnityTestingWindow* self); void utils_set_strut (GtkWindow* window, guint32 strut_size, guint32 strut_start, guint32 strut_end, guint32 top_size, guint32 top_start, guint32 top_end); ClutterActor* unity_launcher_launcher_get_view (UnityLauncherLauncher* self); +#define UNITY_PANEL_PANEL_HEIGHT 24 static void unity_testing_window_relayout (UnityTestingWindow* self); static void unity_testing_window_real_show (GtkWidget* base); void unity_testing_window_on_active_window_changed (UnityTestingWindow* self, WnckWindow* previous_window); @@ -205,6 +206,10 @@ void unity_panel_view_set_indicator_mode (UnityPanelView* self, gboolean mode); static void unity_testing_window_real_show_unity (UnityShell* base); gint unity_panel_view_get_indicators_width (UnityPanelView* self); static gint unity_testing_window_real_get_indicators_width (UnityShell* base); +float unity_launcher_launcher_get_width (UnityLauncherLauncher* self); +static gint unity_testing_window_real_get_launcher_width_foobar (UnityShell* base); +gint unity_panel_view_get_panel_height (UnityPanelView* self); +static gint unity_testing_window_real_get_panel_height_foobar (UnityShell* base); static void unity_testing_window_real_add_fullscreen_request (UnityShell* base, GObject* o); static gboolean unity_testing_window_real_remove_fullscreen_request (UnityShell* base, GObject* o); static void unity_testing_window_real_ensure_input_region (UnityShell* base); @@ -218,14 +223,14 @@ static void unity_testing_window_set_popup_height (UnityTestingWindow* self, gin UnityTestingWorkarea* unity_testing_workarea_new (void); UnityTestingWorkarea* unity_testing_workarea_construct (GType object_type); void unity_testing_workarea_update_net_workarea (UnityTestingWorkarea* self); -static gboolean _lambda15_ (UnityTestingWindow* self); -static gboolean __lambda15__gtk_widget_delete_event (GtkWidget* _sender, GdkEvent* event, gpointer self); -static gboolean _lambda16_ (UnityTestingWindow* self); -static gboolean __lambda16__gtk_widget_delete_event (GtkWidget* _sender, GdkEvent* event, gpointer self); -static void _lambda17_ (GdkScreen* s, UnityTestingWindow* self); -static void __lambda17__gdk_screen_size_changed (GdkScreen* _sender, gpointer self); -static void _lambda18_ (GdkScreen* s, UnityTestingWindow* self); -static void __lambda18__gdk_screen_monitors_changed (GdkScreen* _sender, gpointer self); +static gboolean _lambda19_ (UnityTestingWindow* self); +static gboolean __lambda19__gtk_widget_delete_event (GtkWidget* _sender, GdkEvent* event, gpointer self); +static gboolean _lambda20_ (UnityTestingWindow* self); +static gboolean __lambda20__gtk_widget_delete_event (GtkWidget* _sender, GdkEvent* event, gpointer self); +static void _lambda21_ (GdkScreen* s, UnityTestingWindow* self); +static void __lambda21__gdk_screen_size_changed (GdkScreen* _sender, gpointer self); +static void _lambda22_ (GdkScreen* s, UnityTestingWindow* self); +static void __lambda22__gdk_screen_monitors_changed (GdkScreen* _sender, gpointer self); static gboolean _unity_testing_window_on_stage_button_press_clutter_actor_button_press_event (ClutterActor* _sender, ClutterEvent* event, gpointer self); UnityTestingBackground* unity_testing_background_new (void); UnityTestingBackground* unity_testing_background_construct (GType object_type); @@ -306,15 +311,15 @@ static void unity_testing_window_relayout (UnityTestingWindow* self) { } clutter_actor_set_position ((ClutterActor*) self->priv->background, (float) 0, (float) 0); clutter_actor_set_size ((ClutterActor*) self->priv->background, (float) width, (float) height); - clutter_actor_set_size (_tmp0_ = unity_launcher_launcher_get_view (self->priv->launcher), ql_width, (float) (height - 23)); + clutter_actor_set_size (_tmp0_ = unity_launcher_launcher_get_view (self->priv->launcher), ql_width, (float) (height - UNITY_PANEL_PANEL_HEIGHT)); _g_object_unref0 (_tmp0_); - clutter_actor_set_position (_tmp1_ = unity_launcher_launcher_get_view (self->priv->launcher), (float) 0, (float) 23); + clutter_actor_set_position (_tmp1_ = unity_launcher_launcher_get_view (self->priv->launcher), (float) 0, (float) UNITY_PANEL_PANEL_HEIGHT); _g_object_unref0 (_tmp1_); if (self->priv->places_enabled) { clutter_actor_set_size ((ClutterActor*) self->priv->places, (float) width, (float) height); clutter_actor_set_position ((ClutterActor*) self->priv->places, (float) 0, (float) 0); } - clutter_actor_set_size ((ClutterActor*) self->priv->panel, (float) width, (float) 23); + clutter_actor_set_size ((ClutterActor*) self->priv->panel, (float) width, (float) UNITY_PANEL_PANEL_HEIGHT); clutter_actor_set_position ((ClutterActor*) self->priv->panel, (float) 0, (float) 0); } @@ -441,6 +446,24 @@ static gint unity_testing_window_real_get_indicators_width (UnityShell* base) { } +static gint unity_testing_window_real_get_launcher_width_foobar (UnityShell* base) { + UnityTestingWindow * self; + gint result = 0; + self = (UnityTestingWindow*) base; + result = (gint) unity_launcher_launcher_get_width (self->priv->launcher); + return result; +} + + +static gint unity_testing_window_real_get_panel_height_foobar (UnityShell* base) { + UnityTestingWindow * self; + gint result = 0; + self = (UnityTestingWindow*) base; + result = (gint) unity_panel_view_get_panel_height (self->priv->panel); + return result; +} + + static void unity_testing_window_real_add_fullscreen_request (UnityShell* base, GObject* o) { UnityTestingWindow * self; self = (UnityTestingWindow*) base; @@ -577,7 +600,7 @@ static void unity_testing_window_set_popup_height (UnityTestingWindow* self, gin } -static gboolean _lambda15_ (UnityTestingWindow* self) { +static gboolean _lambda19_ (UnityTestingWindow* self) { gboolean result = FALSE; gtk_main_quit (); result = FALSE; @@ -585,47 +608,53 @@ static gboolean _lambda15_ (UnityTestingWindow* self) { } -static gboolean __lambda15__gtk_widget_delete_event (GtkWidget* _sender, GdkEvent* event, gpointer self) { - return _lambda15_ (self); +static gboolean __lambda19__gtk_widget_delete_event (GtkWidget* _sender, GdkEvent* event, gpointer self) { + gboolean result; + result = _lambda19_ (self); + return result; } -static gboolean _lambda16_ (UnityTestingWindow* self) { +static gboolean _lambda20_ (UnityTestingWindow* self) { gboolean result = FALSE; result = TRUE; return result; } -static gboolean __lambda16__gtk_widget_delete_event (GtkWidget* _sender, GdkEvent* event, gpointer self) { - return _lambda16_ (self); +static gboolean __lambda20__gtk_widget_delete_event (GtkWidget* _sender, GdkEvent* event, gpointer self) { + gboolean result; + result = _lambda20_ (self); + return result; } -static void _lambda17_ (GdkScreen* s, UnityTestingWindow* self) { +static void _lambda21_ (GdkScreen* s, UnityTestingWindow* self) { g_return_if_fail (s != NULL); unity_testing_window_relayout (self); } -static void __lambda17__gdk_screen_size_changed (GdkScreen* _sender, gpointer self) { - _lambda17_ (_sender, self); +static void __lambda21__gdk_screen_size_changed (GdkScreen* _sender, gpointer self) { + _lambda21_ (_sender, self); } -static void _lambda18_ (GdkScreen* s, UnityTestingWindow* self) { +static void _lambda22_ (GdkScreen* s, UnityTestingWindow* self) { g_return_if_fail (s != NULL); unity_testing_window_relayout (self); } -static void __lambda18__gdk_screen_monitors_changed (GdkScreen* _sender, gpointer self) { - _lambda18_ (_sender, self); +static void __lambda22__gdk_screen_monitors_changed (GdkScreen* _sender, gpointer self) { + _lambda22_ (_sender, self); } static gboolean _unity_testing_window_on_stage_button_press_clutter_actor_button_press_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_testing_window_on_stage_button_press (self, event); + gboolean result; + result = unity_testing_window_on_stage_button_press (self, event); + return result; } @@ -674,7 +703,7 @@ static GObject * unity_testing_window_constructor (GType type, guint n_construct gtk_window_set_decorated ((GtkWindow*) self, TRUE); gtk_window_set_skip_taskbar_hint ((GtkWindow*) self, FALSE); gtk_window_set_skip_pager_hint ((GtkWindow*) self, FALSE); - g_signal_connect_object ((GtkWidget*) self, "delete-event", (GCallback) __lambda15__gtk_widget_delete_event, self, 0); + g_signal_connect_object ((GtkWidget*) self, "delete-event", (GCallback) __lambda19__gtk_widget_delete_event, self, 0); } else { gtk_window_set_type_hint ((GtkWindow*) self, GDK_WINDOW_TYPE_HINT_DESKTOP); gtk_window_set_keep_below ((GtkWindow*) self, TRUE); @@ -683,9 +712,9 @@ static GObject * unity_testing_window_constructor (GType type, guint n_construct gtk_window_set_skip_pager_hint ((GtkWindow*) self, TRUE); gtk_window_set_accept_focus ((GtkWindow*) self, FALSE); g_object_set ((GtkWidget*) self, "can-focus", FALSE, NULL); - g_signal_connect_object ((GtkWidget*) self, "delete-event", (GCallback) __lambda16__gtk_widget_delete_event, self, 0); - g_signal_connect_object (gtk_window_get_screen ((GtkWindow*) self), "size-changed", (GCallback) __lambda17__gdk_screen_size_changed, self, 0); - g_signal_connect_object (gtk_window_get_screen ((GtkWindow*) self), "monitors-changed", (GCallback) __lambda18__gdk_screen_monitors_changed, self, 0); + g_signal_connect_object ((GtkWidget*) self, "delete-event", (GCallback) __lambda20__gtk_widget_delete_event, self, 0); + g_signal_connect_object (gtk_window_get_screen ((GtkWindow*) self), "size-changed", (GCallback) __lambda21__gdk_screen_size_changed, self, 0); + g_signal_connect_object (gtk_window_get_screen ((GtkWindow*) self), "monitors-changed", (GCallback) __lambda22__gdk_screen_monitors_changed, self, 0); } gtk_window_set_title ((GtkWindow*) self, "Unity"); gtk_window_set_icon_name ((GtkWindow*) self, "distributor-logo"); @@ -763,6 +792,8 @@ static void unity_testing_window_unity_shell_interface_init (UnityShellIface * i iface->get_mode = unity_testing_window_real_get_mode; iface->show_unity = unity_testing_window_real_show_unity; iface->get_indicators_width = unity_testing_window_real_get_indicators_width; + iface->get_launcher_width_foobar = unity_testing_window_real_get_launcher_width_foobar; + iface->get_panel_height_foobar = unity_testing_window_real_get_panel_height_foobar; iface->add_fullscreen_request = unity_testing_window_real_add_fullscreen_request; iface->remove_fullscreen_request = unity_testing_window_real_remove_fullscreen_request; iface->ensure_input_region = unity_testing_window_real_ensure_input_region; diff --git a/unity-private/testing/test-window.vala b/unity-private/testing/test-window.vala index 491f11d4b..611be3103 100644 --- a/unity-private/testing/test-window.vala +++ b/unity-private/testing/test-window.vala @@ -213,8 +213,9 @@ namespace Unity.Testing this.background.set_position (0, 0); this.background.set_size (width, height); - this.launcher.get_view ().set_size (ql_width, height - 23); - this.launcher.get_view ().set_position (0, 23); + this.launcher.get_view ().set_size (ql_width, + height - Unity.Panel.PANEL_HEIGHT); + this.launcher.get_view ().set_position (0, Unity.Panel.PANEL_HEIGHT); if (this.places_enabled) { @@ -222,7 +223,7 @@ namespace Unity.Testing this.places.set_position (0, 0); } - this.panel.set_size (width, 23); + this.panel.set_size (width, Unity.Panel.PANEL_HEIGHT); this.panel.set_position (0, 0); } @@ -331,6 +332,16 @@ namespace Unity.Testing return this.panel.get_indicators_width (); } + public int get_launcher_width_foobar () + { + return (int) this.launcher.get_width (); + } + + public int get_panel_height_foobar () + { + return (int) this.panel.get_panel_height (); + } + public void add_fullscreen_request (Object o) { return; diff --git a/unity-private/unity-private.h b/unity-private/unity-private.h index df2adf83b..57fa34a6a 100644 --- a/unity-private/unity-private.h +++ b/unity-private/unity-private.h @@ -19,11 +19,11 @@ #include <X11/Xutil.h> #include <X11/Xregion.h> #include <clutk/clutk.h> +#include <gee.h> #include <libindicator/indicator-object.h> #include <libindicator/indicator.h> #include <libindicator/indicator-service.h> #include <libindicator/indicator-service-manager.h> -#include <gee.h> #include <libbamf/libbamf.h> #include <float.h> #include <math.h> @@ -47,6 +47,17 @@ typedef struct _UnityApplication UnityApplication; typedef struct _UnityApplicationClass UnityApplicationClass; typedef struct _UnityApplicationPrivate UnityApplicationPrivate; +#define UNITY_PANEL_TYPE_BACKGROUND (unity_panel_background_get_type ()) +#define UNITY_PANEL_BACKGROUND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_TYPE_BACKGROUND, UnityPanelBackground)) +#define UNITY_PANEL_BACKGROUND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_TYPE_BACKGROUND, UnityPanelBackgroundClass)) +#define UNITY_PANEL_IS_BACKGROUND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_TYPE_BACKGROUND)) +#define UNITY_PANEL_IS_BACKGROUND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_TYPE_BACKGROUND)) +#define UNITY_PANEL_BACKGROUND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_TYPE_BACKGROUND, UnityPanelBackgroundClass)) + +typedef struct _UnityPanelBackground UnityPanelBackground; +typedef struct _UnityPanelBackgroundClass UnityPanelBackgroundClass; +typedef struct _UnityPanelBackgroundPrivate UnityPanelBackgroundPrivate; + #define UNITY_PANEL_TYPE_HOME_BUTTON (unity_panel_home_button_get_type ()) #define UNITY_PANEL_HOME_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_TYPE_HOME_BUTTON, UnityPanelHomeButton)) #define UNITY_PANEL_HOME_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_TYPE_HOME_BUTTON, UnityPanelHomeButtonClass)) @@ -58,6 +69,61 @@ typedef struct _UnityPanelHomeButton UnityPanelHomeButton; typedef struct _UnityPanelHomeButtonClass UnityPanelHomeButtonClass; typedef struct _UnityPanelHomeButtonPrivate UnityPanelHomeButtonPrivate; +#define UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR (unity_panel_indicators_indicator_bar_get_type ()) +#define UNITY_PANEL_INDICATORS_INDICATOR_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR, UnityPanelIndicatorsIndicatorBar)) +#define UNITY_PANEL_INDICATORS_INDICATOR_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR, UnityPanelIndicatorsIndicatorBarClass)) +#define UNITY_PANEL_INDICATORS_IS_INDICATOR_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR)) +#define UNITY_PANEL_INDICATORS_IS_INDICATOR_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR)) +#define UNITY_PANEL_INDICATORS_INDICATOR_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR, UnityPanelIndicatorsIndicatorBarClass)) + +typedef struct _UnityPanelIndicatorsIndicatorBar UnityPanelIndicatorsIndicatorBar; +typedef struct _UnityPanelIndicatorsIndicatorBarClass UnityPanelIndicatorsIndicatorBarClass; +typedef struct _UnityPanelIndicatorsIndicatorBarPrivate UnityPanelIndicatorsIndicatorBarPrivate; + +#define UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL (unity_panel_indicators_indicators_model_get_type ()) +#define UNITY_PANEL_INDICATORS_INDICATORS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL, UnityPanelIndicatorsIndicatorsModel)) +#define UNITY_PANEL_INDICATORS_INDICATORS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL, UnityPanelIndicatorsIndicatorsModelClass)) +#define UNITY_PANEL_INDICATORS_IS_INDICATORS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL)) +#define UNITY_PANEL_INDICATORS_IS_INDICATORS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL)) +#define UNITY_PANEL_INDICATORS_INDICATORS_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL, UnityPanelIndicatorsIndicatorsModelClass)) + +typedef struct _UnityPanelIndicatorsIndicatorsModel UnityPanelIndicatorsIndicatorsModel; +typedef struct _UnityPanelIndicatorsIndicatorsModelClass UnityPanelIndicatorsIndicatorsModelClass; +typedef struct _UnityPanelIndicatorsIndicatorsModelPrivate UnityPanelIndicatorsIndicatorsModelPrivate; + +#define UNITY_PANEL_INDICATORS_TYPE_INDICATORS_FILE_MODEL (unity_panel_indicators_indicators_file_model_get_type ()) +#define UNITY_PANEL_INDICATORS_INDICATORS_FILE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_FILE_MODEL, UnityPanelIndicatorsIndicatorsFileModel)) +#define UNITY_PANEL_INDICATORS_INDICATORS_FILE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_FILE_MODEL, UnityPanelIndicatorsIndicatorsFileModelClass)) +#define UNITY_PANEL_INDICATORS_IS_INDICATORS_FILE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_FILE_MODEL)) +#define UNITY_PANEL_INDICATORS_IS_INDICATORS_FILE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_FILE_MODEL)) +#define UNITY_PANEL_INDICATORS_INDICATORS_FILE_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_FILE_MODEL, UnityPanelIndicatorsIndicatorsFileModelClass)) + +typedef struct _UnityPanelIndicatorsIndicatorsFileModel UnityPanelIndicatorsIndicatorsFileModel; +typedef struct _UnityPanelIndicatorsIndicatorsFileModelClass UnityPanelIndicatorsIndicatorsFileModelClass; +typedef struct _UnityPanelIndicatorsIndicatorsFileModelPrivate UnityPanelIndicatorsIndicatorsFileModelPrivate; + +#define UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_ENTRY_VIEW (unity_panel_indicators_indicator_object_entry_view_get_type ()) +#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_ENTRY_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_ENTRY_VIEW, UnityPanelIndicatorsIndicatorObjectEntryView)) +#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_ENTRY_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_ENTRY_VIEW, UnityPanelIndicatorsIndicatorObjectEntryViewClass)) +#define UNITY_PANEL_INDICATORS_IS_INDICATOR_OBJECT_ENTRY_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_ENTRY_VIEW)) +#define UNITY_PANEL_INDICATORS_IS_INDICATOR_OBJECT_ENTRY_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_ENTRY_VIEW)) +#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_ENTRY_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_ENTRY_VIEW, UnityPanelIndicatorsIndicatorObjectEntryViewClass)) + +typedef struct _UnityPanelIndicatorsIndicatorObjectEntryView UnityPanelIndicatorsIndicatorObjectEntryView; +typedef struct _UnityPanelIndicatorsIndicatorObjectEntryViewClass UnityPanelIndicatorsIndicatorObjectEntryViewClass; +typedef struct _UnityPanelIndicatorsIndicatorObjectEntryViewPrivate UnityPanelIndicatorsIndicatorObjectEntryViewPrivate; + +#define UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW (unity_panel_indicators_indicator_object_view_get_type ()) +#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW, UnityPanelIndicatorsIndicatorObjectView)) +#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW, UnityPanelIndicatorsIndicatorObjectViewClass)) +#define UNITY_PANEL_INDICATORS_IS_INDICATOR_OBJECT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW)) +#define UNITY_PANEL_INDICATORS_IS_INDICATOR_OBJECT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW)) +#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW, UnityPanelIndicatorsIndicatorObjectViewClass)) + +typedef struct _UnityPanelIndicatorsIndicatorObjectView UnityPanelIndicatorsIndicatorObjectView; +typedef struct _UnityPanelIndicatorsIndicatorObjectViewClass UnityPanelIndicatorsIndicatorObjectViewClass; +typedef struct _UnityPanelIndicatorsIndicatorObjectViewPrivate UnityPanelIndicatorsIndicatorObjectViewPrivate; + #define UNITY_PANEL_INDICATORS_TYPE_VIEW (unity_panel_indicators_view_get_type ()) #define UNITY_PANEL_INDICATORS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_INDICATORS_TYPE_VIEW, UnityPanelIndicatorsView)) #define UNITY_PANEL_INDICATORS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_INDICATORS_TYPE_VIEW, UnityPanelIndicatorsViewClass)) @@ -91,16 +157,38 @@ typedef struct _UnityPanelIndicatorsIndicatorEntryClass UnityPanelIndicatorsIndi typedef struct _UnityPanelIndicatorsIndicatorItemPrivate UnityPanelIndicatorsIndicatorItemPrivate; typedef struct _UnityPanelIndicatorsIndicatorEntryPrivate UnityPanelIndicatorsIndicatorEntryPrivate; -#define UNITY_PANEL_TRAY_TYPE_VIEW (unity_panel_tray_view_get_type ()) -#define UNITY_PANEL_TRAY_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_TRAY_TYPE_VIEW, UnityPanelTrayView)) -#define UNITY_PANEL_TRAY_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_TRAY_TYPE_VIEW, UnityPanelTrayViewClass)) -#define UNITY_PANEL_TRAY_IS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_TRAY_TYPE_VIEW)) -#define UNITY_PANEL_TRAY_IS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_TRAY_TYPE_VIEW)) -#define UNITY_PANEL_TRAY_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_TRAY_TYPE_VIEW, UnityPanelTrayViewClass)) - -typedef struct _UnityPanelTrayView UnityPanelTrayView; -typedef struct _UnityPanelTrayViewClass UnityPanelTrayViewClass; -typedef struct _UnityPanelTrayViewPrivate UnityPanelTrayViewPrivate; +#define TYPE_MENU_MANAGER (menu_manager_get_type ()) +#define MENU_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MENU_MANAGER, MenuManager)) +#define MENU_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MENU_MANAGER, MenuManagerClass)) +#define IS_MENU_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MENU_MANAGER)) +#define IS_MENU_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MENU_MANAGER)) +#define MENU_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MENU_MANAGER, MenuManagerClass)) + +typedef struct _MenuManager MenuManager; +typedef struct _MenuManagerClass MenuManagerClass; +typedef struct _MenuManagerPrivate MenuManagerPrivate; + +#define UNITY_PANEL_INDICATORS_TYPE_MENU_BAR (unity_panel_indicators_menu_bar_get_type ()) +#define UNITY_PANEL_INDICATORS_MENU_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_INDICATORS_TYPE_MENU_BAR, UnityPanelIndicatorsMenuBar)) +#define UNITY_PANEL_INDICATORS_MENU_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_INDICATORS_TYPE_MENU_BAR, UnityPanelIndicatorsMenuBarClass)) +#define UNITY_PANEL_INDICATORS_IS_MENU_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_INDICATORS_TYPE_MENU_BAR)) +#define UNITY_PANEL_INDICATORS_IS_MENU_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_INDICATORS_TYPE_MENU_BAR)) +#define UNITY_PANEL_INDICATORS_MENU_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_INDICATORS_TYPE_MENU_BAR, UnityPanelIndicatorsMenuBarClass)) + +typedef struct _UnityPanelIndicatorsMenuBar UnityPanelIndicatorsMenuBar; +typedef struct _UnityPanelIndicatorsMenuBarClass UnityPanelIndicatorsMenuBarClass; +typedef struct _UnityPanelIndicatorsMenuBarPrivate UnityPanelIndicatorsMenuBarPrivate; + +#define UNITY_PANEL_TYPE_SYSTEM_TRAY (unity_panel_system_tray_get_type ()) +#define UNITY_PANEL_SYSTEM_TRAY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_TYPE_SYSTEM_TRAY, UnityPanelSystemTray)) +#define UNITY_PANEL_SYSTEM_TRAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_TYPE_SYSTEM_TRAY, UnityPanelSystemTrayClass)) +#define UNITY_PANEL_IS_SYSTEM_TRAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_TYPE_SYSTEM_TRAY)) +#define UNITY_PANEL_IS_SYSTEM_TRAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_TYPE_SYSTEM_TRAY)) +#define UNITY_PANEL_SYSTEM_TRAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_TYPE_SYSTEM_TRAY, UnityPanelSystemTrayClass)) + +typedef struct _UnityPanelSystemTray UnityPanelSystemTray; +typedef struct _UnityPanelSystemTrayClass UnityPanelSystemTrayClass; +typedef struct _UnityPanelSystemTrayPrivate UnityPanelSystemTrayPrivate; #define UNITY_PANEL_TYPE_VIEW (unity_panel_view_get_type ()) #define UNITY_PANEL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_TYPE_VIEW, UnityPanelView)) @@ -656,14 +744,74 @@ struct _UnityApplicationClass { UniqueAppClass parent_class; }; +struct _UnityPanelBackground { + ClutterCairoTexture parent_instance; + UnityPanelBackgroundPrivate * priv; +}; + +struct _UnityPanelBackgroundClass { + ClutterCairoTextureClass parent_class; +}; + struct _UnityPanelHomeButton { - CtkBin parent_instance; + CtkButton parent_instance; UnityPanelHomeButtonPrivate * priv; - UnityThemeImage* image; + UnityThemeImage* theme_image; }; struct _UnityPanelHomeButtonClass { - CtkBinClass parent_class; + CtkButtonClass parent_class; +}; + +struct _UnityPanelIndicatorsIndicatorBar { + CtkBox parent_instance; + UnityPanelIndicatorsIndicatorBarPrivate * priv; +}; + +struct _UnityPanelIndicatorsIndicatorBarClass { + CtkBoxClass parent_class; +}; + +struct _UnityPanelIndicatorsIndicatorsModel { + GObject parent_instance; + UnityPanelIndicatorsIndicatorsModelPrivate * priv; +}; + +struct _UnityPanelIndicatorsIndicatorsModelClass { + GObjectClass parent_class; + GeeArrayList* (*get_indicators) (UnityPanelIndicatorsIndicatorsModel* self); + char* (*get_indicator_name) (UnityPanelIndicatorsIndicatorsModel* self, IndicatorObject* o); +}; + +struct _UnityPanelIndicatorsIndicatorsFileModel { + UnityPanelIndicatorsIndicatorsModel parent_instance; + UnityPanelIndicatorsIndicatorsFileModelPrivate * priv; + GeeHashMap* indicator_map; + GeeArrayList* indicator_list; +}; + +struct _UnityPanelIndicatorsIndicatorsFileModelClass { + UnityPanelIndicatorsIndicatorsModelClass parent_class; +}; + +struct _UnityPanelIndicatorsIndicatorObjectEntryView { + CtkBox parent_instance; + UnityPanelIndicatorsIndicatorObjectEntryViewPrivate * priv; + CtkImage* image; + CtkText* text; +}; + +struct _UnityPanelIndicatorsIndicatorObjectEntryViewClass { + CtkBoxClass parent_class; +}; + +struct _UnityPanelIndicatorsIndicatorObjectView { + CtkBox parent_instance; + UnityPanelIndicatorsIndicatorObjectViewPrivate * priv; +}; + +struct _UnityPanelIndicatorsIndicatorObjectViewClass { + CtkBoxClass parent_class; }; struct _UnityPanelIndicatorsView { @@ -694,22 +842,41 @@ struct _UnityPanelIndicatorsIndicatorEntryClass { CtkBoxClass parent_class; }; -struct _UnityPanelTrayView { +struct _MenuManager { + GObject parent_instance; + MenuManagerPrivate * priv; +}; + +struct _MenuManagerClass { + GObjectClass parent_class; +}; + +struct _UnityPanelIndicatorsMenuBar { + CtkBox parent_instance; + UnityPanelIndicatorsMenuBarPrivate * priv; +}; + +struct _UnityPanelIndicatorsMenuBarClass { + CtkBoxClass parent_class; +}; + +struct _UnityPanelSystemTray { CtkBox parent_instance; - UnityPanelTrayViewPrivate * priv; + UnityPanelSystemTrayPrivate * priv; }; -struct _UnityPanelTrayViewClass { +struct _UnityPanelSystemTrayClass { CtkBoxClass parent_class; }; struct _UnityPanelView { - CtkActor parent_instance; + CtkBox parent_instance; UnityPanelViewPrivate * priv; + gboolean expanded; }; struct _UnityPanelViewClass { - CtkActorClass parent_class; + CtkBoxClass parent_class; }; struct _UnityPlacesApplicationApplicationIcon { @@ -1250,10 +1417,45 @@ Window utils_get_stage_window (ClutterStage* stage); gboolean utils_save_snapshot (ClutterStage* stage, const char* filename, gint x, gint y, gint width, gint height); gboolean utils_compare_snapshot (ClutterStage* stage, const char* filename, gint x, gint y, gint width, gint height, gboolean expected); gboolean utils_utils_compare_images (const char* img1_path, const char* img2_path); +GType unity_panel_background_get_type (void); +#define UNITY_PANEL_BACKGROUND_BG "/usr/share/unity/themes/panel_background.png" +UnityPanelBackground* unity_panel_background_new (void); +UnityPanelBackground* unity_panel_background_construct (GType object_type); GType unity_panel_home_button_get_type (void); UnityPanelHomeButton* unity_panel_home_button_new (UnityShell* shell); UnityPanelHomeButton* unity_panel_home_button_construct (GType object_type, UnityShell* shell); UnityShell* unity_panel_home_button_get_shell (UnityPanelHomeButton* self); +GType unity_panel_indicators_indicator_bar_get_type (void); +UnityPanelIndicatorsIndicatorBar* unity_panel_indicators_indicator_bar_new (void); +UnityPanelIndicatorsIndicatorBar* unity_panel_indicators_indicator_bar_construct (GType object_type); +GType unity_panel_indicators_indicators_model_get_type (void); +UnityPanelIndicatorsIndicatorsModel* unity_panel_indicators_indicators_model_get_default (void); +void unity_panel_indicators_indicators_model_set_default (UnityPanelIndicatorsIndicatorsModel* model); +GeeArrayList* unity_panel_indicators_indicators_model_get_indicators (UnityPanelIndicatorsIndicatorsModel* self); +char* unity_panel_indicators_indicators_model_get_indicator_name (UnityPanelIndicatorsIndicatorsModel* self, IndicatorObject* o); +UnityPanelIndicatorsIndicatorsModel* unity_panel_indicators_indicators_model_construct (GType object_type); +GType unity_panel_indicators_indicators_file_model_get_type (void); +extern GeeHashMap* unity_panel_indicators_indicators_file_model_indicator_order; +UnityPanelIndicatorsIndicatorsFileModel* unity_panel_indicators_indicators_file_model_new (void); +UnityPanelIndicatorsIndicatorsFileModel* unity_panel_indicators_indicators_file_model_construct (GType object_type); +gint unity_panel_indicators_indicators_file_model_indicator_sort_func (const char* a, const char* b); +GType unity_panel_indicators_indicator_object_entry_view_get_type (void); +UnityPanelIndicatorsIndicatorObjectEntryView* unity_panel_indicators_indicator_object_entry_view_new (IndicatorObjectEntry* _entry); +UnityPanelIndicatorsIndicatorObjectEntryView* unity_panel_indicators_indicator_object_entry_view_construct (GType object_type, IndicatorObjectEntry* _entry); +void unity_panel_indicators_indicator_object_entry_view_show_menu (UnityPanelIndicatorsIndicatorObjectEntryView* self); +gboolean unity_panel_indicators_indicator_object_entry_view_on_button_press_event (UnityPanelIndicatorsIndicatorObjectEntryView* self, ClutterEvent* e); +gboolean unity_panel_indicators_indicator_object_entry_view_on_motion_event (UnityPanelIndicatorsIndicatorObjectEntryView* self, ClutterEvent* e); +void unity_panel_indicators_indicator_object_entry_view_menu_shown (UnityPanelIndicatorsIndicatorObjectEntryView* self); +void unity_panel_indicators_indicator_object_entry_view_menu_vis_changed (UnityPanelIndicatorsIndicatorObjectEntryView* self); +void unity_panel_indicators_indicator_object_entry_view_menu_key_moved (UnityPanelIndicatorsIndicatorObjectEntryView* self, GtkMenuDirectionType type); +IndicatorObjectEntry* unity_panel_indicators_indicator_object_entry_view_get_entry (UnityPanelIndicatorsIndicatorObjectEntryView* self); +GType unity_panel_indicators_indicator_object_view_get_type (void); +UnityPanelIndicatorsIndicatorObjectView* unity_panel_indicators_indicator_object_view_new (IndicatorObject* _object); +UnityPanelIndicatorsIndicatorObjectView* unity_panel_indicators_indicator_object_view_construct (GType object_type, IndicatorObject* _object); +void unity_panel_indicators_indicator_object_view_show_entry_menu (UnityPanelIndicatorsIndicatorObjectView* self, gint entry); +void unity_panel_indicators_indicator_object_view_open_first_menu_entry (UnityPanelIndicatorsIndicatorObjectView* self); +void unity_panel_indicators_indicator_object_view_open_last_menu_entry (UnityPanelIndicatorsIndicatorObjectView* self); +IndicatorObject* unity_panel_indicators_indicator_object_view_get_indicator_object (UnityPanelIndicatorsIndicatorObjectView* self); GType unity_panel_indicators_view_get_type (void); UnityPanelIndicatorsView* unity_panel_indicators_view_new (void); UnityPanelIndicatorsView* unity_panel_indicators_view_construct (GType object_type); @@ -1272,15 +1474,25 @@ void unity_panel_indicators_indicator_entry_menu_vis_changed (UnityPanelIndicato void unity_panel_indicators_indicator_entry_menu_key_moved (UnityPanelIndicatorsIndicatorEntry* self, GtkMenuDirectionType type); IndicatorObjectEntry* unity_panel_indicators_indicator_entry_get_entry (UnityPanelIndicatorsIndicatorEntry* self); GtkMenu* unity_panel_indicators_indicator_entry_get_menu (UnityPanelIndicatorsIndicatorEntry* self); -GType unity_panel_tray_view_get_type (void); -UnityPanelTrayView* unity_panel_tray_view_new (void); -UnityPanelTrayView* unity_panel_tray_view_construct (GType object_type); -void unity_panel_tray_view_manage_stage (UnityPanelTrayView* self, ClutterStage* stage); -extern gboolean* unity_panel_search_entry_has_focus; +GType menu_manager_get_type (void); +MenuManager* menu_manager_get_default (void); +void menu_manager_register_visible_menu (MenuManager* self, GtkMenu* menu); +gboolean menu_manager_menu_is_open (MenuManager* self); +MenuManager* menu_manager_new (void); +MenuManager* menu_manager_construct (GType object_type); +GType unity_panel_indicators_menu_bar_get_type (void); +UnityPanelIndicatorsMenuBar* unity_panel_indicators_menu_bar_new (void); +UnityPanelIndicatorsMenuBar* unity_panel_indicators_menu_bar_construct (GType object_type); +GType unity_panel_system_tray_get_type (void); +UnityPanelSystemTray* unity_panel_system_tray_new (void); +UnityPanelSystemTray* unity_panel_system_tray_construct (GType object_type); +void unity_panel_system_tray_manage_stage (UnityPanelSystemTray* self, ClutterStage* stage); GType unity_panel_view_get_type (void); UnityPanelView* unity_panel_view_new (UnityShell* shell); UnityPanelView* unity_panel_view_construct (GType object_type, UnityShell* shell); gint unity_panel_view_get_indicators_width (UnityPanelView* self); +void unity_panel_view_set_expanded (UnityPanelView* self, gboolean _expanded); +gint unity_panel_view_get_panel_height (UnityPanelView* self); void unity_panel_view_set_indicator_mode (UnityPanelView* self, gboolean mode); UnityShell* unity_panel_view_get_shell (UnityPanelView* self); gpointer unity_places_application_application_icon_ref (gpointer instance); @@ -1539,7 +1751,9 @@ UnityTimelineLogger* unity_timeline_logger_construct (GType object_type); GType unity_testing_director_get_type (void); UnityTestingDirector* unity_testing_director_new (ClutterStage* stage); UnityTestingDirector* unity_testing_director_construct (GType object_type, ClutterStage* stage); -void unity_testing_director_button_press (UnityTestingDirector* self, ClutterActor* actor, guint32 button, gboolean autorelease, float relative_x, float relative_y); +void unity_testing_director_do_wait_for_animation (UnityTestingDirector* self, ClutterActor* actor); +void unity_testing_director_do_wait_for_timeout (UnityTestingDirector* self, guint32 msecs); +void unity_testing_director_button_press (UnityTestingDirector* self, ClutterActor* actor, guint32 button, gboolean autorelease, float relative_x, float relative_y, gboolean wait_for_animation); void unity_testing_director_button_release (UnityTestingDirector* self, ClutterActor* actor, guint32 button, float relative_x, float relative_y); void unity_testing_director_enter_event (UnityTestingDirector* self, ClutterActor* actor, float relative_x, float relative_y); void unity_testing_director_leave_event (UnityTestingDirector* self, ClutterActor* actor, float relative_x, float relative_y); diff --git a/unity-private/unity-private.vapi b/unity-private/unity-private.vapi index e523eb451..f748f29a1 100644 --- a/unity-private/unity-private.vapi +++ b/unity-private/unity-private.vapi @@ -154,6 +154,10 @@ namespace Unity { [CCode (cprefix = "UnityPanelIndicators", lower_case_cprefix = "unity_panel_indicators_")] namespace Indicators { [CCode (cheader_filename = "unity-private.h")] + public class IndicatorBar : Ctk.Box { + public IndicatorBar (); + } + [CCode (cheader_filename = "unity-private.h")] public class IndicatorEntry : Ctk.Box { public IndicatorEntry (Indicator.ObjectEntry entry); public void menu_key_moved (Gtk.MenuDirectionType type); @@ -172,36 +176,83 @@ namespace Unity { public signal void menu_moved (Gtk.MenuDirectionType type); } [CCode (cheader_filename = "unity-private.h")] + public class IndicatorObjectEntryView : Ctk.Box { + public Ctk.Image image; + public Ctk.Text text; + public IndicatorObjectEntryView (Indicator.ObjectEntry _entry); + public void menu_key_moved (Gtk.MenuDirectionType type); + public void menu_shown (); + public void menu_vis_changed (); + public bool on_button_press_event (Clutter.Event e); + public bool on_motion_event (Clutter.Event e); + public void show_menu (); + public Indicator.ObjectEntry entry { get; construct; } + public signal void menu_moved (Gtk.MenuDirectionType type); + } + [CCode (cheader_filename = "unity-private.h")] + public class IndicatorObjectView : Ctk.Box { + public IndicatorObjectView (Indicator.Object _object); + public void open_first_menu_entry (); + public void open_last_menu_entry (); + public void show_entry_menu (int entry); + public Indicator.Object indicator_object { get; construct; } + public signal void menu_moved (Gtk.MenuDirectionType type); + } + [CCode (cheader_filename = "unity-private.h")] + public class IndicatorsFileModel : Unity.Panel.Indicators.IndicatorsModel { + public Gee.ArrayList<Indicator.Object> indicator_list; + public Gee.HashMap<Indicator.Object,string> indicator_map; + public static Gee.HashMap<string,int> indicator_order; + public IndicatorsFileModel (); + public override string get_indicator_name (Indicator.Object o); + public override Gee.ArrayList<Indicator.Object> get_indicators (); + public static int indicator_sort_func (string a, string b); + } + [CCode (cheader_filename = "unity-private.h")] + public abstract class IndicatorsModel : GLib.Object { + public IndicatorsModel (); + public static Unity.Panel.Indicators.IndicatorsModel get_default (); + public abstract string get_indicator_name (Indicator.Object o); + public abstract Gee.ArrayList<Indicator.Object> get_indicators (); + public static void set_default (Unity.Panel.Indicators.IndicatorsModel model); + } + [CCode (cheader_filename = "unity-private.h")] + public class MenuBar : Ctk.Box { + public MenuBar (); + } + [CCode (cheader_filename = "unity-private.h")] public class View : Ctk.Box { public View (); public static int reorder_icons (Unity.Panel.Indicators.IndicatorItem a, Unity.Panel.Indicators.IndicatorItem b); public void show_entry (Unity.Panel.Indicators.IndicatorEntry entry); } } - [CCode (cprefix = "UnityPanelTray", lower_case_cprefix = "unity_panel_tray_")] - namespace Tray { - [CCode (cheader_filename = "unity-private.h")] - public class View : Ctk.Box { - public View (); - public void manage_stage (Clutter.Stage stage); - } + [CCode (cheader_filename = "unity-private.h")] + public class Background : Clutter.CairoTexture { + public const string BG; + public Background (); } [CCode (cheader_filename = "unity-private.h")] - public class HomeButton : Ctk.Bin { - public Unity.ThemeImage image; + public class HomeButton : Ctk.Button { + public Unity.ThemeImage theme_image; public HomeButton (Unity.Shell shell); public Unity.Shell shell { get; construct; } - public signal void clicked (uint32 time_); } [CCode (cheader_filename = "unity-private.h")] - public class View : Ctk.Actor { + public class SystemTray : Ctk.Box { + public SystemTray (); + public void manage_stage (Clutter.Stage stage); + } + [CCode (cheader_filename = "unity-private.h")] + public class View : Ctk.Box { + public bool expanded; public View (Unity.Shell shell); public int get_indicators_width (); + public int get_panel_height (); + public void set_expanded (bool _expanded); public void set_indicator_mode (bool mode); public Unity.Shell shell { get; construct; } } - [CCode (cheader_filename = "unity-private.h")] - public static bool? search_entry_has_focus; } [CCode (cprefix = "UnityPlaces", lower_case_cprefix = "unity_places_")] namespace Places { @@ -431,8 +482,10 @@ namespace Unity { [CCode (cheader_filename = "unity-private.h")] public class Director : GLib.Object { public Director (Clutter.Stage stage); - public void button_press (Clutter.Actor actor, uint32 button, bool autorelease, float relative_x, float relative_y); + public void button_press (Clutter.Actor actor, uint32 button, bool autorelease, float relative_x, float relative_y, bool wait_for_animation); public void button_release (Clutter.Actor actor, uint32 button, float relative_x, float relative_y); + public void do_wait_for_animation (Clutter.Actor actor); + public void do_wait_for_timeout (uint32 msecs); public void enter_event (Clutter.Actor actor, float relative_x, float relative_y); public void leave_event (Clutter.Actor actor, float relative_x, float relative_y); public void motion_event (Clutter.Actor actor, float relative_startx, float relative_starty, float relative_endx, float relative_endy); @@ -536,3 +589,10 @@ namespace G { } } } +[CCode (cheader_filename = "unity-private.h")] +public class MenuManager : GLib.Object { + public MenuManager (); + public static MenuManager get_default (); + public bool menu_is_open (); + public void register_visible_menu (Gtk.Menu menu); +} diff --git a/unity-private/unity-utils.c b/unity-private/unity-utils.c index a68c4a2cc..99dc061e8 100644 --- a/unity-private/unity-utils.c +++ b/unity-private/unity-utils.c @@ -27,6 +27,8 @@ #include <clutter/clutter.h> #include <clutter/x11/clutter-x11.h> +#include <libindicator/indicator-object.h> + #include <gio/gio.h> #include <gtk/gtk.h> #include <gdk/gdkx.h> @@ -277,3 +279,18 @@ utils_compare_images (const gchar *img1_path, /* perceptualdiff exits '0' on failed comparison and '1' on successful */ return exit_status != 0; } + +IndicatorObjectEntry * +indicator_object_entry_new () +{ + return g_new0 (IndicatorObjectEntry, 1); +} + +void +indicator_object_entry_free (IndicatorObjectEntry *entry) +{ + if (G_LIKELY (entry)) + g_free (entry); + + entry = NULL; +} diff --git a/unity/drag-controller.c b/unity/drag-controller.c index cb20ae00b..d50849894 100644 --- a/unity/drag-controller.c +++ b/unity/drag-controller.c @@ -105,6 +105,8 @@ struct _UnityShellIface { ClutterStage* (*get_stage) (UnityShell* self); void (*show_unity) (UnityShell* self); gint (*get_indicators_width) (UnityShell* self); + gint (*get_launcher_width_foobar) (UnityShell* self); + gint (*get_panel_height_foobar) (UnityShell* self); void (*ensure_input_region) (UnityShell* self); void (*add_fullscreen_request) (UnityShell* self, GObject* o); gboolean (*remove_fullscreen_request) (UnityShell* self, GObject* o); diff --git a/unity/drag-view.c b/unity/drag-view.c index d6ec60895..081805c0a 100644 --- a/unity/drag-view.c +++ b/unity/drag-view.c @@ -102,7 +102,9 @@ UnityDragView* unity_drag_view_new (ClutterStage* stage) { static gboolean _unity_drag_view_captured_event_clutter_actor_captured_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_drag_view_captured_event (self, event); + gboolean result; + result = unity_drag_view_captured_event (self, event); + return result; } @@ -150,7 +152,9 @@ static gboolean unity_drag_view_captured_event (UnityDragView* self, ClutterEven static gboolean _unity_drag_view_on_motion_event_clutter_actor_motion_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_drag_view_on_motion_event (self, event); + gboolean result; + result = unity_drag_view_on_motion_event (self, event); + return result; } @@ -186,7 +190,9 @@ static gboolean unity_drag_view_on_motion_event (UnityDragView* self, ClutterEve static gboolean _unity_drag_view_on_release_event_clutter_actor_button_release_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_drag_view_on_release_event (self, event); + gboolean result; + result = unity_drag_view_on_release_event (self, event); + return result; } diff --git a/unity/entry.c b/unity/entry.c index bd1fe2d40..da1600259 100644 --- a/unity/entry.c +++ b/unity/entry.c @@ -75,6 +75,8 @@ struct _UnityShellIface { ClutterStage* (*get_stage) (UnityShell* self); void (*show_unity) (UnityShell* self); gint (*get_indicators_width) (UnityShell* self); + gint (*get_launcher_width_foobar) (UnityShell* self); + gint (*get_panel_height_foobar) (UnityShell* self); void (*ensure_input_region) (UnityShell* self); void (*add_fullscreen_request) (UnityShell* self, GObject* o); gboolean (*remove_fullscreen_request) (UnityShell* self, GObject* o); @@ -168,7 +170,9 @@ static void unity_entry_on_activate (UnityEntry* self) { static gboolean _unity_entry_on_stage_captured_event_clutter_actor_captured_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_entry_on_stage_captured_event (self, event); + gboolean result; + result = unity_entry_on_stage_captured_event (self, event); + return result; } @@ -241,7 +245,9 @@ static void _unity_entry_on_key_focus_out_clutter_actor_key_focus_out (ClutterAc static gboolean _unity_entry_on_button_press_event_clutter_actor_button_press_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) { - return unity_entry_on_button_press_event (self, event); + gboolean result; + result = unity_entry_on_button_press_event (self, event); + return result; } diff --git a/unity/icon-postprocessor.c b/unity/icon-postprocessor.c index 6311a122a..d0618f4e2 100644 --- a/unity/icon-postprocessor.c +++ b/unity/icon-postprocessor.c @@ -88,6 +88,8 @@ static gpointer unity_unity_icon_parent_class = NULL; void unity_rgb_to_hsv (float r, float g, float b, float* hue, float* sat, float* val); void unity_hsv_to_rgb (float hue, float sat, float val, float* r, float* g, float* b); +guint unity_pixbuf_check_threshold (GdkPixbuf* source, gint x1, gint y1, gint x2, gint y2, float threshold); +gboolean unity_pixbuf_is_tile (GdkPixbuf* source); void unity_get_average_color (GdkPixbuf* source, guint* red, guint* green, guint* blue); GType unity_unity_icon_get_type (void); #define UNITY_UNITY_ICON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UNITY_TYPE_UNITY_ICON, UnityUnityIconPrivate)) @@ -123,8 +125,9 @@ static void unity_unity_icon_set_property (GObject * object, guint property_id, void unity_rgb_to_hsv (float r, float g, float b, float* hue, float* sat, float* val) { float min = 0.0F; - float max = 0.0F; + float max; float delta; + max = 0.0f; if (r > g) { float _tmp0_ = 0.0F; if (r > b) { @@ -252,6 +255,148 @@ void unity_hsv_to_rgb (float hue, float sat, float val, float* r, float* g, floa } +guint unity_pixbuf_check_threshold (GdkPixbuf* source, gint x1, gint y1, gint x2, gint y2, float threshold) { + guint result = 0U; + gint num_channels; + gint width; + gint rowstride; + guint total_visible_pixels; + guchar* _tmp0_; + gint _pixels_size_; + gint pixels_length1; + guchar* pixels; + gboolean _tmp1_ = FALSE; + gboolean _tmp2_ = FALSE; + gboolean _tmp3_ = FALSE; + guint i; + g_return_val_if_fail (source != NULL, 0U); + num_channels = gdk_pixbuf_get_n_channels (source); + width = gdk_pixbuf_get_width (source); + rowstride = gdk_pixbuf_get_rowstride (source); + total_visible_pixels = (guint) 0; + pixels = (_tmp0_ = gdk_pixbuf_get_pixels (source), pixels_length1 = -1, _pixels_size_ = pixels_length1, _tmp0_); + if (gdk_pixbuf_get_colorspace (source) != GDK_COLORSPACE_RGB) { + _tmp3_ = TRUE; + } else { + _tmp3_ = gdk_pixbuf_get_bits_per_sample (source) != 8; + } + if (_tmp3_) { + _tmp2_ = TRUE; + } else { + _tmp2_ = !gdk_pixbuf_get_has_alpha (source); + } + if (_tmp2_) { + _tmp1_ = TRUE; + } else { + _tmp1_ = num_channels != 4; + } + if (_tmp1_) { + g_warning ("icon-postprocessor.vala:148: pixbuf is not in a friendly format, can n" \ +"ot work with it"); + result = (guint) 0; + return result; + } + i = (guint) 0; + { + gint yi; + yi = y1; + { + gboolean _tmp4_; + _tmp4_ = TRUE; + while (TRUE) { + if (!_tmp4_) { + yi++; + } + _tmp4_ = FALSE; + if (!(yi < y2)) { + break; + } + { + gint xi; + xi = x1; + { + gboolean _tmp5_; + _tmp5_ = TRUE; + while (TRUE) { + float pixel; + if (!_tmp5_) { + xi++; + } + _tmp5_ = FALSE; + if (!(xi < x2)) { + break; + } + pixel = pixels[(i + (xi * 4)) + 3] / 255.0f; + if (pixel > threshold) { + total_visible_pixels = total_visible_pixels + ((guint) 1); + } + } + } + } + i = (guint) ((yi * (width * 4)) + rowstride); + } + } + } + result = total_visible_pixels; + return result; +} + + +gboolean unity_pixbuf_is_tile (GdkPixbuf* source) { + gboolean result = FALSE; + gboolean is_tile; + gint num_channels; + gint width; + gint height; + guint total_visible_pixels; + gboolean _tmp0_ = FALSE; + gboolean _tmp1_ = FALSE; + gboolean _tmp2_ = FALSE; + gint height_3; + gint width_3; + gint max_pixels; + g_return_val_if_fail (source != NULL, FALSE); + is_tile = FALSE; + num_channels = gdk_pixbuf_get_n_channels (source); + width = gdk_pixbuf_get_width (source); + height = gdk_pixbuf_get_height (source); + total_visible_pixels = (guint) 0; + if (gdk_pixbuf_get_colorspace (source) != GDK_COLORSPACE_RGB) { + _tmp2_ = TRUE; + } else { + _tmp2_ = gdk_pixbuf_get_bits_per_sample (source) != 8; + } + if (_tmp2_) { + _tmp1_ = TRUE; + } else { + _tmp1_ = !gdk_pixbuf_get_has_alpha (source); + } + if (_tmp1_) { + _tmp0_ = TRUE; + } else { + _tmp0_ = num_channels != 4; + } + if (_tmp0_) { + g_warning ("icon-postprocessor.vala:180: pixbuf is not in a friendly format, can n" \ +"ot work with it"); + result = FALSE; + return result; + } + height_3 = height / 3; + width_3 = width / 3; + total_visible_pixels = unity_pixbuf_check_threshold (source, width_3, 0, width_3 * 2, 3, 0.1f); + total_visible_pixels = total_visible_pixels + unity_pixbuf_check_threshold (source, width_3, height - 3, width_3 * 2, 3, 0.1f); + total_visible_pixels = total_visible_pixels + unity_pixbuf_check_threshold (source, 0, height_3, 3, height_3 * 2, 0.1f); + total_visible_pixels = total_visible_pixels + unity_pixbuf_check_threshold (source, width - 3, height_3, 3, height_3 * 2, 0.1f); + max_pixels = ((width_3 * 6) + (height_3 * 6)) / 3; + if ((total_visible_pixels / max_pixels) > 0.33333) { + is_tile = TRUE; + } + result = is_tile; + return result; +} + + void unity_get_average_color (GdkPixbuf* source, guint* red, guint* green, guint* blue) { gint num_channels; gint width; @@ -274,7 +419,11 @@ void unity_get_average_color (GdkPixbuf* source, guint* red, guint* green, guint double r_total = 0.0; double g_total = 0.0; double b_total = 0.0; + double rs_total = 0.0; + double gs_total = 0.0; + double bs_total = 0.0; gint i; + guint total_caught_pixels; g_return_if_fail (source != NULL); num_channels = gdk_pixbuf_get_n_channels (source); width = gdk_pixbuf_get_width (source); @@ -303,7 +452,9 @@ void unity_get_average_color (GdkPixbuf* source, guint* red, guint* green, guint return; } r_total = g_total = b_total = 0.0; + rs_total = gs_total = bs_total = 0.0; i = 0; + total_caught_pixels = (guint) 1; { gint y; y = 0; @@ -334,17 +485,24 @@ void unity_get_average_color (GdkPixbuf* source, guint* red, guint* green, guint break; } pix_index = i + (x * 4); - r = pixels[pix_index + 0] / 256.0f; - g = pixels[pix_index + 1] / 256.0f; - b = pixels[pix_index + 2] / 256.0f; - a = pixels[pix_index + 3] / 256.0f; - if (a < (1.0 / 256.0)) { + r = pixels[pix_index + 0] / 255.0f; + g = pixels[pix_index + 1] / 255.0f; + b = pixels[pix_index + 2] / 255.0f; + a = pixels[pix_index + 3] / 255.0f; + if (a < 0.5) { continue; } unity_rgb_to_hsv (r, g, b, &hue, &sat, &val); - r_total = r_total + ((double) ((r * sat) * a)); - g_total = g_total + ((double) ((g * sat) * a)); - b_total = b_total + ((double) ((b * sat) * a)); + rs_total = rs_total + ((double) r); + gs_total = gs_total + ((double) g); + bs_total = bs_total + ((double) b); + if (sat <= 0.33) { + continue; + } + r_total = r_total + ((double) r); + g_total = g_total + ((double) g); + b_total = b_total + ((double) b); + total_caught_pixels = total_caught_pixels + ((guint) 1); } } } @@ -352,11 +510,18 @@ void unity_get_average_color (GdkPixbuf* source, guint* red, guint* green, guint } } } - r_total = r_total / (width * height); - g_total = g_total / (width * height); - b_total = b_total / (width * height); - unity_rgb_to_hsv ((float) r_total, (float) g_total, (float) b_total, &hue, &sat, &val); - unity_hsv_to_rgb (hue, fminf (sat + 0.6f, 1.0f), 0.5f, &r, &g, &b); + r_total = r_total / MAX (total_caught_pixels, (guint) 1); + g_total = g_total / MAX (total_caught_pixels, (guint) 1); + b_total = b_total / MAX (total_caught_pixels, (guint) 1); + if (total_caught_pixels <= 20) { + unity_rgb_to_hsv ((float) rs_total, (float) gs_total, (float) bs_total, &hue, &sat, &val); + sat = 0.0f; + } else { + unity_rgb_to_hsv ((float) r_total, (float) g_total, (float) b_total, &hue, &sat, &val); + sat = fminf (sat * 0.7f, 1.0f); + val = fminf (val * 1.4f, 1.0f); + } + unity_hsv_to_rgb (hue, sat, val, &r, &g, &b); *red = (guint) (r * 255); *green = (guint) (g * 255); *blue = (guint) (b * 255); @@ -378,14 +543,14 @@ UnityUnityIcon* unity_unity_icon_new (ClutterTexture* icon, ClutterTexture* bg_t static void unity_unity_icon_real_get_preferred_width (ClutterActor* base, float for_height, float* minimum_width, float* natural_width) { UnityUnityIcon * self; self = (UnityUnityIcon*) base; - *natural_width = *minimum_width = (float) 48; + *natural_width = *minimum_width = (float) 50; } static void unity_unity_icon_real_get_preferred_height (ClutterActor* base, float for_width, float* minimum_height, float* natural_height) { UnityUnityIcon * self; self = (UnityUnityIcon*) base; - *natural_height = *minimum_height = (float) 48; + *natural_height = *minimum_height = (float) 50; } @@ -435,11 +600,12 @@ void unity_unity_icon_paint_real (ClutterActor* actor) { cogl_material_set_color4ub (_self_->priv->bgcol_material, opacity, opacity, opacity, opacity); cogl_material_set_color4ub (_self_->priv->icon_material, opacity, opacity, opacity, opacity); cogl_material_set_color4ub (_self_->priv->fg_mat, opacity, opacity, opacity, opacity); - cogl_set_source (_self_->priv->bg_mat); - cogl_rectangle (box.x1, box.y1, box.x2, box.y2); if (CLUTTER_IS_TEXTURE (_self_->priv->_bg_color)) { cogl_set_source (_self_->priv->bgcol_material); cogl_rectangle (box.x1, box.y1, box.x2, box.y2); + } else { + cogl_set_source (_self_->priv->bg_mat); + cogl_rectangle (box.x1, box.y1, box.x2, box.y2); } if (CLUTTER_IS_TEXTURE (_self_->priv->_icon)) { gint width = 0; @@ -611,7 +777,7 @@ static GObject * unity_unity_icon_constructor (GType type, guint n_construct_pro color = (CoglHandle*) clutter_texture_get_cogl_texture (self->priv->_bg_color); mask_tex = (CoglHandle*) clutter_texture_get_cogl_texture (unity_unity_icon_mk_layer); cogl_material_set_layer (self->priv->bgcol_material, 0, color); - cogl_material_set_layer_filters (self->priv->bgcol_material, 1, COGL_MATERIAL_FILTER_NEAREST, COGL_MATERIAL_FILTER_NEAREST); + cogl_material_set_layer_filters (self->priv->bgcol_material, 1, COGL_MATERIAL_FILTER_LINEAR, COGL_MATERIAL_FILTER_LINEAR); cogl_material_set_layer (self->priv->bgcol_material, 1, mask_tex); _cogl_handle_unref0 (color); _cogl_handle_unref0 (mask_tex); diff --git a/unity/icon-postprocessor.vala b/unity/icon-postprocessor.vala index d14230c73..424d1c92c 100644 --- a/unity/icon-postprocessor.vala +++ b/unity/icon-postprocessor.vala @@ -32,7 +32,7 @@ namespace Unity public static void rgb_to_hsv (float r, float g, float b, out float hue, out float sat, out float val) { - float min, max; + float min, max = 0.0f; if (r > g) max = (r > b) ? r : b; else @@ -131,6 +131,72 @@ namespace Unity } } + private static uint pixbuf_check_threshold (Gdk.Pixbuf source, + int x1, int y1, int x2, int y2, float threshold) + { + int num_channels = source.get_n_channels (); + int width = source.get_width (); + int rowstride = source.get_rowstride (); + uint total_visible_pixels = 0; + unowned uchar[] pixels = source.get_pixels (); + if (source.get_colorspace () != Gdk.Colorspace.RGB || + source.get_bits_per_sample () != 8 || + !source.get_has_alpha () || + num_channels != 4) + { + // we can't deal with this pixbuf =\ + warning ("pixbuf is not in a friendly format, can not work with it"); + return 0; + } + + uint i = 0; + for (int yi = y1; yi < y2; yi++) + { + for (int xi = x1; xi < x2; xi++) + { + float pixel = pixels[(i + (xi*4)) + 3] / 255.0f; + if (pixel > threshold) + total_visible_pixels += 1; + } + i = yi * (width * 4) + rowstride; + } + + return total_visible_pixels; + } + + public static bool pixbuf_is_tile (Gdk.Pixbuf source) + { + bool is_tile = false; + int num_channels = source.get_n_channels (); + int width = source.get_width (); + int height = source.get_height (); + uint total_visible_pixels = 0; + if (source.get_colorspace () != Gdk.Colorspace.RGB || + source.get_bits_per_sample () != 8 || + !source.get_has_alpha () || + num_channels != 4) + { + // we can't deal with this pixbuf =\ + warning ("pixbuf is not in a friendly format, can not work with it"); + return false; + } + + int height_3 = height / 3; + int width_3 = width / 3; + + total_visible_pixels = pixbuf_check_threshold (source, width_3, 0, width_3*2, 3, 0.1f); + total_visible_pixels += pixbuf_check_threshold (source, width_3, height-3, width_3*2, 3, 0.1f); + total_visible_pixels += pixbuf_check_threshold (source, 0, height_3, 3, height_3*2, 0.1f); + total_visible_pixels += pixbuf_check_threshold (source, width - 3, height_3, 3, height_3*2, 0.1f); + + int max_pixels = (width_3 * 6 + height_3 * 6) / 3; + + if (total_visible_pixels / max_pixels > 0.33333) + is_tile = true; + + return is_tile; + } + public static void get_average_color (Gdk.Pixbuf source, out uint red, out uint green, out uint blue) { int num_channels = source.get_n_channels (); @@ -151,39 +217,61 @@ namespace Unity return; } - double r_total, g_total, b_total; + double r_total, g_total, b_total, rs_total, gs_total, bs_total; r_total = g_total = b_total = 0.0; + rs_total = gs_total = bs_total = 0.0; int i = 0; + uint total_caught_pixels = 1; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int pix_index = i + (x*4); - r = pixels[pix_index + 0] / 256.0f; - g = pixels[pix_index + 1] / 256.0f; - b = pixels[pix_index + 2] / 256.0f; - a = pixels[pix_index + 3] / 256.0f; + r = pixels[pix_index + 0] / 255.0f; + g = pixels[pix_index + 1] / 255.0f; + b = pixels[pix_index + 2] / 255.0f; + a = pixels[pix_index + 3] / 255.0f; - if (a < 1.0 / 256.0) + if (a < 0.5) continue; rgb_to_hsv (r, g, b, out hue, out sat, out val); + rs_total += r; + gs_total += g; + bs_total += b; + + if (sat <= 0.33) + continue; + // we now have the saturation and value! wewt. - r_total += (r * sat) * a; - g_total += (g * sat) * a; - b_total += (b * sat) * a; + r_total += r; + g_total += g; + b_total += b; + + total_caught_pixels += 1; } i = y * (width * 4) + rowstride; } // okay we should now have a large value in our totals - r_total = r_total / (width * height); - g_total = g_total / (width * height); - b_total = b_total / (width * height); + r_total = r_total / uint.max (total_caught_pixels, 1); + g_total = g_total / uint.max (total_caught_pixels, 1); + b_total = b_total / uint.max (total_caught_pixels, 1); // get a new super saturated value based on our totals - rgb_to_hsv ((float)r_total, (float)g_total, (float)b_total, out hue, out sat, out val); - hsv_to_rgb (hue, Math.fminf (sat + 0.6f, 1.0f), 0.5f, out r, out g, out b); + if (total_caught_pixels <= 20) + { + rgb_to_hsv ((float)rs_total, (float)gs_total, (float)bs_total, out hue, out sat, out val); + sat = 0.0f; + } + else + { + rgb_to_hsv ((float)r_total, (float)g_total, (float)b_total, out hue, out sat, out val); + sat = Math.fminf (sat * 0.7f, 1.0f); + val = Math.fminf (val * 1.4f, 1.0f); + } + + hsv_to_rgb (hue, sat, val, out r, out g, out b); red = (uint)(r * 255); green = (uint)(g * 255); @@ -222,69 +310,69 @@ namespace Unity unity_icon_mk_layer = new ThemeImage ("prism_icon_mask"); } - if (this.icon is Clutter.Texture) + if (icon is Clutter.Texture) { - this.icon.set_parent (this); + icon.set_parent (this); var icon_mat = new Cogl.Material (); - Cogl.Texture icon_tex = (Cogl.Texture)(this.icon.get_cogl_texture ()); + Cogl.Texture icon_tex = (Cogl.Texture)(icon.get_cogl_texture ()); Cogl.Texture mask_tex = (Cogl.Texture)(unity_icon_mk_layer.get_cogl_texture ()); icon_mat.set_layer (0, icon_tex); icon_mat.set_layer (1, mask_tex); - this.icon_material = icon_mat; + icon_material = icon_mat; } - if (this.bg_color is Clutter.Texture) + if (bg_color is Clutter.Texture) { - this.bg_color.set_parent (this); - this.bgcol_material = new Cogl.Material (); - Cogl.Texture color = (Cogl.Texture)(this.bg_color.get_cogl_texture ()); + bg_color.set_parent (this); + bgcol_material = new Cogl.Material (); + Cogl.Texture color = (Cogl.Texture)(bg_color.get_cogl_texture ()); Cogl.Texture mask_tex = (Cogl.Texture)(unity_icon_mk_layer.get_cogl_texture ()); - this.bgcol_material.set_layer (0, color); - this.bgcol_material.set_layer_filters (1, Cogl.MaterialFilter.NEAREST, Cogl.MaterialFilter.NEAREST); - this.bgcol_material.set_layer (1, mask_tex); + bgcol_material.set_layer (0, color); + bgcol_material.set_layer_filters (1, Cogl.MaterialFilter.LINEAR, Cogl.MaterialFilter.LINEAR); + bgcol_material.set_layer (1, mask_tex); } var mat = new Cogl.Material (); Cogl.Texture tex = (Cogl.Texture)(unity_icon_bg_layer.get_cogl_texture ()); mat.set_layer (0, tex); - this.bg_mat = mat; + bg_mat = mat; mat = new Cogl.Material (); tex = (Cogl.Texture)(unity_icon_fg_layer.get_cogl_texture ()); mat.set_layer (0, tex); - this.fg_mat = mat; + fg_mat = mat; } public override void get_preferred_width (float for_height, out float minimum_width, out float natural_width) { - natural_width = minimum_width = 48; + natural_width = minimum_width = 50; } public override void get_preferred_height (float for_width, out float minimum_height, out float natural_height) { - natural_height = minimum_height = 48; + natural_height = minimum_height = 50; } public override void allocate (Clutter.ActorBox box, Clutter.AllocationFlags flags) { base.allocate (box, flags); - if (this.icon is Clutter.Texture) - this.icon.allocate (box, flags); - if (this.bg_color is Clutter.Texture) - this.bg_color.allocate (box, flags); + if (icon is Clutter.Texture) + icon.allocate (box, flags); + if (bg_color is Clutter.Texture) + bg_color.allocate (box, flags); } public override void pick (Clutter.Color color) { - this.set_effects_painting (true); + set_effects_painting (true); var mat = new Cogl.Material (); mat.set_color4ub (color.red, color.green, color.blue, color.alpha); Cogl.rectangle (0, 0, 48, 48); base.pick (color); - this.set_effects_painting (false); + set_effects_painting (false); } /* The closest most horrible thing you will ever see in vala. its basically @@ -307,14 +395,16 @@ namespace Unity self.icon_material.set_color4ub (opacity, opacity, opacity, opacity); self.fg_mat.set_color4ub (opacity, opacity, opacity, opacity); - Cogl.set_source (self.bg_mat); - Cogl.rectangle (box.x1, box.y1, box.x2, box.y2); - if (self.bg_color is Clutter.Texture) { Cogl.set_source (self.bgcol_material); Cogl.rectangle (box.x1, box.y1, box.x2, box.y2); } + else + { + Cogl.set_source (self.bg_mat); + Cogl.rectangle (box.x1, box.y1, box.x2, box.y2); + } if (self.icon is Clutter.Texture) { int width, height; @@ -337,36 +427,36 @@ namespace Unity /* we need a beter way of doing this effects stuff in vala, its horrible * to do, must have a think... */ - unowned SList<Ctk.Effect> effects = this.get_effects (); - if (!this.get_effects_painting () && effects != null) + unowned SList<Ctk.Effect> effects = get_effects (); + if (!get_effects_painting () && effects != null) { unowned SList<Ctk.Effect> e; - this.set_effects_painting (true); + set_effects_painting (true); for (e = effects; e != null; e = e.next) { Ctk.Effect effect = e.data; bool last_effect = (e.next != null) ? false : true; - effect.paint (this.paint_real, last_effect); + effect.paint (paint_real, last_effect); } - this.set_effects_painting (false); + set_effects_painting (false); } else { - this.paint_real (this); + paint_real (this); } } public override void map () { base.map (); - this.icon.map (); + icon.map (); } public override void unmap () { base.unmap (); - this.icon.unmap (); + icon.unmap (); } } } diff --git a/unity/shell.c b/unity/shell.c index 43d5f276d..ada5302eb 100644 --- a/unity/shell.c +++ b/unity/shell.c @@ -55,6 +55,8 @@ struct _UnityShellIface { ClutterStage* (*get_stage) (UnityShell* self); void (*show_unity) (UnityShell* self); gint (*get_indicators_width) (UnityShell* self); + gint (*get_launcher_width_foobar) (UnityShell* self); + gint (*get_panel_height_foobar) (UnityShell* self); void (*ensure_input_region) (UnityShell* self); void (*add_fullscreen_request) (UnityShell* self, GObject* o); gboolean (*remove_fullscreen_request) (UnityShell* self, GObject* o); @@ -78,6 +80,8 @@ UnityShellMode unity_shell_get_mode (UnityShell* self); ClutterStage* unity_shell_get_stage (UnityShell* self); void unity_shell_show_unity (UnityShell* self); gint unity_shell_get_indicators_width (UnityShell* self); +gint unity_shell_get_launcher_width_foobar (UnityShell* self); +gint unity_shell_get_panel_height_foobar (UnityShell* self); void unity_shell_ensure_input_region (UnityShell* self); void unity_shell_add_fullscreen_request (UnityShell* self, GObject* o); gboolean unity_shell_remove_fullscreen_request (UnityShell* self, GObject* o); @@ -135,6 +139,16 @@ gint unity_shell_get_indicators_width (UnityShell* self) { } +gint unity_shell_get_launcher_width_foobar (UnityShell* self) { + return UNITY_SHELL_GET_INTERFACE (self)->get_launcher_width_foobar (self); +} + + +gint unity_shell_get_panel_height_foobar (UnityShell* self) { + return UNITY_SHELL_GET_INTERFACE (self)->get_panel_height_foobar (self); +} + + void unity_shell_ensure_input_region (UnityShell* self) { UNITY_SHELL_GET_INTERFACE (self)->ensure_input_region (self); } diff --git a/unity/shell.vala b/unity/shell.vala index 8c02c4314..d01e1de6a 100644 --- a/unity/shell.vala +++ b/unity/shell.vala @@ -38,6 +38,8 @@ namespace Unity public abstract Clutter.Stage get_stage (); public abstract void show_unity (); public abstract int get_indicators_width (); + public abstract int get_launcher_width_foobar (); // _foobar is used to avoid a symbol-clash + public abstract int get_panel_height_foobar (); // with unity/targets/mutter/main.c public abstract void ensure_input_region (); public abstract void add_fullscreen_request (Object o); public abstract bool remove_fullscreen_request (Object o); diff --git a/unity/theme.c b/unity/theme.c index 5a2c3c50d..d0b2e6096 100644 --- a/unity/theme.c +++ b/unity/theme.c @@ -301,7 +301,9 @@ static void unity_theme_file_path_path_from_theme_ready (GObject* source_object, static gboolean _unity_theme_file_path_path_from_theme_co_gsource_func (gpointer self) { - return unity_theme_file_path_path_from_theme_co (self); + gboolean result; + result = unity_theme_file_path_path_from_theme_co (self); + return result; } diff --git a/unity/unity.h b/unity/unity.h index 2cf575b14..c706117ba 100644 --- a/unity/unity.h +++ b/unity/unity.h @@ -295,6 +295,8 @@ struct _UnityShellIface { ClutterStage* (*get_stage) (UnityShell* self); void (*show_unity) (UnityShell* self); gint (*get_indicators_width) (UnityShell* self); + gint (*get_launcher_width_foobar) (UnityShell* self); + gint (*get_panel_height_foobar) (UnityShell* self); void (*ensure_input_region) (UnityShell* self); void (*add_fullscreen_request) (UnityShell* self, GObject* o); gboolean (*remove_fullscreen_request) (UnityShell* self, GObject* o); @@ -400,6 +402,7 @@ const char* unity_entry_get_static_text (UnityEntry* self); void unity_entry_set_static_text (UnityEntry* self, const char* value); void unity_rgb_to_hsv (float r, float g, float b, float* hue, float* sat, float* val); void unity_hsv_to_rgb (float hue, float sat, float val, float* r, float* g, float* b); +gboolean unity_pixbuf_is_tile (GdkPixbuf* source); void unity_get_average_color (GdkPixbuf* source, guint* red, guint* green, guint* blue); GType unity_unity_icon_get_type (void); UnityUnityIcon* unity_unity_icon_new (ClutterTexture* icon, ClutterTexture* bg_tex); @@ -438,6 +441,8 @@ UnityShellMode unity_shell_get_mode (UnityShell* self); ClutterStage* unity_shell_get_stage (UnityShell* self); void unity_shell_show_unity (UnityShell* self); gint unity_shell_get_indicators_width (UnityShell* self); +gint unity_shell_get_launcher_width_foobar (UnityShell* self); +gint unity_shell_get_panel_height_foobar (UnityShell* self); void unity_shell_ensure_input_region (UnityShell* self); void unity_shell_add_fullscreen_request (UnityShell* self, GObject* o); gboolean unity_shell_remove_fullscreen_request (UnityShell* self, GObject* o); diff --git a/unity/unity.vapi b/unity/unity.vapi index c55589ccc..b5fb0e20f 100644 --- a/unity/unity.vapi +++ b/unity/unity.vapi @@ -167,7 +167,9 @@ namespace Unity { public abstract void ensure_input_region (); public abstract void expose_xids (GLib.Array<uint32> xids); public abstract int get_indicators_width (); + public abstract int get_launcher_width_foobar (); public abstract Unity.ShellMode get_mode (); + public abstract int get_panel_height_foobar (); public abstract Clutter.Stage get_stage (); public abstract void grab_keyboard (bool grab, uint32 timestamp); public abstract bool remove_fullscreen_request (GLib.Object o); @@ -202,5 +204,7 @@ namespace Unity { [CCode (cheader_filename = "unity.h")] public static bool icon_name_exists_in_theme (string icon_name, string theme); [CCode (cheader_filename = "unity.h")] + public static bool pixbuf_is_tile (Gdk.Pixbuf source); + [CCode (cheader_filename = "unity.h")] public static void rgb_to_hsv (float r, float g, float b, out float hue, out float sat, out float val); } diff --git a/unity/webapp-fetcher.c b/unity/webapp-fetcher.c index 56546286b..d3086de9e 100644 --- a/unity/webapp-fetcher.c +++ b/unity/webapp-fetcher.c @@ -154,6 +154,8 @@ struct _UnityShellIface { ClutterStage* (*get_stage) (UnityShell* self); void (*show_unity) (UnityShell* self); gint (*get_indicators_width) (UnityShell* self); + gint (*get_launcher_width_foobar) (UnityShell* self); + gint (*get_panel_height_foobar) (UnityShell* self); void (*ensure_input_region) (UnityShell* self); void (*add_fullscreen_request) (UnityShell* self, GObject* o); gboolean (*remove_fullscreen_request) (UnityShell* self, GObject* o); @@ -939,7 +941,9 @@ static gboolean _lambda3_ (UnityWebappWebiconFetcher* self) { static gboolean __lambda3__gsource_func (gpointer self) { - return _lambda3_ (self); + gboolean result; + result = _lambda3_ (self); + return result; } diff --git a/vapi/indicator.vapi b/vapi/indicator.vapi index 735b0b029..46698ef50 100644 --- a/vapi/indicator.vapi +++ b/vapi/indicator.vapi @@ -35,6 +35,7 @@ namespace Indicator { [Compact] [CCode (cheader_filename = "gtk/gtk.h,libindicator/indicator.h,libindicator/indicator-object.h,libindicator/indicator-service.h,libindicator/indicator-service-manager.h")] public class ObjectEntry { + public ObjectEntry (); public weak Gtk.Image image; public weak Gtk.Label label; public weak Gtk.Menu menu; |
