static void mx_scroll_bar_init (MxScrollBar *self) { self->priv = MX_SCROLL_BAR_GET_PRIVATE (self); self->priv->bw_stepper = (ClutterActor *) mx_button_new (); mx_stylable_set_style_class (MX_STYLABLE (self->priv->bw_stepper), "backward-stepper"); clutter_actor_set_parent (CLUTTER_ACTOR (self->priv->bw_stepper), CLUTTER_ACTOR (self)); g_signal_connect (self->priv->bw_stepper, "button-press-event", G_CALLBACK (stepper_button_press_event_cb), self); g_signal_connect (self->priv->bw_stepper, "button-release-event", G_CALLBACK (stepper_button_release_cb), self); g_signal_connect (self->priv->bw_stepper, "leave-event", G_CALLBACK (stepper_button_release_cb), self); self->priv->fw_stepper = (ClutterActor *) mx_button_new (); mx_stylable_set_style_class (MX_STYLABLE (self->priv->fw_stepper), "forward-stepper"); clutter_actor_set_parent (CLUTTER_ACTOR (self->priv->fw_stepper), CLUTTER_ACTOR (self)); g_signal_connect (self->priv->fw_stepper, "button-press-event", G_CALLBACK (stepper_button_press_event_cb), self); g_signal_connect (self->priv->fw_stepper, "button-release-event", G_CALLBACK (stepper_button_release_cb), self); g_signal_connect (self->priv->fw_stepper, "leave-event", G_CALLBACK (stepper_button_release_cb), self); self->priv->trough = mx_frame_new (); clutter_actor_set_reactive ((ClutterActor *) self->priv->trough, TRUE); mx_stylable_set_style_class (MX_STYLABLE (self->priv->trough), "htrough"); clutter_actor_set_parent (CLUTTER_ACTOR (self->priv->trough), CLUTTER_ACTOR (self)); g_signal_connect (self->priv->trough, "button-press-event", G_CALLBACK (trough_button_press_event_cb), self); g_signal_connect (self->priv->trough, "button-release-event", G_CALLBACK (trough_button_release_event_cb), self); g_signal_connect (self->priv->trough, "leave-event", G_CALLBACK (trough_leave_event_cb), self); self->priv->handle = (ClutterActor *) mx_button_new (); mx_stylable_set_style_class (MX_STYLABLE (self->priv->handle), "hhandle"); clutter_actor_set_parent (CLUTTER_ACTOR (self->priv->handle), CLUTTER_ACTOR (self)); g_signal_connect (self->priv->handle, "button-press-event", G_CALLBACK (handle_button_press_event_cb), self); clutter_actor_set_reactive (CLUTTER_ACTOR (self), TRUE); g_signal_connect (self, "style-changed", G_CALLBACK (mx_scroll_bar_style_changed), NULL); g_signal_connect (self, "notify::reactive", G_CALLBACK (mx_scroll_bar_notify_reactive), NULL); }
static void dawati_bt_device_init (DawatiBtDevice *device) { ClutterActor *button; DawatiBtDevicePrivate *priv = GET_PRIVATE (device); mx_stylable_set_style_class (MX_STYLABLE (device), "BtDevice"); priv->label = mx_label_new (); mx_stylable_set_style_class (MX_STYLABLE (priv->label), "BtTitle"); mx_box_layout_insert_actor_with_properties (MX_BOX_LAYOUT (device), priv->label, -1, "expand", TRUE, "x-fill", FALSE, "y-fill", FALSE, "x-align", MX_ALIGN_START, "y-align", MX_ALIGN_MIDDLE, NULL); button = mx_button_new (); mx_stylable_set_style_class (MX_STYLABLE (button), "BtCloseButton"); mx_bin_set_child (MX_BIN (button), mx_icon_new ()); g_signal_connect (button, "clicked", G_CALLBACK (_disconnect_clicked_cb), device); mx_box_layout_insert_actor (MX_BOX_LAYOUT (device), button, -1); }
static void mex_volume_control_init (MexVolumeControl *self) { MexVolumeControlPrivate *priv = self->priv = VOLUME_CONTROL_PRIVATE (self); gchar *new_style_class; MexPlayer *player; MexMusicPlayer *music; player = mex_player_get_default (); priv->media = mex_player_get_clutter_media (player); music = mex_music_player_get_default (); priv->music = mex_music_player_get_clutter_media (music); priv->volume = mx_button_new (); mx_widget_set_disabled (MX_WIDGET (priv->volume), TRUE); priv->vol_value = clutter_media_get_audio_volume (priv->media); /* The media sound can also be changed from another process changint the * stream audio with pulse audio, adjust the volume on those changes */ g_signal_connect (priv->media, "notify::audio-volume", G_CALLBACK (on_audio_volume_changed), self); g_signal_connect (priv->music, "notify::audio-volume", G_CALLBACK (on_audio_volume_changed), self); new_style_class = g_strdup_printf ("volume-%.0f", priv->vol_value * 10); mx_stylable_set_style_class (MX_STYLABLE (priv->volume), new_style_class); g_free (new_style_class); clutter_actor_add_child (CLUTTER_ACTOR (self), priv->volume); }
static void mnb_statusbar_init (MnbStatusbar *self) { MnbStatusbarPrivate *priv; GDateTime *datetime; priv = self->priv = STATUSBAR_PRIVATE (self); g_signal_connect (self, "event", G_CALLBACK (mnb_statusbar_event_cb), NULL); priv->datetime = mx_button_new (); clutter_actor_set_name (priv->datetime, "statusbar-date-button"); clutter_actor_set_parent (priv->datetime, CLUTTER_ACTOR (self)); mnb_statusbar_update_datetime (self); datetime = g_date_time_new_now_local (); g_timeout_add_seconds (60 - g_date_time_get_second (datetime), (GSourceFunc) mnb_statusbar_initial_timeout_cb, self); g_date_time_unref (datetime); }
static void mex_column_view_init (MexColumnView *self) { MexColumnViewPrivate *priv = self->priv = COLUMN_VIEW_PRIVATE (self); /* Begin private children */ clutter_actor_push_internal (CLUTTER_ACTOR (self)); /* Create the header */ priv->header = mx_box_layout_new (); mx_box_layout_set_orientation ((MxBoxLayout *) priv->header, MX_ORIENTATION_HORIZONTAL); clutter_actor_push_internal (CLUTTER_ACTOR (self)); clutter_actor_set_parent (priv->header, CLUTTER_ACTOR (self)); clutter_actor_pop_internal (CLUTTER_ACTOR (self)); priv->button = mx_button_new (); mx_stylable_set_style_class (MX_STYLABLE (priv->button), "Header"); priv->label = mx_label_new (); g_object_set (priv->label, "clip-to-allocation", TRUE, "fade-out", TRUE, NULL); clutter_actor_add_child (CLUTTER_ACTOR (priv->button), priv->label); clutter_actor_add_child (priv->header, priv->button); clutter_container_child_set (CLUTTER_CONTAINER (priv->header), priv->button, "expand", TRUE, "x-fill", TRUE, "x-align", MX_ALIGN_START, "y-fill", TRUE, NULL); g_signal_connect (priv->button, "clicked", G_CALLBACK (mex_column_header_clicked_cb), self); priv->scroll = mex_scroll_view_new (); mx_kinetic_scroll_view_set_scroll_policy (MX_KINETIC_SCROLL_VIEW (priv->scroll), MX_SCROLL_POLICY_VERTICAL); mex_scroll_view_set_indicators_hidden (MEX_SCROLL_VIEW (priv->scroll), TRUE); clutter_actor_set_parent (priv->scroll, CLUTTER_ACTOR (self)); priv->column = mex_column_new (); clutter_actor_add_child (CLUTTER_ACTOR (priv->scroll), priv->column); g_signal_connect (priv->column, "notify::opened", G_CALLBACK (mex_column_view_opened_cb), self); /* End of private children */ clutter_actor_pop_internal (CLUTTER_ACTOR (self)); /* Set the column as reactive and enable collapsing */ clutter_actor_set_reactive (CLUTTER_ACTOR (self), TRUE); }
static void mnb_launcher_button_init (MnbLauncherButton *self) { ClutterActor *label; self->priv = MNB_LAUNCHER_BUTTON_GET_PRIVATE (self); g_signal_connect (self, "leave-event", G_CALLBACK (_leave_event_cb), NULL); g_signal_connect (self, "key-focus-out", G_CALLBACK (_leave_event_cb), NULL); g_signal_connect (self, "enter-event", G_CALLBACK (_enter_event_cb), NULL); self->priv->icon = NULL; mx_stylable_set_style_class (MX_STYLABLE (self), "contentTile"); /* "app" label */ self->priv->title = (MxLabel *) mx_label_new (); mx_label_set_x_align (MX_LABEL (self->priv->title), MX_ALIGN_MIDDLE); clutter_actor_set_reactive (CLUTTER_ACTOR (self->priv->title), FALSE); mx_table_insert_actor_with_properties (MX_TABLE (self), CLUTTER_ACTOR (self->priv->title), 1, 0, "x-align", MX_ALIGN_MIDDLE, "x-expand", TRUE, "x-fill", TRUE, "y-align", MX_ALIGN_MIDDLE, "y-expand", TRUE, "y-fill", TRUE, NULL); label = mx_label_get_clutter_text (self->priv->title); clutter_text_set_ellipsize (CLUTTER_TEXT (label), PANGO_ELLIPSIZE_END); clutter_text_set_line_alignment (CLUTTER_TEXT (label), PANGO_ALIGN_CENTER); clutter_text_set_line_wrap (CLUTTER_TEXT (label), TRUE); clutter_text_set_line_wrap_mode (CLUTTER_TEXT (label), PANGO_WRAP_WORD_CHAR); /* "fav app" toggle */ self->priv->fav_toggle = g_object_ref_sink (CLUTTER_ACTOR (mx_button_new ())); mx_button_set_is_toggle (MX_BUTTON (self->priv->fav_toggle), TRUE); clutter_actor_set_name (CLUTTER_ACTOR (self->priv->fav_toggle), "mnb-launcher-button-fav-toggle"); clutter_actor_set_size (self->priv->fav_toggle, FAV_TOGGLE_SIZE, FAV_TOGGLE_SIZE); mx_table_insert_actor (MX_TABLE (self), CLUTTER_ACTOR (self->priv->fav_toggle), 0, 0); g_signal_connect (self->priv->fav_toggle, "notify::toggled", G_CALLBACK (fav_button_notify_toggled_cb), self); clutter_actor_set_reactive ((ClutterActor *) self, TRUE); }
static void mpl_application_view_init (MplApplicationView *self) { MplApplicationViewPrivate *priv; ClutterActor *actor = CLUTTER_ACTOR (self); priv = self->priv = APPLICATION_VIEW_PRIVATE (self); /* tile */ clutter_actor_set_reactive (actor, TRUE); mx_stylable_set_style_class (MX_STYLABLE (actor), "switcherTile"); clutter_actor_set_size (actor, TILE_WIDTH, TILE_HEIGHT); g_signal_connect (self, "button-release-event", G_CALLBACK (activate_clicked), NULL); priv->title_box = mx_box_layout_new_with_orientation (MX_ORIENTATION_VERTICAL); clutter_actor_set_parent (priv->title_box, actor); /* title */ priv->title = mx_label_new (); mx_label_set_y_align (MX_LABEL (priv->title), MX_ALIGN_MIDDLE); mx_stylable_set_style_class (MX_STYLABLE (priv->title), "appTitle"); mx_box_layout_add_actor (MX_BOX_LAYOUT (priv->title_box), priv->title, 0); mx_box_layout_child_set_expand (MX_BOX_LAYOUT (priv->title_box), priv->title, TRUE); /* subtitle */ priv->subtitle = mx_label_new (); mx_label_set_y_align (MX_LABEL (priv->subtitle), MX_ALIGN_MIDDLE); mx_stylable_set_style_class (MX_STYLABLE (priv->subtitle), "appSubTitle"); mx_box_layout_add_actor (MX_BOX_LAYOUT (priv->title_box), priv->subtitle, 1); mx_box_layout_child_set_expand (MX_BOX_LAYOUT (priv->title_box), priv->subtitle, FALSE); /* close button */ priv->close_button = mx_button_new (); mx_stylable_set_style_class (MX_STYLABLE (priv->close_button), "appCloseButton"); clutter_actor_set_parent (priv->close_button, actor); g_signal_connect (priv->close_button, "clicked", G_CALLBACK (close_btn_clicked), self); /* frame */ priv->app_frame = mx_frame_new (); clutter_actor_set_size (priv->app_frame, 250, 100); mx_stylable_set_style_class (MX_STYLABLE (priv->app_frame), "appBackground"); clutter_actor_set_parent (priv->app_frame, actor); /* shadow */ priv->shadow = mx_frame_new (); mx_stylable_set_style_class (MX_STYLABLE (priv->shadow), "appShadow"); mx_bin_set_child (MX_BIN (priv->app_frame), priv->shadow); mx_bin_set_fill (MX_BIN (priv->app_frame), FALSE, FALSE); clutter_actor_show_all (actor); }
static void mpl_entry_init (MplEntry *self) { MplEntryPrivate *priv; ClutterActor *text; self->priv = priv = MPL_ENTRY_GET_PRIVATE (self); priv->entry = mx_entry_new (); clutter_actor_add_child (CLUTTER_ACTOR (self), priv->entry); mx_stylable_set_style_class (MX_STYLABLE (priv->entry), "MplEntryEntry"); text = mx_entry_get_clutter_text (MX_ENTRY (priv->entry)); clutter_text_set_single_line_mode (CLUTTER_TEXT (text), TRUE); g_signal_connect (text, "text-changed", G_CALLBACK (text_changed_cb), self); priv->table = CLUTTER_ACTOR (mx_table_new ()); clutter_actor_add_child (CLUTTER_ACTOR (self), priv->table); priv->clear_button = CLUTTER_ACTOR (mx_button_new ()); clutter_actor_hide (priv->clear_button); mx_table_insert_actor (MX_TABLE (priv->table), priv->clear_button, 0, 0); mx_stylable_set_style_class (MX_STYLABLE (priv->clear_button), "MplEntryClearButton"); set_clear_button_size (priv->clear_button); g_signal_connect (priv->clear_button, "clicked", G_CALLBACK (clear_button_clicked_cb), self); priv->search_button = CLUTTER_ACTOR (mx_button_new ()); mx_table_insert_actor (MX_TABLE (priv->table), priv->search_button, 0, 1); mx_stylable_set_style_class (MX_STYLABLE (priv->search_button), "MplEntryButton"); g_signal_connect (priv->search_button, "clicked", G_CALLBACK (search_button_clicked_cb), self); }
static void ntf_wm_update_notification (NtfNotification *ntf, MetaWindow *window) { ClutterActor *src_icon; ClutterActor *button; NtfSource *src; const gchar *title; const gchar *summary; const gchar *body; g_return_if_fail (ntf && window); src = ntf_notification_get_source (ntf); if ((src_icon = ntf_source_get_icon (src))) { ClutterActor *icon = clutter_clone_new (src_icon) ; ntf_notification_set_icon (ntf, icon); } title = meta_window_get_title (window); if (title) summary = title; else summary = _("Unknown window"); ntf_notification_set_summary (ntf, summary); body = _("is asking for your attention."); ntf_notification_set_body (ntf, body); ntf_notification_remove_all_buttons (ntf); button = mx_button_new (); mx_button_set_label (MX_BUTTON (button), _("Activate")); g_signal_connect (button, "clicked", G_CALLBACK (ntf_wm_activate_cb), window); ntf_notification_add_button (ntf, button, 0); }
static ClutterActor * create_button (const char *button_style, const char *icon_style, const char *icon_name) { ClutterActor *widget; ClutterActor *icon; icon = mx_icon_new (); mx_stylable_set_style_class (MX_STYLABLE (icon), icon_style); mx_stylable_set_style (MX_STYLABLE (icon), style); mx_icon_set_icon_name (MX_ICON (icon), icon_name); mx_icon_set_icon_size (MX_ICON (icon), 64); widget = mx_button_new (); mx_stylable_set_style_class (MX_STYLABLE (widget), button_style); mx_stylable_set_style (MX_STYLABLE (widget), style); mx_bin_set_child (MX_BIN (widget), icon); return widget; }
static void ntf_tray_constructed (GObject *object) { NtfTray *self = (NtfTray*) object; ClutterActor *actor = (ClutterActor*) self; NtfTrayPrivate *priv = self->priv; ClutterActor *button; if (G_OBJECT_CLASS (ntf_tray_parent_class)->constructed) G_OBJECT_CLASS (ntf_tray_parent_class)->constructed (object); priv->notifiers = clutter_actor_new (); clutter_actor_add_child(actor, priv->notifiers); /* 'Overflow' control */ priv->control = mx_table_new (); mx_stylable_set_style_class (MX_STYLABLE (priv->control), "notification-control"); #if 0 button = mx_button_new (); mx_button_set_label (MX_BUTTON (button), _("Dismiss All")); mx_table_add_actor (MX_TABLE (priv->control), button, 0, 1); g_signal_connect (button, "clicked", G_CALLBACK (ntf_tray_dismiss_all_cb), self); #endif //DV priv->control_text = mx_label_new (); mx_table_add_actor (MX_TABLE (priv->control), CLUTTER_ACTOR (priv->control_text), 0, 0); clutter_actor_set_width (priv->control, CLUSTER_WIDTH); clutter_actor_add_child(actor, priv->control); clutter_actor_hide (priv->control); clutter_actor_set_reactive (priv->notifiers, TRUE); clutter_actor_set_reactive (actor, TRUE); mnb_input_manager_push_actor (actor, MNB_INPUT_LAYER_TOP); }
/** * mx_toolbar_set_has_close_button: * @toolbar: A #MxToolbar * @has_close_button: #TRUE if a close button should be displayed * * Set the #MxToolbar:has-close-button property * */ void mx_toolbar_set_has_close_button (MxToolbar *toolbar, gboolean has_close_button) { MxToolbarPrivate *priv; g_return_if_fail (MX_IS_TOOLBAR (toolbar)); priv = toolbar->priv; if (priv->has_close_button != has_close_button) { priv->has_close_button = has_close_button; if (!has_close_button) { if (priv->close_button) { clutter_actor_destroy (priv->close_button); priv->close_button = NULL; } } else { priv->close_button = mx_button_new (); clutter_actor_set_name (priv->close_button, "close-button"); clutter_actor_add_child (CLUTTER_ACTOR (toolbar), priv->close_button); g_signal_connect (priv->close_button, "clicked", G_CALLBACK (close_button_click_cb), toolbar); mx_stylable_style_changed (MX_STYLABLE (priv->close_button), MX_STYLE_CHANGED_FORCE); } clutter_actor_queue_relayout (CLUTTER_ACTOR (toolbar)); g_object_notify (G_OBJECT (toolbar), "has-close-button"); } }
static void mx_slider_init (MxSlider *self) { MxSliderPrivate *priv; self->priv = priv = SLIDER_PRIVATE (self); g_signal_connect (self, "style-changed", G_CALLBACK (mx_slider_style_changed_cb), NULL); priv->trough_bg = CLUTTER_ACTOR (_mx_progress_bar_fill_new ()); clutter_actor_set_name (priv->trough_bg, "trough-background"); clutter_actor_set_reactive (priv->trough_bg, TRUE); clutter_actor_add_child (CLUTTER_ACTOR (self), priv->trough_bg); g_signal_connect (priv->trough_bg, "button-press-event", G_CALLBACK (on_trough_bg_button_press_event), self); g_signal_connect (priv->trough_bg, "button-release-event", G_CALLBACK (on_trough_bg_button_release_event), self); g_signal_connect (priv->trough_bg, "leave-event", G_CALLBACK (on_trough_bg_leave_event), self); priv->fill = CLUTTER_ACTOR (_mx_progress_bar_fill_new ()); clutter_actor_set_name (priv->fill, "fill"); clutter_actor_add_child (CLUTTER_ACTOR (self), priv->fill); priv->trough = CLUTTER_ACTOR (mx_frame_new ()); clutter_actor_set_name (priv->trough, "trough"); clutter_actor_add_child (CLUTTER_ACTOR (self), priv->trough); self->priv->handle = CLUTTER_ACTOR (mx_button_new ()); clutter_actor_set_name (priv->handle, "handle"); clutter_actor_add_child (CLUTTER_ACTOR (self), priv->handle); g_signal_connect (priv->handle, "button-press-event", G_CALLBACK (on_handle_button_press_event), self); priv->buffer = _mx_progress_bar_fill_new (); clutter_actor_set_name (priv->buffer, "buffer"); clutter_actor_add_child (CLUTTER_ACTOR (self), priv->buffer); }
static void penge_interesting_tile_init (PengeInterestingTile *self) { PengeInterestingTilePrivate *priv = GET_PRIVATE_REAL (self); ClutterActor *tmp_text; ClutterActor *icon; self->priv = priv; priv->inner_table = mx_table_new (); mx_bin_set_child (MX_BIN (self), priv->inner_table); mx_bin_set_fill (MX_BIN (self), TRUE, TRUE); priv->primary_text = mx_label_new (); mx_stylable_set_style_class (MX_STYLABLE (priv->primary_text), "PengeInterestingTilePrimaryLabel"); tmp_text = mx_label_get_clutter_text (MX_LABEL (priv->primary_text)); clutter_text_set_line_alignment (CLUTTER_TEXT (tmp_text), PANGO_ALIGN_LEFT); clutter_text_set_ellipsize (CLUTTER_TEXT (tmp_text), PANGO_ELLIPSIZE_END); g_signal_connect (priv->primary_text, "notify::allocation", (GCallback)_label_notify_allocation_cb, self); priv->secondary_text = mx_label_new (); mx_stylable_set_style_class (MX_STYLABLE (priv->secondary_text), "PengeInterestingTileSecondaryLabel"); tmp_text = mx_label_get_clutter_text (MX_LABEL (priv->secondary_text)); clutter_text_set_line_alignment (CLUTTER_TEXT (tmp_text), PANGO_ALIGN_LEFT); clutter_text_set_ellipsize (CLUTTER_TEXT (tmp_text), PANGO_ELLIPSIZE_END); g_signal_connect (priv->secondary_text, "notify::allocation", (GCallback)_label_notify_allocation_cb, self); priv->icon = clutter_texture_new (); clutter_actor_set_size (priv->icon, 28, 28); clutter_actor_hide (priv->icon); /* This gets added to ourself table after our body because of ordering */ priv->details_overlay = mx_table_new (); mx_stylable_set_style_class (MX_STYLABLE (priv->details_overlay), "PengeInterestingTileDetails"); mx_table_add_actor (MX_TABLE (priv->inner_table), priv->details_overlay, 1, 0); clutter_container_child_set (CLUTTER_CONTAINER (priv->inner_table), (ClutterActor *)priv->details_overlay, "x-expand", TRUE, "y-expand", FALSE, "y-fill", FALSE, "y-align", MX_ALIGN_END, NULL); mx_table_add_actor (MX_TABLE (priv->details_overlay), priv->primary_text, 0, 1); clutter_container_child_set (CLUTTER_CONTAINER (priv->details_overlay), (ClutterActor *)priv->primary_text, "x-expand", TRUE, "y-expand", FALSE, NULL); mx_table_add_actor (MX_TABLE (priv->details_overlay), priv->secondary_text, 1, 1); clutter_container_child_set (CLUTTER_CONTAINER (priv->details_overlay), (ClutterActor *)priv->secondary_text, "x-expand", TRUE, "y-expand", FALSE, NULL); mx_table_add_actor (MX_TABLE (priv->details_overlay), priv->icon, 0, 0); clutter_container_child_set (CLUTTER_CONTAINER (priv->details_overlay), priv->icon, "row-span", 2, "y-expand", FALSE, "x-expand", FALSE, "y-fill", FALSE, "x-fill", FALSE, NULL); priv->remove_button = mx_button_new (); mx_stylable_set_style_class (MX_STYLABLE (priv->remove_button), "PengeInterestingTileRemoveButton"); icon = (ClutterActor *)mx_icon_new (); mx_stylable_set_style_class (MX_STYLABLE (icon), "PengeInterestingTileIcon"); mx_bin_set_child (MX_BIN (priv->remove_button), (ClutterActor *)icon); mx_table_add_actor_with_properties (MX_TABLE (priv->details_overlay), priv->remove_button, 0, 2, "row-span", 2, "x-expand", TRUE, "y-expand", TRUE, "x-fill", FALSE, "y-fill", FALSE, "x-align", MX_ALIGN_END, "y-align", MX_ALIGN_MIDDLE, NULL); g_signal_connect (priv->remove_button, "clicked", (GCallback)_remove_button_clicked, self); mx_table_set_column_spacing (MX_TABLE (priv->details_overlay), 4); clutter_actor_set_reactive ((ClutterActor *) self, TRUE); clutter_actor_hide (priv->icon); clutter_container_child_set (CLUTTER_CONTAINER (priv->details_overlay), priv->primary_text, "column", 0, NULL); clutter_container_child_set (CLUTTER_CONTAINER (priv->details_overlay), priv->secondary_text, "column", 0, NULL); }
static void mnp_clock_construct (MnpClockTile *tile) { MnpDateFormat *fmt; ClutterActor *box1, *label1, *label2, *label3; ClutterActor *icon; MnpClockTilePriv *priv = tile->priv; GConfClient *client = gconf_client_get_default(); fmt = mnp_format_time_from_location (tile->priv->loc, tile->priv->time_now, gconf_client_get_bool (client, "/apps/date-time-panel/24_h_clock", NULL) ); g_object_unref(client); label1 = mx_label_new_with_text (fmt->date); tile->priv->date = (MxLabel *)label1; clutter_actor_set_name (label1, "ClockTileDate"); label2 = mx_label_new_with_text (fmt->time); tile->priv->time = (MxLabel *)label2; clutter_actor_set_name (label2, fmt->day ? "ClockTileTimeDay" : "ClockTileTimeNight"); label3 = mx_label_new_with_text (fmt->city); tile->priv->city = (MxLabel *)label3; clutter_actor_set_name (label3, "ClockTileCity"); box1 = mx_box_layout_new (); clutter_actor_set_name (box1, "ClockTileDateCityBox"); mx_box_layout_set_orientation ((MxBoxLayout *)box1, MX_ORIENTATION_VERTICAL); mx_box_layout_add_actor ((MxBoxLayout *)box1, label3, 0); clutter_container_child_set ((ClutterContainer *)box1, label3, "expand", FALSE, "y-fill", FALSE, "y-align", MX_ALIGN_END, NULL); mx_box_layout_add_actor ((MxBoxLayout *)box1, label1, 1); clutter_container_child_set ((ClutterContainer *)box1, label1, "expand", TRUE, "y-fill", FALSE, "y-align", MX_ALIGN_START, NULL); mx_box_layout_set_orientation ((MxBoxLayout *)tile, MX_ORIENTATION_HORIZONTAL); mx_box_layout_add_actor ((MxBoxLayout *)tile, box1, 0); clutter_container_child_set ((ClutterContainer *)tile, box1, "expand", TRUE, "x-fill", TRUE, "y-fill", FALSE, NULL); mx_box_layout_add_actor ((MxBoxLayout *)tile, label2, 1); clutter_container_child_set ((ClutterContainer *)tile, label2, "expand", TRUE, "x-fill", FALSE, "y-fill", FALSE, "y-align", MX_ALIGN_MIDDLE, "x-align", MX_ALIGN_END, NULL); FREE_DFMT(fmt); priv->remove_button = (MxButton *)mx_button_new (); g_signal_connect (priv->remove_button, "clicked", G_CALLBACK(remove_tile), tile); mx_box_layout_add_actor ((MxBoxLayout *)tile, (ClutterActor *)priv->remove_button, 2); clutter_container_child_set ((ClutterContainer *)tile, (ClutterActor *)priv->remove_button, "expand", FALSE, "x-fill", FALSE, "y-fill", FALSE, "y-align", MX_ALIGN_MIDDLE, "x-align", MX_ALIGN_END, NULL); mx_stylable_set_style_class (MX_STYLABLE (priv->remove_button), "ClockTileRemoveButton"); icon = (ClutterActor *)mx_icon_new (); mx_stylable_set_style_class (MX_STYLABLE (icon), "ClockTileRemoveIcon"); mx_bin_set_child (MX_BIN (priv->remove_button), (ClutterActor *)icon); }
static void construct_heading_and_top_area (MnpWorldClock *world_clock) { MnpWorldClockPrivate *priv = GET_PRIVATE (world_clock); ClutterActor *box, *icon, *check_button, *text; GConfClient *client = gconf_client_get_default (); gboolean tfh; /* Time title */ box = mx_box_layout_new (); mx_stylable_set_style_class (MX_STYLABLE (box), "sectionHeader"); /* clutter_actor_set_name (box, */ /* "TimeTitleBox"); */ mx_box_layout_set_orientation ((MxBoxLayout *)box, MX_ORIENTATION_HORIZONTAL); mx_box_layout_set_spacing ((MxBoxLayout *)box, 4); icon = (ClutterActor *)mx_icon_new (); mx_stylable_set_style_class (MX_STYLABLE (icon), "ClockIcon"); clutter_actor_set_size (icon, 36, 36); mx_box_layout_add_actor (MX_BOX_LAYOUT(box), icon, -1); clutter_container_child_set (CLUTTER_CONTAINER (box), icon, "expand", FALSE, "x-fill", FALSE, "y-fill", FALSE, "y-align", MX_ALIGN_MIDDLE, "x-align", MX_ALIGN_START, NULL); text = mx_label_new_with_text (_("Time")); /* clutter_actor_set_name (text, "TimeTitle"); */ mx_box_layout_add_actor (MX_BOX_LAYOUT(box), text, -1); clutter_container_child_set (CLUTTER_CONTAINER (box), text, "expand", TRUE, "x-fill", TRUE, "y-fill", FALSE, "y-align", MX_ALIGN_MIDDLE, "x-align", MX_ALIGN_START, NULL); mx_box_layout_add_actor (MX_BOX_LAYOUT(world_clock), box, -1); clutter_container_child_set (CLUTTER_CONTAINER (world_clock), box, "expand", FALSE, "y-fill", FALSE, "x-fill", TRUE, "x-align", MX_ALIGN_START, NULL); /* Check box */ box = mx_box_layout_new (); priv->widget_box = box; mx_box_layout_set_orientation ((MxBoxLayout *)box, MX_ORIENTATION_VERTICAL); mx_box_layout_set_spacing ((MxBoxLayout *)box, 6); clutter_actor_set_name (box, "TwelveHourButtonBox"); box = mx_box_layout_new (); mx_box_layout_set_orientation ((MxBoxLayout *)box, MX_ORIENTATION_HORIZONTAL); mx_box_layout_set_spacing ((MxBoxLayout *)box, 4); tfh = gconf_client_get_bool (client, "/apps/date-time-panel/24_h_clock", NULL); g_object_unref(client); check_button = mx_button_new (); priv->tfh_clock = check_button; mx_button_set_is_toggle (MX_BUTTON (check_button), TRUE); mx_button_set_toggled(MX_BUTTON (check_button), tfh); g_signal_connect(priv->tfh_clock, "clicked", G_CALLBACK(hour_clock_changed), world_clock); mx_stylable_set_style_class (MX_STYLABLE (check_button), "check-box"); clutter_actor_set_size ((ClutterActor *)check_button, 21, 21); mx_box_layout_add_actor (MX_BOX_LAYOUT(box), check_button, -1); clutter_container_child_set (CLUTTER_CONTAINER (box), check_button, "expand", FALSE, "y-fill", FALSE, "x-fill", FALSE, NULL); text = mx_label_new_with_text (_("24 hour clock")); clutter_actor_set_name (text, "HourClockLabel"); mx_box_layout_add_actor (MX_BOX_LAYOUT(box), text, -1); clutter_container_child_set (CLUTTER_CONTAINER (box), text, "expand", TRUE, "y-fill", FALSE, "x-fill", TRUE, NULL); mx_box_layout_add_actor (MX_BOX_LAYOUT(priv->widget_box), box, -1); clutter_container_child_set (CLUTTER_CONTAINER (priv->widget_box), box, "expand", FALSE, "y-fill", FALSE, "x-fill", TRUE, NULL); mx_box_layout_add_actor (MX_BOX_LAYOUT(world_clock), priv->widget_box, -1); clutter_container_child_set (CLUTTER_CONTAINER (world_clock), box, "expand", FALSE, "y-fill", FALSE, "x-fill", TRUE, NULL); /* div = clutter_texture_new_from_file (SINGLE_DIV_LINE, NULL); mx_box_layout_add_actor (MX_BOX_LAYOUT(world_clock), div, -1); */ }
static void mpd_storage_device_tile_init (MpdStorageDeviceTile *self) { MpdStorageDeviceTilePrivate *priv = GET_PRIVATE (self); ClutterText *text; ClutterActor *separator; mx_box_layout_set_orientation (MX_BOX_LAYOUT (self), MX_ORIENTATION_VERTICAL); mx_box_layout_set_enable_animations (MX_BOX_LAYOUT (self), true); priv->table = mx_table_new (); mx_table_set_column_spacing (MX_TABLE (priv->table), 5); mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (self), priv->table, -1, "x-fill", true, NULL); /* 0 1 2 +--------------------------+ Table 0 | | Text | Open | 1 | Icon | Progress | Eject | +------+-----------+-------+ Vbox 2 | <message> .. Import data | +--------------------------+ 3 | ======================== | +--------------------------+ */ /* * Column 0: icon */ priv->icon = clutter_texture_new (); clutter_actor_set_size (priv->icon, MPD_STORAGE_DEVICE_TILE_ICON_SIZE, MPD_STORAGE_DEVICE_TILE_ICON_SIZE); mx_table_add_actor_with_properties (MX_TABLE (priv->table), priv->icon, 0, 0, "row-span", 2, "column-span", 1, "x-align", MX_ALIGN_START, "x-expand", false, "x-fill", false, "y-align", MX_ALIGN_MIDDLE, "y-expand", false, "y-fill", false, NULL); /* * Column 1 */ /* Text */ priv->label = mx_label_new (); clutter_actor_set_width (priv->label, 200.0); text = (ClutterText *) mx_label_get_clutter_text (MX_LABEL (priv->label)); clutter_text_set_line_wrap (text, true); clutter_text_set_line_wrap_mode (text, PANGO_WRAP_WORD); clutter_text_set_single_line_mode (text, false); clutter_text_set_ellipsize (text, PANGO_ELLIPSIZE_END); mx_table_add_actor_with_properties (MX_TABLE (priv->table), priv->label, 0, 1, "x-align", MX_ALIGN_START, "x-expand", true, "x-fill", true, "y-align", MX_ALIGN_MIDDLE, "y-expand", false, "y-fill", false, NULL); /* Progress */ priv->meter = mx_progress_bar_new (); mx_table_add_actor_with_properties (MX_TABLE (priv->table), priv->meter, 1, 1, "x-align", MX_ALIGN_START, "x-expand", true, "x-fill", true, "y-align", MX_ALIGN_MIDDLE, "y-expand", false, "y-fill", false, NULL); /* * Column 2: buttons */ /* Open button */ priv->open = mx_button_new_with_label (_("Open")); g_signal_connect (priv->open, "clicked", G_CALLBACK (_open_clicked_cb), self); mx_table_add_actor_with_properties (MX_TABLE (priv->table), priv->open, 0, 2, "x-align", MX_ALIGN_END, "x-expand", false, "x-fill", true, "y-align", MX_ALIGN_END, "y-expand", false, "y-fill", false, NULL); /* Eject button */ priv->eject = mx_button_new_with_label (_("Eject")); g_signal_connect (priv->eject, "clicked", G_CALLBACK (_eject_clicked_cb), self); mx_table_add_actor_with_properties (MX_TABLE (priv->table), priv->eject, 1, 2, "x-align", MX_ALIGN_END, "x-expand", false, "x-fill", true, "y-align", MX_ALIGN_MIDDLE, "y-expand", false, "y-fill", false, NULL); /* * Row 2 */ /* Import button */ priv->import = mx_button_new (); clutter_actor_set_name (priv->import, "import"); g_signal_connect (priv->import, "clicked", G_CALLBACK (_import_clicked_cb), self); mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (self), priv->import, -1, "expand", false, "x-align", MX_ALIGN_END, "x-fill", false, NULL); /* * 4th row: separator */ /* Separator */ separator = mx_frame_new (); mx_stylable_set_style_class (MX_STYLABLE (separator), "separator"); mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (self), separator, -1, "expand", false, "x-align", MX_ALIGN_MIDDLE, "x-fill", true, "y-align", MX_ALIGN_START, "y-fill", false, NULL); }
static void ntf_libnotify_update (NtfNotification *ntf, Notification *details) { ClutterActor *icon = NULL; g_return_if_fail (store && ntf && details); if (details->summary) ntf_notification_set_summary (ntf, details->summary); if (details->body) ntf_notification_set_body (ntf, details->body); if (details->icon_pixbuf) { GdkPixbuf *pixbuf = details->icon_pixbuf; icon = clutter_texture_new (); clutter_texture_set_from_rgb_data (CLUTTER_TEXTURE (icon), gdk_pixbuf_get_pixels (pixbuf), gdk_pixbuf_get_has_alpha (pixbuf), gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), gdk_pixbuf_get_rowstride (pixbuf), gdk_pixbuf_get_has_alpha (pixbuf) ? 4 : 3, 0, NULL); } else if (details->icon_name) { GtkIconTheme *theme; GtkIconInfo *info; theme = gtk_icon_theme_get_default (); info = gtk_icon_theme_lookup_icon (theme, details->icon_name, 24, 0); if (info) { icon = clutter_texture_new (); clutter_texture_set_from_file (CLUTTER_TEXTURE(icon), gtk_icon_info_get_filename (info), NULL); gtk_icon_info_free (info); } } if (icon) clutter_actor_set_size (icon, 24.0, 24.0); ntf_notification_set_icon (ntf, icon); if (details->actions) { GList *action; gchar *key, *value; ntf_notification_remove_all_buttons (ntf); for (action = details->actions; action;) { /* * The action list length is * guaranteed to be % 2 and > 0 */ key = action->data; action = g_list_next (action); value = action->data; action = g_list_next (action); if (strcasecmp(key, "default") != 0) { ActionData *data; ClutterActor *button; KeySym keysym = 0; data = g_slice_new0 (ActionData); data->notification = ntf; data->action = g_strdup (key); data->id = details->id; data->store = store; button = mx_button_new (); mx_button_set_label (MX_BUTTON (button), value); g_signal_connect_data (button, "clicked", G_CALLBACK (ntf_libnotify_action_cb), data, (GClosureNotify) free_action_data, 0); /* * Handle the dawati key shortcut protocol */ if (!strncmp (key, DAWATI_KEY_PREFIX, strlen (DAWATI_KEY_PREFIX))) { const char *k = key + strlen (DAWATI_KEY_PREFIX); const char *pfx = strstr (k, "XK_"); char *name; if (pfx) { if (k == pfx) { name = g_strdup (k + 3); } else { name = g_strdup (k); name [pfx - k] = 0; strcat (name, pfx + 3); } keysym = XStringToKeysym (name); if (!keysym) g_warning (G_STRLOC ": no keysym found for %s (%s)", key, name); g_free (name); } else { g_warning (G_STRLOC ": invalid key %s", key); } } ntf_notification_add_button (ntf, button, key, keysym); mx_stylable_set_style_class (MX_STYLABLE (button), "Primary"); } } } ntf_notification_set_urgent (ntf, details->is_urgent); ntf_notification_set_timeout (ntf, details->timeout_ms); }
static void mnp_world_clock_construct (MnpWorldClock *world_clock) { ClutterActor *entry, *box, *stage; MxBoxLayout *table = (MxBoxLayout *)world_clock; gfloat width, height; MnpWorldClockPrivate *priv = GET_PRIVATE (world_clock); stage = priv->stage; priv->location_tile = FALSE; mx_box_layout_set_orientation ((MxBoxLayout *)world_clock, MX_ORIENTATION_VERTICAL); mx_box_layout_set_spacing ((MxBoxLayout *)world_clock, 0); clutter_actor_set_name (CLUTTER_ACTOR(world_clock), "TimePane"); construct_heading_and_top_area (world_clock); priv->completion_timeout = 0; /* Search Entry */ box = mx_box_layout_new (); mx_box_layout_set_enable_animations ((MxBoxLayout *)box, TRUE); mx_box_layout_set_orientation ((MxBoxLayout *)box, MX_ORIENTATION_HORIZONTAL); mx_box_layout_set_spacing ((MxBoxLayout *)box, 4); priv->entry_box = box; mx_stylable_set_style_class (MX_STYLABLE(box), "ZoneSearchEntryBox"); entry = mx_entry_new (); mx_stylable_set_style_class (MX_STYLABLE (entry), "ZoneSearchEntry"); priv->search_location = (MxEntry *)entry; mx_entry_set_hint_text (MX_ENTRY (entry), _("Enter a country or city")); mx_entry_set_secondary_icon_from_file (MX_ENTRY (entry), THEMEDIR"/edit-clear.png"); g_signal_connect (entry, "secondary-icon-clicked", G_CALLBACK (clear_btn_clicked_cb), world_clock); g_signal_connect (G_OBJECT (entry), "notify::text", G_CALLBACK (text_changed_cb), world_clock); clutter_actor_get_size (entry, &width, &height); clutter_actor_set_size (entry, width+10, -1); mx_box_layout_add_actor ((MxBoxLayout *)box, entry, 0); clutter_container_child_set (CLUTTER_CONTAINER (box), entry, "expand", FALSE, "y-fill", FALSE, "x-fill", FALSE, "y-align", MX_ALIGN_MIDDLE, "x-align", MX_ALIGN_START, NULL); priv->add_location = mx_button_new (); mx_button_set_label ((MxButton *)priv->add_location, _("Add")); mx_stylable_set_style_class (MX_STYLABLE(priv->add_location), "ZoneSearchEntryAddButton"); /* mx_box_layout_add_actor ((MxBoxLayout *)box, priv->add_location, 1); */ /* g_signal_connect (priv->add_location, "clicked", G_CALLBACK (add_location_clicked_cb), world_clock); */ /*clutter_container_child_set (CLUTTER_CONTAINER (box), priv->add_location, "expand", FALSE, "y-fill", FALSE, "y-align", MX_ALIGN_MIDDLE, NULL);*/ mx_box_layout_add_actor (MX_BOX_LAYOUT(priv->widget_box), box, -1); clutter_container_child_set (CLUTTER_CONTAINER (priv->widget_box), box, "expand", FALSE, "y-fill", FALSE, "x-fill", FALSE, "x-align", MX_ALIGN_START, NULL); /* Prep GeoClue */ priv->geo_position = geoclue_position_new ("org.freedesktop.Geoclue.Providers.Hostip", "/org/freedesktop/Geoclue/Providers/Hostip"); priv->geo_geocode = geoclue_geocode_new ("org.freedesktop.Geoclue.Providers.Yahoo", "/org/freedesktop/Geoclue/Providers/Yahoo"); priv->geo_reverse_geocode = geoclue_reverse_geocode_new ("org.freedesktop.Geoclue.Providers.Nominatim", "/org/freedesktop/Geoclue/Providers/Nominatim"); geoclue_position_get_position_async (priv->geo_position, mnp_wc_get_position_cb, world_clock); /* Clock Area */ priv->area = mnp_clock_area_new (); g_signal_connect (priv->area, "time-changed", G_CALLBACK(time_changed), world_clock); clutter_actor_set_size ((ClutterActor *)priv->area, 300, -1); clutter_actor_set_reactive ((ClutterActor *)priv->area, TRUE); clutter_actor_set_name ((ClutterActor *)priv->area, "WorldClockArea"); clutter_container_add_actor ((ClutterContainer *)stage, (ClutterActor *)priv->area); clutter_actor_lower_bottom ((ClutterActor *)priv->area); mx_droppable_enable ((MxDroppable *)priv->area); g_object_ref ((GObject *)priv->area); clutter_container_remove_actor ((ClutterContainer *)stage, (ClutterActor *)priv->area); mx_box_layout_add_actor ((MxBoxLayout *) table, (ClutterActor *)priv->area, -1); clutter_container_child_set (CLUTTER_CONTAINER (table), (ClutterActor *)priv->area, "expand", TRUE, "y-fill", TRUE, "x-fill", TRUE, NULL); priv->zones = mnp_load_zones (); mnp_clock_area_refresh_time (priv->area, TRUE); mnp_clock_area_set_zone_remove_cb (priv->area, (ZoneRemovedFunc) zone_removed_cb, (gpointer)world_clock); mnp_clock_area_set_zone_reordered_cb (priv->area, (ClockZoneReorderedFunc) zone_reordered_cb, (gpointer)world_clock); if (priv->zones->len) { int i=0; for (i=0; i<priv->zones->len; i++) { MnpZoneLocation *loc = (MnpZoneLocation *)priv->zones->pdata[i]; loc->local = FALSE; MnpClockTile *tile = mnp_clock_tile_new (loc, mnp_clock_area_get_time(priv->area), FALSE); mnp_clock_area_add_tile (priv->area, tile); } if (priv->zones->len >= 4) clutter_actor_hide (priv->entry_box); } /* div = clutter_texture_new_from_file (SINGLE_DIV_LINE, NULL); mx_box_layout_add_actor (MX_BOX_LAYOUT(world_clock), div, -1); */ box = mx_box_layout_new (); clutter_actor_set_name (box, "DateTimeLauncherBox"); priv->launcher_box = box; mx_box_layout_set_orientation ((MxBoxLayout *)box, MX_ORIENTATION_VERTICAL); mx_box_layout_set_spacing ((MxBoxLayout *)box, 6); priv->launcher = mx_button_new (); mx_button_set_label ((MxButton *) priv->launcher, _("Set Time & Date")); mx_stylable_set_style_class (MX_STYLABLE(priv->launcher), "DateTimeLauncherButton"); mx_box_layout_add_actor ((MxBoxLayout *)box, priv->launcher, -1); clutter_container_child_set (CLUTTER_CONTAINER (box), (ClutterActor *)priv->launcher, "expand", FALSE, "y-fill", FALSE, "x-fill", FALSE, "x-align", MX_ALIGN_END, NULL); mx_box_layout_add_actor ((MxBoxLayout *)world_clock, box, -1); }
static gboolean _create_settings_dialog (MexInfoBar *self) { MexInfoBarPrivate *priv = self->priv; ClutterActor *dialog, *network_graphic; ClutterActor *network_tile, *dialog_layout, *dialog_label; ClutterActor *network_button; MxAction *close_dialog, *network_settings; dialog = mx_dialog_new (); mx_stylable_set_style_class (MX_STYLABLE (dialog), "MexInfoBarDialog"); dialog_label = mx_label_new_with_text (_("Settings")); mx_stylable_set_style_class (MX_STYLABLE (dialog_label), "DialogHeader"); /* Create actions for settings dialog */ network_settings = _action_new_from_desktop_file ("mex-networks.desktop"); close_dialog = mx_action_new_full ("close", _("Close"), G_CALLBACK (_close_dialog_cb), self); dialog_layout = mx_table_new (); mx_table_set_column_spacing (MX_TABLE (dialog_layout), 10); mx_table_set_row_spacing (MX_TABLE (dialog_layout), 30); mx_table_insert_actor (MX_TABLE (dialog_layout), CLUTTER_ACTOR (dialog_label), 0, 0); if (network_settings) { gchar *tmp; network_graphic = mx_image_new (); mx_stylable_set_style_class (MX_STYLABLE (network_graphic), "NetworkGraphic"); tmp = g_build_filename (mex_get_data_dir (), "style", "graphic-network.png", NULL); mx_image_set_from_file (MX_IMAGE (network_graphic), tmp, NULL); g_free (tmp); network_tile = mex_tile_new (); mex_tile_set_label (MEX_TILE (network_tile), _("Network")); mex_tile_set_important (MEX_TILE (network_tile), TRUE); network_button = mx_button_new (); mx_button_set_action (MX_BUTTON (network_button), network_settings); mx_bin_set_child (MX_BIN (network_tile), network_button); mx_bin_set_child (MX_BIN (network_button), network_graphic); mx_table_insert_actor (MX_TABLE (dialog_layout), CLUTTER_ACTOR (network_tile), 1, 1); } if (!network_settings) { ClutterActor *no_settings; no_settings = mx_label_new_with_text (_("No settings helpers installed")); clutter_actor_destroy (priv->settings_button); mx_table_insert_actor (MX_TABLE (dialog_layout), CLUTTER_ACTOR (no_settings), 1, 0); } mx_bin_set_child (MX_BIN (dialog), dialog_layout); mx_dialog_add_action (MX_DIALOG (dialog), close_dialog); priv->settings_dialog = g_object_ref (dialog); return TRUE; }
int main (int argc, char **argv) { const ClutterColor grey = { 0x40, 0x40, 0x40, 0xff }; ClutterActor *stage, *tile, *tile2, *image, *image2, *dialog, *tiles; MxApplication *app; ClutterConstraint *constraint; mex_init (&argc, &argv); app = mx_application_new (&argc, &argv, "mex-tile-controls-test", 0); mex_style_load_default (); stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &grey); clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE); image = mx_image_new (); mx_image_set_from_file (MX_IMAGE (image), "/home/michael/dev/mex-info-bar/graphic-mapButtons.png", NULL); image2 = mx_image_new (); mx_image_set_from_file (MX_IMAGE (image2), "/home/michael/dev/mex-info-bar/graphic-network.png", NULL); tile = mex_tile_new (); mex_tile_set_label (tile, "Remote mapping"); mex_tile_set_important (tile, TRUE); ClutterActor *button; button = mx_button_new (); mx_bin_set_child (MX_BIN (tile), button); mx_bin_set_child (MX_BIN (button), image); tile2 = mex_tile_new (); mex_tile_set_label (tile2, "Network"); mex_tile_set_important (tile2, TRUE); ClutterActor *button2; button2 = mx_button_new (); mx_bin_set_child (MX_BIN (tile2), button2); mx_bin_set_child (MX_BIN (button2), image2); tiles = mx_box_layout_new (); mx_box_layout_set_spacing (tiles, 10); mx_box_layout_set_orientation (tiles, MX_ORIENTATION_HORIZONTAL); mx_box_layout_add_actor (tiles, tile, 0); mx_box_layout_add_actor (tiles, tile2, 1); g_print (clutter_actor_get_reactive (tile) ? "reactive" : "notreactive"); dialog = mx_dialog_new (); mx_dialog_set_transient_parent (dialog, stage); g_signal_connect (button2, "clicked", G_CALLBACK (focus_in_cb), NULL); g_signal_connect (button, "clicked", G_CALLBACK (focus_in_cb), NULL); clutter_container_add_actor (CLUTTER_CONTAINER (dialog), tiles); clutter_actor_show (dialog); clutter_actor_set_size (stage, 1024, 768); clutter_actor_show (stage); clutter_main (); return 0; }
static ClutterActor * mex_menu_item_new (MexMenu *self, MxAction *action, MexMenuActionType type) { ClutterActor *button, *layout, *icon, *vbox, *label, *arrow = NULL; button = mx_button_new (); mx_button_set_is_toggle (MX_BUTTON (button), TRUE); mx_stylable_set_style_class (MX_STYLABLE (button), "Item"); layout = mx_box_layout_new (); mx_bin_set_child (MX_BIN (button), layout); mx_bin_set_fill (MX_BIN (button), TRUE, FALSE); if (type == MEX_MENU_LEFT) { arrow = mx_icon_new (); mx_stylable_set_style_class (MX_STYLABLE (arrow), "Left"); clutter_container_add_actor (CLUTTER_CONTAINER (layout), arrow); } vbox = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (vbox), MX_ORIENTATION_VERTICAL); label = mx_label_new (); mx_label_set_fade_out (MX_LABEL (label), TRUE); mx_stylable_set_style_class (MX_STYLABLE (label), "Action"); g_object_bind_property (action, "display-name", label, "text", G_BINDING_SYNC_CREATE); clutter_container_add_actor (CLUTTER_CONTAINER (vbox), label); label = mx_label_new (); mx_label_set_fade_out (MX_LABEL (label), TRUE); mx_stylable_set_style_class (MX_STYLABLE (label), "Detail"); clutter_container_add_actor (CLUTTER_CONTAINER (vbox), label); clutter_actor_hide (label); g_object_set_data (G_OBJECT (button), "detail-label", label); clutter_container_add_actor (CLUTTER_CONTAINER (layout), vbox); clutter_container_child_set (CLUTTER_CONTAINER (layout), vbox, "expand", TRUE, "x-fill", FALSE, "x-align", MX_ALIGN_START, "y-fill", FALSE, NULL); icon = mx_icon_new (); g_object_bind_property (action, "icon", icon, "icon-name", G_BINDING_SYNC_CREATE); clutter_container_add_actor (CLUTTER_CONTAINER (layout), icon); if (type == MEX_MENU_RIGHT) { arrow = mx_icon_new (); mx_stylable_set_style_class (MX_STYLABLE (arrow), "Right"); clutter_container_add_actor (CLUTTER_CONTAINER (layout), arrow); } else if (type == MEX_MENU_TOGGLE) { ClutterActor *toggle = mx_icon_new (); mx_stylable_set_style_class (MX_STYLABLE (toggle), "Toggle"); clutter_container_add_actor (CLUTTER_CONTAINER (layout), toggle); g_object_set_data (G_OBJECT (button), "toggle-icon", toggle); } if (arrow) clutter_container_child_set (CLUTTER_CONTAINER (layout), arrow, "expand", FALSE, "y-align", MX_ALIGN_MIDDLE, "y-fill", FALSE, NULL); g_signal_connect (button, "clicked", G_CALLBACK (mex_menu_item_clicked_cb), action); g_object_weak_ref (G_OBJECT (button), (GWeakNotify)mex_menu_item_destroyed_cb, self); /* Set the item qdata on the button to mark that we created it */ g_object_set_qdata (G_OBJECT (button), mex_menu_item_quark, GINT_TO_POINTER (TRUE)); return button; }
static void dawati_bt_request_init (DawatiBtRequest *request) { ClutterActor *title_box, *close_btn, *btn_box; DawatiBtRequestPrivate *priv = GET_PRIVATE (request); mx_box_layout_set_orientation (MX_BOX_LAYOUT (request), MX_ORIENTATION_VERTICAL); mx_stylable_set_style_class (MX_STYLABLE (request), "BtRequest"); priv->request = DAWATI_BT_REQUEST_TYPE_PIN; /* FIXME: this should maybe not be instance-specific */ priv->uuid_strings = _new_uiid_strings (); title_box = mx_box_layout_new (); mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (request), title_box, -1, "expand", TRUE, "x-fill", TRUE, "x-align", MX_ALIGN_START, NULL); priv->title = mx_label_new (); mx_stylable_set_style_class (MX_STYLABLE (priv->title), "BtTitle"); mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (title_box), priv->title, -1, "expand", TRUE, "x-fill", TRUE, "x-align", MX_ALIGN_START, NULL); close_btn = mx_button_new (); mx_stylable_set_style_class (MX_STYLABLE (close_btn), "BtCloseButton"); mx_bin_set_child (MX_BIN (close_btn), mx_icon_new ()); mx_box_layout_add_actor (MX_BOX_LAYOUT (title_box), close_btn, -1); g_signal_connect (close_btn, "clicked", G_CALLBACK (_close_clicked_cb), request); priv->request_label = mx_label_new (); mx_stylable_set_style_class (MX_STYLABLE (priv->request_label), "BtLabel"); mx_label_set_line_wrap (MX_LABEL (priv->request_label), TRUE); mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (request), priv->request_label, -1, "expand", TRUE, "x-fill", FALSE, "x-align", MX_ALIGN_START, NULL); btn_box = mx_box_layout_new (); mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (request), btn_box, -1, "expand", TRUE, "x-fill", FALSE, "x-align", MX_ALIGN_END, NULL); priv->request_entry = mx_entry_new (); mx_box_layout_add_actor (MX_BOX_LAYOUT (btn_box), priv->request_entry, -1); priv->request_always_btn = mx_button_new (); /* TRANSLATORS: request button label */ mx_button_set_label (MX_BUTTON (priv->request_always_btn), _("Always grant")); mx_box_layout_add_actor (MX_BOX_LAYOUT (btn_box), priv->request_always_btn, -1); g_signal_connect (priv->request_always_btn, "clicked", G_CALLBACK (_always_clicked_cb), request); priv->request_yes_btn = mx_button_new (); mx_box_layout_add_actor (MX_BOX_LAYOUT (btn_box), priv->request_yes_btn, -1); g_signal_connect (priv->request_yes_btn, "clicked", G_CALLBACK (_yes_clicked_cb), request); }
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 add_pictures (ClutterActor *box) { GList *files = get_pictures (); while (files) { gint w, h, i; ClutterActor *drawer, *drawer2, *tile, *texture, *menu, *description; gchar *file = files->data; /* Create texture */ texture = clutter_texture_new_from_file (file, NULL); clutter_texture_get_base_size (CLUTTER_TEXTURE (texture), &w, &h); clutter_actor_set_size (texture, 300, 300.0/w * h); /* Create menu */ menu = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (menu), MX_ORIENTATION_VERTICAL); for (i = 0; i < 4; i++) { ClutterActor *button, *layout, *icon, *label; button = mx_button_new (); layout = mx_box_layout_new (); icon = mx_icon_new (); label = mx_label_new (); mx_box_layout_set_spacing (MX_BOX_LAYOUT (layout), 8); mx_icon_set_icon_size (MX_ICON (icon), 16); clutter_actor_set_size (icon, 16, 16); clutter_container_add (CLUTTER_CONTAINER (layout), icon, label, NULL); mx_bin_set_child (MX_BIN (button), layout); mx_bin_set_alignment (MX_BIN (button), MX_ALIGN_START, MX_ALIGN_MIDDLE); clutter_container_add_actor (CLUTTER_CONTAINER (menu), button); mx_box_layout_child_set_x_fill (MX_BOX_LAYOUT (menu), button, TRUE); switch (i) { case 0: mx_icon_set_icon_name (MX_ICON (icon), "dialog-information"); mx_label_set_text (MX_LABEL (label), "This"); break; case 1: mx_icon_set_icon_name (MX_ICON (icon), "dialog-question"); mx_label_set_text (MX_LABEL (label), "is"); break; case 2: mx_icon_set_icon_name (MX_ICON (icon), "dialog-warning"); mx_label_set_text (MX_LABEL (label), "a"); break; case 3: mx_icon_set_icon_name (MX_ICON (icon), "dialog-error"); mx_label_set_text (MX_LABEL (label), "menu"); break; } } /* Create description */ description = mx_label_new_with_text ("Here you could put a very " "long description of whatever " "is above it. Or you could put " "another focusable widget here " "and it'd be navigable, like " "the menu on the right. Whoo!"); clutter_text_set_line_wrap ((ClutterText *)mx_label_get_clutter_text ( MX_LABEL (description)), TRUE); drawer = mex_expander_box_new (); mex_expander_box_set_important_on_focus (MEX_EXPANDER_BOX (drawer), TRUE); drawer2 = mex_expander_box_new (); mex_expander_box_set_grow_direction (MEX_EXPANDER_BOX (drawer2), MEX_EXPANDER_BOX_RIGHT); mex_expander_box_set_important (MEX_EXPANDER_BOX (drawer2), TRUE); tile = mex_tile_new_with_label (file); mex_tile_set_important (MEX_TILE (tile), TRUE); mx_bin_set_child (MX_BIN (tile), texture); clutter_container_add (CLUTTER_CONTAINER (drawer2), tile, menu, NULL); clutter_container_add (CLUTTER_CONTAINER (drawer), drawer2, description, NULL); g_signal_connect (drawer, "notify::open", G_CALLBACK (sync_drawer2_cb), drawer2); clutter_container_add_actor (CLUTTER_CONTAINER (box), drawer); clutter_actor_set_reactive (texture, TRUE); g_signal_connect (texture, "enter-event", G_CALLBACK (texture_enter_cb), drawer); g_signal_connect (texture, "leave-event", G_CALLBACK (texture_leave_cb), drawer); g_signal_connect (texture, "button-press-event", G_CALLBACK (texture_clicked_cb), drawer); g_free (file); files = g_list_delete_link (files, files); } }
static void mex_column_init (MexColumn *self) { ClutterActor *box; MexColumnPrivate *priv = self->priv = GET_PRIVATE (self); /* Begin private children */ clutter_actor_push_internal (CLUTTER_ACTOR (self)); /* Create the header */ priv->header = mx_box_layout_new (); mx_box_layout_set_orientation ((MxBoxLayout *) priv->header, MX_ORIENTATION_HORIZONTAL); mx_stylable_set_style_class (MX_STYLABLE (priv->header), "Header"); clutter_actor_push_internal (CLUTTER_ACTOR (self)); clutter_actor_set_parent (priv->header, CLUTTER_ACTOR (self)); clutter_actor_pop_internal (CLUTTER_ACTOR (self)); priv->button = mx_button_new (); priv->icon = mx_icon_new (); priv->label = mx_label_new (); g_object_set (priv->label, "clip-to-allocation", TRUE, "fade-out", TRUE, NULL); box = mx_box_layout_new (); mx_box_layout_set_spacing (MX_BOX_LAYOUT (box), 8); clutter_container_add (CLUTTER_CONTAINER (box), priv->icon, priv->label, NULL); clutter_container_child_set (CLUTTER_CONTAINER (box), priv->icon, "expand", FALSE, "y-align", MX_ALIGN_MIDDLE, "y-fill", FALSE, NULL); clutter_container_child_set (CLUTTER_CONTAINER (box), priv->label, "expand", TRUE, "x-fill", TRUE, "x-align", MX_ALIGN_START, "y-fill", FALSE, NULL); clutter_container_add_actor (CLUTTER_CONTAINER (priv->button), box); mx_bin_set_fill (MX_BIN (priv->button), TRUE, FALSE); clutter_container_add_actor (CLUTTER_CONTAINER (priv->header), priv->button); clutter_container_child_set (CLUTTER_CONTAINER (priv->header), priv->button, "expand", TRUE, "x-fill", TRUE, "x-align", MX_ALIGN_START, "y-fill", TRUE, NULL); g_signal_connect (priv->button, "clicked", G_CALLBACK (mex_column_header_clicked_cb), self); /* End of private children */ clutter_actor_pop_internal (CLUTTER_ACTOR (self)); /* Set the column as reactive and enable collapsing */ clutter_actor_set_reactive (CLUTTER_ACTOR (self), TRUE); priv->collapse = TRUE; }