示例#1
0
static ClutterActor *
mex_menu_create_layout (MexMenu *menu, gboolean lower)
{
  ClutterActor *layout, *scroll;

  MexMenuPrivate *priv = menu->priv;

  layout = mx_box_layout_new ();
  if (priv->min_width >= 0)
    g_object_set (G_OBJECT (layout), "min-width", priv->min_width, NULL);

  mx_box_layout_set_orientation (MX_BOX_LAYOUT (layout),
                                 MX_ORIENTATION_VERTICAL);
  mx_stylable_set_style_class (MX_STYLABLE (layout), "Menu");

  clutter_container_add_actor (CLUTTER_CONTAINER (menu), layout);


  priv->action_layout = mx_box_layout_new ();
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->action_layout), MX_ORIENTATION_VERTICAL);

  scroll = mex_scroll_view_new ();
  clutter_container_add_actor (CLUTTER_CONTAINER (scroll), priv->action_layout);
  clutter_container_add_actor (CLUTTER_CONTAINER (layout), scroll);

  g_object_set_data (G_OBJECT (layout), "action-layout", priv->action_layout);

  return layout;
}
示例#2
0
static void
mx_list_view_init (MxListView *list_view)
{
  list_view->priv = LIST_VIEW_PRIVATE (list_view);

  mx_box_layout_set_orientation (MX_BOX_LAYOUT (list_view), MX_ORIENTATION_VERTICAL);
}
示例#3
0
static void
penge_email_pane_init (PengeEmailPane *self)
{
  PengeEmailPanePrivate *priv = GET_PRIVATE_REAL (self);

  self->priv = priv;

  priv->account_to_widget = g_hash_table_new (NULL, NULL);
  priv->provider = g_object_new (MAILME_TYPE_TELEPATHY, NULL);
  priv->vertical = FALSE;

  mailme_telepathy_prepare_async (priv->provider,
                                  _tp_provider_prepared,
                                  self);

  mx_box_layout_set_orientation (MX_BOX_LAYOUT (self),
                                 MX_ORIENTATION_VERTICAL);

  g_signal_connect (G_OBJECT (priv->provider),
                    "account-added",
                    G_CALLBACK (_account_added_cb),
                    self);

  g_signal_connect (G_OBJECT (priv->provider),
                    "account-removed",
                    G_CALLBACK (_account_removed_cb),
                    self);
}
MnpClockArea *
mnp_clock_area_new (void)
{
	MnpClockArea *area = g_object_new(MNP_TYPE_CLOCK_AREA, NULL);
	int clk_sec = 60 - (time(NULL)%60);
	GConfClient *client = gconf_client_get_default ();

	area->priv = g_new0(MnpClockAreaPriv, 1);
	area->priv->is_enabled = 1;
	area->priv->prop_sec_zero = FALSE;
	area->priv->clock_tiles = g_ptr_array_new ();
	area->priv->position = 0.05;
	mx_box_layout_set_orientation ((MxBoxLayout *)area, MX_ORIENTATION_VERTICAL);
	mx_box_layout_set_enable_animations ((MxBoxLayout *)area, TRUE);
	area->priv->time_now = time(NULL);
	area->priv->last_time = area->priv->time_now - 60 + clk_sec;

	mx_box_layout_set_spacing ((MxBoxLayout *)area, 4);

	if (clk_sec) {
		area->priv->source = g_timeout_add (clk_sec * 1000, (GSourceFunc)clock_ticks, area);
	} else {
		area->priv->prop_sec_zero = TRUE;
		area->priv->source = g_timeout_add (60 * 1000, (GSourceFunc)clock_ticks, area);
	}

  	gconf_client_add_dir (client, "/apps/date-time-panel", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
  	gconf_client_notify_add (client, "/apps/date-time-panel/24_h_clock", clock_fmt_changed, area, NULL, NULL);
	
	area->priv->tfh = gconf_client_get_bool (client, "/apps/date-time-panel/24_h_clock", NULL);

	g_object_unref(client);

	return area;
}
static ClutterActor *
_make_notification_actor (MexNotification *notification)
{
    ClutterActor *box;
    ClutterActor *label, *icon;

    box = mx_box_layout_new ();
    mx_box_layout_set_orientation (MX_BOX_LAYOUT (box),
                                   MX_ORIENTATION_HORIZONTAL);

    if (notification->icon)
    {
        icon = mx_icon_new ();
        clutter_actor_set_size (icon, 26, 26);
        mx_icon_set_icon_name (MX_ICON (icon), notification->icon);
        clutter_container_add_actor (CLUTTER_CONTAINER (box), icon);

        mx_box_layout_child_set_y_align (MX_BOX_LAYOUT (box),
                                         icon,
                                         MX_ALIGN_MIDDLE);
    }

    label = mx_label_new_with_text (notification->message);

    mx_label_set_y_align (MX_LABEL (label), MX_ALIGN_MIDDLE);

    clutter_container_add_actor (CLUTTER_CONTAINER (box), label);

    return box;
}
示例#6
0
static void
mpl_content_pane_init (MplContentPane *self)
{
  MplContentPanePrivate *priv = GET_PRIVATE (self);

  mx_box_layout_set_orientation (MX_BOX_LAYOUT (self), MX_ORIENTATION_VERTICAL);
  mx_box_layout_set_spacing (MX_BOX_LAYOUT (self), 6);

  priv->header = (MxBoxLayout *) mx_box_layout_new ();
  mx_box_layout_set_spacing (priv->header, 12);
  mx_stylable_set_style_class (MX_STYLABLE (priv->header), "header");
  clutter_actor_set_height ((ClutterActor *) priv->header, 36);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (self),
                              CLUTTER_ACTOR (priv->header), 0);
  clutter_container_child_set (CLUTTER_CONTAINER (self),
                               (ClutterActor *) priv->header,
                               "expand", FALSE,
                               "x-fill", TRUE,
                               "y-fill", TRUE,
                               NULL);

  priv->title = (MxLabel *) mx_label_new ();
  mx_stylable_set_style_class (MX_STYLABLE (priv->title), "title");
  mx_box_layout_insert_actor (priv->header, (ClutterActor *) priv->title, 0);
  clutter_container_child_set (CLUTTER_CONTAINER (priv->header),
                               (ClutterActor *) priv->title,
                               "expand", TRUE,
                               "x-fill", TRUE,
                               "y-fill", FALSE,
                               NULL);
}
示例#7
0
int
main (int argc, char **argv)
{
  MxWindow *window;
  MxApplication *app;
  ClutterActor *stage, *bar, *button, *hbox;

  app = mx_application_new (&argc, &argv, "Test PathBar", 0);

  window = mx_application_create_window (app);
  stage = (ClutterActor *)mx_window_get_clutter_stage (window);

  bar = mx_path_bar_new ();
  mx_path_bar_set_clear_on_change (MX_PATH_BAR (bar), TRUE);

  hbox = mx_box_layout_new ();

  button = mx_button_new_with_label ("Add crumb");
  g_signal_connect_swapped (button, "clicked",
                            G_CALLBACK (add_cb), bar);
  clutter_container_add_actor (CLUTTER_CONTAINER (hbox), button);

  button = mx_button_new_with_label ("Remove crumb");
  g_signal_connect_swapped (button, "clicked",
                            G_CALLBACK (remove_cb), bar);
  clutter_container_add_actor (CLUTTER_CONTAINER (hbox), button);

  button = mx_button_new_with_label ("Toggle editable");
  g_signal_connect_swapped (button, "clicked",
                            G_CALLBACK (toggle_editable_cb), bar);
  clutter_container_add_actor (CLUTTER_CONTAINER (hbox), button);

  button = mx_button_new_with_label ("Re-label first crumb");
  g_signal_connect_swapped (button, "clicked",
                            G_CALLBACK (relabel_cb), bar);
  clutter_container_add_actor (CLUTTER_CONTAINER (hbox), button);

  /* -a for 'alternative packing'... */
  if (argc > 1 && g_str_equal (argv[1], "-a"))
    {
      ClutterActor *vbox = mx_box_layout_new ();
      mx_box_layout_set_orientation (MX_BOX_LAYOUT (vbox), MX_ORIENTATION_VERTICAL);
      clutter_container_add_actor (CLUTTER_CONTAINER (vbox), bar);
      clutter_container_add_actor (CLUTTER_CONTAINER (vbox), hbox);
      mx_window_set_child (window, vbox);
      mx_path_bar_set_editable (MX_PATH_BAR (bar), TRUE);
    }
  else
    {
      MxToolbar *toolbar = mx_window_get_toolbar (window);
      clutter_container_add_actor (CLUTTER_CONTAINER (toolbar), bar);
      mx_window_set_child (window, hbox);
    }

  clutter_actor_show (stage);

  mx_application_run (app);

  return 0;
}
示例#8
0
static void
mpd_disk_tile_init (MpdDiskTile *self)
{
  MpdDiskTilePrivate *priv = GET_PRIVATE (self);

  mx_box_layout_set_orientation (MX_BOX_LAYOUT (self), MX_ORIENTATION_VERTICAL);
  mx_box_layout_set_spacing (MX_BOX_LAYOUT (self), 5);

  priv->label = mx_label_new ();
  clutter_container_add_actor (CLUTTER_CONTAINER (self), priv->label);
  clutter_text_set_ellipsize (CLUTTER_TEXT (mx_label_get_clutter_text (
                                MX_LABEL (priv->label))), PANGO_ELLIPSIZE_NONE);

  priv->meter = mx_progress_bar_new ();
  clutter_actor_set_height (priv->meter, 12);
  clutter_container_add_actor (CLUTTER_CONTAINER (self), priv->meter);

  /* Display size of the volume $HOME is on. */
  priv->storage = mpd_storage_device_new (g_get_home_dir ());
  g_signal_connect (priv->storage, "notify::size",
                    G_CALLBACK (_storage_size_notify_cb), self);
  g_signal_connect (priv->storage, "notify::available-size",
                    G_CALLBACK (_storage_size_notify_cb), self);
  update (self);
}
示例#9
0
static void
mpd_fs_pane_init (MpdFsPane *self)
{
  ClutterActor  *tile;

  self->priv = FS_PANEL_PRIVATE (self);

  mx_box_layout_set_orientation (MX_BOX_LAYOUT (self), MX_ORIENTATION_VERTICAL);
  mx_box_layout_set_spacing (MX_BOX_LAYOUT (self), 21);
  clutter_actor_set_width (CLUTTER_ACTOR (self), MPD_PANE_WIDTH);

  tile = mpd_disk_tile_new ();
  clutter_container_add_actor (CLUTTER_CONTAINER (self), tile);

  tile = mpd_folder_tile_new ();
  clutter_actor_set_width (tile,  MPD_FOLDER_TILE_WIDTH);
  g_signal_connect (tile, "request-hide",
                    G_CALLBACK (_tile_request_hide_cb), self);
  clutter_container_add_actor (CLUTTER_CONTAINER (self), tile);
  clutter_container_child_set (CLUTTER_CONTAINER (self), tile,
                               "expand", TRUE,
                               "x-fill", TRUE,
                               "y-fill", TRUE,
                               NULL);
}
static void
mpd_devices_tile_init (MpdDevicesTile *self)
{
  MpdDevicesTilePrivate *priv = GET_PRIVATE (self);
  ClutterActor  *tile;
  GList *mounts;

  priv->tiles = g_hash_table_new (g_direct_hash, g_direct_equal);

  priv->vbox = mx_box_layout_new ();
  mx_box_layout_set_enable_animations (MX_BOX_LAYOUT (priv->vbox),
                                       TRUE);
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->vbox),
                                 MX_ORIENTATION_VERTICAL);
  clutter_container_add_actor (CLUTTER_CONTAINER (self), priv->vbox);

  tile = mpd_default_device_tile_new ();
  clutter_container_add_actor (CLUTTER_CONTAINER (priv->vbox), tile);

  priv->monitor = g_volume_monitor_get ();
  g_signal_connect (priv->monitor, "mount-added",
                    G_CALLBACK (_monitor_mount_added_cb), self);
  g_signal_connect (priv->monitor, "mount-changed",
                    G_CALLBACK (_monitor_mount_changed_cb), self);
  g_signal_connect (priv->monitor, "mount-removed",
                    G_CALLBACK (_monitor_mount_removed_cb), self);

  mounts = g_volume_monitor_get_mounts (priv->monitor);
  g_list_foreach (mounts, (GFunc) _add_mount_cb, self);
  g_list_free (mounts);
}
int
main (int argc, char **argv)
{
  const ClutterColor dark_gray = { 0x40, 0x40, 0x40, 0xff };

  ClutterActor *box, *stage;
  MxApplication *app;
  MxWindow *window;

  mex_init (&argc, &argv);
  app = mx_application_new (&argc, &argv, "test-mex-expander-box", 0);
  clutter_init (&argc, &argv);

  mex_style_load_default ();

  window = mx_application_create_window (app);
  stage = (ClutterActor *)mx_window_get_clutter_stage (window);
  clutter_stage_set_color (CLUTTER_STAGE (stage), &dark_gray);

  box = mx_box_layout_new ();
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (box), MX_ORIENTATION_VERTICAL);

  add_pictures (box);

  clutter_container_add_actor (CLUTTER_CONTAINER (stage), box);

  mx_window_set_has_toolbar (window, FALSE);
  clutter_actor_set_size (stage, 640, 480);
  clutter_actor_show (stage);

  clutter_main ();

  return 0;
}
示例#12
0
static void
mex_content_box_init (MexContentBox *self)
{
  MexContentBoxPrivate *priv = self->priv = CONTENT_BOX_PRIVATE (self);
  ClutterActor *hline, *box;

  priv->thumb_width = 426;
  priv->thumb_height = 240;

  /* Create description panel */
  box = mx_box_layout_new ();
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (box), MX_ORIENTATION_VERTICAL);

  hline = clutter_rectangle_new_with_color (&hline_color);
  clutter_actor_set_height (hline, 1);

  priv->panel = mex_info_panel_new (MEX_INFO_PANEL_MODE_SIMPLE);

  clutter_container_add (CLUTTER_CONTAINER (box), hline, priv->panel, NULL);


  /* monitor key press events */
  g_signal_connect (self, "key-press-event",
                    G_CALLBACK (mex_content_box_key_press_event_cb), self);

  /* Create tile */
  priv->tile = mex_content_tile_new ();
  g_object_set (G_OBJECT (priv->tile),
                "thumb-width", priv->thumb_width,
                "thumb-height", priv->thumb_height,
                NULL);
  mx_bin_set_fill (MX_BIN (priv->tile), TRUE, TRUE);

  clutter_actor_set_reactive (priv->tile, TRUE);
  g_signal_connect (priv->tile, "button-release-event",
                    G_CALLBACK (mex_content_box_tile_clicked_cb), self);

  /* Create secondary box for tile/menu */
  priv->box = mex_expander_box_new ();
  mex_expander_box_set_important (MEX_EXPANDER_BOX (priv->box), TRUE);
  mex_expander_box_set_grow_direction (MEX_EXPANDER_BOX (priv->box),
                                      MEX_EXPANDER_BOX_RIGHT);
  mex_expander_box_set_primary_child (MEX_EXPANDER_BOX (priv->box), priv->tile);

  /* Pack box and panel into self */
  mex_expander_box_set_primary_child (MEX_EXPANDER_BOX (self), priv->box);
  mex_expander_box_set_secondary_child (MEX_EXPANDER_BOX (self), box);

  /* Create the action list */
  priv->action_list = mex_action_list_new ();
  mex_expander_box_set_secondary_child (MEX_EXPANDER_BOX (priv->box),
                                        priv->action_list);

  /* Connect to the open notify signal */
  g_signal_connect (self, "notify::open",
                    G_CALLBACK (mex_content_box_notify_open_cb), NULL);
}
示例#13
0
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);
}
示例#14
0
文件: test-focus.c 项目: danni/mx
int
main (int argc, char *argv[])
{
  ClutterActor *button, *box, *stage;
  MxApplication *application;
  MxWindow *window;

  application = mx_application_new (&argc, &argv, "Test Mx focus handling",
                                    MX_APPLICATION_SINGLE_INSTANCE);

  window = mx_application_create_window (application);
  stage = (ClutterActor *)mx_window_get_clutter_stage (window);

  box = mx_box_layout_new ();
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (box), MX_ORIENTATION_VERTICAL);
  mx_window_set_child (window, box);

  button = mx_button_new_with_label ("button #1 (activate to remove)");
  g_signal_connect (button, "clicked",
                    G_CALLBACK (button_clicked_cb), NULL);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (box), button, -1);

  mx_focus_manager_push_focus (mx_focus_manager_get_for_stage (CLUTTER_STAGE (stage)),
                               MX_FOCUSABLE (button));


  button = mx_button_new_with_label ("button #2 (activate to remove)");
  g_signal_connect (button, "clicked",
                    G_CALLBACK (button_clicked_cb), NULL);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (box), button, -1);

  button = mx_button_new_with_label ("button #3 (activate to remove)");
  g_signal_connect (button, "clicked",
                    G_CALLBACK (button_clicked_cb), NULL);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (box), button, -1);

  button = mx_button_new_with_label ("button #4 (activate to remove)");
  g_signal_connect (button, "clicked",
                    G_CALLBACK (button_clicked_cb), NULL);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (box), button, -1);

  clutter_actor_show (stage);

  mx_application_run (application);

  return EXIT_SUCCESS;
}
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
mpd_devices_pane_init (MpdDevicesPane *self)
{
  ClutterActor  *label;
  ClutterActor  *tile;

  mx_box_layout_set_orientation (MX_BOX_LAYOUT (self), MX_ORIENTATION_VERTICAL);
  clutter_actor_set_width (CLUTTER_ACTOR (self), MPD_DEVICES_PANE_WIDTH);

  label = mx_label_new_with_text (_("Other devices"));
  clutter_actor_set_name (label, "pane-label");
  clutter_container_add_actor (CLUTTER_CONTAINER (self), label);

  tile = mpd_devices_tile_new ();
  g_signal_connect (tile, "request-hide",
                    G_CALLBACK (_tile_request_hide_cb), self);
  g_signal_connect (tile, "request-show",
                    G_CALLBACK (_tile_request_show_cb), self);
  clutter_container_add_actor (CLUTTER_CONTAINER (self), tile);
  clutter_container_child_set (CLUTTER_CONTAINER (self), tile,
                               "expand", true,
                               NULL);
}
示例#17
0
static void
mpd_folder_button_init (MpdFolderButton *self)
{
  MpdFolderButtonPrivate *priv = GET_PRIVATE (self);
  ClutterActor  *vbox;
  ClutterText   *text;

  /* Box */
  vbox = mx_box_layout_new ();
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (vbox), MX_ORIENTATION_VERTICAL);
  mx_bin_set_child (MX_BIN (self), vbox);

  /* Icon */
  priv->icon = clutter_texture_new ();
  clutter_texture_set_sync_size (CLUTTER_TEXTURE (priv->icon), true);
  clutter_container_add_actor (CLUTTER_CONTAINER (vbox), priv->icon);
  clutter_container_child_set (CLUTTER_CONTAINER (vbox), priv->icon,
                               "expand", false,
                               "x-align", MX_ALIGN_MIDDLE,
                               "x-fill", false,
                               "y-align", MX_ALIGN_START,
                               "y-fill", false,
                               NULL);

  /* Label */
  priv->label = mx_label_new ();
  text = (ClutterText *) mx_label_get_clutter_text (MX_LABEL (priv->label));
  clutter_text_set_line_wrap_mode (text, PANGO_WRAP_WORD_CHAR);
  clutter_container_add_actor (CLUTTER_CONTAINER (vbox), priv->label);
  clutter_container_child_set (CLUTTER_CONTAINER (vbox), priv->label,
                               "expand", false,
                               "x-align", MX_ALIGN_MIDDLE,
                               "x-fill", false,
                               "y-align", MX_ALIGN_START,
                               "y-fill", false,
                               NULL);
}
示例#18
0
int
main (int     argc,
      char  **argv)
{
  ClutterActor    *stage;
  MxBoxLayout     *vbox;
  MxBoxLayout     *hbox;
  ClutterActor    *button;
  ClutterActor    *label;
  ObjectStoreTest  app = { 0, };

  clutter_init (&argc, &argv);

  stage = clutter_stage_get_default ();
  clutter_actor_set_size (stage, 320.0, 240.0);

  vbox = (MxBoxLayout *) mx_box_layout_new ();
  clutter_actor_set_size (CLUTTER_ACTOR (vbox), 320.0, 240.0);
  mx_box_layout_set_orientation (vbox, MX_ORIENTATION_VERTICAL);
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), CLUTTER_ACTOR (vbox));

  /* Create model */
  app.store = foo_object_store_new (2,
                                    FOO_TYPE_TEST_OBJECT, "foo",  /* column #0 */
                                    G_TYPE_STRING, "text");       /* column #1 */

  /*
   * Create view
   */
  app.view = mx_list_view_new ();

  /* Use MxButton to render the model's items */
  mx_list_view_set_item_type (MX_LIST_VIEW (app.view), MX_TYPE_BUTTON);

  /* Map column #1 to attribute "label" of view's GtkButton */
  mx_list_view_add_attribute (MX_LIST_VIEW (app.view), "label", 1);

  /* Connect to model */
  mx_list_view_set_model (MX_LIST_VIEW (app.view), app.store);

  mx_box_layout_add_actor_with_properties (vbox, app.view, -1,
                                           "expand", true,
                                           "x-fill", true,
                                           "y-fill", true,
                                           NULL);

  hbox = (MxBoxLayout *) mx_box_layout_new ();
  mx_box_layout_set_orientation (hbox, MX_ORIENTATION_HORIZONTAL);
  mx_box_layout_add_actor_with_properties (vbox, CLUTTER_ACTOR (hbox), -1,
                                           "expand", false,
                                           "x-fill", true,
                                           NULL);

  app.entry = (MxEntry *) mx_entry_new ();
  mx_box_layout_add_actor_with_properties (hbox, CLUTTER_ACTOR (app.entry), -1,
                                           "expand", true,
                                           "x-fill", true,
                                           NULL);

  button = mx_button_new_with_label ("Update");
  g_signal_connect (button, "clicked",
                    G_CALLBACK (_update_clicked), &app);
  clutter_container_add_actor (CLUTTER_CONTAINER (hbox), button);

  button = mx_button_new_with_label ("Dump");
  g_signal_connect (button, "clicked",
                    G_CALLBACK (_dump_clicked), &app);
  clutter_container_add_actor (CLUTTER_CONTAINER (hbox), button);

  label = mx_label_new_with_text ("Enter text and update to add item\n"
                                  "Enter <number>:<text> to change item <number>\n"
                                  "Enter -<number> to delete item <number>");
  clutter_container_add_actor (CLUTTER_CONTAINER (vbox), label);

  clutter_actor_show_all (stage);
  clutter_main ();

  return EXIT_SUCCESS;
}
示例#19
0
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 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;
}
示例#21
0
static void
mex_search_plugin_init (MexSearchPlugin *self)
{
  MexProxy *suggest_proxy;
  ClutterActor *icon, *header, *text, *frame, *box, *hbox;
  MexSearchPluginPrivate *priv = self->priv = SEARCH_PLUGIN_PRIVATE (self);

  /* Load style data */
  mx_style_load_from_file (mx_style_get_default (),
                           PLUGIN_DATA_DIR "/style.css", NULL);

  /* Create the history model and models list */
  priv->history_model = mex_feed_new (_("Search"), _("Search"));

  priv->model_info =
    mex_model_info_new_with_sort_funcs (MEX_MODEL (priv->history_model),
                                        "search", 0);
  g_object_unref (priv->history_model);
  priv->models = g_list_append (NULL, priv->model_info);

  /* Create the actions list */
  memset (&priv->action_info, 0, sizeof (MexActionInfo));
  priv->action_info.action =
    mx_action_new_full ("x-mex/search",
                        _("Search"),
                        G_CALLBACK (mex_search_plugin_history_cb),
                        self);
  priv->action_info.mime_types = (gchar **)search_mimetypes;
  priv->actions = g_list_append (NULL, &priv->action_info);

  /* Create the suggestions model */
  priv->suggest_model =
    mex_feed_new (_("Suggestions"), _("Google Suggestions"));

  /* Create the search page */

  /* Create header */
  icon = mx_icon_new ();
  mx_stylable_set_style_class (MX_STYLABLE (icon), "Search");

  header = mx_box_layout_new ();
  mx_box_layout_set_spacing (MX_BOX_LAYOUT (header), 5);
  clutter_actor_set_name (header, "search-header");

  /* Create search entry */
  frame = mx_table_new ();
  clutter_actor_set_name (frame, "search-entry-frame");
  priv->search_entry = mx_entry_new ();
  priv->spinner = mx_spinner_new ();

  mx_table_add_actor (MX_TABLE (frame), priv->search_entry, 0, 0);
  mx_table_add_actor (MX_TABLE (frame), priv->spinner, 0, 1);
  mx_table_child_set_x_fill (MX_TABLE (frame), priv->spinner, FALSE);
  mx_table_child_set_x_expand (MX_TABLE (frame), priv->spinner, FALSE);
  mx_table_child_set_y_fill (MX_TABLE (frame), priv->spinner, FALSE);

  mx_spinner_set_animating (MX_SPINNER (priv->spinner), FALSE);
  clutter_actor_hide (priv->spinner);

  clutter_container_add (CLUTTER_CONTAINER (header), icon, frame, NULL);
  clutter_container_child_set (CLUTTER_CONTAINER (header), icon,
                               "x-fill", FALSE, "y-fill", FALSE, NULL);
  clutter_container_child_set (CLUTTER_CONTAINER (header), frame,
                               "expand", TRUE, "x-fill", TRUE, NULL);

  text = mx_entry_get_clutter_text (MX_ENTRY (priv->search_entry));
  g_signal_connect_swapped (text, "activate",
                            G_CALLBACK (mex_search_plugin_search_cb), self);
  g_signal_connect (priv->search_entry, "notify::text",
                    G_CALLBACK (mex_search_text_changed_cb), self);
  g_signal_connect (priv->search_entry, "notify::style-pseudo-class",
                    G_CALLBACK (mex_search_text_style_changed), header);

  /* Create the suggestions column */
  priv->suggest_column = mx_box_layout_new ();
  clutter_actor_set_name (priv->suggest_column, "suggest-column");
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->suggest_column),
                                 MX_ORIENTATION_VERTICAL);
  suggest_proxy = mex_generic_proxy_new (MEX_MODEL (priv->suggest_model),
                                        MX_TYPE_BUTTON);
  mex_generic_proxy_bind (MEX_GENERIC_PROXY (suggest_proxy),
                          mex_enum_to_string (MEX_TYPE_CONTENT_METADATA,
                                              MEX_CONTENT_METADATA_TITLE),
                          "label");
  g_signal_connect (suggest_proxy, "object-created",
                    G_CALLBACK (mex_search_proxy_add_cb),
                    priv->suggest_column);
  g_signal_connect (suggest_proxy, "object-removed",
                    G_CALLBACK (mex_search_proxy_remove_cb),
                    priv->suggest_column);
  g_object_weak_ref (G_OBJECT (priv->suggest_column),
                     (GWeakNotify)g_object_unref, suggest_proxy);

  /* Pack the search page */
  priv->search_page = mx_frame_new ();
  clutter_actor_set_name (priv->search_page, "search-page");
  mx_bin_set_fill (MX_BIN (priv->search_page), FALSE, TRUE);
  mx_bin_set_alignment (MX_BIN (priv->search_page), MX_ALIGN_START,
                        MX_ALIGN_START);
  hbox = mex_resizing_hbox_new ();
  mex_resizing_hbox_set_resizing_enabled (MEX_RESIZING_HBOX (hbox), FALSE);
  box = mx_box_layout_new ();
  clutter_container_add_actor (CLUTTER_CONTAINER (priv->search_page), hbox);
  clutter_container_add_actor (CLUTTER_CONTAINER (hbox), box);
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (box),
                                 MX_ORIENTATION_VERTICAL);
  clutter_container_add (CLUTTER_CONTAINER (box),
                         header, priv->suggest_column, NULL);
  mx_box_layout_child_set_expand (MX_BOX_LAYOUT (box),
                                  priv->suggest_column, TRUE);
  clutter_container_child_set (CLUTTER_CONTAINER (box), header,
                               "x-fill", TRUE,
                               "x-align", MX_ALIGN_START, NULL);
  clutter_container_child_set (CLUTTER_CONTAINER (box),
                               priv->suggest_column,
                               "x-fill", TRUE,
                               "x-align", MX_ALIGN_START, NULL);
  clutter_actor_set_width (box, 426.0);

  /* Update the history list */
  mex_search_plugin_update_history (self, NULL);

  /* Start the history list and suggestions proxy */
  mex_proxy_start (suggest_proxy);
}
示例#22
0
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;
}
示例#23
0
static void
dawati_bt_shell_init (DawatiBtShell *shell)
{
  ClutterActor *label, *active_label, *active_box, *settings_button;
  DawatiBtShellPrivate *priv = GET_PRIVATE (shell);

  priv->devices = g_hash_table_new_full (g_str_hash, g_str_equal,
                                         g_free, NULL);
  priv->requests = g_hash_table_new_full (g_str_hash, g_str_equal,
                                         g_free, NULL);

  priv->notification = notify_notification_new ("", NULL, icon);
  notify_notification_set_timeout (priv->notification,
                                   NOTIFY_EXPIRES_NEVER);
  /* TRANSLATORS: button in a notification, will open the
   * bluetooth panel */
  notify_notification_add_action (priv->notification,
                                  "show",
                                  _("Show"),
                                  (NotifyActionCallback)_notify_action_cb,
                                  shell, NULL);

  mx_box_layout_set_orientation (MX_BOX_LAYOUT (shell),
                                 MX_ORIENTATION_VERTICAL);

  label = mx_label_new_with_text (_("Bluetooth"));
  mx_stylable_set_style_class (MX_STYLABLE (label), "titleBar");
  mx_box_layout_insert_actor_with_properties (MX_BOX_LAYOUT (shell),
                                              label, -1,
                                              "expand", TRUE,
                                              "x-fill", TRUE,
                                              "x-align", MX_ALIGN_START,
                                              NULL);

  priv->content = mx_box_layout_new ();
  clutter_actor_set_name (priv->content, "bt-panel-content");
  mx_box_layout_set_enable_animations (MX_BOX_LAYOUT (priv->content), TRUE);
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->content), MX_ORIENTATION_VERTICAL);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (shell), priv->content, -1);

  active_box = mx_box_layout_new ();
  clutter_actor_set_name (active_box, "bt-panel-active-box");
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->content), active_box, -1);

  /* TRANSLATORS: Label for bluetooth enable/disable toggle */
  active_label = mx_label_new_with_text (_("Active"));
  mx_stylable_set_style_class (MX_STYLABLE (active_label), "BtTitle");
  mx_box_layout_insert_actor_with_properties (MX_BOX_LAYOUT (active_box),
                                              active_label, -1,
                                              "expand", TRUE,
                                              "x-fill", TRUE,
                                              "x-align", MX_ALIGN_START,
                                              "y-fill", FALSE,
                                              "y-align", MX_ALIGN_MIDDLE,
                                              NULL);

  priv->kill_toggle = mx_toggle_new ();
  priv->kill_handler = g_signal_connect (priv->kill_toggle, "notify::active",
                                         G_CALLBACK (_toggle_active_cb), shell);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (active_box),
                              priv->kill_toggle, -1);

  /* devices that are requesting something go here */
  priv->request_box = mx_box_layout_new ();
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->request_box),
                                 MX_ORIENTATION_VERTICAL);
  mx_box_layout_set_enable_animations (MX_BOX_LAYOUT (priv->request_box),
                                       TRUE);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->content),
                              priv->request_box, -1);


  /* connected devices go here */
  priv->device_panelbox = g_object_ref (mx_box_layout_new ());
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->device_panelbox),
                                 MX_ORIENTATION_VERTICAL);
  mx_stylable_set_style_class (MX_STYLABLE (priv->device_panelbox),
                               "contentPanel");

  priv->info_label = mx_label_new_with_text (_("Nothing connected"));
  mx_stylable_set_style_class (MX_STYLABLE (priv->info_label), "BtTitle");
  clutter_actor_hide (priv->info_label);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->device_panelbox),
                              priv->info_label, -1);

  priv->device_box = mx_box_layout_new ();
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->device_box),
                                 MX_ORIENTATION_VERTICAL);

  mx_box_layout_set_enable_animations (MX_BOX_LAYOUT (priv->device_box),
                                       TRUE);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->device_panelbox),
                              priv->device_box, -1);

  /* button row */
  priv->button_box = mx_box_layout_new ();
  clutter_actor_set_name (priv->button_box, "bt-panel-button-box");
  mx_box_layout_set_enable_animations (MX_BOX_LAYOUT (priv->button_box), TRUE);
  mx_box_layout_insert_actor_with_properties (MX_BOX_LAYOUT (priv->content),
                                              priv->button_box, -1,
                                              "expand", TRUE,
                                              "x-fill", TRUE,
                                              NULL);

  mx_box_layout_insert_actor_with_properties (MX_BOX_LAYOUT (priv->button_box),
                                              mx_box_layout_new (), 0,
                                              "expand", TRUE,
                                              NULL);

  priv->send_button = mx_button_new_with_label (_("Send file"));
  g_signal_connect (priv->send_button, "clicked",
                    G_CALLBACK (_send_clicked_cb), shell);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->button_box),
                              priv->send_button, 1);

  priv->add_button = mx_button_new_with_label (_("Add new"));
  g_signal_connect (priv->add_button, "clicked",
                    G_CALLBACK (_add_clicked_cb), shell);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->button_box),
                              priv->add_button, 2);

  settings_button = mx_button_new_with_label (_("Settings"));
  g_signal_connect (settings_button, "clicked",
                    G_CALLBACK (_settings_clicked_cb), shell);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->button_box), settings_button, 3);

  dawati_bt_shell_init_applet (shell);

  priv->cm = carrick_connman_manager_new ();
  g_signal_connect (priv->cm, "notify::available-technologies",
                    G_CALLBACK (_available_techs_changed), shell);
  g_signal_connect (priv->cm, "notify::enabled-technologies",
                    G_CALLBACK (_enabled_techs_changed), shell);

