#define CREATE_MODE 1
#define DELETE_MODE 2
#define MODIFY_MODE 3
+#define RESET_MODE 4
GtkBuilder *g_builder;
GtkBuilder *g_create_builder;
disk_path = get_config_value(info_file, HARDWARE_GROUP, DISK_PATH_KEY);
basedisk_path = get_config_value(info_file, HARDWARE_GROUP, BASEDISK_PATH_KEY);
-
-#ifndef _WIN32
/* check image & base image */
if(access(disk_path, R_OK) != 0){
error_log = g_strdup_printf("The image does not exist \n\n"
show_message("Error", error_log);
g_free(error_log);
return;
- }
-
+ }
+#ifndef _WIN32
kvm = get_config_value(info_file, QEMU_GROUP, KVM_KEY);
if(g_file_test("/dev/kvm", G_FILE_TEST_EXISTS) && strcmp(kvm,"1") == 0)
{
else
enable_kvm = g_strdup_printf(" ");
#else /* _WIN32 */
- /* todo: check image & base image */
enable_kvm = g_strdup_printf(" ");
#endif
show_message("Warning", "Can not delete this target!\nVirtual target with the same name is running now!");
else if(type == MODIFY_MODE)
show_message("Warning", "Can not modify this target!\nVirtual target with the same name is running now!");
+ else if(type == RESET_MODE)
+ show_message("Warning", "Can not reset this target!\nVirtual target with the same name is running now!");
+ else
+ show_message("Warning", "Can not reset this target!\nVirtual target with the same name is running now!");
else
ERR("wrong type passed\n");
}
}
+void reset_clicked_cb(GtkWidget *widget, gpointer selection)
+{
+ GtkListStore *store;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ char *target_name;
+ char *cmd = NULL;
+ char *virtual_target_path;
+ char *info_file;
+ char *disk_path;
+ int file_status;
+ char* basedisk_path = NULL;
+ store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (list)));
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (list));
+
+ if (gtk_tree_model_get_iter_first(model, &iter) == FALSE)
+ return;
+
+ if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(selection),
+ &model, &iter)) {
+ //get target name
+ gtk_tree_model_get(model, &iter, TARGET_NAME, &target_name, -1);
+
+ if(check_shdmem(target_name, RESET_MODE)== -1)
+ return;
+
+ gboolean bResult = show_ok_cancel_message("Warning", "Are you sure you reset this target?");
+ if(bResult == FALSE)
+ return;
+ virtual_target_path = get_virtual_target_abs_path(target_name);
+ info_file = g_strdup_printf("%sconfig.ini", virtual_target_path);
+ file_status = is_exist_file(info_file);
+ if(file_status == -1 || file_status == FILE_NOT_EXISTS)
+ {
+ ERR( "target info file not exists : %s\n", target_name);
+ return;
+ }
+
+ basedisk_path = get_config_value(info_file, HARDWARE_GROUP, BASEDISK_PATH_KEY);
+ file_status = is_exist_file(basedisk_path);
+ if(file_status == -1 || file_status == FILE_NOT_EXISTS)
+ {
+ ERR( "Base image file not exists : %s\n", basedisk_path);
+ return;
+ }
+ disk_path = get_config_value(info_file, HARDWARE_GROUP, DISK_PATH_KEY);
+
+ // reset emulator image
+#ifdef _WIN32
+ cmd = g_strdup_printf("%s/bin/qemu-img.exe create -b %s -f qcow2 %s",
+ get_root_path(), basedisk_path, disk_path);
+#else
+ cmd = g_strdup_printf("qemu-img create -b %s -f qcow2 %s",
+ basedisk_path, disk_path);
+#endif
+ if(!run_cmd(cmd))
+ {
+ g_free(cmd);
+ free(basedisk_path);
+ free(disk_path);
+ show_message("Error", "emulator image reset failed!");
+ return;
+ }
+ g_free(cmd);
+ g_free(target_name);
+ free(basedisk_path);
+ free(disk_path);
+ show_message("INFO","Virtual target reset success!");
+ return;
+ }
+
+ show_message("Warning", "Target is not selected. Firstly select a target and reset.");
+}
+
void details_clicked_cb(GtkWidget *widget, gpointer selection)
{
GtkListStore *store;
}
ram_size_detail = g_strdup_printf("%sMB", ram_size);
-
-#ifndef _WIN32
- /* check image & base image */
+
if(access(disk_path, R_OK) != 0){
details = g_strdup_printf("The image does not exist \n\n"
" - [%s]", disk_path);
g_free(details);
}
+#ifndef _WIN32
+ /* check image & base image */
+
details = g_strdup_printf(""
" - Name: %s\n"
" - CPU: %s\n"
-
+<?xml version="1.0"?>
<interface>
<!-- interface-requires gtk+ 2.10 -->
<!-- interface-naming-policy project-wide -->
<object class="GtkWindow" id="window1">
- <property name="width_request">430</property>
- <property name="height_request">280</property>
+ <property name="width_request">451</property>
+ <property name="height_request">345</property>
<property name="border_width">6</property>
<property name="title" translatable="yes">Emulator Manager</property>
<property name="window_position">center</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">Select x86 architecture.</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">Selecting arm architecture is not supported currently.</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">radiobutton8</property>
</child>
<child>
<object class="GtkVBox" id="vbox2">
- <property name="width_request">89</property>
- <property name="height_request">73</property>
<property name="visible">True</property>
<property name="spacing">3</property>
<child>
<object class="GtkButton" id="button1">
+ <property name="width_request">95</property>
<property name="height_request">28</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Create new virtual target.</property>
+ <property name="xalign">0</property>
<property name="image_position">bottom</property>
<child>
<object class="GtkHBox" id="hbox13">
<child>
<object class="GtkLabel" id="label14">
<property name="visible">True</property>
+ <property name="xalign">0</property>
<property name="label" translatable="yes">Create</property>
+ <property name="ellipsize">end</property>
</object>
<packing>
<property name="position">1</property>
</child>
<child>
<object class="GtkButton" id="button3">
+ <property name="width_request">95</property>
<property name="height_request">28</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Modify selected virtual target.</property>
<child>
<object class="GtkHBox" id="hbox12">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="label13">
<property name="visible">True</property>
+ <property name="xalign">0</property>
<property name="label" translatable="yes">Modify</property>
+ <property name="ellipsize">end</property>
</object>
<packing>
<property name="position">1</property>
</child>
<child>
<object class="GtkButton" id="button2">
+ <property name="width_request">95</property>
<property name="height_request">28</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Delete selected virtual target.</property>
<child>
<object class="GtkHBox" id="hbox11">
<property name="visible">True</property>
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Delete</property>
+ <property name="ellipsize">end</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
- <object class="GtkHSeparator" id="hseparator1">
+ <object class="GtkButton" id="button9">
+ <property name="width_request">95</property>
+ <property name="height_request">28</property>
<property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Reset selected virtual target.</property>
+ <child>
+ <object class="GtkHBox" id="hbox18">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkImage" id="image9">
+ <property name="visible">True</property>
+ <property name="stock">gtk-undo</property>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label19">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Reset</property>
+ <property name="ellipsize">end</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
</object>
<packing>
<property name="expand">False</property>
- <property name="padding">5</property>
+ <property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
- <object class="GtkButton" id="button5">
+ <object class="GtkHSeparator" id="hseparator1">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="padding">7</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button8">
+ <property name="width_request">95</property>
<property name="height_request">28</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Refresh target list.</property>
<child>
- <object class="GtkHBox" id="hbox14">
+ <object class="GtkHBox" id="hbox15">
<property name="visible">True</property>
<child>
- <object class="GtkImage" id="image6">
+ <object class="GtkImage" id="image7">
<property name="visible">True</property>
- <property name="stock">gtk-info</property>
+ <property name="stock">gtk-refresh</property>
<property name="icon-size">1</property>
</object>
<packing>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label15">
+ <object class="GtkLabel" id="label16">
<property name="visible">True</property>
- <property name="label" translatable="yes">Details</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Refresh</property>
+ <property name="ellipsize">end</property>
</object>
<packing>
<property name="position">1</property>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="padding">1</property>
<property name="position">5</property>
</packing>
</child>
<child>
- <object class="GtkButton" id="button8">
+ <object class="GtkButton" id="button5">
+ <property name="width_request">95</property>
<property name="height_request">28</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Show virtual target information.</property>
<child>
- <object class="GtkHBox" id="hbox15">
+ <object class="GtkHBox" id="hbox14">
<property name="visible">True</property>
<child>
- <object class="GtkImage" id="image7">
+ <object class="GtkImage" id="image6">
<property name="visible">True</property>
- <property name="stock">gtk-refresh</property>
+ <property name="stock">gtk-info</property>
<property name="icon-size">1</property>
</object>
<packing>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label16">
+ <object class="GtkLabel" id="label15">
<property name="visible">True</property>
- <property name="label" translatable="yes">Refresh</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Details</property>
+ <property name="ellipsize">end</property>
</object>
<packing>
<property name="position">1</property>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">5</property>
+ <property name="padding">1</property>
+ <property name="position">6</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHSeparator" id="hseparator2">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="padding">7</property>
+ <property name="position">7</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button4">
+ <property name="width_request">95</property>
<property name="height_request">28</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Start selected virtual target.</property>
<signal name="clicked" handler="activate_clicked_cb"/>
<child>
<object class="GtkHBox" id="hbox16">
<child>
<object class="GtkLabel" id="label17">
<property name="visible">True</property>
- <property name="label" translatable="yes">Activate</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Start</property>
+ <property name="ellipsize">end</property>
</object>
<packing>
<property name="position">1</property>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">6</property>
+ <property name="position">8</property>
</packing>
</child>
</object>
<object class="GtkFileChooserButton" id="filechooserbutton2">
<property name="width_request">150</property>
<property name="visible">True</property>
- <property name="title" translatable="yes">Change Base Image</property>
+ <property name="title" translatable="yes">Select an existing Disk</property>
</object>
<packing>
<property name="padding">5</property>
</child>
<child>
<object class="GtkRadioButton" id="radiobutton12">
- <property name="label" translatable="yes">Use Default Base Image</property>
+ <property name="label" translatable="yes">Use default Base Image</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>