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; }
static void places_cfg_finalize (GObject *object) { PlacesCfg *cfg = XFCE_PLACES_CFG (object); DBG("PlacesCfg finalize called"); if(cfg->label != NULL) g_free(cfg->label); if(cfg->server_connect_cmd != NULL) g_free(cfg->server_connect_cmd); if(cfg->network_cmd != NULL) g_free(cfg->network_cmd); if(cfg->search_cmd != NULL) g_free(cfg->search_cmd); xfconf_shutdown(); G_OBJECT_CLASS (places_cfg_parent_class)->finalize (object); }
/* Dispose this object */ static void _xfdashboard_application_dispose(GObject *inObject) { XfdashboardApplication *self=XFDASHBOARD_APPLICATION(inObject); XfdashboardApplicationPrivate *priv=self->priv; /* Ensure "is-quitting" flag is set just in case someone asks */ priv->isQuitting=TRUE; /* Signal "shutdown-final" of application */ g_signal_emit(self, XfdashboardApplicationSignals[SIGNAL_SHUTDOWN_FINAL], 0); /* Release allocated resources */ if(priv->xfconfThemeChangedSignalID) { xfconf_g_property_unbind(priv->xfconfThemeChangedSignalID); priv->xfconfThemeChangedSignalID=0L; } if(priv->theme) { g_object_unref(priv->theme); priv->theme=NULL; } if(priv->themeName) { g_free(priv->themeName); priv->themeName=NULL; } if(priv->viewManager) { /* Unregisters all remaining registered views - no need to unregister them here */ g_object_unref(priv->viewManager); priv->viewManager=NULL; } if(priv->searchManager) { /* Unregisters all remaining registered providers - no need to unregister them here */ g_object_unref(priv->searchManager); priv->searchManager=NULL; } if(priv->focusManager) { /* Unregisters all remaining registered focusable actors. * There is no need to unregister them here. */ g_object_unref(priv->focusManager); priv->focusManager=NULL; } if(priv->bindings) { g_object_unref(priv->bindings); priv->bindings=NULL; } if(priv->appDatabase) { g_object_unref(priv->appDatabase); priv->appDatabase=NULL; } if(priv->appTracker) { g_object_unref(priv->appTracker); priv->appTracker=NULL; } /* Shutdown session management */ if(priv->sessionManagementClient) { priv->sessionManagementClient=NULL; } /* Shutdown xfconf */ priv->xfconfChannel=NULL; xfconf_shutdown(); /* Unset singleton */ if(G_LIKELY(G_OBJECT(application)==inObject)) application=NULL; /* Call parent's class dispose method */ G_OBJECT_CLASS(xfdashboard_application_parent_class)->dispose(inObject); }
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) { 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; }