diff options
Diffstat (limited to 'src/file-manager')
| -rw-r--r-- | src/file-manager/Makefile.am | 2 | ||||
| -rw-r--r-- | src/file-manager/fm-desktop-icon-view.c | 125 | ||||
| -rw-r--r-- | src/file-manager/fm-desktop-wayland-bg-dialog.c | 471 | ||||
| -rw-r--r-- | src/file-manager/fm-desktop-wayland-bg-dialog.h | 28 | ||||
| -rw-r--r-- | src/file-manager/fm-directory-view.c | 4 | ||||
| -rw-r--r-- | src/file-manager/fm-icon-view.c | 44 | ||||
| -rw-r--r-- | src/file-manager/fm-list-view.c | 8 | ||||
| -rw-r--r-- | src/file-manager/fm-properties-window.c | 60 | ||||
| -rw-r--r-- | src/file-manager/fm-tree-model.c | 8 | ||||
| -rw-r--r-- | src/file-manager/fm-tree-view.c | 7 |
10 files changed, 669 insertions, 88 deletions
diff --git a/src/file-manager/Makefile.am b/src/file-manager/Makefile.am index 98173976..3707409c 100644 --- a/src/file-manager/Makefile.am +++ b/src/file-manager/Makefile.am @@ -23,6 +23,8 @@ libcaja_file_manager_la_SOURCES = \ fm-actions.h \ fm-desktop-icon-view.c \ fm-desktop-icon-view.h \ + fm-desktop-wayland-bg-dialog.c \ + fm-desktop-wayland-bg-dialog.h \ fm-directory-view.c \ fm-directory-view.h \ fm-widget-view.c \ diff --git a/src/file-manager/fm-desktop-icon-view.c b/src/file-manager/fm-desktop-icon-view.c index a90f884f..954c26de 100644 --- a/src/file-manager/fm-desktop-icon-view.c +++ b/src/file-manager/fm-desktop-icon-view.c @@ -62,6 +62,12 @@ #include "fm-desktop-icon-view.h" #include "fm-actions.h" +#ifdef HAVE_WAYLAND +#include <gdk/gdkwayland.h> +#include "fm-desktop-wayland-bg-dialog.h" + +#endif + /* Timeout to check the desktop directory for updates */ #define RESCAN_TIMEOUT 4 @@ -120,13 +126,27 @@ icon_container_set_workarea (CajaIconContainer *icon_container, int screen_width, screen_height; int scale; int i; + GdkDisplay *display; left = right = top = bottom = 0; - scale = gdk_window_get_scale_factor (gdk_screen_get_root_window (screen)); - - screen_width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale; - screen_height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale; + display = gdk_screen_get_display (screen); + if (GDK_IS_X11_DISPLAY (display)) + { + scale = gdk_window_get_scale_factor (gdk_screen_get_root_window (screen)); + screen_width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale; + screen_height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale; + } + else + { + scale = 1; /*wayland handles this for us*/ + GdkRectangle geometry = {0}; + GdkMonitor *monitor; + monitor = gdk_display_get_monitor (display, 0); + gdk_monitor_get_geometry (monitor, &geometry); + screen_width = geometry.width; + screen_height = geometry.height; + } for (i = 0; i < n_items; i += 4) { @@ -148,6 +168,7 @@ icon_container_set_workarea (CajaIconContainer *icon_container, left, right, top, bottom); } +/*This code is only reached when running in x11*/ static void net_workarea_changed (FMDesktopIconView *icon_view, GdkWindow *window) @@ -239,6 +260,7 @@ net_workarea_changed (FMDesktopIconView *icon_view, g_free (workareas); } +/*This code is reached only in x11*/ static GdkFilterReturn desktop_icon_view_property_filter (GdkXEvent *gdk_xevent, GdkEvent *event, @@ -258,7 +280,6 @@ desktop_icon_view_property_filter (GdkXEvent *gdk_xevent, default: break; } - return GDK_FILTER_CONTINUE; } @@ -317,6 +338,7 @@ fm_desktop_icon_view_class_init (FMDesktopIconViewClass *class) FM_ICON_VIEW_CLASS (class)->supports_labels_beside_icons = real_supports_labels_beside_icons; } +/*This code is only reached when running on x11*/ static void fm_desktop_icon_view_handle_middle_click (CajaIconContainer *icon_container, GdkEventButton *event, @@ -373,6 +395,9 @@ fm_desktop_icon_view_handle_middle_click (CajaIconContainer *icon_container, static void unrealized_callback (GtkWidget *widget, FMDesktopIconView *desktop_icon_view) { + if (!GDK_IS_X11_DISPLAY (gdk_display_get_default())) + return; + g_return_if_fail (desktop_icon_view->priv->root_window != NULL); /* Remove the property filter */ @@ -387,13 +412,13 @@ realized_callback (GtkWidget *widget, FMDesktopIconView *desktop_icon_view) { GdkWindow *root_window; GdkScreen *screen; + GdkDisplay *display; GtkAllocation allocation; - gint scale; g_return_if_fail (desktop_icon_view->priv->root_window == NULL); screen = gtk_widget_get_screen (widget); - scale = gtk_widget_get_scale_factor (widget); + display = gdk_screen_get_display (screen); /* Ugly HACK for the problem that the views realize at the * wrong size and then get resized. (This is a problem with @@ -403,24 +428,46 @@ realized_callback (GtkWidget *widget, FMDesktopIconView *desktop_icon_view) */ allocation.x = 0; allocation.y = 0; - allocation.width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale; - allocation.height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale; + if (GDK_IS_X11_DISPLAY (display)) + { + gint scale; + scale = gtk_widget_get_scale_factor (widget); + allocation.width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale; + allocation.height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale; + } + else + { + /*No real root window or primary monitor in wayland unless compositors add it back*/ + GdkRectangle geometry = {0}; + GdkMonitor *monitor; + monitor = gdk_display_get_monitor (display, 0); + gdk_monitor_get_geometry (monitor, &geometry); + allocation.width = geometry.width; + allocation.height = geometry.height; + } + gtk_widget_size_allocate (GTK_WIDGET(get_icon_container(desktop_icon_view)), &allocation); - root_window = gdk_screen_get_root_window (screen); - - desktop_icon_view->priv->root_window = root_window; + if (GDK_IS_X11_DISPLAY (display)) + { + root_window = gdk_screen_get_root_window (screen); + desktop_icon_view->priv->root_window = root_window; - /* Read out the workarea geometry and update the icon container accordingly */ - net_workarea_changed (desktop_icon_view, root_window); + /* Read out the workarea geometry and update the icon container accordingly */ + net_workarea_changed (desktop_icon_view, root_window); - /* Setup the property filter */ - gdk_window_set_events (root_window, GDK_PROPERTY_CHANGE_MASK); - gdk_window_add_filter (root_window, - desktop_icon_view_property_filter, - desktop_icon_view); + /* Setup the property filter */ + gdk_window_set_events (root_window, GDK_PROPERTY_CHANGE_MASK); + gdk_window_add_filter (root_window, + desktop_icon_view_property_filter, + desktop_icon_view); + } + else + { + desktop_icon_view->priv->root_window = NULL; + } } static CajaZoomLevel @@ -610,8 +657,13 @@ fm_desktop_icon_view_init (FMDesktopIconView *desktop_icon_view) CAJA_ICON_LAYOUT_T_B_R_L : CAJA_ICON_LAYOUT_T_B_L_R); - g_signal_connect_object (icon_container, "middle_click", - G_CALLBACK (fm_desktop_icon_view_handle_middle_click), desktop_icon_view, 0); + /*Handle the middle click on x11 */ + if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) + { + g_signal_connect_object (desktop_icon_view, "middle_click", + G_CALLBACK (fm_desktop_icon_view_handle_middle_click), desktop_icon_view, 0); + } + g_signal_connect_object (desktop_icon_view, "realize", G_CALLBACK (realized_callback), desktop_icon_view, 0); g_signal_connect_object (desktop_icon_view, "unrealize", @@ -661,12 +713,31 @@ action_change_background_callback (GtkAction *action, gpointer data) { g_assert (FM_DIRECTORY_VIEW (data)); - - caja_launch_application_from_command (gtk_widget_get_screen (GTK_WIDGET (data)), - _("Background"), - "mate-appearance-properties", - FALSE, - "--show-page=background", NULL); +#ifdef HAVE_WAYLAND + /*Get the new background and switch to it in wayland*/ + if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default())) + { + /*We can use the appearance capplet with some versions of mate-control-center + *in which the appearance capplet works in wayland + *Try it first, and fall back to the standalone dialog if it fails + */ + GError *error = NULL; + + g_spawn_command_line_async ("mate-appearance-properties --show-page=background", + &error); + if (error != NULL) + wayland_bg_dialog_new (); + } + else +#endif + /*Get the new background and switch to it in x11*/ + { + caja_launch_application_from_command (gtk_widget_get_screen (GTK_WIDGET (data)), + _("Background"), + "mate-appearance-properties", + FALSE, + "--show-page=background", NULL); + } } static void diff --git a/src/file-manager/fm-desktop-wayland-bg-dialog.c b/src/file-manager/fm-desktop-wayland-bg-dialog.c new file mode 100644 index 00000000..127baff3 --- /dev/null +++ b/src/file-manager/fm-desktop-wayland-bg-dialog.c @@ -0,0 +1,471 @@ + +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* fm-desktop-wayland-bg-dialog.c background changing dialog for wayland + + Copyright (C) 2024 Luke <[email protected]> + + The Mate Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Mate Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the Mate Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. + + Author: <[email protected]> +*/ + +#include <config.h> +#include <fcntl.h> +#include <limits.h> +#include <stddef.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> + +#include <X11/Xatom.h> +#include <gtk/gtk.h> +#include <gdk/gdkx.h> +#include <glib/gi18n.h> +#include <sys/stat.h> +#include <sys/types.h> + +#include <eel/eel-glib-extensions.h> +#include <eel/eel-gtk-extensions.h> +#include <eel/eel-vfs-extensions.h> + +#include <libcaja-private/caja-directory-background.h> +#include <libcaja-private/caja-global-preferences.h> + +#include "fm-desktop-icon-view.h" +#include "fm-desktop-wayland-bg-dialog.h" + + +#ifdef HAVE_WAYLAND + +GSettings *background_settings; + +static void +update_preview (gboolean starting, GtkWidget *box, gchar *filename, + const gchar *shading_type, gchar *primary_color_str, gchar *secondary_color_str) +{ + static GtkWidget *preview_image; + static GtkCssProvider *provider; + gchar *css; + GString *string; + static GdkRectangle geometry = {0}; + + /* setup the preview only once*/ + if (starting == TRUE) + { + static GtkWidget *preview; + + /*Get the size and shape of the desktop*/ + GdkDisplay *display = gdk_screen_get_display (gdk_screen_get_default()); + GdkMonitor *monitor = gdk_display_get_monitor (display, 0); + gdk_monitor_get_geometry (monitor, &geometry); + + preview = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); + gtk_widget_set_size_request (preview, geometry.width / 5, geometry.height / 5); + gtk_widget_set_name (GTK_WIDGET (preview), "caja-wayland-bg-preview"); + + preview_image = gtk_image_new (); + provider = gtk_css_provider_new (); + gtk_style_context_add_provider (gtk_widget_get_style_context (preview), + GTK_STYLE_PROVIDER (provider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + gtk_box_pack_start (GTK_BOX (preview), preview_image, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (box), preview, FALSE, FALSE, 0); + } + + /* No image filename means we are previewing a color or gradient background*/ + if ((!filename) || (strcmp (filename, "") == 0) || (strcmp (filename, " ") == 0)) + { + if (GTK_IS_IMAGE(preview_image)) + gtk_image_clear (GTK_IMAGE(preview_image)); + + /*Build a color preview using a cssprovider due to requirement to handle RBGA values*/ + string = g_string_new(NULL); + g_string_append (string, "#caja-wayland-bg-preview {"); + + if (strcmp (shading_type, "vertical-gradient") == 0) + g_string_append (string, "background-image: linear-gradient(to bottom,"); + + else if (strcmp (shading_type, "horizontal-gradient") == 0) + g_string_append (string, "background-image: linear-gradient(to right,"); + + else + { + g_string_append (string, "background-color:"); + g_string_append (string, primary_color_str); + } + + if ((strcmp (shading_type, "vertical-gradient") == 0) || + (strcmp (shading_type, "horizontal-gradient") == 0)) + { + g_string_append (string, primary_color_str); + g_string_append (string, ","); + g_string_append (string, secondary_color_str); + g_string_append (string, ");"); + } + g_string_append (string, "}"); + + css = g_string_free (string, FALSE); + + gtk_css_provider_load_from_data (provider, css, -1, NULL); + + g_free (css); + } + else + /*Preview a background image*/ + { + GdkPixbuf *pixbuf; + + pixbuf = gdk_pixbuf_new_from_file_at_scale (filename, geometry.width / 5, + geometry.height / 5, TRUE, NULL); + + if (GTK_IS_IMAGE(preview_image)) + gtk_image_set_from_pixbuf (GTK_IMAGE (preview_image), pixbuf); + + /*Clear the color preview*/ + string = g_string_new (NULL); + g_string_append (string, "#caja-wayland-bg-preview {"); + + g_string_append (string, "background-image: none;"); + g_string_append (string, "background-color: transparent;"); + g_string_append (string, "}"); + + css = g_string_free (string, FALSE); + gtk_css_provider_load_from_data (provider, css, -1, NULL); + + g_free (css); + g_object_unref (pixbuf); + } +} + +static void +update_primary_color (GtkWidget *colorbutton1) +{ + gchar *shading_type, *primary_color_str, *secondary_color_str; + GdkRGBA color1; + + shading_type = g_settings_get_string (background_settings, + "color-shading-type"); + + secondary_color_str = g_settings_get_string (background_settings, + "secondary-color"); + + gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (colorbutton1), &color1); + primary_color_str = gdk_rgba_to_string (&color1); + + update_preview (FALSE, NULL, "", shading_type, + primary_color_str, secondary_color_str); + + g_settings_set_string (background_settings, + "primary-color", primary_color_str); + + g_settings_set_string (background_settings, + "picture-filename", ""); + + g_free (shading_type); + g_free (primary_color_str); + g_free (secondary_color_str); +} + +static void +update_secondary_color (GtkWidget *colorbutton2) +{ + gchar *shading_type, *primary_color_str, *secondary_color_str; + GdkRGBA color2; + + shading_type = g_settings_get_string (background_settings, + "color-shading-type"); + + primary_color_str = g_settings_get_string (background_settings, + "primary-color"); + + gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (colorbutton2), &color2); + secondary_color_str = gdk_rgba_to_string (&color2); + + g_settings_set_string (background_settings, + "secondary-color", secondary_color_str); + + g_settings_set_string (background_settings, + "picture-filename", ""); + + update_preview (FALSE, NULL, "", shading_type, + primary_color_str, secondary_color_str); + + g_free (shading_type); + g_free (primary_color_str); + g_free (secondary_color_str); +} + +static void +update_color_background_options (GtkWidget *colorbox) +{ + gchar *primary_color_str, *secondary_color_str; + const gchar *shading_type; + + primary_color_str = g_settings_get_string (background_settings, + "primary-color"); + + secondary_color_str = g_settings_get_string (background_settings, + "secondary-color"); + + shading_type = gtk_combo_box_get_active_id (GTK_COMBO_BOX (colorbox)); + /*write to gsettings*/ + g_settings_set_string (background_settings, + "color-shading-type", shading_type); + g_settings_set_string (background_settings, + "picture-filename", ""); + + update_preview (FALSE, NULL, "", shading_type, + primary_color_str, secondary_color_str); + + g_free (primary_color_str); + g_free (secondary_color_str); +} + +static void +update_image_background_options(GtkWidget *stylebox) +{ + const gchar *options; + options = gtk_combo_box_get_active_id (GTK_COMBO_BOX(stylebox)); + + /*write to gsettings*/ + g_settings_set_string (background_settings, + "picture-options", options); + + /*Only the image changes here, we are not thumbnailing image options yet*/ +} + +static void +update_background_image (GtkWidget *filebutton) +{ + gchar *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filebutton)); + if (strcmp (filename, " ") == 0) + filename = ""; + + /*write to gsettings*/ + g_settings_set_string (background_settings, + "picture-filename", filename); + + update_preview (FALSE, NULL, filename, NULL, NULL, NULL); + g_free (filename); +} + +void +wayland_bg_dialog_new (void) +{ + GtkWidget *dialog, *box, *vbox1, *vbox2, *hbox1, *hbox2; + GtkWidget *close_button, *colorlabel, *stylelabel; + GtkWidget *filelabel, *stylebox; + GtkWidget *colorbox, *colorbutton1, *colorbutton2; + GtkWidget *filebutton; + GdkRGBA color1, color2; + gchar *filename, *options; + gchar *shading_type, *primary_color_str, *secondary_color_str; + + background_settings = g_settings_new ("org.mate.background"); + + filename = g_settings_get_string (background_settings, + "picture-filename"); + + options = g_settings_get_string (background_settings, + "picture-options"); + + primary_color_str = g_settings_get_string (background_settings, + "primary-color"); + + secondary_color_str = g_settings_get_string (background_settings, + "secondary-color"); + + shading_type = g_settings_get_string (background_settings, + "color-shading-type"); + + dialog = gtk_dialog_new (); + gtk_window_set_title (GTK_WINDOW (dialog), + _("Desktop Background Preferences")); + + gtk_window_set_transient_for (GTK_WINDOW (dialog), NULL); + + /*Image Style Combobox*/ + stylebox = gtk_combo_box_text_new (); + + gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (stylebox), + "wallpaper", "Tile" ); + + gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (stylebox), + "zoom", "Zoom" ); + + gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (stylebox), + "centered", "Center"); + + gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (stylebox), + "scaled", "Scale"); + + gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (stylebox), + "stretched", "Stretch"); + + gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (stylebox), + "spanned", "Span"); + + gtk_combo_box_set_active_id (GTK_COMBO_BOX (stylebox), options); + + g_signal_connect (stylebox, "changed", + G_CALLBACK (update_image_background_options), stylebox); + + gtk_widget_set_tooltip_text (stylebox, "Image Aspect Ratio and Size. \n" + "Changes applied immediately"); + + /*Color Combobox*/ + colorlabel = gtk_label_new ("Colors:"); + colorbox = gtk_combo_box_text_new (); + + gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (colorbox), + "solid", "Solid color" ); + + gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (colorbox), + "horizontal-gradient", "Horizontal gradient" ); + + gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (colorbox), + "vertical-gradient", "Vertical gradient"); + + gtk_combo_box_set_active_id (GTK_COMBO_BOX (colorbox), shading_type); + + g_signal_connect (colorbox, "changed", + G_CALLBACK (update_color_background_options), colorbox); + + gtk_widget_set_tooltip_text (colorbox, "Use gradient or solid color. \n" + "Changes applied immediately"); + + colorbutton1 = gtk_color_button_new (); + colorbutton2 = gtk_color_button_new (); + gtk_widget_set_tooltip_text (colorbutton1, "Color for gradient top/left or solid color \n" + "Applies on selecting any color"); + + gtk_widget_set_tooltip_text (colorbutton2, "Color for gradient bottom/right\n" + "Applies on selecting any color"); + + + if (!(gdk_rgba_parse (&color1, primary_color_str))) + gdk_rgba_parse (&color1, "rgb(88,145,188)"); + + if (!(gdk_rgba_parse (&color2, secondary_color_str))) + gdk_rgba_parse (&color2, "rgb(60,143,37)"); + + gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (colorbutton1), &color1); + gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (colorbutton2), &color2); + + g_signal_connect (colorbutton1, "color-set", + G_CALLBACK (update_primary_color), colorbutton1); + + g_signal_connect (colorbutton2, "color-set", + G_CALLBACK (update_secondary_color), colorbutton1); + + /*file chooser and it's label for the color bg case*/ + filelabel = gtk_label_new ("Image:"); + stylelabel = gtk_label_new ("Style:"); + filebutton = gtk_file_chooser_button_new (_("Select a file"), + GTK_FILE_CHOOSER_ACTION_OPEN); + + gtk_widget_set_tooltip_text (filebutton, "Image for desktop background. \n" + "Applies on opening image"); + + gtk_file_chooser_button_set_width_chars (GTK_FILE_CHOOSER_BUTTON (filebutton), 16); + + gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (filebutton), + filename); + + gtk_file_chooser_button_set_title (GTK_FILE_CHOOSER_BUTTON (filebutton), + "Select a File"); + + /* If the last background was an image show the user the default background directory*/ + if ((!filename) || (strcmp (filename, "") == 0) || (strcmp (filename, " ") == 0)) + { + gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (filebutton), "/usr/share/backgrounds/"); + } + + g_signal_connect (filebutton, "file-set", + G_CALLBACK (update_background_image), NULL); + + /*Apply and Cancel buttons */ + close_button = gtk_button_new_with_mnemonic (_("_Close")); + + gtk_button_set_image (GTK_BUTTON (close_button), + gtk_image_new_from_icon_name ("gtk-cancel", GTK_ICON_SIZE_BUTTON)); + + gtk_button_set_use_underline (GTK_BUTTON (close_button), TRUE); + gtk_widget_set_can_default (close_button, TRUE); + + /*Prepare the boxes to pack all this into*/ + box = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); + vbox1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); + vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); + hbox1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); + hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); + + /*Pack the filechooser and image options*/ + gtk_box_pack_start (GTK_BOX (hbox1), filelabel, FALSE, FALSE, 7); + gtk_box_pack_start (GTK_BOX (hbox1), filebutton, FALSE, FALSE, 3); + gtk_box_pack_end (GTK_BOX (hbox1), stylebox, FALSE, FALSE, 5); + gtk_box_pack_end (GTK_BOX (hbox1), stylelabel, FALSE, FALSE, 2); + + /*Pack the colorpickers and color options*/ + + gtk_box_pack_start (GTK_BOX (hbox2), colorlabel, FALSE, FALSE, 7); + gtk_box_pack_start (GTK_BOX (hbox2), colorbox, FALSE, FALSE, 5); + gtk_box_pack_end (GTK_BOX (hbox2), colorbutton2, FALSE, FALSE, 5); + gtk_box_pack_end (GTK_BOX (hbox2), colorbutton1, FALSE, FALSE, 2); + + /*Get the preview and pack it*/ + update_preview (TRUE, vbox2, filename, shading_type, + primary_color_str, secondary_color_str); + + gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0); + + /*Pack the other boxes into the final vertical box*/ + gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 20); + gtk_box_pack_start (GTK_BOX (vbox1), hbox2, FALSE, FALSE, 5); + + /*Pack the final vertical box into the content area*/ + gtk_box_pack_start (GTK_BOX (box), vbox1, FALSE, FALSE, 0); + + /*Pack the close action area*/ + + gtk_dialog_add_action_widget (GTK_DIALOG (dialog), + close_button, + GTK_RESPONSE_APPLY); + + gtk_widget_show_all (dialog); + + /*Run the dialog*/ + gtk_dialog_run (GTK_DIALOG (dialog)); + + /*cleanup*/ + g_free(filename); + g_free(options); + g_free(shading_type); + g_free(primary_color_str); + g_free(secondary_color_str); + + g_signal_handlers_disconnect_by_func (stylebox, update_image_background_options, stylebox); + g_signal_handlers_disconnect_by_func (colorbox, update_color_background_options, colorbox); + g_signal_handlers_disconnect_by_func (colorbutton1, update_primary_color, colorbutton1); + g_signal_handlers_disconnect_by_func (colorbutton2, update_primary_color, colorbutton2); + g_signal_handlers_disconnect_by_func (filebutton, update_background_image, NULL); + + g_object_unref (background_settings); + gtk_widget_destroy (dialog); +} +#endif + diff --git a/src/file-manager/fm-desktop-wayland-bg-dialog.h b/src/file-manager/fm-desktop-wayland-bg-dialog.h new file mode 100644 index 00000000..7c6b6c5c --- /dev/null +++ b/src/file-manager/fm-desktop-wayland-bg-dialog.h @@ -0,0 +1,28 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* fm-desktop-wayland-bg-dialog.h + + Copyright (C) 2024 Luke <[email protected]> + + The Mate Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Mate Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the Mate Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. + + Author: Luke <[email protected]> +*/ +#ifdef HAVE_WAYLAND +#include "fm-desktop-icon-view.h" + +void wayland_bg_dialog_new (void); +#endif diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c index ddaa334c..c76eefba 100644 --- a/src/file-manager/fm-directory-view.c +++ b/src/file-manager/fm-directory-view.c @@ -2351,9 +2351,9 @@ fm_directory_view_display_selection_info (FMDirectoryView *view) char *size_string; if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_USE_IEC_UNITS)) - size_string = g_format_size_full (non_folder_size, G_FORMAT_SIZE_IEC_UNITS); + size_string = g_format_size_full ((guint64) non_folder_size, G_FORMAT_SIZE_IEC_UNITS); else - size_string = g_format_size(non_folder_size); + size_string = g_format_size ((guint64) non_folder_size); /* Translators: This is marked for translation in case a localiser * needs to use something other than parentheses. The diff --git a/src/file-manager/fm-icon-view.c b/src/file-manager/fm-icon-view.c index 1843fd2e..83517273 100644 --- a/src/file-manager/fm-icon-view.c +++ b/src/file-manager/fm-icon-view.c @@ -80,8 +80,6 @@ typedef struct const CajaFileSortType sort_type; const char *metadata_text; const char *action; - const char *menu_label; - const char *menu_hint; } SortCriterion; typedef enum @@ -125,65 +123,47 @@ static const SortCriterion sort_criteria[] = { CAJA_FILE_SORT_BY_DISPLAY_NAME, "name", - "Sort by Name", - N_("by _Name"), - N_("Keep icons sorted by name in rows") + "Sort by Name" }, { CAJA_FILE_SORT_BY_SIZE, "size", - "Sort by Size", - N_("by _Size"), - N_("Keep icons sorted by size in rows") + "Sort by Size" }, { CAJA_FILE_SORT_BY_SIZE_ON_DISK, "size_on_disk", - "Sort by Size on Disk", - N_("by S_ize on Disk"), - N_("Keep icons sorted by disk usage in rows") + "Sort by Size on Disk" }, { CAJA_FILE_SORT_BY_TYPE, "type", - "Sort by Type", - N_("by _Type"), - N_("Keep icons sorted by type in rows") + "Sort by Type" }, { CAJA_FILE_SORT_BY_MTIME, "modification date", - "Sort by Modification Date", - N_("by Modification _Date"), - N_("Keep icons sorted by modification date in rows") + "Sort by Modification Date" }, { CAJA_FILE_SORT_BY_BTIME, "creation date", - "Sort by Creation Date", - N_("by _Creation Date"), - N_("Keep icons sorted by creation date in rows") + "Sort by Creation Date" }, { CAJA_FILE_SORT_BY_EMBLEMS, "emblems", - "Sort by Emblems", - N_("by _Emblems"), - N_("Keep icons sorted by emblems in rows") + "Sort by Emblems" }, { CAJA_FILE_SORT_BY_TRASHED_TIME, "trashed", - "Sort by Trash Time", - N_("by T_rash Time"), - N_("Keep icons sorted by trash time in rows") + "Sort by Trash Time" }, { CAJA_FILE_SORT_BY_EXTENSION, "extension", - "Sort by Extension", - N_("by E_xtension"), - N_("Keep icons sorted by reversed extension segments in rows") + "Sort by Extension" } }; @@ -1694,11 +1674,17 @@ action_lock_icons_position_callback (GtkAction *action, FMIconView *icon_view; CajaFile *file; gboolean lock_icons_position; + GtkAction *action_other; icon_view = FM_ICON_VIEW (user_data); lock_icons_position = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)); + action_other = gtk_action_group_get_action (icon_view->details->icon_action_group, + FM_ACTION_CLEAN_UP); + gtk_action_set_visible (action_other, !lock_icons_position); + + file = fm_directory_view_get_directory_as_file (FM_DIRECTORY_VIEW (icon_view)); fm_icon_view_set_directory_lock_icons_position (icon_view, file, diff --git a/src/file-manager/fm-list-view.c b/src/file-manager/fm-list-view.c index 921128b0..b5a61459 100644 --- a/src/file-manager/fm-list-view.c +++ b/src/file-manager/fm-list-view.c @@ -179,12 +179,14 @@ get_default_sort_order (CajaFile *file, gboolean *reversed) "name", "uri", "size", - "size_on_disk", "type", "date_modified", + "date_created", "date_accessed", "emblems", "trashed_on", + "size_on_disk", + "extension", NULL }; @@ -1296,11 +1298,11 @@ sort_column_changed_callback (GtkTreeSortable *sortable, if (sort_attr == default_sort_attr) { /* use value from preferences */ - reversed = g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_DEFAULT_SORT_IN_REVERSE_ORDER); + reversed = (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_DEFAULT_SORT_IN_REVERSE_ORDER) != FALSE); } else { - reversed = caja_file_is_date_sort_attribute_q (sort_attr); + reversed = (caja_file_is_date_sort_attribute_q (sort_attr) != FALSE); } if (reversed) diff --git a/src/file-manager/fm-properties-window.c b/src/file-manager/fm-properties-window.c index 0ab2bfc7..e615e1fa 100644 --- a/src/file-manager/fm-properties-window.c +++ b/src/file-manager/fm-properties-window.c @@ -98,7 +98,6 @@ struct _FMPropertiesWindowPrivate { GtkLabel *name_label; GtkWidget *name_field; - unsigned int name_row; char *pending_name; GtkLabel *directory_contents_title_field; @@ -365,11 +364,13 @@ add_prompt_and_separator (GtkWidget *vbox, const char *prompt_text) static void get_image_for_properties_window (FMPropertiesWindow *window, char **icon_name, + char **display_name_, GdkPixbuf **icon_pixbuf) { CajaIconInfo *icon, *new_icon; GList *l; gint icon_scale; + gchar *display_name = NULL; icon = NULL; icon_scale = gtk_widget_get_scale_factor (GTK_WIDGET (window->details->notebook)); @@ -383,6 +384,7 @@ get_image_for_properties_window (FMPropertiesWindow *window, icon = caja_file_get_icon (file, CAJA_ICON_SIZE_STANDARD, icon_scale, CAJA_FILE_ICON_FLAGS_USE_THUMBNAILS | CAJA_FILE_ICON_FLAGS_IGNORE_VISITING); + display_name = caja_file_get_string_attribute (file, "type"); } else { new_icon = caja_file_get_icon (file, CAJA_ICON_SIZE_STANDARD, icon_scale, CAJA_FILE_ICON_FLAGS_USE_THUMBNAILS | @@ -391,6 +393,8 @@ get_image_for_properties_window (FMPropertiesWindow *window, g_object_unref (icon); g_object_unref (new_icon); icon = NULL; + g_free (display_name); + display_name = g_strdup (_("Multiple files")); break; } g_object_unref (new_icon); @@ -407,11 +411,23 @@ get_image_for_properties_window (FMPropertiesWindow *window, *icon_name = g_strdup (caja_icon_info_get_used_name (icon)); } + if (display_name_ != NULL) { + if (! display_name) { + display_name = g_strdup (_("No files")); + } else if (! caja_icon_info_get_used_name (icon)) { + g_free (display_name); + display_name = g_strdup (_("User-defined icon")); + } + *display_name_ = display_name; + display_name = NULL; + } + if (icon_pixbuf != NULL) { *icon_pixbuf = caja_icon_info_get_pixbuf_at_size (icon, CAJA_ICON_SIZE_STANDARD); } g_object_unref (icon); + g_free (display_name); } static void @@ -420,8 +436,9 @@ update_properties_window_icon (FMPropertiesWindow *window) GdkPixbuf *pixbuf; cairo_surface_t *surface; char *name; + char *display_name; - get_image_for_properties_window (window, &name, &pixbuf); + get_image_for_properties_window (window, &name, &display_name, &pixbuf); if (name != NULL) { gtk_window_set_icon_name (GTK_WINDOW (window), name); @@ -433,7 +450,10 @@ update_properties_window_icon (FMPropertiesWindow *window) gtk_widget_get_window (GTK_WIDGET (window))); gtk_image_set_from_surface (GTK_IMAGE (window->details->icon_image), surface); + atk_object_set_name (gtk_widget_get_accessible (window->details->icon_image), display_name); + g_free (name); + g_free (display_name); g_object_unref (pixbuf); cairo_surface_destroy (surface); } @@ -548,7 +568,8 @@ create_image_widget (FMPropertiesWindow *window, button = NULL; if (is_customizable) { button = gtk_button_new (); - gtk_container_add (GTK_CONTAINER (button), image); + gtk_widget_set_tooltip_text (button, _("Change associated icon")); + gtk_button_set_image (GTK_BUTTON (button), image); /* prepare the image to receive dropped objects to assign custom images */ gtk_drag_dest_set (GTK_WIDGET (image), @@ -4139,7 +4160,7 @@ permission_combo_update (FMPropertiesWindow *window, int current_perm; gtk_tree_model_get (model, &iter, 1, ¤t_perm, -1); - if (current_perm == all_perm) { + if (((PermissionValue) current_perm) == all_perm) { found = TRUE; break; } @@ -4224,13 +4245,23 @@ add_permissions_combo_box (FMPropertiesWindow *window, GtkGrid *grid, GtkListStore *store; GtkCellRenderer *cell; GtkTreeIter iter; + AtkObject *atk_object; + static const gchar *const descriptions[4][3] = { + { N_("Access:"), N_("Folder access:"), N_("File access:") }, + /* As the UI lacks semantic grouping, provide more context for accessibility */ + { N_("User access:"), N_("User folder access:"), N_("User file access:") }, + { N_("Group access:"), N_("Group folder access:"), N_("Group file access:") }, + { N_("Others access:"), N_("Others folder access:"), N_("Others file access:") } + }; + const guint group = short_label ? 0 : is_folder ? 1 : 2; - if (short_label) { - label = attach_title_field (grid, _("Access:")); - } else if (is_folder) { - label = attach_title_field (grid, _("Folder access:")); - } else { - label = attach_title_field (grid, _("File access:")); + g_return_if_fail (type + 1 < G_N_ELEMENTS (descriptions)); + + label = attach_title_field (grid, _(descriptions[0][group])); + + atk_object = gtk_widget_get_accessible (GTK_WIDGET (label)); + if (GTK_IS_ACCESSIBLE (atk_object)) { + atk_object_set_name (atk_object, _(descriptions[type + 1][group])); } store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_INT, G_TYPE_BOOLEAN); @@ -5675,14 +5706,17 @@ update_preview_callback (GtkFileChooser *icon_chooser, if (gdk_pixbuf_get_width (pixbuf) > PREVIEW_IMAGE_WIDTH) { double scale; + gint height; + gint width; - scale = (double)gdk_pixbuf_get_height (pixbuf) / - gdk_pixbuf_get_width (pixbuf); + height = gdk_pixbuf_get_height (pixbuf); + width = gdk_pixbuf_get_width (pixbuf); + scale = ((double) height) / ((double) width); scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf, PREVIEW_IMAGE_WIDTH, - scale * PREVIEW_IMAGE_WIDTH, + (int) (scale * (double) PREVIEW_IMAGE_WIDTH), GDK_INTERP_HYPER); g_object_unref (pixbuf); pixbuf = scaled_pixbuf; diff --git a/src/file-manager/fm-tree-model.c b/src/file-manager/fm-tree-model.c index 017d9f8c..fba39e1c 100644 --- a/src/file-manager/fm-tree-model.c +++ b/src/file-manager/fm-tree-model.c @@ -119,12 +119,6 @@ struct FMTreeModelRoot TreeNode *root_node; }; -typedef struct -{ - CajaDirectory *directory; - FMTreeModel *model; -} DoneLoadingParameters; - static void fm_tree_model_tree_model_init (GtkTreeModelIface *iface); static void schedule_monitoring_update (FMTreeModel *model); static void destroy_node_without_reporting (FMTreeModel *model, @@ -1101,7 +1095,7 @@ set_done_loading (FMTreeModel *model, TreeNode *node, gboolean done_loading) had_dummy = tree_node_has_dummy_child (node); - node->done_loading = done_loading; + node->done_loading = (done_loading != FALSE); if (tree_node_has_dummy_child (node)) { diff --git a/src/file-manager/fm-tree-view.c b/src/file-manager/fm-tree-view.c index 2e7cfbb5..a01f91e8 100644 --- a/src/file-manager/fm-tree-view.c +++ b/src/file-manager/fm-tree-view.c @@ -101,7 +101,6 @@ struct FMTreeViewDetails GtkWidget *popup_cut; GtkWidget *popup_copy; GtkWidget *popup_paste; - GtkWidget *popup_rename; GtkWidget *popup_trash; GtkWidget *popup_delete; GtkWidget *popup_properties; @@ -114,12 +113,6 @@ struct FMTreeViewDetails guint selection_changed_timer; }; -typedef struct -{ - GList *uris; - FMTreeView *view; -} PrependURIParameters; - static GdkAtom copied_files_atom; static void fm_tree_view_iface_init (CajaSidebarIface *iface); |
