XfwWindow *xfw_window; /* We keep track of the current workspace number because
* sometimes fetching the active workspace returns NULL. */
gint active_workspace;
/* If we didn't create a thumbnail there might not be a thumbnailer service
* or it may not support that format */
GdkPixbuf *pix; if (thumbnail == NULL) {
XF_DEBUG("generating thumbnail for filename %s", filename);
pix = gdk_pixbuf_new_from_file_at_scale(filename,
PREVIEW_WIDTH * pdata->scale_factor, PREVIEW_HEIGHT * pdata->scale_factor, TRUE, NULL);
} else {
XF_DEBUG("loading thumbnail %s", thumbnail);
pix = gdk_pixbuf_new_from_file_at_scale(thumbnail,
PREVIEW_WIDTH * pdata->scale_factor, PREVIEW_HEIGHT * pdata->scale_factor, TRUE, NULL);
g_free(thumbnail);
}
g_free(filename);
if (pix != NULL) {
cairo_surface_t *surface;
pdata->pix = pix;
/* set the image */
surface = gdk_cairo_surface_create_from_pixbuf(pix, pdata->scale_factor, NULL);
gtk_list_store_set(GTK_LIST_STORE(pdata->model), pdata->iter,
COL_PIX, pdata->pix,
COL_SURFACE, surface,
-1);
cairo_surface_destroy(surface);
if (pdata != NULL) {
xfdesktop_settings_do_single_preview(pdata); /* Continue on the next idle time */ returnTRUE;
} else { /* Nothing left, remove the queue, we're done with it */
g_async_queue_unref(background_settings->preview_queue);
background_settings->preview_queue = NULL;
}
}
/* clear the idle source */
background_settings->preview_id = 0;
/* Create the previews in an idle callback */ if (background_settings->preview_id == 0) {
background_settings->preview_id = g_idle_add(xfdesktop_settings_create_previews, background_settings);
}
}
if (gtk_tree_model_get_iter_first(model, &iter)) { do {
gchar *filename = NULL;
gtk_tree_model_get(model, &iter, COL_FILENAME, &filename, -1);
/* We're looking for the src_file */ if (g_strcmp0(filename, src_file) == 0) { /* Add the thumb_file to it */
gtk_list_store_set(GTK_LIST_STORE(model), &iter,
COL_THUMBNAIL, thumb_file, -1);
/* Attempt to use the thumbnailer if possible */ if (!xfdesktop_thumbnailer_queue_thumbnail(background_settings->thumbnailer, filename)) { /* Thumbnailing not possible, add it to the queue to be loaded manually */
PreviewData *pdata;
pdata = g_new0(PreviewData, 1);
pdata->model = GTK_TREE_MODEL(g_object_ref(G_OBJECT(model)));
pdata->iter = gtk_tree_iter_copy(iter);
pdata->scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(background_settings->image_iconview));
/* Display the file name, file type, and file size in the tooltip. */ const gchar *content_type = g_file_info_get_content_type(info);
gchar *name_markup = g_markup_printf_escaped(_("<b>%s</b>\nType: %s\nSize: %s"),
name_utf8,
content_type,
size_string);
/* create a case sensitive collation key for sorting filenames like
* Thunar does */
gchar *collate_key = g_utf8_collate_key_for_filename(name, name_length);
/* Insert sorted */
GtkTreeIter search_iter;
gboolean valid = gtk_tree_model_get_iter_first(model, &search_iter);
gboolean found = FALSE;
gint position = 0; while (valid && !found) { if (image_list_compare(model, collate_key, &search_iter) <= 0) {
found = TRUE;
} else {
valid = gtk_tree_model_iter_next(model, &search_iter);
position++;
}
}
/* Get the last image/current image displayed so we can select it in the
* icon view */
dir_data->last_image = xfdesktop_settings_get_backdrop_image(background_settings);
dir_data->file_path = g_file_get_path(background_settings->selected_folder);
static gint
workspace_count_total(XfwWorkspaceManager *workspace_manager) {
gint n_ws = 0; for (GList *l = xfw_workspace_manager_list_workspace_groups(workspace_manager);
l != NULL;
l = l->next)
{
n_ws += xfw_workspace_group_get_workspace_count(XFW_WORKSPACE_GROUP(l->data));
} return n_ws;
}
staticvoid
xfdesktop_settings_update_iconview_frame_name(XfdesktopBackgroundSettings *background_settings,
XfwWorkspace *xfw_workspace)
{ /* Don't update the name until we find our window */ if (background_settings->xfw_window == NULL) { return;
}
/* If it's a pinned window get the active workspace */
XfwWorkspace *workspace; if (xfw_workspace == NULL) {
workspace = find_workspace_by_number(workspace_manager, background_settings->active_workspace);
} else {
workspace = xfw_workspace;
}
if (workspace == NULL) {
g_critical("active workspace is not in list"); return;
}
gchar *label_text; if (gdk_display_get_n_monitors(gtk_widget_get_display(background_settings->chk_apply_to_all)) > 1) { if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(background_settings->chk_apply_to_all))) { /* Multi-monitor single workspace */ if (background_settings->monitor_name != NULL) {
label_text = g_strdup_printf(_("Wallpaper for Monitor %d (%s)"),
background_settings->monitor,
background_settings->monitor_name);
} else {
label_text = g_strdup_printf(_("Wallpaper for Monitor %d"), background_settings->monitor);
}
/* This is for the infobar letting the user know how to configure
* multiple monitor setups */
gtk_label_set_text(GTK_LABEL(background_settings->infobar_label),
_("Move this dialog to the display you " "want to edit the settings for."));
} else { /* Multi-monitor per workspace wallpaper */ if (background_settings->monitor_name != NULL) {
label_text = g_strdup_printf(_("Wallpaper for %s on Monitor %d (%s)"),
workspace_name,
background_settings->monitor,
background_settings->monitor_name);
} else {
label_text = g_strdup_printf(_("Wallpaper for %s on Monitor %d"),
workspace_name,
background_settings->monitor);
}
/* This is for the infobar letting the user know how to configure
* multiple monitor/workspace setups */
gtk_label_set_text(GTK_LABEL(background_settings->infobar_label),
_("Move this dialog to the display and " "workspace you want to edit the settings for."));
}
gtk_widget_show(background_settings->infobar);
} else { if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(background_settings->chk_apply_to_all)) ||
(workspace_count_total(workspace_manager) == 1)) { /* Single monitor and single workspace */
label_text = g_strdup(_("Wallpaper for my desktop"));
/* No need for the infobar */
gtk_widget_hide(background_settings->infobar);
} else { /* Single monitor and per workspace wallpaper */
label_text = g_strdup_printf(_("Wallpaper for %s"), workspace_name);
/* This is for the infobar letting the user know how to configure
* multiple workspace setups */
gtk_label_set_text(GTK_LABEL(background_settings->infobar_label),
_("Move this dialog to the workspace you " "want to edit the settings for."));
gtk_widget_show(background_settings->infobar);
}
}
/* This label is for which workspace/monitor we're on */
gtk_label_set_text(GTK_LABEL(background_settings->label_header), label_text);
g_free(workspace_name);
g_free(label_text);
}
/* Free the returned string when done using it */ static gchar *
xfdesktop_settings_generate_per_workspace_binding_string(XfdesktopBackgroundSettings *background_settings, const gchar *property)
{
gchar *buf; if (background_settings->monitor_name == NULL) {
buf = g_strdup_printf("/backdrop/screen%d/monitor%d/workspace%d/%s",
background_settings->screen,
background_settings->monitor,
background_settings->workspace,
property);
} else {
buf = xfdesktop_remove_whitspaces(g_strdup_printf("/backdrop/screen%d/monitor%s/workspace%d/%s",
background_settings->screen,
background_settings->monitor_name,
background_settings->workspace,
property));
}
/* Attempts to load the backdrop from the current location followed by using *howpreviousversionsofxfdesktop(before4.11)did.Thismatcheshow *xfdesktopsearchesforbackdrops.
* Free the returned string when done using it. */ static gchar *
xfdesktop_settings_get_backdrop_image(XfdesktopBackgroundSettings *background_settings) { /* Get the last image/current image displayed, if available */
gchar *property = xfdesktop_settings_generate_per_workspace_binding_string(background_settings, "last-image");
gchar *last_image = xfconf_channel_get_string(background_settings->settings->channel, property, NULL);
/* Try the previous version or fall back to our provided default */ if (last_image == NULL) {
gchar *old_property = xfdesktop_settings_generate_old_binding_string(background_settings, "image-path");
last_image = xfconf_channel_get_string(background_settings->settings->channel,
old_property,
DEFAULT_BACKDROP);
g_free(old_property);
}
/* Get the current/last image, handles migrating from old versions */
gchar *current_filename = xfdesktop_settings_get_backdrop_image(background_settings);
/* check to see if the selection actually did change */ if (g_strcmp0(current_filename, filename) != 0) { if (background_settings->monitor_name == NULL) {
XF_DEBUG("got %s, applying to screen %d monitor %d workspace %d", filename,
background_settings->screen, background_settings->monitor, background_settings->workspace);
} else {
XF_DEBUG("got %s, applying to screen %d monitor %s workspace %d", filename,
background_settings->screen, background_settings->monitor_name, background_settings->workspace);
}
/* Get the property location to save our changes, always save to new
* location */
gchar *buf = xfdesktop_settings_generate_per_workspace_binding_string(background_settings, "last-image");
XF_DEBUG("Saving to %s/%s", buf, filename);
xfconf_channel_set_string(background_settings->settings->channel, buf, filename);
g_free(buf);
}
staticvoid
update_backdrop_random_order_chkbox(XfdesktopBackgroundSettings *background_settings) { /* For the random check box to be active the combo_backdrop_cycle_period
* needs to be active and needs to not be set to chronological */
gboolean sensitive; if (gtk_widget_get_sensitive(background_settings->combo_backdrop_cycle_period)) {
gint period = gtk_combo_box_get_active(GTK_COMBO_BOX(background_settings->combo_backdrop_cycle_period));
sensitive = period != XFCE_BACKDROP_PERIOD_CHRONOLOGICAL;
} else {
sensitive = FALSE;
}
staticvoid
update_backdrop_cycle_spinbox(XfdesktopBackgroundSettings *background_settings) { /* For the spinbox to be active the combo_backdrop_cycle_period needs to be
* active and needs to be set to something where the spinbox would apply */
gboolean sensitive; if (gtk_widget_get_sensitive(background_settings->combo_backdrop_cycle_period)) {
gint period = gtk_combo_box_get_active(GTK_COMBO_BOX(background_settings->combo_backdrop_cycle_period));
sensitive = period == XFCE_BACKDROP_PERIOD_SECONDS
|| period == XFCE_BACKDROP_PERIOD_MINUTES
|| period == XFCE_BACKDROP_PERIOD_HOURS;
} else {
sensitive = FALSE;
}
staticvoid
cb_combo_backdrop_cycle_period_change(GtkComboBox *combo, XfdesktopBackgroundSettings *background_settings) { /* determine if the spin box should be sensitive */
update_backdrop_cycle_spinbox(background_settings); /* determine if the random check box should be sensitive */
update_backdrop_random_order_chkbox(background_settings);
}
/* The cycle backdrop toggles the period and random widgets */
gtk_widget_set_sensitive(background_settings->combo_backdrop_cycle_period, sensitive); /* determine if the spin box should be sensitive */
update_backdrop_cycle_spinbox(background_settings); /* determine if the random check box should be sensitive */
update_backdrop_random_order_chkbox(background_settings);
staticvoid
stop_image_loading(XfdesktopBackgroundSettings *background_settings) {
XF_DEBUG("xfdesktop_settings_stop_image_loading"); /* stop any thumbnailing in progress */
xfdesktop_thumbnailer_dequeue_all_thumbnails(background_settings->thumbnailer);
/* stop the idle preview callback */ if (background_settings->preview_id != 0) {
g_source_remove(background_settings->preview_id);
background_settings->preview_id = 0;
}
/* Remove the previews in the message queue */ if (background_settings->preview_queue != NULL) {
g_async_queue_unref(background_settings->preview_queue);
background_settings->preview_queue = NULL;
}
/* Cancel any file enumeration that's running */ if (background_settings->cancel_enumeration != NULL) {
g_cancellable_cancel(background_settings->cancel_enumeration);
g_object_unref(background_settings->cancel_enumeration);
background_settings->cancel_enumeration = NULL;
}
/* Cancel the file enumeration for populating the icon view */ if (background_settings->add_dir_idle_id != 0) {
g_source_remove(background_settings->add_dir_idle_id);
background_settings->add_dir_idle_id = 0;
}
}
/* Check to see if the folder actually did change */ if (g_strcmp0(new_folder, previous_folder) == 0) {
gchar *current_filename = xfdesktop_settings_get_backdrop_image(background_settings);
gchar *current_folder = g_path_get_dirname(current_filename);
g_free(current_filename);
/* workaround another gtk bug - if the user sets the file chooser *buttontosomethingthenitcan'tbechangedwithasetfolder
* call anymore. */ if(g_strcmp0(new_folder, current_folder) == 0) {
XF_DEBUG("folder didn't change");
g_free(current_folder);
g_free(new_folder);
g_free(previous_folder); returnFALSE;
} else {
g_free(new_folder);
new_folder = current_folder;
}
}
TRACE("folder changed to: %s", new_folder);
if (background_settings->selected_folder != NULL) {
g_object_unref(background_settings->selected_folder);
}
background_settings->selected_folder = g_file_new_for_path(new_folder);
/* Stop any previous loading since something changed */
stop_image_loading(background_settings);
if (gtk_combo_box_get_active(combo) == XFCE_BACKDROP_IMAGE_NONE) { /* No wallpaper so set the iconview to insensitive so the user doesn't *pickwallpapersthathavenoeffect.Stoppoppinguptooltipsfor *thenowinsensitiveiconviewandprovideatooltipexplainingwhy
* the iconview is insensitive. */
gtk_widget_set_sensitive(background_settings->image_iconview, FALSE);
g_object_set(G_OBJECT(background_settings->image_iconview), "tooltip-column", -1,
NULL);
gtk_widget_set_tooltip_text(background_settings->image_iconview,
_("Image selection is unavailable while the image style is set to None."));
} else {
/* We are expected to provide a wallpaper so make the iconview active. *Additionally,ifwewereinsensitivethenweneedtoremovethe
* global iconview tooltip and enable the individual tooltips again. */
gtk_widget_set_sensitive(background_settings->image_iconview, TRUE);
gint tooltip_column;
g_object_get(G_OBJECT(background_settings->image_iconview), "tooltip-column", &tooltip_column,
NULL); if (tooltip_column == -1) {
gtk_widget_set_tooltip_text(background_settings->image_iconview, NULL);
g_object_set(G_OBJECT(background_settings->image_iconview), "tooltip-column", COL_NAME,
NULL);
}
}
}
static gboolean
xfdesktop_settings_update_iconview_folder(XfdesktopBackgroundSettings *background_settings) { /* If we haven't found our window return now and wait for that */ if (background_settings->xfw_window == NULL) { returnFALSE;
}
/* This function is to add or remove all the bindings for the background *tab.It'sintendedtobeusedwhentheappchangesmonitorsorworkspaces. *Itrevertstheitemsbacktotheirdefaultsbeforebindinganynewsettings
* that way if the setting isn't present, the default correctly displays. */ staticvoid
xfdesktop_settings_background_tab_change_bindings(XfdesktopBackgroundSettings *background_settings,
gboolean remove_binding)
{
gchar *buf, *old_property = NULL;
XfconfChannel *channel = background_settings->settings->channel;
/* Image style combo box */
buf = xfdesktop_settings_generate_per_workspace_binding_string(background_settings, "image-style"); if (remove_binding) {
xfconf_g_property_unbind_by_property(channel,
buf,
G_OBJECT(background_settings->image_style_combo), "active");
} else { /* If the current image style doesn't exist, try to load the old one */ if (!xfconf_channel_has_property(channel, buf)) {
gint image_style;
old_property = xfdesktop_settings_generate_old_binding_string(background_settings, "image-style");
/* default to zoomed when trying to migrate (zoomed was part of how
* auto worked in 4.10)*/
image_style = xfconf_channel_get_int(channel, old_property, XFCE_BACKDROP_IMAGE_ZOOMED);
/* xfce_translate_image_styles will do sanity checking */
gtk_combo_box_set_active(GTK_COMBO_BOX(background_settings->image_style_combo),
xfce_translate_image_styles(image_style));
g_free(old_property);
}
xfconf_g_property_bind(channel, buf, G_TYPE_INT,
G_OBJECT(background_settings->image_style_combo), "active"); /* determine if the iconview is sensitive */
cb_xfdesktop_combo_image_style_changed(GTK_COMBO_BOX(background_settings->image_style_combo), background_settings);
}
g_free(buf);
/* Color style combo box */
buf = xfdesktop_settings_generate_per_workspace_binding_string(background_settings, "color-style"); if (remove_binding) {
xfconf_g_property_unbind_by_property(channel,
buf,
G_OBJECT(background_settings->color_style_combo), "active");
} else { /* If the current color style doesn't exist, try to load the old one */ if (!xfconf_channel_has_property(channel, buf)) {
gint color_style;
old_property = xfdesktop_settings_generate_old_binding_string(background_settings, "color-style");
/* default to solid when trying to migrate */
color_style = xfconf_channel_get_int(channel, old_property, XFCE_BACKDROP_COLOR_SOLID);
xfconf_g_property_bind(channel, buf, G_TYPE_INT,
G_OBJECT(background_settings->color_style_combo), "active"); /* update the color button sensitivity */
cb_xfdesktop_combo_color_changed(GTK_COMBO_BOX(background_settings->color_style_combo), background_settings);
}
g_free(buf);
/* color 1 button */ /* Fixme: we will need to migrate from color1 to rgba1 (GdkColor to GdkRGBA) */
buf = xfdesktop_settings_generate_per_workspace_binding_string(background_settings, "rgba1"); if (remove_binding) {
xfconf_g_property_unbind(background_settings->color1_btn_id);
} else { /* If the first color doesn't exist, try to load the old one */ if (!xfconf_channel_has_property(channel, buf)) {
GValue value = { 0, };
old_property = xfdesktop_settings_generate_old_binding_string(background_settings, "rgba1");
/* Now bind to the new value */
background_settings->color1_btn_id = xfconf_g_property_bind(channel,
buf,
G_TYPE_PTR_ARRAY,
G_OBJECT(background_settings->color1_btn), "rgba");
}
g_free(buf);
/* color 2 button */ /* Fixme: we will need to migrate from color1 to rgba1 (GdkColor to GdkRGBA) */
buf = xfdesktop_settings_generate_per_workspace_binding_string(background_settings, "rgba2"); if (remove_binding) {
xfconf_g_property_unbind(background_settings->color2_btn_id);
} else { /* If the 2nd color doesn't exist, try to load the old one */ if (!xfconf_channel_has_property(channel, buf)) {
GValue value = { 0, };
old_property = xfdesktop_settings_generate_old_binding_string(background_settings, "rgba2");
/* Now bind to the new value */
background_settings->color2_btn_id = xfconf_g_property_bind(channel,
buf,
G_TYPE_PTR_ARRAY,
G_OBJECT(background_settings->color2_btn), "rgba");
}
g_free(buf);
/* enable cycle timer check box */
buf = xfdesktop_settings_generate_per_workspace_binding_string(background_settings, "backdrop-cycle-enable"); if (remove_binding) {
xfconf_g_property_unbind_by_property(channel,
buf,
G_OBJECT(background_settings->backdrop_cycle_chkbox), "active");
} else { /* The default is disable cycling, set that before we bind to anything */
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_settings->backdrop_cycle_chkbox), FALSE);
/* backdrop cycle period combo box */
buf = xfdesktop_settings_generate_per_workspace_binding_string(background_settings, "backdrop-cycle-period"); if (remove_binding) {
xfconf_g_property_unbind_by_property(channel, buf,
G_OBJECT(background_settings->combo_backdrop_cycle_period), "active");
} else { /* default is minutes, set that before we bind to it */
gtk_combo_box_set_active(GTK_COMBO_BOX(background_settings->combo_backdrop_cycle_period), XFCE_BACKDROP_PERIOD_MINUTES);
xfconf_g_property_bind(channel, buf, G_TYPE_INT,
G_OBJECT(background_settings->combo_backdrop_cycle_period), "active"); /* determine if the cycle timer spin box is sensitive */
cb_combo_backdrop_cycle_period_change(GTK_COMBO_BOX(background_settings->combo_backdrop_cycle_period), background_settings);
}
g_free(buf);
/* cycle timer spin box */
buf = xfdesktop_settings_generate_per_workspace_binding_string(background_settings, "backdrop-cycle-timer");
GtkAdjustment *adj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(background_settings->backdrop_cycle_spinbox)); if (remove_binding) {
xfconf_g_property_unbind_by_property(channel, buf, G_OBJECT(adj), "value");
} else {
guint current_timer = xfconf_channel_get_uint(channel, buf, 10); /* Update the spin box before we bind to it */
gtk_spin_button_set_value(GTK_SPIN_BUTTON(background_settings->backdrop_cycle_spinbox), current_timer);
/* cycle random order check box */
buf = xfdesktop_settings_generate_per_workspace_binding_string(background_settings, "backdrop-cycle-random-order"); if (remove_binding) {
xfconf_g_property_unbind_by_property(channel, buf,
G_OBJECT(background_settings->random_backdrop_order_chkbox), "active");
} else { /* The default is sequential, set that before we bind to anything */
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_settings->random_backdrop_order_chkbox), FALSE);
/* If workspace is NULL that means it's pinned and we just need to
* use the active/current workspace */
gint workspace_num = -1, n_workspaces = 0; if (workspace != NULL) {
xfdesktop_workspace_get_number_and_total(workspace_manager, workspace, &workspace_num, &n_workspaces);
} else {
workspace_num = background_settings->active_workspace;
n_workspaces = workspace_count_total(workspace_manager);
}
/* If we're in single_workspace mode we need to return the workspace that *itwassetto,ifthatworkspaceexists,otherwisereturnthecurrent
* workspace and turn off the single workspace mode */ if (single_workspace) {
gint single_workspace_num = xfconf_channel_get_int(background_settings->settings->channel,
SINGLE_WORKSPACE_NUMBER, 0); if (single_workspace_num < n_workspaces) { return single_workspace_num;
} else {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_settings->chk_apply_to_all), FALSE);
}
}
return workspace_num;
}
staticvoid
cb_update_background_tab(XfwWindow *xfw_window, XfdesktopBackgroundSettings *background_settings) { /* If we haven't found our window return now and wait for that */ if (background_settings->xfw_window == NULL) { return;
}
/* Get all the new settings for comparison */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gint screen_num = gdk_screen_get_number(gtk_widget_get_screen(background_settings->image_iconview));
G_GNUC_END_IGNORE_DEPRECATIONS
XfwWorkspace *workspace = xfw_window_get_workspace(background_settings->xfw_window);
gint workspace_num = xfdesktop_settings_get_active_workspace(background_settings, xfw_window);
GdkWindow *window = gtk_widget_get_window(background_settings->image_iconview);
GdkDisplay *display = gdk_window_get_display(window);
GdkMonitor *monitor = gdk_display_get_monitor_at_window(display, window);
gint monitor_num = xfdesktop_get_monitor_num(display, monitor);
gchar *monitor_name = xfdesktop_get_monitor_name_from_gtk_widget(background_settings->image_iconview, monitor_num);
/* Most of the time we won't change monitor, screen, or workspace so try
* to bail out now if we can */ /* Check to see if we haven't changed workspace or screen */ if (background_settings->workspace == workspace_num && background_settings->screen == screen_num) { /* do we support monitor names? */ if(background_settings->monitor_name != NULL || monitor_name != NULL) { /* Check if we haven't changed monitors (by name) */ if(g_strcmp0(background_settings->monitor_name, monitor_name) == 0) {
g_free(monitor_name); return;
}
}
}
TRACE("screen, monitor, or workspace changed");
/* remove the old bindings if there are any */ if (background_settings->color1_btn_id || background_settings->color2_btn_id) {
XF_DEBUG("removing old bindings");
xfdesktop_settings_background_tab_change_bindings(background_settings, TRUE);
}
/* The first monitor has the option of doing the "spanning screens" style, *butonlyifthere'smultiplemonitorsattached.Removeitinallothercases. * *Removethespanningscreensoptionbeforewepotentiallyadditagain
*/
gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(background_settings->image_style_combo),
XFCE_BACKDROP_IMAGE_SPANNING_SCREENS);
staticvoid
cb_workspace_changed(XfwWorkspaceGroup *group,
XfwWorkspace *previously_active_workspace,
XfdesktopBackgroundSettings *background_settings)
{ /* Update the current workspace number */
XfwWorkspace *active_workspace = xfw_workspace_group_get_active_workspace(group);
gint new_num = -1; if (active_workspace != NULL) {
XfwWorkspaceManager *workspace_manager = xfw_workspace_group_get_workspace_manager(group);
gint n_ws;
xfdesktop_workspace_get_number_and_total(workspace_manager, active_workspace, &new_num, &n_ws);
}
/* This will sometimes fail to update */ if (new_num != -1) {
background_settings->active_workspace = new_num;
}
XF_DEBUG("active_workspace now %d", background_settings->active_workspace);
/* Call cb_update_background_tab in case this is a pinned window */ if (background_settings->xfw_window != NULL) {
cb_update_background_tab(background_settings->xfw_window, background_settings);
}
}
// When we're embedded in the settings manager, the XID of 'window' is that of the settings // manager's main window, whereas our XID is the ID of the GtkPlug window. while (cur_win != window_xid && cur_win != root_win) {
Window parent_win = 0;
Window *children = NULL; unsignedint n_children = 0;
/* These callbacks are for updating the image_iconview when the window
* moves to another monitor or workspace */
g_signal_connect(background_settings->xfw_window, "geometry-changed",
G_CALLBACK(cb_update_background_tab), background_settings);
g_signal_connect(background_settings->xfw_window, "workspace-changed",
G_CALLBACK(cb_update_background_tab), background_settings);
XfwWorkspaceGroup *group = NULL;
XfwWorkspace *workspace = xfw_window_get_workspace(window); if (workspace == NULL) {
XfwWorkspaceManager *workspace_manager = xfw_screen_get_workspace_manager(screen); for (GList *l = xfw_workspace_manager_list_workspace_groups(workspace_manager);
l != NULL;
l = l->next)
{
workspace = xfw_workspace_group_get_active_workspace(XFW_WORKSPACE_GROUP(l->data)); if (workspace != NULL) {
group = XFW_WORKSPACE_GROUP(l->data); break;
}
}
} else {
group = xfw_workspace_get_workspace_group(workspace);
}
if (group != NULL) { /* Update the active workspace number */
cb_workspace_changed(group, NULL, background_settings);
} else {
g_message("Couldn't find active workspace or group");
}
/* Update the background settings */
cb_update_background_tab(window, background_settings);
/* Update the frame name */
xfdesktop_settings_update_iconview_frame_name(background_settings, workspace);
}
staticvoid
cb_monitor_changed(GdkScreen *gscreen, XfdesktopBackgroundSettings *background_settings) { if (gdk_display_get_n_monitors(gdk_screen_get_display(gscreen)) > 0) { /* Update background because the monitor we're on may have changed */
cb_update_background_tab(background_settings->xfw_window, background_settings);
/* Update the frame name because we may change from/to a single monitor */
xfdesktop_settings_update_iconview_frame_name(background_settings,
xfw_window_get_workspace(background_settings->xfw_window));
}
}
/* update the frame name to since we changed to/from single workspace mode */
xfdesktop_settings_update_iconview_frame_name(background_settings,
xfw_window_get_workspace(background_settings->xfw_window));
}
staticvoid
cb_workspace_count_changed(XfwWorkspaceManager *manager,
XfwWorkspace *workspace,
XfdesktopBackgroundSettings *background_settings)
{ /* Update background because the single workspace mode may have
* changed due to the addition/removal of a workspace */ if (background_settings->xfw_window != NULL) {
cb_update_background_tab(background_settings->xfw_window, background_settings);
}
}
#ifdef ENABLE_X11 if (xfw_windowing_get() == XFW_WINDOWING_X11) { if (GTK_IS_PLUG(background_settings->settings->settings_toplevel)) { /* In a GtkPlug setting there isn't an easy way to find our window
* in cb_window_opened so we'll just get the screen's active window */
background_settings->xfw_window = xfw_screen_get_active_window(background_settings->xfw_screen);
if (background_settings->xfw_window != NULL) { /* These callbacks are for updating the image_iconview when the window
* moves to another monitor or workspace */
g_signal_connect(background_settings->xfw_window, "geometry-changed",
G_CALLBACK(cb_update_background_tab), background_settings);
g_signal_connect(background_settings->xfw_window, "workspace-changed",
G_CALLBACK(cb_update_background_tab), background_settings);
} else { // XfwScreen doesn't know the active window yet, so wait until it // figures it out
g_signal_connect(background_settings->xfw_screen, "active-window-changed",
G_CALLBACK(cb_active_window_changed), background_settings);
}
}
/* watch for workspace changes */ for (GList *l = xfw_workspace_manager_list_workspace_groups(workspace_manager);
l != NULL;
l = l->next)
{
g_signal_connect(l->data, "active-workspace-changed",
G_CALLBACK(cb_workspace_changed), background_settings);
}
/* watch for window-opened so we can find our window and track its changes */
g_signal_connect(background_settings->xfw_screen, "window-opened",
G_CALLBACK(cb_window_opened), background_settings);
/* Add the background tab widgets to the main window and don't display the
* notebook label/tab */
gtk_notebook_append_page(GTK_NOTEBOOK(appearance_container),
appearance_settings, NULL);
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(appearance_container), FALSE);
/* Change the title of the file chooser dialog */
gtk_file_chooser_button_set_title(GTK_FILE_CHOOSER_BUTTON(background_settings->btn_folder), _("Select a Directory"));
/* Get default wallpaper folders */
GList *background_dirs = find_background_directories(); for (GList *l = background_dirs; l != NULL; l = l->next) {
GFile *file = G_FILE(l->data);
gchar *uri_path = g_file_get_uri(file);
gtk_file_chooser_add_shortcut_folder_uri(GTK_FILE_CHOOSER(background_settings->btn_folder), uri_path, NULL);
g_free(uri_path);
}
g_list_free_full(background_dirs, g_object_unref);
/* Image and color style options */
background_settings->image_style_combo = GTK_WIDGET(gtk_builder_get_object(appearance_gxml, "combo_style"));
gtk_combo_box_set_active(GTK_COMBO_BOX(background_settings->image_style_combo), XFCE_BACKDROP_IMAGE_ZOOMED);
g_signal_connect(G_OBJECT(background_settings->image_style_combo), "changed",
G_CALLBACK(cb_xfdesktop_combo_image_style_changed),
background_settings);
/* Use these settings for all workspaces checkbox */
background_settings->chk_apply_to_all = GTK_WIDGET(gtk_builder_get_object(appearance_gxml, "chk_apply_to_all")); if (xfconf_channel_get_bool(background_settings->settings->channel, SINGLE_WORKSPACE_MODE, TRUE)) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_settings->chk_apply_to_all), TRUE);
}
g_signal_connect(G_OBJECT(background_settings->chk_apply_to_all), "toggled",
G_CALLBACK(cb_xfdesktop_chk_apply_to_all),
background_settings);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.