[gnome-disk-utility/wip/mdraid] Add a "Create RAID Array..." menu item
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility/wip/mdraid] Add a "Create RAID Array..." menu item
- Date: Fri, 21 Sep 2012 19:55:32 +0000 (UTC)
commit ccc775cabbdc869e065d25c87dfebc6fbc80320d
Author: David Zeuthen <zeuthen gmail com>
Date: Fri Sep 21 15:54:32 2012 -0400
Add a "Create RAID Array..." menu item
All we need to do now is to show the dialog...
Signed-off-by: David Zeuthen <zeuthen gmail com>
data/ui/app-menu.ui | 4 ++
data/ui/disks.ui | 28 +++++++++++++--
src/disks/gduapplication.c | 10 +++++
src/disks/gduwindow.c | 85 ++++++++++++++++++++++++++++++++++++++-----
src/disks/gduwindow.h | 1 +
5 files changed, 115 insertions(+), 13 deletions(-)
---
diff --git a/data/ui/app-menu.ui b/data/ui/app-menu.ui
index c14c614..06ef9de 100644
--- a/data/ui/app-menu.ui
+++ b/data/ui/app-menu.ui
@@ -6,6 +6,10 @@
<attribute name="label" translatable="yes">Attach Disk _Image...</attribute>
<attribute name="action">app.attach_disk_image</attribute>
</item>
+ <item>
+ <attribute name="label" translatable="yes">Create RAID Array...</attribute>
+ <attribute name="action">app.create_raid_array</attribute>
+ </item>
</section>
<section>
<item>
diff --git a/data/ui/disks.ui b/data/ui/disks.ui
index f00d9bb..05e571b 100644
--- a/data/ui/disks.ui
+++ b/data/ui/disks.ui
@@ -128,13 +128,13 @@
<property name="can_focus">False</property>
<property name="icon_size">1</property>
<child>
- <object class="GtkToolButton" id="device-tree-attach-disk-image-button">
+ <object class="GtkToolButton" id="device-tree-add-menu-button">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
- <property name="tooltip_markup" translatable="yes">Attach Disk Image...</property>
- <property name="tooltip_text" translatable="yes">Attach Disk Image...</property>
+ <property name="tooltip_markup" translatable="yes">Attach or Create...</property>
+ <property name="tooltip_text" translatable="yes">Attach or Create...</property>
<property name="use_action_appearance">False</property>
<property name="icon_name">list-add-symbolic</property>
</object>
@@ -1796,4 +1796,26 @@
</object>
</child>
</object>
+ <object class="GtkMenu" id="device-tree-menu">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkMenuItem" id="device-tree-menu-item-attach-disk-image">
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Attach Disk Image...</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="device-tree-menu-item-create-raid-array">
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Create RAID Array...</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ </object>
</interface>
diff --git a/src/disks/gduapplication.c b/src/disks/gduapplication.c
index ea68f8d..7fbf6ea 100644
--- a/src/disks/gduapplication.c
+++ b/src/disks/gduapplication.c
@@ -102,6 +102,15 @@ attach_disk_image_activated (GSimpleAction *action,
}
static void
+create_raid_array_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ GduApplication *app = GDU_APPLICATION (user_data);
+ gdu_window_show_create_raid_array (app->window);
+}
+
+static void
about_activated (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
@@ -136,6 +145,7 @@ quit_activated (GSimpleAction *action,
static GActionEntry app_entries[] =
{
{ "attach_disk_image", attach_disk_image_activated, NULL, NULL, NULL },
+ { "create_raid_array", create_raid_array_activated, NULL, NULL, NULL },
{ "about", about_activated, NULL, NULL, NULL },
{ "quit", quit_activated, NULL, NULL, NULL }
};
diff --git a/src/disks/gduwindow.c b/src/disks/gduwindow.c
index 3a44906..01a0f0e 100644
--- a/src/disks/gduwindow.c
+++ b/src/disks/gduwindow.c
@@ -70,7 +70,7 @@ struct _GduWindow
GtkWidget *device_scrolledwindow;
GtkWidget *device_treeview;
GtkWidget *device_toolbar;
- GtkWidget *device_toolbar_attach_disk_image_button;
+ GtkWidget *device_toolbar_add_menu_button;
GtkWidget *device_toolbar_detach_disk_image_button;
GtkWidget *devtab_drive_box;
GtkWidget *devtab_drive_vbox;
@@ -153,6 +153,10 @@ struct _GduWindow
/* GtkLabel instances we need to handle ::activate-link for */
GtkWidget *devtab_volume_type_value_label;
+
+ GtkWidget *device_tree_menu;
+ GtkWidget *device_tree_menu_item_attach_disk_image;
+ GtkWidget *device_tree_menu_item_create_raid_array;
};
static const struct {
@@ -163,7 +167,7 @@ static const struct {
{G_STRUCT_OFFSET (GduWindow, main_hpane), "main-hpane"},
{G_STRUCT_OFFSET (GduWindow, device_scrolledwindow), "device-tree-scrolledwindow"},
{G_STRUCT_OFFSET (GduWindow, device_toolbar), "device-tree-add-remove-toolbar"},
- {G_STRUCT_OFFSET (GduWindow, device_toolbar_attach_disk_image_button), "device-tree-attach-disk-image-button"},
+ {G_STRUCT_OFFSET (GduWindow, device_toolbar_add_menu_button), "device-tree-add-menu-button"},
{G_STRUCT_OFFSET (GduWindow, device_toolbar_detach_disk_image_button), "device-tree-detach-disk-image-button"},
{G_STRUCT_OFFSET (GduWindow, device_treeview), "device-tree-treeview"},
{G_STRUCT_OFFSET (GduWindow, details_notebook), "disks-notebook"},
@@ -249,6 +253,10 @@ static const struct {
/* GtkLabel instances we need to handle ::activate-link for */
{G_STRUCT_OFFSET (GduWindow, devtab_volume_type_value_label), "devtab-volume-type-value-label"},
+ {G_STRUCT_OFFSET (GduWindow, device_tree_menu), "device-tree-menu"},
+ {G_STRUCT_OFFSET (GduWindow, device_tree_menu_item_attach_disk_image), "device-tree-menu-item-attach-disk-image"},
+ {G_STRUCT_OFFSET (GduWindow, device_tree_menu_item_create_raid_array), "device-tree-menu-item-create-raid-array"},
+
{0, NULL}
};
@@ -322,6 +330,12 @@ typedef struct
ShowFlagsDeviceTreeButtons device_tree_buttons;
} ShowFlags;
+static void generic_menu_position_func (GtkMenu *menu,
+ gint *x,
+ gint *y,
+ gboolean *push_in,
+ gpointer user_data);
+
/* ---------------------------------------------------------------------------------------------------- */
static void setup_device_page (GduWindow *window, UDisksObject *object);
@@ -397,6 +411,12 @@ static gboolean on_activate_link (GtkLabel *label,
const gchar *uri,
gpointer user_data);
+static void on_device_tree_menu_item_attach_disk_image (GtkMenuItem *menu_item,
+ gpointer user_data);
+
+static void on_device_tree_menu_item_create_raid_array (GtkMenuItem *menu_item,
+ gpointer user_data);
+
G_DEFINE_TYPE (GduWindow, gdu_window, GTK_TYPE_APPLICATION_WINDOW);
static void
@@ -853,14 +873,51 @@ gdu_window_show_attach_disk_image (GduWindow *window)
g_free (filename);
}
+/* ---------------------------------------------------------------------------------------------------- */
+
static void
-on_device_tree_attach_disk_image_button_clicked (GtkToolButton *button,
- gpointer user_data)
+on_device_tree_menu_item_attach_disk_image (GtkMenuItem *menu_item,
+ gpointer user_data)
{
GduWindow *window = GDU_WINDOW (user_data);
gdu_window_show_attach_disk_image (window);
}
+static void
+on_device_tree_menu_item_create_raid_array (GtkMenuItem *menu_item,
+ gpointer user_data)
+{
+ GduWindow *window = GDU_WINDOW (user_data);
+ gdu_window_show_create_raid_array (window);
+}
+
+void
+gdu_window_show_create_raid_array (GduWindow *window)
+{
+ g_print ("TODO: show create RAID array dialog\n");
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+
+static void
+on_device_tree_add_menu_button_clicked (GtkToolButton *button,
+ gpointer user_data)
+{
+ GduWindow *window = GDU_WINDOW (user_data);
+ GdkEventButton *event = NULL;
+
+ gtk_menu_popup_for_device (GTK_MENU (window->device_tree_menu),
+ event != NULL ? event->device : NULL,
+ NULL, /* parent_menu_shell */
+ NULL, /* parent_menu_item */
+ generic_menu_position_func,
+ button,
+ NULL, /* user_data GDestroyNotify */
+ event != NULL ? event->button : 0,
+ event != NULL ? event->time : gtk_get_current_event_time ());
+}
+
/* ---------------------------------------------------------------------------------------------------- */
gboolean
@@ -1209,9 +1266,9 @@ gdu_window_constructed (GObject *object)
gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
/* main toolbar */
- g_signal_connect (window->device_toolbar_attach_disk_image_button,
+ g_signal_connect (window->device_toolbar_add_menu_button,
"clicked",
- G_CALLBACK (on_device_tree_attach_disk_image_button_clicked),
+ G_CALLBACK (on_device_tree_add_menu_button_clicked),
window);
g_signal_connect (window->device_toolbar_detach_disk_image_button,
"clicked",
@@ -1370,6 +1427,16 @@ gdu_window_constructed (GObject *object)
G_CALLBACK (on_activate_link),
window);
+ /* device-tree add menu */
+ g_signal_connect (window->device_tree_menu_item_attach_disk_image,
+ "activate",
+ G_CALLBACK (on_device_tree_menu_item_attach_disk_image),
+ window);
+ g_signal_connect (window->device_tree_menu_item_create_raid_array,
+ "activate",
+ G_CALLBACK (on_device_tree_menu_item_create_raid_array),
+ window);
+
g_idle_add (on_constructed_in_idle, g_object_ref (window));
}
@@ -3502,8 +3569,7 @@ generic_menu_position_func (GtkMenu *menu,
gboolean *push_in,
gpointer user_data)
{
- GduWindow *window = GDU_WINDOW (user_data);
- GtkWidget *align_widget;
+ GtkWidget *align_widget = GTK_WIDGET (user_data);
GtkRequisition menu_req;
GtkTextDirection direction;
GdkRectangle monitor;
@@ -3514,7 +3580,6 @@ generic_menu_position_func (GtkMenu *menu,
GtkAlign align;
GtkWidget *toplevel;
- align_widget = window->toolbutton_generic_menu;
align = gtk_widget_get_halign (GTK_WIDGET (menu));
direction = gtk_widget_get_direction (align_widget);
gdk_window = gtk_widget_get_window (align_widget);
@@ -3577,7 +3642,7 @@ on_devtab_action_generic_activated (GtkAction *action,
NULL, /* parent_menu_shell */
NULL, /* parent_menu_item */
generic_menu_position_func,
- window,
+ window->toolbutton_generic_menu,
NULL, /* user_data GDestroyNotify */
event != NULL ? event->button : 0,
event != NULL ? event->time : gtk_get_current_event_time ());
diff --git a/src/disks/gduwindow.h b/src/disks/gduwindow.h
index a348014..991ae5b 100644
--- a/src/disks/gduwindow.h
+++ b/src/disks/gduwindow.h
@@ -30,6 +30,7 @@ gboolean gdu_window_select_object (GduWindow *window,
void gdu_window_show_attach_disk_image (GduWindow *window);
+void gdu_window_show_create_raid_array (GduWindow *window);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]