int main (int argc, char **argv) { GtkWidget *dialog; GError *error = NULL; /* setup translation domain */ xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); /* setup application name */ g_set_application_name (_("Thunar Volume Manager Settings")); #ifdef G_ENABLE_DEBUG /* Do NOT remove this line for now. If something doesn't work, fix your code instead */ g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING); #endif /* initialize the threading system */ if (!g_thread_supported ()) g_thread_init (NULL); /* initialize GTK+ */ if (!gtk_init_with_args (&argc, &argv, NULL, NULL, GETTEXT_PACKAGE, &error)) { g_fprintf (stderr, "%s: %s.\n", g_get_prgname (), error->message); g_error_free (error); return EXIT_FAILURE; } /* initialize xfconf */ if (!xfconf_init (&error)) { g_fprintf (stderr, "%s: %s.\n", g_get_prgname (), error->message); g_error_free (error); return EXIT_FAILURE; } /* display the dialog */ dialog = tvm_preferences_dialog_new (); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); /* free xfconf resources */ xfconf_shutdown (); return EXIT_SUCCESS; }
XfconfChannel * wck_properties_get_channel (GObject *object_for_weak_ref, const gchar *channel_name) { GError *error = NULL; XfconfChannel *channel; g_return_val_if_fail (G_IS_OBJECT (object_for_weak_ref), NULL); if (!xfconf_init (&error)) { g_critical ("Failed to initialize Xfconf: %s", error->message); g_error_free (error); return NULL; } //~ channel = xfconf_channel_get (XFCE_PANEL_CHANNEL_NAME); channel = xfconf_channel_get (channel_name); g_object_weak_ref (object_for_weak_ref, (GWeakNotify) xfconf_shutdown, NULL); return channel; }
/* Perform full initialization of this application instance */ static gboolean _xfdashboard_application_initialize_full(XfdashboardApplication *self, XfdashboardStage **outStage) { XfdashboardApplicationPrivate *priv; GError *error; ClutterActor *stage; #if !GARCON_CHECK_VERSION(0,3,0) const gchar *desktop; #endif g_return_val_if_fail(XFDASHBOARD_IS_APPLICATION(self), FALSE); g_return_val_if_fail(outStage==NULL || *outStage==NULL, FALSE); priv=self->priv; error=NULL; /* Initialize garcon for current desktop environment */ #if !GARCON_CHECK_VERSION(0,3,0) desktop=g_getenv("XDG_CURRENT_DESKTOP"); if(G_LIKELY(desktop==NULL)) { /* If we could not determine current desktop environment * assume Xfce as this application is developed for this DE. */ desktop="XFCE"; } /* If desktop enviroment was found but has no name * set NULL to get all menu items shown. */ else if(*desktop==0) desktop=NULL; garcon_set_environment(desktop); #else garcon_set_environment_xdg(GARCON_ENVIRONMENT_XFCE); #endif /* Setup the session management */ priv->sessionManagementClient=xfce_sm_client_get(); xfce_sm_client_set_priority(priv->sessionManagementClient, XFCE_SM_CLIENT_PRIORITY_DEFAULT); xfce_sm_client_set_restart_style(priv->sessionManagementClient, XFCE_SM_CLIENT_RESTART_IMMEDIATELY); g_signal_connect_swapped(priv->sessionManagementClient, "quit", G_CALLBACK(_xfdashboard_application_on_session_quit), self); if(!xfce_sm_client_connect(priv->sessionManagementClient, &error)) { g_warning("Failed to connect to session manager: %s", (error && error->message) ? error->message : _("unknown error")); g_clear_error(&error); } /* Initialize xfconf */ if(!xfconf_init(&error)) { g_critical(_("Could not initialize xfconf: %s"), (error && error->message) ? error->message : _("unknown error")); if(error) g_error_free(error); return(FALSE); } priv->xfconfChannel=xfconf_channel_get(XFDASHBOARD_XFCONF_CHANNEL); /* Set up keyboard and pointer bindings */ priv->bindings=xfdashboard_bindings_pool_get_default(); if(!priv->bindings) { g_critical(_("Could not initialize bindings")); return(FALSE); } if(!xfdashboard_bindings_pool_load(priv->bindings, &error)) { g_critical(_("Could not load bindings: %s"), (error && error->message) ? error->message : _("unknown error")); if(error!=NULL) g_error_free(error); return(FALSE); } /* Set up application database */ priv->appDatabase=xfdashboard_application_database_get_default(); if(!priv->appDatabase) { g_critical(_("Could not initialize application database")); return(FALSE); } if(!xfdashboard_application_database_load(priv->appDatabase, &error)) { g_critical(_("Could not load application database: %s"), (error && error->message) ? error->message : _("unknown error")); if(error!=NULL) g_error_free(error); return(FALSE); } /* Set up application tracker */ priv->appTracker=xfdashboard_application_tracker_get_default(); if(!priv->appTracker) { g_critical(_("Could not initialize application tracker")); return(FALSE); } /* Set up and load theme */ priv->xfconfThemeChangedSignalID=xfconf_g_property_bind(priv->xfconfChannel, THEME_NAME_XFCONF_PROP, G_TYPE_STRING, self, "theme-name"); if(!priv->xfconfThemeChangedSignalID) { g_warning(_("Could not create binding between xfconf property and local resource for theme change notification.")); } /* Set up default theme in Xfcond if property in channel does not exist * because it indicates first start. */ if(!xfconf_channel_has_property(priv->xfconfChannel, THEME_NAME_XFCONF_PROP)) { xfconf_channel_set_string(priv->xfconfChannel, THEME_NAME_XFCONF_PROP, DEFAULT_THEME_NAME); } /* At this time the theme must have been loaded, either because we * set the default theme name because of missing theme property in * xfconf channel or the value of xfconf channel property has been read * and set when setting up binding (between xfconf property and local property) * what caused a call to function to set theme name in this object * and also caused a reload of theme. * So if no theme object is set in this object then loading theme has * failed and we have to return FALSE. */ if(!priv->theme) return(FALSE); /* Register built-in views (order of registration is important) */ priv->viewManager=xfdashboard_view_manager_get_default(); xfdashboard_view_manager_register(priv->viewManager, XFDASHBOARD_TYPE_WINDOWS_VIEW); xfdashboard_view_manager_register(priv->viewManager, XFDASHBOARD_TYPE_APPLICATIONS_VIEW); xfdashboard_view_manager_register(priv->viewManager, XFDASHBOARD_TYPE_SEARCH_VIEW); /* Register built-in search providers */ priv->searchManager=xfdashboard_search_manager_get_default(); xfdashboard_search_manager_register(priv->searchManager, XFDASHBOARD_TYPE_APPLICATIONS_SEARCH_PROVIDER); /* Create single-instance of focus manager to keep it alive while * application is running. */ priv->focusManager=xfdashboard_focus_manager_get_default(); /* Create stage containing all monitors */ stage=xfdashboard_stage_new(); g_signal_connect_swapped(stage, "delete-event", G_CALLBACK(_xfdashboard_application_on_delete_stage), self); /* Emit signal 'theme-changed' to get current theme loaded at each stage created */ g_signal_emit(self, XfdashboardApplicationSignals[SIGNAL_THEME_CHANGED], 0, priv->theme); /* Set return results */ if(outStage) *outStage=XFDASHBOARD_STAGE(stage); /* Initialization was successful so return TRUE */ #ifdef DEBUG xfdashboard_notify(NULL, NULL, _("Welcome to %s (%s)!"), PACKAGE_NAME, PACKAGE_VERSION); #else xfdashboard_notify(NULL, NULL, _("Welcome to %s!"), PACKAGE_NAME); #endif return(TRUE); }
gint main (gint argc, gchar **argv) { GError *error = NULL; GtkWidget *dialog; GtkWidget *button; gint result; gint retval = EXIT_SUCCESS; gint default_response = GTK_RESPONSE_CANCEL; XfconfChannel *channel; gint configver; gchar *filename_46; gchar *filename_default; gboolean migrate_vendor_default; /* set translation domain */ lde_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); #ifndef NDEBUG /* terminate the program on warnings and critical messages */ g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING); #endif gtk_init (&argc, &argv); if (!xfconf_init (&error)) { g_critical ("Failed to initialize Xfconf: %s", error->message); g_error_free (error); return EXIT_FAILURE; } channel = xfconf_channel_get (LDE_PANEL_CHANNEL_NAME); if (!xfconf_channel_has_property (channel, "/panels")) { /* lookup the old 4.6 config file */ filename_46 = lde_resource_lookup (LDE_RESOURCE_CONFIG, LDE_46_CONFIG); /* lookup the default configuration */ lde_resource_push_path (LDE_RESOURCE_CONFIG, XDGCONFIGDIR); filename_default = lde_resource_lookup (LDE_RESOURCE_CONFIG, DEFAULT_CONFIG_FILENAME); lde_resource_pop_path (LDE_RESOURCE_CONFIG); if (filename_46 == NULL && filename_default == NULL) { g_warning ("No default or old configuration found"); return EXIT_FAILURE; } /* if the default configuration does not match with the file found * by the resource lookup, migrate it without asking */ migrate_vendor_default = (g_strcmp0 (DEFAULT_CONFIG_PATH, filename_default) != 0); /* check if we auto-migrate the default configuration */ if (g_getenv ("LDE_PANEL_MIGRATE_DEFAULT") != NULL || migrate_vendor_default) { if (filename_46 != NULL) g_message ("Tried to auto-migrate, but old configuration found"); else if (filename_default == NULL) g_message ("Tried to auto-migrate, but no default configuration found"); else goto migrate_default; } /* create question dialog */ dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, _("Welcome to the first start of the panel")); gtk_window_set_title (GTK_WINDOW (dialog), _("Panel")); gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_PREFERENCES); gtk_window_stick (GTK_WINDOW (dialog)); gtk_window_set_keep_above (GTK_WINDOW (dialog), TRUE); if (filename_46 != NULL) { gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s\n%s", _("Because the panel moved to a new system for storing the " "settings, it has to load a fresh initial configuration."), _("Choose below which setup you want for the first startup.")); button = gtk_dialog_add_button (GTK_DIALOG (dialog), _("Migrate old config"), GTK_RESPONSE_OK); gtk_widget_set_tooltip_text (button, _("Migrate the old 4.6 configuration to Xfconf")); default_response = GTK_RESPONSE_OK; } else { gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), _("Choose below which setup you want for the first startup.")); } if (filename_default != NULL) { button = gtk_dialog_add_button (GTK_DIALOG (dialog), _("Use default config"), GTK_RESPONSE_YES); gtk_widget_set_tooltip_text (button, _("Load the default configuration")); if (default_response == GTK_RESPONSE_CANCEL) default_response = GTK_RESPONSE_YES; } button = gtk_dialog_add_button (GTK_DIALOG (dialog), _("One empty panel"), GTK_RESPONSE_CANCEL); gtk_widget_set_tooltip_text (button, _("Start with one empty panel")); gtk_dialog_set_default_response (GTK_DIALOG (dialog), default_response); result = gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); if (result == GTK_RESPONSE_OK && filename_46 != NULL) { /* restore 4.6 config */ if (!migrate_46 (filename_46, channel, &error)) { lde_dialog_show_error (NULL, error, _("Failed to migrate the old panel configuration")); g_error_free (error); retval = EXIT_FAILURE; } } else if (result == GTK_RESPONSE_YES && filename_default != NULL) { migrate_default: /* apply default config */ if (!migrate_default (filename_default, &error)) { lde_dialog_show_error (NULL, error, _("Failed to load the default configuration")); g_error_free (error); retval = EXIT_FAILURE; } } g_free (filename_46); g_free (filename_default); } configver = xfconf_channel_get_int (channel, "/configver", -1); if (configver < LDE4_PANEL_CONFIG_VERSION) { g_message (_("Panel config needs migration...")); if (!migrate_config (channel, configver, &error)) { lde_dialog_show_error (NULL, error, _("Failed to migrate the existing configuration")); g_error_free (error); retval = EXIT_FAILURE; } else { g_message (_("Panel configuration has been updated.")); } /* migration complete, set new version */ xfconf_channel_set_int (channel, "/configver", LDE4_PANEL_CONFIG_VERSION); } xfconf_shutdown (); return retval; }
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; }
gint main(gint argc, gchar **argv) { GtkWidget *dialog; GtkWidget *settings_editor; GtkWidget *plug; GError *error = NULL; /* setup translation domain */ xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8"); /* initialize Gtk+ */ if (!gtk_init_with_args (&argc, &argv, "", option_entries, GETTEXT_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; } /* 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 (G_UNLIKELY (!xfconf_init (&error))) { /* print error and leave */ g_critical ("Failed to connect to Xfconf daemon: %s", error->message); g_error_free (error); return EXIT_FAILURE; } channel = xfconf_channel_new ("xfce4-settings-editor"); settings_editor = xfce_settings_editor_box_new ( xfconf_channel_get_int (channel, "/last/paned-position", 180)); if (G_UNLIKELY (opt_socket_id == 0)) { dialog = xfce_titled_dialog_new_with_buttons (_("Settings Editor"), NULL, GTK_DIALOG_DESTROY_WITH_PARENT, "gtk-help", GTK_RESPONSE_HELP, "gtk-close", GTK_RESPONSE_OK, NULL); xfce_titled_dialog_set_subtitle (XFCE_TITLED_DIALOG (dialog), _("Customize settings stored by Xfconf")); gtk_window_set_icon_name (GTK_WINDOW (dialog), "preferences-system"); gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_NORMAL); gtk_window_set_default_size (GTK_WINDOW (dialog), xfconf_channel_get_int (channel, "/last/window-width", 640), xfconf_channel_get_int (channel, "/last/window-height", 500)); gtk_container_add_with_properties( GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), settings_editor, "expand", TRUE, "fill", TRUE, NULL); g_signal_connect (dialog, "response", G_CALLBACK (settings_dialog_response), settings_editor); gtk_widget_show_all (dialog); } else { /* Create plug widget */ plug = gtk_plug_new (opt_socket_id); g_signal_connect (plug, "delete-event", G_CALLBACK (plug_delete_event), settings_editor); gtk_window_set_default_size (GTK_WINDOW (plug), xfconf_channel_get_int (channel, "/last/window-width", 640), xfconf_channel_get_int (channel, "/last/window-height", 500)); gtk_widget_show (plug); gtk_container_add (GTK_CONTAINER(plug), settings_editor); /* Stop startup notification */ gdk_notify_startup_complete (); gtk_widget_show (GTK_WIDGET (settings_editor)); } gtk_main (); g_object_unref(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) { ThunarSessionClient *session_client; #ifdef HAVE_DBUS ThunarDBusService *dbus_service = NULL; #endif ThunarApplication *application; GError *error = NULL; gchar *working_directory; gchar **filenames = NULL; const gchar *startup_id; /* setup translation domain */ xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); /* setup application name */ g_set_application_name (_("Thunar")); #ifdef G_ENABLE_DEBUG /* Do NOT remove this line for now, If something doesn't work, * fix your code instead! */ g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING); #endif #if !GLIB_CHECK_VERSION (2, 32, 0) /* initialize the GThread system */ if (!g_thread_supported ()) g_thread_init (NULL); #endif /* get the startup notification id */ startup_id = g_getenv ("DESKTOP_STARTUP_ID"); /* initialize Gtk+ */ if (!gtk_init_with_args (&argc, &argv, _("[FILES...]"), option_entries, GETTEXT_PACKAGE, &error)) { /* check if we have an error message */ if (G_LIKELY (error == NULL)) { /* no error message, the GUI initialization failed */ const gchar *display_name = gdk_get_display_arg_name (); g_printerr (_("Thunar: Failed to open display: %s\n"), (display_name != NULL) ? display_name : " "); } else { /* yep, there's an error, so print it */ g_printerr (_("Thunar: %s\n"), error->message); g_error_free (error); } return EXIT_FAILURE; } /* check if we should print version information */ if (G_UNLIKELY (opt_version)) { g_print ("%s %s (Xfce %s)\n\n", PACKAGE_NAME, PACKAGE_VERSION, xfce_version_string ()); g_print ("%s\n", "Copyright (c) 2004-2012"); g_print ("\t%s\n\n", _("The Thunar development team. All rights reserved.")); g_print ("%s\n\n", _("Written by Benedikt Meurer <*****@*****.**>.")); g_print (_("Please report bugs to <%s>."), PACKAGE_BUGREPORT); g_print ("\n"); return EXIT_SUCCESS; } /* initialize xfconf */ if (!xfconf_init (&error)) { g_printerr (PACKAGE_NAME ": Failed to initialize Xfconf: %s\n\n", error->message); g_clear_error (&error); /* disable get/set properties */ thunar_preferences_xfconf_init_failed (); } #ifdef HAVE_GIO_UNIX /* set desktop environment for app infos */ g_desktop_app_info_set_desktop_env ("XFCE"); #endif /* register additional transformation functions */ thunar_g_initialize_transformations (); #ifdef HAVE_DBUS /* check if we should terminate a running Thunar instance */ if (G_UNLIKELY (opt_quit)) { /* try to terminate whatever is running */ if (!thunar_dbus_client_terminate (&error)) { g_printerr ("Thunar: Failed to terminate running instance: %s\n", error->message); g_error_free (error); return EXIT_FAILURE; } return EXIT_SUCCESS; } #endif /* determine the current working directory */ working_directory = g_get_current_dir (); /* check if atleast one filename was specified, else * fall back to opening the current working directory * if daemon mode is not requested. */ if (G_LIKELY (argc > 1)) { /* use the specified filenames */ filenames = g_strdupv (argv + 1); } else if (opt_bulk_rename) { /* default to an empty list */ filenames = g_new (gchar *, 1); filenames[0] = NULL; } else if (!opt_daemon)
int main (int argc, char **argv) { GtkWidget *window; GError *error = NULL; /* Setup translation domain */ xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); /* Initialize the threading system */ if (G_LIKELY (!g_thread_supported ())) g_thread_init (NULL); /* Set debug level */ #ifdef G_ENABLE_DEBUG g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING); #endif /* Set application name */ g_set_application_name (_("Mixer")); /* Initialize GTK+ */ gtk_init (&argc, &argv); /* Initialize Xfconf */ if (G_UNLIKELY (!xfconf_init (&error))) { if (G_LIKELY (error != NULL)) { g_print (_("Failed to initialize xfconf: %s"), error->message); g_error_free (error); } return EXIT_FAILURE; } /* Initialize GStreamer */ gst_init (&argc, &argv); /* Initialize the mixer library */ xfce_mixer_init (); /* Use volume control icon for all mixer windows */ gtk_window_set_default_icon_name ("multimedia-volume-control"); /* Warn users if there were no sound cards detected by GStreamer */ if (G_UNLIKELY (g_list_length (xfce_mixer_get_cards ()) <= 0)) { GtkWidget *dlg = gtk_dialog_new_with_buttons (_("No ALSA Devices Found"), NULL, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, 0, NULL); GtkWidget *label = gtk_label_new (_("No ALSA audio devices were detected. Enable the internal audio device, or connect a USB or HAT audio device.")); gtk_container_set_border_width (GTK_CONTAINER (dlg), 10); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))), label, TRUE, TRUE, 0); gtk_widget_show_all (dlg); gtk_dialog_run (GTK_DIALOG (dlg)); return EXIT_FAILURE; } /* Create the mixer window */ window = xfce_mixer_window_new (); /* Display the mixer window */ gtk_widget_show (window); g_bus_watch_name (G_BUS_TYPE_SESSION, "org.lxde.volumealsa", 0, volumealsa_device_changed, NULL, window, NULL); /* Enter the GTK+ main loop */ gtk_main (); /* Destroy the window */ gtk_widget_destroy (window); /* Shutdown the mixer library */ xfce_mixer_shutdown (); /* Shutdown Xfconf */ xfconf_shutdown (); return EXIT_SUCCESS; }
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; }
PlacesCfg* places_cfg_new(XfcePanelPlugin *plugin) { PlacesCfg *cfg; XfconfChannel *channel; gchar *property; cfg = g_object_new (XFCE_TYPE_PLACES_CFG, NULL); cfg->plugin = plugin; xfconf_init(NULL); channel = xfconf_channel_get ("xfce4-panel"); property = g_strconcat (xfce_panel_plugin_get_property_base (plugin), "/show-button-type", NULL); xfconf_g_property_bind (channel, property, G_TYPE_INT, cfg, "show-button-type"); g_free (property); property = g_strconcat (xfce_panel_plugin_get_property_base (plugin), "/button-label", NULL); xfconf_g_property_bind (channel, property, G_TYPE_STRING, cfg, "button-label"); g_free (property); property = g_strconcat (xfce_panel_plugin_get_property_base (plugin), "/show-icons", NULL); xfconf_g_property_bind (channel, property, G_TYPE_BOOLEAN, cfg, "show-icons"); g_free (property); property = g_strconcat (xfce_panel_plugin_get_property_base (plugin), "/show-volumes", NULL); xfconf_g_property_bind (channel, property, G_TYPE_BOOLEAN, cfg, "show-volumes"); g_free (property); property = g_strconcat (xfce_panel_plugin_get_property_base (plugin), "/mount-open-volumes", NULL); xfconf_g_property_bind (channel, property, G_TYPE_BOOLEAN, cfg, "mount-open-volumes"); g_free (property); property = g_strconcat (xfce_panel_plugin_get_property_base (plugin), "/show-bookmarks", NULL); xfconf_g_property_bind (channel, property, G_TYPE_BOOLEAN, cfg, "show-bookmarks"); g_free (property); property = g_strconcat (xfce_panel_plugin_get_property_base (plugin), "/server-connect-cmd", NULL); xfconf_g_property_bind (channel, property, G_TYPE_STRING, cfg, "server-connect-cmd"); g_free (property); property = g_strconcat (xfce_panel_plugin_get_property_base (plugin), "/network-cmd", NULL); xfconf_g_property_bind (channel, property, G_TYPE_STRING, cfg, "network-cmd"); g_free (property); property = g_strconcat (xfce_panel_plugin_get_property_base (plugin), "/show-recent", NULL); xfconf_g_property_bind (channel, property, G_TYPE_BOOLEAN, cfg, "show-recent"); g_free (property); property = g_strconcat (xfce_panel_plugin_get_property_base (plugin), "/show-recent-clear", NULL); xfconf_g_property_bind (channel, property, G_TYPE_BOOLEAN, cfg, "show-recent-clear"); g_free (property); property = g_strconcat (xfce_panel_plugin_get_property_base (plugin), "/show-recent-number", NULL); xfconf_g_property_bind (channel, property, G_TYPE_INT, cfg, "show-recent-number"); g_free (property); property = g_strconcat (xfce_panel_plugin_get_property_base (plugin), "/search-cmd", NULL); xfconf_g_property_bind (channel, property, G_TYPE_STRING, cfg, "search-cmd"); g_free (property); g_signal_connect_swapped(G_OBJECT(plugin), "configure-plugin", G_CALLBACK(places_cfg_open_dialog), cfg); xfce_panel_plugin_menu_show_configure(plugin); return cfg; }
int main (int argc, char **argv) { GtkWidget *dialog; XfpmUnique *unique; GError *error = NULL; DBusGConnection *bus; GHashTable *config_hash; gboolean has_battery; gboolean auth_suspend; gboolean auth_hibernate; gboolean can_suspend; gboolean can_hibernate; gboolean can_shutdown; gboolean has_lcd_brightness; gboolean has_sleep_button; gboolean has_hibernate_button; gboolean has_power_button; gboolean has_lid; gboolean start_xfpm_if_not_running; gboolean debug = FALSE; GdkNativeWindow socket_id = 0; gchar *device_id = NULL; XfconfChannel *channel; DBusGProxy *proxy; GOptionEntry option_entries[] = { { "socket-id", 's', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_INT, &socket_id, N_("Settings manager socket"), N_("SOCKET ID") }, { "device-id", 'd', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING, &device_id, N_("Display a specific device by UpDevice object path"), N_("UpDevice object path") }, { "debug", '\0', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &debug, N_("Enable debugging"), NULL }, { NULL, }, }; xfce_textdomain(GETTEXT_PACKAGE, LOCALEDIR, "UTF-8"); if( !gtk_init_with_args (&argc, &argv, (gchar *)"", option_entries, (gchar *)PACKAGE, &error)) { if( error) { g_printerr("%s: %s.\n", G_LOG_DOMAIN, error->message); g_printerr(_("Type '%s --help' for usage."), G_LOG_DOMAIN); g_printerr("\n"); g_error_free(error); } else { g_error("Unable to open display."); } return EXIT_FAILURE; } bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); if ( error ) { g_error ("%s\n",error->message); } while ( !xfpm_dbus_name_has_owner (dbus_g_connection_get_connection(bus), "org.xfce.PowerManager") ) { g_print(_("Xfce power manager is not running")); g_print("\n"); start_xfpm_if_not_running = xfce_dialog_confirm (NULL, GTK_STOCK_EXECUTE, _("Run"), NULL, _("Xfce4 Power Manager is not running, do you want to launch it now?")); if ( start_xfpm_if_not_running ) { g_spawn_command_line_async("xfce4-power-manager",NULL); /* wait 2 seconds for xfpm to startup */ g_usleep ( 2 * 1000000 ); } else { /* continue without starting xfpm, this will probably error out */ break; } } unique = xfpm_unique_new ("org.xfce.PowerManager.Config"); if ( !xfpm_unique_app_is_running (unique) ) { if ( !xfconf_init(&error) ) { g_critical("xfconf init failed: %s using default settings\n", error->message); xfce_dialog_show_warning (NULL, _("Xfce Power Manager"), "%s", _("Failed to load power manager configuration, using defaults")); g_error_free (error); error = NULL; return EXIT_FAILURE; } #if !GLIB_CHECK_VERSION (2, 32, 0) if ( !g_thread_supported () ) g_thread_init (NULL); #endif dbus_g_thread_init (); channel = xfconf_channel_new(XFPM_CHANNEL_CFG); proxy = dbus_g_proxy_new_for_name(bus, "org.xfce.PowerManager", "/org/xfce/PowerManager", "org.xfce.Power.Manager"); xfpm_manager_dbus_client_get_config (proxy, &config_hash, &error); if ( error ) { g_critical ("Unable to get configuration information from xfce power manager: %s", error->message); xfce_dialog_show_error (NULL, error, "%s", _("Unable to connect to Xfce Power Manager")); g_error_free (error); return EXIT_FAILURE; } xfpm_debug_init (debug); has_battery = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "has-battery")); has_lid = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "has-lid")); can_suspend = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "can-suspend")); can_hibernate = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "can-hibernate")); auth_suspend = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "auth-suspend")); auth_hibernate = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "auth-hibernate")); has_lcd_brightness = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "has-brightness")); has_sleep_button = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "sleep-button")); has_power_button = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "power-button")); has_hibernate_button = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "hibernate-button")); can_shutdown = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "can-shutdown")); g_hash_table_destroy (config_hash); dialog = xfpm_settings_dialog_new (channel, auth_suspend, auth_hibernate, can_suspend, can_hibernate, can_shutdown, has_battery, has_lcd_brightness, has_lid, has_sleep_button, has_hibernate_button, has_power_button, socket_id, device_id); g_signal_connect_swapped (unique, "ping-received", G_CALLBACK (gtk_window_present), dialog); gtk_main(); xfpm_dbus_release_name(dbus_g_connection_get_connection(bus), "org.xfce.PowerManager.Config"); dbus_g_connection_unref (bus); g_object_unref (proxy); g_object_unref (unique); return EXIT_SUCCESS; } return EXIT_SUCCESS; }