void
MyApplication::init()
{
	time(&starttime);
	endtime = starttime + 5;
	done = false;

	qMainWindow = new QMainWindow();

	qButton = new QPushButton();
	qButton->setMinimumWidth(180);
	qButton->setMinimumHeight(35);
	QObject::connect(qButton, SIGNAL(clicked()), this, SLOT(myQuit()));
	update_button(*qButton);

	qMainWindow->setCentralWidget(qButton);
	QRect r = qMainWindow->frameGeometry();
	r.moveCenter(desktop()->availableGeometry().center());
	qMainWindow->move(r.topLeft());
	qMainWindow->show();

	timer = new QTimer(qMainWindow);
	QObject::connect(timer, SIGNAL(timeout()), this, SLOT(tick()));
	timer->start(334);
}
Ejemplo n.º 2
0
static int in_tsbutton_update_keycode(void *data, int *is_down)
{
	int ret, ret_kc = -1, ret_down = 0;

	ret = update_button();
	if (ret != 0)
		return ret;

	if (tsbutton_down_id == last_tsbutton_id)
		return -1;

	if (tsbutton_down_id >= 0) {
		if (last_tsbutton_id >= 0) {
			ret_kc = last_tsbutton_id;
			last_tsbutton_id = -1;
		}
		else {
			ret_down = 1;
			ret_kc = tsbutton_down_id;
			last_tsbutton_id = tsbutton_down_id;
		}
	}
	else {
		ret_kc = last_tsbutton_id;
		last_tsbutton_id = -1;
	}

	if (is_down != NULL)
		*is_down = ret_down;

	return ret_kc;
}
Ejemplo n.º 3
0
static void
add_child (GtkStackSwitcher *self,
           GtkWidget        *widget)
{
  GtkWidget *button;
  GList *group;

  button = gtk_radio_button_new (NULL);
  gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);

  update_button (self, widget, button);

  group = gtk_container_get_children (GTK_CONTAINER (self));
  if (group != NULL)
    {
      gtk_radio_button_join_group (GTK_RADIO_BUTTON (button), GTK_RADIO_BUTTON (group->data));
      g_list_free (group);
    }

  gtk_container_add (GTK_CONTAINER (self), button);

  g_object_set_data (G_OBJECT (button), "stack-child", widget);
  g_signal_connect (button, "clicked", G_CALLBACK (on_button_clicked), self);
  g_signal_connect (widget, "child-notify::title", G_CALLBACK (on_title_icon_updated), self);
  g_signal_connect (widget, "child-notify::icon-name", G_CALLBACK (on_title_icon_updated), self);
  g_signal_connect (widget, "child-notify::position", G_CALLBACK (on_position_updated), self);

  g_hash_table_insert (self->priv->buttons, widget, button);
}
void
MyApplication::tick(void)
{
	tick_count++;
	if(update_button(*qButton)) {
		emit qButton->click();
	}
}
Ejemplo n.º 5
0
void GameGui::update_all_buttons()
{
    for (auto y = 0; y < rows_; y++) {
        for (auto x = 0; x < cols_; x++) {
            update_button(x, y);
        }
    }
}
Ejemplo n.º 6
0
static void
on_title_icon_updated (GtkWidget        *widget,
                       GParamSpec       *pspec,
                       GtkStackSwitcher *self)
{
  GtkWidget *button;

  button = g_hash_table_lookup (self->priv->buttons, widget);
  update_button (self, widget, button);
}
Ejemplo n.º 7
0
static void
update_and_emit (CEPolkitButton *self, gboolean old_actionable)
{
	gboolean new_actionable;

	new_actionable = ce_polkit_button_get_actionable (self);
	update_button (self, new_actionable);
	if (new_actionable != old_actionable)
		g_signal_emit (self, signals[ACTIONABLE], 0, new_actionable);
}
Ejemplo n.º 8
0
void hide_alert_timeout(void){
   g_seconds --;
   if (g_seconds > 0){
      update_button();
      return;
   }

   hide_alert_dialog();
   alert_active = FALSE;
   the_active_alert.active_alert_id = -1;
   kill_timer();
}
Ejemplo n.º 9
0
static int in_tsbutton_update(void *drv_data, const int *binds, int *result)
{
	int ret, t;
	
	ret = update_button();
	if (ret != 0)
		return ret;

	if (tsbutton_down_id >= 0)
		for (t = 0; t < IN_BINDTYPE_COUNT; t++)
			result[t] |= binds[IN_BIND_OFFS(tsbutton_down_id, t)];

	return 0;
}
Ejemplo n.º 10
0
static void
update_button_by_name(Pixel pix, const char *name)
{
    static Widget pref_shell = 0;
    Widget button;

    if (pref_shell == 0
	&& !get_widget_by_name(&pref_shell, globals.widgets.top_level, Xdvi_PREFS_DIALOG_NAME, True))
	return;
    
    if (get_widget_by_name(&button, pref_shell, name, True)) {
	update_button(button, pix);
    }
}
Ejemplo n.º 11
0
void ButtonWidget::update(float dt)
{
	ActiveDrawableRect::update(dt);
	int mouse_x = Input::get_mouse_x();
	int mouse_y = Input::get_mouse_y();
	//if left button is pressed state.Ture for pressed.
	bool bpressed = Input::get_sys_key_pressed(WIP_MOUSE_LBUTTON);
	if(_last_mouse_state==0&&bpressed==1)
		set_mouse_state(mouse_x,mouse_y,1 );
	else if(_last_mouse_state==1&&bpressed==0)
		set_mouse_state(mouse_x,mouse_y,2 );
	update_button(mouse_x,mouse_y);
	//set_mouse_state(mouse_x,mouse_y,bpressed? 1 : 2 );
	
	draw_internal();
	_last_mouse_state = bpressed;
}
Ejemplo n.º 12
0
GtkWidget *
ce_polkit_button_new (const char *label,
                      const char *tooltip,
                      const char *auth_tooltip,
                      const char *stock_icon,
                      NMClient *client,
                      NMClientPermission permission)
{
	GObject *object;
	CEPolkitButtonPrivate *priv;

	object = g_object_new (CE_TYPE_POLKIT_BUTTON, NULL);
	if (!object)
		return NULL;

	priv = CE_POLKIT_BUTTON_GET_PRIVATE (object);

	priv->tooltip = g_strdup (tooltip);
	priv->auth_tooltip = g_strdup (auth_tooltip);
	priv->permission = permission;

	priv->client = g_object_ref (client);
	priv->perm_id = g_signal_connect (client,
	                                  "permission-changed",
	                                  G_CALLBACK (permission_changed_cb),
	                                  object);

	priv->stock = gtk_image_new_from_stock (stock_icon, GTK_ICON_SIZE_BUTTON);
	g_object_ref_sink (priv->stock);
	priv->auth = gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_BUTTON);
	g_object_ref_sink (priv->auth);

	gtk_button_set_label (GTK_BUTTON (object), label);
	update_button (CE_POLKIT_BUTTON (object),
	               ce_polkit_button_get_actionable (CE_POLKIT_BUTTON (object)));

	permission_changed_cb (client,
	                       permission,
	                       nm_client_get_permission_result (client, permission),
	                       CE_POLKIT_BUTTON (object));

	return GTK_WIDGET (object);
}
Ejemplo n.º 13
0
GtkWidget *
ce_polkit_button_new (const char *label,
                      const char *tooltip,
                      const char *auth_label,
                      const char *auth_tooltip,
                      const char *stock_icon,
                      BMRemoteSettingsSystem *settings,
                      BMSettingsSystemPermissions permission)
{
	GObject *object;
	CEPolkitButtonPrivate *priv;

	object = g_object_new (CE_TYPE_POLKIT_BUTTON, NULL);
	if (!object)
		return NULL;

	priv = CE_POLKIT_BUTTON_GET_PRIVATE (object);

	priv->label = g_strdup (label);
	priv->tooltip = g_strdup (tooltip);
	priv->auth_label = g_strdup (auth_label);
	priv->auth_tooltip = g_strdup (auth_tooltip);
	priv->permission = permission;
	priv->use_polkit = FALSE;

	priv->settings = g_object_ref (settings);
	priv->check_id = g_signal_connect (settings,
	                                   BM_SETTINGS_SYSTEM_INTERFACE_CHECK_PERMISSIONS,
	                                   G_CALLBACK (check_permissions_cb),
	                                   object);

	priv->stock = gtk_image_new_from_stock (stock_icon, GTK_ICON_SIZE_BUTTON);
	g_object_ref_sink (priv->stock);
	priv->auth = gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_BUTTON);
	g_object_ref_sink (priv->auth);

	update_button (CE_POLKIT_BUTTON (object),
	               ce_polkit_button_get_actionable (CE_POLKIT_BUTTON (object)));

	check_permissions_cb (settings, CE_POLKIT_BUTTON (object));

	return GTK_WIDGET (object);
}
Ejemplo n.º 14
0
void Arcball::update(
    gst::Input const & input,
    gst::CameraNode const & eye,
    gst::Viewport const & viewport)
{
    update_button(input);
    update_key(input);

    drag.from = ball_coord(viewport, mouse_position_start);
    drag.to = ball_coord(viewport, input.position());

    if (!dragging) {
        update_current_axis_set(input);
        update_constraint_axes(eye);
        constraint.nearest = nearest_constraint(drag.to);
    }

    if (dragging) {
        update_drag_arc(eye);
        object->orientation = orientation.now;
    }

    update_result_arc();
}
Ejemplo n.º 15
0
BonoboObject *
circle_control_new (CommonData *com)
{
        BonoboPropertyBag  *pb;
        BonoboControl      *control;
        GParamSpec        **pspecs;
        guint               n_pspecs;
        GtkWidget *button, *frame, *spin, *hbox, *spin_label;
        GtkObject *adj;
        GSList **list = &com->list;
        GSList *li;
        ObjectData *object = NULL;

        frame = gtk_frame_new("Circle");
        hbox = gtk_hbox_new(FALSE, 2);
        gtk_container_add(GTK_CONTAINER(frame), hbox);
        button = gtk_button_new();
        gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
        spin_label = gtk_label_new ("Speed:");
        gtk_box_pack_start (GTK_BOX (hbox), spin_label, FALSE, FALSE, 0);
        adj = gtk_adjustment_new(100.0, 0.0, 1000.0, 1.0, 10.0, 0.0);
        g_signal_connect(adj, "value_changed", G_CALLBACK(set_speed), com);
        spin = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 0.0, 0);
        gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, FALSE, 0);

        gtk_widget_show_all(frame);
        control = bonobo_control_new (frame);

        pb = bonobo_property_bag_new (NULL, NULL, NULL);
        bonobo_control_set_properties (control, BONOBO_OBJREF (pb), NULL);
        bonobo_object_unref (BONOBO_OBJECT (pb));

        g_signal_connect(button, "clicked", G_CALLBACK(on_press), com);

        pspecs = g_object_class_list_properties (
                G_OBJECT_GET_CLASS (button), &n_pspecs);

        bonobo_property_bag_map_params (
                pb, G_OBJECT (button), (const GParamSpec **)pspecs, n_pspecs);

        g_free (pspecs);

        bonobo_control_life_instrument (control);

        li = g_slist_last(*list);
        if (li)
        {
               object = li->data;
        }
        if (!object || object->button)
        {
                object = g_new0(ObjectData, 1);
                *list = g_slist_append(*list, object);
        }

        object->button = button;
        object->adj = GTK_ADJUSTMENT(adj);

        update_button(object, com);
        set_speed(GTK_ADJUSTMENT(adj), com);

        return BONOBO_OBJECT (control);
}
Ejemplo n.º 16
0
Archivo: apply.c Proyecto: atrinik/dwc
/**
 * 'victim' moves onto 'trap' (trap has FLAG_WALK_ON or FLAG_FLY_ON set) or
 * 'victim' leaves 'trap' (trap has FLAG_WALK_OFF or FLAG_FLY_OFF) set.
 *
 * I added the flags parameter to give the single events more information
 * about whats going on:
 *
 * Most important is the "MOVE_APPLY_VANISHED" flag.
 * If set, a object has left a tile but "vanished" and not moved (perhaps
 * it exploded or something). This means that some events are not
 * triggered like trapdoors or teleporter traps for example which have a
 * "FLY/MOVE_OFF" set. This will avoid that they touch invalid objects.
 * @param trap Object victim moved on.
 * @param victim The object that moved on trap.
 * @param originator Player, monster or other object that caused 'victim'
 * to move onto 'trap'. Will receive messages caused by this action. May
 * be NULL, however, some types of traps require an originator to
 * function.
 * @param flags Flags. */
