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 ClutterActor * create_controls (RBShell *shell) { RBShellPlayer *player; ClutterActor *box; ClutterActor *button; int pos; gboolean playing; g_object_get (shell, "shell-player", &player, NULL); box = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (box), MX_ORIENTATION_HORIZONTAL); mx_box_layout_set_spacing (MX_BOX_LAYOUT (box), 16); mx_stylable_set_style_class (MX_STYLABLE (box), "ControlsBox"); mx_stylable_set_style (MX_STYLABLE (box), style); clutter_actor_set_reactive (box, TRUE); /* XXX rtl? */ pos = 0; button = create_button ("PrevButton", "PrevButtonIcon", "media-skip-backward"); g_signal_connect_object (button, "clicked", G_CALLBACK (prev_clicked_cb), player, 0); mx_box_layout_add_actor (MX_BOX_LAYOUT (box), button, pos++); button = create_button ("PlayPauseButton", "PlayPauseButtonIcon", "media-playback-start"); g_signal_connect_object (button, "clicked", G_CALLBACK (playpause_clicked_cb), player, 0); g_signal_connect_object (player, "playing-changed", G_CALLBACK (playing_changed_cb), button, 0); g_object_get (player, "playing", &playing, NULL); update_playing (MX_BUTTON (button), playing); mx_box_layout_add_actor (MX_BOX_LAYOUT (box), button, pos++); button = create_button ("NextButton", "NextButtonIcon", "media-skip-forward"); g_signal_connect_object (button, "clicked", G_CALLBACK (next_clicked_cb), player, 0); mx_box_layout_add_actor (MX_BOX_LAYOUT (box), button, pos++); g_object_unref (player); return box; }
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); }
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 * create_track_info (RBShell *shell) { RBShellPlayer *player; RhythmDB *db; ClutterActor *box; ClutterActor *box2; ClutterActor *widget; ClutterActor *frame; RhythmDBEntry *entry; GValue *value; guint elapsed; g_object_get (shell, "shell-player", &player, "db", &db, NULL); entry = rb_shell_player_get_playing_entry (player); box = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (box), MX_ORIENTATION_HORIZONTAL); mx_box_layout_set_spacing (MX_BOX_LAYOUT (box), 16); mx_stylable_set_style_class (MX_STYLABLE (box), "TrackInfoBox"); mx_stylable_set_style (MX_STYLABLE (box), style); /* XXX rtl? */ /* image container */ frame = mx_frame_new (); mx_stylable_set_style_class (MX_STYLABLE (frame), "TrackInfoImage"); mx_stylable_set_style (MX_STYLABLE (frame), style); mx_box_layout_add_actor (MX_BOX_LAYOUT (box), frame, 0); clutter_container_child_set (CLUTTER_CONTAINER (box), frame, "expand", FALSE, NULL); set_blank_image (MX_FRAME (frame)); clutter_actor_show_all (CLUTTER_ACTOR (frame)); g_signal_connect_object (player, "playing-song-changed", G_CALLBACK (cover_art_entry_changed_cb), frame, 0); request_cover_art (MX_FRAME (frame), entry); box2 = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (box2), MX_ORIENTATION_VERTICAL); mx_box_layout_set_spacing (MX_BOX_LAYOUT (box2), 16); mx_stylable_set_style (MX_STYLABLE (box2), style); mx_box_layout_add_actor (MX_BOX_LAYOUT (box), box2, 1); clutter_container_child_set (CLUTTER_CONTAINER (box), box2, "expand", TRUE, "x-fill", TRUE, "y-fill", TRUE, "y-align", MX_ALIGN_MIDDLE, NULL); /* track info */ widget = mx_label_new (); mx_stylable_set_style_class (MX_STYLABLE (widget), "TrackInfoText"); mx_stylable_set_style (MX_STYLABLE (widget), style); mx_box_layout_add_actor (MX_BOX_LAYOUT (box2), widget, 1); clutter_container_child_set (CLUTTER_CONTAINER (box2), widget, "expand", FALSE, "x-fill", TRUE, "y-fill", TRUE, "y-align", MX_ALIGN_MIDDLE, NULL); g_signal_connect_object (player, "playing-song-changed", G_CALLBACK (playing_song_changed_cb), widget, 0); g_signal_connect_object (db, "entry-changed", G_CALLBACK (entry_changed_cb), widget, 0); g_signal_connect_object (db, "entry-extra-metadata-notify::" RHYTHMDB_PROP_STREAM_SONG_TITLE, G_CALLBACK (streaming_title_notify_cb), widget, 0); value = rhythmdb_entry_request_extra_metadata (db, entry, RHYTHMDB_PROP_STREAM_SONG_TITLE); if (value != NULL) { update_track_info (MX_LABEL (widget), db, entry, g_value_get_string (value)); g_value_unset (value); g_free (value); } else { update_track_info (MX_LABEL (widget), db, entry, NULL); } /* elapsed/duration */ widget = mx_label_new (); mx_stylable_set_style_class (MX_STYLABLE (widget), "TrackTimeText"); mx_stylable_set_style (MX_STYLABLE (widget), style); mx_box_layout_add_actor (MX_BOX_LAYOUT (box2), widget, 2); clutter_container_child_set (CLUTTER_CONTAINER (box2), widget, "expand", FALSE, "x-fill", TRUE, "y-fill", TRUE, "y-align", MX_ALIGN_MIDDLE, NULL); g_signal_connect_object (player, "elapsed-changed", G_CALLBACK (elapsed_changed_cb), widget, 0); if (rb_shell_player_get_playing_time (player, &elapsed, NULL)) { update_elapsed (widget, player, elapsed); } rhythmdb_entry_unref (entry); g_object_unref (player); g_object_unref (db); return box; }
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 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 add_tile_from_mount (MpdDevicesTile *self, GMount *mount) { MpdDevicesTilePrivate *priv = GET_PRIVATE (self); GFile *file; char *uri; GVolume *volume; char *name = NULL; char **mime_types; GIcon *icon; GtkIconInfo *icon_info; char const *icon_file; ClutterActor *tile; GError *error = NULL; volume = g_mount_get_volume (mount); if (volume) { name = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_LABEL); g_object_unref (volume); } if (!name) { name = g_mount_get_name (mount); } /* Mount point */ file = g_mount_get_root (mount); uri = g_file_get_uri (file); mime_types = g_mount_guess_content_type_sync (mount, false, NULL, &error); for (int i = 0; mime_types && mime_types[i]; i++) { g_debug ("%s", mime_types[i]); } if (error) { g_warning ("%s : %s", G_STRLOC, error->message); g_clear_error (&error); } /* Icon */ icon = g_mount_get_icon (mount); icon_info = gtk_icon_theme_lookup_by_gicon (gtk_icon_theme_get_default (), icon, MPD_STORAGE_DEVICE_TILE_ICON_SIZE, GTK_ICON_LOOKUP_NO_SVG); icon_file = gtk_icon_info_get_filename (icon_info); g_debug ("%s() %s", __FUNCTION__, icon_file); tile = mpd_storage_device_tile_new (name, uri, mime_types ? mime_types[0] : NULL, icon_file); g_signal_connect (tile, "eject", G_CALLBACK (_tile_eject_cb), self); g_signal_connect (tile, "request-hide", G_CALLBACK (_device_tile_request_hide_cb), self); g_signal_connect (tile, "request-show", G_CALLBACK (_device_tile_request_show_cb), self); mx_box_layout_add_actor (MX_BOX_LAYOUT (priv->vbox), tile, 0); g_hash_table_insert (priv->tiles, mount, tile); gtk_icon_info_free (icon_info); g_object_unref (icon); g_strfreev (mime_types); g_free (uri); g_object_unref (file); }
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); }