static gboolean mx_toggle_handle_button_release_event (ClutterActor *actor, ClutterButtonEvent *event, MxToggle *toggle) { ClutterActorBox box; if (mx_widget_get_disabled (MX_WIDGET (toggle))) return FALSE; if (toggle->priv->last_move == 0) mx_toggle_set_active (toggle, !toggle->priv->active); else mx_toggle_set_active (toggle, (toggle->priv->last_move > 0.0)); toggle->priv->drag_offset = -1; toggle->priv->last_move = 0; clutter_ungrab_pointer (); /* ensure the hover state is removed if the pointer left the handle * during the grab */ clutter_actor_get_allocation_box (actor, &box); if (!clutter_actor_box_contains (&box, event->x, event->y)) mx_stylable_style_pseudo_class_remove (MX_STYLABLE (actor), "hover"); return TRUE; }
static void _enabled_techs_changed (CarrickConnmanManager *cm, GParamSpec *pspec, MpdComputerTile *tile) { MpdComputerTilePrivate *priv = tile->priv; gboolean enabled_techs[N_RADIO_TECHS]; char **techs, **iter; int i; memset (enabled_techs, 0, N_RADIO_TECHS * sizeof (gboolean)); g_object_get (cm, "enabled-technologies", &techs, NULL); iter = techs; while (*iter) { for (i = 0; i < N_RADIO_TECHS; i++) if (g_strcmp0 (*iter, radio_tech_to_connman_tech (i)) == 0) enabled_techs[i] = TRUE; iter++; } for (i = 0; i < N_RADIO_TECHS; i++) { g_signal_handlers_block_by_func (priv->rows[i].toggle, on_switch_toggled, &priv->toggled_data[i]); mx_toggle_set_active (MX_TOGGLE (priv->rows[i].toggle), enabled_techs[i]); g_signal_handlers_unblock_by_func (priv->rows[i].toggle, on_switch_toggled, &priv->toggled_data[i]); } g_strfreev (techs); }
static gboolean mx_toggle_button_release_event (ClutterActor *actor, ClutterButtonEvent *event) { MxToggle *toggle = MX_TOGGLE (actor); if (mx_widget_get_disabled (MX_WIDGET (actor))) return FALSE; mx_toggle_set_active (toggle, !toggle->priv->active); return FALSE; }
static gboolean mx_toggle_key_press (ClutterActor *actor, ClutterKeyEvent *event) { if (event->keyval == CLUTTER_KEY_Return || event->keyval == CLUTTER_KEY_KP_Enter || event->keyval == CLUTTER_KEY_ISO_Enter || event->keyval == CLUTTER_KEY_space) { MxToggle *toggle = (MxToggle *) actor; mx_toggle_set_active (toggle, !toggle->priv->active); return TRUE; } return FALSE; }
static void mx_toggle_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { MxToggle *toggle = MX_TOGGLE (object); switch (property_id) { case PROP_ACTIVE: mx_toggle_set_active (toggle, g_value_get_boolean (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } }
static void _offline_mode_changed (CarrickConnmanManager *cm, GParamSpec *pspec, MpdComputerTile *tile) { MpdComputerTilePrivate *priv = tile->priv; gboolean offline_mode; offline_mode = carrick_connman_manager_get_offline_mode (cm); g_signal_handlers_block_by_func (priv->rows[OFFLINE_MODE].toggle, on_switch_toggled, &priv->toggled_data[OFFLINE_MODE]); mx_toggle_set_active (MX_TOGGLE (priv->rows[OFFLINE_MODE].toggle), offline_mode); g_signal_handlers_unblock_by_func (priv->rows[OFFLINE_MODE].toggle, on_switch_toggled, &priv->toggled_data[OFFLINE_MODE]); }
static void startup_cb (MxApplication *app) { MxWindow *window; ClutterActor *stage, *toggle, *label, *table, *button, *icon; window = mx_application_create_window (app, "Test Window"); stage = (ClutterActor *)mx_window_get_clutter_stage (window); mx_window_set_icon_name (window, "window-new"); clutter_actor_set_size (stage, 480, 320); table = mx_table_new (); mx_table_set_column_spacing (MX_TABLE (table), 8); mx_table_set_row_spacing (MX_TABLE (table), 12); mx_window_set_child (window, table); toggle = mx_toggle_new (); label = mx_label_new_with_text ("Toggle small-screen mode"); g_signal_connect (toggle, "notify::active", G_CALLBACK (small_screen_cb), window); mx_table_insert_actor_with_properties (MX_TABLE (table), toggle, 0, 0, "x-expand", TRUE, "x-align", MX_ALIGN_END, "x-fill", FALSE, NULL); mx_table_insert_actor_with_properties (MX_TABLE (table), label, 0, 1, "x-expand", TRUE, "x-align", MX_ALIGN_START, "y-fill", FALSE, "x-fill", FALSE, NULL); toggle = mx_toggle_new (); label = mx_label_new_with_text ("Toggle full-screen mode"); g_signal_connect (toggle, "notify::active", G_CALLBACK (fullscreen_cb), stage); mx_table_insert_actor_with_properties (MX_TABLE (table), toggle, 1, 0, "x-expand", TRUE, "x-align", MX_ALIGN_END, "x-fill", FALSE, NULL); mx_table_insert_actor_with_properties (MX_TABLE (table), label, 1, 1, "x-expand", TRUE, "x-align", MX_ALIGN_START, "y-fill", FALSE, "x-fill", FALSE, NULL); toggle = mx_toggle_new (); label = mx_label_new_with_text ("Toggle custom window icon"); g_signal_connect (toggle, "notify::active", G_CALLBACK (icon_cb), window); mx_table_insert_actor_with_properties (MX_TABLE (table), toggle, 2, 0, "x-expand", TRUE, "x-align", MX_ALIGN_END, "x-fill", FALSE, NULL); mx_table_insert_actor_with_properties (MX_TABLE (table), label, 2, 1, "x-expand", TRUE, "x-align", MX_ALIGN_START, "y-fill", FALSE, "x-fill", FALSE, NULL); toggle = mx_toggle_new (); mx_toggle_set_active (MX_TOGGLE (toggle), TRUE); label = mx_label_new_with_text ("Toggle user-resizable"); g_signal_connect (toggle, "notify::active", G_CALLBACK (resizable_cb), stage); mx_table_insert_actor_with_properties (MX_TABLE (table), toggle, 3, 0, "x-expand", TRUE, "x-align", MX_ALIGN_END, "x-fill", FALSE, NULL); mx_table_insert_actor_with_properties (MX_TABLE (table), label, 3, 1, "x-expand", TRUE, "x-align", MX_ALIGN_START, "y-fill", FALSE, "x-fill", FALSE, NULL); toggle = mx_toggle_new (); mx_toggle_set_active (MX_TOGGLE (toggle), TRUE); label = mx_label_new_with_text ("Toggle toolbar"); g_signal_connect (toggle, "notify::active", G_CALLBACK (toolbar_cb), window); mx_table_insert_actor_with_properties (MX_TABLE (table), toggle, 4, 0, "x-expand", TRUE, "x-align", MX_ALIGN_END, "x-fill", FALSE, NULL); mx_table_insert_actor_with_properties (MX_TABLE (table), label, 4, 1, "x-expand", TRUE, "x-align", MX_ALIGN_START, "y-fill", FALSE, "x-fill", FALSE, NULL); icon = mx_icon_new (); mx_icon_set_icon_name (MX_ICON (icon), "object-rotate-right"); mx_icon_set_icon_size (MX_ICON (icon), 16); button = mx_button_new (); mx_bin_set_child (MX_BIN (button), icon); g_signal_connect (button, "clicked", G_CALLBACK (rotate_clicked_cb), window); clutter_container_add_actor ( CLUTTER_CONTAINER (mx_window_get_toolbar (window)), button); mx_bin_set_alignment (MX_BIN (mx_window_get_toolbar (window)), MX_ALIGN_END, MX_ALIGN_MIDDLE); clutter_actor_show (stage); }
static void dawati_bt_shell_update (DawatiBtShell *shell) { DawatiBtShellPrivate *priv = GET_PRIVATE (shell); gboolean showinfo; showinfo = g_hash_table_size (priv->devices) == 0; g_signal_handler_block (priv->kill_toggle, priv->kill_handler); mx_toggle_set_active (MX_TOGGLE (priv->kill_toggle), priv->enabled); g_signal_handler_unblock (priv->kill_toggle, priv->kill_handler); /* Now way to know from Connman: mx_widget_set_disabled (MX_WIDGET (priv->kill_toggle), disabled); */ g_object_set (priv->info_label, "visible", showinfo, NULL); if (priv->enabled) { if (!clutter_actor_get_parent (priv->device_panelbox)) mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->content), priv->device_panelbox, 2); clutter_actor_show (priv->add_button); clutter_actor_animate (priv->add_button, CLUTTER_LINEAR, 300, "opacity", 0xff, NULL); clutter_actor_show (priv->send_button); clutter_actor_animate (priv->send_button, CLUTTER_LINEAR, 300, "opacity", 0xff, NULL); mx_stylable_set_style_pseudo_class (MX_STYLABLE (priv->button_box), NULL); } else { if (clutter_actor_get_parent (priv->device_panelbox)) clutter_actor_remove_child (priv->content, priv->device_panelbox); clutter_actor_animate (priv->add_button, CLUTTER_LINEAR, 300, "opacity", 0x00, NULL); clutter_actor_animate (priv->send_button, CLUTTER_LINEAR, 300, "opacity", 0x00, "signal::completed", fadeout_completed_cb, shell, NULL); mx_stylable_set_style_pseudo_class (MX_STYLABLE (priv->button_box), "state-off"); } if (priv->panel_client) { g_object_set (priv->kill_toggle, "disabled", FALSE, NULL); if (!priv->available) { mpl_panel_client_request_button_state (priv->panel_client, MNB_BUTTON_HIDDEN); } else { mpl_panel_client_request_button_state (priv->panel_client, MNB_BUTTON_NORMAL); if (priv->enabled) mpl_panel_client_request_button_style (priv->panel_client, "state-idle"); else mpl_panel_client_request_button_style (priv->panel_client, "state-off"); } } else { g_object_set (priv->kill_toggle, "disabled", !priv->available, NULL); } }