#ifdef TEST_WITH_BOGUS_DATA
  g_debug ("TEST_WITH_BOGUS_DATA: Adding false devices & requests, "
           "and setting Bluetooth available even if connman is not there");
  /* Dummies for quick testing without bluetooth devices or connman */
  dawati_bt_shell_add_device (shell, "TestDeviceA", "a");
  dawati_bt_shell_add_device (shell, "TestDeviceB", "b");
  dawati_bt_shell_add_request (shell, "TestDeviceC", "c", DAWATI_BT_REQUEST_TYPE_PIN, NULL);
  dawati_bt_shell_add_request (shell, "TestDeviceD", "d", DAWATI_BT_REQUEST_TYPE_CONFIRM, "001234");
  dawati_bt_shell_add_request (shell, "TestDeviceE", "e", DAWATI_BT_REQUEST_TYPE_AUTH, "0000111f-0000-1000-8000-00805f9b34fb");
  priv->enabled = priv->available = TRUE;
  dawati_bt_shell_update (shell);
#endif
}
示例#24
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;
}
示例#25
0
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
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);
    }
}
示例#27
0
static void
mex_grid_view_init (MexGridView *self)
{
  MexGridViewPrivate *priv = self->priv = GRID_VIEW_PRIVATE (self);
  ClutterActor *scroll_view;

  priv->state = STATE_CLOSED;

  /* Create the menu */
  priv->menu_layout = mex_menu_new ();
  mex_resizing_hbox_set_max_depth (MEX_RESIZING_HBOX (priv->menu_layout), 1);

  /* Add a title/icon */
  priv->menu_title = mx_label_new ();

  mx_stylable_set_style_class (MX_STYLABLE (priv->menu_title), "Header");
  clutter_actor_set_name (priv->menu_title, "menu-header");

  priv->menu = (ClutterActor*) mex_menu_get_layout (MEX_MENU (priv->menu_layout));

  clutter_actor_set_width (priv->menu, MENU_MIN_WIDTH);
  clutter_actor_insert_child_at_index (priv->menu, priv->menu_title, 0);


  /* Add the grid */
  priv->grid_layout = mx_box_layout_new ();
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->grid_layout),
                                 MX_ORIENTATION_VERTICAL);

  /* header */
  priv->grid_title = mx_label_new ();
  mx_stylable_set_style_class (MX_STYLABLE (priv->grid_title), "Header");
  clutter_actor_add_child (priv->grid_layout, priv->grid_title);

  /* scroll view */
  scroll_view = mex_scroll_view_new ();
  mx_kinetic_scroll_view_set_scroll_policy (MX_KINETIC_SCROLL_VIEW (scroll_view),
                                            MX_SCROLL_POLICY_VERTICAL);
  mx_stylable_set_style_class (MX_STYLABLE (scroll_view), "Grid");
  mx_box_layout_insert_actor_with_properties (MX_BOX_LAYOUT (priv->grid_layout),
                                              scroll_view, 1,
                                              "expand", TRUE, NULL);

  /* grid */
  priv->grid = mex_grid_new ();
  mx_bin_set_child (MX_BIN (scroll_view), priv->grid);
  clutter_actor_set_opacity (priv->grid, 0);


  /* Name actors so we can style */
  clutter_actor_set_name (CLUTTER_ACTOR (self), "grid-page");
  clutter_actor_set_name (priv->grid_layout, "content");

  clutter_actor_push_internal (CLUTTER_ACTOR (self));

  clutter_actor_set_parent (priv->menu_layout, CLUTTER_ACTOR (self));
  clutter_actor_set_parent (priv->grid_layout, CLUTTER_ACTOR (self));

  clutter_actor_pop_internal (CLUTTER_ACTOR (self));


  /* timeline for animations */
  priv->timeline = clutter_timeline_new (ANIMATION_DURATION);
  priv->alpha = clutter_alpha_new_full (priv->timeline, CLUTTER_EASE_IN_OUT_CUBIC);
  g_signal_connect (priv->timeline, "new-frame",
                    G_CALLBACK (mex_grid_view_timeline_cb), self);
  g_signal_connect (priv->timeline, "completed",
                    G_CALLBACK (mex_grid_view_timeline_complete_cb), self);
}
示例#28
0
文件: mx-button.c 项目: danni/mx
static void
mx_button_update_contents (MxButton *self)
{
  MxButtonPrivate *priv = self->priv;
  ClutterActor *child;
  gboolean icon_visible, label_visible;
  const gchar *text;

  /* If the icon doesn't have a name set, treat it as
   * not-visible.
   */
  if (priv->icon_visible && mx_icon_get_icon_name (MX_ICON (priv->icon)))
    icon_visible = TRUE;
  else
    icon_visible = FALSE;

  text = clutter_text_get_text (CLUTTER_TEXT (priv->label));

  if (priv->label_visible && text && (strcmp (text, "") != 0))
    label_visible = TRUE;
  else
    label_visible = FALSE;

  /* replace any custom content */
  child = mx_bin_get_child (MX_BIN (self));

  if (child != priv->hbox)
    mx_bin_set_child (MX_BIN (self), priv->hbox);

  /* Handle the simple cases first */
  if (!icon_visible && !label_visible)
    {
      clutter_actor_hide (priv->hbox);
      return;
    }

  /* ensure the hbox is visible */
  clutter_actor_show (priv->hbox);

  if (icon_visible && !label_visible)
    {
      clutter_actor_show (priv->icon);
      clutter_actor_hide (priv->label);
      clutter_actor_set_child_below_sibling (priv->hbox, priv->icon, NULL);
      return;
    }

  if (!icon_visible && label_visible)
    {
      clutter_actor_hide (priv->icon);
      clutter_actor_show (priv->label);
      clutter_actor_set_child_below_sibling (priv->hbox, priv->label, NULL);
      return;
    }

  /* Both the icon and text are visible, handle this case */
  clutter_actor_show (priv->icon);
  clutter_actor_show (priv->label);

  switch (priv->icon_position)
    {
    case MX_POSITION_TOP:
      mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->hbox),
                                     MX_ORIENTATION_VERTICAL);
      clutter_actor_set_child_below_sibling (priv->hbox, priv->icon, NULL);

      clutter_container_child_set (CLUTTER_CONTAINER (priv->hbox),
                                   priv->label, "x-align", MX_ALIGN_MIDDLE,
                                   "y-align", MX_ALIGN_END, NULL);
      clutter_container_child_set (CLUTTER_CONTAINER (priv->hbox),
                                   priv->icon, "x-align", MX_ALIGN_MIDDLE,
                                   "y-align", MX_ALIGN_START, NULL);
      break;

    case MX_POSITION_RIGHT:
      mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->hbox),
                                     MX_ORIENTATION_HORIZONTAL);
      clutter_actor_set_child_above_sibling (priv->hbox, priv->icon, NULL);

      clutter_container_child_set (CLUTTER_CONTAINER (priv->hbox),
                                   priv->label, "x-align", MX_ALIGN_START,
                                   "y-align", MX_ALIGN_MIDDLE, NULL);
      clutter_container_child_set (CLUTTER_CONTAINER (priv->hbox),
                                   priv->icon, "x-align", MX_ALIGN_END,
                                   "y-align", MX_ALIGN_MIDDLE, NULL);
      break;

    case MX_POSITION_BOTTOM:
      mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->hbox),
                                     MX_ORIENTATION_VERTICAL);
      clutter_actor_set_child_above_sibling (priv->hbox, priv->icon, NULL);

      mx_box_layout_child_set_x_align (MX_BOX_LAYOUT (priv->hbox),
                                       priv->label, MX_ALIGN_MIDDLE);
      clutter_container_child_set (CLUTTER_CONTAINER (priv->hbox),
                                   priv->label, "x-align", MX_ALIGN_MIDDLE,
                                   "y-align", MX_ALIGN_START, NULL);
      clutter_container_child_set (CLUTTER_CONTAINER (priv->hbox),
                                   priv->icon, "x-align", MX_ALIGN_MIDDLE,
                                   "y-align", MX_ALIGN_END, NULL);
      break;

    case MX_POSITION_LEFT:
      mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->hbox),
                                     MX_ORIENTATION_HORIZONTAL);
      clutter_actor_set_child_below_sibling (priv->hbox, priv->icon, NULL);

      clutter_container_child_set (CLUTTER_CONTAINER (priv->hbox),
                                   priv->label, "x-align", MX_ALIGN_END,
                                   "y-align", MX_ALIGN_MIDDLE, NULL);
      clutter_container_child_set (CLUTTER_CONTAINER (priv->hbox),
                                   priv->icon, "x-align", MX_ALIGN_START,
                                   "y-align", MX_ALIGN_MIDDLE, NULL);
      break;
    }
}
示例#29
0
static gboolean
key_release_cb (ClutterActor    *actor,
                ClutterKeyEvent *event,
                MxBoxLayout   *box)
{

  if (event->keyval == 'v')
    {
      mx_box_layout_set_orientation (box,
                                     !mx_box_layout_get_orientation (box));
    }

  if (event->keyval == '=')
    {
      add_actor ((ClutterContainer*) box);
    }

  if (event->keyval == '-')
    {
      ClutterActor *child = NULL;

      clutter_container_foreach (CLUTTER_CONTAINER (box), (ClutterCallback) find_last_child, &child);

      if (child)
        clutter_container_remove_actor (CLUTTER_CONTAINER (box), child);
    }

  if (event->keyval == 'c')
    {
      gboolean clip;

      g_object_get (actor, "clip-to-allocation", &clip, NULL);
      g_object_set (actor, "clip-to-allocation", !clip, NULL);
    }

  if (event->keyval == 's')
    {
      guint spacing;

      spacing = mx_box_layout_get_spacing (box);

      if (spacing > 6)
        spacing = 0;
      else
        spacing++;

      mx_box_layout_set_spacing (box, spacing);
    }

  if (event->keyval == 'e')
    {
      if (hover_actor)
        {
          gboolean expand;
          clutter_container_child_get ((ClutterContainer*) box, hover_actor,
                                       "expand", &expand, NULL);
          clutter_container_child_set ((ClutterContainer*) box, hover_actor,
                                       "expand", !expand, NULL);
        }
    }

  if (event->keyval == 'a')
    {
      mx_box_layout_set_enable_animations (box,
                                           !mx_box_layout_get_enable_animations (box));
    }

  return FALSE;
}
示例#30
0
static void
mtp_bin_constructed (GObject *self)
{
  MtpBinPrivate *priv = MTP_BIN (self)->priv;
  MtpToolbar    *toolbar = (MtpToolbar*) mtp_toolbar_new ();
  ClutterActor  *box = (ClutterActor *)self;
  ClutterActor  *jar = mtp_jar_new ();
  GConfClient   *client;

  priv->toolbar = (ClutterActor*)toolbar;
  priv->jar     = jar;

  clutter_actor_set_name (jar, "jar");
  clutter_actor_set_height ((ClutterActor*)toolbar, TOOLBAR_HEIGHT);

  mx_box_layout_set_orientation (MX_BOX_LAYOUT (box), MX_ORIENTATION_VERTICAL);
  mx_box_layout_set_spacing (MX_BOX_LAYOUT (box), 10);

  clutter_container_add (CLUTTER_CONTAINER (box), (ClutterActor*)toolbar, NULL);

  {
    ClutterActor *dummy = mx_label_new ();
    ClutterActor *hbox = mx_box_layout_new ();
    ClutterActor *button = mx_button_new_with_label (_("Save toolbar"));

    clutter_actor_set_name (hbox, "message-box");
    clutter_actor_set_name (button, "save-button");

    priv->err_msg = _("Sorry, you'll have to remove a panel before you can "
                      "add a new one.");
    priv->normal_msg = _("You can add, remove, and reorder many of the panels "
                         "in your toolbar.");

    priv->message = mx_label_new_with_text (priv->normal_msg);

    clutter_actor_set_name (priv->message, "error-message");

    clutter_container_add (CLUTTER_CONTAINER (box), hbox, NULL);
    clutter_container_add (CLUTTER_CONTAINER (hbox), priv->message,
                           dummy, button, NULL);
    clutter_container_child_set (CLUTTER_CONTAINER (hbox), dummy,
                                 "expand", TRUE, NULL);
    clutter_container_child_set (CLUTTER_CONTAINER (hbox), button,
                                 "x-align", MX_ALIGN_END,
                                 "y-align", MX_ALIGN_MIDDLE, NULL);
    clutter_container_child_set (CLUTTER_CONTAINER (hbox), priv->message,
                                 "y-align", MX_ALIGN_MIDDLE, NULL);

    g_signal_connect (button, "clicked",
                      G_CALLBACK (mtp_bin_save_button_clicked_cb),
                      self);

    g_signal_connect (toolbar, "notify::free-space",
                      G_CALLBACK (mtp_bin_toolbar_free_space_cb),
                      self);
  }

  clutter_container_add (CLUTTER_CONTAINER (box), jar, NULL);

  clutter_container_child_set (CLUTTER_CONTAINER (box), jar,
                               "expand", TRUE, NULL);

  client = priv->client = gconf_client_get_default ();
  gconf_client_add_dir (client, KEY_DIR, GCONF_CLIENT_PRELOAD_RECURSIVE, NULL);
}