Exemplo n.º 1
0
/* Callback for the bar operations */
static gboolean
item_event_help (GooCanvasItem  *item,
		 GooCanvasItem  *target,
		 GdkEventButton *event,
		 gchar *data)
{

  gc_sound_play_ogg ("sounds/bleep.wav", NULL);
  if(!strcmp((char *)data, "ok"))
    {
      gc_help_stop();
    }
  else if(!strcmp((char *)data, "prerequisite"))
    {
      select_item(item_prerequisite, item_prerequisite_text);
      set_content(prerequisite);
    }
  else if(!strcmp((char *)data, "goal"))
    {
      select_item(item_goal, item_goal_text);
      set_content(goal);
    }
  else if(!strcmp((char *)data, "manual"))
    {
      select_item(item_manual, item_manual_text);
      set_content(manual);
    }
  else if(!strcmp((char *)data, "credit"))
    {
      select_item(item_credit, item_credit_text);
      set_content(credit);
    }

  return TRUE;
}
Exemplo n.º 2
0
void
mkdir_cmd (void)
{
    char *tempdir;
    char *dir;

    dir =
	input_expand_dialog (_("Create a new Directory"),
			     _(" Enter directory name:"), "");

    if (!dir || !*dir)
	return;

    if (dir[0] == '/' || dir[0] == '~')
	tempdir = g_strdup (dir);
    else
	tempdir = concat_dir_and_file (current_panel->cwd, dir);
    g_free (dir);

    save_cwds_stat ();
    if (my_mkdir (tempdir, 0777) == 0) {
	update_panels (UP_OPTIMIZE, tempdir);
	repaint_screen ();
	select_item (current_panel);
	g_free (tempdir);
	return;
    }
    g_free (tempdir);
    message (1, MSG_ERROR, "  %s  ", unix_error_string (errno));
}
static void
wp_add_images (AppearanceData *data,
               GSList *images)
{
  GdkWindow *window;
  GtkWidget *w;
  GdkCursor *cursor;
  MateWPItem *item;

  w = appearance_capplet_get_widget (data, "appearance_window");
  window = gtk_widget_get_window (w);

  item = NULL;
  cursor = gdk_cursor_new_for_display (gdk_display_get_default (),
                                       GDK_WATCH);
  gdk_window_set_cursor (window, cursor);
  gdk_cursor_unref (cursor);

  while (images != NULL)
  {
    gchar *uri = images->data;

    item = wp_add_image (data, uri);
    images = g_slist_remove (images, uri);
    g_free (uri);
  }

  gdk_window_set_cursor (window, NULL);

  if (item != NULL)
  {
    select_item (data, item, TRUE);
  }
}
Exemplo n.º 4
0
void ElementsCtrlBase::OnKeyDown( wxListEvent& ev )
{
  int kc = tolower(ev.GetKeyCode());
  wxLogDebug(wxT("ElementsCtrlBase::OnKeyDown - %d"), kc);
  if( kc >= 'a' && kc <= 'z' )
  {
    const long startidx = (m_selidx.size() == 0 ? 0 : m_selidx.front());
    long idx = startidx;
    wxListItem info;
    for( ;; )
    {
      idx = m_list->GetNextItem(idx, wxLIST_NEXT_BELOW, wxLIST_STATE_DONTCARE);
      if( idx == -1 ) idx = 0;
      if( idx == startidx )
        break;
      info.m_mask = wxLIST_MASK_TEXT;
      info.m_col = 1;
      info.m_itemId = idx;
      // skip over collection titles and those that don't start with the pressed key
      if( m_list->GetItem(info) && m_list->GetItemData(idx) != 0 && info.m_text.Lower().StartsWith(wxString::Format(wxT("%c"), kc)) )
      {
        deselect_all();
        select_item(idx);
        break;
      }
    }
  }
}
Exemplo n.º 5
0
void ElementsCtrlBase::select_next()
{
  const long startidx = (m_selidx.size() == 0 ? 0 : m_selidx.front());
  long idx = startidx;
  wxListItem info;
  for( ;; )
  {
    idx = m_list->GetNextItem(idx, wxLIST_NEXT_BELOW, wxLIST_STATE_DONTCARE);
    if( idx == -1 ) idx = 0;
    if( idx == startidx )
      break; // only one element to choose from? shouldn't happen normally
    info.m_mask = wxLIST_MASK_TEXT;
    info.m_col = 1;
    info.m_itemId = idx;
    if( m_list->GetItem(info) )
    {
      // skip over collection titles
      if( m_list->GetItemData(idx) != 0 )
      {
        deselect_all();
        select_item(idx);
        break;
      }
    }
  }
}
Exemplo n.º 6
0
void menu_file_selector::handle()
{
	// process the menu
	event const *const event = process(0);
	if (event && event->itemref)
	{
		// handle selections
		if (event->iptkey == IPT_UI_SELECT)
		{
			select_item(*reinterpret_cast<file_selector_entry const *>(event->itemref));

			// reset the char buffer when pressing IPT_UI_SELECT
			m_filename.clear();
		}
		else if (event->iptkey == IPT_SPECIAL)
		{
			// if it's any other key and we're not maxed out, update
			type_search_char(event->unichar);
		}
		else if (event->iptkey == IPT_UI_CANCEL)
		{
			// reset the char buffer also in this case
			m_filename.clear();
		}
	}
}
Exemplo n.º 7
0
static void
tree_chdir_sel (WTree * tree)
{
    if (tree->is_panel)
    {
        change_panel ();

        if (do_cd (tree->selected_ptr->name, cd_exact))
            select_item (current_panel);
        else
            message (D_ERROR, MSG_ERROR, _("Cannot chdir to \"%s\"\n%s"),
                     vfs_path_as_str (tree->selected_ptr->name), unix_error_string (errno));

        widget_redraw (WIDGET (current_panel));
        change_panel ();
        show_tree (tree);
    }
    else
    {
        WDialog *h = WIDGET (tree)->owner;

        h->ret_value = B_ENTER;
        dlg_stop (h);
    }
}
Exemplo n.º 8
0
void tvertical_list::handle_key_down_arrow(SDLMod /*modifier*/, bool& handled)
{
	if(get_selected_item_count() == 0) {
		return;
	}

	// NOTE maybe this should only work if we can select only one item...
	handled = true;

	for(size_t i = get_ordered_index(get_selected_item()) + 1; i < get_item_count(); ++i) {

		// why do we do this check here but not in handle_key_up_arrow?
		if(item_ordered(i).get_visible() == twidget::tvisible::invisible
		   || !get_item_shown(get_item_at_ordered(i))) {

			continue;
		}

		// NOTE we check the first widget to be active since grids have no
		// active flag. This method might not be entirely reliable.
		tcontrol* control = dynamic_cast<tcontrol*>(item_ordered(i).widget(0, 0));
		if(control && control->get_active()) {
			select_item(get_item_at_ordered(i), true);
			return;
		}
	}
}
Exemplo n.º 9
0
void thorizontal_list::handle_key_right_arrow(
		SDLMod /*modifier*/, bool& handled)
{
	if(get_selected_item_count() == 0) {
		return;
	}

	// NOTE maybe this should only work if we can select only one item...
	handled = true;

	for(size_t i = get_selected_item() + 1; i < get_item_count(); ++i) {

		if(item(i).get_visible() == twidget::INVISIBLE
				|| !get_item_shown(i)) {

			continue;
		}

		// NOTE we check the first widget to be active since grids have no
		// active flag. This method might not be entirely reliable.
		tcontrol* control = dynamic_cast<tcontrol*>(item(i).widget(0, 0));
		if(control && control->get_active()) {
			select_item(i);
			return;
		}
	}
}
Exemplo n.º 10
0
Arquivo: cmd.c Projeto: ebichu/dd-wrt
void
mkdir_cmd (void)
{
    char *dir, *absdir;

    dir =
	input_expand_dialog (_("Create a new Directory"),
			     _(" Enter directory name:"), 
			     MC_HISTORY_FM_MKDIR, "");
    if (!dir)
	return;

    if (dir[0] == '/' || dir[0] == '~')
	absdir = g_strdup (dir);
    else
	absdir = mhl_str_dir_plus_file (current_panel->cwd, dir);

    save_cwds_stat ();
    if (my_mkdir (absdir, 0777) == 0) {
	update_panels (UP_OPTIMIZE, dir);
	repaint_screen ();
	select_item (current_panel);
    } else {
	message (1, MSG_ERROR, "  %s  ", unix_error_string (errno));
    }

    g_free (absdir);
    g_free (dir);
}
Exemplo n.º 11
0
void Parser::select_list() {
    select_lists.clear();
    while (tokens[look].type != FROM) {
        select_items.clear();
        select_item();
        select_lists[select_items[1]] = select_items[0];
    }
}
Exemplo n.º 12
0
//	Called when the category is changed.
//	- Update the store of items/category.
//	- If in the process of picking up an item go for it if this is the category.
//
static void category_updated(void)
{
	int i;
	for (i=0; i<no_storage; i++)
		update_category_maps(storage_items[i].image_id, storage_items[i].id, storage_categories[selected_category].id);
	if (selected_category == wanted_category)
	{
		select_item(wanted_image_id, wanted_item_id);
		wanted_category = -1;
	}
}
static void
wp_select_after_realize (GtkWidget *widget,
                         AppearanceData *data)
{
  MateWPItem *item;

  g_idle_add (wp_load_stuffs, data);

  item = get_selected_item (data, NULL);
  if (item == NULL)
    item = g_hash_table_lookup (data->wp_hash, "(none)");

  select_item (data, item, TRUE);
}
Exemplo n.º 14
0
void ElementsCtrlBase::OnInsertNotuniq( wxCommandEvent& ev )
{
  int idx = ev.GetId() - ID_INSERT_NOTUNIQ;

  if( m_selels.size() != 1 )
    return;
  const notuniqs_type& notuniqs = wxGetApp().hudfile()->notuniq_elements();
  ElementBase *el = wxGetApp().hudfile()->create_element_from_default( notuniqs[idx] );
  wxGetApp().hudfile()->insert( m_selels.front(), el );
  wxGetApp().mainframe()->update_elementsctrl();

  long itemidx = index_by_pointer(el);
  m_list->EnsureVisible( itemidx );
  select_item( itemidx );
}
Exemplo n.º 15
0
void
mkdir_cmd (void)
{
    char *dir;
    const char *name = "";

    /* If 'on' then automatically fills name with current selected item name */
    if (auto_fill_mkdir_name && !DIR_IS_DOTDOT (selection (current_panel)->fname))
        name = selection (current_panel)->fname;

    dir =
        input_expand_dialog (_("Create a new Directory"),
                             _("Enter directory name:"), MC_HISTORY_FM_MKDIR, name,
                             INPUT_COMPLETE_FILENAMES);

    if (dir != NULL && *dir != '\0')
    {
        vfs_path_t *absdir;

        if (dir[0] == '/' || dir[0] == '~')
            absdir = vfs_path_from_str (dir);
        else
        {
            /* possible escaped '~' */
            /* allow create directory with name '~' */
            char *tmpdir = dir;

            if (dir[0] == '\\' && dir[1] == '~')
                tmpdir = dir + 1;

            absdir = vfs_path_append_new (current_panel->cwd_vpath, tmpdir, NULL);
        }

        save_cwds_stat ();
        if (my_mkdir (absdir, 0777) == 0)
        {
            update_panels (UP_OPTIMIZE, dir);
            repaint_screen ();
            select_item (current_panel);
        }
        else
        {
            message (D_ERROR, MSG_ERROR, "%s", unix_error_string (errno));
        }
        vfs_path_free (absdir);
    }
    g_free (dir);
}
Exemplo n.º 16
0
Arquivo: tree.c Projeto: ebichu/dd-wrt
static void
chdir_sel (WTree *tree)
{
    if (!tree->is_panel) {
	return;
    }
    change_panel ();
    if (do_cd (tree->selected_ptr->name, cd_exact)) {
	select_item (current_panel);
    } else {
	message (1, MSG_ERROR, _(" Cannot chdir to \"%s\" \n %s "),
		 tree->selected_ptr->name, unix_error_string (errno));
    }
    change_panel ();
    show_tree (tree);
    return;
}
static void
wp_uri_changed (const gchar *uri,
                AppearanceData *data)
{
  MateWPItem *item, *selected;

  item = g_hash_table_lookup (data->wp_hash, uri);
  selected = get_selected_item (data, NULL);

  if (selected != NULL && strcmp (selected->filename, uri) != 0)
  {
    if (item == NULL)
      item = wp_add_image (data, uri);

    if (item)
      select_item (data, item, TRUE);
  }
}
Exemplo n.º 18
0
// select_cat() returns 0 if lista is empty. Returns -1 if input's value is invalid.
int select_cat(vocab_t *listavocab, int cat, const char texto[]) {
	
	pantalla_t *pant = get_curses();

	int numcat = 0;
	
	char *str = NULL;
	str = (char *)malloc(sizeof(char)*TAM_BUF);
	if (!str) {
		exit_mem(EXIT_FAILURE, "Not enough memory.");
	}

	snprintf(str, TAM_BUF, "Choose a list %s.\n\n", texto);
	// If previously we don't select any category...
	if (cat <= 0) {
		numcat = show_cat(listavocab);

		if (numcat>0) {
			print_buffer(str, false);
			cat = 0;
			upgrade_buffer(false);
			while ((cat != 13) && (cat != 27)) {
				wrefresh(pant->ppal);
				 cat = wgetch(pant->menu);
				scroll_keys(cat, true);				
			}
			
			cat = select_item(cat);
			
			if (cat <=0 || cat > numcat) {
				print_buffer("Category not valid.", true);
				cat = -1;
			}
		} else
			cat = 0;
	}
	upgrade_buffer(false);
	wrefresh(pant->ppal);

	free(str);
					
	return cat;
	
}
Exemplo n.º 19
0
//	Start the process of picking up the specified item from a specified category.
//	If the category is already selected, try picking up the item now, otherwise
//	set the requird category, the pick will continue when the category is availble.
//
void pickup_storage_item(int image_id, Uint16 item_id, int cat_id)
{
	if ((storage_win<0) || (find_category(cat_id) == -1))
	{
		do_alert1_sound();
		item_lists_reset_pickup_fail_time();
		return;
	}
	wanted_category = find_category(cat_id);
	wanted_image_id = image_id;
	wanted_item_id = item_id;	
	if (selected_category == wanted_category)
	{
		select_item(wanted_image_id, wanted_item_id);
		wanted_category = -1;
	}
	else
		move_to_category(wanted_category);
}
Exemplo n.º 20
0
void tvertical_list::handle_key_up_arrow(SDLMod /*modifier*/, bool& handled)
{
	if(get_selected_item_count() == 0) {
		return;
	}

	// NOTE maybe this should only work if we can select only one item...
	handled = true;

	for(int i = get_ordered_index(get_selected_item()) - 1; i >= 0; --i) {

		// NOTE we check the first widget to be active since grids have no
		// active flag. This method might not be entirely reliable.
		tcontrol* control = dynamic_cast<tcontrol*>(item_ordered(i).widget(0, 0));
		if(control && control->get_active()) {
			select_item(get_item_at_ordered(i), true);
			return;
		}
	}
}
Exemplo n.º 21
0
Arquivo: tree.c Projeto: ryanlee/mc
static void
tree_chdir_sel (WTree * tree)
{
    char *tmp_path;

    if (!tree->is_panel)
        return;

    change_panel ();

    tmp_path = vfs_path_to_str (tree->selected_ptr->name);
    if (do_cd (tree->selected_ptr->name, cd_exact))
        select_item (current_panel);
    else
        message (D_ERROR, MSG_ERROR, _("Cannot chdir to \"%s\"\n%s"),
                 tmp_path, unix_error_string (errno));

    g_free (tmp_path);
    change_panel ();
    show_tree (tree);
}
Exemplo n.º 22
0
void
mkdir_cmd (void)
{
    char *dir, *absdir;
    const char *name = "";

    /* If 'on' then automatically fills name with current selected item name */
    if (auto_fill_mkdir_name && strcmp (selection (current_panel)->fname, "..") != 0)
        name = selection (current_panel)->fname;

    dir =
        input_expand_dialog (_("Create a new Directory"),
                             _("Enter directory name:"), MC_HISTORY_FM_MKDIR, name);

    if (!dir)
        return;

    if (*dir)
    {
        if (dir[0] == '/' || dir[0] == '~')
            absdir = g_strdup (dir);
        else
            absdir = concat_dir_and_file (current_panel->cwd, dir);

        save_cwds_stat ();
        if (my_mkdir (absdir, 0777) == 0)
        {
            update_panels (UP_OPTIMIZE, dir);
            repaint_screen ();
            select_item (current_panel);
        }
        else
        {
            message (D_ERROR, MSG_ERROR, "%s", unix_error_string (errno));
        }
        g_free (absdir);
    }
    g_free (dir);
}
Exemplo n.º 23
0
void gc_help_start (GcomprisBoard *gcomprisBoard)
{

  gchar *item_id = "#UP";
  GooCanvasItem *item;
  gint y = 0;
  gint y_start = 0;
  gint x_start = 0;
  gchar   *name = NULL;
  gchar   *text_to_display = NULL;

  if(rootitem)
    return;

  gc_board_pause(TRUE);

  caller_cursor = gc_cursor_get();
  gc_cursor_set(GCOMPRIS_DEFAULT_CURSOR);

  item_selected = NULL;
  item_selected_text = NULL;

  name = gcomprisBoard->title;
  gc_help_has_board(gcomprisBoard);

  rootitem = goo_canvas_group_new (goo_canvas_get_root_item(gc_get_canvas()),
				   NULL);

  item = goo_canvas_svg_new (rootitem,
			     gc_skin_rsvg_get(),
			     "svg-id", "#DIALOG",
			     "pointer-events", GOO_CANVAS_EVENTS_NONE,
			     NULL);

  GooCanvasBounds bounds;
  guint pixmap_width = 40;
  goo_canvas_item_get_bounds(item, &bounds);
  x_start = bounds.x1;
  y_start = bounds.y1;

  y = bounds.y2 - 26;

  y_start += 15;
  if(gcomprisBoard->section && gcomprisBoard->name) {
    text_to_display = g_strdup_printf("%s/%s", gcomprisBoard->section, gcomprisBoard->name);
     goo_canvas_text_new (rootitem,
			  text_to_display,
			  BOARDWIDTH*0.10,
			  y_start,
			  -1,
			  GTK_ANCHOR_NW,
			  "font", gc_skin_font_board_tiny,
			  "fill-color-rgba", gc_skin_color_title,
			  NULL);
    g_free(text_to_display);
  }

  y_start += 30;
  goo_canvas_text_new (rootitem,
		       name,
		       BOARDWIDTH/2,
		       y_start,
		       -1,
		       GTK_ANCHOR_CENTER,
		       "font", gc_skin_font_title,
		       "fill-color-rgba", gc_skin_color_title,
		       NULL);


  y_start += 80;

  // Prerequisite Button
  if(prerequisite)
    {
      item_prerequisite = goo_canvas_svg_new (rootitem,
					      gc_skin_rsvg_get(),
					      "svg-id", item_id,
					      NULL);
      SET_ITEM_LOCATION(item_prerequisite,
			(BOARDWIDTH*0.2) - pixmap_width/2,
			y_start  - 10)

      g_signal_connect(item_prerequisite, "button_press_event",
			 (GtkSignalFunc) item_event_help,
			 "prerequisite");
      gc_item_focus_init(item_prerequisite, NULL);

      item_prerequisite_text = \
	goo_canvas_text_new (rootitem,
			     _("Prerequisite"),
			     BOARDWIDTH*0.20,
			     y_start   + GAP_TO_BUTTON,
			     -1,
			     GTK_ANCHOR_CENTER,
			     "font", gc_skin_font_content,
			     "fill-color-rgba", gc_skin_get_color("gcompris/helpunselect"),
			     NULL);
      g_signal_connect(item_prerequisite_text, "button_press_event",
			 (GtkSignalFunc) item_event_help,
			 "prerequisite");
    }

  // Goal Button
  if(goal)
    {
      item_goal = goo_canvas_svg_new (rootitem,
				      gc_skin_rsvg_get(),
				      "svg-id", item_id,
				      NULL);
      SET_ITEM_LOCATION(item_goal,
			(BOARDWIDTH*0.4) - pixmap_width/2,
			y_start  - 10);

      g_signal_connect(item_goal, "button_press_event",
			 (GtkSignalFunc) item_event_help,
			 "goal");
      gc_item_focus_init(item_goal, NULL);

      item_goal_text = goo_canvas_text_new (rootitem,
					    _("Goal"),
					    BOARDWIDTH*0.4,
					    y_start   + GAP_TO_BUTTON,
					    -1,
					    GTK_ANCHOR_CENTER,
					    "font", gc_skin_font_content,
					    "fill-color-rgba", gc_skin_get_color("gcompris/helpunselect"),
					    NULL);
      g_signal_connect(item_goal_text, "button_press_event",
			 (GtkSignalFunc) item_event_help,
			 "goal");
    }

  // Manual Button
  if(manual)
    {
      item_manual = goo_canvas_svg_new (rootitem,
					gc_skin_rsvg_get(),
					"svg-id", item_id,
					NULL);
      SET_ITEM_LOCATION(item_manual,
			(BOARDWIDTH*0.6) - pixmap_width/2,
			y_start  - 10);

      g_signal_connect(item_manual, "button_press_event",
			 (GtkSignalFunc) item_event_help,
			 "manual");
      gc_item_focus_init(item_manual, NULL);

      item_manual_text = goo_canvas_text_new (rootitem,
					      _("Manual"),
					      BOARDWIDTH*0.6,
					      y_start   + GAP_TO_BUTTON,
					      -1,
					      GTK_ANCHOR_CENTER,
					      "font", gc_skin_font_content,
					      "fill-color-rgba", gc_skin_get_color("gcompris/helpunselect"),
					      NULL);
      g_signal_connect(item_manual_text, "button_press_event",
			 (GtkSignalFunc) item_event_help,
			 "manual");
    }

  // Credit Button
  if(credit)
    {
      item_credit = goo_canvas_svg_new (rootitem,
					gc_skin_rsvg_get(),
					"svg-id", item_id,
					NULL);
      SET_ITEM_LOCATION(item_credit,
			(BOARDWIDTH*0.8) - pixmap_width/2,
			y_start  - 10);

      g_signal_connect(item_credit, "button_press_event",
			 (GtkSignalFunc) item_event_help,
			 "credit");
      gc_item_focus_init(item_credit, NULL);

      item_credit_text = goo_canvas_text_new (rootitem,
					      _("Credit"),
					      BOARDWIDTH*0.8,
					      y_start   + GAP_TO_BUTTON,
					      -1,
					      GTK_ANCHOR_CENTER,
					      "font", gc_skin_font_content,
					      "fill-color-rgba", gc_skin_get_color("gcompris/helpunselect"),
					      NULL);
      g_signal_connect(item_credit_text, "button_press_event",
			 (GtkSignalFunc) item_event_help,
			 "credit");
    }

  // CONTENT

  // default text to display

  if(prerequisite)
    {
      text_to_display = prerequisite;
      select_item(item_prerequisite, item_prerequisite_text);
    }
  else if(goal)
    {
      text_to_display = goal;
      select_item(item_goal, item_goal_text);
    }
  else if(manual)
    {
      text_to_display = manual;
      select_item(item_manual, item_manual_text);
    }
  else if(credit)
    {
      text_to_display = credit;
      select_item(item_credit, item_credit_text);
    }

  y_start += 45;

  /* Create a scrolled area for the text content */
  GtkWidget *view;
  GtkWidget *sw;
  view = gtk_text_view_new ();
  gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD);
  gtk_text_view_set_editable(GTK_TEXT_VIEW (view), FALSE);
  gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW (view), FALSE);

  gtk_signal_connect(GTK_OBJECT(view), "button-press-event",
		     (GtkSignalFunc) event_disable_right_click_popup, NULL);

  PangoFontDescription *font_desc;
  font_desc = pango_font_description_from_string (gc_skin_font_content);
  gtk_widget_modify_font (view, font_desc);
  pango_font_description_free (font_desc);

  GdkColor fg_color;
  GdkColor bg_color;
  gc_skin_get_gdkcolor("gcompris/helpfg", &fg_color);
  gc_skin_get_gdkcolor("gcompris/helpbg", &bg_color);
  gtk_widget_modify_base(view, GTK_STATE_NORMAL, &bg_color);
  gtk_widget_modify_text(view, GTK_STATE_NORMAL, &fg_color);

  buffer_content = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
  sw = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
				  GTK_POLICY_AUTOMATIC,
				  GTK_POLICY_AUTOMATIC);
  gtk_container_add (GTK_CONTAINER (sw), view);

  goo_canvas_widget_new (rootitem,
			 sw,
			 x_start + 40,
			 y_start,
			 618.0,
			 280.0,
			 NULL);
  gtk_widget_show_all (sw);

  set_content(text_to_display);
  // OK
  gc_util_button_text_svg(rootitem,
			  BOARDWIDTH * 0.5,
			  y,
			  "#BUTTON_TEXT",
			  _("OK"),
			  (GtkSignalFunc) item_event_help,
			  "ok");

  gc_bar_hide(TRUE);

  help_displayed = TRUE;
}
	/**
	 * Toggles the selection state of an item.
	 *
	 * @param index               The item to toggle.
	 */
	void toggle_item(const unsigned index)
	{
		select_item(index, !is_selected(index));
	}
