/** * gtk_action_set_stock_id: * @action: a #GtkAction * @stock_id: the stock id * * Sets the stock id on @action * * Since: 2.16 */ void gtk_action_set_stock_id (GtkAction *action, const gchar *stock_id) { gchar *tmp; g_return_if_fail (GTK_IS_ACTION (action)); g_return_if_fail (GTK_IS_ACTION (action)); tmp = action->private_data->stock_id; action->private_data->stock_id = g_strdup (stock_id); g_free (tmp); g_object_notify (G_OBJECT (action), "stock-id"); /* update label and short_label if appropriate */ if (!action->private_data->label_set) { GtkStockItem stock_item; if (action->private_data->stock_id && gtk_stock_lookup (action->private_data->stock_id, &stock_item)) gtk_action_set_label (action, stock_item.label); else gtk_action_set_label (action, NULL); action->private_data->label_set = FALSE; } }
void nemo_action_set_label (NemoAction *action, NemoFile *file) { const gchar *orig_label = nemo_action_get_orig_label (action); if (!test_string_for_label_token (orig_label) || file == NULL || action->selection_type != SELECTION_SINGLE) { gtk_action_set_label (GTK_ACTION (action), orig_label); return; } gchar *display_name = nemo_file_get_display_name (file); gchar **split = g_strsplit (orig_label, TOKEN_LABEL_FILE_NAME, 2); gchar *new_label = g_strconcat (split[0], display_name, split[1], NULL); gchar *escaped = eel_str_double_underscores (new_label); gtk_action_set_label (GTK_ACTION (action), escaped); g_strfreev (split); g_free (display_name); g_free (new_label); g_free (escaped); }
static void killswitch_state_changed (GObject *gobject, GParamSpec *pspec, gpointer user_data) { GObject *object; BluetoothApplet *applet = BLUETOOTH_APPLET (gobject); BluetoothKillswitchState state = bluetooth_applet_get_killswitch_state (applet); gboolean sensitive = TRUE; gboolean bstate = FALSE; const char *label, *status_label; if (state == BLUETOOTH_KILLSWITCH_STATE_NO_ADAPTER) { object = gtk_builder_get_object (xml, "bluetooth-applet-popup"); gtk_menu_popdown (GTK_MENU (object)); update_icon_visibility (); return; } if (state == BLUETOOTH_KILLSWITCH_STATE_SOFT_BLOCKED) { label = N_("Turn on Bluetooth"); status_label = N_("Bluetooth: Off"); bstate = FALSE; } else if (state == BLUETOOTH_KILLSWITCH_STATE_UNBLOCKED) { label = N_("Turn off Bluetooth"); status_label = N_("Bluetooth: On"); bstate = TRUE; } else if (state == BLUETOOTH_KILLSWITCH_STATE_HARD_BLOCKED) { sensitive = FALSE; label = NULL; status_label = N_("Bluetooth: Disabled"); } else { g_assert_not_reached (); } object = gtk_builder_get_object (xml, "killswitch-label"); gtk_action_set_label (GTK_ACTION (object), _(status_label)); gtk_action_set_visible (GTK_ACTION (object), TRUE); object = gtk_builder_get_object (xml, "killswitch"); gtk_action_set_visible (GTK_ACTION (object), sensitive); gtk_action_set_label (GTK_ACTION (object), _(label)); if (sensitive != FALSE) { gtk_action_set_label (GTK_ACTION (object), _(label)); g_object_set_data (object, "bt-active", GINT_TO_POINTER (bstate)); } object = gtk_builder_get_object (xml, "bluetooth-applet-ui-manager"); gtk_ui_manager_ensure_update (GTK_UI_MANAGER (object)); update_icon_visibility (); }
static void miscui_action_controller_update_label(MiscUIActionController *controller) { MiscUIActionControllerPrivate *privat = MISCUI_ACTION_CONTROLLER_GET_PRIVATE(controller); if (privat != NULL) { if (privat->action != NULL) { gchar *label = miscui_action_model_get_label(privat->model); if (label != NULL) { gtk_action_set_label( privat->action, label ); g_free(label); } else { /*! \todo Provide some default label */ } } } }
void on_reactlist_start(struct s_gui_data *gui_data) { gtk_action_set_label(gui_data->action_startPause, "Stop"); gtk_status_icon_set_from_pixbuf(gui_data->systrayIcon, gtk_image_get_pixbuf(gui_data->image_started)); gtk_image_set_from_icon_name(gui_data->image_startStop, ICON_NAME_STOP, GTK_ICON_SIZE_BUTTON); start_reading_event_log(gui_data); }
static void gnac_ui_update_trayicon_popup(void) { GtkAction *show_action = gnac_ui_get_action("tray_show_hide_item"); /* Translators: Show/Hide main window */ gchar *label_text = g_strdup((gnac_ui_main_window_is_visible() && state != GNAC_AUDIO_READY_STATE) ? _("Hide") : _("Show")); /* update the menu */ gtk_action_set_label(show_action, label_text); g_free(label_text); }
static void set_device_status_label (const char *address, int connected) { char *action_name, *action_path; GtkAction *status; GObject *object; const char *label; g_return_if_fail (address != NULL); switch (connected) { case DISCONNECTING: label = N_("Disconnecting..."); break; case CONNECTING: label = N_("Connecting..."); break; case CONNECTED: label = N_("Connected"); break; case DISCONNECTED: label = N_("Disconnected"); break; default: g_assert_not_reached (); } action_name = g_strdup_printf ("%s-status", address); status = gtk_action_group_get_action (devices_action_group, action_name); g_free (action_name); g_assert (status != NULL); gtk_action_set_label (status, _(label)); object = gtk_builder_get_object (xml, "bluetooth-applet-ui-manager"); action_path = g_strdup_printf ("/bluetooth-applet-popup/devices-placeholder/%s/%s-status", address, address); action_set_bold (GTK_UI_MANAGER (object), status, action_path); g_free (action_path); }
void gimp_action_group_set_action_label (GimpActionGroup *group, const gchar *action_name, const gchar *label) { GtkAction *action; g_return_if_fail (GIMP_IS_ACTION_GROUP (group)); g_return_if_fail (action_name != NULL); action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action_name); if (! action) { g_warning ("%s: Unable to set label of action " "which doesn't exist: %s", G_STRFUNC, action_name); return; } gtk_action_set_label (action, label); }
static void update_device_list (BluetoothApplet *applet, gpointer user_data) { GtkUIManager *uimanager; GList *actions, *devices, *l; gboolean has_devices = FALSE; uimanager = GTK_UI_MANAGER (gtk_builder_get_object (xml, "bluetooth-applet-ui-manager")); devices = bluetooth_applet_get_devices (applet); if (devices == NULL) { /* No devices? Remove everything */ actions = gtk_action_group_list_actions (devices_action_group); g_list_foreach (actions, (GFunc) remove_action_item, uimanager); g_list_free (actions); goto done; } /* Get a list of actions, and we'll remove the ones with a * device in the list. We remove the submenu items first */ actions = gtk_action_group_list_actions (devices_action_group); for (l = actions; l != NULL; l = l->next) { if (bluetooth_verify_address (gtk_action_get_name (l->data)) == FALSE) l->data = NULL; } actions = g_list_remove_all (actions, NULL); for (l = devices; l != NULL; l = g_list_next (l)) { BluetoothSimpleDevice *device = l->data; GtkAction *action, *status, *oper; char *name; if (device_has_submenu (device) == FALSE) { g_boxed_free (BLUETOOTH_TYPE_SIMPLE_DEVICE, device); continue; } has_devices = TRUE; action = gtk_action_group_get_action (devices_action_group, device->bdaddr); oper = NULL; status = NULL; if (action) { char *action_name; actions = g_list_remove (actions, action); action_name = g_strdup_printf ("%s-status", device->bdaddr); status = gtk_action_group_get_action (devices_action_group, action_name); g_free (action_name); action_name = g_strdup_printf ("%s-action", device->bdaddr); oper = gtk_action_group_get_action (devices_action_group, action_name); g_free (action_name); } name = escape_label_for_action (device->alias); if (action == NULL) { guint menu_merge_id; char *action_path; /* The menu item with descendants */ action = gtk_action_new (device->bdaddr, name, NULL, NULL); gtk_action_group_add_action (devices_action_group, action); g_object_unref (action); menu_merge_id = gtk_ui_manager_new_merge_id (uimanager); gtk_ui_manager_add_ui (uimanager, menu_merge_id, "/bluetooth-applet-popup/devices-placeholder", device->bdaddr, device->bdaddr, GTK_UI_MANAGER_MENU, FALSE); g_object_set_data_full (G_OBJECT (action), "merge-id", GUINT_TO_POINTER (menu_merge_id), NULL); /* The status menu item */ status = add_menu_item (device->bdaddr, "status", device->connected ? _("Connected") : _("Disconnected"), uimanager, menu_merge_id, NULL); gtk_action_set_sensitive (status, FALSE); if (device->can_connect) { action_path = g_strdup_printf ("/bluetooth-applet-popup/devices-placeholder/%s/%s-status", device->bdaddr, device->bdaddr); action_set_bold (uimanager, status, action_path); g_free (action_path); } else { gtk_action_set_visible (status, FALSE); } /* The connect button */ oper = add_menu_item (device->bdaddr, "action", device->connected ? _("Disconnect") : _("Connect"), uimanager, menu_merge_id, G_CALLBACK (on_connect_activate)); if (!device->can_connect) gtk_action_set_visible (oper, FALSE); add_separator_item (device->bdaddr, "connect-sep", uimanager, menu_merge_id); /* The Send to... button */ if (device->capabilities & BLUETOOTH_CAPABILITIES_OBEX_PUSH) { add_menu_item (device->bdaddr, "sendto", _("Send files..."), uimanager, menu_merge_id, G_CALLBACK (sendto_callback)); g_object_set_data_full (G_OBJECT (action), "alias", g_strdup (device->alias), g_free); } if (device->capabilities & BLUETOOTH_CAPABILITIES_OBEX_FILE_TRANSFER) { add_menu_item (device->bdaddr, "browse", _("Browse files..."), uimanager, menu_merge_id, G_CALLBACK (browse_callback)); } add_separator_item (device->bdaddr, "files-sep", uimanager, menu_merge_id); if (device->type == BLUETOOTH_TYPE_KEYBOARD && program_available (GNOMECC)) { add_menu_item (device->bdaddr, "keyboard", _("Keyboard Settings"), uimanager, menu_merge_id, G_CALLBACK (keyboard_callback)); } if (device->type == BLUETOOTH_TYPE_MOUSE && program_available (GNOMECC)) { add_menu_item (device->bdaddr, "mouse", _("Mouse and Touchpad Settings"), uimanager, menu_merge_id, G_CALLBACK (mouse_callback)); } if ((device->type == BLUETOOTH_TYPE_HEADSET || device->type == BLUETOOTH_TYPE_HEADPHONES || device->type == BLUETOOTH_TYPE_OTHER_AUDIO) && program_available (GNOMECC)) { add_menu_item (device->bdaddr, "sound", _("Sound Settings"), uimanager, menu_merge_id, G_CALLBACK (sound_callback)); } } else { gtk_action_set_label (action, name); if (device->can_connect) { gtk_action_set_visible (status, TRUE); gtk_action_set_visible (oper, TRUE); set_device_status_label (device->bdaddr, device->connected ? CONNECTED : DISCONNECTED); gtk_action_set_label (oper, device->connected ? _("Disconnect") : _("Connect")); } else { gtk_action_set_visible (status, FALSE); gtk_action_set_visible (oper, FALSE); } } g_free (name); if (oper != NULL) { g_object_set_data_full (G_OBJECT (oper), "connected", GINT_TO_POINTER (device->connected ? CONNECTED : DISCONNECTED), NULL); g_object_set_data_full (G_OBJECT (oper), "device-path", g_strdup (device->device_path), g_free); } /* And now for the trick of the day */ if (device->connected != FALSE) { char *path; path = g_strdup_printf ("/bluetooth-applet-popup/devices-placeholder/%s", device->bdaddr); action_set_bold (uimanager, action, path); g_free (path); } g_boxed_free (BLUETOOTH_TYPE_SIMPLE_DEVICE, device); } /* Remove the left-over devices */ g_list_foreach (actions, (GFunc) remove_action_item, uimanager); g_list_free (actions); /* Cleanup */ g_list_free (devices); done: gtk_ui_manager_ensure_update (uimanager); gtk_action_set_visible (GTK_ACTION (gtk_builder_get_object (xml, "devices-label")), has_devices); }
int main (int argc, char *argv[]) { char *cwd; char *glade_path; struct s_gui_data data; config_args args; args.config_path = NULL; monconf_parse_cli_args(&args, argc, argv); monconf_prepare_config_directory(); monconf *conf = monconf_create(); monconf_read_config(conf, args.config_path); monconf_load_available_actions(conf); data.rstart.active = 0; data.lstart.active = 0; gtk_init (&argc, &argv); data.builder = gtk_builder_new (); glade_path = monconf_resolve_path("ui-glade/monarqui_gui.glade"); gtk_builder_add_from_file (data.builder, glade_path, NULL); g_free(glade_path); data.builder = GTK_BUILDER(data.builder); data.windowMain = GTK_WIDGET(gtk_builder_get_object (data.builder, "windowMain")); data.windowEntry = GTK_WIDGET(gtk_builder_get_object (data.builder, "windowEntry")); data.windowConfig = GTK_WIDGET(gtk_builder_get_object (data.builder, "windowConfig")); data.windowAction = GTK_WIDGET(gtk_builder_get_object (data.builder, "windowAction")); data.action_mainExit = GTK_ACTION(gtk_builder_get_object(data.builder, "action_mainExit")); data.action_configOpen = GTK_ACTION(gtk_builder_get_object(data.builder, "action_configOpen")); data.action_configClose = GTK_ACTION(gtk_builder_get_object(data.builder, "action_configClose")); data.action_startPause = GTK_ACTION(gtk_builder_get_object(data.builder, "action_startPause")); data.action_entryAdd = GTK_ACTION(gtk_builder_get_object(data.builder, "action_entryAdd")); data.action_entryModify = GTK_ACTION(gtk_builder_get_object(data.builder, "action_entryModify")); data.action_entryDuplicate = GTK_ACTION(gtk_builder_get_object(data.builder, "action_entryDuplicate")); data.action_entryDelete = GTK_ACTION(gtk_builder_get_object(data.builder, "action_entryDelete")); data.action_actionAdd = GTK_ACTION(gtk_builder_get_object(data.builder, "action_actionAdd")); data.action_actionModify = GTK_ACTION(gtk_builder_get_object(data.builder, "action_actionModify")); data.action_actionDelete = GTK_ACTION(gtk_builder_get_object(data.builder, "action_actionDelete")); data.action_saveConfig = GTK_ACTION(gtk_builder_get_object(data.builder, "action_saveConfig")); data.action_toggleApplication = GTK_ACTION(gtk_builder_get_object(data.builder, "action_toggleApplication")); data.action_systrayPopup = GTK_ACTION(gtk_builder_get_object(data.builder, "action_systrayPopup")); data.image_startStop = GTK_IMAGE(gtk_builder_get_object(data.builder,"image_startStop")); data.systrayIcon = GTK_STATUS_ICON(gtk_builder_get_object(data.builder,"systrayIcon")); data.args = &args; data.conf = conf; data.treeviewActions = GTK_TREE_VIEW(gtk_builder_get_object(data.builder,"treeviewActions")); data.treeviewEntries = GTK_TREE_VIEW(gtk_builder_get_object(data.builder,"treeviewEntries")); data.treeviewEntryActions = GTK_TREE_VIEW(gtk_builder_get_object(data.builder,"treeviewEntryActions")); data.listStoreActions = GTK_LIST_STORE(gtk_builder_get_object(data.builder,"listStoreActions")); data.listStoreEntries = GTK_LIST_STORE(gtk_builder_get_object(data.builder,"listStoreEntries")); data.listStoreEntryActions = GTK_LIST_STORE(gtk_builder_get_object(data.builder,"listStoreEntryActions")); data.image_started = GTK_IMAGE(gtk_builder_get_object(data.builder,"image_started")); data.image_started_event = GTK_IMAGE(gtk_builder_get_object(data.builder,"image_started_event")); data.image_stopped = GTK_IMAGE(gtk_builder_get_object(data.builder,"image_stopped")); data.logged_event = FALSE; data.textbufferLog = GTK_TEXT_BUFFER(gtk_builder_get_object(data.builder, "textbufferLog")); data.systrayMenu = GTK_MENU(gtk_menu_new()); data.systrayMenuItem_startStop = GTK_MENU_ITEM(gtk_menu_item_new_with_label("Start")); data.systrayMenuItem_quit = GTK_MENU_ITEM(gtk_menu_item_new_with_label("Quit")); gtk_menu_shell_append(GTK_MENU_SHELL(data.systrayMenu), GTK_WIDGET(data.systrayMenuItem_startStop)); gtk_menu_shell_append(GTK_MENU_SHELL(data.systrayMenu), GTK_WIDGET(data.systrayMenuItem_quit)); gtk_action_set_label(data.action_startPause, "Start"); gtk_builder_connect_signals (data.builder, (gpointer)&data); gtk_image_set_from_icon_name(data.image_startStop, ICON_NAME_START, GTK_ICON_SIZE_BUTTON); gtk_status_icon_set_from_pixbuf(data.systrayIcon, gtk_image_get_pixbuf(data.image_stopped)); populate_entries(&data); populate_actions(&data); gtk_widget_show (data.windowMain); gtk_main (); g_object_unref (G_OBJECT (data.builder)); free(args.config_path); return 0; }
void ghb_queue_buttons_grey(signal_user_data_t *ud) { GtkWidget *widget; GtkAction *action; gint queue_count; gint titleindex; gint queue_state, scan_state; gboolean show_start, show_stop, paused; queue_count = ghb_array_len(ud->queue); titleindex = ghb_settings_combo_int(ud->settings, "title"); queue_state = ghb_get_queue_state(); scan_state = ghb_get_scan_state(); show_stop = queue_state & (GHB_STATE_WORKING | GHB_STATE_SEARCHING | GHB_STATE_SCANNING | GHB_STATE_MUXING); show_start = !(scan_state & GHB_STATE_SCANNING) && (titleindex >= 0 || queue_count > 0); paused = queue_state & GHB_STATE_PAUSED; widget = GHB_WIDGET(ud->builder, "queue_add"); gtk_widget_set_sensitive(widget, show_start); action = GHB_ACTION(ud->builder, "queue_add_menu"); gtk_action_set_sensitive(action, show_start); action = GHB_ACTION(ud->builder, "queue_add_all_menu"); gtk_action_set_sensitive(action, show_start); widget = GHB_WIDGET (ud->builder, "queue_start1"); if (show_stop) { gtk_widget_set_sensitive (widget, TRUE); gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-stop"); gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Stop"); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), "Stop Encoding"); } else { gtk_widget_set_sensitive (widget, show_start); gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-start"); gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Start"); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), "Start Encoding"); } widget = GHB_WIDGET (ud->builder, "queue_start2"); if (show_stop) { gtk_widget_set_sensitive (widget, TRUE); gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-stop"); gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Stop"); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), "Stop Encoding"); } else { gtk_widget_set_sensitive (widget, show_start); gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-start"); gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Start"); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), "Start Encoding"); } widget = GHB_WIDGET (ud->builder, "queue_pause1"); if (paused) { gtk_widget_set_sensitive (widget, show_stop); gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-start"); gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Resume"); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), "Resume Encoding"); } else { gtk_widget_set_sensitive (widget, show_stop); gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-pause"); gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Pause"); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), "Pause Encoding"); } widget = GHB_WIDGET (ud->builder, "queue_pause2"); if (paused) { gtk_widget_set_sensitive (widget, show_stop); gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-start"); gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Resume"); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), "Resume Encoding"); } else { gtk_widget_set_sensitive (widget, show_stop); gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-pause"); gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Pause"); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), "Pause Encoding"); } action = GHB_ACTION (ud->builder, "queue_start_menu"); if (show_stop) { gtk_action_set_sensitive (action, TRUE); #if GTK_CHECK_VERSION(2, 16, 0) gtk_action_set_icon_name(action, "hb-stop"); gtk_action_set_label(action, "S_top Queue"); gtk_action_set_tooltip(action, "Stop Encoding"); #else g_object_set_property(G_OBJECT(action), "icon-name", ghb_string_value("hb-stop")); g_object_set_property(G_OBJECT(action), "label", ghb_string_value("S_top Queue")); g_object_set_property(G_OBJECT(action), "tooltip", ghb_string_value("Stop Encoding")); #endif } else { gtk_action_set_sensitive (action, show_start); #if GTK_CHECK_VERSION(2, 16, 0) gtk_action_set_icon_name(action, "hb-start"); gtk_action_set_label(action, "_Start Queue"); gtk_action_set_tooltip(action, "Start Encoding"); #else g_object_set_property(G_OBJECT(action), "icon-name", ghb_string_value("hb-start")); g_object_set_property(G_OBJECT(action), "label", ghb_string_value("_Start Queue")); g_object_set_property(G_OBJECT(action), "tooltip", ghb_string_value("Start Encoding")); #endif } action = GHB_ACTION (ud->builder, "queue_pause_menu"); if (paused) { gtk_action_set_sensitive (action, show_start); #if GTK_CHECK_VERSION(2, 16, 0) gtk_action_set_icon_name(action, "hb-start"); gtk_action_set_label(action, "_Resume Queue"); gtk_action_set_tooltip(action, "Resume Encoding"); #else g_object_set_property(G_OBJECT(action), "icon-name", ghb_string_value("hb-start")); g_object_set_property(G_OBJECT(action), "label", ghb_string_value("_Resume Queue")); g_object_set_property(G_OBJECT(action), "tooltip", ghb_string_value("Resume Encoding")); #endif } else { gtk_action_set_sensitive (action, show_stop); #if GTK_CHECK_VERSION(2, 16, 0) gtk_action_set_icon_name(action, "hb-pause"); gtk_action_set_label(action, "_Pause Queue"); gtk_action_set_tooltip(action, "Pause Encoding"); #else g_object_set_property(G_OBJECT(action), "icon-name", ghb_string_value("hb-pause")); g_object_set_property(G_OBJECT(action), "label", ghb_string_value("_Pause Queue")); g_object_set_property(G_OBJECT(action), "tooltip", ghb_string_value("Pause Encoding")); #endif } }
static void update_device_list (GtkTreeIter *parent) { GtkUIManager *uimanager; GtkTreeIter iter; gboolean cont; guint num_devices; GList *actions, *l; num_devices = 0; uimanager = GTK_UI_MANAGER (gtk_builder_get_object (xml, "bluetooth-applet-ui-manager")); if (parent == NULL) { /* No default adapter? Remove everything */ actions = gtk_action_group_list_actions (devices_action_group); g_list_foreach (actions, (GFunc) remove_action_item, uimanager); g_list_free (actions); goto done; } /* Get a list of actions, and we'll remove the ones with a * device in the list. We remove the submenu items first */ actions = gtk_action_group_list_actions (devices_action_group); for (l = actions; l != NULL; l = l->next) { if (bluetooth_verify_address (gtk_action_get_name (l->data)) == FALSE) l->data = NULL; } actions = g_list_remove_all (actions, NULL); cont = gtk_tree_model_iter_children (devices_model, &iter, parent); while (cont) { GHashTable *services; DBusGProxy *proxy; char *alias, *address, **uuids, *name; gboolean is_connected; BluetoothType type; GtkAction *action, *status, *oper; gtk_tree_model_get (devices_model, &iter, BLUETOOTH_COLUMN_PROXY, &proxy, BLUETOOTH_COLUMN_ADDRESS, &address, BLUETOOTH_COLUMN_SERVICES, &services, BLUETOOTH_COLUMN_ALIAS, &alias, BLUETOOTH_COLUMN_UUIDS, &uuids, BLUETOOTH_COLUMN_TYPE, &type, -1); if (device_has_submenu ((const char **) uuids, services, type) == FALSE || address == NULL || proxy == NULL || alias == NULL) { if (proxy != NULL) g_object_unref (proxy); if (services != NULL) g_hash_table_unref (services); g_strfreev (uuids); g_free (alias); g_free (address); cont = gtk_tree_model_iter_next (devices_model, &iter); continue; } action = gtk_action_group_get_action (devices_action_group, address); oper = NULL; status = NULL; if (action) { char *action_name; actions = g_list_remove (actions, action); action_name = g_strdup_printf ("%s-status", address); status = gtk_action_group_get_action (devices_action_group, action_name); g_free (action_name); action_name = g_strdup_printf ("%s-action", address); oper = gtk_action_group_get_action (devices_action_group, action_name); g_free (action_name); } /* If one service is connected, then we're connected */ is_connected = FALSE; if (services != NULL) { GList *list, *l; list = g_hash_table_get_values (services); for (l = list; l != NULL; l = l->next) { BluetoothStatus val = GPOINTER_TO_INT (l->data); if (val == BLUETOOTH_STATUS_CONNECTED || val == BLUETOOTH_STATUS_PLAYING) { is_connected = TRUE; break; } } g_list_free (list); } name = escape_label_for_action (alias); if (action == NULL) { guint menu_merge_id; char *action_path; /* The menu item with descendants */ action = gtk_action_new (address, name, NULL, NULL); gtk_action_group_add_action (devices_action_group, action); g_object_unref (action); menu_merge_id = gtk_ui_manager_new_merge_id (uimanager); gtk_ui_manager_add_ui (uimanager, menu_merge_id, "/bluetooth-applet-popup/devices-placeholder", address, address, GTK_UI_MANAGER_MENU, FALSE); g_object_set_data_full (G_OBJECT (action), "merge-id", GUINT_TO_POINTER (menu_merge_id), NULL); /* The status menu item */ status = add_menu_item (address, "status", is_connected ? _("Connected") : _("Disconnected"), uimanager, menu_merge_id, NULL); gtk_action_set_sensitive (status, FALSE); if (services != NULL) { action_path = g_strdup_printf ("/bluetooth-applet-popup/devices-placeholder/%s/%s-status", address, address); action_set_bold (uimanager, status, action_path); g_free (action_path); } else { gtk_action_set_visible (status, FALSE); } /* The connect button */ oper = add_menu_item (address, "action", is_connected ? _("Disconnect") : _("Connect"), uimanager, menu_merge_id, G_CALLBACK (on_connect_activate)); if (services == NULL) gtk_action_set_visible (oper, FALSE); add_separator_item (address, "connect-sep", uimanager, menu_merge_id); /* The Send to... button */ if (device_has_uuid ((const char **) uuids, "OBEXObjectPush") != FALSE) { add_menu_item (address, "sendto", _("Send files..."), uimanager, menu_merge_id, G_CALLBACK (sendto_callback)); g_object_set_data_full (G_OBJECT (action), "alias", g_strdup (alias), g_free); } if (device_has_uuid ((const char **) uuids, "OBEXFileTransfer") != FALSE) { add_menu_item (address, "browse", _("Browse files..."), uimanager, menu_merge_id, G_CALLBACK (browse_callback)); } add_separator_item (address, "files-sep", uimanager, menu_merge_id); if (type == BLUETOOTH_TYPE_KEYBOARD && program_available (KEYBOARD_PREFS)) { add_menu_item (address, "keyboard", _("Open Keyboard Preferences..."), uimanager, menu_merge_id, G_CALLBACK (keyboard_callback)); } if (type == BLUETOOTH_TYPE_MOUSE && program_available (MOUSE_PREFS)) { add_menu_item (address, "mouse", _("Open Mouse Preferences..."), uimanager, menu_merge_id, G_CALLBACK (mouse_callback)); } if ((type == BLUETOOTH_TYPE_HEADSET || type == BLUETOOTH_TYPE_HEADPHONES || type == BLUETOOTH_TYPE_OTHER_AUDIO) && program_available (SOUND_PREFS)) { add_menu_item (address, "sound", _("Open Sound Preferences..."), uimanager, menu_merge_id, G_CALLBACK (sound_callback)); } } else { gtk_action_set_label (action, name); gtk_action_set_visible (status, services != NULL); gtk_action_set_visible (oper, services != NULL); if (services != NULL) { set_device_status_label (address, is_connected ? CONNECTED : DISCONNECTED); gtk_action_set_label (oper, is_connected ? _("Disconnect") : _("Connect")); } } g_free (name); if (oper != NULL) { g_object_set_data_full (G_OBJECT (oper), "connected", GINT_TO_POINTER (is_connected ? CONNECTED : DISCONNECTED), NULL); g_object_set_data_full (G_OBJECT (oper), "device-path", g_strdup (dbus_g_proxy_get_path (proxy)), g_free); } /* And now for the trick of the day */ if (is_connected != FALSE) { char *path; path = g_strdup_printf ("/bluetooth-applet-popup/devices-placeholder/%s", address); action_set_bold (uimanager, action, path); g_free (path); } num_devices++; if (proxy != NULL) g_object_unref (proxy); if (services != NULL) g_hash_table_unref (services); g_strfreev (uuids); g_free (alias); g_free (address); cont = gtk_tree_model_iter_next (devices_model, &iter); } /* Remove the left-over devices */ g_list_foreach (actions, (GFunc) remove_action_item, uimanager); g_list_free (actions); done: gtk_ui_manager_ensure_update (uimanager); gtk_action_set_visible (GTK_ACTION (gtk_builder_get_object (xml, "devices-label")), num_devices > 0); }
static void book_shell_view_update_actions (EShellView *shell_view) { EShellContent *shell_content; EShellSidebar *shell_sidebar; EShellWindow *shell_window; GtkAction *action; const gchar *label; gboolean sensitive; guint32 state; /* Be descriptive. */ gboolean any_contacts_selected; gboolean has_primary_source; gboolean multiple_contacts_selected; gboolean primary_source_is_writable; gboolean primary_source_is_removable; gboolean primary_source_is_remote_deletable; gboolean primary_source_in_collection; gboolean refresh_supported; gboolean single_contact_selected; gboolean selection_is_contact_list; gboolean selection_has_email; gboolean source_is_busy; gboolean source_is_editable; /* Chain up to parent's update_actions() method. */ E_SHELL_VIEW_CLASS (e_book_shell_view_parent_class)-> update_actions (shell_view); shell_window = e_shell_view_get_shell_window (shell_view); shell_content = e_shell_view_get_shell_content (shell_view); state = e_shell_content_check_state (shell_content); single_contact_selected = (state & E_BOOK_SHELL_CONTENT_SELECTION_SINGLE); multiple_contacts_selected = (state & E_BOOK_SHELL_CONTENT_SELECTION_MULTIPLE); selection_has_email = (state & E_BOOK_SHELL_CONTENT_SELECTION_HAS_EMAIL); selection_is_contact_list = (state & E_BOOK_SHELL_CONTENT_SELECTION_IS_CONTACT_LIST); source_is_busy = (state & E_BOOK_SHELL_CONTENT_SOURCE_IS_BUSY); source_is_editable = (state & E_BOOK_SHELL_CONTENT_SOURCE_IS_EDITABLE); shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); state = e_shell_sidebar_check_state (shell_sidebar); has_primary_source = (state & E_BOOK_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE); primary_source_is_writable = (state & E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_WRITABLE); primary_source_is_removable = (state & E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_REMOVABLE); primary_source_is_remote_deletable = (state & E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_REMOTE_DELETABLE); primary_source_in_collection = (state & E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IN_COLLECTION); refresh_supported = (state & E_BOOK_SHELL_SIDEBAR_SOURCE_SUPPORTS_REFRESH); any_contacts_selected = (single_contact_selected || multiple_contacts_selected); action = ACTION (ADDRESS_BOOK_MOVE); sensitive = source_is_editable; gtk_action_set_sensitive (action, sensitive); action = ACTION (ADDRESS_BOOK_DELETE); sensitive = primary_source_is_removable || primary_source_is_remote_deletable; gtk_action_set_sensitive (action, sensitive); action = ACTION (ADDRESS_BOOK_PRINT); sensitive = has_primary_source; gtk_action_set_sensitive (action, sensitive); action = ACTION (ADDRESS_BOOK_PRINT_PREVIEW); sensitive = has_primary_source; gtk_action_set_sensitive (action, sensitive); action = ACTION (ADDRESS_BOOK_PROPERTIES); sensitive = primary_source_is_writable; gtk_action_set_sensitive (action, sensitive); action = ACTION (ADDRESS_BOOK_REFRESH); sensitive = refresh_supported; gtk_action_set_sensitive (action, sensitive); action = ACTION (ADDRESS_BOOK_RENAME); sensitive = primary_source_is_writable && !primary_source_in_collection; gtk_action_set_sensitive (action, sensitive); action = ACTION (ADDRESS_BOOK_STOP); sensitive = source_is_busy; gtk_action_set_sensitive (action, sensitive); action = ACTION (CONTACT_COPY); sensitive = any_contacts_selected; gtk_action_set_sensitive (action, sensitive); action = ACTION (CONTACT_DELETE); sensitive = source_is_editable && any_contacts_selected; gtk_action_set_sensitive (action, sensitive); action = ACTION (CONTACT_FIND); sensitive = single_contact_selected; gtk_action_set_sensitive (action, sensitive); action = ACTION (CONTACT_FORWARD); sensitive = any_contacts_selected; gtk_action_set_sensitive (action, sensitive); if (multiple_contacts_selected) label = _("_Forward Contacts"); else label = _("_Forward Contact"); gtk_action_set_label (action, label); action = ACTION (CONTACT_MOVE); sensitive = source_is_editable && any_contacts_selected; gtk_action_set_sensitive (action, sensitive); action = ACTION (CONTACT_NEW); sensitive = source_is_editable; gtk_action_set_sensitive (action, sensitive); action = ACTION (CONTACT_NEW_LIST); sensitive = source_is_editable; gtk_action_set_sensitive (action, sensitive); action = ACTION (CONTACT_OPEN); sensitive = any_contacts_selected; gtk_action_set_sensitive (action, sensitive); action = ACTION (CONTACT_PRINT); sensitive = any_contacts_selected; gtk_action_set_sensitive (action, sensitive); action = ACTION (CONTACT_SAVE_AS); sensitive = any_contacts_selected; gtk_action_set_sensitive (action, sensitive); action = ACTION (CONTACT_SEND_MESSAGE); sensitive = any_contacts_selected && selection_has_email; gtk_action_set_sensitive (action, sensitive); if (multiple_contacts_selected) label = _("_Send Message to Contacts"); else if (selection_is_contact_list) label = _("_Send Message to List"); else label = _("_Send Message to Contact"); gtk_action_set_label (action, label); }
static void gtk_action_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { GtkAction *action; action = GTK_ACTION (object); switch (prop_id) { case PROP_NAME: action->private_data->name = g_intern_string (g_value_get_string (value)); break; case PROP_LABEL: gtk_action_set_label (action, g_value_get_string (value)); break; case PROP_SHORT_LABEL: gtk_action_set_short_label (action, g_value_get_string (value)); break; case PROP_TOOLTIP: gtk_action_set_tooltip (action, g_value_get_string (value)); break; case PROP_STOCK_ID: gtk_action_set_stock_id (action, g_value_get_string (value)); break; case PROP_GICON: gtk_action_set_gicon (action, g_value_get_object (value)); break; case PROP_ICON_NAME: gtk_action_set_icon_name (action, g_value_get_string (value)); break; case PROP_VISIBLE_HORIZONTAL: gtk_action_set_visible_horizontal (action, g_value_get_boolean (value)); break; case PROP_VISIBLE_VERTICAL: gtk_action_set_visible_vertical (action, g_value_get_boolean (value)); break; case PROP_VISIBLE_OVERFLOWN: action->private_data->visible_overflown = g_value_get_boolean (value); break; case PROP_IS_IMPORTANT: gtk_action_set_is_important (action, g_value_get_boolean (value)); break; case PROP_HIDE_IF_EMPTY: action->private_data->hide_if_empty = g_value_get_boolean (value); break; case PROP_SENSITIVE: gtk_action_set_sensitive (action, g_value_get_boolean (value)); break; case PROP_VISIBLE: gtk_action_set_visible (action, g_value_get_boolean (value)); break; case PROP_ACTION_GROUP: gtk_action_set_action_group (action, g_value_get_object (value)); break; case PROP_ALWAYS_SHOW_IMAGE: gtk_action_set_always_show_image (action, g_value_get_boolean (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static void memo_shell_view_update_actions (EShellView *shell_view) { EShellContent *shell_content; EShellSidebar *shell_sidebar; EShellWindow *shell_window; GtkAction *action; const gchar *label; gboolean sensitive; guint32 state; /* Be descriptive. */ gboolean any_memos_selected; gboolean has_primary_source; gboolean multiple_memos_selected; gboolean primary_source_is_writable; gboolean primary_source_is_removable; gboolean primary_source_is_remote_deletable; gboolean primary_source_in_collection; gboolean selection_has_url; gboolean single_memo_selected; gboolean sources_are_editable; gboolean refresh_supported; /* Chain up to parent's update_actions() method. */ E_SHELL_VIEW_CLASS (e_memo_shell_view_parent_class)-> update_actions (shell_view); shell_window = e_shell_view_get_shell_window (shell_view); shell_content = e_shell_view_get_shell_content (shell_view); state = e_shell_content_check_state (shell_content); single_memo_selected = (state & E_MEMO_SHELL_CONTENT_SELECTION_SINGLE); multiple_memos_selected = (state & E_MEMO_SHELL_CONTENT_SELECTION_MULTIPLE); sources_are_editable = (state & E_MEMO_SHELL_CONTENT_SELECTION_CAN_EDIT); selection_has_url = (state & E_MEMO_SHELL_CONTENT_SELECTION_HAS_URL); shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); state = e_shell_sidebar_check_state (shell_sidebar); has_primary_source = (state & E_MEMO_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE); primary_source_is_writable = (state & E_MEMO_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_WRITABLE); primary_source_is_removable = (state & E_MEMO_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_REMOVABLE); primary_source_is_remote_deletable = (state & E_MEMO_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_REMOTE_DELETABLE); primary_source_in_collection = (state & E_MEMO_SHELL_SIDEBAR_PRIMARY_SOURCE_IN_COLLECTION); refresh_supported = (state & E_MEMO_SHELL_SIDEBAR_SOURCE_SUPPORTS_REFRESH); any_memos_selected = (single_memo_selected || multiple_memos_selected); action = ACTION (MEMO_DELETE); sensitive = any_memos_selected && sources_are_editable; gtk_action_set_sensitive (action, sensitive); if (multiple_memos_selected) label = _("Delete Memos"); else label = _("Delete Memo"); gtk_action_set_label (action, label); action = ACTION (MEMO_FIND); sensitive = single_memo_selected; gtk_action_set_sensitive (action, sensitive); action = ACTION (MEMO_FORWARD); sensitive = single_memo_selected; gtk_action_set_sensitive (action, sensitive); action = ACTION (MEMO_LIST_COPY); sensitive = has_primary_source; gtk_action_set_sensitive (action, sensitive); action = ACTION (MEMO_LIST_DELETE); sensitive = primary_source_is_removable || primary_source_is_remote_deletable; gtk_action_set_sensitive (action, sensitive); action = ACTION (MEMO_LIST_PROPERTIES); sensitive = primary_source_is_writable; gtk_action_set_sensitive (action, sensitive); action = ACTION (MEMO_LIST_REFRESH); sensitive = refresh_supported; gtk_action_set_sensitive (action, sensitive); action = ACTION (MEMO_LIST_RENAME); sensitive = primary_source_is_writable && !primary_source_in_collection; gtk_action_set_sensitive (action, sensitive); action = ACTION (MEMO_OPEN); sensitive = single_memo_selected; gtk_action_set_sensitive (action, sensitive); action = ACTION (MEMO_OPEN_URL); sensitive = single_memo_selected && selection_has_url; gtk_action_set_sensitive (action, sensitive); action = ACTION (MEMO_PRINT); sensitive = single_memo_selected; gtk_action_set_sensitive (action, sensitive); action = ACTION (MEMO_SAVE_AS); sensitive = single_memo_selected; gtk_action_set_sensitive (action, sensitive); }