Пример #1
0
static void watchfile_menu_init(void)
{
  static _Bool ready = 0;
  if (!ready) {
    ready = 1;
    struct menu *menu = &watchfile_menu;
    menu_init(menu, MENU_NOVALUE, MENU_NOVALUE, MENU_NOVALUE);
    watchfile_return = menu_add_submenu(menu, 0, 0, NULL, "return");
    watchfile_return->leave_proc = watchfile_leave_proc;
    struct gfx_texture *t_arrow = resource_get(RES_ICON_ARROW);
    menu_add_button_icon(menu, 0, 1,
                         t_arrow, 0, 0xFFFFFF,
                         scroll_up_proc, NULL);
    menu_add_button_icon(menu, 0, 1 + WATCHFILE_VIEW_ROWS - 1,
                         t_arrow, 1, 0xFFFFFF,
                         scroll_down_proc, NULL);
    for (int i = 0; i < WATCHFILE_VIEW_ROWS; ++i) {
      struct menu_item *item = menu_item_add(menu, 2, 1 + i, NULL, 0xFFFFFF);
      item->data = (void*)i;
      item->enter_proc = entry_enter_proc;
      item->draw_proc = entry_draw_proc;
      item->activate_proc = entry_activate_proc;
      watchfile_items[i] = item;
    }
  }
}
Пример #2
0
GtkWidget *menu_item_add_sensitive(GtkWidget *menu, const gchar *label, gboolean sensitive,
				   GCallback func, gpointer data)
{
	GtkWidget *item;

	item = menu_item_add(menu, label, func, data);
	gtk_widget_set_sensitive(item, sensitive);

	return item;
}
Пример #3
0
static int add_member(struct item_data *data,
                      uint32_t address, enum watch_type type, int position,
                      _Bool anchored, int x, int y, _Bool position_set)
{
  if (data->members.size >= SETTINGS_WATCHES_MAX ||
      position < 0 || position > data->members.size)
    return 0;
  ++data->add_button->y;
#ifndef WIIVC
  ++data->import_button->y;
#endif
  for (int i = position; i < data->members.size; ++i) {
    struct member_data *member_data = get_member(data, i);
    ++member_data->index;
    ++member_data->member->y;
  }
  struct menu *imenu;
  struct member_data *member_data = malloc(sizeof(*member_data));
  member_data->data = data;
  member_data->index = position;
  member_data->member = menu_add_imenu(data->imenu, 0, position, &imenu);
  member_data->anchor_button = menu_item_add(imenu, 2, 0, NULL, 0xFFFFFF);
  member_data->anchor_button->enter_proc = anchor_button_enter_proc;
  member_data->anchor_button->draw_proc = anchor_button_draw_proc;
  member_data->anchor_button->activate_proc = anchor_button_activate_proc;
  member_data->anchor_button->data = member_data;
  member_data->positioning = menu_add_positioning(imenu, 4, 0,
                                                  position_proc, member_data);
  member_data->userwatch = menu_add_userwatch(imenu, 6, 0, address, type);
  member_data->anchored = 1;
  member_data->anchor_anim_state = 0;
  member_data->x = x;
  member_data->y = y;
  member_data->position_set = 1;
  menu_add_button_icon(imenu, 0, 0, list_icons, 1, 0xFF0000,
                       remove_button_proc, member_data);
  if (anchored)
    menu_item_disable(member_data->positioning);
  else
    release_member(member_data);
  member_data->position_set = position_set;
  vector_insert(&data->members, position, 1, &member_data);
  return 1;
}
Пример #4
0
void explorer_create(struct menu *menu)
{
  menu_init(menu, MENU_NOVALUE, MENU_NOVALUE, MENU_NOVALUE);
  struct menu_item *item = menu_item_add(menu, 0, 0, NULL, 0);
  menu->selector = item;
  struct item_data *data = malloc(sizeof(*data));
  zu_gfx_init(&data->gfx);
  data->state = STATE_LOAD;
  data->scene_index = -1;
  data->scene_file = NULL;
  data->room_index = -1;
  data->room_file = NULL;
  data->scale = .5f;
  item->data = data;
  item->enter_proc = enter_proc;
  item->leave_proc = leave_proc;
  item->think_proc = think_proc;
  item->draw_proc = draw_proc;
  item->activate_proc = activate_proc;
}
Пример #5
0
static char *menu_handle(struct menu_display *display)
{
	struct menu *m;
	int i;
	void *choice = NULL;
	char key[2];
	int ret;
	char *s;
	char temp[6][200];

	m = menu_create(display->title, display->timeout, 1, ait_menu_print,
			NULL, NULL);

	for (i = 0; display->menulist[i]; i++) {
		sprintf(key, "%d", i + 1);
		if (display->id == MENU_NETWORK) {
			switch (i) {
			case 0:
				s = getenv("ipaddr");
				break;
			case 1:
				s = getenv("netmask");
				break;
			case 2:
				s = getenv("serverip");
				break;
			case 3:
				s = getenv("gatewayip");
				break;
			case 4:
				s = getenv("img_file");
				break;
			default:
				s = NULL;
				break;
			}
			if (s) {
				sprintf(temp[i], "%s: %s",
					display->menulist[i], s);
				ret = menu_item_add(m, key, temp[i]);
			} else {
				ret = menu_item_add(m, key,
					display->menulist[i]);
			}
		} else {
			ret = menu_item_add(m, key, display->menulist[i]);
		}

		if (ret != 1) {
			printf("failed to add item!");
			menu_destroy(m);
			return NULL;
		}
	}
	sprintf(key, "%d", 1);
	menu_default_set(m, key);

	if (menu_get_choice(m, &choice) != 1)
		debug("Problem picking a choice!\n");

	menu_destroy(m);

	return choice;
}
Пример #6
0
/* Fill main menu with boot items */
int fill_menu(struct params_t *params)
{
	kx_menu_item *mi;
	int i, b_items, max_pri, max_i, *a;
	struct boot_item_t *tbi;
	struct bootconf_t *bl;
	const int sizeof_desc = 160;
	char *desc, *label;
#ifdef USE_ICONS
	kx_picture *icon;
	struct gui_t *gui;

	gui = params->gui;
#endif

	bl = params->bootcfg;

	if ( (NULL != bl) && (bl->fill > 0) ) b_items = bl->fill;
	else {
		log_msg(lg, "No items for menu found");
		return 0;
	}

	log_msg(lg, "Populating menu: %d item(s)", b_items);

	desc = malloc(sizeof_desc);
	if (NULL == desc) {
		DPRINTF("Can't allocate item description");
		goto dirty_exit;
	}

	a = malloc(b_items * sizeof(*a));	/* Markers array */
	if (NULL == a) {
		DPRINTF("Can't allocate markers array");
		goto dirty_exit;
	}

	for (i = 0; i < b_items; i++) a[i] = 0;	/* Clean markers array */

	/* Create menu of sorted by priority boot items */
	max_i = -1;
	for(;;) {
		max_pri = -1;
		/* Search item with maximum priority */
		for (i = 0; i < b_items; i++) {
			if (0 == a[i]) {	/* Check that item is not processed yet */
				tbi = bl->list[i];
				if (tbi->priority > max_pri) {
					max_pri = tbi->priority;	/* Max priority */
					max_i = i;					/* Max priority item index */
				}
			}
		}

		if (max_pri >= 0) {
			a[max_i] = 1;	/* Mark item as processed */
			/* We have found new max priority - insert into menu */
			tbi = bl->list[max_i];
			snprintf(desc, sizeof_desc, "%s %s %lluMb",
					tbi->device, tbi->fstype, tbi->blocks/1024);

			if (tbi->label)
				label = tbi->label;
			else
				label = tbi->kernelpath + sizeof(MOUNTPOINT) - 1;

			log_msg(lg, "+ [%s]", label);
			mi = menu_item_add(params->menu->top, A_DEVICES + max_i,
					label, desc, NULL);

#ifdef USE_ICONS
			if (gui) {
				/* Search associated with boot item icon if any */
				icon = tbi->icondata;
				if (!icon && (gui->icons)) {
					/* We have no custom icon - use default */
					switch (tbi->dtype) {
					case DVT_STORAGE:
						icon = gui->icons[ICON_STORAGE];
						break;
					case DVT_MMC:
						icon = gui->icons[ICON_MMC];
						break;
					case DVT_MTD:
						icon = gui->icons[ICON_MEMORY];
						break;
					case DVT_UNKNOWN:
					default:
						break;
					}
				}

				/* Add icon to menu */
				if (mi) mi->data = icon;
			}
#endif
		}

		if (-1 == max_pri) break;	/* We have no items to process */
	}

	free(a);
	free(desc);
	return 0;

dirty_exit:
	dispose(desc);
	return -1;
}
Пример #7
0
/* Create system menu */
kx_menu *build_menu(struct params_t *params)
{
	kx_menu *menu;
	kx_menu_level *ml;
	kx_menu_item *mi;
	
#ifdef USE_ICONS
	kx_picture **icons;
	
	if (params->gui) icons = params->gui->icons;
	else icons = NULL;
#endif
	
	/* Create menu with 2 levels (main and system) */
	menu = menu_create(2);
	if (!menu) {
		DPRINTF("Can't create menu");
		return NULL;
	}
	
	/* Create main menu level */
	menu->top = menu_level_create(menu, 4, NULL);
	
	/* Create system menu level */
	ml = menu_level_create(menu, 6, menu->top);
	if (!ml) {
		DPRINTF("Can't create system menu");
		return menu;
	}

	mi = menu_item_add(menu->top, A_SUBMENU, "System menu", NULL, ml);
#ifdef USE_ICONS
	if (icons) menu_item_set_data(mi, icons[ICON_SYSTEM]);
#endif

	mi = menu_item_add(ml, A_PARENTMENU, "Back", NULL, NULL);
#ifdef USE_ICONS
	if (icons) menu_item_set_data(mi, icons[ICON_BACK]);
#endif

	mi = menu_item_add(ml, A_RESCAN, "Rescan", NULL, NULL);
#ifdef USE_ICONS
	if (icons) menu_item_set_data(mi, icons[ICON_RESCAN]);
#endif

	mi = menu_item_add(ml, A_DEBUG, "Show debug info", NULL, NULL);
#ifdef USE_ICONS
	if (icons) menu_item_set_data(mi, icons[ICON_DEBUG]);
#endif

	mi = menu_item_add(ml, A_REBOOT, "Reboot", NULL, NULL);
#ifdef USE_ICONS
	if (icons) menu_item_set_data(mi, icons[ICON_REBOOT]);
#endif

	mi = menu_item_add(ml, A_SHUTDOWN, "Shutdown", NULL, NULL);
#ifdef USE_ICONS
	if (icons) menu_item_set_data(mi, icons[ICON_SHUTDOWN]);
#endif

	if (!initmode) {
		mi = menu_item_add(ml, A_EXIT, "Exit", NULL, NULL);
#ifdef USE_ICONS
		if (icons) menu_item_set_data(mi, icons[ICON_EXIT]);
#endif
	}

	menu->current = menu->top;
	menu_item_select(menu, 0);
	return menu;
}
Пример #8
0
static void bar_pane_keywords_menu_popup(GtkWidget *widget, PaneKeywordsData *pkd, gint x, gint y)
{
	GtkWidget *menu;
	GtkWidget *item;
	GtkWidget *submenu;
        GtkTreeViewDropPosition pos;

        if (pkd->click_tpath) gtk_tree_path_free(pkd->click_tpath);
        pkd->click_tpath = NULL;
	gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(pkd->keyword_treeview), x, y, &pkd->click_tpath, &pos);

	menu = popup_menu_short_lived();

	menu_item_add_stock(menu, _("Add keyword"), GTK_STOCK_EDIT, G_CALLBACK(bar_pane_keywords_add_dialog_cb), pkd);

	menu_item_add_divider(menu);

	menu_item_add(menu, _("Add keyword to all selected images"), G_CALLBACK(bar_pane_keywords_add_to_selected_cb), pkd);

	menu_item_add_divider(menu);

	if (pkd->click_tpath)
		{
		/* for the entry */
		gchar *text;
		gchar *mark;
		gint i;

		GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));

		GtkTreeIter iter;
                gtk_tree_model_get_iter(model, &iter, pkd->click_tpath);
		gchar *name;

		gtk_tree_model_get(model, &iter, FILTER_KEYWORD_COLUMN_NAME, &name,
						 FILTER_KEYWORD_COLUMN_MARK, &mark, -1);

		text = g_strdup_printf(_("Hide \"%s\""), name);
		menu_item_add_stock(menu, text, GTK_STOCK_EDIT, G_CALLBACK(bar_pane_keywords_hide_cb), pkd);
		g_free(text);

		submenu = gtk_menu_new();
		for (i = 0; i < FILEDATA_MARKS_SIZE; i++)
			{
			text = g_strdup_printf(_("Mark %d"), i + 1);
			item = menu_item_add(submenu, text, G_CALLBACK(bar_pane_keywords_connect_mark_cb), pkd);
			g_object_set_data(G_OBJECT(item), "mark", GINT_TO_POINTER(i + 1));
			g_free(text);
			}
		text = g_strdup_printf(_("Connect \"%s\" to mark"), name);
		item = menu_item_add(menu, text, NULL, NULL);
		gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
		g_free(text);

		menu_item_add_divider(menu);

		text = g_strdup_printf(_("Edit \"%s\""), name);
		menu_item_add_stock(menu, text, GTK_STOCK_EDIT, G_CALLBACK(bar_pane_keywords_edit_dialog_cb), pkd);
		g_free(text);
		text = g_strdup_printf(_("Remove \"%s\""), name);
		menu_item_add_stock(menu, text, GTK_STOCK_DELETE, G_CALLBACK(bar_pane_keywords_delete_cb), pkd);
		g_free(text);


		if (mark && mark[0])
			{
			text = g_strdup_printf(_("Disconnect \"%s\" from mark %s"), name, mark);
			menu_item_add_stock(menu, text, GTK_STOCK_DELETE, G_CALLBACK(bar_pane_keywords_connect_mark_cb), pkd);
			g_free(text);
			}

		menu_item_add_divider(menu);
		g_free(mark);
		g_free(name);
		}
	/* for the pane */


	menu_item_add(menu, _("Expand checked"), G_CALLBACK(bar_pane_keywords_expand_checked_cb), pkd);
	menu_item_add(menu, _("Collapse unchecked"), G_CALLBACK(bar_pane_keywords_collapse_unchecked_cb), pkd);
	menu_item_add(menu, _("Hide unchecked"), G_CALLBACK(bar_pane_keywords_hide_unchecked_cb), pkd);
	menu_item_add(menu, _("Show all"), G_CALLBACK(bar_pane_keywords_show_all_cb), pkd);

	submenu = gtk_menu_new();
	item = menu_item_add(menu, _("On any change"), NULL, NULL);
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);

	menu_item_add_check(submenu, _("Expand checked"), pkd->expand_checked, G_CALLBACK(bar_pane_keywords_expand_checked_toggle_cb), pkd);
	menu_item_add_check(submenu, _("Collapse unchecked"), pkd->collapse_unchecked, G_CALLBACK(bar_pane_keywords_collapse_unchecked_toggle_cb), pkd);
	menu_item_add_check(submenu, _("Hide unchecked"), pkd->hide_unchecked, G_CALLBACK(bar_pane_keywords_hide_unchecked_toggle_cb), pkd);

	gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, GDK_CURRENT_TIME);
}
Пример #9
0
GtkWidget *vf_pop_menu(ViewFile *vf)
{
	GtkWidget *menu;
	GtkWidget *item;
	GtkWidget *submenu;
	gboolean active = FALSE;

	switch (vf->type)
	{
	case FILEVIEW_LIST:
		vflist_color_set(vf, VFLIST(vf)->click_fd, TRUE);
		active = (VFLIST(vf)->click_fd != NULL);
		break;
	case FILEVIEW_ICON:
		active = (VFICON(vf)->click_id != NULL);
		break;
	}

	menu = popup_menu_short_lived();

	g_signal_connect(G_OBJECT(menu), "destroy",
			 G_CALLBACK(vf_popup_destroy_cb), vf);

	if (vf->clicked_mark > 0)
		{
		gint mark = vf->clicked_mark;
		gchar *str_set_mark = g_strdup_printf(_("_Set mark %d"), mark);
		gchar *str_res_mark = g_strdup_printf(_("_Reset mark %d"), mark);
		gchar *str_toggle_mark = g_strdup_printf(_("_Toggle mark %d"), mark);
		gchar *str_sel_mark = g_strdup_printf(_("_Select mark %d"), mark);
		gchar *str_sel_mark_or = g_strdup_printf(_("_Add mark %d"), mark);
		gchar *str_sel_mark_and = g_strdup_printf(_("_Intersection with mark %d"), mark);
		gchar *str_sel_mark_minus = g_strdup_printf(_("_Unselect mark %d"), mark);

		g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);

		vf->active_mark = mark;
		vf->clicked_mark = 0;

		menu_item_add_sensitive(menu, str_set_mark, active,
					G_CALLBACK(vf_pop_menu_set_mark_sel_cb), vf);

		menu_item_add_sensitive(menu, str_res_mark, active,
					G_CALLBACK(vf_pop_menu_res_mark_sel_cb), vf);

		menu_item_add_sensitive(menu, str_toggle_mark, active,
					G_CALLBACK(vf_pop_menu_toggle_mark_sel_cb), vf);

		menu_item_add_divider(menu);

		menu_item_add_sensitive(menu, str_sel_mark, active,
					G_CALLBACK(vf_pop_menu_sel_mark_cb), vf);
		menu_item_add_sensitive(menu, str_sel_mark_or, active,
					G_CALLBACK(vf_pop_menu_sel_mark_or_cb), vf);
		menu_item_add_sensitive(menu, str_sel_mark_and, active,
					G_CALLBACK(vf_pop_menu_sel_mark_and_cb), vf);
		menu_item_add_sensitive(menu, str_sel_mark_minus, active,
					G_CALLBACK(vf_pop_menu_sel_mark_minus_cb), vf);

		menu_item_add_divider(menu);

		g_free(str_set_mark);
		g_free(str_res_mark);
		g_free(str_toggle_mark);
		g_free(str_sel_mark);
		g_free(str_sel_mark_and);
		g_free(str_sel_mark_or);
		g_free(str_sel_mark_minus);
		}

	vf->editmenu_fd_list = vf_pop_menu_file_list(vf);
	submenu_add_edit(menu, &item, G_CALLBACK(vf_pop_menu_edit_cb), vf, vf->editmenu_fd_list);
	gtk_widget_set_sensitive(item, active);

	menu_item_add_stock_sensitive(menu, _("View in _new window"), GTK_STOCK_NEW, active,
				      G_CALLBACK(vf_pop_menu_view_cb), vf);

	menu_item_add_divider(menu);
	menu_item_add_stock_sensitive(menu, _("_Copy..."), GTK_STOCK_COPY, active,
				      G_CALLBACK(vf_pop_menu_copy_cb), vf);
	menu_item_add_sensitive(menu, _("_Move..."), active,
				G_CALLBACK(vf_pop_menu_move_cb), vf);
	menu_item_add_sensitive(menu, _("_Rename..."), active,
				G_CALLBACK(vf_pop_menu_rename_cb), vf);
	menu_item_add_stock_sensitive(menu, _("_Delete..."), GTK_STOCK_DELETE, active,
				      G_CALLBACK(vf_pop_menu_delete_cb), vf);
	menu_item_add_sensitive(menu, _("_Copy path"), active,
				G_CALLBACK(vf_pop_menu_copy_path_cb), vf);

	menu_item_add_sensitive(menu, _("Enable file _grouping"), active,
				G_CALLBACK(vf_pop_menu_enable_grouping_cb), vf);
	menu_item_add_sensitive(menu, _("Disable file groupi_ng"), active,
				G_CALLBACK(vf_pop_menu_disable_grouping_cb), vf);

	menu_item_add_divider(menu);

	submenu = submenu_add_sort(NULL, G_CALLBACK(vf_pop_menu_sort_cb), vf,
				   FALSE, FALSE, TRUE, vf->sort_method);
	menu_item_add_divider(submenu);
	menu_item_add_check(submenu, _("Ascending"), vf->sort_ascend,
			    G_CALLBACK(vf_pop_menu_sort_ascend_cb), vf);

	item = menu_item_add(menu, _("_Sort"), NULL, NULL);
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);

	item = menu_item_add_radio(menu, _("View as _List"), GINT_TO_POINTER(FILEVIEW_LIST), vf->type == FILEVIEW_LIST,
                                           G_CALLBACK(vf_pop_menu_toggle_view_type_cb), vf);

	item = menu_item_add_radio(menu, _("View as _Icons"), GINT_TO_POINTER(FILEVIEW_ICON), vf->type == FILEVIEW_ICON,
                                           G_CALLBACK(vf_pop_menu_toggle_view_type_cb), vf);

	switch (vf->type)
	{
	case FILEVIEW_LIST:
		menu_item_add_check(menu, _("Show _thumbnails"), VFLIST(vf)->thumbs_enabled,
				    G_CALLBACK(vflist_pop_menu_thumbs_cb), vf);
		break;
	case FILEVIEW_ICON:
		menu_item_add_check(menu, _("Show filename _text"), VFICON(vf)->show_text,
				    G_CALLBACK(vficon_pop_menu_show_names_cb), vf);
		break;
	}
	
	menu_item_add_stock(menu, _("Re_fresh"), GTK_STOCK_REFRESH, G_CALLBACK(vf_pop_menu_refresh_cb), vf);

	return menu;
}
Пример #10
0
static GtkWidget *view_popup_menu(ViewWindow *vw)
{
	GtkWidget *menu;
	GtkWidget *item;
	GList *editmenu_fd_list;

	menu = popup_menu_short_lived();


	menu_item_add_stock(menu, _("Zoom _in"), GTK_STOCK_ZOOM_IN, G_CALLBACK(view_zoom_in_cb), vw);
	menu_item_add_stock(menu, _("Zoom _out"), GTK_STOCK_ZOOM_OUT, G_CALLBACK(view_zoom_out_cb), vw);
	menu_item_add_stock(menu, _("Zoom _1:1"), GTK_STOCK_ZOOM_100, G_CALLBACK(view_zoom_1_1_cb), vw);
	menu_item_add_stock(menu, _("Fit image to _window"), GTK_STOCK_ZOOM_FIT, G_CALLBACK(view_zoom_fit_cb), vw);
	menu_item_add_divider(menu);

 	editmenu_fd_list = view_window_get_fd_list(vw);
	g_signal_connect(G_OBJECT(menu), "destroy",
			 G_CALLBACK(view_popup_menu_destroy_cb), editmenu_fd_list);
	item = submenu_add_edit(menu, NULL, G_CALLBACK(view_edit_cb), vw, editmenu_fd_list);
	menu_item_add_divider(item);
	menu_item_add(item, _("Set as _wallpaper"), G_CALLBACK(view_wallpaper_cb), vw);

	submenu_add_alter(menu, G_CALLBACK(view_alter_cb), vw);

	menu_item_add_stock(menu, _("View in _new window"), GTK_STOCK_NEW, G_CALLBACK(view_new_window_cb), vw);
	item = menu_item_add(menu, _("_Go to directory view"), G_CALLBACK(view_set_layout_path_cb), vw);

	menu_item_add_divider(menu);
	menu_item_add_stock(menu, _("_Copy..."), GTK_STOCK_COPY, G_CALLBACK(view_copy_cb), vw);
	menu_item_add(menu, _("_Move..."), G_CALLBACK(view_move_cb), vw);
	menu_item_add(menu, _("_Rename..."), G_CALLBACK(view_rename_cb), vw);
	menu_item_add_stock(menu, _("_Delete..."), GTK_STOCK_DELETE, G_CALLBACK(view_delete_cb), vw);
	menu_item_add(menu, _("_Copy path"), G_CALLBACK(view_copy_path_cb), vw);

	menu_item_add_divider(menu);

	if (vw->ss)
		{
		menu_item_add(menu, _("_Stop slideshow"), G_CALLBACK(view_slideshow_stop_cb), vw);
		if (slideshow_paused(vw->ss))
			{
			item = menu_item_add(menu, _("Continue slides_how"),
					     G_CALLBACK(view_slideshow_pause_cb), vw);
			}
		else
			{
			item = menu_item_add(menu, _("Pause slides_how"),
					     G_CALLBACK(view_slideshow_pause_cb), vw);
			}
		}
	else
		{
		item = menu_item_add(menu, _("_Start slideshow"), G_CALLBACK(view_slideshow_start_cb), vw);
		gtk_widget_set_sensitive(item, (vw->list != NULL) || view_window_contains_collection(vw));
		item = menu_item_add(menu, _("Pause slides_how"), G_CALLBACK(view_slideshow_pause_cb), vw);
		gtk_widget_set_sensitive(item, FALSE);
		}

	if (vw->fs)
		{
		menu_item_add(menu, _("Exit _full screen"), G_CALLBACK(view_fullscreen_cb), vw);
		}
	else
		{
		menu_item_add(menu, _("_Full screen"), G_CALLBACK(view_fullscreen_cb), vw);
		}

	menu_item_add_divider(menu);
	menu_item_add_stock(menu, _("C_lose window"), GTK_STOCK_CLOSE, G_CALLBACK(view_close_cb), vw);

	return menu;
}
Пример #11
0
struct menu_item *menu_add_floatinput(struct menu *menu, int x, int y,
                                      int sig_precis, int exp_precis,
                                      menu_generic_callback callback_proc,
                                      void *callback_data)
{
  struct item_data *data = malloc(sizeof(*data));
  data->sig_precis = sig_precis;
  data->exp_precis = exp_precis;
  data->callback_proc = callback_proc;
  data->callback_data = callback_data;
  data->value = 0.;
  data->active = 0;
  data->sig_digits = malloc(sizeof(*data->sig_digits) * sig_precis);
  data->exp_digits = malloc(sizeof(*data->exp_digits) * exp_precis);
  data->imenu = malloc(sizeof(*data->imenu));
  menu_init(data->imenu, MENU_NOVALUE, MENU_NOVALUE, MENU_NOVALUE);
  data->imenu->parent = menu;
  struct menu_item *item = menu_item_add(menu, x, y, NULL, 0xFFFFFF);
  data->item = item;
  item->text = malloc(sig_precis + exp_precis + 5);
  item->text[1] = '.';
  item->text[1 + sig_precis] = 'e';
  item->text[sig_precis + exp_precis + 2] = 0;
  item->data = data;
  item->think_proc = think_proc;
  item->draw_proc = draw_proc;
  item->navigate_proc = navigate_proc;
  item->activate_proc = activate_proc;
  item->destroy_proc = destroy_proc;
  uint32_t color = data->imenu->highlight_color_static;
  menu_item_add(data->imenu, 2, 0, ".", color)->selectable = 0;
  menu_item_add(data->imenu, 2 + sig_precis, 0, "e", color)->selectable = 0;
  for (int i = 0; i < 2; ++i) {
    int x = i * (3 + sig_precis);
    struct menu_item *sign = menu_item_add(data->imenu, x, 0, NULL, color);
    sign->text = malloc(2);
    sign->text[0] = '+';
    sign->text[1] = 0;
    sign->navigate_proc = sign_navigate_proc;
    sign->animate_highlight = 1;
    sign->data = data;
    if (i == 0)
      data->sig_sign = sign;
    else
      data->exp_sign = sign;
  }
  for (int i = 0; i < sig_precis + exp_precis; ++i) {
    int x = 1 + i;
    int tx = i;
    if (i >= sig_precis) {
      x += 3;
      tx += 2;
    }
    else if (i > 0) {
      ++x;
      ++tx;
    }
    struct menu_item *digit = menu_item_add(data->imenu, x, 0, NULL, color);
    digit->text = malloc(2);
    digit->text[0] = '0';
    item->text[tx] = '0';
    digit->text[1] = 0;
    digit->navigate_proc = digit_navigate_proc;
    digit->animate_highlight = 1;
    digit->data = data;
    if (i < sig_precis)
      data->sig_digits[i] = digit;
    else
      data->exp_digits[i - sig_precis] = digit;
  }
  data->imenu->selector = data->sig_digits[0];
  return item;
}