[Xfce4-commits] [apps/xfdashboard] 01/01: Unify API of XfdashboardApplication to match other single instance APIs
noreply at xfce.org
noreply at xfce.org
Tue Feb 2 14:49:20 CET 2016
This is an automated email from the git hooks/post-receive script.
nomad pushed a commit to branch master
in repository apps/xfdashboard.
commit 0ab88e19aa6cc147910178e7922822eec7628a46
Author: Stephan Haller <nomad at froevel.de>
Date: Tue Feb 2 14:41:00 2016 +0100
Unify API of XfdashboardApplication to match other single instance APIs
---
xfdashboard/actor.c | 4 +-
xfdashboard/application.c | 77 ++++++++++++++++++++--------
xfdashboard/application.h | 9 ++--
xfdashboard/applications-search-provider.c | 2 +-
xfdashboard/applications-view.c | 4 +-
xfdashboard/image-content.c | 4 +-
xfdashboard/main.c | 2 +-
xfdashboard/plugins-manager.c | 2 +-
xfdashboard/quicklaunch.c | 8 +--
xfdashboard/search-view.c | 6 +--
xfdashboard/stage.c | 10 ++--
xfdashboard/stylable.c | 2 +-
xfdashboard/window-content.c | 6 +--
xfdashboard/windows-view.c | 4 +-
xfdashboard/workspace-selector.c | 4 +-
15 files changed, 91 insertions(+), 53 deletions(-)
diff --git a/xfdashboard/actor.c b/xfdashboard/actor.c
index c288307..fe6e379 100644
--- a/xfdashboard/actor.c
+++ b/xfdashboard/actor.c
@@ -237,7 +237,7 @@ static void _xfdashboard_actor_update_effects(XfdashboardActor *self, const gcha
* Also take a reference on theme effect instance as it needs to be alive
* while iterating through list of effect IDs and creating these effects.
*/
- theme=xfdashboard_application_get_theme();
+ theme=xfdashboard_application_get_theme(NULL);
themeEffects=xfdashboard_theme_get_effects(theme);
g_object_ref(themeEffects);
@@ -485,7 +485,7 @@ static void _xfdashboard_actor_stylable_invalidate(XfdashboardStylable *inStylab
if(!priv->forceStyleRevalidation && !CLUTTER_ACTOR_IS_MAPPED(self)) return;
/* Get theme CSS */
- theme=xfdashboard_application_get_theme();
+ theme=xfdashboard_application_get_theme(NULL);
themeCSS=xfdashboard_theme_get_css(theme);
/* First get list of all stylable properties of this and parent classes.
diff --git a/xfdashboard/application.c b/xfdashboard/application.c
index 2ba3312..c6110ba 100644
--- a/xfdashboard/application.c
+++ b/xfdashboard/application.c
@@ -129,7 +129,7 @@ static guint XfdashboardApplicationSignals[SIGNAL_LAST]={ 0, };
#define DEFAULT_THEME_NAME "xfdashboard"
/* Single instance of application */
-static XfdashboardApplication* application=NULL;
+static XfdashboardApplication* _xfdashboard_application=NULL;
/* Forward declarations */
static void _xfdashboard_application_activate(GApplication *inApplication);
@@ -831,7 +831,7 @@ static void _xfdashboard_application_dispose(GObject *inObject)
xfconf_shutdown();
/* Unset singleton */
- if(G_LIKELY(G_OBJECT(application)==inObject)) application=NULL;
+ if(G_LIKELY(G_OBJECT(_xfdashboard_application)==inObject)) _xfdashboard_application=NULL;
/* Call parent's class dispose method */
G_OBJECT_CLASS(xfdashboard_application_parent_class)->dispose(inObject);
@@ -1057,7 +1057,7 @@ static void xfdashboard_application_init(XfdashboardApplication *self)
/* Get single instance of application */
XfdashboardApplication* xfdashboard_application_get_default(void)
{
- if(G_UNLIKELY(application==NULL))
+ if(G_UNLIKELY(!_xfdashboard_application))
{
gchar *appID;
const gchar *forceNewInstance=NULL;
@@ -1076,16 +1076,16 @@ XfdashboardApplication* xfdashboard_application_get_default(void)
}
else appID=g_strdup(XFDASHBOARD_APP_ID);
- application=g_object_new(XFDASHBOARD_TYPE_APPLICATION,
- "application-id", appID,
- "flags", G_APPLICATION_HANDLES_COMMAND_LINE,
- NULL);
+ _xfdashboard_application=g_object_new(XFDASHBOARD_TYPE_APPLICATION,
+ "application-id", appID,
+ "flags", G_APPLICATION_HANDLES_COMMAND_LINE,
+ NULL);
/* Release allocated resources */
if(appID) g_free(appID);
}
- return(application);
+ return(_xfdashboard_application);
}
/* Get flag if application is running in daemonized mode */
@@ -1112,47 +1112,84 @@ gboolean xfdashboard_application_is_quitting(XfdashboardApplication *self)
return(self->priv->isQuitting);
}
+/* Resume application */
+void xfdashboard_application_resume(XfdashboardApplication *self)
+{
+ g_return_if_fail(self==NULL || XFDASHBOARD_IS_APPLICATION(self));
+
+ /* Get default single instance if NULL is requested */
+ if(!self) self=_xfdashboard_application;
+
+ /* Resume application */
+ if(G_LIKELY(self))
+ {
+ _xfdashboard_application_activate(G_APPLICATION(self));
+ }
+}
+
/* Quit application */
-void xfdashboard_application_quit(void)
+void xfdashboard_application_suspend_or_quit(XfdashboardApplication *self)
{
- if(G_LIKELY(application!=NULL))
+ g_return_if_fail(self==NULL || XFDASHBOARD_IS_APPLICATION(self));
+
+ /* Get default single instance if NULL is requested */
+ if(!self) self=_xfdashboard_application;
+
+ /* Quit application */
+ if(G_LIKELY(self))
{
- _xfdashboard_application_quit(application, FALSE);
+ _xfdashboard_application_quit(self, FALSE);
}
}
-void xfdashboard_application_quit_forced(void)
+void xfdashboard_application_quit_forced(XfdashboardApplication *self)
{
- if(G_LIKELY(application!=NULL))
+ g_return_if_fail(self==NULL || XFDASHBOARD_IS_APPLICATION(self));
+
+ /* Get default single instance if NULL is requested */
+ if(!self) self=_xfdashboard_application;
+
+ /* Force application to quit */
+ if(G_LIKELY(self))
{
/* Quit also any other running instance */
- if(g_application_get_is_remote(G_APPLICATION(application))==TRUE)
+ if(g_application_get_is_remote(G_APPLICATION(self))==TRUE)
{
- g_action_group_activate_action(G_ACTION_GROUP(application), "Quit", NULL);
+ g_action_group_activate_action(G_ACTION_GROUP(self), "Quit", NULL);
}
/* Quit this instance */
- _xfdashboard_application_quit(application, TRUE);
+ _xfdashboard_application_quit(self, TRUE);
}
else clutter_main_quit();
}
/* Get xfconf channel for this application */
-XfconfChannel* xfdashboard_application_get_xfconf_channel(void)
+XfconfChannel* xfdashboard_application_get_xfconf_channel(XfdashboardApplication *self)
{
XfconfChannel *channel=NULL;
- if(G_LIKELY(application!=NULL)) channel=application->priv->xfconfChannel;
+ g_return_if_fail(self==NULL || XFDASHBOARD_IS_APPLICATION(self));
+
+ /* Get default single instance if NULL is requested */
+ if(!self) self=_xfdashboard_application;
+
+ /* Get xfconf channel */
+ if(G_LIKELY(self)) channel=self->priv->xfconfChannel;
return(channel);
}
/* Get current theme used */
-XfdashboardTheme* xfdashboard_application_get_theme(void)
+XfdashboardTheme* xfdashboard_application_get_theme(XfdashboardApplication *self)
{
XfdashboardTheme *theme=NULL;
- if(G_LIKELY(application!=NULL)) theme=application->priv->theme;
+ /* Get default single instance if NULL is requested */
+ if(!self) self=_xfdashboard_application;
+
+ /* Get theme */
+ if(G_LIKELY(self)) theme=self->priv->theme;
return(theme);
}
diff --git a/xfdashboard/application.h b/xfdashboard/application.h
index 00f2454..392f9cb 100644
--- a/xfdashboard/application.h
+++ b/xfdashboard/application.h
@@ -108,12 +108,13 @@ gboolean xfdashboard_application_is_daemonized(XfdashboardApplication *self);
gboolean xfdashboard_application_is_suspended(XfdashboardApplication *self);
gboolean xfdashboard_application_is_quitting(XfdashboardApplication *self);
-void xfdashboard_application_quit(void);
-void xfdashboard_application_quit_forced(void);
+void xfdashboard_application_resume(XfdashboardApplication *self);
+void xfdashboard_application_suspend_or_quit(XfdashboardApplication *self);
+void xfdashboard_application_quit_forced(XfdashboardApplication *self);
-XfconfChannel* xfdashboard_application_get_xfconf_channel(void);
+XfconfChannel* xfdashboard_application_get_xfconf_channel(XfdashboardApplication *self);
-XfdashboardTheme* xfdashboard_application_get_theme(void);
+XfdashboardTheme* xfdashboard_application_get_theme(XfdashboardApplication *self);
G_END_DECLS
diff --git a/xfdashboard/applications-search-provider.c b/xfdashboard/applications-search-provider.c
index 4554b41..70c8e5e 100644
--- a/xfdashboard/applications-search-provider.c
+++ b/xfdashboard/applications-search-provider.c
@@ -1302,7 +1302,7 @@ static void xfdashboard_applications_search_provider_init(XfdashboardApplication
self->priv=priv=XFDASHBOARD_APPLICATIONS_SEARCH_PROVIDER_GET_PRIVATE(self);
/* Set up default values */
- priv->xfconfChannel=xfdashboard_application_get_xfconf_channel();
+ priv->xfconfChannel=xfdashboard_application_get_xfconf_channel(NULL);
priv->currentSortMode=XFDASHBOARD_APPLICATIONS_SEARCH_PROVIDER_SORT_MODE_NONE;
priv->nextSortMode=XFDASHBOARD_APPLICATIONS_SEARCH_PROVIDER_SORT_MODE_NONE;
diff --git a/xfdashboard/applications-view.c b/xfdashboard/applications-view.c
index 585f20a..3863df7 100644
--- a/xfdashboard/applications-view.c
+++ b/xfdashboard/applications-view.c
@@ -283,7 +283,7 @@ static void _xfdashboard_applications_view_on_item_clicked(XfdashboardApplicatio
if(xfdashboard_application_button_execute(button, NULL))
{
/* Launching application seems to be successfuly so quit application */
- xfdashboard_application_quit();
+ xfdashboard_application_suspend_or_quit(NULL);
return;
}
}
@@ -1392,7 +1392,7 @@ static void xfdashboard_applications_view_init(XfdashboardApplicationsView *self
priv->formatTitleDescription=g_strdup("%s\n%s");
priv->selectedItem=NULL;
priv->showAllAppsMenu=FALSE;
- priv->xfconfChannel=xfdashboard_application_get_xfconf_channel();
+ priv->xfconfChannel=xfdashboard_application_get_xfconf_channel(NULL);
priv->xfconfShowAllAppsMenuBindingID=0;
/* Set up view */
diff --git a/xfdashboard/image-content.c b/xfdashboard/image-content.c
index c355e9d..7a6c2d8 100644
--- a/xfdashboard/image-content.c
+++ b/xfdashboard/image-content.c
@@ -352,7 +352,7 @@ static void _xfdashboard_image_content_load_from_file(XfdashboardImageContent *s
const gchar *themePath;
/* Get theme path */
- theme=xfdashboard_application_get_theme();
+ theme=xfdashboard_application_get_theme(NULL);
g_object_ref(theme);
themePath=xfdashboard_theme_get_path(theme);
@@ -911,7 +911,7 @@ static void _xfdashboard_image_content_setup_for_icon(XfdashboardImageContent *s
gchar *iconFilename;
/* Build absolute path from theme path and given relative path to icon */
- theme=xfdashboard_application_get_theme();
+ theme=xfdashboard_application_get_theme(NULL);
g_object_ref(theme);
iconFilename=g_build_filename(xfdashboard_theme_get_path(theme),
diff --git a/xfdashboard/main.c b/xfdashboard/main.c
index 440a3f0..d61909e 100644
--- a/xfdashboard/main.c
+++ b/xfdashboard/main.c
@@ -69,7 +69,7 @@ static gboolean _on_quit_timeout(gpointer inUserData)
static gboolean _on_quit_idle(gpointer inUserData)
{
/* Quit application */
- xfdashboard_application_quit_forced();
+ xfdashboard_application_quit_forced(NULL);
/* Remove this source from main loop and prevent getting it called again */
return(G_SOURCE_REMOVE);
diff --git a/xfdashboard/plugins-manager.c b/xfdashboard/plugins-manager.c
index 9ea7e03..ad1879f 100644
--- a/xfdashboard/plugins-manager.c
+++ b/xfdashboard/plugins-manager.c
@@ -280,7 +280,7 @@ gboolean xfdashboard_plugins_manager_setup(XfdashboardPluginsManager *self)
g_free(path);
/* Get list of enabled plugins and try to load them */
- enabledPlugins=xfconf_channel_get_string_list(xfdashboard_application_get_xfconf_channel(),
+ enabledPlugins=xfconf_channel_get_string_list(xfdashboard_application_get_xfconf_channel(NULL),
ENABLED_PLUGINS_XFCONF_PROP);
/* Try to load all enabled plugin and collect each error occurred. */
diff --git a/xfdashboard/quicklaunch.c b/xfdashboard/quicklaunch.c
index 8dc3b6d..6d50077 100644
--- a/xfdashboard/quicklaunch.c
+++ b/xfdashboard/quicklaunch.c
@@ -323,7 +323,7 @@ static void _xfdashboard_quicklaunch_on_favourite_clicked(XfdashboardQuicklaunch
* of application whose button was clicked, then check if a window exists
* and activate it. Otherwise launch a new instance.
*/
- launchNewInstance=xfconf_channel_get_bool(xfdashboard_application_get_xfconf_channel(),
+ launchNewInstance=xfconf_channel_get_bool(xfdashboard_application_get_xfconf_channel(NULL),
LAUNCH_NEW_INSTANCE_XFCONF_PROP,
DEFAULT_LAUNCH_NEW_INSTANCE);
if(!launchNewInstance)
@@ -372,7 +372,7 @@ static void _xfdashboard_quicklaunch_on_favourite_clicked(XfdashboardQuicklaunch
/* Activating last active window of application seems to be successfully
* so quit application.
*/
- xfdashboard_application_quit();
+ xfdashboard_application_suspend_or_quit(NULL);
return;
}
@@ -403,7 +403,7 @@ static void _xfdashboard_quicklaunch_on_favourite_clicked(XfdashboardQuicklaunch
if(xfdashboard_application_button_execute(button, NULL))
{
/* Launching application seems to be successfully so quit application */
- xfdashboard_application_quit();
+ xfdashboard_application_suspend_or_quit(NULL);
return;
}
@@ -2853,7 +2853,7 @@ static void xfdashboard_quicklaunch_init(XfdashboardQuicklaunch *self)
priv->scaleMin=DEFAULT_SCALE_MIN;
priv->scaleMax=DEFAULT_SCALE_MAX;
priv->scaleStep=DEFAULT_SCALE_STEP;
- priv->xfconfChannel=xfdashboard_application_get_xfconf_channel();
+ priv->xfconfChannel=xfdashboard_application_get_xfconf_channel(NULL);
priv->dragMode=DRAG_MODE_NONE;
priv->dragPreviewIcon=NULL;
priv->selectedItem=NULL;
diff --git a/xfdashboard/search-view.c b/xfdashboard/search-view.c
index 64dbe0d..0579bf6 100644
--- a/xfdashboard/search-view.c
+++ b/xfdashboard/search-view.c
@@ -445,7 +445,7 @@ static void _xfdashboard_search_view_on_result_item_clicked(XfdashboardSearchRes
if(success)
{
/* Activating result item seems to be successfuly so quit application */
- xfdashboard_application_quit();
+ xfdashboard_application_suspend_or_quit(NULL);
}
}
@@ -477,7 +477,7 @@ static void _xfdashboard_search_view_on_provider_icon_clicked(XfdashboardSearchR
if(success)
{
/* Activating result item seems to be successfuly so quit application */
- xfdashboard_application_quit();
+ xfdashboard_application_suspend_or_quit(NULL);
}
}
@@ -1576,7 +1576,7 @@ static void xfdashboard_search_view_init(XfdashboardSearchView *self)
priv->selectionProvider=NULL;
priv->focusManager=xfdashboard_focus_manager_get_default();
priv->repaintID=0;
- priv->xfconfChannel=xfdashboard_application_get_xfconf_channel();
+ priv->xfconfChannel=xfdashboard_application_get_xfconf_channel(NULL);
/* Set up view (Note: Search view is disabled by default!) */
xfdashboard_view_set_name(XFDASHBOARD_VIEW(self), _("Search"));
diff --git a/xfdashboard/stage.c b/xfdashboard/stage.c
index 331abdf..edaedb5 100644
--- a/xfdashboard/stage.c
+++ b/xfdashboard/stage.c
@@ -179,7 +179,7 @@ static gboolean _xfdashboard_stage_event(ClutterActor *inActor, ClutterEvent *in
/* ... otherwise quit application */
else
{
- xfdashboard_application_quit();
+ xfdashboard_application_suspend_or_quit(NULL);
return(CLUTTER_EVENT_STOP);
}
}
@@ -655,10 +655,10 @@ static void _xfdashboard_stage_on_application_resume(XfdashboardStage *self, gpo
XfdashboardView *resumeView;
/* Get configured options */
- doResetSearch=xfconf_channel_get_bool(xfdashboard_application_get_xfconf_channel(),
+ doResetSearch=xfconf_channel_get_bool(xfdashboard_application_get_xfconf_channel(NULL),
RESET_SEARCH_ON_RESUME_XFCONF_PROP,
DEFAULT_RESET_SEARCH_ON_RESUME);
- resumeViewInternalName=xfconf_channel_get_string(xfdashboard_application_get_xfconf_channel(),
+ resumeViewInternalName=xfconf_channel_get_string(xfdashboard_application_get_xfconf_channel(NULL),
SWITCH_VIEW_ON_RESUME_XFCONF_PROP,
DEFAULT_SWITCH_VIEW_ON_RESUME);
@@ -1223,7 +1223,7 @@ static void _xfdashboard_stage_on_monitor_added(XfdashboardStage *self,
g_return_if_fail(XFDASHBOARD_IS_WINDOW_TRACKER(inUserData));
/* Get theme and theme layout */
- theme=xfdashboard_application_get_theme();
+ theme=xfdashboard_application_get_theme(NULL);
themeLayout=xfdashboard_theme_get_layout(theme);
/* Create interface for non-primary monitors. If no interface is defined in theme
@@ -1971,7 +1971,7 @@ void xfdashboard_stage_show_notification(XfdashboardStage *self, const gchar *in
* of the notification text to show but never drops below the minimum timeout configured.
* The interval is calculated by one second for 30 characters.
*/
- interval=xfconf_channel_get_uint(xfdashboard_application_get_xfconf_channel(),
+ interval=xfconf_channel_get_uint(xfdashboard_application_get_xfconf_channel(NULL),
NOTIFICATION_TIMEOUT_XFCONF_PROP,
DEFAULT_NOTIFICATION_TIMEOUT);
interval=MAX((gint)((strlen(inText)/30.0f)*1000.0f), interval);
diff --git a/xfdashboard/stylable.c b/xfdashboard/stylable.c
index fd21f06..a96435c 100644
--- a/xfdashboard/stylable.c
+++ b/xfdashboard/stylable.c
@@ -159,7 +159,7 @@ static void _xfdashboard_stylable_real_invalidate(XfdashboardStylable *self)
if(!stylableProperties) return;
/* Get theme CSS */
- theme=xfdashboard_application_get_theme();
+ theme=xfdashboard_application_get_theme(NULL);
themeCSS=xfdashboard_theme_get_css(theme);
/* Get styled properties from theme CSS */
diff --git a/xfdashboard/window-content.c b/xfdashboard/window-content.c
index 7101b18..0a8ea81 100644
--- a/xfdashboard/window-content.c
+++ b/xfdashboard/window-content.c
@@ -398,7 +398,7 @@ static void _xfdashboard_window_content_on_window_creation_priority_shutdown(voi
g_debug("Disconnecting property changed signal handler %u for window creation priority value change notifications",
_xfdashboard_window_content_xfconf_priority_notify_id);
- xfconfChannel=xfdashboard_application_get_xfconf_channel();
+ xfconfChannel=xfdashboard_application_get_xfconf_channel(NULL);
g_signal_handler_disconnect(xfconfChannel, _xfdashboard_window_content_xfconf_priority_notify_id);
_xfdashboard_window_content_xfconf_priority_notify_id=0;
}
@@ -564,7 +564,7 @@ static void _xfdashboard_window_content_setup_workaround(XfdashboardWindowConten
priv=self->priv;
/* Check if should workaround unmapped windows at all */
- doWorkaround=xfconf_channel_get_bool(xfdashboard_application_get_xfconf_channel(),
+ doWorkaround=xfconf_channel_get_bool(xfdashboard_application_get_xfconf_channel(NULL),
WORKAROUND_UNMAPPED_WINDOW_XFCONF_PROP,
DEFAULT_WORKAROUND_UNMAPPED_WINDOW);
if(!doWorkaround) return;
@@ -2239,7 +2239,7 @@ void xfdashboard_window_content_init(XfdashboardWindowContent *self)
gchar *detailedSignal;
/* Connect to property changed signal in xfconf */
- xfconfChannel=xfdashboard_application_get_xfconf_channel();
+ xfconfChannel=xfdashboard_application_get_xfconf_channel(NULL);
detailedSignal=g_strconcat("property-changed::", WINDOW_CONTENT_CREATION_PRIORITY_XFCONF_PROP, NULL);
_xfdashboard_window_content_xfconf_priority_notify_id=g_signal_connect(xfconfChannel,
detailedSignal,
diff --git a/xfdashboard/windows-view.c b/xfdashboard/windows-view.c
index 3962c32..7cf0a7b 100644
--- a/xfdashboard/windows-view.c
+++ b/xfdashboard/windows-view.c
@@ -717,7 +717,7 @@ static void _xfdashboard_windows_view_on_window_clicked(XfdashboardWindowsView *
xfdashboard_window_tracker_window_activate(window);
/* Quit application */
- xfdashboard_application_quit();
+ xfdashboard_application_suspend_or_quit(NULL);
}
/* The close button of a live window was clicked */
@@ -2145,7 +2145,7 @@ static void xfdashboard_windows_view_init(XfdashboardWindowsView *self)
priv->preventUpscaling=FALSE;
priv->selectedItem=NULL;
priv->isWindowsNumberShown=FALSE;
- priv->xfconfChannel=xfdashboard_application_get_xfconf_channel();
+ priv->xfconfChannel=xfdashboard_application_get_xfconf_channel(NULL);
priv->isScrollEventChangingWorkspace=FALSE;
priv->scrollEventChangingWorkspaceStage=NULL;
priv->scrollEventChangingWorkspaceStageSignalID=0;
diff --git a/xfdashboard/workspace-selector.c b/xfdashboard/workspace-selector.c
index 899f9ca..00d97a3 100644
--- a/xfdashboard/workspace-selector.c
+++ b/xfdashboard/workspace-selector.c
@@ -382,7 +382,7 @@ static void _xfdashboard_workspace_selector_on_workspace_clicked(XfdashboardWork
xfdashboard_window_tracker_workspace_activate(xfdashboard_live_workspace_get_workspace(liveWorkspace));
/* Quit application */
- xfdashboard_application_quit();
+ xfdashboard_application_suspend_or_quit(NULL);
}
/* A workspace was destroyed */
@@ -1084,7 +1084,7 @@ static gboolean _xfdashboard_workspace_selector_focusable_activate_selection(Xfd
xfdashboard_window_tracker_workspace_activate(workspace);
/* Quit application */
- xfdashboard_application_quit();
+ xfdashboard_application_suspend_or_quit(NULL);
/* Activation was successful */
return(TRUE);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list