// funzione per creare una transazione ed accodarla // AGGIUNGERE ORDER STATUS
transaction_descriptor *create_new_tpcc_transaction(state_type *state, int tx_id) {

	// Get the client configuration from simulation state
	CLIENT_lp_state_type *pointer = &state->type.client_state;

	operation_descriptor *op = NULL;
	int i = 0;
	int op_number = 1;
	int tx_class_id = -1;
	transaction_descriptor *tx_descr = (transaction_descriptor *) malloc(sizeof(transaction_descriptor));

	tx_descr->tx_id = tx_id;
	tx_descr->next = NULL;
	tx_descr->first_operation = NULL;
	tx_descr->last_operation = NULL;
	tx_descr->current_operation = NULL;

	if (pointer->configuration.tlm_verbose) {
		printf("creazione nuova transazione tx_id %i\n", tx_id);
	}

	//crea le operazioni
	// seleziona la classe transazionale
	double rand_number = Random();
	double sum = 0;

	for (i = 0; i < pointer->configuration.number_of_tx_classes; i++) {
		sum += pointer->configuration.tx_class_probability[i];
		if (rand_number < sum) {
			tx_class_id = i;
			break;
		}
	}

	tx_descr->tx_class_id = tx_class_id;

	if (tx_class_id == NEW_ORDER) {
		/*
		 * NEW ORDER TRANSACTION
		 */

		int warehouse = select_warehouse();
		int district = select_district(warehouse);
		int customer = select_customer(district);

		//crea l'operazione customer
		op = (operation_descriptor *) malloc(sizeof(operation_descriptor));
		op->op_number = op_number++;
		op->op_type = TX_GET;
		op->object_key_id = customer;

		op->next = NULL;
		enqueue_operation(tx_descr, op);
		if (pointer->configuration.tlm_verbose) {
			printf("\t\ttipo TX_GET customer\n");
			printf("\t\tdata_item %i\n", op->object_key_id);
		}

		//crea l'operazione warehouse
		op = (operation_descriptor *) malloc(sizeof(operation_descriptor));
		op->op_number = op_number++;
		op->op_type = TX_GET;
		op->object_key_id = warehouse;

		op->next = NULL;
		enqueue_operation(tx_descr, op);
		if (pointer->configuration.tlm_verbose) {
			printf("\t\ttipo TX_GET warehouse\n");
			printf("\t\tdata_item %i\n", op->object_key_id);
		}

		//crea l'operazione district
		op = (operation_descriptor *) malloc(sizeof(operation_descriptor));
		op->op_number = op_number++;
		op->op_type = TX_GET;
		op->object_key_id = district;

		op->next = NULL;
		enqueue_operation(tx_descr, op);
		if (pointer->configuration.tlm_verbose) {
			printf("\t\ttipo TX_GET district\n");
			printf("\t\tdata_item %i\n", op->object_key_id);
		}

		int i;
		int top = RandomRange(5, 15);
		for (i = 1; i <= top; i++) {

			//crea l'operazione item
			op = (operation_descriptor *) malloc(sizeof(operation_descriptor));
			op->op_number = op_number++;
			op->op_type = TX_GET;
			int item = select_item();
			op->object_key_id = item;

			op->next = NULL;
			enqueue_operation(tx_descr, op);
			if (pointer->configuration.tlm_verbose) {
				printf("\t\ttipo TX_GET item\n");
				printf("\t\tdata_item %i\n", op->object_key_id);
			}

			//crea l'operazione stock
			op = (operation_descriptor *) malloc(sizeof(operation_descriptor));
			op->op_number = op_number++;
			op->op_type = TX_GET;
			int stock = from_item_to_stock(item, warehouse);
			op->object_key_id = stock;

			op->next = NULL;
			enqueue_operation(tx_descr, op);
			if (pointer->configuration.tlm_verbose) {
				printf("\t\ttipo TX_GET stock\n");
				printf("\t\tdata_item %i\n", op->object_key_id);
			}

			//crea l'operazione stock
			op = (operation_descriptor *) malloc(sizeof(operation_descriptor));
			op->op_number = op_number++;
			op->op_type = TX_PUT;
			op->object_key_id = stock;

			op->next = NULL;
			enqueue_operation(tx_descr, op);
			if (pointer->configuration.tlm_verbose) {
				printf("\t\ttipo TX_PUT stock\n");
				printf("\t\tdata_item %i\n", op->object_key_id);
			}
		}
		//crea l'operazione district
		op = (operation_descriptor *) malloc(sizeof(operation_descriptor));
		op->op_number = op_number++;
		op->op_type = TX_PUT;
		op->object_key_id = district;

	} else if (tx_class_id == PAYMENT) {

		/*
		 * PAYMENT TRANSACTION
		 */



		int warehouse = select_warehouse();
		int district = select_district(warehouse);
		int customer = select_customer(district);

		//crea l'operazione warehouse
		op = (operation_descriptor *) malloc(sizeof(operation_descriptor));
		op->op_number = op_number++;
		op->op_type = TX_GET;
		op->object_key_id = warehouse;

		op->next = NULL;
		enqueue_operation(tx_descr, op);
		if (pointer->configuration.tlm_verbose) {
			printf("\t\ttipo TX_GET warehouse\n");
			printf("\t\tdata_item %i\n", op->object_key_id);
		}

		//crea l'operazione warehouse
		op = (operation_descriptor *) malloc(sizeof(operation_descriptor));
		op->op_number = op_number++;
		op->op_type = TX_PUT;
		op->object_key_id = warehouse;

		op->next = NULL;
		enqueue_operation(tx_descr, op);
		if (pointer->configuration.tlm_verbose) {
			printf("\t\ttipo TX_PUT warehouse\n");
			printf("\t\tdata_item %i\n", op->object_key_id);
		}

		//crea l'operazione district
		op = (operation_descriptor *) malloc(sizeof(operation_descriptor));
		op->op_number = op_number++;
		op->op_type = TX_GET;
		op->object_key_id = district;

		op->next = NULL;
		enqueue_operation(tx_descr, op);
		if (pointer->configuration.tlm_verbose) {
			printf("\t\ttipo TX_GET district\n");
			printf("\t\tdata_item %i\n", op->object_key_id);
		}

		//crea l'operazione district
		op = (operation_descriptor *) malloc(sizeof(operation_descriptor));
		op->op_number = op_number++;
		op->op_type = TX_PUT;
		op->object_key_id = district;

		op->next = NULL;
		enqueue_operation(tx_descr, op);
		if (pointer->configuration.tlm_verbose) {
			printf("\t\ttipo TX_PUT district\n");
			printf("\t\tdata_item %i\n", op->object_key_id);
		}

		//crea l'operazione customer
		op = (operation_descriptor *) malloc(sizeof(operation_descriptor));
		op->op_number = op_number++;
		op->op_type = TX_GET;
		op->object_key_id = customer;

		op->next = NULL;
		enqueue_operation(tx_descr, op);
		if (pointer->configuration.tlm_verbose) {
			printf("\t\ttipo TX_GET customer\n");
			printf("\t\tdata_item %i\n", op->object_key_id);
		}

		//crea l'operazione customer
		op = (operation_descriptor *) malloc(sizeof(operation_descriptor));
		op->op_number = op_number++;
		op->op_type = TX_PUT;
		op->object_key_id = customer;

		op->next = NULL;
		enqueue_operation(tx_descr, op);
		if (pointer->configuration.tlm_verbose) {
			printf("\t\ttipo TX_PUT customer\n");
			printf("\t\tdata_item %i\n", op->object_key_id);
		}

	} else if (tx_class_id == ORDER_STATUS) {


		// get orders
		for (i = 0; i < 3000; i++) {
			//crea l'operazione customer
			op = (operation_descriptor *) malloc(sizeof(operation_descriptor));
			memset(op, 0,sizeof(operation_descriptor));
			op->op_number = op_number++;
			op->op_type = TX_GET;
			op->object_key_id = RandomRange(0, 203010);
			enqueue_operation(tx_descr, op);
		}

	} else {
		printf("\nErrore: classe transazionale non corretta");
	}

	//resetta lo stato della transazione
	reset_transaction_state(tx_descr);

	return tx_descr;
}
static gboolean
wp_load_stuffs (void *user_data)
{
  AppearanceData *data;
  gchar *imagepath, *uri, *style;
  MateWPItem *item;

  data = (AppearanceData *) user_data;

  compute_thumbnail_sizes (data);

  mate_wp_xml_load_list (data);
  g_hash_table_foreach (data->wp_hash, (GHFunc) wp_props_load_wallpaper,
                        data);

  style = g_settings_get_string (data->wp_settings,
                                   WP_OPTIONS_KEY);
  if (style == NULL)
    style = g_strdup ("none");

  uri = g_settings_get_string (data->wp_settings,
                                 WP_FILE_KEY);

  if (uri && *uri == '\0')
  {
    g_free (uri);
    uri = NULL;
  }

  if (uri == NULL)
    uri = g_strdup ("(none)");

  if (g_utf8_validate (uri, -1, NULL) && g_file_test (uri, G_FILE_TEST_EXISTS))
    imagepath = g_strdup (uri);
  else
    imagepath = g_filename_from_utf8 (uri, -1, NULL, NULL, NULL);

  g_free (uri);

  item = g_hash_table_lookup (data->wp_hash, imagepath);

  if (item != NULL)
  {
    /* update with the current gsettings */
    mate_wp_item_update (item);

    if (strcmp (style, "none") != 0)
    {
      if (item->deleted == TRUE)
      {
        item->deleted = FALSE;
        wp_props_load_wallpaper (item->filename, item, data);
      }

      select_item (data, item, FALSE);
    }
  }
  else if (strcmp (style, "none") != 0)
  {
    item = wp_add_image (data, imagepath);
    if (item)
      select_item (data, item, FALSE);
  }

  item = g_hash_table_lookup (data->wp_hash, "(none)");
  if (item == NULL)
  {
    item = mate_wp_item_new ("(none)", data->wp_hash, data->thumb_factory);
    if (item != NULL)
    {
      wp_props_load_wallpaper (item->filename, item, data);
    }
  }
  else
  {
    if (item->deleted == TRUE)
    {
      item->deleted = FALSE;
      wp_props_load_wallpaper (item->filename, item, data);
    }

    if (!strcmp (style, "none"))
    {
      select_item (data, item, FALSE);
      wp_option_menu_set (data, MATE_BG_PLACEMENT_SCALED, FALSE);
    }
  }
  g_free (imagepath);
  g_free (style);

  if (data->wp_uris) {
    wp_add_images (data, data->wp_uris);
    data->wp_uris = NULL;
  }

  return FALSE;
}
Exemplo n.º 27
0
int
main(int ac, char **av)
{
  int c;
  int ch;
  int i;
  int count_items;
  char **items;
  int shortcut[] = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'a', 'b',
		    'c', 'd', 'e', 'f', 'g', 'h', 'i', 'k', 'l', 'm', 'n', 'o',
		    'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0};
  int shortcut_len = sizeof shortcut / sizeof(int);
  int l_num;
  int mode = 0;

  if (ac == 1)
    usage();

  init_locale();
  f_result = stderr;
  l.f_out = stdout;  
  i = get_options(ac, av);
  items = av + i;
  count_items = ac - i;
  if (count_items == 0)
    return (1);

  if (nb_items_per_page <= 0 || nb_items_per_page >= shortcut_len)
    return 1;

  tcgetattr( STDIN_FILENO, &oldt );
  newt = oldt;
  newt.c_lflag &= ~( ICANON | ECHO );
  tcsetattr( STDIN_FILENO, TCSANOW, &newt);
  terminit();

  l.prefix = shortcut;
  l.upstr = upstr;
  l.dcstr = dcstr;
  l.bottom_msg[0] = '\0';
  l.bottom_msg_col_s = 0;
  l.y = 0;
  l.cursor_y = 0;
  l.item_top_page = 0;

  set_items_per_page(&l, nb_items_per_page);
  set_items(&l, items, count_items);
  signal(SIGWINCH, sigwinch);
  ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsz);
  l.col_width = winsz.ws_col;
  calibre_width(&l);
  draw_items(&l);

  fflush(l.f_out);
  while ((c = getchar()) != 'q') {
    if (c == -1) {
      if (errno == EINTR)
	continue;
      exit(1);
    }
    switch (c) {
    case '/':
      tcsetattr( STDIN_FILENO, TCSANOW, &oldt);
      search();
      l.cur_page = 0;
      l.cursor_y = 0;
      draw_items(&l);
      tcsetattr( STDIN_FILENO, TCSANOW, &newt);
      break;
      
    case 'n' /*|| ' ' || 'j' */:
      page_seek(&l, RELATIVE, 1);
      break;
    case 'p' /*|| 'k'*/:
      page_seek(&l, RELATIVE, -1);
      break;
    case 'j':
      cursor_seek(&l, 1, 1);
      break;
    case 'k':
      cursor_seek(&l, 1, -1);
      break;

    case ' ':
      select_item(&l, l.cursor_y);
      cursor_seek(&l, RELATIVE, 1);
      break;

    case '\n':
      enter_selected_items();
      cleanup_exit(0);
      break;

    default:
      if ((l_num = has_c(c, shortcut)) >= 0) {
	enter_result(l_num + l.item_top_page);
	cleanup_exit(0);
      }
      break;
    }
    fflush(l.f_out);
  }

  cleanup_exit(0);
  return 0;
}
Exemplo n.º 28
0
static void
scroll_ended(app_t *app)
{
    select_item(app, app->current);
    evas_object_move(app->e_box, app->box_x, app->box_y);
}
Exemplo n.º 29
0
void accel_data_handler(AccelData *data, uint32_t num_samples) {
  if (!scrollEnabled) return;
  
  int avgX = 0, avgY = 0, avgZ = 0;
  uint64_t latest_time = 0;
  AccelData d = data[0];
  if (d.did_vibrate) return;
  avgX = d.x;
  avgY = d.y;
  avgZ = d.z;
  latest_time = d.timestamp;
  
  if (!baselineSet) {
    baselineX = avgX;
    baselineY = avgY;
    baselineZ = avgZ;
    baselineSet = true;
    return;
  }
  
  // Selection
  if (avgX - baselineX > SELECT_THR ||
      avgX - baselineX < -SELECT_THR) {
    select_item();
  }
  // Fast downward scroll
  else if (avgY - baselineY > FAST_SCROLL_THR) {
    if (current_speed != FAST_SCROLL_SPEED &&
        current_speed != XTRA_FAST_SCROLL_SPEED) {
      current_speed = FAST_SCROLL_SPEED;
      fast_scroll_start = latest_time;
    }
    
    if (avgY - baselineY > XTRA_FAST_SCROLL_THR &&
        latest_time - fast_scroll_start >= XTRA_FAST_TIME_THR) {
      current_speed = XTRA_FAST_SCROLL_SPEED;
    }
    
    count++;
    if (count >= current_speed) {
      count -= current_speed;
      menu_layer_set_selected_next(menu_layer, false, MenuRowAlignCenter, true);
    }
  }
  // Slow downward scroll
  else if (avgY - baselineY > SLOW_SCROLL_THR) {
    current_speed = SLOW_SCROLL_SPEED;
    fast_scroll_start = 0;
    count++;
    if (count >= current_speed) {
      count -= current_speed;
      menu_layer_set_selected_next(menu_layer, false, MenuRowAlignCenter, true);
    }
  }
  // Fast upward scroll
  else if (avgY - baselineY < -FAST_SCROLL_THR) {
    if (current_speed != FAST_SCROLL_SPEED &&
        current_speed != XTRA_FAST_SCROLL_SPEED) {
      current_speed = FAST_SCROLL_SPEED;
      fast_scroll_start = latest_time;
    }
    
    if (avgY - baselineY < -XTRA_FAST_SCROLL_THR &&
        latest_time - fast_scroll_start >= XTRA_FAST_TIME_THR) {
      current_speed = XTRA_FAST_SCROLL_SPEED;
    }
    
    count++;
    if (count >= current_speed) {
      count -= current_speed;
      menu_layer_set_selected_next(menu_layer, true, MenuRowAlignCenter, true);
    }
  }
  // Slow upward scroll
  else if (avgY - baselineY < -SLOW_SCROLL_THR) {
    current_speed = SLOW_SCROLL_SPEED;
    fast_scroll_start = 0;
    count++;
    if (count >= current_speed) {
      count -= current_speed;
      menu_layer_set_selected_next(menu_layer, true, MenuRowAlignCenter, true);        
    }
  }
  // No scroll
  else {
    current_speed = 0;
    count = 0;
    fast_scroll_start = 0;
  }
}
Exemplo n.º 30
0
void SectionPopup::selection_item_triggered()
{
	QAction* action = (QAction*)QObject::sender();
	
	emit select_item(action->data().toInt());
}