void move_apply(object *trap, object *victim, object *originator, int flags)
{
	static int recursion_depth = 0;

	/* move_apply() is the most likely candidate for causing unwanted and
	 * possibly unlimited recursion. */
	/* The following was changed because it was causing perfeclty correct
	 * maps to fail.  1)  it's not an error to recurse:
	 * rune detonates, summoning monster.  monster lands on nearby rune.
	 * nearby rune detonates.  This sort of recursion is expected and
	 * proper.  This code was causing needless crashes. */
	if (recursion_depth >= 500)
	{
		LOG(llevDebug, "WARNING: move_apply(): aborting recursion [trap arch %s, name %s; victim arch %s, name %s]\n", trap->arch->name, trap->name, victim->arch->name, victim->name);
		return;
	}

	if (trap->head)
	{
		trap = trap->head;
	}

	/* Trigger the TRIGGER event */
	if (trigger_event(EVENT_TRIGGER, victim, trap, originator, NULL, 0, 0, 0, SCRIPT_FIX_NOTHING))
	{
		return;
	}

	recursion_depth++;

	switch (trap->type)
	{
		/* these objects can trigger other objects connected to them.
		 * We need to check them at map loading time and other special
		 * events to be sure to have a 100% working map state. */
		case BUTTON:
		case PEDESTAL:
			update_button(trap);
			break;

		case TRIGGER_BUTTON:
		case TRIGGER_PEDESTAL:
		case TRIGGER_ALTAR:
			check_trigger(trap, victim);
			break;

		case CHECK_INV:
			check_inv(victim, trap);
			break;

		/* these objects trigger to but they are "instant".
		 * We don't need to check them when loading. */
		case ALTAR:
			/* sacrifice victim on trap */
			apply_altar(trap, victim, originator);
			break;

		case CONVERTER:
			if (!(flags & MOVE_APPLY_VANISHED))
			{
				convert_item(victim, trap);
			}

			break;

		case PLAYERMOVER:
			break;

		/* should be walk_on/fly_on only */
		case SPINNER:
			if (victim->direction)
			{
				if ((victim->direction = victim->direction + trap->direction) > 8)
				{
					victim->direction = (victim->direction % 8) + 1;
				}

				update_turn_face(victim);
			}

			break;

		case DIRECTOR:
			if (victim->direction)
			{
				victim->direction = trap->direction;
				update_turn_face(victim);
			}

			break;

		/* no need to hit anything */
		case MMISSILE:
			if (IS_LIVE(victim) && !(flags&MOVE_APPLY_VANISHED))
			{
				tag_t trap_tag = trap->count;
				hit_player(victim, trap->stats.dam, trap, AT_MAGIC);

				if (!was_destroyed(trap, trap_tag))
				{
					remove_ob(trap);
				}

				check_walk_off(trap, NULL, MOVE_APPLY_VANISHED);
			}

			break;

		case THROWN_OBJ:
			if (trap->inv == NULL || (flags & MOVE_APPLY_VANISHED))
			{
				break;
			}

		/* fallthrough */
		case ARROW:
			/* bad bug: monster throw a object, make a step forwards, step on object ,
			 * trigger this here and get hit by own missile - and will be own enemy.
			 * Victim then is his own enemy and will start to kill herself (this is
			 * removed) but we have not synced victim and his missile. To avoid senseless
			 * action, we avoid hits here */
			if ((IS_LIVE(victim) && trap->speed) && trap->owner != victim)
			{
				hit_with_arrow(trap, victim);
			}

			break;

		case CONE:
		case LIGHTNING:
			break;

		case BULLET:
			if ((QUERY_FLAG(victim, FLAG_NO_PASS) || IS_LIVE(victim)) && !(flags & MOVE_APPLY_VANISHED))
			{
				check_fired_arch(trap);
			}

			break;

		case TRAPDOOR:
		{
			int max, sound_was_played;
			object *ab;

			if ((flags & MOVE_APPLY_VANISHED))
			{
				break;
			}

			if (!trap->value)
			{
				sint32 tot;

				for (ab = trap->above, tot = 0; ab != NULL; ab = ab->above)
				{
					if (!QUERY_FLAG(ab, FLAG_FLYING))
					{
						tot += (ab->nrof ? ab->nrof : 1) * ab->weight + ab->carrying;
					}
				}

				if (!(trap->value = (tot > trap->weight) ? 1 : 0))
				{
					break;
				}

				SET_ANIMATION(trap, (NUM_ANIMATIONS(trap) / NUM_FACINGS(trap)) * trap->direction + trap->value);
				update_object(trap, UP_OBJ_FACE);
			}

			for (ab = trap->above, max = 100, sound_was_played = 0; --max && ab && !QUERY_FLAG(ab, FLAG_FLYING); ab = ab->above)
			{
				if (!sound_was_played)
				{
					play_sound_map(trap->map, trap->x, trap->y, SOUND_FALL_HOLE, SOUND_NORMAL);
					sound_was_played = 1;
				}

				if (ab->type == PLAYER)
				{
					new_draw_info(NDI_UNIQUE, ab, "You fall into a trapdoor!");
				}

				transfer_ob(ab, EXIT_X(trap), EXIT_Y(trap), trap->last_sp, ab, trap);
			}

			break;
		}


		case PIT:
			/* Pit not open? */
			if ((flags & MOVE_APPLY_VANISHED) || trap->stats.wc > 0)
			{
				break;
			}

			play_sound_map(victim->map, victim->x, victim->y, SOUND_FALL_HOLE, SOUND_NORMAL);

			if (victim->type == PLAYER)
			{
				new_draw_info(NDI_UNIQUE, victim, "You fall through the hole!\n");
			}

			transfer_ob(victim->head ? victim->head : victim, EXIT_X(trap), EXIT_Y(trap), trap->last_sp, victim, trap);

			break;

		case EXIT:
			/* If no map path specified, we assume it is the map path of the exit. */
			if (!EXIT_PATH(trap))
			{
				FREE_AND_ADD_REF_HASH(EXIT_PATH(trap), trap->map->path);
			}

			if (!(flags & MOVE_APPLY_VANISHED) && victim->type == PLAYER && EXIT_PATH(trap) && EXIT_Y(trap) != -1 && EXIT_X(trap) != -1)
			{
				/* Basically, don't show exits leading to random maps the players output. */
				if (trap->msg && strncmp(EXIT_PATH(trap), "/!", 2) && strncmp(EXIT_PATH(trap), "/random/", 8))
				{
					new_draw_info(NDI_NAVY, victim, trap->msg);
				}

				enter_exit(victim, trap);
			}

			break;

		case SHOP_MAT:
			if (!(flags & MOVE_APPLY_VANISHED))
			{
				apply_shop_mat(trap, victim);
			}

			break;

		/* Drop a certain amount of gold, and have one item identified */
		case IDENTIFY_ALTAR:
			if (!(flags & MOVE_APPLY_VANISHED))
			{
				apply_identify_altar(victim, trap, originator);
			}

			break;

		case SIGN:
			/* Only player should be able read signs */
			if (victim->type == PLAYER)
			{
				apply_sign(victim, trap);
			}

			break;

		case CONTAINER:
			if (victim->type == PLAYER)
			{
				(void) esrv_apply_container(victim, trap);
			}

			break;

		case RUNE:
			if (!(flags & MOVE_APPLY_VANISHED) && trap->level && IS_LIVE(victim))
			{
				spring_trap(trap, victim);
			}

			break;

#if 0
		/* we don't have this atm. */
		case DEEP_SWAMP:
			if (!(flags & MOVE_APPLY_VANISHED))
			{
				walk_on_deep_swamp(trap, victim);
			}

			break;
#endif

		default:
			LOG(llevDebug, "name %s, arch %s, type %d with fly/walk on/off not handled in move_apply()\n", trap->name, trap->arch->name, trap->type);
			break;
	}

	recursion_depth--;
}
Ejemplo n.º 17
0
void update_buttons(void)
{
	update_button(0);
	update_button(1);
}
Ejemplo n.º 18
0
static Boolean
revert_colors(Pixel fg, Pixel bg, Pixel hl)
{
    XColor color_data[2];
    Boolean need_redraw = False;    
    Widget button;
    Pixel visited, unvisited;
    
    color_data[0].pixel = resource.fore_Pixel;
    color_data[1].pixel = resource.back_Pixel;
    
    str_to_pixel(globals.widgets.top_level, resource.visited_link_color, &visited);
    str_to_pixel(globals.widgets.top_level, resource.link_color, &unvisited);

    XQueryColors(DISP, G_colormap, color_data, 2);

    if (fg != resource.fore_Pixel) {
	XGCValues values;
	
	fg_initial.r = color_data[0].red;
	fg_initial.g = color_data[0].green;
	fg_initial.b = color_data[0].blue;

	values.foreground = resource.rule_pixel = resource.fore_Pixel;
	XChangeGC(DISP, globals.gc.ruler, GCForeground, &values);

	scanned_page = scanned_page_color = scanned_page_reset;

	update_button_by_name(resource.fore_Pixel, Xdvi_FG_COLOR_BTN);

	need_redraw = True;
    }
    if (bg != resource.back_Pixel) {
	bg_initial.r = color_data[1].red;
	bg_initial.g = color_data[1].green;
	bg_initial.b = color_data[1].blue;

	scanned_page = scanned_page_color = scanned_page_reset;

	update_button_by_name(resource.back_Pixel, Xdvi_BG_COLOR_BTN);

	need_redraw = True;
    }
    if (hl != resource.hl_Pixel) {
	XGCValues values;
	values.foreground = resource.hl_Pixel;
	XChangeGC(DISP, globals.gc.high, GCForeground, &values);
	/* hack to update match GC: fake change in inverted property, redraw
	   so that GC is cleared, then change inverted property back */
	resource.match_highlight_inverted = !resource.match_highlight_inverted;
	search_draw_inverted_regions();
	resource.match_highlight_inverted = !resource.match_highlight_inverted;

	update_button_by_name(resource.hl_Pixel, Xdvi_HL_COLOR_BTN);

	need_redraw = True;
    }
    /* NOTE: pixels for hyperlinks are not stored anywhere; just update always: */
    if (get_widget_by_name(&button, globals.widgets.top_level, Xdvi_VISITED_LINKS_BTN, True)) {
	update_button(button, visited);
	h_update_hyperlinks(button, visited); /* this already triggers a redraw */
    }
    if (get_widget_by_name(&button, globals.widgets.top_level, Xdvi_UNVISITED_LINKS_BTN, True)) {
	update_button(button, unvisited);
	h_update_hyperlinks(button, unvisited); /* this already triggers a redraw */
    }
    return need_redraw;
}