From 922e0c1daea2778c5ff14546b0912ae9b30b6eda Mon Sep 17 00:00:00 2001 From: Maoschanz Date: Tue, 15 Jan 2019 17:27:03 +0000 Subject: [PATCH] Update the UI to match current guidelines --- src/disks/gduapplication.c | 50 +- src/disks/gduwindow.c | 857 ++++++++++++---------------- src/disks/gnome-disks.gresource.xml | 6 +- src/disks/ui/app-menu.ui | 16 +- src/disks/ui/disks.ui | 218 +------ src/disks/ui/drive-menu.ui | 49 ++ src/disks/ui/headerbar.ui | 95 +++ src/disks/ui/shortcuts.ui | 108 ++++ src/disks/ui/volume-menu.ui | 63 ++ 9 files changed, 740 insertions(+), 722 deletions(-) create mode 100644 src/disks/ui/drive-menu.ui create mode 100644 src/disks/ui/headerbar.ui create mode 100644 src/disks/ui/shortcuts.ui create mode 100644 src/disks/ui/volume-menu.ui diff --git a/src/disks/gduapplication.c b/src/disks/gduapplication.c index 5ca8657c..a319e394 100644 --- a/src/disks/gduapplication.c +++ b/src/disks/gduapplication.c @@ -315,6 +315,23 @@ attach_disk_image_activated (GSimpleAction *action, gdu_window_show_attach_disk_image (app->window); } +static void +shortcuts_activated (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) +{ + GduApplication *app = GDU_APPLICATION (user_data); + GtkWidget *dialog; + + dialog = GTK_WIDGET (gdu_application_new_widget (app, + "shortcuts.ui", + "shortcuts", + NULL)); + + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (app->window)); + gtk_widget_show_all (dialog); +} + static void about_activated (GSimpleAction *action, GVariant *parameter, @@ -377,8 +394,9 @@ static GActionEntry app_entries[] = { { "new_disk_image", new_disk_image_activated, NULL, NULL, NULL }, { "attach_disk_image", attach_disk_image_activated, NULL, NULL, NULL }, - { "about", about_activated, NULL, NULL, NULL }, + { "shortcuts", shortcuts_activated, NULL, NULL, NULL }, { "help", help_activated, NULL, NULL, NULL }, + { "about", about_activated, NULL, NULL, NULL }, { "quit", quit_activated, NULL, NULL, NULL } }; @@ -386,21 +404,33 @@ static void gdu_application_startup (GApplication *_app) { GduApplication *app = GDU_APPLICATION (_app); - GMenuModel *app_menu; - GtkBuilder *builder; + const gchar **it; + const gchar *action_accels[] = { + "win.open-drive-menu", "F10", NULL, + "win.open-volume-menu", "F10", NULL, + + "win.format-disk", "D", NULL, + "win.restore-disk-image", "R", NULL, + "win.view-smart", "S", NULL, + "win.disk-settings", "E", NULL, + + "win.format-partition", "P", NULL, + + "app.new_disk_image", "N", NULL, + "app.attach_disk_image", "A", NULL, + + "app.help", "F1", NULL, + "app.quit", "Q", NULL, + NULL + }; if (G_APPLICATION_CLASS (gdu_application_parent_class)->startup != NULL) G_APPLICATION_CLASS (gdu_application_parent_class)->startup (_app); g_action_map_add_action_entries (G_ACTION_MAP (app), app_entries, G_N_ELEMENTS (app_entries), app); - app_menu = G_MENU_MODEL (gdu_application_new_widget (app, - "app-menu.ui", - "app-menu", - &builder)); - gtk_application_set_app_menu (GTK_APPLICATION (app), app_menu); - g_object_unref (app_menu); - g_clear_object (&builder); + for (it = action_accels; it[0] != NULL; it += g_strv_length ((gchar **)it) + 1) + gtk_application_set_accels_for_action (GTK_APPLICATION (app), it[0], &it[1]); } /* ---------------------------------------------------------------------------------------------------- */ diff --git a/src/disks/gduwindow.c b/src/disks/gduwindow.c index 3b43bc32..f7b1d753 100644 --- a/src/disks/gduwindow.c +++ b/src/disks/gduwindow.c @@ -59,7 +59,7 @@ struct _GduWindow GtkWidget *volume_grid; - GtkWidget *toolbutton_generic_menu; + GtkWidget *toolbutton_volume_menu; GtkWidget *toolbutton_partition_create; GtkWidget *toolbutton_partition_delete; GtkWidget *toolbutton_mount; @@ -70,6 +70,8 @@ struct _GduWindow GtkWidget *toolbutton_deactivate_swap; GtkWidget *header; + GtkWidget *right_header; + GtkWidget *left_header; GtkWidget *main_box; GtkWidget *main_hpane; @@ -77,44 +79,22 @@ struct _GduWindow GtkWidget *device_tree_scrolledwindow; GtkWidget *device_tree_treeview; + GtkWidget *devtab_app_menu_button; GtkWidget *devtab_drive_loop_detach_button; GtkWidget *devtab_drive_eject_button; GtkWidget *devtab_drive_power_off_button; - GtkWidget *devtab_drive_generic_button; + const gchar *icon_name; + GtkWidget *devtab_drive_menu_icon; + GtkWidget *devtab_drive_menu_button; GtkWidget *devtab_table; GtkWidget *devtab_drive_table; GtkWidget *devtab_grid_hbox; GtkWidget *devtab_volumes_label; GtkWidget *devtab_grid_toolbar; - GtkWidget *generic_drive_menu; - GtkWidget *generic_drive_menu_item_format_disk; - GtkWidget *generic_drive_menu_item_create_disk_image; - GtkWidget *generic_drive_menu_item_restore_disk_image; - GtkWidget *generic_drive_menu_item_benchmark; - /* Drive-specific items */ - GtkWidget *generic_drive_menu_item_drive_sep_1; - GtkWidget *generic_drive_menu_item_view_smart; - GtkWidget *generic_drive_menu_item_disk_settings; - GtkWidget *generic_drive_menu_item_drive_sep_2; - GtkWidget *generic_drive_menu_item_standby_now; - GtkWidget *generic_drive_menu_item_resume_now; - GtkWidget *generic_drive_menu_item_power_off; - - GtkWidget *generic_menu; - GtkWidget *generic_menu_item_configure_fstab; - GtkWidget *generic_menu_item_configure_crypttab; - GtkWidget *generic_menu_item_change_passphrase; - GtkWidget *generic_menu_item_resize; - GtkWidget *generic_menu_item_repair; - GtkWidget *generic_menu_item_check; - GtkWidget *generic_menu_item_separator; - GtkWidget *generic_menu_item_edit_label; - GtkWidget *generic_menu_item_edit_partition; - GtkWidget *generic_menu_item_format_volume; - GtkWidget *generic_menu_item_create_volume_image; - GtkWidget *generic_menu_item_restore_volume_image; - GtkWidget *generic_menu_item_benchmark; + GtkWidget *app_menu; + GtkWidget *drive_menu; + GtkWidget *volume_menu; GtkWidget *devtab_loop_autoclear_switch; @@ -140,7 +120,7 @@ static const struct { goffset offset; const gchar *name; } widget_mapping[] = { - {G_STRUCT_OFFSET (GduWindow, toolbutton_generic_menu), "toolbutton-generic-menu"}, + {G_STRUCT_OFFSET (GduWindow, toolbutton_volume_menu), "toolbutton-volume-menu"}, {G_STRUCT_OFFSET (GduWindow, toolbutton_partition_create), "toolbutton-partition-create"}, {G_STRUCT_OFFSET (GduWindow, toolbutton_partition_delete), "toolbutton-partition-delete"}, {G_STRUCT_OFFSET (GduWindow, toolbutton_mount), "toolbutton-mount"}, @@ -164,35 +144,6 @@ static const struct { {G_STRUCT_OFFSET (GduWindow, devtab_loop_autoclear_switch), "devtab-loop-autoclear-switch"}, - {G_STRUCT_OFFSET (GduWindow, generic_drive_menu), "generic-drive-menu"}, - {G_STRUCT_OFFSET (GduWindow, generic_drive_menu_item_format_disk), "generic-drive-menu-item-format-disk"}, - {G_STRUCT_OFFSET (GduWindow, generic_drive_menu_item_create_disk_image), "generic-drive-menu-item-create-disk-image"}, - {G_STRUCT_OFFSET (GduWindow, generic_drive_menu_item_restore_disk_image), "generic-drive-menu-item-restore-disk-image"}, - {G_STRUCT_OFFSET (GduWindow, generic_drive_menu_item_benchmark), "generic-drive-menu-item-benchmark"}, - /* Drive-specific items */ - {G_STRUCT_OFFSET (GduWindow, generic_drive_menu_item_drive_sep_1), "generic-drive-menu-item-drive-sep-1"}, - {G_STRUCT_OFFSET (GduWindow, generic_drive_menu_item_view_smart), "generic-drive-menu-item-view-smart"}, - {G_STRUCT_OFFSET (GduWindow, generic_drive_menu_item_disk_settings), "generic-drive-menu-item-disk-settings"}, - {G_STRUCT_OFFSET (GduWindow, generic_drive_menu_item_drive_sep_2), "generic-drive-menu-item-drive-sep-2"}, - {G_STRUCT_OFFSET (GduWindow, generic_drive_menu_item_standby_now), "generic-drive-menu-item-standby-now"}, - {G_STRUCT_OFFSET (GduWindow, generic_drive_menu_item_resume_now), "generic-drive-menu-item-resume-now"}, - {G_STRUCT_OFFSET (GduWindow, generic_drive_menu_item_power_off), "generic-drive-menu-item-power-off"}, - - {G_STRUCT_OFFSET (GduWindow, generic_menu), "generic-menu"}, - {G_STRUCT_OFFSET (GduWindow, generic_menu_item_configure_fstab), "generic-menu-item-configure-fstab"}, - {G_STRUCT_OFFSET (GduWindow, generic_menu_item_configure_crypttab), "generic-menu-item-configure-crypttab"}, - {G_STRUCT_OFFSET (GduWindow, generic_menu_item_change_passphrase), "generic-menu-item-change-passphrase"}, - {G_STRUCT_OFFSET (GduWindow, generic_menu_item_resize), "generic-menu-item-resize"}, - {G_STRUCT_OFFSET (GduWindow, generic_menu_item_check), "generic-menu-item-check"}, - {G_STRUCT_OFFSET (GduWindow, generic_menu_item_repair), "generic-menu-item-repair"}, - {G_STRUCT_OFFSET (GduWindow, generic_menu_item_separator), "generic-menu-item-separator"}, - {G_STRUCT_OFFSET (GduWindow, generic_menu_item_edit_label), "generic-menu-item-edit-label"}, - {G_STRUCT_OFFSET (GduWindow, generic_menu_item_edit_partition), "generic-menu-item-edit-partition"}, - {G_STRUCT_OFFSET (GduWindow, generic_menu_item_format_volume), "generic-menu-item-format-volume"}, - {G_STRUCT_OFFSET (GduWindow, generic_menu_item_create_volume_image), "generic-menu-item-create-volume-image"}, - {G_STRUCT_OFFSET (GduWindow, generic_menu_item_restore_volume_image), "generic-menu-item-restore-volume-image"}, - {G_STRUCT_OFFSET (GduWindow, generic_menu_item_benchmark), "generic-menu-item-benchmark"}, - {G_STRUCT_OFFSET (GduWindow, devtab_drive_job_label), "devtab-drive-job-label"}, {G_STRUCT_OFFSET (GduWindow, devtab_drive_job_grid), "devtab-drive-job-grid"}, {G_STRUCT_OFFSET (GduWindow, devtab_drive_job_progressbar), "devtab-drive-job-progressbar"}, @@ -288,7 +239,7 @@ static void update_all (GduWindow *window, gboolean is_delayed_job_update); static void on_volume_grid_changed (GduVolumeGrid *grid, gpointer user_data); -static void on_generic_tool_button_clicked (GtkToolButton *button, gpointer user_data); +static void on_volume_menu_tool_button_clicked (GtkToolButton *button, gpointer user_data); static void on_partition_create_tool_button_clicked (GtkToolButton *button, gpointer user_data); static void on_partition_delete_tool_button_clicked (GtkToolButton *button, gpointer user_data); static void on_mount_tool_button_clicked (GtkToolButton *button, gpointer user_data); @@ -302,53 +253,77 @@ static void on_devtab_drive_loop_detach_button_clicked (GtkButton *button, gpoin static void on_devtab_drive_eject_button_clicked (GtkButton *button, gpointer user_data); static void on_devtab_drive_power_off_button_clicked (GtkButton *button, gpointer user_data); -static void on_generic_drive_menu_item_view_smart (GtkMenuItem *menu_item, - gpointer user_data); -static void on_generic_drive_menu_item_disk_settings (GtkMenuItem *menu_item, - gpointer user_data); -static void on_generic_drive_menu_item_standby_now (GtkMenuItem *menu_item, - gpointer user_data); -static void on_generic_drive_menu_item_resume_now (GtkMenuItem *menu_item, - gpointer user_data); -static void on_generic_drive_menu_item_power_off (GtkMenuItem *menu_item, - gpointer user_data); -static void on_generic_drive_menu_item_format_disk (GtkMenuItem *menu_item, - gpointer user_data); -static void on_generic_drive_menu_item_create_disk_image (GtkMenuItem *menu_item, - gpointer user_data); -static void on_generic_drive_menu_item_restore_disk_image (GtkMenuItem *menu_item, - gpointer user_data); -static void on_generic_drive_menu_item_benchmark (GtkMenuItem *menu_item, - gpointer user_data); - -static void on_generic_menu_item_configure_fstab (GtkMenuItem *menu_item, - gpointer user_data); -static void on_generic_menu_item_configure_crypttab (GtkMenuItem *menu_item, - gpointer user_data); -static void on_generic_menu_item_change_passphrase (GtkMenuItem *menu_item, - gpointer user_data); +static void on_drive_menu_open (GSimpleAction *action, GVariant *parameter, gpointer user_data); +static void on_volume_menu_open (GSimpleAction *action, GVariant *parameter, gpointer user_data); + +static void on_drive_menu_item_view_smart (GSimpleAction *action, + GVariant *parameter, + gpointer user_data); +static void on_drive_menu_item_disk_settings (GSimpleAction *action, + GVariant *parameter, + gpointer user_data); +static void on_drive_menu_item_standby_now (GSimpleAction *action, + GVariant *parameter, + gpointer user_data); +static void on_drive_menu_item_resume_now (GSimpleAction *action, + GVariant *parameter, + gpointer user_data); +static void on_drive_menu_item_power_off (GSimpleAction *action, + GVariant *parameter, + gpointer user_data); +static void on_drive_menu_item_format_disk (GSimpleAction *action, + GVariant *parameter, + gpointer user_data); +static void on_drive_menu_item_create_disk_image (GSimpleAction *action, + GVariant *parameter, + gpointer user_data); +static void on_drive_menu_item_restore_disk_image (GSimpleAction *action, + GVariant *parameter, + gpointer user_data); +static void on_drive_menu_item_benchmark (GSimpleAction *action, + GVariant *parameter, + gpointer user_data); + +static void on_volume_menu_item_configure_fstab (GSimpleAction *action, + GVariant *parameter, + gpointer user_data); +static void on_volume_menu_item_configure_crypttab (GSimpleAction *action, + GVariant *parameter, + gpointer user_data); +static void on_volume_menu_item_change_passphrase (GSimpleAction *action, + GVariant *parameter, + gpointer user_data); #ifdef HAVE_UDISKS2_7_2 -static void on_generic_menu_item_resize (GtkMenuItem *menu_item, - gpointer user_data); -static void on_generic_menu_item_repair (GtkMenuItem *menu_item, - gpointer user_data); -static void on_generic_menu_item_check (GtkMenuItem *menu_item, - gpointer user_data); +static void on_volume_menu_item_resize (GSimpleAction *action, + GVariant *parameter, + gpointer user_data); +static void on_volume_menu_item_repair (GSimpleAction *action, + GVariant *parameter, + gpointer user_data); +static void on_volume_menu_item_check (GSimpleAction *action, + GVariant *parameter, + gpointer user_data); #endif -static void on_generic_menu_item_edit_label (GtkMenuItem *menu_item, - gpointer user_data); -static void on_generic_menu_item_edit_partition (GtkMenuItem *menu_item, - gpointer user_data); -static void on_generic_menu_item_format_volume (GtkMenuItem *menu_item, - gpointer user_data); -static void on_generic_menu_item_create_volume_image (GtkMenuItem *menu_item, - gpointer user_data); -static void on_generic_menu_item_restore_volume_image (GtkMenuItem *menu_item, - gpointer user_data); -static void on_generic_menu_item_benchmark (GtkMenuItem *menu_item, - gpointer user_data); +static void on_volume_menu_item_edit_label (GSimpleAction *action, + GVariant *parameter, + gpointer user_data); +static void on_volume_menu_item_edit_partition (GSimpleAction *action, + GVariant *parameter, + gpointer user_data); +static void on_volume_menu_item_format_volume (GSimpleAction *action, + GVariant *parameter, + gpointer user_data); +static void on_volume_menu_item_create_volume_image (GSimpleAction *action, + GVariant *parameter, + gpointer user_data); +static void on_volume_menu_item_restore_volume_image (GSimpleAction *action, + GVariant *parameter, + gpointer user_data); +static void on_volume_menu_item_benchmark (GSimpleAction *action, + GVariant *parameter, + gpointer user_data); static void on_devtab_loop_autoclear_switch_notify_active (GObject *object, GParamSpec *pspec, @@ -366,6 +341,36 @@ static gboolean on_activate_link (GtkLabel *label, G_DEFINE_TYPE (GduWindow, gdu_window, GTK_TYPE_APPLICATION_WINDOW); +static const GActionEntry actions[] = { + { "open-drive-menu", on_drive_menu_open }, + { "open-volume-menu", on_volume_menu_open }, + + { "format-disk", on_drive_menu_item_format_disk }, + { "create-disk-image", on_drive_menu_item_create_disk_image }, + { "restore-disk-image", on_drive_menu_item_restore_disk_image }, + { "benchmark-disk", on_drive_menu_item_benchmark }, + { "view-smart", on_drive_menu_item_view_smart }, + { "disk-settings", on_drive_menu_item_disk_settings }, + { "standby-now", on_drive_menu_item_standby_now }, + { "resume-now", on_drive_menu_item_resume_now }, + { "power-off", on_drive_menu_item_power_off }, + + { "format-partition", on_volume_menu_item_format_volume }, + { "edit-partition", on_volume_menu_item_edit_partition }, + { "edit-label", on_volume_menu_item_edit_label }, + { "change-passphrase", on_volume_menu_item_change_passphrase }, +#ifdef HAVE_UDISKS2_7_2 + { "resize", on_volume_menu_item_resize }, + { "check-fs", on_volume_menu_item_check }, + { "repair-fs", on_volume_menu_item_repair }, +#endif + { "configure-fstab", on_volume_menu_item_configure_fstab }, + { "configure-crypttab", on_volume_menu_item_configure_crypttab }, + { "create-partition-image", on_volume_menu_item_create_volume_image }, + { "restore-partition-image", on_volume_menu_item_restore_volume_image }, + { "benchmark-partition", on_volume_menu_item_benchmark } +}; + static void gdu_window_init (GduWindow *window) { @@ -378,7 +383,7 @@ static gboolean on_delete_event (GtkWidget *widget, GdkEvent *event, - gpointer user_data) + gpointer user_data) { return !gdu_application_should_exit (GDU_WINDOW (widget)->application); } @@ -467,43 +472,63 @@ update_for_show_flags (GduWindow *window, gtk_widget_set_visible (window->toolbutton_lock, show_flags->volume_buttons & SHOW_FLAGS_VOLUME_BUTTONS_ENCRYPTED_LOCK); - gtk_widget_set_sensitive (GTK_WIDGET (window->generic_drive_menu_item_format_disk), - show_flags->drive_menu & SHOW_FLAGS_DRIVE_MENU_FORMAT_DISK); - gtk_widget_set_sensitive (GTK_WIDGET (window->generic_drive_menu_item_view_smart), - show_flags->drive_menu & SHOW_FLAGS_DRIVE_MENU_VIEW_SMART); - gtk_widget_set_sensitive (GTK_WIDGET (window->generic_drive_menu_item_disk_settings), - show_flags->drive_menu & SHOW_FLAGS_DRIVE_MENU_DISK_SETTINGS); - gtk_widget_set_sensitive (GTK_WIDGET (window->generic_drive_menu_item_create_disk_image), - show_flags->drive_menu & SHOW_FLAGS_DRIVE_MENU_CREATE_DISK_IMAGE); - gtk_widget_set_sensitive (GTK_WIDGET (window->generic_drive_menu_item_restore_disk_image), - show_flags->drive_menu & SHOW_FLAGS_DRIVE_MENU_RESTORE_DISK_IMAGE); - gtk_widget_set_sensitive (GTK_WIDGET (window->generic_drive_menu_item_benchmark), - show_flags->drive_menu & SHOW_FLAGS_DRIVE_MENU_BENCHMARK); - - gtk_widget_set_sensitive (GTK_WIDGET (window->generic_menu_item_configure_fstab), - show_flags->volume_menu & SHOW_FLAGS_VOLUME_MENU_CONFIGURE_FSTAB); - gtk_widget_set_sensitive (GTK_WIDGET (window->generic_menu_item_configure_crypttab), - show_flags->volume_menu & SHOW_FLAGS_VOLUME_MENU_CONFIGURE_CRYPTTAB); - gtk_widget_set_sensitive (GTK_WIDGET (window->generic_menu_item_change_passphrase), - show_flags->volume_menu & SHOW_FLAGS_VOLUME_MENU_CHANGE_PASSPHRASE); - gtk_widget_set_sensitive (GTK_WIDGET (window->generic_menu_item_resize), - show_flags->volume_menu & SHOW_FLAGS_VOLUME_MENU_RESIZE); - gtk_widget_set_sensitive (GTK_WIDGET (window->generic_menu_item_repair), - show_flags->volume_menu & SHOW_FLAGS_VOLUME_MENU_REPAIR); - gtk_widget_set_sensitive (GTK_WIDGET (window->generic_menu_item_check), - show_flags->volume_menu & SHOW_FLAGS_VOLUME_MENU_CHECK); - gtk_widget_set_sensitive (GTK_WIDGET (window->generic_menu_item_edit_label), - show_flags->volume_menu & SHOW_FLAGS_VOLUME_MENU_EDIT_LABEL); - gtk_widget_set_sensitive (GTK_WIDGET (window->generic_menu_item_edit_partition), - show_flags->volume_menu & SHOW_FLAGS_VOLUME_MENU_EDIT_PARTITION); - gtk_widget_set_sensitive (GTK_WIDGET (window->generic_menu_item_format_volume), - show_flags->volume_menu & SHOW_FLAGS_VOLUME_MENU_FORMAT_VOLUME); - gtk_widget_set_sensitive (GTK_WIDGET (window->generic_menu_item_create_volume_image), - show_flags->volume_menu & SHOW_FLAGS_VOLUME_MENU_CREATE_VOLUME_IMAGE); - gtk_widget_set_sensitive (GTK_WIDGET (window->generic_menu_item_restore_volume_image), - show_flags->volume_menu & SHOW_FLAGS_VOLUME_MENU_RESTORE_VOLUME_IMAGE); - gtk_widget_set_sensitive (GTK_WIDGET (window->generic_menu_item_benchmark), - show_flags->volume_menu & SHOW_FLAGS_VOLUME_MENU_BENCHMARK); + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), + "format-disk")), + show_flags->drive_menu & SHOW_FLAGS_DRIVE_MENU_FORMAT_DISK); + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), + "view-smart")), + show_flags->drive_menu & SHOW_FLAGS_DRIVE_MENU_VIEW_SMART); + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), + "disk-settings")), + show_flags->drive_menu & SHOW_FLAGS_DRIVE_MENU_DISK_SETTINGS); + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), + "create-disk-image")), + show_flags->drive_menu & SHOW_FLAGS_DRIVE_MENU_CREATE_DISK_IMAGE); + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), + "restore-disk-image")), + show_flags->drive_menu & SHOW_FLAGS_DRIVE_MENU_RESTORE_DISK_IMAGE); + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), + "benchmark-disk")), + show_flags->drive_menu & SHOW_FLAGS_DRIVE_MENU_BENCHMARK); + + + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), + "configure-fstab")), + show_flags->volume_menu & SHOW_FLAGS_VOLUME_MENU_CONFIGURE_FSTAB); + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), + "configure-crypttab")), + show_flags->volume_menu & SHOW_FLAGS_VOLUME_MENU_CONFIGURE_CRYPTTAB); + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), + "change-passphrase")), + show_flags->volume_menu & SHOW_FLAGS_VOLUME_MENU_CHANGE_PASSPHRASE); + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), + "resize")), + show_flags->volume_menu & SHOW_FLAGS_VOLUME_MENU_RESIZE); + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), + "repair-fs")), + show_flags->volume_menu & SHOW_FLAGS_VOLUME_MENU_REPAIR); + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), + "check-fs")), + show_flags->volume_menu & SHOW_FLAGS_VOLUME_MENU_CHECK); + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), + "edit-label")), + show_flags->volume_menu & SHOW_FLAGS_VOLUME_MENU_EDIT_LABEL); + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), + "edit-partition")), + show_flags->volume_menu & SHOW_FLAGS_VOLUME_MENU_EDIT_PARTITION); + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), + "format-partition")), + show_flags->volume_menu & SHOW_FLAGS_VOLUME_MENU_FORMAT_VOLUME); + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), + "create-partition-image")), + show_flags->volume_menu & SHOW_FLAGS_VOLUME_MENU_CREATE_VOLUME_IMAGE); + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), + "restore-partition-image")), + show_flags->volume_menu & SHOW_FLAGS_VOLUME_MENU_RESTORE_VOLUME_IMAGE); + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), + "benchmark-partition")), + show_flags->volume_menu & SHOW_FLAGS_VOLUME_MENU_BENCHMARK); + /* TODO: don't show the button bringing up the popup menu if it has no items */ } @@ -868,9 +893,9 @@ init_css (GduWindow *window) static gint device_sort_function (GtkTreeModel *model, - GtkTreeIter *a, - GtkTreeIter *b, - gpointer user_data) + GtkTreeIter *a, + GtkTreeIter *b, + gpointer user_data) { gchar *sa, *sb; gint ret; @@ -988,79 +1013,79 @@ power_state_cell_func (GtkTreeViewColumn *column, update_all (window, FALSE); } -/* TODO: load from .ui file */ static GtkWidget * create_header (GduWindow *window) { GtkWidget *header; - GtkWidget *button; - GtkWidget *image; - - header = gtk_header_bar_new (); - gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (header), TRUE); - - button = window->devtab_drive_generic_button = gtk_menu_button_new (); - gtk_menu_button_set_popup (GTK_MENU_BUTTON (button), window->generic_drive_menu); - gtk_menu_button_set_direction (GTK_MENU_BUTTON (button), GTK_ARROW_NONE); - gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button); - - button = window->devtab_drive_power_off_button = gtk_button_new (); - image = gtk_image_new_from_icon_name ("system-shutdown-symbolic", GTK_ICON_SIZE_MENU); - gtk_button_set_image (GTK_BUTTON (button), image); - gtk_widget_set_tooltip_text (button, _("Power off this disk")); - gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button); - - button = window->devtab_drive_eject_button = gtk_button_new (); - image = gtk_image_new_from_icon_name ("media-eject-symbolic", GTK_ICON_SIZE_MENU); - gtk_button_set_image (GTK_BUTTON (button), image); - gtk_widget_set_tooltip_text (button, _("Eject this disk")); - gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button); - - button = window->devtab_drive_loop_detach_button = gtk_button_new (); - image = gtk_image_new_from_icon_name ("list-remove-symbolic", GTK_ICON_SIZE_MENU); - gtk_button_set_image (GTK_BUTTON (button), image); - gtk_widget_set_tooltip_text (button, _("Detach this loop device")); - gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button); + GMenuModel *model; + GError **error0 = NULL; + GError **error1 = NULL; + GError **error2 = NULL; + + gtk_builder_add_from_resource (window->builder, "/org/gnome/Disks/ui/headerbar.ui", error0); + header = GTK_WIDGET (gtk_builder_get_object (window->builder, "headerbar-paned")); + window->right_header = GTK_WIDGET (gtk_builder_get_object (window->builder, "disks-main-headerbar")); + window->left_header = GTK_WIDGET (gtk_builder_get_object (window->builder, "disks-side-headerbar")); + + window->devtab_drive_menu_button = GTK_WIDGET (gtk_builder_get_object (window->builder, "drive-menu-button")); + window->devtab_app_menu_button = GTK_WIDGET (gtk_builder_get_object (window->builder, "app-menu-button")); + window->devtab_drive_power_off_button = GTK_WIDGET (gtk_builder_get_object (window->builder, "power-off-disk-button")); + window->devtab_drive_eject_button = GTK_WIDGET (gtk_builder_get_object (window->builder, "eject-disk-button")); + window->devtab_drive_loop_detach_button = GTK_WIDGET (gtk_builder_get_object (window->builder, "detach-loop-device-button")); + + gtk_builder_add_from_resource (window->builder, "/org/gnome/Disks/ui/drive-menu.ui", error1); + model = G_MENU_MODEL (gtk_builder_get_object (window->builder, "drive-menu")); + window->drive_menu = gtk_popover_new_from_model (window->devtab_drive_menu_button, model); + gtk_menu_button_set_popover (GTK_MENU_BUTTON (window->devtab_drive_menu_button), window->drive_menu); + + gtk_builder_add_from_resource (window->builder, "/org/gnome/Disks/ui/app-menu.ui", error2); + model = G_MENU_MODEL (gtk_builder_get_object (window->builder, "app-menu")); + window->app_menu = gtk_popover_new_from_model (window->devtab_app_menu_button, model); + gtk_menu_button_set_popover (GTK_MENU_BUTTON (window->devtab_app_menu_button), window->app_menu); return header; } -static gboolean -in_desktop (const gchar *name) -{ - const gchar *desktop_name_list; - gchar **names; - gboolean in_list = FALSE; - gint i; - - desktop_name_list = g_getenv ("XDG_CURRENT_DESKTOP"); - if (!desktop_name_list) - return FALSE; - - names = g_strsplit (desktop_name_list, ":", -1); - for (i = 0; names[i] && !in_list; i++) - { - if (strcmp (names[i], name) == 0) - in_list = TRUE; - } - g_strfreev (names); - - return in_list; +static void +gdu_window_update_decoration_layout (GObject *object, + GParamSpec *pspec, + GduWindow *window) +{ + gchar *layout_desc; + gchar **tokens; + + g_object_get (gtk_settings_get_default (), + "gtk-decoration-layout", &layout_desc, + NULL); + + tokens = g_strsplit (layout_desc, ":", 2); + if (tokens) + { + gchar *layout_headerbar; + + layout_headerbar = g_strdup_printf ("%c%s", ':', tokens[1]); + gtk_header_bar_set_decoration_layout (GTK_HEADER_BAR (window->right_header), layout_headerbar); + gtk_header_bar_set_decoration_layout (GTK_HEADER_BAR (window->left_header), tokens[0]); + + g_free (layout_headerbar); + g_strfreev (tokens); + } + + g_free (layout_desc); } static void gdu_window_constructed (GObject *object) { GduWindow *window = GDU_WINDOW (object); - guint key; - GdkModifierType mod; - GtkAccelGroup *accelgroup; GtkTreeViewColumn *column; GtkCellRenderer *renderer; GtkTreeSelection *selection; GtkStyleContext *context; GList *children, *l; guint n; + GtkBuilder *builder; + GMenuModel *model; init_css (window); @@ -1085,32 +1110,33 @@ gdu_window_constructed (GObject *object) window->has_volume_job = FALSE; window->delay_job_update_id = 0; - window->header = create_header (window); - if (!in_desktop ("Unity")) - gtk_window_set_titlebar (GTK_WINDOW (window), window->header); - else - { - gtk_box_pack_start (GTK_BOX (window->main_box), - GTK_WIDGET (window->header), - FALSE, TRUE, 0); - gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (window->header), - FALSE); - context = gtk_widget_get_style_context (GTK_WIDGET (window->header)); - gtk_style_context_remove_class (context, "header-bar"); - gtk_style_context_add_class (context, "toolbar"); - gtk_style_context_add_class (context, "primary-toolbar"); - } - - gtk_widget_show_all (window->header); - g_object_ref (window->main_box); gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (window->main_box)), window->main_box); gtk_container_add (GTK_CONTAINER (window), window->main_box); g_object_unref (window->main_box); + + /* build the headerbar */ + window->header = create_header (window); + gtk_window_set_titlebar (GTK_WINDOW (window), window->header); + + gtk_widget_show_all (window->header); + + g_object_bind_property (window->header, "position", + window->main_hpane, "position", + G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); + gtk_window_set_title (GTK_WINDOW (window), _("Disks")); - gtk_window_set_default_size (GTK_WINDOW (window), 800, 700); + gtk_window_set_default_size (GTK_WINDOW (window), 900, 600); gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER); + /* build the decorations */ + gdu_window_update_decoration_layout (NULL, NULL, window); + + g_signal_connect (gtk_settings_get_default (), + "notify::gtk-decoration-layout", + G_CALLBACK (gdu_window_update_decoration_layout), + window); + /* set up mnemonic */ gtk_window_add_mnemonic (GTK_WINDOW (window), 'd', @@ -1249,10 +1275,16 @@ gdu_window_constructed (GObject *object) gtk_widget_set_name (window->devtab_grid_toolbar, "devtab-grid-toolbar"); gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP); + builder = gtk_builder_new_from_resource ("/org/gnome/Disks/ui/volume-menu.ui"); + model = G_MENU_MODEL (gtk_builder_get_object (GTK_BUILDER (builder), "volume-menu")); + window->volume_menu = gtk_popover_new_from_model (window->toolbutton_volume_menu, model); + gtk_popover_set_position (GTK_POPOVER (window->volume_menu), GTK_POS_BOTTOM); + g_object_unref (builder); + /* toolbar buttons */ - g_signal_connect (window->toolbutton_generic_menu, + g_signal_connect (window->toolbutton_volume_menu, "clicked", - G_CALLBACK (on_generic_tool_button_clicked), + G_CALLBACK (on_volume_menu_tool_button_clicked), window); g_signal_connect (window->toolbutton_partition_create, "clicked", @@ -1301,101 +1333,9 @@ gdu_window_constructed (GObject *object) G_CALLBACK (on_devtab_drive_power_off_button_clicked), window); - /* drive menu */ - g_signal_connect (window->generic_drive_menu_item_view_smart, - "activate", - G_CALLBACK (on_generic_drive_menu_item_view_smart), - window); - g_signal_connect (window->generic_drive_menu_item_disk_settings, - "activate", - G_CALLBACK (on_generic_drive_menu_item_disk_settings), - window); - g_signal_connect (window->generic_drive_menu_item_standby_now, - "activate", - G_CALLBACK (on_generic_drive_menu_item_standby_now), - window); - g_signal_connect (window->generic_drive_menu_item_resume_now, - "activate", - G_CALLBACK (on_generic_drive_menu_item_resume_now), - window); - g_signal_connect (window->generic_drive_menu_item_power_off, - "activate", - G_CALLBACK (on_generic_drive_menu_item_power_off), - window); - g_signal_connect (window->generic_drive_menu_item_format_disk, - "activate", - G_CALLBACK (on_generic_drive_menu_item_format_disk), - window); - g_signal_connect (window->generic_drive_menu_item_create_disk_image, - "activate", - G_CALLBACK (on_generic_drive_menu_item_create_disk_image), - window); - g_signal_connect (window->generic_drive_menu_item_restore_disk_image, - "activate", - G_CALLBACK (on_generic_drive_menu_item_restore_disk_image), - window); - g_signal_connect (window->generic_drive_menu_item_benchmark, - "activate", - G_CALLBACK (on_generic_drive_menu_item_benchmark), - window); - - /* volume menu */ - g_signal_connect (window->generic_menu_item_configure_fstab, - "activate", - G_CALLBACK (on_generic_menu_item_configure_fstab), - window); - g_signal_connect (window->generic_menu_item_configure_crypttab, - "activate", - G_CALLBACK (on_generic_menu_item_configure_crypttab), - window); - g_signal_connect (window->generic_menu_item_change_passphrase, - "activate", - G_CALLBACK (on_generic_menu_item_change_passphrase), - window); - -#ifdef HAVE_UDISKS2_7_2 - g_signal_connect (window->generic_menu_item_resize, - "activate", - G_CALLBACK (on_generic_menu_item_resize), - window); - g_signal_connect (window->generic_menu_item_repair, - "activate", - G_CALLBACK (on_generic_menu_item_repair), - window); - g_signal_connect (window->generic_menu_item_check, - "activate", - G_CALLBACK (on_generic_menu_item_check), - window); -#else - gtk_widget_hide (window->generic_menu_item_resize); - gtk_widget_hide (window->generic_menu_item_repair); - gtk_widget_hide (window->generic_menu_item_check); - gtk_widget_hide (window->generic_menu_item_separator); -#endif - - g_signal_connect (window->generic_menu_item_edit_label, - "activate", - G_CALLBACK (on_generic_menu_item_edit_label), - window); - g_signal_connect (window->generic_menu_item_edit_partition, - "activate", - G_CALLBACK (on_generic_menu_item_edit_partition), - window); - g_signal_connect (window->generic_menu_item_format_volume, - "activate", - G_CALLBACK (on_generic_menu_item_format_volume), - window); - g_signal_connect (window->generic_menu_item_create_volume_image, - "activate", - G_CALLBACK (on_generic_menu_item_create_volume_image), - window); - g_signal_connect (window->generic_menu_item_restore_volume_image, - "activate", - G_CALLBACK (on_generic_menu_item_restore_volume_image), - window); - g_signal_connect (window->generic_menu_item_benchmark, - "activate", - G_CALLBACK (on_generic_menu_item_benchmark), + /* actions from both menus are connected here ; in a perfect world, buttons should to */ + g_action_map_add_action_entries (G_ACTION_MAP (window), + actions, G_N_ELEMENTS (actions), window); /* loop's auto-clear switch */ @@ -1430,72 +1370,6 @@ gdu_window_constructed (GObject *object) ensure_something_selected (window); gtk_widget_grab_focus (window->device_tree_treeview); update_all (window, FALSE); - - /* attach the generic menu to the toplevel window for correct placement */ - gtk_menu_attach_to_widget (GTK_MENU (window->generic_menu), - GTK_WIDGET (window), - NULL); - - /* TODO: would be better to have all this in the .ui file - no idea - * why it doesn't work - accelerator support in GTK+ seems extremely - * confusing and flaky :-( - */ - accelgroup = gtk_accel_group_new (); - gtk_window_add_accel_group (GTK_WINDOW (window), accelgroup); - - /* Translators: This is the short-cut to open the disks/drive gear menu */ - gtk_accelerator_parse (C_("accelerator", "F10"), &key, &mod); - gtk_accel_map_add_entry ("/DriveMenu", key, mod); - gtk_widget_set_accel_path (window->devtab_drive_generic_button, "/DriveMenu", accelgroup); - - /* Translators: This is the short-cut to format a disk. - * The Ctrl modifier must not be translated or parsing will fail. - * You can however change to another English modifier (e.g. ). - */ - gtk_accelerator_parse (C_("accelerator", "F"), &key, &mod); - gtk_accel_map_add_entry ("/DriveMenu/Format", key, mod); - gtk_widget_set_accel_path (window->generic_drive_menu_item_format_disk, "/DriveMenu/Format", accelgroup); - - /* Translators: This is the short-cut to view SMART data for a disk. - * The Ctrl modifier must not be translated or parsing will fail. - * You can however change to another English modifier (e.g. ). - */ - gtk_accelerator_parse (C_("accelerator", "S"), &key, &mod); - gtk_accel_map_add_entry ("/DriveMenu/ViewSmart", key, mod); - gtk_widget_set_accel_path (window->generic_drive_menu_item_view_smart, "/DriveMenu/ViewSmart", accelgroup); - - /* Translators: This is the short-cut to view the "Drive Settings" dialog for a hard disk. - * The Ctrl modifier must not be translated or parsing will fail. - * You can however change to another English modifier (e.g. ). - */ - gtk_accelerator_parse (C_("accelerator", "E"), &key, &mod); - gtk_accel_map_add_entry ("/DriveMenu/Settings", key, mod); - gtk_widget_set_accel_path (window->generic_drive_menu_item_disk_settings, "/DriveMenu/Settings", accelgroup); - - /* Translators: This is the short-cut to open the volume gear menu. - * The Shift modifier must not be translated or parsing will fail. - * You can however change to another English modifier (e.g. ). - */ - /* TODO: This results in - * - * Gtk-CRITICAL **: gtk_widget_set_accel_path: assertion 'GTK_WIDGET_GET_CLASS (widget)->activate_signal != 0' failed - * - * so comment it out for now. - */ -#if 0 - gtk_accelerator_parse (C_("accelerator", "F10"), &key, &mod); - gtk_accel_map_add_entry ("/VolumeMenu", key, mod); - gtk_widget_set_accel_path (window->toolbutton_generic_menu, "/VolumeMenu", accelgroup); -#endif - - - /* Translators: This is the short-cut to format a volume. - * The Shift and Ctrl modifiers must not be translated or parsing will fail. - * You can however change to other English modifiers. - */ - gtk_accelerator_parse (C_("accelerator", "F"), &key, &mod); - gtk_accel_map_add_entry ("/VolumeMenu/Format", key, mod); - gtk_widget_set_accel_path (window->generic_menu_item_format_volume, "/VolumeMenu/Format", accelgroup); } static void @@ -1960,7 +1834,7 @@ update_jobs (GduWindow *window, drive_sensitivity = !gdu_application_has_running_job (window->application, window->current_object); selected_volume_sensitivity = (!window->has_volume_job && !window->has_drive_job); - gets_sensitive = (drive_sensitivity && !gtk_widget_get_sensitive (window->devtab_drive_generic_button)) + gets_sensitive = (drive_sensitivity && !gtk_widget_get_sensitive (window->devtab_drive_menu_button)) || (selected_volume_sensitivity && !gtk_widget_get_sensitive (window->devtab_grid_toolbar)); /* delay for some milliseconds if change to sensitive or while a delay is pending */ @@ -1973,7 +1847,7 @@ update_jobs (GduWindow *window, } else { - gtk_widget_set_sensitive (window->devtab_drive_generic_button, drive_sensitivity); + gtk_widget_set_sensitive (window->devtab_drive_menu_button, drive_sensitivity); gtk_widget_set_sensitive (window->devtab_drive_eject_button, drive_sensitivity); gtk_widget_set_sensitive (window->devtab_drive_power_off_button, drive_sensitivity); gtk_widget_set_sensitive (window->devtab_drive_loop_detach_button, drive_sensitivity); @@ -2165,7 +2039,6 @@ update_device_page_for_drive (GduWindow *window, const gchar *our_seat; const gchar *serial; GList *jobs; - gchar *title = NULL; //g_debug ("In update_device_page_for_drive() - selected=%s", // object != NULL ? g_dbus_object_get_object_path (object) : ""); @@ -2202,22 +2075,12 @@ update_device_page_for_drive (GduWindow *window, g_free (s); } - if (!in_desktop ("Unity")) - { - gtk_header_bar_set_title (GTK_HEADER_BAR (window->header), udisks_object_info_get_description (info)); - gtk_header_bar_set_subtitle (GTK_HEADER_BAR (window->header), str->str); - } - else - { - title = g_strdup_printf ("%s — %s", udisks_object_info_get_description (info), str->str); - gtk_window_set_title (GTK_WINDOW (window), title); - - g_free (title); - } + gtk_header_bar_set_title (GTK_HEADER_BAR (window->right_header), udisks_object_info_get_description (info)); + gtk_header_bar_set_subtitle (GTK_HEADER_BAR (window->right_header), str->str); g_string_free (str, TRUE); - gtk_widget_show (window->devtab_drive_generic_button); + gtk_widget_show (window->devtab_drive_menu_button); str = g_string_new (NULL); if (strlen (drive_vendor) == 0) @@ -2334,7 +2197,6 @@ update_device_page_for_drive (GduWindow *window, } } - if (udisks_drive_get_can_power_off (drive)) { show_flags->drive_menu |= SHOW_FLAGS_DRIVE_MENU_POWER_OFF; @@ -2381,29 +2243,24 @@ update_device_page_for_drive (GduWindow *window, show_flags->drive_buttons |= SHOW_FLAGS_DRIVE_BUTTONS_EJECT; } - /* Show Drive-specific items */ - gtk_widget_show (GTK_WIDGET (window->generic_drive_menu_item_drive_sep_1)); - gtk_widget_show (GTK_WIDGET (window->generic_drive_menu_item_view_smart)); - gtk_widget_show (GTK_WIDGET (window->generic_drive_menu_item_disk_settings)); - gtk_widget_show (GTK_WIDGET (window->generic_drive_menu_item_drive_sep_2)); + /* Enable Drive-specific items */ + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), "view-smart")), TRUE); + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), "disk-settings")), TRUE); + if (!(show_flags->drive_menu & (SHOW_FLAGS_DRIVE_MENU_STANDBY_NOW|SHOW_FLAGS_DRIVE_MENU_RESUME_NOW))) { /* no PM / safely-remove capabilities... only show "standby" greyed out */ - gtk_widget_show (GTK_WIDGET (window->generic_drive_menu_item_standby_now)); - gtk_widget_set_sensitive (GTK_WIDGET (window->generic_drive_menu_item_standby_now), FALSE); } else { /* Only show one of Standby and Resume (they are mutually exclusive) */ - gtk_widget_set_sensitive (GTK_WIDGET (window->generic_drive_menu_item_standby_now), TRUE); - gtk_widget_set_sensitive (GTK_WIDGET (window->generic_drive_menu_item_resume_now), TRUE); if (show_flags->drive_menu & SHOW_FLAGS_DRIVE_MENU_STANDBY_NOW) - gtk_widget_show (GTK_WIDGET (window->generic_drive_menu_item_standby_now)); + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), "standby-now")), TRUE); else - gtk_widget_show (GTK_WIDGET (window->generic_drive_menu_item_resume_now)); + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), "resume-now")), TRUE); } if (show_flags->drive_menu & SHOW_FLAGS_DRIVE_MENU_POWER_OFF) - gtk_widget_show (GTK_WIDGET (window->generic_drive_menu_item_power_off)); + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), "power-off")), TRUE); g_list_foreach (blocks, (GFunc) g_object_unref, NULL); g_list_free (blocks); @@ -2434,18 +2291,10 @@ update_device_page_for_loop (GduWindow *window, info = udisks_client_get_object_info (window->client, object); device_desc = get_device_file_for_display (block); - if (!in_desktop ("Unity")) - { - gtk_header_bar_set_title (GTK_HEADER_BAR (window->header), udisks_object_info_get_description (info)); - gtk_header_bar_set_subtitle (GTK_HEADER_BAR (window->header), device_desc); - } - else - { - title = g_strdup_printf ("%s — %s", udisks_object_info_get_description (info), device_desc); - gtk_window_set_title (GTK_WINDOW (window), title); - } + gtk_header_bar_set_title (GTK_HEADER_BAR (window->right_header), udisks_object_info_get_description (info)); + gtk_header_bar_set_subtitle (GTK_HEADER_BAR (window->right_header), device_desc); - gtk_widget_show (window->devtab_drive_generic_button); + gtk_widget_show (window->devtab_drive_menu_button); update_generic_drive_bits (window, block, NULL, show_flags, is_delayed_job_update); @@ -2498,18 +2347,10 @@ update_device_page_for_fake_block (GduWindow *window, info = udisks_client_get_object_info (window->client, object); device_desc = get_device_file_for_display (block); - if (!in_desktop ("Unity")) - { - gtk_header_bar_set_title (GTK_HEADER_BAR (window->header), udisks_object_info_get_description (info)); - gtk_header_bar_set_subtitle (GTK_HEADER_BAR (window->header), device_desc); - } - else - { - title = g_strdup_printf ("%s — %s", udisks_object_info_get_description (info), device_desc); - gtk_window_set_title (GTK_WINDOW (window), title); - } + gtk_header_bar_set_title (GTK_HEADER_BAR (window->right_header), udisks_object_info_get_description (info)); + gtk_header_bar_set_subtitle (GTK_HEADER_BAR (window->right_header), device_desc); - gtk_widget_show (window->devtab_drive_generic_button); + gtk_widget_show (window->devtab_drive_menu_button); update_generic_drive_bits (window, block, NULL, show_flags, is_delayed_job_update); @@ -3044,14 +2885,12 @@ update_device_page (GduWindow *window, gtk_container_foreach (GTK_CONTAINER (window->devtab_drive_table), maybe_hide, window); gtk_container_foreach (GTK_CONTAINER (window->devtab_table), maybe_hide, window); - /* Hide all Drive-specific menu items - will be turned on again in update_device_page_for_drive() */ - gtk_widget_hide (GTK_WIDGET (window->generic_drive_menu_item_drive_sep_1)); - gtk_widget_hide (GTK_WIDGET (window->generic_drive_menu_item_view_smart)); - gtk_widget_hide (GTK_WIDGET (window->generic_drive_menu_item_disk_settings)); - gtk_widget_hide (GTK_WIDGET (window->generic_drive_menu_item_drive_sep_2)); - gtk_widget_hide (GTK_WIDGET (window->generic_drive_menu_item_standby_now)); - gtk_widget_hide (GTK_WIDGET (window->generic_drive_menu_item_resume_now)); - gtk_widget_hide (GTK_WIDGET (window->generic_drive_menu_item_power_off)); + /* Disable all Drive-specific menu items - will be turned on again in update_device_page_for_drive() */ + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), "view-smart")), FALSE); + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), "disk-settings")), FALSE); + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), "standby-now")), FALSE); + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), "resume-now")), FALSE); + g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), "power-off")), FALSE); /* ensure grid is set to the right volumes */ device_page_ensure_grid (window); @@ -3121,8 +2960,9 @@ update_device_page (GduWindow *window, #ifdef HAVE_UDISKS2_7_2 static void -on_generic_menu_item_resize (GtkMenuItem *menu_item, - gpointer user_data) +on_volume_menu_item_resize (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) { GduWindow *window = GDU_WINDOW (user_data); UDisksObject *object; @@ -3218,8 +3058,9 @@ fs_repair_unmount_cb (GduWindow *window, } static void -on_generic_menu_item_repair (GtkMenuItem *menu_item, - gpointer user_data) +on_volume_menu_item_repair (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) { GduWindow *window = GDU_WINDOW (user_data); GtkWidget *message_dialog, *ok_button; @@ -3335,8 +3176,9 @@ fs_check_unmount_cb (GduWindow *window, } static void -on_generic_menu_item_check (GtkMenuItem *menu_item, - gpointer user_data) +on_volume_menu_item_check (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) { GduWindow *window = GDU_WINDOW (user_data); UDisksObject *object; @@ -3370,8 +3212,35 @@ on_generic_menu_item_check (GtkMenuItem *menu_item, /* ---------------------------------------------------------------------------------------------------- */ static void -on_generic_menu_item_edit_label (GtkMenuItem *menu_item, - gpointer user_data) +on_volume_menu_open (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) +{ + GduWindow *window = GDU_WINDOW (user_data); + + update_all (window, FALSE); + gtk_popover_popup (GTK_POPOVER (window->volume_menu)); +} + +/* ---------------------------------------------------------------------------------------------------- */ + +static void +on_drive_menu_open (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) +{ + GduWindow *window = GDU_WINDOW (user_data); + + update_all (window, FALSE); + gtk_popover_popup (GTK_POPOVER (window->drive_menu)); +} + +/* ---------------------------------------------------------------------------------------------------- */ + +static void +on_volume_menu_item_edit_label (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) { GduWindow *window = GDU_WINDOW (user_data); UDisksObject *object; @@ -3384,8 +3253,9 @@ on_generic_menu_item_edit_label (GtkMenuItem *menu_item, /* ---------------------------------------------------------------------------------------------------- */ static void -on_generic_menu_item_edit_partition (GtkMenuItem *menu_item, - gpointer user_data) +on_volume_menu_item_edit_partition (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) { GduWindow *window = GDU_WINDOW (user_data); UDisksObject *object; @@ -3398,8 +3268,9 @@ on_generic_menu_item_edit_partition (GtkMenuItem *menu_item, /* ---------------------------------------------------------------------------------------------------- */ static void -on_generic_menu_item_format_volume (GtkMenuItem *menu_item, - gpointer user_data) +on_volume_menu_item_format_volume (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) { GduWindow *window = GDU_WINDOW (user_data); UDisksObject *object; @@ -3412,8 +3283,9 @@ on_generic_menu_item_format_volume (GtkMenuItem *menu_item, /* ---------------------------------------------------------------------------------------------------- */ static void -on_generic_drive_menu_item_create_disk_image (GtkMenuItem *menu_item, - gpointer user_data) +on_drive_menu_item_create_disk_image (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) { GduWindow *window = GDU_WINDOW (user_data); UDisksObject *object; @@ -3426,8 +3298,9 @@ on_generic_drive_menu_item_create_disk_image (GtkMenuItem *menu_item, /* ---------------------------------------------------------------------------------------------------- */ static void -on_generic_drive_menu_item_restore_disk_image (GtkMenuItem *menu_item, - gpointer user_data) +on_drive_menu_item_restore_disk_image (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) { GduWindow *window = GDU_WINDOW (user_data); UDisksObject *object; @@ -3440,8 +3313,9 @@ on_generic_drive_menu_item_restore_disk_image (GtkMenuItem *menu_item, /* ---------------------------------------------------------------------------------------------------- */ static void -on_generic_drive_menu_item_benchmark (GtkMenuItem *menu_item, - gpointer user_data) +on_drive_menu_item_benchmark (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) { GduWindow *window = GDU_WINDOW (user_data); UDisksObject *object; @@ -3454,8 +3328,9 @@ on_generic_drive_menu_item_benchmark (GtkMenuItem *menu_item, /* ---------------------------------------------------------------------------------------------------- */ static void -on_generic_menu_item_create_volume_image (GtkMenuItem *menu_item, - gpointer user_data) +on_volume_menu_item_create_volume_image (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) { GduWindow *window = GDU_WINDOW (user_data); UDisksObject *object; @@ -3468,8 +3343,9 @@ on_generic_menu_item_create_volume_image (GtkMenuItem *menu_item, /* ---------------------------------------------------------------------------------------------------- */ static void -on_generic_menu_item_restore_volume_image (GtkMenuItem *menu_item, - gpointer user_data) +on_volume_menu_item_restore_volume_image (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) { GduWindow *window = GDU_WINDOW (user_data); UDisksObject *object; @@ -3482,8 +3358,9 @@ on_generic_menu_item_restore_volume_image (GtkMenuItem *menu_item, /* ---------------------------------------------------------------------------------------------------- */ static void -on_generic_menu_item_benchmark (GtkMenuItem *menu_item, - gpointer user_data) +on_volume_menu_item_benchmark (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) { GduWindow *window = GDU_WINDOW (user_data); UDisksObject *object; @@ -3496,8 +3373,9 @@ on_generic_menu_item_benchmark (GtkMenuItem *menu_item, /* ---------------------------------------------------------------------------------------------------- */ static void -on_generic_drive_menu_item_format_disk (GtkMenuItem *menu_item, - gpointer user_data) +on_drive_menu_item_format_disk (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) { GduWindow *window = GDU_WINDOW (user_data); UDisksObject *object; @@ -3510,8 +3388,9 @@ on_generic_drive_menu_item_format_disk (GtkMenuItem *menu_item, /* ---------------------------------------------------------------------------------------------------- */ static void -on_generic_menu_item_configure_fstab (GtkMenuItem *menu_item, - gpointer user_data) +on_volume_menu_item_configure_fstab (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) { GduWindow *window = GDU_WINDOW (user_data); UDisksObject *object; @@ -3522,16 +3401,18 @@ on_generic_menu_item_configure_fstab (GtkMenuItem *menu_item, } static void -on_generic_drive_menu_item_view_smart (GtkMenuItem *menu_item, - gpointer user_data) +on_drive_menu_item_view_smart (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) { GduWindow *window = GDU_WINDOW (user_data); gdu_ata_smart_dialog_show (window, window->current_object); } static void -on_generic_drive_menu_item_disk_settings (GtkMenuItem *menu_item, - gpointer user_data) +on_drive_menu_item_disk_settings (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) { GduWindow *window = GDU_WINDOW (user_data); gdu_disk_settings_dialog_show (window, window->current_object); @@ -3562,8 +3443,9 @@ ata_pm_standby_cb (GObject *source_object, } static void -on_generic_drive_menu_item_standby_now (GtkMenuItem *menu_item, - gpointer user_data) +on_drive_menu_item_standby_now (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) { GduWindow *window = GDU_WINDOW (user_data); UDisksDriveAta *ata; @@ -3608,8 +3490,9 @@ ata_pm_wakeup_cb (GObject *source_object, } static void -on_generic_drive_menu_item_resume_now (GtkMenuItem *menu_item, - gpointer user_data) +on_drive_menu_item_resume_now (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) { GduWindow *window = GDU_WINDOW (user_data); UDisksDriveAta *ata; @@ -3719,8 +3602,9 @@ do_power_off (GduWindow *window) } static void -on_generic_drive_menu_item_power_off (GtkMenuItem *menu_item, - gpointer user_data) +on_drive_menu_item_power_off (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) { GduWindow *window = GDU_WINDOW (user_data); do_power_off (window); @@ -3737,8 +3621,9 @@ on_devtab_drive_power_off_button_clicked (GtkButton *button, /* ---------------------------------------------------------------------------------------------------- */ static void -on_generic_menu_item_configure_crypttab (GtkMenuItem *menu_item, - gpointer user_data) +on_volume_menu_item_configure_crypttab (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) { GduWindow *window = GDU_WINDOW (user_data); UDisksObject *object; @@ -3750,8 +3635,9 @@ on_generic_menu_item_configure_crypttab (GtkMenuItem *menu_item, } static void -on_generic_menu_item_change_passphrase (GtkMenuItem *menu_item, - gpointer user_data) +on_volume_menu_item_change_passphrase (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) { GduWindow *window = GDU_WINDOW (user_data); UDisksObject *object; @@ -3821,17 +3707,12 @@ on_unmount_tool_button_clicked (GtkToolButton *button, gpointer user_data) /* ---------------------------------------------------------------------------------------------------- */ static void -on_generic_tool_button_clicked (GtkToolButton *button, gpointer user_data) +on_volume_menu_tool_button_clicked (GtkToolButton *button, gpointer user_data) { GduWindow *window = GDU_WINDOW (user_data); update_all (window, FALSE); - - gtk_menu_popup_at_widget (GTK_MENU (window->generic_menu), - window->toolbutton_generic_menu, - GDK_GRAVITY_SOUTH_WEST, - GDK_GRAVITY_NORTH_WEST, - NULL); + gtk_popover_popup (GTK_POPOVER (window->volume_menu)); } /* ---------------------------------------------------------------------------------------------------- */ diff --git a/src/disks/gnome-disks.gresource.xml b/src/disks/gnome-disks.gresource.xml index 759f4c29..d9542c17 100644 --- a/src/disks/gnome-disks.gresource.xml +++ b/src/disks/gnome-disks.gresource.xml @@ -8,11 +8,13 @@ ui/create-confirm-page.ui ui/create-disk-image-dialog.ui ui/create-filesystem-page.ui + ui/create-format.ui ui/create-other-page.ui ui/create-partition-page.ui ui/create-password-page.ui ui/disk-settings-dialog.ui ui/disks.ui + ui/drive-menu.ui ui/edit-crypttab-dialog.ui ui/edit-dos-partition-dialog.ui ui/edit-filesystem-dialog.ui @@ -21,12 +23,14 @@ ui/edit-partition-dialog.ui ui/erase-multiple-disks-dialog.ui ui/format-disk-dialog.ui - ui/create-format.ui + ui/headerbar.ui ui/new-disk-image-dialog.ui ui/resize-dialog.ui ui/restore-disk-image-dialog.ui + ui/shortcuts.ui ui/smart-dialog.ui ui/unlock-device-dialog.ui + ui/volume-menu.ui ui/gdu.css diff --git a/src/disks/ui/app-menu.ui b/src/disks/ui/app-menu.ui index eea28864..668b6956 100644 --- a/src/disks/ui/app-menu.ui +++ b/src/disks/ui/app-menu.ui @@ -7,24 +7,22 @@ app.new_disk_image - Attach Disk _Image… + _Attach Disk Image… (.iso, .img) app.attach_disk_image
- app.help - _Help - F1 + app.shortcuts + _Keyboard Shortcuts - _About - app.about + app.help + _Help - _Quit - app.quit - <Primary>q + _About Disks + app.about
diff --git a/src/disks/ui/disks.ui b/src/disks/ui/disks.ui index 12824deb..8e04a4dc 100644 --- a/src/disks/ui/disks.ui +++ b/src/disks/ui/disks.ui @@ -13,10 +13,11 @@ False vertical - + True True - 250 + horizontal + 200 True @@ -789,7 +790,7 @@ - + True False Additional partition options @@ -1161,215 +1162,4 @@ - - True - False - end - - - True - False - Format Disk… - - - - - True - False - - - - - True - False - Create Disk Image… - - - - - True - False - Restore Disk Image… - - - - - True - False - Benchmark Disk… - - - - - True - False - - - - - True - False - SMART Data & Self-Tests… - - - - - True - False - Drive Settings… - - - - - True - False - - - - - True - False - Standby Now - - - - - True - False - Wake-Up from Standby - - - - - True - False - Power Off… - True - - - - - True - False - start - - - True - False - Format Partition… - True - - - - - True - False - - - - - True - False - Edit Partition… - True - - - - - True - False - Edit Filesystem… - True - - - - - True - False - Change Passphrase… - True - - - - - True - False - - - - - True - False - Resize… - True - - - - - True - False - Check Filesystem… - True - - - - - True - False - Repair Filesystem… - True - - - - - True - False - - - - - True - False - Edit Mount Options… - True - - - - - True - False - Edit Encryption Options… - True - - - - - True - False - - - - - True - False - Create Partition Image… - True - - - - - True - False - Restore Partition Image… - True - - - - - True - False - Benchmark Partition… - - - diff --git a/src/disks/ui/drive-menu.ui b/src/disks/ui/drive-menu.ui new file mode 100644 index 00000000..97505c26 --- /dev/null +++ b/src/disks/ui/drive-menu.ui @@ -0,0 +1,49 @@ + + + +
+ + Format _Disk… + win.format-disk + +
+
+ + _Create Disk Image… + win.create-disk-image + + + _Restore Disk Image… + win.restore-disk-image + +
+
+ + _Benchmark Disk… + win.benchmark-disk + + + _SMART Data & Self-Tests… + win.view-smart + + + Drive S_ettings… + win.disk-settings + +
+
+ + S_tandby Now + win.standby-now + + + _Wake-Up from Standby + win.resume-now + + + _Power Off + win.power-off + +
+
+
diff --git a/src/disks/ui/headerbar.ui b/src/disks/ui/headerbar.ui new file mode 100644 index 00000000..c3012e57 --- /dev/null +++ b/src/disks/ui/headerbar.ui @@ -0,0 +1,95 @@ + + + + + horizontal + 200 + + + False + Disks + True + + + True + none + + + end + + + + + False + + + + + + + False + True + + + True + Drive Options + + + True + view-more-symbolic + + + + + end + + + + + True + Power off this disk + + + True + system-shutdown-symbolic + + + + + end + + + + + True + Eject this disk + + + True + media-eject-symbolic + + + + + end + + + + + True + Detach this loop device + + + True + list-remove-symbolic + + + + + end + + + + + + diff --git a/src/disks/ui/shortcuts.ui b/src/disks/ui/shortcuts.ui new file mode 100644 index 00000000..b338253f --- /dev/null +++ b/src/disks/ui/shortcuts.ui @@ -0,0 +1,108 @@ + + + + True + + + True + shortcuts + 10 + + + True + General + + + True + Create a new empty disk image + <Primary>n + + + + + True + Attach an existing disk image + <Primary>a + + + + + True + Help + F1 + + + + + True + Quit + <Primary>q + + + + + + + True + Drive + + + True + Open the drive menu + F10 + + + + + True + Format the drive + <Primary>d + + + + + True + Restore an image to the disk + <Primary>r + + + + + True + SMART data + <Primary>s + + + + + True + Drive settings + <Primary>e + + + + + + + True + Partition + + + True + Open the volume menu + <Shift>F10 + + + + + True + Format the selected volume + <Primary>p + + + + + + + + diff --git a/src/disks/ui/volume-menu.ui b/src/disks/ui/volume-menu.ui new file mode 100644 index 00000000..b780c544 --- /dev/null +++ b/src/disks/ui/volume-menu.ui @@ -0,0 +1,63 @@ + + + +
+ + Format _Partition… + win.format-partition + +
+
+ + _Edit Partition… + win.edit-partition + + + Edit _Filesystem… + win.edit-label + + + Change Pa_ssphrase… + win.change-passphrase + +
+
+ + Resi_ze… + win.resize + + + C_heck Filesystem… + win.check-fs + + + Rep_air Filesystem… + win.repair-fs + +
+
+ + Edit _Mount Options… + win.configure-fstab + + + Edit Encr_yption Options… + win.configure-crypttab + +
+
+ + _Create Partition Image… + win.create-partition-image + + + _Restore Partition Image… + win.restore-partition-image + + + _Benchmark Partition… + win.benchmark-partition + +
+
+