diff options
author | monsta <[email protected]> | 2015-08-25 14:40:58 +0300 |
---|---|---|
committer | infirit <[email protected]> | 2015-09-02 11:34:01 +0200 |
commit | b24934e186456b50d7702192ec3a270926831791 (patch) | |
tree | e7daae0af65482e5f1a5598808e4e55792dd7e6d /pluma | |
parent | f6d7a422f3f5f97e676cd18cef5bb46aca8da6be (diff) | |
download | pluma-b24934e186456b50d7702192ec3a270926831791.tar.bz2 pluma-b24934e186456b50d7702192ec3a270926831791.tar.xz |
drop support for win32/osx and checkupdate plugin
that plugin has never been built in linux anyway due to logic
in configure.ac
Diffstat (limited to 'pluma')
-rw-r--r-- | pluma/Makefile.am | 36 | ||||
-rwxr-xr-x | pluma/osx/Makefile.am | 23 | ||||
-rwxr-xr-x | pluma/osx/pluma-osx-delegate.h | 16 | ||||
-rwxr-xr-x | pluma/osx/pluma-osx-delegate.m | 84 | ||||
-rwxr-xr-x | pluma/osx/pluma-osx.c | 94 | ||||
-rwxr-xr-x | pluma/osx/pluma-osx.h | 17 | ||||
-rw-r--r-- | pluma/pluma-app.c | 12 | ||||
-rw-r--r-- | pluma/pluma-commands-file.c | 50 | ||||
-rw-r--r-- | pluma/pluma-dirs.c | 97 | ||||
-rw-r--r-- | pluma/pluma-document.h | 10 | ||||
-rw-r--r-- | pluma/pluma-help.c | 23 | ||||
-rw-r--r-- | pluma/pluma-ui.h | 5 | ||||
-rw-r--r-- | pluma/pluma-window-private.h | 8 | ||||
-rw-r--r-- | pluma/pluma-window.c | 107 | ||||
-rw-r--r-- | pluma/pluma.c | 102 | ||||
-rwxr-xr-x | pluma/smclient/Makefile.am | 13 | ||||
-rwxr-xr-x | pluma/smclient/eggsmclient-osx.c | 235 | ||||
-rwxr-xr-x | pluma/smclient/eggsmclient-private.h | 14 | ||||
-rwxr-xr-x | pluma/smclient/eggsmclient-win32.c | 353 | ||||
-rwxr-xr-x | pluma/smclient/eggsmclient.c | 16 |
20 files changed, 7 insertions, 1308 deletions
diff --git a/pluma/Makefile.am b/pluma/Makefile.am index bae5cd01..01914351 100644 --- a/pluma/Makefile.am +++ b/pluma/Makefile.am @@ -1,10 +1,6 @@ ## Process this file with automake to produce Makefile.in SUBDIRS = dialogs smclient -if OS_OSX -SUBDIRS += osx -endif - bin_PROGRAMS = pluma noinst_LTLIBRARIES = libpluma.la @@ -14,7 +10,6 @@ AM_CPPFLAGS = \ -I$(srcdir) \ -I$(srcdir)/smclient \ $(PLUMA_CFLAGS) \ - $(IGE_MAC_CFLAGS) \ $(WARN_CFLAGS) \ $(DISABLE_DEPRECATED_CFLAGS) \ -DDATADIR=\""$(datadir)"\" \ @@ -23,16 +18,9 @@ AM_CPPFLAGS = \ pluma_SOURCES = \ pluma.c -pluma_LDADD = libpluma.la $(PLUMA_LIBS) $(IGE_MAC_LIBS) $(EGG_SMCLIENT_LIBS) +pluma_LDADD = libpluma.la $(PLUMA_LIBS) $(EGG_SMCLIENT_LIBS) -if PLATFORM_WIN32 -pluma_LDFLAGS = -Wl,--export-all-symbols -Wl,--out-implib,libpluma.a -if OS_WIN32 -pluma_LDFLAGS += -mwindows -endif -else pluma_LDFLAGS = -export-dynamic -no-undefined -export-symbols-regex "^[[^_]].*" -endif libpluma_la_LDFLAGS = -export-dynamic -no-undefined -export-symbols-regex "^[[^_]].*" @@ -43,24 +31,12 @@ libpluma_la_LIBADD = \ # PLUMA_LIBS must be the last to ensure correct order on some platforms libpluma_la_LIBADD += $(PLUMA_LIBS) -lICE -if OS_OSX -pluma_LDFLAGS += -framework Carbon - -libpluma_la_LIBADD += osx/libosx.la -endif - BUILT_SOURCES = \ pluma-enum-types.c \ pluma-enum-types.h \ pluma-marshal.c \ pluma-marshal.h -if OS_WIN32 -pluma-res.o: pluma.rc - $(WINDRES) -i pluma.rc --input-format=rc -o pluma-res.o -O coff - -pluma_LDADD += pluma-res.o -endif NOINST_H_FILES = \ pluma-close-button.h \ @@ -222,20 +198,10 @@ CLEANFILES = $(BUILT_SOURCES) dist-hook: cd $(distdir); rm -f $(BUILT_SOURCES) -install-exec-hook: -if PLATFORM_WIN32 - $(mkinstalldirs) "$(DESTDIR)$(libdir)" - $(INSTALL_DATA) libpluma.a "$(DESTDIR)$(libdir)" -endif - -if !OS_WIN32 BACON_DIR=$(srcdir)/../../libbacon/src/ BACON_FILES=bacon-message-connection.h bacon-message-connection.c regenerate-built-sources: BACONFILES="$(BACON_FILES)" BACONDIR="$(BACON_DIR)" $(top_srcdir)/pluma/update-from-bacon.sh -else -BACON_DIR= -endif -include $(top_srcdir)/git.mk diff --git a/pluma/osx/Makefile.am b/pluma/osx/Makefile.am deleted file mode 100755 index c9192b13..00000000 --- a/pluma/osx/Makefile.am +++ /dev/null @@ -1,23 +0,0 @@ -AM_CPPFLAGS = \ - -I$(top_srcdir) \ - -I$(top_builddir) \ - -I$(top_srcdir)/pluma \ - -I$(top_builddir)/pluma \ - $(PLUMA_CFLAGS) \ - $(IGE_MAC_CFLAGS) \ - $(WARN_CFLAGS) \ - $(DISABLE_DEPRECATED_CFLAGS) - -noinst_LTLIBRARIES = libosx.la - -libosx_la_LDFLAGS = -framework Carbon -framework ApplicationServices -framework Cocoa -libosx_la_LIBADD = -lobjc -libosx_la_CFLAGS = -xobjective-c - -libosx_la_SOURCES = \ - pluma-osx.c \ - pluma-osx.h \ - pluma-osx-delegate.m \ - pluma-osx-delegate.h - --include $(top_srcdir)/git.mk diff --git a/pluma/osx/pluma-osx-delegate.h b/pluma/osx/pluma-osx-delegate.h deleted file mode 100755 index f6eb2ae5..00000000 --- a/pluma/osx/pluma-osx-delegate.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef PLUMA_OSX_DELEGATE_H_ -#define PLUMA_OSX_DELEGATE_H_ - -#import <Foundation/NSAppleEventManager.h> - -@interface PlumaOSXDelegate : NSObject -{ -} - --(id) init; --(void) openFiles:(NSAppleEventDescriptor*)event - withReply:(NSAppleEventDescriptor*)reply; - -@end - -#endif /* PLUMA_OSX_DELEGATE_H_ */ diff --git a/pluma/osx/pluma-osx-delegate.m b/pluma/osx/pluma-osx-delegate.m deleted file mode 100755 index 15ecf813..00000000 --- a/pluma/osx/pluma-osx-delegate.m +++ /dev/null @@ -1,84 +0,0 @@ -#import "pluma-osx-delegate.h" -#import <Foundation/NSAppleEventManager.h> -#import <Foundation/NSAppleEventDescriptor.h> -#import <Foundation/NSData.h> -#include <glib.h> -#include <pluma/pluma-app.h> -#include <pluma/pluma-commands.h> - -@implementation PlumaOSXDelegate --(id)init -{ - if ((self = [super init])) - { - NSAppleEventManager* em = [NSAppleEventManager sharedAppleEventManager]; - - [em setEventHandler:self - andSelector:@selector(openFiles:withReply:) - forEventClass:kCoreEventClass - andEventID:kAEOpenDocuments]; - } - - return self; -} - -static PlumaWindow * -get_window(NSAppleEventDescriptor *event) -{ - PlumaApp *app = pluma_app_get_default (); - return pluma_app_get_active_window (app); -} - -- (void)openFiles:(NSAppleEventDescriptor*)event - withReply:(NSAppleEventDescriptor*)reply -{ - NSAppleEventDescriptor *fileList = [event paramDescriptorForKeyword:keyDirectObject]; - NSInteger i; - GSList *uris = NULL; - - if (!fileList) - { - return; - } - - for (i = 1; i <= [fileList numberOfItems]; ++i) - { - NSAppleEventDescriptor *fileAliasDesc = [fileList descriptorAtIndex:i]; - NSAppleEventDescriptor *fileURLDesc; - NSData *fileURLData; - gchar *url; - - if (!fileAliasDesc) - { - continue; - } - - fileURLDesc = [fileAliasDesc coerceToDescriptorType:typeFileURL]; - - if (!fileURLDesc) - { - continue; - } - - fileURLData = [fileURLDesc data]; - - if (!fileURLData) - { - continue; - } - - url = g_strndup([fileURLData bytes], [fileURLData length]); - uris = g_slist_prepend (uris, url); - } - - if (uris != NULL) - { - PlumaWindow *window = get_window (event); - pluma_commands_load_uris (window, uris, NULL, 0); - - g_slist_foreach (uris, (GFunc)g_free, NULL); - g_slist_free (uris); - } -} - -@end
\ No newline at end of file diff --git a/pluma/osx/pluma-osx.c b/pluma/osx/pluma-osx.c deleted file mode 100755 index b9e23c90..00000000 --- a/pluma/osx/pluma-osx.c +++ /dev/null @@ -1,94 +0,0 @@ -#include "pluma-osx.h" -#include <gdk/gdkquartz.h> -#include <Carbon/Carbon.h> - -#import "pluma-osx-delegate.h" - -void -pluma_osx_set_window_title (PlumaWindow *window, - gchar const *title, - PlumaDocument *document) -{ - NSWindow *native; - - g_return_if_fail (PLUMA_IS_WINDOW (window)); - - if (GTK_WIDGET (window)->window == NULL) - { - return; - } - - native = gdk_quartz_window_get_nswindow (GTK_WIDGET (window)->window); - - if (document) - { - bool ismodified; - - if (pluma_document_is_untitled (document)) - { - [native setRepresentedURL:nil]; - } - else - { - const gchar *uri = pluma_document_get_uri (document); - NSURL *nsurl = [NSURL URLWithString:[NSString stringWithUTF8String:uri]]; - - [native setRepresentedURL:nsurl]; - } - - ismodified = !pluma_document_is_untouched (document); - [native setDocumentEdited:ismodified]; - } - else - { - [native setRepresentedURL:nil]; - [native setDocumentEdited:false]; - } - - gtk_window_set_title (GTK_WINDOW (window), title); -} - -gboolean -pluma_osx_show_url (const gchar *url) -{ - return [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[NSString stringWithUTF8String:url]]]; -} - -gboolean -pluma_osx_show_help (const gchar *link_id) -{ - gchar *link; - gboolean ret; - - if (link_id) - { - link = g_strdup_printf ("http://library.gnome.org/users/pluma/stable/%s", - link_id); - } - else - { - link = g_strdup ("http://library.gnome.org/users/pluma/stable/"); - } - - ret = pluma_osx_show_url (link); - g_free (link); - - return ret; -} - -static void -destroy_delegate (PlumaOSXDelegate *delegate) -{ - [delegate dealloc]; -} - -void -pluma_osx_init(PlumaApp *app) -{ - PlumaOSXDelegate *delegate = [[PlumaOSXDelegate alloc] init]; - - g_object_set_data_full (G_OBJECT (app), - "PlumaOSXDelegate", - delegate, - (GDestroyNotify)destroy_delegate); -}
\ No newline at end of file diff --git a/pluma/osx/pluma-osx.h b/pluma/osx/pluma-osx.h deleted file mode 100755 index df06865f..00000000 --- a/pluma/osx/pluma-osx.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef __PLUMA_OSX_H__ -#define __PLUMA_OSX_H__ - -#include <gtk/gtk.h> -#include <pluma/pluma-window.h> -#include <pluma/pluma-app.h> - -void pluma_osx_init (PlumaApp *app); - -void pluma_osx_set_window_title (PlumaWindow *window, - gchar const *title, - PlumaDocument *document); - -gboolean pluma_osx_show_url (const gchar *url); -gboolean pluma_osx_show_help (const gchar *link_id); - -#endif /* __PLUMA_OSX_H__ */ diff --git a/pluma/pluma-app.c b/pluma/pluma-app.c index 248656bb..3f486f0b 100644 --- a/pluma/pluma-app.c +++ b/pluma/pluma-app.c @@ -46,10 +46,6 @@ #include "pluma-enum-types.h" #include "pluma-dirs.h" -#ifdef OS_OSX -#include <ige-mac-integration.h> -#endif - #define PLUMA_PAGE_SETUP_FILE "pluma-page-setup" #define PLUMA_PRINT_SETTINGS_FILE "pluma-print-settings" @@ -440,14 +436,6 @@ window_destroy (PlumaWindow *window, */ if (app->priv->windows == NULL) { -#ifdef OS_OSX - if (!GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window), "pluma-is-quitting-all"))) - { - /* Create hidden proxy window on OS X to handle the menu */ - pluma_app_create_window (app, NULL); - return; - } -#endif /* Last window is gone... save some settings and exit */ ensure_user_config_dir (); diff --git a/pluma/pluma-commands-file.c b/pluma/pluma-commands-file.c index a40ef1cb..a21cdff6 100644 --- a/pluma/pluma-commands-file.c +++ b/pluma/pluma-commands-file.c @@ -1647,11 +1647,6 @@ close_confirmation_dialog_response_handler (PlumaCloseConfirmationDialog *dlg, PLUMA_IS_QUITTING, GBOOLEAN_TO_POINTER (FALSE)); -#ifdef OS_OSX - g_object_set_data (G_OBJECT (window), - PLUMA_IS_QUITTING_ALL, - GINT_TO_POINTER (FALSE)); -#endif break; } @@ -1734,10 +1729,6 @@ _pluma_cmd_file_close (GtkAction *action, if (active_tab == NULL) { -#ifdef OS_OSX - /* Close the window on OS X */ - gtk_widget_destroy (GTK_WIDGET (window)); -#endif return; } @@ -1829,53 +1820,12 @@ _pluma_cmd_file_close_all (GtkAction *action, file_close_all (window, FALSE); } -/* Quit */ -#ifdef OS_OSX -static void -quit_all () -{ - GList *windows; - GList *item; - PlumaApp *app; - - app = pluma_app_get_default (); - windows = g_list_copy ((GList *)pluma_app_get_windows (app)); - - for (item = windows; item; item = g_list_next (item)) - { - PlumaWindow *window = PLUMA_WINDOW (item->data); - - g_object_set_data (G_OBJECT (window), - PLUMA_IS_QUITTING_ALL, - GINT_TO_POINTER (TRUE)); - - if (!(pluma_window_get_state (window) & - (PLUMA_WINDOW_STATE_SAVING | - PLUMA_WINDOW_STATE_PRINTING | - PLUMA_WINDOW_STATE_SAVING_SESSION))) - { - file_close_all (window, TRUE); - } - } - - g_list_free (windows); -} -#endif - void _pluma_cmd_file_quit (GtkAction *action, PlumaWindow *window) { pluma_debug (DEBUG_COMMANDS); -#ifdef OS_OSX - if (action != NULL) - { - quit_all (); - return; - } -#endif - g_return_if_fail (!(pluma_window_get_state (window) & (PLUMA_WINDOW_STATE_SAVING | PLUMA_WINDOW_STATE_PRINTING | diff --git a/pluma/pluma-dirs.c b/pluma/pluma-dirs.c index 8c079cf0..929b8bd2 100644 --- a/pluma/pluma-dirs.c +++ b/pluma/pluma-dirs.c @@ -22,15 +22,11 @@ */ #ifdef HAVE_CONFIG_H - #include <config.h> +#include <config.h> #endif #include "pluma-dirs.h" -#ifdef OS_OSX - #include <ige-mac-bundle.h> -#endif - gchar* pluma_dirs_get_user_config_dir(void) { gchar* config_dir = NULL; @@ -73,102 +69,17 @@ gchar* pluma_dirs_get_user_accels_file(void) gchar* pluma_dirs_get_pluma_data_dir(void) { - gchar* data_dir; - - #ifdef G_OS_WIN32 - gchar* win32_dir; - - win32_dir = g_win32_get_package_installation_directory_of_module(NULL); - - data_dir = g_build_filename(win32_dir, "share", "pluma", NULL); - - g_free(win32_dir); - - #elif defined(OS_OSX) - - IgeMacBundle* bundle = ige_mac_bundle_get_default(); - - if (ige_mac_bundle_get_is_app_bundle(bundle)) - { - const gchar* bundle_data_dir = ige_mac_bundle_get_datadir(bundle); - - data_dir = g_build_filename(bundle_data_dir, "pluma", NULL); - } - else - { - data_dir = g_build_filename(DATADIR, "pluma", NULL); - } - #else - data_dir = g_build_filename(DATADIR, "pluma", NULL); - #endif - - return data_dir; + return g_build_filename(DATADIR, "pluma", NULL); } gchar* pluma_dirs_get_pluma_locale_dir(void) { - gchar* locale_dir; - - #ifdef G_OS_WIN32 - - gchar* win32_dir; - - win32_dir = g_win32_get_package_installation_directory_of_module(NULL); - - locale_dir = g_build_filename(win32_dir, "share", "locale", NULL); - - g_free(win32_dir); - - #elif defined(OS_OSX) - - IgeMacBundle *bundle = ige_mac_bundle_get_default(); - - if (ige_mac_bundle_get_is_app_bundle(bundle)) - { - locale_dir = g_strdup(ige_mac_bundle_get_localedir(bundle)); - } - else - { - locale_dir = g_build_filename(DATADIR, "locale", NULL); - } - #else - locale_dir = g_build_filename(DATADIR, "locale", NULL); - #endif - - return locale_dir; + return g_build_filename(DATADIR, "locale", NULL); } gchar* pluma_dirs_get_pluma_lib_dir(void) { - gchar* lib_dir; - - #ifdef G_OS_WIN32 - - gchar* win32_dir; - - win32_dir = g_win32_get_package_installation_directory_of_module(NULL); - - lib_dir = g_build_filename(win32_dir, "lib", "pluma", NULL); - - g_free(win32_dir); - - #elif defined(OS_OSX) - IgeMacBundle* bundle = ige_mac_bundle_get_default(); - - if (ige_mac_bundle_get_is_app_bundle(bundle)) - { - const gchar* path = ige_mac_bundle_get_resourcesdir(bundle); - lib_dir = g_build_filename(path, "lib", "pluma", NULL); - } - else - { - lib_dir = g_build_filename(LIBDIR, "pluma", NULL); - } - #else - lib_dir = g_build_filename(LIBDIR, "pluma", NULL); - #endif - - return lib_dir; + return g_build_filename(LIBDIR, "pluma", NULL); } gchar* pluma_dirs_get_pluma_plugins_dir(void) diff --git a/pluma/pluma-document.h b/pluma/pluma-document.h index 099aaae1..80b66780 100644 --- a/pluma/pluma-document.h +++ b/pluma/pluma-document.h @@ -51,15 +51,9 @@ G_BEGIN_DECLS #define PLUMA_IS_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PLUMA_TYPE_DOCUMENT)) #define PLUMA_DOCUMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PLUMA_TYPE_DOCUMENT, PlumaDocumentClass)) -#ifdef G_OS_WIN32 -#define PLUMA_METADATA_ATTRIBUTE_POSITION "position" -#define PLUMA_METADATA_ATTRIBUTE_ENCODING "encoding" -#define PLUMA_METADATA_ATTRIBUTE_LANGUAGE "language" -#else #define PLUMA_METADATA_ATTRIBUTE_POSITION "metadata::pluma-position" #define PLUMA_METADATA_ATTRIBUTE_ENCODING "metadata::pluma-encoding" #define PLUMA_METADATA_ATTRIBUTE_LANGUAGE "metadata::pluma-language" -#endif typedef enum { @@ -68,11 +62,7 @@ typedef enum PLUMA_DOCUMENT_NEWLINE_TYPE_CR_LF } PlumaDocumentNewlineType; -#ifdef G_OS_WIN32 -#define PLUMA_DOCUMENT_NEWLINE_TYPE_DEFAULT PLUMA_DOCUMENT_NEWLINE_TYPE_CR_LF -#else #define PLUMA_DOCUMENT_NEWLINE_TYPE_DEFAULT PLUMA_DOCUMENT_NEWLINE_TYPE_LF -#endif typedef enum { diff --git a/pluma/pluma-help.c b/pluma/pluma-help.c index 336d5793..23129b89 100644 --- a/pluma/pluma-help.c +++ b/pluma/pluma-help.c @@ -38,10 +38,6 @@ #include <string.h> #include <gtk/gtk.h> -#ifdef OS_OSX -#include "osx/pluma-osx.h" -#endif - gboolean pluma_help_display (GtkWindow *parent, const gchar *name, /* "pluma" if NULL */ @@ -53,17 +49,6 @@ pluma_help_display (GtkWindow *parent, g_return_val_if_fail ((parent == NULL) || GTK_IS_WINDOW (parent), FALSE); -#ifdef OS_OSX - if (name == NULL || strcmp(name, "pluma.xml") == NULL || strcmp(name, "pluma") == 0) - { - return pluma_osx_show_help (link_id); - } - else - { - return FALSE; - } -#endif - if (name == NULL) name = "pluma"; else if (strcmp (name, "pluma.xml") == 0) @@ -73,18 +58,10 @@ pluma_help_display (GtkWindow *parent, name = "pluma"; } -#ifndef G_OS_WIN32 if (link_id) link = g_strdup_printf ("help:%s/%s", name, link_id); else link = g_strdup_printf ("help:%s", name); -#else - if (link_id) - link = g_strdup_printf ("http://library.gnome.org/users/pluma/stable/%s", - link_id); - else - link = g_strdup ("http://library.gnome.org/users/pluma/stable/"); -#endif ret = gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (parent)), link, diff --git a/pluma/pluma-ui.h b/pluma/pluma-ui.h index 50b3740f..c2c465b2 100644 --- a/pluma/pluma-ui.h +++ b/pluma/pluma-ui.h @@ -114,13 +114,8 @@ static const GtkActionEntry pluma_menu_entries[] = N_("Search forwards for the same text"), G_CALLBACK (_pluma_cmd_search_find_next) }, { "SearchFindPrevious", NULL, N_("Find Pre_vious"), "<shift><control>G", N_("Search backwards for the same text"), G_CALLBACK (_pluma_cmd_search_find_prev) }, -#ifndef OS_OSX { "SearchReplace", GTK_STOCK_FIND_AND_REPLACE, N_("_Replace..."), "<control>H", N_("Search for and replace text"), G_CALLBACK (_pluma_cmd_search_replace) }, -#else - { "SearchReplace", GTK_STOCK_FIND_AND_REPLACE, N_("_Replace..."), "<control><alt>F", - N_("Search for and replace text"), G_CALLBACK (_pluma_cmd_search_replace) }, -#endif { "SearchClearHighlight", NULL, N_("_Clear Highlight"), "<shift><control>K", N_("Clear highlighting of search matches"), G_CALLBACK (_pluma_cmd_search_clear_highlight) }, { "SearchGoToLine", GTK_STOCK_JUMP_TO, N_("Go to _Line..."), "<control>I", diff --git a/pluma/pluma-window-private.h b/pluma/pluma-window-private.h index 0f0ff34c..e575a59e 100644 --- a/pluma/pluma-window-private.h +++ b/pluma/pluma-window-private.h @@ -35,10 +35,6 @@ #include "pluma-prefs-manager.h" #include "pluma-message-bus.h" -#ifdef OS_OSX -#include <ige-mac-integration.h> -#endif - G_BEGIN_DECLS /* WindowPrivate is in a separate .h so that we can access it from pluma-commands */ @@ -111,10 +107,6 @@ struct _PlumaWindowPrivate GFile *default_location; -#ifdef OS_OSX - IgeMacMenuGroup *mac_menu_group; -#endif - gboolean removing_tabs : 1; gboolean dispose_has_run : 1; }; diff --git a/pluma/pluma-window.c b/pluma/pluma-window.c index 8ebb7953..f00f2ac8 100644 --- a/pluma/pluma-window.c +++ b/pluma/pluma-window.c @@ -61,10 +61,6 @@ #include "pluma-dirs.h" #include "pluma-status-combo-box.h" -#ifdef OS_OSX -#include "osx/pluma-osx.h" -#endif - #define LANGUAGE_NONE (const gchar *)"LangNone" #define PLUMA_UIFILE "pluma-ui.xml" #define TAB_WIDTH_DATA "PlumaWindowTabWidthData" @@ -159,58 +155,6 @@ save_panes_state (PlumaWindow *window) pluma_prefs_manager_set_bottom_panel_active_page (pane_page); } -#ifdef OS_OSX -static GtkMenuItem * -ui_manager_menu_item (GtkUIManager *uimanager, - const gchar *path) -{ - return GTK_MENU_ITEM (gtk_ui_manager_get_widget (uimanager, path)); -} - -static void -add_mac_root_menu (PlumaWindow *window) -{ - if (window->priv->mac_menu_group != NULL) - { - return; - } - - window->priv->mac_menu_group = ige_mac_menu_add_app_menu_group (); - - ige_mac_menu_add_app_menu_item (window->priv->mac_menu_group, - ui_manager_menu_item (window->priv->manager, "/ui/MenuBar/HelpMenu/HelpAboutMenu"), - NULL); -} - -static void -remove_mac_root_menu (PlumaWindow *window) -{ - if (window->priv->mac_menu_group == NULL) - { - return; - } - - ige_mac_menu_remove_app_menu_group (window->priv->mac_menu_group); - window->priv->mac_menu_group = NULL; -} - -static gboolean -pluma_window_focus_in_event (GtkWidget *widget, - GdkEventFocus *event) -{ - add_mac_root_menu (PLUMA_WINDOW (widget)); - return GTK_WIDGET_CLASS (pluma_window_parent_class)->focus_in_event (widget, event); -} - -static gboolean -pluma_window_focus_out_event (GtkWidget *widget, - GdkEventFocus *event) -{ - remove_mac_root_menu (PLUMA_WINDOW (widget)); - return GTK_WIDGET_CLASS (pluma_window_parent_class)->focus_out_event (widget, event); -} -#endif - static void pluma_window_dispose (GObject *object) { @@ -292,10 +236,6 @@ pluma_window_dispose (GObject *object) */ pluma_plugins_engine_garbage_collect (pluma_plugins_engine_get_default ()); -#ifdef OS_OSX - remove_mac_root_menu (window); -#endif - G_OBJECT_CLASS (pluma_window_parent_class)->dispose (object); } @@ -403,11 +343,6 @@ pluma_window_class_init (PlumaWindowClass *klass) widget_class->configure_event = pluma_window_configure_event; widget_class->key_press_event = pluma_window_key_press_event; -#ifdef OS_OSX - widget_class->focus_in_event = pluma_window_focus_in_event; - widget_class->focus_out_event = pluma_window_focus_out_event; -#endif - signals[TAB_ADDED] = g_signal_new ("tab_added", G_OBJECT_CLASS_TYPE (object_class), @@ -2183,11 +2118,7 @@ set_title (PlumaWindow *window) if (window->priv->active_tab == NULL) { -#ifdef OS_OSX - pluma_osx_set_window_title (window, "pluma", NULL); -#else gtk_window_set_title (GTK_WINDOW (window), "pluma"); -#endif return; } @@ -2267,11 +2198,7 @@ set_title (PlumaWindow *window) name); } -#ifdef OS_OSX - pluma_osx_set_window_title (window, title, doc); -#else gtk_window_set_title (GTK_WINDOW (window), title); -#endif g_free (dirname); g_free (name); @@ -2583,14 +2510,8 @@ set_sensitivity_according_to_window_state (PlumaWindow *window) window->priv->num_tabs > 0); if (!gtk_action_group_get_sensitive (window->priv->close_action_group)) { -#ifdef OS_OSX - /* On OS X, File Close is always sensitive */ - gtk_action_group_set_sensitive (window->priv->close_action_group, - TRUE); -#else gtk_action_group_set_sensitive (window->priv->close_action_group, window->priv->num_tabs > 0); -#endif } } } @@ -3212,11 +3133,8 @@ update_sensitivity_according_to_open_tabs (PlumaWindow *window) gtk_action_set_sensitive (action, window->priv->num_tabs > 1); - /* Do not set close action insensitive on OS X */ -#ifndef OS_OSX gtk_action_group_set_sensitive (window->priv->close_action_group, window->priv->num_tabs != 0); -#endif } static void @@ -3840,27 +3758,6 @@ check_window_is_active (PlumaWindow *window, } } -#ifdef OS_OSX -static void -setup_mac_menu (PlumaWindow *window) -{ - GtkAction *action; - - gtk_widget_hide (window->priv->menubar); - action = gtk_ui_manager_get_action (window->priv->manager, "/ui/MenuBar/HelpMenu/HelpAboutMenu"); - - gtk_action_set_label (action, _("About pluma")); - - ige_mac_menu_set_menu_bar (GTK_MENU_SHELL (window->priv->menubar)); - ige_mac_menu_set_quit_menu_item (ui_manager_menu_item (window->priv->manager, "/ui/MenuBar/FileMenu/FileQuitMenu")); - - ige_mac_menu_set_preferences_menu_item (ui_manager_menu_item (window->priv->manager, "/ui/MenuBar/EditMenu/EditPreferencesMenu")); - - add_mac_root_menu (window); - ige_mac_menu_connect_window_key_handler (GTK_WINDOW (window)); -} -#endif - static void connect_notebook_signals (PlumaWindow *window, GtkWidget *notebook) @@ -4042,10 +3939,6 @@ pluma_window_init (PlumaWindow *window) update_sensitivity_according_to_open_tabs (window); -#ifdef OS_OSX - setup_mac_menu (window); -#endif - pluma_debug_message (DEBUG_WINDOW, "END"); } diff --git a/pluma/pluma.c b/pluma/pluma.c index 8cd599dd..4fb5a752 100644 --- a/pluma/pluma.c +++ b/pluma/pluma.c @@ -40,10 +40,7 @@ #include <glib.h> #include <glib/gi18n.h> #include <gtk/gtk.h> - -#ifdef GDK_WINDOWING_X11 #include <gdk/gdkx.h> -#endif #include "pluma-app.h" #include "pluma-commands.h" @@ -59,34 +56,15 @@ #include "eggsmclient.h" #include "eggdesktopfile.h" -#ifdef G_OS_WIN32 -#define SAVE_DATADIR DATADIR -#undef DATADIR -#include <io.h> -#include <conio.h> -#define _WIN32_WINNT 0x0500 -#include <windows.h> -#define DATADIR SAVE_DATADIR -#undef SAVE_DATADIR -#endif - -#ifdef OS_OSX -#include <ige-mac-dock.h> -#include <ige-mac-integration.h> -#include "osx/pluma-osx.h" -#endif - #ifndef ENABLE_GVFS_METADATA #include "pluma-metadata-manager.h" #endif -static guint32 startup_timestamp = 0; - -#ifndef G_OS_WIN32 #include "bacon-message-connection.h" +static guint32 startup_timestamp = 0; + static BaconMessageConnection *connection; -#endif /* command line */ static gint line_position = 0; @@ -234,7 +212,6 @@ get_startup_timestamp (void) return (retval > 0) ? retval : 0; } -#ifndef G_OS_WIN32 static GdkDisplay * display_open_if_needed (const gchar *name) { @@ -400,13 +377,11 @@ on_message_received (const char *message, if (!gtk_widget_get_realized (GTK_WIDGET (window))) gtk_widget_realize (GTK_WIDGET (window)); -#ifdef GDK_WINDOWING_X11 if (startup_timestamp <= 0) startup_timestamp = gdk_x11_get_server_time (gtk_widget_get_window (GTK_WIDGET (window))); gdk_x11_window_set_user_time (gtk_widget_get_window (GTK_WIDGET (window)), startup_timestamp); -#endif gtk_window_present (GTK_WINDOW (window)); @@ -513,35 +488,6 @@ send_bacon_message (void) g_string_free (command, TRUE); } -#endif /* G_OS_WIN32 */ - -#ifdef G_OS_WIN32 -static void -setup_path (void) -{ - gchar *path; - gchar *installdir; - gchar *bin; - - installdir = g_win32_get_package_installation_directory_of_module (NULL); - - bin = g_build_filename (installdir, - "bin", NULL); - g_free (installdir); - - /* Set PATH to include the pluma executable's folder */ - path = g_build_path (";", - bin, - g_getenv ("PATH"), - NULL); - g_free (bin); - - if (!g_setenv ("PATH", path, TRUE)) - g_warning ("Could not set PATH for pluma"); - - g_free (path); -} -#endif int main (int argc, char *argv[]) @@ -576,33 +522,6 @@ main (int argc, char *argv[]) g_option_context_add_group (context, gtk_get_option_group (FALSE)); g_option_context_add_group (context, egg_sm_client_get_option_group ()); -#ifdef G_OS_WIN32 - setup_path (); - - /* If we open pluma from a console get the stdout printing */ - if (fileno (stdout) != -1 && - _get_osfhandle (fileno (stdout)) != -1) - { - /* stdout is fine, presumably redirected to a file or pipe */ - } - else - { - typedef BOOL (* WINAPI AttachConsole_t) (DWORD); - - AttachConsole_t p_AttachConsole = - (AttachConsole_t) GetProcAddress (GetModuleHandle ("kernel32.dll"), - "AttachConsole"); - - if (p_AttachConsole != NULL && p_AttachConsole (ATTACH_PARENT_PROCESS)) - { - freopen ("CONOUT$", "w", stdout); - dup2 (fileno (stdout), 1); - freopen ("CONOUT$", "w", stderr); - dup2 (fileno (stderr), 2); - } - } -#endif - gtk_init (&argc, &argv); if (!g_option_context_parse (context, &argc, &argv, &error)) @@ -616,7 +535,6 @@ main (int argc, char *argv[]) g_option_context_free (context); -#ifndef G_OS_WIN32 pluma_debug_message (DEBUG_APP, "Create bacon connection"); connection = bacon_message_connection_new ("pluma"); @@ -655,7 +573,6 @@ main (int argc, char *argv[]) { g_warning ("Cannot create the 'pluma' connection."); } -#endif pluma_debug_message (DEBUG_APP, "Set icon"); @@ -669,14 +586,8 @@ main (int argc, char *argv[]) icon_dir); g_free (icon_dir); -#ifdef GDK_WINDOWING_X11 /* Set the associated .desktop file */ egg_set_desktop_file (DATADIR "/applications/pluma.desktop"); -#else - /* manually set name and icon */ - g_set_application_name("Pluma"); - gtk_window_set_default_icon_name ("accessories-text-editor"); -#endif /* Load user preferences */ pluma_debug_message (DEBUG_APP, "Init prefs manager"); @@ -690,10 +601,6 @@ main (int argc, char *argv[]) pluma_debug_message (DEBUG_APP, "Init session manager"); pluma_session_init (); -#ifdef OS_OSX - ige_mac_menu_set_global_key_handler_enabled (FALSE); -#endif - if (pluma_session_is_restored ()) restored = pluma_session_load (); @@ -735,14 +642,9 @@ main (int argc, char *argv[]) pluma_debug_message (DEBUG_APP, "Start gtk-main"); -#ifdef OS_OSX - pluma_osx_init(pluma_app_get_default ()); -#endif gtk_main(); -#ifndef G_OS_WIN32 bacon_message_connection_free (connection); -#endif /* We kept the original engine reference here. So let's unref it to * finalize it properly. diff --git a/pluma/smclient/Makefile.am b/pluma/smclient/Makefile.am index 481cd914..56d35d06 100755 --- a/pluma/smclient/Makefile.am +++ b/pluma/smclient/Makefile.am @@ -1,18 +1,7 @@ -if OS_WIN32 -platform_sources = eggsmclient-win32.c -platform_logout_test_ldflags = -mwindows -else -if OS_OSX -platform_defines = -xobjective-c -platform_ldflags = -framework Carbon -platform_sources = eggsmclient-osx.c -else platform_defines = -DEGG_SM_CLIENT_BACKEND_XSMP platform_libs = libeggdesktopfile.la platform_ltlibraries = libeggdesktopfile.la platform_sources = eggsmclient-xsmp.c -endif -endif AM_CPPFLAGS = \ -DG_LOG_DOMAIN=\""EggSMClient"\" \ @@ -45,8 +34,6 @@ libeggdesktopfile_la_SOURCES = \ eggdesktopfile.h EXTRA_DIST = \ - eggsmclient-osx.c \ - eggsmclient-win32.c \ eggsmclient-xsmp.c -include $(top_srcdir)/git.mk diff --git a/pluma/smclient/eggsmclient-osx.c b/pluma/smclient/eggsmclient-osx.c deleted file mode 100755 index 1ccfa7fd..00000000 --- a/pluma/smclient/eggsmclient-osx.c +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright (C) 2007 Novell, Inc. - * Copyright (C) 2008 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -/* EggSMClientOSX - * - * For details on the OS X logout process, see: - * http://developer.apple.com/documentation/MacOSX/Conceptual/BPSystemStartup/Articles/BootProcess.html#//apple_ref/doc/uid/20002130-114618 - * - * EggSMClientOSX registers for the kAEQuitApplication AppleEvent; the - * handler we register (quit_requested()) will be invoked from inside - * the quartz event-handling code (specifically, from inside - * [NSApplication nextEventMatchingMask]) when an AppleEvent arrives. - * We use AESuspendTheCurrentEvent() and AEResumeTheCurrentEvent() to - * allow asynchronous / non-main-loop-reentering processing of the - * quit request. (These are part of the Carbon framework; it doesn't - * seem to be possible to handle AppleEvents asynchronously from - * Cocoa.) - */ - -#include "config.h" - -#include "eggsmclient-private.h" -#include <glib.h> -#include <Carbon/Carbon.h> -#include <CoreServices/CoreServices.h> - -#define EGG_TYPE_SM_CLIENT_OSX (egg_sm_client_osx_get_type ()) -#define EGG_SM_CLIENT_OSX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_SM_CLIENT_OSX, EggSMClientOSX)) -#define EGG_SM_CLIENT_OSX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_SM_CLIENT_OSX, EggSMClientOSXClass)) -#define EGG_IS_SM_CLIENT_OSX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_SM_CLIENT_OSX)) -#define EGG_IS_SM_CLIENT_OSX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_SM_CLIENT_OSX)) -#define EGG_SM_CLIENT_OSX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_SM_CLIENT_OSX, EggSMClientOSXClass)) - -typedef struct _EggSMClientOSX EggSMClientOSX; -typedef struct _EggSMClientOSXClass EggSMClientOSXClass; - -struct _EggSMClientOSX { - EggSMClient parent; - - AppleEvent quit_event, quit_reply; - gboolean quit_requested, quitting; -}; - -struct _EggSMClientOSXClass -{ - EggSMClientClass parent_class; - -}; - -static void sm_client_osx_startup (EggSMClient *client, - const char *client_id); -static void sm_client_osx_will_quit (EggSMClient *client, - gboolean will_quit); -static gboolean sm_client_osx_end_session (EggSMClient *client, - EggSMClientEndStyle style, - gboolean request_confirmation); - -static pascal OSErr quit_requested (const AppleEvent *, AppleEvent *, long); - -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); - - 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); -} - -static void -sm_client_osx_startup (EggSMClient *client, - const char *client_id) -{ - 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; -} - -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; -} - -static pascal OSErr -quit_requested_resumed (const AppleEvent *aevt, AppleEvent *reply, long refcon) -{ - EggSMClientOSX *osx = GSIZE_TO_POINTER ((gsize)refcon); - - 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; -} - -static void -sm_client_osx_will_quit (EggSMClient *client, - gboolean will_quit) -{ - EggSMClientOSX *osx = (EggSMClientOSX *)client; - - g_return_if_fail (osx->quit_requested); - - 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); -} - -static gboolean -sm_client_osx_end_session (EggSMClient *client, - 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; -} diff --git a/pluma/smclient/eggsmclient-private.h b/pluma/smclient/eggsmclient-private.h index d13035bf..071eb8f0 100755 --- a/pluma/smclient/eggsmclient-private.h +++ b/pluma/smclient/eggsmclient-private.h @@ -33,22 +33,8 @@ void egg_sm_client_quit_requested (EggSMClient *client); void egg_sm_client_quit_cancelled (EggSMClient *client); void egg_sm_client_quit (EggSMClient *client); -#if defined (GDK_WINDOWING_X11) -# ifdef EGG_SM_CLIENT_BACKEND_XSMP GType egg_sm_client_xsmp_get_type (void); EggSMClient *egg_sm_client_xsmp_new (void); -# endif -# ifdef EGG_SM_CLIENT_BACKEND_DBUS -GType egg_sm_client_dbus_get_type (void); -EggSMClient *egg_sm_client_dbus_new (void); -# endif -#elif defined (GDK_WINDOWING_WIN32) -GType egg_sm_client_win32_get_type (void); -EggSMClient *egg_sm_client_win32_new (void); -#elif defined (GDK_WINDOWING_QUARTZ) -GType egg_sm_client_osx_get_type (void); -EggSMClient *egg_sm_client_osx_new (void); -#endif G_END_DECLS diff --git a/pluma/smclient/eggsmclient-win32.c b/pluma/smclient/eggsmclient-win32.c deleted file mode 100755 index 7b88fa15..00000000 --- a/pluma/smclient/eggsmclient-win32.c +++ /dev/null @@ -1,353 +0,0 @@ -/* - * Copyright (C) 2007 Novell, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -/* EggSMClientWin32 - * - * For details on the Windows XP logout process, see: - * http://msdn.microsoft.com/en-us/library/aa376876.aspx. - * - * Vista adds some new APIs which EggSMClient does not make use of; see - * http://msdn.microsoft.com/en-us/library/ms700677(VS.85).aspx - * - * When shutting down, Windows sends every top-level window a - * WM_QUERYENDSESSION event, which the application must respond to - * synchronously, saying whether or not it will quit. To avoid main - * loop re-entrancy problems (and to avoid having to muck about too - * much with the guts of the gdk-win32 main loop), we watch for this - * event in a separate thread, which then signals the main thread and - * waits for the main thread to handle the event. Since we don't want - * to require g_thread_init() to be called, we do this all using - * Windows-specific thread methods. - * - * After the application handles the WM_QUERYENDSESSION event, - * Windows then sends it a WM_ENDSESSION event with a TRUE or FALSE - * parameter indicating whether the session is or is not actually - * going to end now. We handle this from the other thread as well. - * - * As mentioned above, Vista introduces several additional new APIs - * that don't fit into the (current) EggSMClient API. Windows also has - * an entirely separate shutdown-notification scheme for non-GUI apps, - * which we also don't handle here. - */ - -#include "config.h" - -#include "eggsmclient-private.h" -#include <gdk/gdk.h> - -#define WIN32_LEAN_AND_MEAN -#define UNICODE -#include <windows.h> -#include <process.h> - -#define EGG_TYPE_SM_CLIENT_WIN32 (egg_sm_client_win32_get_type ()) -#define EGG_SM_CLIENT_WIN32(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_SM_CLIENT_WIN32, EggSMClientWin32)) -#define EGG_SM_CLIENT_WIN32_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_SM_CLIENT_WIN32, EggSMClientWin32Class)) -#define EGG_IS_SM_CLIENT_WIN32(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_SM_CLIENT_WIN32)) -#define EGG_IS_SM_CLIENT_WIN32_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_SM_CLIENT_WIN32)) -#define EGG_SM_CLIENT_WIN32_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_SM_CLIENT_WIN32, EggSMClientWin32Class)) - -typedef struct _EggSMClientWin32 EggSMClientWin32; -typedef struct _EggSMClientWin32Class EggSMClientWin32Class; - -struct _EggSMClientWin32 { - EggSMClient parent; - - HANDLE message_event, response_event; - - volatile GSourceFunc event; - volatile gboolean will_quit; -}; - -struct _EggSMClientWin32Class -{ - EggSMClientClass parent_class; - -}; - -static void sm_client_win32_startup (EggSMClient *client, - const char *client_id); -static void sm_client_win32_will_quit (EggSMClient *client, - gboolean will_quit); -static gboolean sm_client_win32_end_session (EggSMClient *client, - EggSMClientEndStyle style, - gboolean request_confirmation); - -static GSource *g_win32_handle_source_add (HANDLE handle, GSourceFunc callback, - gpointer user_data); -static gboolean got_message (gpointer user_data); -static void sm_client_thread (gpointer data); - -G_DEFINE_TYPE (EggSMClientWin32, egg_sm_client_win32, EGG_TYPE_SM_CLIENT) - -static void -egg_sm_client_win32_init (EggSMClientWin32 *win32) -{ - ; -} - -static void -egg_sm_client_win32_class_init (EggSMClientWin32Class *klass) -{ - EggSMClientClass *sm_client_class = EGG_SM_CLIENT_CLASS (klass); - - sm_client_class->startup = sm_client_win32_startup; - sm_client_class->will_quit = sm_client_win32_will_quit; - sm_client_class->end_session = sm_client_win32_end_session; -} - -EggSMClient * -egg_sm_client_win32_new (void) -{ - return g_object_new (EGG_TYPE_SM_CLIENT_WIN32, NULL); -} - -static void -sm_client_win32_startup (EggSMClient *client, - const char *client_id) -{ - EggSMClientWin32 *win32 = (EggSMClientWin32 *)client; - - win32->message_event = CreateEvent (NULL, FALSE, FALSE, NULL); - win32->response_event = CreateEvent (NULL, FALSE, FALSE, NULL); - g_win32_handle_source_add (win32->message_event, got_message, win32); - _beginthread (sm_client_thread, 0, client); -} - -static void -sm_client_win32_will_quit (EggSMClient *client, - gboolean will_quit) -{ - EggSMClientWin32 *win32 = (EggSMClientWin32 *)client; - - win32->will_quit = will_quit; - SetEvent (win32->response_event); -} - -static gboolean -sm_client_win32_end_session (EggSMClient *client, - EggSMClientEndStyle style, - gboolean request_confirmation) -{ - UINT uFlags = EWX_LOGOFF; - - switch (style) - { - case EGG_SM_CLIENT_END_SESSION_DEFAULT: - case EGG_SM_CLIENT_LOGOUT: - uFlags = EWX_LOGOFF; - break; - case EGG_SM_CLIENT_REBOOT: - uFlags = EWX_REBOOT; - break; - case EGG_SM_CLIENT_SHUTDOWN: - uFlags = EWX_POWEROFF; - break; - } - - /* There's no way to make ExitWindowsEx() show a logout dialog, so - * we ignore @request_confirmation. - */ - -#ifdef SHTDN_REASON_FLAG_PLANNED - ExitWindowsEx (uFlags, SHTDN_REASON_FLAG_PLANNED); -#else - ExitWindowsEx (uFlags, 0); -#endif - - return TRUE; -} - - -/* callbacks from logout-listener thread */ - -static gboolean -emit_quit_requested (gpointer smclient) -{ - gdk_threads_enter (); - egg_sm_client_quit_requested (smclient); - gdk_threads_leave (); - - return FALSE; -} - -static gboolean -emit_quit (gpointer smclient) -{ - EggSMClientWin32 *win32 = smclient; - - gdk_threads_enter (); - egg_sm_client_quit (smclient); - gdk_threads_leave (); - - SetEvent (win32->response_event); - return FALSE; -} - -static gboolean -emit_quit_cancelled (gpointer smclient) -{ - EggSMClientWin32 *win32 = smclient; - - gdk_threads_enter (); - egg_sm_client_quit_cancelled (smclient); - gdk_threads_leave (); - - SetEvent (win32->response_event); - return FALSE; -} - -static gboolean -got_message (gpointer smclient) -{ - EggSMClientWin32 *win32 = smclient; - - win32->event (win32); - return TRUE; -} - -/* Windows HANDLE GSource */ - -typedef struct { - GSource source; - GPollFD pollfd; -} GWin32HandleSource; - -static gboolean -g_win32_handle_source_prepare (GSource *source, gint *timeout) -{ - *timeout = -1; - return FALSE; -} - -static gboolean -g_win32_handle_source_check (GSource *source) -{ - GWin32HandleSource *hsource = (GWin32HandleSource *)source; - - return hsource->pollfd.revents; -} - -static gboolean -g_win32_handle_source_dispatch (GSource *source, GSourceFunc callback, gpointer user_data) -{ - return (*callback) (user_data); -} - -static void -g_win32_handle_source_finalize (GSource *source) -{ - ; -} - -GSourceFuncs g_win32_handle_source_funcs = { - g_win32_handle_source_prepare, - g_win32_handle_source_check, - g_win32_handle_source_dispatch, - g_win32_handle_source_finalize -}; - -static GSource * -g_win32_handle_source_add (HANDLE handle, GSourceFunc callback, gpointer user_data) -{ - GWin32HandleSource *hsource; - GSource *source; - - source = g_source_new (&g_win32_handle_source_funcs, sizeof (GWin32HandleSource)); - hsource = (GWin32HandleSource *)source; - hsource->pollfd.fd = (int)handle; - hsource->pollfd.events = G_IO_IN; - hsource->pollfd.revents = 0; - g_source_add_poll (source, &hsource->pollfd); - - g_source_set_callback (source, callback, user_data, NULL); - g_source_attach (source, NULL); - return source; -} - -/* logout-listener thread */ - -LRESULT CALLBACK -sm_client_win32_window_procedure (HWND hwnd, - UINT message, - WPARAM wParam, - LPARAM lParam) -{ - EggSMClientWin32 *win32 = - (EggSMClientWin32 *)GetWindowLongPtr (hwnd, GWLP_USERDATA); - - switch (message) - { - case WM_QUERYENDSESSION: - win32->event = emit_quit_requested; - SetEvent (win32->message_event); - - WaitForSingleObject (win32->response_event, INFINITE); - return win32->will_quit; - - case WM_ENDSESSION: - if (wParam) - { - /* The session is ending */ - win32->event = emit_quit; - } - else - { - /* Nope, the session *isn't* ending */ - win32->event = emit_quit_cancelled; - } - - SetEvent (win32->message_event); - WaitForSingleObject (win32->response_event, INFINITE); - - return 0; - - default: - return DefWindowProc (hwnd, message, wParam, lParam); - } -} - -static void -sm_client_thread (gpointer smclient) -{ - HINSTANCE instance; - WNDCLASSEXW wcl; - ATOM klass; - HWND window; - MSG msg; - - instance = GetModuleHandle (NULL); - - memset (&wcl, 0, sizeof (WNDCLASSEX)); - wcl.cbSize = sizeof (WNDCLASSEX); - wcl.lpfnWndProc = sm_client_win32_window_procedure; - wcl.hInstance = instance; - wcl.lpszClassName = L"EggSmClientWindow"; - klass = RegisterClassEx (&wcl); - - window = CreateWindowEx (0, MAKEINTRESOURCE (klass), - L"EggSmClientWindow", 0, - 10, 10, 50, 50, GetDesktopWindow (), - NULL, instance, NULL); - SetWindowLongPtr (window, GWLP_USERDATA, (LONG_PTR)smclient); - - /* main loop */ - while (GetMessage (&msg, NULL, 0, 0)) - DispatchMessage (&msg); -} diff --git a/pluma/smclient/eggsmclient.c b/pluma/smclient/eggsmclient.c index 0cc3818a..4fc64dad 100755 --- a/pluma/smclient/eggsmclient.c +++ b/pluma/smclient/eggsmclient.c @@ -320,23 +320,7 @@ egg_sm_client_get (void) if (global_client_mode != EGG_SM_CLIENT_MODE_DISABLED && !sm_client_disable) { -#if defined (GDK_WINDOWING_WIN32) - global_client = egg_sm_client_win32_new (); -#elif defined (GDK_WINDOWING_QUARTZ) - global_client = egg_sm_client_osx_new (); -#else - /* If both D-Bus and XSMP are compiled in, try XSMP first - * (since it supports state saving) and fall back to D-Bus - * if XSMP isn't available. - */ -# ifdef EGG_SM_CLIENT_BACKEND_XSMP global_client = egg_sm_client_xsmp_new (); -# endif -# ifdef EGG_SM_CLIENT_BACKEND_DBUS - if (!global_client) - global_client = egg_sm_client_dbus_new (); -# endif -#endif } /* Fallback: create a dummy client, so that callers don't have |