summaryrefslogtreecommitdiff
path: root/src/eggsmclient-osx.c
diff options
context:
space:
mode:
authorPerberos <[email protected]>2011-11-06 19:14:03 -0300
committerPerberos <[email protected]>2011-11-06 19:14:03 -0300
commitf2a13175e5a3a38d1340d2fff5e03f8c2e0d8f8e (patch)
tree5bc248a29ae93e5534428e6908a94d50d419ceb9 /src/eggsmclient-osx.c
parentdef492f92d29f294c62d94ef562dd6271bd9b84b (diff)
downloadmate-terminal-f2a13175e5a3a38d1340d2fff5e03f8c2e0d8f8e.tar.bz2
mate-terminal-f2a13175e5a3a38d1340d2fff5e03f8c2e0d8f8e.tar.xz
aplicando formato allman
Diffstat (limited to 'src/eggsmclient-osx.c')
-rw-r--r--src/eggsmclient-osx.c225
1 files changed, 113 insertions, 112 deletions
diff --git a/src/eggsmclient-osx.c b/src/eggsmclient-osx.c
index e6fa376..456616c 100644
--- a/src/eggsmclient-osx.c
+++ b/src/eggsmclient-osx.c
@@ -51,26 +51,27 @@
typedef struct _EggSMClientOSX EggSMClientOSX;
typedef struct _EggSMClientOSXClass EggSMClientOSXClass;
-struct _EggSMClientOSX {
- EggSMClient parent;
+struct _EggSMClientOSX
+{
+ EggSMClient parent;
- AppleEvent quit_event, quit_reply;
- gboolean quit_requested, quitting;
+ AppleEvent quit_event, quit_reply;
+ gboolean quit_requested, quitting;
};
struct _EggSMClientOSXClass
{
- EggSMClientClass parent_class;
+ EggSMClientClass parent_class;
};
static void sm_client_osx_startup (EggSMClient *client,
- const char *client_id);
+ const char *client_id);
static void sm_client_osx_will_quit (EggSMClient *client,
- gboolean will_quit);
+ gboolean will_quit);
static gboolean sm_client_osx_end_session (EggSMClient *client,
- EggSMClientEndStyle style,
- gboolean request_confirmation);
+ EggSMClientEndStyle style,
+ gboolean request_confirmation);
static pascal OSErr quit_requested (const AppleEvent *, AppleEvent *, long);
@@ -79,157 +80,157 @@ G_DEFINE_TYPE (EggSMClientOSX, egg_sm_client_osx, EGG_TYPE_SM_CLIENT)
static void
egg_sm_client_osx_init (EggSMClientOSX *osx)
{
- ;
+ ;
}
static void
egg_sm_client_osx_class_init (EggSMClientOSXClass *klass)
{
- EggSMClientClass *sm_client_class = EGG_SM_CLIENT_CLASS (klass);
+ EggSMClientClass *sm_client_class = EGG_SM_CLIENT_CLASS (klass);
- sm_client_class->startup = sm_client_osx_startup;
- sm_client_class->will_quit = sm_client_osx_will_quit;
- sm_client_class->end_session = sm_client_osx_end_session;
+ sm_client_class->startup = sm_client_osx_startup;
+ sm_client_class->will_quit = sm_client_osx_will_quit;
+ sm_client_class->end_session = sm_client_osx_end_session;
}
EggSMClient *
egg_sm_client_osx_new (void)
{
- return g_object_new (EGG_TYPE_SM_CLIENT_OSX, NULL);
+ return g_object_new (EGG_TYPE_SM_CLIENT_OSX, NULL);
}
static void
sm_client_osx_startup (EggSMClient *client,
- const char *client_id)
+ const char *client_id)
{
- AEInstallEventHandler (kCoreEventClass, kAEQuitApplication,
- NewAEEventHandlerUPP (quit_requested),
- (long)GPOINTER_TO_SIZE (client), false);
+ AEInstallEventHandler (kCoreEventClass, kAEQuitApplication,
+ NewAEEventHandlerUPP (quit_requested),
+ (long)GPOINTER_TO_SIZE (client), false);
}
static gboolean
idle_quit_requested (gpointer client)
{
- egg_sm_client_quit_requested (client);
- return FALSE;
+ egg_sm_client_quit_requested (client);
+ return FALSE;
}
static pascal OSErr
quit_requested (const AppleEvent *aevt, AppleEvent *reply, long refcon)
{
- EggSMClient *client = GSIZE_TO_POINTER ((gsize)refcon);
- EggSMClientOSX *osx = GSIZE_TO_POINTER ((gsize)refcon);
-
- g_return_val_if_fail (!osx->quit_requested, userCanceledErr);
-
- /* FIXME AEInteractWithUser? */
-
- osx->quit_requested = TRUE;
- AEDuplicateDesc (aevt, &osx->quit_event);
- AEDuplicateDesc (reply, &osx->quit_reply);
- AESuspendTheCurrentEvent (aevt);
-
- /* Don't emit the "quit_requested" signal immediately, since we're
- * called from a weird point in the guts of gdkeventloop-quartz.c
- */
- g_idle_add (idle_quit_requested, client);
- return noErr;
+ EggSMClient *client = GSIZE_TO_POINTER ((gsize)refcon);
+ EggSMClientOSX *osx = GSIZE_TO_POINTER ((gsize)refcon);
+
+ g_return_val_if_fail (!osx->quit_requested, userCanceledErr);
+
+ /* FIXME AEInteractWithUser? */
+
+ osx->quit_requested = TRUE;
+ AEDuplicateDesc (aevt, &osx->quit_event);
+ AEDuplicateDesc (reply, &osx->quit_reply);
+ AESuspendTheCurrentEvent (aevt);
+
+ /* Don't emit the "quit_requested" signal immediately, since we're
+ * called from a weird point in the guts of gdkeventloop-quartz.c
+ */
+ g_idle_add (idle_quit_requested, client);
+ return noErr;
}
static pascal OSErr
quit_requested_resumed (const AppleEvent *aevt, AppleEvent *reply, long refcon)
{
- EggSMClientOSX *osx = GSIZE_TO_POINTER ((gsize)refcon);
+ EggSMClientOSX *osx = GSIZE_TO_POINTER ((gsize)refcon);
- osx->quit_requested = FALSE;
- return osx->quitting ? noErr : userCanceledErr;
+ osx->quit_requested = FALSE;
+ return osx->quitting ? noErr : userCanceledErr;
}
static gboolean
idle_will_quit (gpointer client)
{
- EggSMClientOSX *osx = (EggSMClientOSX *)client;
-
- /* Resume the event with a new handler that will return a value to
- * the system.
- */
- AEResumeTheCurrentEvent (&osx->quit_event, &osx->quit_reply,
- NewAEEventHandlerUPP (quit_requested_resumed),
- (long)GPOINTER_TO_SIZE (client));
- AEDisposeDesc (&osx->quit_event);
- AEDisposeDesc (&osx->quit_reply);
-
- if (osx->quitting)
- egg_sm_client_quit (client);
- return FALSE;
+ EggSMClientOSX *osx = (EggSMClientOSX *)client;
+
+ /* Resume the event with a new handler that will return a value to
+ * the system.
+ */
+ AEResumeTheCurrentEvent (&osx->quit_event, &osx->quit_reply,
+ NewAEEventHandlerUPP (quit_requested_resumed),
+ (long)GPOINTER_TO_SIZE (client));
+ AEDisposeDesc (&osx->quit_event);
+ AEDisposeDesc (&osx->quit_reply);
+
+ if (osx->quitting)
+ egg_sm_client_quit (client);
+ return FALSE;
}
static void
sm_client_osx_will_quit (EggSMClient *client,
- gboolean will_quit)
+ gboolean will_quit)
{
- EggSMClientOSX *osx = (EggSMClientOSX *)client;
+ EggSMClientOSX *osx = (EggSMClientOSX *)client;
- g_return_if_fail (osx->quit_requested);
+ g_return_if_fail (osx->quit_requested);
- osx->quitting = will_quit;
+ osx->quitting = will_quit;
- /* Finish in an idle handler since the caller might have called
- * egg_sm_client_will_quit() from inside the "quit_requested" signal
- * handler, but may not expect the "quit" signal to arrive during
- * the _will_quit() call.
- */
- g_idle_add (idle_will_quit, client);
+ /* Finish in an idle handler since the caller might have called
+ * egg_sm_client_will_quit() from inside the "quit_requested" signal
+ * handler, but may not expect the "quit" signal to arrive during
+ * the _will_quit() call.
+ */
+ g_idle_add (idle_will_quit, client);
}
static gboolean
sm_client_osx_end_session (EggSMClient *client,
- EggSMClientEndStyle style,
- gboolean request_confirmation)
+ EggSMClientEndStyle style,
+ gboolean request_confirmation)
{
- static const ProcessSerialNumber loginwindow_psn = { 0, kSystemProcess };
- AppleEvent event = { typeNull, NULL }, reply = { typeNull, NULL };
- AEAddressDesc target;
- AEEventID id;
- OSErr err;
-
- switch (style)
- {
- case EGG_SM_CLIENT_END_SESSION_DEFAULT:
- case EGG_SM_CLIENT_LOGOUT:
- id = request_confirmation ? kAELogOut : kAEReallyLogOut;
- break;
- case EGG_SM_CLIENT_REBOOT:
- id = request_confirmation ? kAEShowRestartDialog : kAERestart;
- break;
- case EGG_SM_CLIENT_SHUTDOWN:
- id = request_confirmation ? kAEShowShutdownDialog : kAEShutDown;
- break;
- }
-
- err = AECreateDesc (typeProcessSerialNumber, &loginwindow_psn,
- sizeof (loginwindow_psn), &target);
- if (err != noErr)
- {
- g_warning ("Could not create descriptor for loginwindow: %d", err);
- return FALSE;
- }
-
- err = AECreateAppleEvent (kCoreEventClass, id, &target,
- kAutoGenerateReturnID, kAnyTransactionID,
- &event);
- AEDisposeDesc (&target);
- if (err != noErr)
- {
- g_warning ("Could not create logout AppleEvent: %d", err);
- return FALSE;
- }
-
- err = AESend (&event, &reply, kAENoReply, kAENormalPriority,
- kAEDefaultTimeout, NULL, NULL);
- AEDisposeDesc (&event);
- if (err == noErr)
- AEDisposeDesc (&reply);
-
- return err == noErr;
+ static const ProcessSerialNumber loginwindow_psn = { 0, kSystemProcess };
+ AppleEvent event = { typeNull, NULL }, reply = { typeNull, NULL };
+ AEAddressDesc target;
+ AEEventID id;
+ OSErr err;
+
+ switch (style)
+ {
+ case EGG_SM_CLIENT_END_SESSION_DEFAULT:
+ case EGG_SM_CLIENT_LOGOUT:
+ id = request_confirmation ? kAELogOut : kAEReallyLogOut;
+ break;
+ case EGG_SM_CLIENT_REBOOT:
+ id = request_confirmation ? kAEShowRestartDialog : kAERestart;
+ break;
+ case EGG_SM_CLIENT_SHUTDOWN:
+ id = request_confirmation ? kAEShowShutdownDialog : kAEShutDown;
+ break;
+ }
+
+ err = AECreateDesc (typeProcessSerialNumber, &loginwindow_psn,
+ sizeof (loginwindow_psn), &target);
+ if (err != noErr)
+ {
+ g_warning ("Could not create descriptor for loginwindow: %d", err);
+ return FALSE;
+ }
+
+ err = AECreateAppleEvent (kCoreEventClass, id, &target,
+ kAutoGenerateReturnID, kAnyTransactionID,
+ &event);
+ AEDisposeDesc (&target);
+ if (err != noErr)
+ {
+ g_warning ("Could not create logout AppleEvent: %d", err);
+ return FALSE;
+ }
+
+ err = AESend (&event, &reply, kAENoReply, kAENormalPriority,
+ kAEDefaultTimeout, NULL, NULL);
+ AEDisposeDesc (&event);
+ if (err == noErr)
+ AEDisposeDesc (&reply);
+
+ return err == noErr;
}