static void compute_supported_archive_types (void) { int i, j; int s_i = 0; for (i = 0; i < G_N_ELEMENTS (command_desc); i++) { FRCommandDescription com = command_desc[i]; if (!is_program_in_path (com.command)) continue; if (strcmp (com.command, "tar") == 0) for (j = 0; j < G_N_ELEMENTS (tar_command_desc); j++) { FRCommandDescription com2 = tar_command_desc[j]; if (!is_program_in_path (com2.command)) continue; save_type[s_i++] = com2.file_type; } if (com.can_save && com.support_many_files) save_type[s_i++] = com.file_type; } save_type[s_i++] = FR_FILE_TYPE_NULL; }
static void maybe_lock_screen (void) { gboolean use_xscreensaver = FALSE; gboolean call_multiple_screensaver = FALSE; GError *error = NULL; char *command; GdkScreen *screen; screen = gdk_screen_get_default (); if (is_program_in_path ("gnome-screensaver-command") || is_program_in_path ("mate-screensaver-command")) { command = g_strdup ("gnome-screensaver-command --lock || mate-screensaver-command --lock"); call_multiple_screensaver = TRUE; } if (is_program_in_path ("gnome-screensaver-command")) { command = g_strdup ("gnome-screensaver-command --lock"); } else if (is_program_in_path ("mate-screensaver-command")) { command = g_strdup ("mate-screensaver-command --lock"); } else if (is_program_in_path ("xscreensaver-command")) { command = g_strdup ("xscreensaver-command -lock"); use_xscreensaver = TRUE; } else if( access( "/usr/lib/kde4/libexec/kscreenlocker_greet", X_OK ) != -1 ) { command = g_strdup ("/usr/lib/kde4/libexec/kscreenlocker_greet"); } else { return; } if (! gdk_spawn_command_line_on_screen (screen, command, &error)) { if (! call_multiple_screensaver) { g_warning ("Cannot lock screen: %s", error->message); } g_error_free (error); } g_free (command); if (use_xscreensaver) { command = g_strdup ("xscreensaver-command -throttle"); if (! gdk_spawn_command_line_on_screen (screen, command, &error)) { g_warning ("Cannot disable screensaver engines: %s", error->message); g_error_free (error); } g_free (command); } }
static void maybe_lock_screen (void) { gboolean use_gscreensaver = FALSE; GError *error = NULL; char *command; if (is_program_in_path ("gnome-screensaver-command")) { use_gscreensaver = TRUE; } else if (! is_program_in_path ("xscreensaver-command")) { return; } if (use_gscreensaver) { command = g_strdup ("gnome-screensaver-command --lock"); } else { command = g_strdup ("xscreensaver-command -lock"); } if (! g_spawn_command_line_async (command, &error)) { g_warning ("Cannot lock screen: %s", error->message); g_error_free (error); } g_free (command); if (! use_gscreensaver) { command = g_strdup ("xscreensaver-command -throttle"); if (! g_spawn_command_line_async (command, &error)) { g_warning ("Cannot disable screensaver engines: %s", error->message); g_error_free (error); } g_free (command); } }
static void add_compress_arg (FrCommand *comm) { if (is_mime_type (comm->mime_type, "application/x-compressed-tar")) fr_process_add_arg (comm->process, "-z"); else if (is_mime_type (comm->mime_type, "application/x-bzip-compressed-tar")) fr_process_add_arg (comm->process, "--use-compress-program=bzip2"); else if (is_mime_type (comm->mime_type, "application/x-tarz")) { if (is_program_in_path ("gzip")) fr_process_add_arg (comm->process, "-z"); else fr_process_add_arg (comm->process, "-Z"); } else if (is_mime_type (comm->mime_type, "application/x-lrzip-compressed-tar")) fr_process_add_arg (comm->process, "--use-compress-program=lrzip"); else if (is_mime_type (comm->mime_type, "application/x-lzip-compressed-tar")) fr_process_add_arg (comm->process, "--use-compress-program=lzip"); else if (is_mime_type (comm->mime_type, "application/x-lzma-compressed-tar")) fr_process_add_arg (comm->process, "--use-compress-program=lzma"); else if (is_mime_type (comm->mime_type, "application/x-xz-compressed-tar")) fr_process_add_arg (comm->process, "--use-compress-program=xz"); else if (is_mime_type (comm->mime_type, "application/x-lzop-compressed-tar")) fr_process_add_arg (comm->process, "--use-compress-program=lzop"); else if (is_mime_type (comm->mime_type, "application/x-7z-compressed-tar")) { FrCommandTar *comm_tar = (FrCommandTar*) comm; char *option; option = g_strdup_printf ("--use-compress-program=%s", comm_tar->compress_command); fr_process_add_arg (comm->process, option); g_free (option); } }
static void got_session_name (GObject *object, GAsyncResult *res, gpointer data) { GDBusProxy *proxy; GVariant *result, *variant; const gchar *session_name = NULL; GError *error = NULL; proxy = G_DBUS_PROXY (object); result = g_dbus_proxy_call_finish (proxy, res, &error); if (!result) { g_debug ("Failed to get session name: %s", error->message); g_error_free (error); register_with_gnome_session (proxy); return; } g_variant_get (result, "(v)", &variant); g_variant_unref (result); g_variant_get (variant, "&s", &session_name); if (g_strcmp0 (session_name, "gnome") == 0 && is_program_in_path ("ibus-daemon") && keyboard_plugin_is_enabled ()) { set_session_env (proxy, "QT_IM_MODULE", "ibus"); set_session_env (proxy, "XMODIFIERS", "@im=ibus"); } g_variant_unref (variant); /* Finally we can register. */ register_with_gnome_session (proxy); }
static void fr_command_cfile_test (FrCommand *comm) { const char *compress_cmd; if (is_mime_type (comm->mime_type, "application/x-gzip")) { compress_cmd = "gzip"; } else if (is_mime_type (comm->mime_type, "application/x-brotli")) { compress_cmd = "brotli"; } else if (is_mime_type (comm->mime_type, "application/x-bzip")) { compress_cmd = "bzip2"; } else if (is_mime_type (comm->mime_type, "application/x-compress")) { compress_cmd = is_program_in_path ("gzip") ? "gzip" : "uncompress"; } else if (is_mime_type (comm->mime_type, "application/x-lzip")) { compress_cmd = "lzip"; } else if (is_mime_type (comm->mime_type, "application/x-lzma")) { compress_cmd = "lzma"; } else if (is_mime_type (comm->mime_type, "application/x-xz")) { compress_cmd = "xz"; } else if (is_mime_type (comm->mime_type, "application/x-lzop")) { compress_cmd = "lzop"; } else { // i.e. if (is_mime_type (comm->mime_type, "application/x-rzip")) g_warning ("Test integrity is unsupported for %s\n", comm->mime_type); return; } fr_process_begin_command (comm->process, compress_cmd); fr_process_add_arg (comm->process, "-vt"); // verbose and test fr_process_add_arg (comm->process, comm->filename); fr_process_end_command (comm->process); }
static void fr_command_cfile_extract (FrCommand *comm, const char *from_file, GList *file_list, const char *dest_dir, gboolean overwrite, gboolean skip_older, gboolean junk_paths) { char *temp_dir; char *dest_file; char *temp_file; char *uncompr_file; char *compr_file; /* copy file to the temp dir, remove the already existing file first */ temp_dir = get_temp_work_dir (NULL); temp_file = g_strconcat (temp_dir, "/", file_name_from_path (comm->filename), NULL); fr_process_begin_command (comm->process, "cp"); fr_process_add_arg (comm->process, "-f"); fr_process_add_arg (comm->process, comm->filename); fr_process_add_arg (comm->process, temp_file); fr_process_end_command (comm->process); /* uncompress the file */ if (is_mime_type (comm->mime_type, "application/x-gzip")) { fr_process_begin_command (comm->process, "gzip"); fr_process_add_arg (comm->process, "-f"); fr_process_add_arg (comm->process, "-d"); fr_process_add_arg (comm->process, "-n"); fr_process_add_arg (comm->process, temp_file); fr_process_end_command (comm->process); } else if (is_mime_type (comm->mime_type, "application/x-bzip")) { fr_process_begin_command (comm->process, "bzip2"); fr_process_add_arg (comm->process, "-f"); fr_process_add_arg (comm->process, "-d"); fr_process_add_arg (comm->process, temp_file); fr_process_end_command (comm->process); } else if (is_mime_type (comm->mime_type, "application/x-compress")) { if (is_program_in_path ("gzip")) { fr_process_begin_command (comm->process, "gzip"); fr_process_add_arg (comm->process, "-d"); fr_process_add_arg (comm->process, "-n"); } else fr_process_begin_command (comm->process, "uncompress"); fr_process_add_arg (comm->process, "-f"); fr_process_add_arg (comm->process, temp_file); fr_process_end_command (comm->process); } else if (is_mime_type (comm->mime_type, "application/x-lzip")) { fr_process_begin_command (comm->process, "lzip"); fr_process_add_arg (comm->process, "-f"); fr_process_add_arg (comm->process, "-d"); fr_process_add_arg (comm->process, temp_file); fr_process_end_command (comm->process); } else if (is_mime_type (comm->mime_type, "application/x-lzma")) { fr_process_begin_command (comm->process, "lzma"); fr_process_add_arg (comm->process, "-f"); fr_process_add_arg (comm->process, "-d"); fr_process_add_arg (comm->process, temp_file); fr_process_end_command (comm->process); } else if (is_mime_type (comm->mime_type, "application/x-xz")) { fr_process_begin_command (comm->process, "xz"); fr_process_add_arg (comm->process, "-f"); fr_process_add_arg (comm->process, "-d"); fr_process_add_arg (comm->process, temp_file); fr_process_end_command (comm->process); } else if (is_mime_type (comm->mime_type, "application/x-lzop")) { fr_process_begin_command (comm->process, "lzop"); fr_process_set_working_dir (comm->process, temp_dir); fr_process_add_arg (comm->process, "-d"); fr_process_add_arg (comm->process, "-fU"); fr_process_add_arg (comm->process, "--no-stdin"); fr_process_add_arg (comm->process, temp_file); fr_process_end_command (comm->process); } else if (is_mime_type (comm->mime_type, "application/x-rzip")) { fr_process_begin_command (comm->process, "rzip"); fr_process_add_arg (comm->process, "-f"); fr_process_add_arg (comm->process, "-d"); fr_process_add_arg (comm->process, temp_file); fr_process_end_command (comm->process); } /* copy uncompress file to the dest dir */ uncompr_file = remove_extension_from_path (temp_file); compr_file = get_uncompressed_name_from_archive (comm, comm->filename); if (compr_file == NULL) compr_file = remove_extension_from_path (file_name_from_path (comm->filename)); dest_file = g_strconcat (dest_dir, "/", compr_file, NULL); fr_process_begin_command (comm->process, "cp"); fr_process_add_arg (comm->process, "-f"); fr_process_add_arg (comm->process, uncompr_file); fr_process_add_arg (comm->process, dest_file); fr_process_end_command (comm->process); /* remove the temp dir */ fr_process_begin_command (comm->process, "rm"); fr_process_set_sticky (comm->process, TRUE); fr_process_add_arg (comm->process, "-rf"); fr_process_add_arg (comm->process, temp_dir); fr_process_end_command (comm->process); g_free (dest_file); g_free (compr_file); g_free (uncompr_file); g_free (temp_file); g_free (temp_dir); }
static void init_capplet (void) { GtkWidget *dialog; GtkWidget *preview; GtkWidget *treeview; GtkWidget *list_scroller; GtkWidget *activate_delay_hscale; GtkWidget *activate_delay_hbox; GtkWidget *label; GtkWidget *enabled_checkbox; GtkWidget *lock_checkbox; GtkWidget *root_warning_label; GtkWidget *preview_button; GtkWidget *gpm_button; GtkWidget *fullscreen_preview_window; GtkWidget *fullscreen_preview_previous; GtkWidget *fullscreen_preview_next; GtkWidget *fullscreen_preview_area; GtkWidget *fullscreen_preview_close; char *gtk_builder_file; gdouble activate_delay; gboolean enabled; gboolean is_writable; GSettings *settings; GError *error=NULL; gint mode; gtk_builder_file = g_build_filename (GTKBUILDERDIR, GTK_BUILDER_FILE, NULL); builder = gtk_builder_new(); if (!gtk_builder_add_from_file(builder, gtk_builder_file, &error)) { g_warning("Couldn't load builder file: %s", error->message); g_error_free(error); } g_free (gtk_builder_file); if (builder == NULL) { dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Could not load the main interface")); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), _("Please make sure that the screensaver is properly installed")); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); exit (1); } preview = GTK_WIDGET (gtk_builder_get_object (builder, "preview_area")); dialog = GTK_WIDGET (gtk_builder_get_object (builder, "prefs_dialog")); treeview = GTK_WIDGET (gtk_builder_get_object (builder, "savers_treeview")); list_scroller = GTK_WIDGET (gtk_builder_get_object (builder, "themes_scrolled_window")); activate_delay_hscale = GTK_WIDGET (gtk_builder_get_object (builder, "activate_delay_hscale")); activate_delay_hbox = GTK_WIDGET (gtk_builder_get_object (builder, "activate_delay_hbox")); enabled_checkbox = GTK_WIDGET (gtk_builder_get_object (builder, "enable_checkbox")); lock_checkbox = GTK_WIDGET (gtk_builder_get_object (builder, "lock_checkbox")); root_warning_label = GTK_WIDGET (gtk_builder_get_object (builder, "root_warning_label")); preview_button = GTK_WIDGET (gtk_builder_get_object (builder, "preview_button")); gpm_button = GTK_WIDGET (gtk_builder_get_object (builder, "gpm_button")); fullscreen_preview_window = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_window")); fullscreen_preview_area = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_area")); fullscreen_preview_close = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_close")); fullscreen_preview_previous = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_previous_button")); fullscreen_preview_next = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_next_button")); label = GTK_WIDGET (gtk_builder_get_object (builder, "activate_delay_label")); gtk_label_set_mnemonic_widget (GTK_LABEL (label), activate_delay_hscale); label = GTK_WIDGET (gtk_builder_get_object (builder, "savers_label")); gtk_label_set_mnemonic_widget (GTK_LABEL (label), treeview); gtk_widget_set_no_show_all (root_warning_label, TRUE); widget_set_best_colormap (preview); if (! is_program_in_path (GPM_COMMAND)) { gtk_widget_set_no_show_all (gpm_button, TRUE); gtk_widget_hide (gpm_button); } activate_delay = config_get_activate_delay (&is_writable); ui_set_delay (activate_delay); if (! is_writable) { gtk_widget_set_sensitive (activate_delay_hbox, FALSE); } g_signal_connect (activate_delay_hscale, "format-value", G_CALLBACK (format_value_callback_time), NULL); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lock_checkbox), config_get_lock (&is_writable)); if (! is_writable) { gtk_widget_set_sensitive (lock_checkbox, FALSE); } g_signal_connect (lock_checkbox, "toggled", G_CALLBACK (lock_checkbox_toggled), NULL); enabled = config_get_enabled (&is_writable); ui_set_enabled (enabled); if (! is_writable) { gtk_widget_set_sensitive (enabled_checkbox, FALSE); } g_signal_connect (enabled_checkbox, "toggled", G_CALLBACK (enabled_checkbox_toggled), NULL); setup_list_size_constraint (list_scroller, treeview); gtk_widget_set_size_request (preview, 480, 300); gtk_window_set_icon_name (GTK_WINDOW (dialog), "preferences-desktop-screensaver"); gtk_window_set_icon_name (GTK_WINDOW (fullscreen_preview_window), "screensaver"); gtk_drag_dest_set (dialog, GTK_DEST_DEFAULT_ALL, drop_types, G_N_ELEMENTS (drop_types), GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_MOVE); g_signal_connect (dialog, "drag-motion", G_CALLBACK (drag_motion_cb), NULL); g_signal_connect (dialog, "drag-leave", G_CALLBACK (drag_leave_cb), NULL); g_signal_connect (dialog, "drag-data-received", G_CALLBACK (drag_data_received_cb), NULL); gtk_widget_show_all (dialog); /* Update list of themes if using random screensaver */ settings = g_settings_new (GSETTINGS_SCHEMA); mode = g_settings_get_enum (settings, KEY_MODE); if (mode == GS_MODE_RANDOM) { gchar **list; list = get_all_theme_ids (theme_manager); g_settings_set_strv (settings, KEY_THEMES, (const gchar * const*) list); g_strfreev (list); } g_signal_connect (settings, "changed", G_CALLBACK (key_changed_cb), NULL); g_object_unref (settings); preview_clear (preview); gs_job_set_widget (job, preview); if (check_is_root_user ()) { setup_for_root_user (); } g_signal_connect (activate_delay_hscale, "value-changed", G_CALLBACK (activate_delay_value_changed_cb), NULL); g_signal_connect (dialog, "response", G_CALLBACK (response_cb), NULL); g_signal_connect (preview_button, "clicked", G_CALLBACK (fullscreen_preview_start_cb), treeview); g_signal_connect (fullscreen_preview_close, "clicked", G_CALLBACK (fullscreen_preview_cancelled_cb), NULL); g_signal_connect (fullscreen_preview_previous, "clicked", G_CALLBACK (fullscreen_preview_previous_cb), NULL); g_signal_connect (fullscreen_preview_next, "clicked", G_CALLBACK (fullscreen_preview_next_cb), NULL); g_idle_add ((GSourceFunc)setup_treeview_idle, NULL); }