void panel_session_init (void) { EggSMClientMode mode; EggSMClient *client; /* Explicitly tell the session manager we're ready -- we don't do it * before. Note: this depends on setting the mode to DISABLED early * during startup. */ if (do_not_restart || getenv ("MATE_PANEL_DEBUG")) mode = EGG_SM_CLIENT_MODE_NO_RESTART; else mode = EGG_SM_CLIENT_MODE_NORMAL; egg_sm_client_set_mode (mode); client = egg_sm_client_get (); g_signal_connect (client, "quit", G_CALLBACK (panel_session_handle_quit), NULL); /* We don't want the WM to try and save/restore our * window position */ gdk_set_sm_client_id (NULL); }
int main (int argc, char **argv) { /* imported from xfsm-manager.c */ extern gint shutdown_type; xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); /* install required signal handlers */ signal (SIGPIPE, SIG_IGN); gtk_init (&argc, &argv); /* fake a client id for the manager, so the legacy management does not * recognize us to be a session client. */ gdk_set_sm_client_id (xfsm_manager_generate_client_id (NULL)); initialize (argc, argv); xfsm_manager_restart (); gtk_main (); ice_cleanup (); return xfsm_shutdown (shutdown_type); }
void panel_session_init (void) { GnomeClient *client; /* We don't want the WM to try and save/restore our * window position */ gdk_set_sm_client_id (NULL); client = gnome_master_client (); if (!getenv ("GNOME_PANEL_DEBUG")) gnome_client_set_restart_style (client, GNOME_RESTART_IMMEDIATELY); gnome_client_set_priority (client, 40); g_signal_connect (client, "die", G_CALLBACK (panel_session_handle_die_request), NULL); }
void x_session_initialize (struct x_display_info *dpyinfo) { #define SM_ERRORSTRING_LEN 512 char errorstring[SM_ERRORSTRING_LEN]; char* previous_id = NULL; SmcCallbacks callbacks; int name_len = 0; ice_fd = -1; doing_interact = False; /* Check if we where started by the session manager. If so, we will have a previous id. */ if (! EQ (Vx_session_previous_id, Qnil) && STRINGP (Vx_session_previous_id)) previous_id = SSDATA (Vx_session_previous_id); /* Construct the path to the Emacs program. */ if (! EQ (Vinvocation_directory, Qnil)) name_len += strlen (SSDATA (Vinvocation_directory)); name_len += strlen (SSDATA (Vinvocation_name)); /* This malloc will not be freed, but it is only done once, and hopefully not very large */ emacs_program = xmalloc (name_len + 1); emacs_program[0] = '\0'; if (! EQ (Vinvocation_directory, Qnil)) strcpy (emacs_program, SSDATA (Vinvocation_directory)); strcat (emacs_program, SSDATA (Vinvocation_name)); /* The SM protocol says all callbacks are mandatory, so set up all here and in the mask passed to SmcOpenConnection. */ callbacks.save_yourself.callback = smc_save_yourself_CB; callbacks.save_yourself.client_data = 0; callbacks.die.callback = smc_die_CB; callbacks.die.client_data = 0; callbacks.save_complete.callback = smc_save_complete_CB; callbacks.save_complete.client_data = 0; callbacks.shutdown_cancelled.callback = smc_shutdown_cancelled_CB; callbacks.shutdown_cancelled.client_data = 0; /* Set error handlers. */ SmcSetErrorHandler (smc_error_handler); IceSetErrorHandler (ice_error_handler); IceSetIOErrorHandler (ice_io_error_handler); /* Install callback for when connection status changes. */ IceAddConnectionWatch (ice_conn_watch_CB, 0); /* Open the connection to the session manager. A failure is not critical, it usually means that no session manager is running. The errorstring is here for debugging. */ smc_conn = SmcOpenConnection (NULL, NULL, 1, 0, (SmcSaveYourselfProcMask| SmcDieProcMask| SmcSaveCompleteProcMask| SmcShutdownCancelledProcMask), &callbacks, previous_id, &client_id, SM_ERRORSTRING_LEN, errorstring); if (smc_conn != 0) { Vx_session_id = make_string (client_id, strlen (client_id)); #ifdef USE_GTK /* GTK creats a leader window by itself, but we need to tell it about our client_id. */ gdk_set_sm_client_id (client_id); #else create_client_leader_window (dpyinfo, client_id); #endif } }
static VALUE gdk_s_set_sm_client_id(VALUE self, VALUE id) { gdk_set_sm_client_id(NIL_P(id) ? NULL : RVAL2CSTR(id)); return self; }
gint main (gint argc, gchar **argv) { GObject *dialog, *plug_child; GtkWidget *plug; GtkBuilder *builder; GError *error = NULL; /* setup translation domain */ xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8"); /* initialize Gtk+ */ if(!gtk_init_with_args (&argc, &argv, "", entries, PACKAGE, &error)) { if (G_LIKELY (error)) { /* print error */ g_print ("%s: %s.\n", G_LOG_DOMAIN, error->message); g_print (_("Type '%s --help' for usage."), G_LOG_DOMAIN); g_print ("\n"); /* cleanup */ g_error_free (error); } else { g_error ("Unable to open display."); } return EXIT_FAILURE; } /* check if we should print version information */ if (G_UNLIKELY (opt_version)) { g_print ("%s %s (Xfce %s)\n\n", G_LOG_DOMAIN, PACKAGE_VERSION, xfce_version_string ()); g_print ("%s\n", "Copyright (c) 2008-2011"); g_print ("\t%s\n\n", _("The Xfce development team. All rights reserved.")); g_print (_("Please report bugs to <%s>."), PACKAGE_BUGREPORT); g_print ("\n"); return EXIT_SUCCESS; } /* initialize xfconf */ if (!xfconf_init (&error)) { /* print error and exit */ g_error ("Failed to connect to xfconf daemon: %s.", error->message); g_error_free (error); return EXIT_FAILURE; } /* open the channels */ accessibility_channel = xfconf_channel_new ("accessibility"); session_channel = xfconf_channel_new ("xfce4-session"); /* hook to make sure the libxfce4ui library is linked */ if (xfce_titled_dialog_get_type () == 0) return EXIT_FAILURE; /* load the Gtk user-interface file */ builder = gtk_builder_new (); if (gtk_builder_add_from_string (builder, accessibility_dialog_ui, accessibility_dialog_ui_length, &error) != 0) { /* Configure widgets */ accessibility_settings_dialog_configure_widgets (builder); if (G_UNLIKELY (opt_socket_id == 0)) { /* Get the dialog widget */ dialog = gtk_builder_get_object (builder, "dialog"); g_signal_connect (dialog, "response", G_CALLBACK (accessibility_settings_dialog_response), NULL); gtk_window_present (GTK_WINDOW (dialog)); /* To prevent the settings dialog to be saved in the session */ gdk_set_sm_client_id ("FAKE ID"); gtk_main (); } else { /* Create plug widget */ plug = gtk_plug_new (opt_socket_id); g_signal_connect (plug, "delete-event", G_CALLBACK (gtk_main_quit), NULL); gtk_widget_show (plug); /* Stop startup notification */ gdk_notify_startup_complete (); /* Get plug child widget */ plug_child = gtk_builder_get_object (builder, "plug-child"); gtk_widget_reparent (GTK_WIDGET (plug_child), plug); gtk_widget_show (GTK_WIDGET (plug_child)); /* To prevent the settings dialog to be saved in the session */ gdk_set_sm_client_id ("FAKE ID"); /* Enter main loop */ gtk_main (); } } else { g_error ("Failed to load the UI file: %s.", error->message); g_error_free (error); } /* Release Builder */ g_object_unref (G_OBJECT (builder)); /* release the channels */ g_object_unref (G_OBJECT (accessibility_channel)); g_object_unref (G_OBJECT (session_channel)); /* shutdown xfconf */ xfconf_shutdown(); return EXIT_SUCCESS; }
int main (int argc, gchar **argv) { GtkWidget *dialog; GtkWidget *plug; GtkWidget *plug_child; GtkBuilder *builder; GError *cli_error = NULL; const gchar *wm_name; #ifdef ENABLE_NLS xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8"); #endif if (!gtk_init_with_args (&argc, &argv, _ ("."), entries, PACKAGE, &cli_error)) { if (cli_error != NULL) { g_print (_ ("%s: %s\nTry %s --help to see a full list of available command line options.\n"), PACKAGE, cli_error->message, PACKAGE_NAME); g_error_free (cli_error); return 1; } } wm_name = gdk_x11_screen_get_window_manager_name (gdk_screen_get_default ()); if (G_UNLIKELY (g_ascii_strcasecmp (wm_name, "Xfwm4"))) { g_print ("These settings cannot work with your current window manager (%s)\n", wm_name); return 1; } if (opt_version) { g_print ("%s\n", PACKAGE_STRING); return 0; } xfconf_init (NULL); builder = gtk_builder_new (); if (xfce_titled_dialog_get_type () == 0) return 1; gtk_builder_add_from_string (builder, tweaks_dialog_ui, tweaks_dialog_ui_length, NULL); if (builder) { wm_tweaks_dialog_configure_widgets (builder); if (opt_socket_id == 0) { dialog = GTK_WIDGET (gtk_builder_get_object (builder, "main-dialog")); gtk_widget_show (dialog); g_signal_connect (dialog, "response", G_CALLBACK (wm_tweaks_dialog_response), NULL); /* To prevent the settings dialog to be saved in the session */ gdk_set_sm_client_id ("FAKE ID"); gtk_main (); gtk_widget_destroy (dialog); } else { /* Create plug widget */ plug = gtk_plug_new (opt_socket_id); g_signal_connect (plug, "delete-event", G_CALLBACK (gtk_main_quit), NULL); gtk_widget_show (plug); /* Get plug child widget */ plug_child = GTK_WIDGET (gtk_builder_get_object (builder, "plug-child")); gtk_widget_reparent (plug_child, plug); gtk_widget_show (plug_child); /* To prevent the settings dialog to be saved in the session */ gdk_set_sm_client_id ("FAKE ID"); /* Stop startup notification */ gdk_notify_startup_complete (); /* Enter main loop */ gtk_main (); } g_object_unref (builder); } xfconf_shutdown (); return 0; }
int main(int argc, char **argv) { GtkBuilder *builder; GtkWidget *notebook, *xfae_page, *lbl; GError *error = NULL; XfconfChannel *channel; xfce_textdomain(GETTEXT_PACKAGE, LOCALEDIR, "UTF-8"); if(!gtk_init_with_args (&argc, &argv, "", option_entries, GETTEXT_PACKAGE, &error)) { if(G_LIKELY(error)) { g_print("%s: %s.\n", G_LOG_DOMAIN, error->message); g_print(_("Type '%s --help' for usage."), G_LOG_DOMAIN); g_print("\n"); g_error_free (error); } else g_error("Unable to open display."); return EXIT_FAILURE; } if(G_UNLIKELY(opt_version)) { g_print("%s %s (Xfce %s)\n\n", G_LOG_DOMAIN, PACKAGE_VERSION, xfce_version_string ()); g_print("%s\n", "Copyright (c) 2004-2014"); g_print("\t%s\n\n", _("The Xfce development team. All rights reserved.")); g_print(_("Please report bugs to <%s>."), PACKAGE_BUGREPORT); g_print("\n"); return EXIT_SUCCESS; } if(G_UNLIKELY(!xfconf_init(&error))) { xfce_dialog_show_error (NULL, error, _("Unable to contact settings server")); g_error_free(error); return EXIT_FAILURE; } gtk_window_set_default_icon_name("xfce4-session"); /* hook to make sure the libxfce4ui library is linked */ if (xfce_titled_dialog_get_type() == 0) return EXIT_FAILURE; builder = gtk_builder_new(); gtk_builder_add_from_string(builder, xfce4_session_settings_ui, xfce4_session_settings_ui_length, &error); if(!builder) { xfce_dialog_show_error(NULL, error, _("Unable to create user interface from embedded definition data")); g_error_free (error); return EXIT_FAILURE; } splash_settings_init(builder); session_editor_init(builder); /* FIXME: someday, glade-ify this, maybe. */ xfae_page = xfae_window_new(); gtk_widget_show(xfae_page); notebook = GTK_WIDGET(gtk_builder_get_object(builder, "plug-child")); lbl = gtk_label_new_with_mnemonic(_("App_lication Autostart")); gtk_widget_show(lbl); gtk_notebook_insert_page(GTK_NOTEBOOK(notebook), xfae_page, lbl, 2); channel = xfconf_channel_get(SETTINGS_CHANNEL); /* bind widgets to xfconf */ xfconf_g_property_bind(channel, "/chooser/AlwaysDisplay", G_TYPE_BOOLEAN, gtk_builder_get_object(builder, "chk_display_chooser"), "active"); xfconf_g_property_bind(channel, "/general/AutoSave", G_TYPE_BOOLEAN, gtk_builder_get_object(builder, "chk_session_autosave"), "active"); xfconf_g_property_bind(channel, "/general/PromptOnLogout", G_TYPE_BOOLEAN, gtk_builder_get_object(builder, "chk_logout_prompt"), "active"); xfconf_g_property_bind(channel, "/compat/LaunchGNOME", G_TYPE_BOOLEAN, gtk_builder_get_object(builder, "chk_compat_gnome"), "active"); xfconf_g_property_bind(channel, "/compat/LaunchKDE", G_TYPE_BOOLEAN, gtk_builder_get_object(builder, "chk_compat_kde"), "active"); xfconf_g_property_bind(channel, "/security/EnableTcp", G_TYPE_BOOLEAN, gtk_builder_get_object(builder, "chk_enable_tcp"), "active"); xfconf_g_property_bind(channel, "/shutdown/LockScreen", G_TYPE_BOOLEAN, gtk_builder_get_object(builder, "chk_lock_screen"), "active"); if(G_UNLIKELY(opt_socket_id == 0)) { GtkWidget *dialog = GTK_WIDGET(gtk_builder_get_object(builder, "xfce4_session_settings_dialog")); g_signal_connect(dialog, "response", G_CALLBACK(xfce4_session_settings_dialog_response), NULL); g_signal_connect(dialog, "delete-event", G_CALLBACK(gtk_main_quit), NULL); gtk_widget_show(dialog); /* To prevent the settings dialog to be saved in the session */ gdk_set_sm_client_id ("FAKE ID"); gtk_main(); } else { GtkWidget *plug, *plug_child; plug = gtk_plug_new(opt_socket_id); gtk_widget_show(plug); g_signal_connect(plug, "delete-event", G_CALLBACK(gtk_main_quit), NULL); plug_child = GTK_WIDGET(gtk_builder_get_object(builder, "plug-child")); gtk_widget_reparent(plug_child, plug); gtk_widget_show(plug_child); /* Stop startup notification */ gdk_notify_startup_complete(); gtk_main(); } g_object_unref(builder); return EXIT_SUCCESS; }