diff options
-rw-r--r-- | ChangeLog | 21 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/beaver-settings-page.c | 124 | ||||
-rw-r--r-- | src/beaver-target-device.c | 129 | ||||
-rw-r--r-- | src/beaver-target-device.h | 46 | ||||
-rw-r--r-- | src/beaver.h | 3 | ||||
-rw-r--r-- | src/plugin.c | 219 | ||||
-rw-r--r-- | src/plugin.h | 11 |
8 files changed, 456 insertions, 98 deletions
@@ -1,3 +1,24 @@ +2008-03-19 Rob Bradford <rob@openedhand.com> + + * src/Makefile.am: + * src/beaver-settings-page.c: (radio_toggled_cb), (create_ui): + * src/beaver-target-device.c: (beaver_target_device_get_property), + (beaver_target_device_set_property), + (beaver_target_device_dispose), (beaver_target_device_finalize), + (beaver_target_device_set_state), (beaver_target_device_get_state), + (beaver_target_device_get_ip_address), + (beaver_target_device_class_init), (beaver_target_device_init), + (beaver_target_device_new): + * src/beaver-target-device.h: + * src/beaver.h: + * src/plugin.c: (update_state), (setup_target), + (rootfs_preference_notify_cb), (kernel_preference_notify_cb), + (target_mode_preference_notify_cb), + (target_ip_preference_notify_cb), (target_state_changed_cb), + (anjuta_plugin_sdk_activate), (anjuta_plugin_sdk_deactivate): + * src/plugin.h: + Add support for using an external device. + 2008-03-18 Rob Bradford <rob@openedhand.com> * src/Makefile.am: diff --git a/src/Makefile.am b/src/Makefile.am index c17f3e1..f01fada 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -45,6 +45,7 @@ plugin_LTLIBRARIES = libanjuta-plugin-sdk.la libanjuta_plugin_sdk_la_SOURCES = plugin.c plugin.h \ beaver-target.c beaver-target.h \ beaver-target-qemu.c beaver-target-qemu.h \ + beaver-target-device.c beaver-target-device.h \ beaver-util.c beaver-util.h \ beaver-settings-page.c beaver-settings-page.h \ beaver.h diff --git a/src/beaver-settings-page.c b/src/beaver-settings-page.c index ea9537a..ccf380a 100644 --- a/src/beaver-settings-page.c +++ b/src/beaver-settings-page.c @@ -146,14 +146,7 @@ preferences_timeout_cb (gpointer userdata) } static void -full_radio_toggled_cb (GtkToggleButton *toggle, gpointer userdata) -{ - gtk_widget_set_sensitive (GTK_WIDGET (userdata), - gtk_toggle_button_get_active (toggle)); -} - -static void -toolchain_radio_toggled_cb (GtkToggleButton *toggle, gpointer userdata) +radio_toggled_cb (GtkToggleButton *toggle, gpointer userdata) { gtk_widget_set_sensitive (GTK_WIDGET (userdata), gtk_toggle_button_get_active (toggle)); @@ -166,8 +159,8 @@ create_ui (BeaverSettingsPage *page) GtkSizeGroup *opts_labels_group; GtkSizeGroup *opts_fields_group; - GtkSizeGroup *qemu_labels_group; - GtkSizeGroup *qemu_fields_group; + GtkSizeGroup *target_labels_group; + GtkSizeGroup *target_fields_group; GtkWidget *frame; GtkWidget *inner_vbox; @@ -181,6 +174,9 @@ create_ui (BeaverSettingsPage *page) GtkWidget *toolchain_radio; GtkWidget *full_radio; + GtkWidget *qemu_radio; + GtkWidget *device_radio; + gboolean res; gchar *filename = NULL; @@ -208,7 +204,7 @@ create_ui (BeaverSettingsPage *page) /* Radio for external toolchain */ toolchain_radio = gtk_radio_button_new_with_label (NULL, - _("Use an external toolchain")); + _("Use an external toolchain:")); gtk_box_pack_start (GTK_BOX (inner_vbox), toolchain_radio, TRUE, FALSE, 0); /* Widgets for sdk root */ @@ -218,7 +214,7 @@ create_ui (BeaverSettingsPage *page) hbox = gtk_hbox_new (FALSE, 6); gtk_container_add (GTK_CONTAINER (inner_alignment), hbox); - g_signal_connect (toolchain_radio, "toggled", (GCallback)toolchain_radio_toggled_cb, + g_signal_connect (toolchain_radio, "toggled", (GCallback)radio_toggled_cb, hbox); /* label */ @@ -258,7 +254,7 @@ create_ui (BeaverSettingsPage *page) hbox = gtk_hbox_new (FALSE, 6); gtk_container_add (GTK_CONTAINER (inner_alignment), hbox); - g_signal_connect (full_radio, "toggled", (GCallback)full_radio_toggled_cb, + g_signal_connect (full_radio, "toggled", (GCallback)radio_toggled_cb, hbox); /* Make the full options insensitive since by default we used external @@ -312,7 +308,10 @@ create_ui (BeaverSettingsPage *page) /* Widgets for toolchain triplet */ hbox = gtk_hbox_new (FALSE, 6); - gtk_box_pack_start (GTK_BOX (inner_vbox), hbox, TRUE, FALSE, 0); + inner_alignment = gtk_alignment_new (0, 0.5, 1, 1); + g_object_set (inner_alignment, "top-padding", 6, NULL); + gtk_container_add (GTK_CONTAINER (inner_alignment), hbox); + gtk_box_pack_start (GTK_BOX (inner_vbox), inner_alignment, TRUE, FALSE, 0); /* label */ label = gtk_label_new (_("Toolchain triplet: ")); @@ -337,17 +336,13 @@ create_ui (BeaverSettingsPage *page) if (!res) g_warning ("Error adding preference for triplet"); - /* Frame for qemu */ - frame = gtk_frame_new ("<b>QEMU Options</b>"); + /* Frame for target */ + frame = gtk_frame_new (_("<b>Target Options</b>")); gtk_box_pack_start (GTK_BOX (page), frame, FALSE, FALSE, 2); gtk_label_set_use_markup (GTK_LABEL (gtk_frame_get_label_widget (GTK_FRAME (frame))), TRUE); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE); - /* size groups for files */ - qemu_labels_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); - qemu_fields_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); - /* Pack inner vbox */ inner_vbox = gtk_vbox_new (FALSE, 6); inner_alignment = gtk_alignment_new (0, 0.5, 1, 1); @@ -355,20 +350,38 @@ create_ui (BeaverSettingsPage *page) gtk_container_add (GTK_CONTAINER (inner_alignment), inner_vbox); gtk_container_add (GTK_CONTAINER (frame), inner_alignment); + /* QEMU */ + qemu_radio = gtk_radio_button_new_with_label (NULL, _("Use QEMU Device Emulator")); + gtk_box_pack_start (GTK_BOX (inner_vbox), qemu_radio, TRUE, FALSE, 2); + + inner_alignment = gtk_alignment_new (0, 0.5, 1, 1); + g_object_set (inner_alignment, "left-padding", 24, NULL); + + qemu_vbox = gtk_vbox_new (FALSE, 6); + gtk_container_add (GTK_CONTAINER (inner_alignment), qemu_vbox); + gtk_box_pack_start (GTK_BOX (inner_vbox), inner_alignment, TRUE, FALSE, 2); + + g_signal_connect (qemu_radio, "toggled", (GCallback)radio_toggled_cb, + qemu_vbox); + + /* size groups for files */ + target_labels_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); + target_fields_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); + /* Widgets for kernel */ hbox = gtk_hbox_new (FALSE, 6); - gtk_box_pack_start (GTK_BOX (inner_vbox), hbox, TRUE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (qemu_vbox), hbox, TRUE, FALSE, 0); /* label */ label = gtk_label_new ("Kernel: "); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_size_group_add_widget (qemu_labels_group, label); + gtk_size_group_add_widget (target_labels_group, label); gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); /* chooser */ chooser = gtk_file_chooser_button_new (_("Select kernel file"), GTK_FILE_CHOOSER_ACTION_OPEN); gtk_box_pack_start (GTK_BOX (hbox), chooser, TRUE, TRUE, 0); - gtk_size_group_add_widget (qemu_fields_group, chooser); + gtk_size_group_add_widget (target_fields_group, chooser); anjuta_preferences_register_property_raw ( priv->prefs, @@ -383,19 +396,19 @@ create_ui (BeaverSettingsPage *page) /* Widgets for rootfs */ hbox = gtk_hbox_new (FALSE, 6); - gtk_box_pack_start (GTK_BOX (inner_vbox), hbox, TRUE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (qemu_vbox), hbox, TRUE, FALSE, 0); /* label */ label = gtk_label_new ("Root filesystem: "); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_size_group_add_widget (qemu_labels_group, label); + gtk_size_group_add_widget (target_labels_group, label); gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); /* chooser */ chooser = gtk_file_chooser_button_new (_("Select root filesystem file"), GTK_FILE_CHOOSER_ACTION_OPEN); gtk_box_pack_start (GTK_BOX (hbox), chooser, TRUE, TRUE, 0); - gtk_size_group_add_widget (qemu_fields_group, chooser); + gtk_size_group_add_widget (target_fields_group, chooser); priv->rootfs_chooser = chooser; anjuta_preferences_register_property_raw ( @@ -407,6 +420,65 @@ create_ui (BeaverSettingsPage *page) ANJUTA_PROPERTY_OBJECT_TYPE_FILE, ANJUTA_PROPERTY_DATA_TYPE_TEXT); + /* device */ + device_radio = gtk_radio_button_new_with_label_from_widget ( + GTK_RADIO_BUTTON (qemu_radio), _("Use an external device")); + gtk_box_pack_start (GTK_BOX (inner_vbox), device_radio, TRUE, FALSE, 2); + + /* widgets for device entry */ + inner_alignment = gtk_alignment_new (0, 0.5, 1, 1); + g_object_set (inner_alignment, "left-padding", 24, NULL); + gtk_box_pack_start (GTK_BOX (inner_vbox), inner_alignment, TRUE, FALSE, 0); + hbox = gtk_hbox_new (FALSE, 6); + gtk_container_add (GTK_CONTAINER (inner_alignment), hbox); + gtk_widget_set_sensitive (hbox, FALSE); + + g_signal_connect (device_radio, "toggled", (GCallback)radio_toggled_cb, + hbox); + + /* Register a preference for the toggle */ + + /* This is all a bit of a hack, we register the property on the second one + * in the group. If the mode is 1 then this gets selected and the world is a + * happy place. But if this is 0, then the group is in an inconsistent + * state...Ah, but actually when the widgets are created the first is + * toggled on by default. + */ + res = anjuta_preferences_register_property_raw ( + priv->prefs, + device_radio, + PREFS_PROP_TARGET_MODE, + NULL, + 0, + ANJUTA_PROPERTY_OBJECT_TYPE_TOGGLE, + ANJUTA_PROPERTY_DATA_TYPE_INT); + + if (!res) + g_warning ("Error adding preference for mode of operation"); + + /* label */ + label = gtk_label_new ("IP address:"); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_size_group_add_widget (target_labels_group, label); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + + /* entry */ + entry = gtk_entry_new (); + gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0); + gtk_size_group_add_widget (target_fields_group, label); + + /* register prop */ + res = anjuta_preferences_register_property_raw (priv->prefs, + entry, + PREFS_PROP_TARGET_IP, + NULL, + 0, + ANJUTA_PROPERTY_OBJECT_TYPE_ENTRY, + ANJUTA_PROPERTY_DATA_TYPE_TEXT); + + if (!res) + g_warning ("Error adding preference for target IP"); + /* add page */ gtk_widget_show_all (GTK_WIDGET (page)); diff --git a/src/beaver-target-device.c b/src/beaver-target-device.c new file mode 100644 index 0000000..fe684b6 --- /dev/null +++ b/src/beaver-target-device.c @@ -0,0 +1,129 @@ +#include "beaver-target-device.h" + +G_DEFINE_TYPE (BeaverTargetDevice, beaver_target_device, BEAVER_TYPE_TARGET) + +#define TARGET_DEVICE_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((o), BEAVER_TYPE_TARGET_DEVICE, BeaverTargetDevicePrivate)) + +typedef struct _BeaverTargetDevicePrivate BeaverTargetDevicePrivate; + +struct _BeaverTargetDevicePrivate { + BeaverTargetState state; + gchar *ip_address; +}; + +enum +{ + PROP_0 = 0, + PROP_IP_ADDRESS +}; + +static void +beaver_target_device_get_property (GObject *object, guint property_id, + GValue *value, GParamSpec *pspec) +{ + BeaverTargetDevicePrivate *priv = TARGET_DEVICE_PRIVATE (object); + + switch (property_id) { + case PROP_IP_ADDRESS: + g_value_set_string (value, priv->ip_address); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +beaver_target_device_set_property (GObject *object, guint property_id, + const GValue *value, GParamSpec *pspec) +{ + BeaverTargetDevicePrivate *priv = TARGET_DEVICE_PRIVATE (object); + + switch (property_id) { + case PROP_IP_ADDRESS: + g_free (priv->ip_address); + + priv->ip_address = g_value_dup_string (value); + + if (priv->ip_address) + priv->state = TARGET_STATE_READY; + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +beaver_target_device_dispose (GObject *object) +{ + if (G_OBJECT_CLASS (beaver_target_device_parent_class)->dispose) + G_OBJECT_CLASS (beaver_target_device_parent_class)->dispose (object); +} + +static void +beaver_target_device_finalize (GObject *object) +{ + if (G_OBJECT_CLASS (beaver_target_device_parent_class)->finalize) + G_OBJECT_CLASS (beaver_target_device_parent_class)->finalize (object); +} + +static void +beaver_target_device_set_state (BeaverTarget *target, BeaverTargetState state) +{ + BeaverTargetDevicePrivate *priv = TARGET_DEVICE_PRIVATE (target); + + priv->state = state; +} + +static BeaverTargetState +beaver_target_device_get_state (BeaverTarget *target) +{ + BeaverTargetDevicePrivate *priv = TARGET_DEVICE_PRIVATE (target); + + return priv->state; +} + +static const gchar * +beaver_target_device_get_ip_address (BeaverTarget *target) +{ + BeaverTargetDevicePrivate *priv = TARGET_DEVICE_PRIVATE (target); + + return priv->ip_address; +} + +static void +beaver_target_device_class_init (BeaverTargetDeviceClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + BeaverTargetClass *target_class = BEAVER_TARGET_CLASS (klass); + GParamSpec *pspec = NULL; + + g_type_class_add_private (klass, sizeof (BeaverTargetDevicePrivate)); + + object_class->get_property = beaver_target_device_get_property; + object_class->set_property = beaver_target_device_set_property; + object_class->dispose = beaver_target_device_dispose; + object_class->finalize = beaver_target_device_finalize; + + target_class->get_state = beaver_target_device_get_state; + target_class->set_state = beaver_target_device_set_state; + target_class->get_ip_address = beaver_target_device_get_ip_address; + + pspec = g_param_spec_string ("ip-address", "ip-address", "ip-address", + NULL, G_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_IP_ADDRESS, pspec); +} + +static void +beaver_target_device_init (BeaverTargetDevice *self) +{ +} + +BeaverTarget * +beaver_target_device_new (AnjutaShell *shell) +{ + return g_object_new (BEAVER_TYPE_TARGET_DEVICE, + "shell", shell, + NULL); +} + diff --git a/src/beaver-target-device.h b/src/beaver-target-device.h new file mode 100644 index 0000000..64f975a --- /dev/null +++ b/src/beaver-target-device.h @@ -0,0 +1,46 @@ +#ifndef _BEAVER_TARGET_DEVICE +#define _BEAVER_TARGET_DEVICE + +#include <glib-object.h> + +#include "beaver-target.h" + +G_BEGIN_DECLS + +#define BEAVER_TYPE_TARGET_DEVICE beaver_target_device_get_type() + +#define BEAVER_TARGET_DEVICE(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ + BEAVER_TYPE_TARGET_DEVICE, BeaverTargetDevice)) + +#define BEAVER_TARGET_DEVICE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), \ + BEAVER_TYPE_TARGET_DEVICE, BeaverTargetDeviceClass)) + +#define BEAVER_IS_TARGET_DEVICE(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ + BEAVER_TYPE_TARGET_DEVICE)) + +#define BEAVER_IS_TARGET_DEVICE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), \ + BEAVER_TYPE_TARGET_DEVICE)) + +#define BEAVER_TARGET_DEVICE_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), \ + BEAVER_TYPE_TARGET_DEVICE, BeaverTargetDeviceClass)) + +typedef struct { + BeaverTarget parent; +} BeaverTargetDevice; + +typedef struct { + BeaverTargetClass parent_class; +} BeaverTargetDeviceClass; + +GType beaver_target_device_get_type (void); + +BeaverTarget *beaver_target_device_new (AnjutaShell *shell); + +G_END_DECLS + +#endif /* _BEAVER_TARGET_DEVICE */ diff --git a/src/beaver.h b/src/beaver.h index c440901..cc61908 100644 --- a/src/beaver.h +++ b/src/beaver.h @@ -20,6 +20,7 @@ #include "beaver-target.h" #include "beaver-target-qemu.h" +#include "beaver-target-device.h" #include "beaver-settings-page.h" #define PREFS_PROP_SDK_ROOT "sdk.root" @@ -28,5 +29,7 @@ #define PREFS_PROP_POKY_MODE "sdk.poky_mode" #define PREFS_PROP_KERNEL "sdk.kernel" #define PREFS_PROP_ROOTFS "sdk.rootfs" +#define PREFS_PROP_TARGET_IP "sdk.target_ip" +#define PREFS_PROP_TARGET_MODE "sdk.target_mode" #endif /* _BEAVER */ diff --git a/src/plugin.c b/src/plugin.c index 0ea32c6..0662abd 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -162,6 +162,7 @@ static void remote_gdb_launcher_child_exited_cb (AnjutaLauncher *launcher, gint child_pid, gint status, gulong time, gpointer userdata); static void oprofileui_launcher_child_exited_cb (AnjutaLauncher *launcher, gint child_pid, gint status, gulong time, gpointer userdata); +static void target_state_changed_cb (BeaverTarget *target, gpointer userdata); /* Prototypes for deployment related activities */ static void deploy_set_state (AnjutaPluginSdk *sp, DeployState deploy_state); @@ -1209,6 +1210,115 @@ update_environment (AnjutaPluginSdk *sp) } static void +update_state (AnjutaPluginSdk *sp) +{ + BeaverTargetState state; + + state = beaver_target_get_state (sp->target); + + if (BEAVER_IS_TARGET_QEMU (sp->target)) + { + switch (state) + { + case TARGET_STATE_UNKNOWN: + gtk_action_set_sensitive (sp->qemu_start_action, FALSE); + break; + case TARGET_STATE_STOPPED: + gtk_action_set_sensitive (sp->qemu_start_action, TRUE); + break; + case TARGET_STATE_READY: + gtk_action_set_sensitive (sp->qemu_start_action, FALSE); + gtk_action_set_sensitive (sp->qemu_shutdown_action, TRUE); + case TARGET_STATE_BUSY: + gtk_action_set_sensitive (sp->qemu_shutdown_action, FALSE); + default: + break; + } + } else { + gtk_action_set_sensitive (sp->qemu_start_action, FALSE); + gtk_action_set_sensitive (sp->qemu_shutdown_action, FALSE); + } + + switch (state) + { + case TARGET_STATE_UNKNOWN: + case TARGET_STATE_STOPPED: + case TARGET_STATE_BUSY: + gtk_action_set_sensitive (sp->deploy_action, FALSE); + gtk_action_set_sensitive (sp->remote_profile_action, FALSE); + gtk_action_set_sensitive (sp->qemu_shutdown_action, FALSE); + gtk_action_set_sensitive (sp->remote_run_action, FALSE); + gtk_action_set_sensitive (sp->remote_debug_action, FALSE); + break; + case TARGET_STATE_READY: + /* Can only turn on if have a project */ + if (sp->project_root_uri) + gtk_action_set_sensitive (sp->deploy_action, TRUE); + + if (anjuta_util_prog_is_installed ("oprofile-viewer", FALSE)) + gtk_action_set_sensitive (sp->remote_profile_action, TRUE); + + gtk_action_set_sensitive (sp->remote_run_action, TRUE); + gtk_action_set_sensitive (sp->remote_debug_action, TRUE); + break; + } +} + + +static void +setup_target (AnjutaPluginSdk *sp) +{ + switch (sp->target_mode) + { + case TARGET_MODE_QEMU: + { + gchar *kernel = NULL; + gchar *rootfs = NULL; + + if (sp->target && + BEAVER_IS_TARGET_QEMU (sp->target)) + return; + + if (sp->target) + g_object_unref (sp->target); + + sp->target = beaver_target_qemu_new (ANJUTA_PLUGIN (sp)->shell); + + kernel = anjuta_preferences_get (sp->prefs, PREFS_PROP_KERNEL); + rootfs = anjuta_preferences_get (sp->prefs, PREFS_PROP_ROOTFS); + g_object_set (sp->target, "kernel", kernel, "rootfs", rootfs, NULL); + g_free (kernel); + g_free (rootfs); + break; + } + case TARGET_MODE_DEVICE: + { + gchar *ip_address = NULL; + if (sp->target && + BEAVER_IS_TARGET_DEVICE (sp->target)) + return; + + if (sp->target) + g_object_unref (sp->target); + + sp->target = beaver_target_device_new (ANJUTA_PLUGIN (sp)->shell); + + ip_address = anjuta_preferences_get (sp->prefs, PREFS_PROP_TARGET_IP); + g_object_set (sp->target, "ip-address", ip_address, NULL); + g_free (ip_address); + + break; + } + } + + g_signal_connect (sp->target, "state-changed", + (GCallback)target_state_changed_cb, sp); + + update_state (sp); +} + + +static void setup_buildable (AnjutaPluginSdk *sp) { gchar *command = NULL; @@ -1294,6 +1404,7 @@ rootfs_preference_notify_cb (GConfClient *client, guint cnxn_id, { rootfs = anjuta_preferences_get (sp->prefs, PREFS_PROP_ROOTFS); g_object_set (sp->target, "rootfs", rootfs, NULL); + g_free (rootfs); } } @@ -1308,6 +1419,7 @@ kernel_preference_notify_cb (GConfClient *client, guint cnxn_id, { kernel = anjuta_preferences_get (sp->prefs, PREFS_PROP_KERNEL); g_object_set (sp->target, "kernel", kernel, NULL); + g_free (kernel); } } @@ -1334,6 +1446,33 @@ poky_root_preference_notify_cb (GConfClient *client, guint cnxn_id, update_environment (sp); } +static void +target_mode_preference_notify_cb (GConfClient *client, guint cnxn_id, + GConfEntry *entry, gpointer userdata) +{ + AnjutaPluginSdk *sp = (AnjutaPluginSdk *)userdata; + + sp->target_mode = anjuta_preferences_get_int (sp->prefs, PREFS_PROP_TARGET_MODE); + + setup_target (sp); +} + +static void +target_ip_preference_notify_cb (GConfClient *client, guint cnxn_id, + GConfEntry *entry, gpointer userdata) +{ + AnjutaPluginSdk *sp = (AnjutaPluginSdk *)userdata; + gchar *ip_address = NULL; + + if (sp->target && + BEAVER_IS_TARGET_DEVICE (sp->target)) + { + ip_address = anjuta_preferences_get (sp->prefs, PREFS_PROP_TARGET_IP); + g_object_set (sp->target, "ip-address", ip_address, NULL); + g_free (ip_address); + } +} + /* * Callbacks for when a value for "project_root_uri" is added to the shell aka * when a project is opened @@ -1398,54 +1537,7 @@ static void target_state_changed_cb (BeaverTarget *target, gpointer userdata) { AnjutaPluginSdk *sp = (AnjutaPluginSdk *)userdata; - BeaverTargetState state; - - state = beaver_target_get_state (target); - - if (BEAVER_IS_TARGET_QEMU (target)) - { - switch (state) - { - case TARGET_STATE_UNKNOWN: - gtk_action_set_sensitive (sp->qemu_start_action, FALSE); - break; - case TARGET_STATE_STOPPED: - gtk_action_set_sensitive (sp->qemu_start_action, TRUE); - break; - case TARGET_STATE_READY: - gtk_action_set_sensitive (sp->qemu_start_action, FALSE); - gtk_action_set_sensitive (sp->qemu_shutdown_action, TRUE); - case TARGET_STATE_BUSY: - gtk_action_set_sensitive (sp->qemu_shutdown_action, FALSE); - default: - break; - } - } - - switch (state) - { - case TARGET_STATE_UNKNOWN: - case TARGET_STATE_STOPPED: - case TARGET_STATE_BUSY: - gtk_action_set_sensitive (sp->deploy_action, FALSE); - gtk_action_set_sensitive (sp->remote_profile_action, FALSE); - gtk_action_set_sensitive (sp->qemu_shutdown_action, FALSE); - gtk_action_set_sensitive (sp->remote_run_action, FALSE); - gtk_action_set_sensitive (sp->remote_debug_action, FALSE); - break; - case TARGET_STATE_READY: - /* Can only turn on if have a project */ - if (sp->project_root_uri) - gtk_action_set_sensitive (sp->deploy_action, TRUE); - - if (anjuta_util_prog_is_installed ("oprofile-viewer", FALSE)) - gtk_action_set_sensitive (sp->remote_profile_action, TRUE); - - gtk_action_set_sensitive (sp->qemu_shutdown_action, TRUE); - gtk_action_set_sensitive (sp->remote_run_action, TRUE); - gtk_action_set_sensitive (sp->remote_debug_action, TRUE); - break; - } + update_state (sp); } static gboolean @@ -1454,7 +1546,6 @@ anjuta_plugin_sdk_activate (AnjutaPlugin *plugin) AnjutaPluginSdk *sp = (AnjutaPluginSdk *)plugin; AnjutaUI *ui; GError *error = NULL; - IAnjutaMessageManager *msg_manager; gchar *kernel = NULL; gchar *rootfs = NULL; @@ -1488,6 +1579,7 @@ anjuta_plugin_sdk_activate (AnjutaPlugin *plugin) sp->remote_profile_action = anjuta_ui_get_action (ui, "ActionGroupSdk", "ActionRemoteProfile"); + gtk_action_set_sensitive (sp->qemu_start_action, FALSE); gtk_action_set_sensitive (sp->qemu_shutdown_action, FALSE); gtk_action_set_sensitive (sp->deploy_action, FALSE); gtk_action_set_sensitive (sp->remote_run_action, FALSE); @@ -1507,6 +1599,10 @@ anjuta_plugin_sdk_activate (AnjutaPlugin *plugin) PREFS_PROP_POKY_ROOT, poky_root_preference_notify_cb, sp, NULL); sp->poky_mode_notifyid = anjuta_preferences_notify_add (sp->prefs, PREFS_PROP_POKY_MODE, poky_mode_preference_notify_cb, sp, NULL); + sp->target_mode_notifyid = anjuta_preferences_notify_add (sp->prefs, + PREFS_PROP_TARGET_MODE, target_mode_preference_notify_cb, sp, NULL); + sp->target_ip_notifyid = anjuta_preferences_notify_add (sp->prefs, + PREFS_PROP_TARGET_IP, target_ip_preference_notify_cb, sp, NULL); sp->sdk_root = anjuta_preferences_get (sp->prefs, PREFS_PROP_SDK_ROOT); sp->triplet = anjuta_preferences_get (sp->prefs, PREFS_PROP_TRIPLET); @@ -1514,24 +1610,9 @@ anjuta_plugin_sdk_activate (AnjutaPlugin *plugin) sp->poky_root = anjuta_preferences_get (sp->prefs, PREFS_PROP_POKY_ROOT); sp->poky_mode = anjuta_preferences_get_int (sp->prefs, PREFS_PROP_POKY_MODE); - msg_manager = anjuta_shell_get_interface (ANJUTA_PLUGIN (sp)->shell, - IAnjutaMessageManager, &error); - - if (!msg_manager) - { - g_warning ("Error getting implementation of IAnjutaMessageManager: %s", - error->message); - g_clear_error (&error); - } - - sp->target = beaver_target_qemu_new (ANJUTA_PLUGIN (plugin)->shell); - g_signal_connect (sp->target, "state-changed", - (GCallback)target_state_changed_cb, sp); - - kernel = anjuta_preferences_get (sp->prefs, PREFS_PROP_KERNEL); - rootfs = anjuta_preferences_get (sp->prefs, PREFS_PROP_ROOTFS); - g_object_set (sp->target, "kernel", kernel, "rootfs", rootfs, NULL); + sp->target_mode = anjuta_preferences_get_int (sp->prefs, PREFS_PROP_TARGET_MODE); + setup_target (sp); update_environment (sp); setup_buildable (sp); @@ -1593,6 +1674,8 @@ anjuta_plugin_sdk_deactivate (AnjutaPlugin *plugin) anjuta_preferences_notify_remove (sp->prefs, sp->kernel_notifyid); anjuta_preferences_notify_remove (sp->prefs, sp->poky_root_notifyid); anjuta_preferences_notify_remove (sp->prefs, sp->poky_mode_notifyid); + anjuta_preferences_notify_remove (sp->prefs, sp->target_mode_notifyid); + anjuta_preferences_notify_remove (sp->prefs, sp->target_ip_notifyid); anjuta_plugin_remove_watch (plugin, sp->project_root_uri_watch, FALSE); @@ -1648,8 +1731,6 @@ anjuta_plugin_sdk_deactivate (AnjutaPlugin *plugin) g_free (sp->sdk_root); g_free (sp->triplet); - g_free (sp->kernel); - g_free (sp->rootfs); g_free (sp->poky_root); g_free (sp->project_root_uri); @@ -1660,8 +1741,6 @@ anjuta_plugin_sdk_deactivate (AnjutaPlugin *plugin) sp->sdk_root = NULL; sp->triplet = NULL; - sp->kernel = NULL; - sp->rootfs = NULL; sp->poky_root = NULL; sp->project_root_uri = NULL; diff --git a/src/plugin.h b/src/plugin.h index 404a866..11f79e2 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -47,6 +47,12 @@ typedef enum POKY_MODE_FULL } PokyMode; +typedef enum +{ + TARGET_MODE_QEMU, + TARGET_MODE_DEVICE +} TargetMode; + struct _AnjutaPluginSdk { AnjutaPlugin parent; @@ -61,6 +67,8 @@ struct _AnjutaPluginSdk guint rootfs_notifyid; guint poky_root_notifyid; guint poky_mode_notifyid; + guint target_mode_notifyid; + guint target_ip_notifyid; guint remote_gdb_timeout; @@ -69,8 +77,7 @@ struct _AnjutaPluginSdk gchar *poky_root; PokyMode poky_mode; - gchar *kernel; - gchar *rootfs; + TargetMode target_mode; gchar *path_component; gchar *poky_scripts_dir; |