Esempio n. 1
0
/**********************************************************************
 * Reads the text file "file_name" and write to the dictionary.
 * If overwrite is TRUE, then besides overwriting any .words file,
 * it loads a lesson with the new dictionary.
 */
void
velo_create_dict (gchar * file_name, gboolean overwrite)
{
	gchar *dict_path;
	gchar *dictio_name;
	gchar *text_raw;
	gchar *text_filtered;
	FILE *fh_destiny;

	if (!file_name)
	{
		gdk_beep ();
		g_warning ("velo_create_dict(): null file name as first argument.");
		return;
	}

	if (!g_file_get_contents (file_name, &text_raw, NULL, NULL))
	{
		gdk_beep ();
		g_warning ("couldn't read the file:\n <%s>", file_name);
		return;
	}

	dictio_name = g_path_get_basename (file_name);
	dict_path = g_strconcat (main_path_user (), G_DIR_SEPARATOR_S, dictio_name, ".words", NULL);
	assert_user_dir ();
	if (!(fh_destiny = (FILE *) g_fopen (dict_path, "w")))
	{
		gdk_beep ();
		g_warning ("couldn't create the file:\n <%s>", dict_path);
		if (overwrite == FALSE)
		{
			g_free (dict_path);
			g_free (dictio_name);
			return;
		}
	}
	g_free (dict_path);

	/* Filter the text
	 */
	text_filtered = velo_filter_utf8 (text_raw);
	fwrite (text_filtered, sizeof (gchar), strlen (text_filtered), fh_destiny);
	fclose (fh_destiny);

	g_free (text_raw);
	g_free (text_filtered);

	if (overwrite == TRUE)
	{
		velo_init_dict (dictio_name);
		tutor_set_query (QUERY_INTRO);
		tutor_process_touch ('\0');
	}
	g_free (dictio_name);
}
Esempio n. 2
0
void layer_new_mouse(void)
{
	// Local variables
	GdkCursor			*selection_cursor;			// Holds the new temporary selection cursor


	// If no project is loaded then don't run this function
	if (NULL == get_current_slide())
	{
		// Make a beep, then return
		gdk_beep();
		return;
	}

	// Change the focus of the window to be this widget
	set_delete_focus(FOCUS_LAYER);

	// Change the cursor to something suitable
	selection_cursor = gdk_cursor_new(GDK_CROSSHAIR);
	gdk_window_set_cursor(get_main_drawing_area()->window, selection_cursor);
	gdk_cursor_unref(selection_cursor);

	// Set a toggle so the release button callback will know to do the rest
	set_new_layer_selected(TYPE_MOUSE_CURSOR);

	// Update the status bar
	gtk_progress_bar_set_text(GTK_PROGRESS_BAR(get_status_bar()), _(" Please click the insertion point"));
	gdk_flush();
}
Esempio n. 3
0
/**
 * Put a message on the statusbar. The message will be displayed for
 * the number of seconds given by timeout. If timeout is 0 the message
 * will not be automatically removed.
 *
 * @returns message id of the added message
 */
statusbar_msgid_t
statusbar_gui_push_v(sb_types_t type, guint scid, guint timeout,
	const gchar *format, va_list args)
{
    static gchar buf[1024];
    statusbar_msgid_t id = zero_msgid;

    if (format != NULL) {
        switch (type) {
        case SB_WARNING:
            gdk_beep();
			/* FALL THRU */
        case SB_MESSAGE:
            str_vbprintf(buf, sizeof(buf), format, args);
            break;
        }
    } else {
        buf[0] = '\0';
    }

    id.scid = scid;
    id.msgid = gtk_statusbar_push(statusbar_get(), scid, buf);

    if (timeout != 0)
        statusbar_gui_add_timeout(id, timeout);

    return id;
}
Esempio n. 4
0
void
ui_signal_cell_clicked (GtkWidget * widget, gint i, gint j, hex_t ignore)
{
  int player;
  int old_i, old_j;
  hex_status_t status;
  int first_move_p;
  first_move_p = !hex_history_last_move (game, &old_i, &old_j);
  player = hex_get_player (game);
  status = hex_move (game, i, j);
  undo_history_marker = history_marker = hex_history_current (game);
  update_history_buttons();
  if (status == HEX_SUCCESS)
    {
      double r = hexboard_color[player][0];
      double g = hexboard_color[player][1];
      double b = hexboard_color[player][2];
      if (!first_move_p)
        hexboard_cell_set_border (HEXBOARD(widget), old_i, old_j, CELL_NORMAL_BORDER_WIDTH);
      hexboard_cell_set_color (HEXBOARD(widget), i, j, r, g, b);
      hexboard_cell_set_border (HEXBOARD(widget), i, j, CELL_SELECT_BORDER_WIDTH);
      check_end_of_game();
    }
  else
    gdk_beep();
}
Esempio n. 5
0
/** \brief Manage name changes.
 *
 * This function is called when the contents of the name entry changes.
 * The primary purpose of this function is to check whether the char length
 * of the name is greater than zero, if yes enable the OK button of the dialog.
 */
static void name_changed (GtkWidget *widget, gpointer data)
{
    const gchar *text;
    gchar       *entry, *end, *j;
    gint         len, pos;
    GtkWidget   *dialog = GTK_WIDGET (data);


    /* step 1: ensure that only valid characters are entered
        (stolen from xlog, tnx pg4i)
     */
    entry = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);
    if ((len = g_utf8_strlen (entry, -1)) > 0)
    {
        end = entry + g_utf8_strlen (entry, -1);
        for (j = entry; j < end; ++j)
        {
            switch (*j)
            {
            case '0' ... '9':
            case 'a' ... 'z':
            case 'A' ... 'Z':
            case '-':
            case '_':
                break;
            default:
                gdk_beep ();
                pos = gtk_editable_get_position (GTK_EDITABLE (widget));
                gtk_editable_delete_text (GTK_EDITABLE (widget),
                                          pos, pos+1);
                break;
            }
        }
    }
Esempio n. 6
0
void Sys_Beep( void ){
#if defined ( __linux__ ) || defined ( __APPLE__ )
	gdk_beep();
#else
	MessageBeep( MB_ICONASTERISK );
#endif
}
Esempio n. 7
0
static void mate_app_warning_bar (MateApp * app, const gchar * warning)
{
  gchar * s = g_strconcat(_("Warning: "), warning, NULL);
  gdk_beep();
  mate_app_flash(app, s);
  g_free(s);
}
Esempio n. 8
0
void plugin_beep(void)
{
	if (geany_data->prefs->beep_on_errors)
		gdk_beep();
	else
		plugin_blink();
}
JNIEXPORT void JNICALL 
Java_gnu_java_awt_peer_gtk_GtkToolkit_beep (JNIEnv *env, jobject obj)
{
  gdk_threads_enter ();
  gdk_beep ();
  gdk_threads_leave ();
}
Esempio n. 10
0
static void
bar_reply_cb(MateAppBar * ab, ReplyInfo * ri)
{
  gchar * response;

  response = mate_appbar_get_response(ab);
  g_return_if_fail(response != NULL);

#ifdef MATE_ENABLE_DEBUG
  g_print("Got reply: \"%s\"\n", response);
#endif

  if ( (g_ascii_strcasecmp(_("y"), response) == 0) ||
       (g_ascii_strcasecmp(_("yes"), response) == 0) ) {
    (* (ri->callback)) (MATE_YES, ri->data);
  }
  else if ( (g_ascii_strcasecmp(_("n"), response) == 0) ||
	    (g_ascii_strcasecmp(_("no"), response) == 0) ) {
    (* (ri->callback)) (MATE_NO, ri->data);
  }
  else {
    g_free(response);
    gdk_beep(); /* Kind of lame; better to give a helpful message */
    return;
  }
  g_free(response);
  mate_appbar_clear_prompt(ab);
  return;
}
Esempio n. 11
0
File: midi.c Progetto: denemo/denemo
//Add the passed midi to a recording in Denemo.project->movement
static void
record_midi (gchar * buf, gdouble time)
{
  buf[0] |= 0xF; //here force the channel to 15
  smf_event_t *event = smf_event_new_from_pointer (buf, 3);
  if (event && smf_event_is_valid (event))
    {
      if (Denemo.project->movement->recorded_midi_track && ((smf_track_t *) Denemo.project->movement->recorded_midi_track)->smf)
        {

          smf_track_add_event_seconds (Denemo.project->movement->recorded_midi_track, event, time);
          if(Denemo.project->movement->recording && noteon_key(event))
            {
                DenemoRecordedNote *note = g_malloc0(sizeof(DenemoRecordedNote));
                note->timing = event->time_seconds * Denemo.project->movement->recording->samplerate;
                notenum2enharmonic (noteon_key(event), &(note->mid_c_offset), &(note->enshift), &(note->octave));
                note->event = event;
                Denemo.project->movement->recording->notes = g_list_append (Denemo.project->movement->recording->notes, note);
            }
        }
      else
        {
          smf_event_delete (event);
          gdk_beep ();
        }
    }
}
Esempio n. 12
0
/** \brief Manage layout code changes.
 *
 * This function is called when the contents of the lyout code changes.
 * The purpose of this function is to check whether entered character is valid
 * and to make the configuration "dirty".
 */
static void layout_code_changed (GtkWidget *widget, gpointer data)
{
    gchar       *entry, *end, *j;
    gint         len, pos;


    /* step 1: ensure that only valid characters are entered
           (stolen from xlog, tnx pg4i)
        */
    entry = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);
    if ((len = g_utf8_strlen (entry, -1)) > 0) {
        end = entry + g_utf8_strlen (entry, -1);
        for (j = entry; j < end; ++j) {
            switch (*j) {
            case '0' ... '9':
            case ';':
                dirty = TRUE;
                /* ensure combo box is set to custom */
                if (gtk_combo_box_get_active (GTK_COMBO_BOX(selector)) != PREDEF_NUM-1) {
                    gtk_combo_box_set_active (GTK_COMBO_BOX(selector), PREDEF_NUM-1);
                }
                break;
            default:
                gdk_beep ();
                pos = gtk_editable_get_position (GTK_EDITABLE (widget));
                gtk_editable_delete_text (GTK_EDITABLE (widget),
                                          pos, pos+1);
                break;
            }
        }
    }
Esempio n. 13
0
static void console_beep (void)
{
#ifdef G_OS_WIN32
    MessageBeep(MB_ICONEXCLAMATION);
#else
    gdk_beep();
#endif
}
Esempio n. 14
0
static void
mate_app_error_bar(MateApp * app, const gchar * error)
{
  gchar * s = g_strconcat(_("ERROR: "), error, NULL);
  gdk_beep();
  mate_app_message_bar(app, s);
  g_free(s);
}
void gui_beep()
{
	bool beep;

	phoebe_config_entry_get ("GUI_BEEP_AFTER_PLOT_AND_FIT", &beep);
	if (beep) {
		gdk_beep();
	}
}
Esempio n. 16
0
static void beep (void)
{
	GConfClient *default_client;
	gboolean audible_bell_set;
	
	default_client = gconf_client_get_default ();
	audible_bell_set = gconf_client_get_bool (default_client, KEY_AUDIBLE_BELL, NULL);
	if (audible_bell_set) {
		gdk_beep ();
	}
}
Esempio n. 17
0
void bell()
{
  if (hime_bell_off)
    return;

#if 1
  XBell(dpy, hime_bell_volume);
#else
  gdk_beep();
#endif
//  abort();
}
Esempio n. 18
0
void bell()
{
  if (gcin_bell_off)
    return;

#if UNIX
  XBell(dpy, gcin_bell_volume);
#else
  gdk_beep();
#endif
//  abort();
}
Esempio n. 19
0
static void
chanlist_join (GtkWidget * wid, server *serv)
{
	char tbuf[CHANLEN + 6];
	char *chan = chanlist_get_selected (serv, FALSE);
	if (chan)
	{
		if (serv->connected && (strcmp (chan, "*") != 0))
		{
			snprintf (tbuf, sizeof (tbuf), "join %s", chan);
			handle_command (serv->server_session, tbuf, FALSE);
		} else
			gdk_beep ();
		g_free (chan);
	}
}
Esempio n. 20
0
static gboolean
on_goto_key_pressed (GtkWidget* entry, GdkEventKey* event, SearchBox* search_box)
{
	switch (event->keyval)
	{
		case GDK_KEY_0:
		case GDK_KEY_1:
		case GDK_KEY_2:
		case GDK_KEY_3:
		case GDK_KEY_4:
		case GDK_KEY_5:
		case GDK_KEY_6:
		case GDK_KEY_7:
		case GDK_KEY_8:
		case GDK_KEY_9:
		case GDK_KEY_KP_0:
		case GDK_KEY_KP_1:
		case GDK_KEY_KP_2:
		case GDK_KEY_KP_3:
		case GDK_KEY_KP_4:
		case GDK_KEY_KP_5:
		case GDK_KEY_KP_6:
		case GDK_KEY_KP_7:
		case GDK_KEY_KP_8:
		case GDK_KEY_KP_9:
		case GDK_KEY_Return:
		case GDK_KEY_KP_Enter:
		case GDK_KEY_BackSpace:
		case GDK_KEY_Delete:
		case GDK_KEY_Tab:
		{
			/* This is a number or enter which is ok */
			break;
		}
		case GDK_KEY_Escape:
		{
			search_box_hide (search_box);
		}
		default:
		{
			/* Not a number */
			gdk_beep ();
			return TRUE;
		}
	}
	return FALSE;
}
Esempio n. 21
0
void
mnp_alarm_instance_raise (MnpAlarmInstance *alarm)
{
  MnpAlarmInstancePrivate *priv = ALARM_INSTANCE_PRIVATE(alarm);
  MnpAlarmItem *item = priv->item;

  show_notification(alarm);
  if (item->sound == MNP_SOUND_BEEP)
	  gdk_beep();
  else if(item->sound == MNP_SOUND_MUSIC) {
	  play_music();
  }
  if (!priv->repeat) {
	  /* raised alarm should be deleted */
	  alarm_del(priv->item);
  } else {
	  g_signal_emit (alarm, signals[ALARM_CHANGED], 0);			
  }
}
Esempio n. 22
0
void
dates_details_time_entry_changed (GtkEditable *entry, gchar *new_text,
				  gint new_text_length,
				  gint *position,
				  DatesData *d)
{
    gint i;
    gchar *c;
	
    for (i = 0, c = new_text; c;
	 c = g_utf8_find_next_char (c, (new_text_length != -1) ?
				    (new_text + new_text_length) : NULL)) {
	if (*c < '0' || *c > '9') {
	    g_signal_stop_emission (entry, g_signal_lookup (
					"insert-text", GTK_TYPE_EDITABLE), 0);
	    gdk_beep ();
	    break;
	}
    }
}
Esempio n. 23
0
File: menu.c Progetto: CBke/xfwm4
gboolean
menu_popup (Menu * menu, int root_x, int root_y, int button,
    guint32 timestamp)
{
    GdkPoint *pt;

    TRACE ("entering menu_popup");

    g_return_val_if_fail (menu != NULL, FALSE);
    g_return_val_if_fail (GTK_IS_MENU (menu->menu), FALSE);

    pt = g_new (GdkPoint, 1);
    pt->x = root_x;
    pt->y = root_y;

    if (!menu_check_and_close ())
    {
        if (!grab_available (gdk_screen_get_root_window (menu->screen), timestamp))
        {
            g_free (pt);
            TRACE ("Cannot get grab on pointer/keyboard, cancel.");
            return FALSE;
        }
        TRACE ("opening new menu");
        menu_open = menu->menu;
        eventFilterPush (menu->filter_setup, menu_filter, NULL);
        gtk_menu_popup (GTK_MENU (menu->menu), NULL, NULL,
            popup_position_func, pt, 0, timestamp);

        if (!GTK_MENU_SHELL (GTK_MENU (menu->menu))->have_xgrab)
        {
            gdk_beep ();
            g_message (_("%s: GtkMenu failed to grab the pointer\n"), g_get_prgname ());
            gtk_menu_popdown (GTK_MENU (menu->menu));
            menu_open = NULL;
            eventFilterPop (menu->filter_setup);
            return FALSE;
        }
    }
    return TRUE;
}
Esempio n. 24
0
/*
 * Manage name changes.
 *
 * This function is called when the contents of the name entry changes.
 * The primary purpose of this function is to check whether the char length
 * of the name is greater than zero, if yes enable the OK button of the dialog.
 */
static void name_changed(GtkWidget * widget, gpointer data)
{
    const gchar    *text;
    gchar          *entry, *end, *j;
    gint            len, pos;

    (void)data;

    /* step 1: ensure that only valid characters are entered
       (stolen from xlog, tnx pg4i)
     */
    entry = gtk_editable_get_chars(GTK_EDITABLE(widget), 0, -1);
    if ((len = g_utf8_strlen(entry, -1)) > 0)
    {
        end = entry + g_utf8_strlen(entry, -1);
        for (j = entry; j < end; ++j)
        {
            if (!gpredict_legal_char(*j))
            {
                gdk_beep();
                pos = gtk_editable_get_position(GTK_EDITABLE(widget));
                gtk_editable_delete_text(GTK_EDITABLE(widget), pos, pos + 1);
            }
        }
    }

    /* step 2: if name seems all right, enable OK button */
    text = gtk_entry_get_text(GTK_ENTRY(widget));

    if (g_utf8_strlen(text, -1) > 0)
    {
        gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog),
                                          GTK_RESPONSE_OK, TRUE);
    }
    else
    {
        gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog),
                                          GTK_RESPONSE_OK, FALSE);
    }
}
Esempio n. 25
0
/**********************************************************************
 * Reads the text "text_raw" and write to the dictionary.
 * If overwrite is TRUE, then besides overwriting any .words file,
 * it loads a lesson with the new dictionary.
 */
void
velo_text_write_to_file (gchar * text_raw, gboolean overwrite)
{
	gchar *dict_path;
	gchar *dictio_name;
	gchar *text_filtered;
	FILE *fh_destiny;

	dictio_name = g_strdup_printf ("(%s)", _("Pasted_or_dropped"));
	dict_path = g_strconcat (main_path_user (), G_DIR_SEPARATOR_S, dictio_name, ".words", NULL);
	assert_user_dir ();
	if (!(fh_destiny = (FILE *) g_fopen (dict_path, "w")))
	{
		gdk_beep ();
		g_warning ("couldn't create the file:\n <%s>", dict_path);
		if (overwrite == FALSE)
		{
			g_free (dict_path);
			g_free (dictio_name);
			return;
		}
	}
	g_free (dict_path);

	/* Filter the text
	 */
	text_filtered = velo_filter_utf8 (text_raw);
	fwrite (text_filtered, sizeof (gchar), strlen (text_filtered), fh_destiny);
	fclose (fh_destiny);

	g_free (text_filtered);

	if (overwrite == TRUE)
	{
		velo_init_dict (dictio_name);
		tutor_set_query (QUERY_INTRO);
		tutor_process_touch ('\0');
	}
	g_free (dictio_name);
}
void chkPrintedObj_toggled (GtkWidget *widget, gpointer user_data)
  {
  QCADLayer *layer = NULL ;
  print_properties_D *dialog = (print_properties_D *)gtk_object_get_data (GTK_OBJECT (user_data), "dialog") ;
  int cx = -1, cy = -1 ;

  if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
    {
    calc_world_size (&cx, &cy, dialog) ;
    if (0 == cx || 0 == cy)
      {
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE) ;
      gdk_beep () ;
      return ;
      }
    }

  if (NULL != (layer = g_object_get_data (G_OBJECT (widget), "layer")))
    g_object_set_data (G_OBJECT (layer), "print_layer", (gpointer)gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) ;

  check_scale (dialog, NULL) ;
  }
Esempio n. 27
0
void layer_copy(void)
{
	// Local variables
	slide				*current_slide_data;		// Alias to make things easier
	guint				selected_layer;				// Holds the number of the layer that is selected
	layer				*this_layer;				// Pointer to the presently selected layer


	// Initialise some things
	current_slide_data = get_current_slide_data();

	// Determine which layer the user has selected in the timeline
	selected_layer = time_line_get_selected_layer_num(current_slide_data->timeline_widget);
	current_slide_data->layers = g_list_first(current_slide_data->layers);
	this_layer = g_list_nth_data(current_slide_data->layers, selected_layer);

	// If there is already a layer in the copy buffer, then we free it
	if (NULL != get_copy_layer())
	{
		layer_free(get_copy_layer());
	}

	// Create a new layer
	set_copy_layer(layer_duplicate(this_layer));
	if (NULL == get_copy_layer())
	{
		// Something went wrong duplicating the existing layer.  Not much we can do
		gdk_beep();
		gtk_progress_bar_set_text(GTK_PROGRESS_BAR(get_status_bar()), _(" Copy failed"));
		gdk_flush();
		return;
	}

	// Update the status bar
	gtk_progress_bar_set_text(GTK_PROGRESS_BAR(get_status_bar()), _(" Layer copied to buffer"));
	gdk_flush();
	return;
}
Esempio n. 28
0
void
PrintTextRaw (void *xtbuf, unsigned char *text, int indent, time_t stamp)
{
	char *last_text = text;
	int len = 0;
	int beep_done = FALSE;

	/* split the text into separate lines */
	while (1)
	{
		switch (*text)
		{
		case 0:
			PrintTextLine (xtbuf, last_text, len, indent, stamp);
			return;
		case '\n':
			PrintTextLine (xtbuf, last_text, len, indent, stamp);
			text++;
			if (*text == 0)
				return;
			last_text = text;
			len = 0;
			break;
		case ATTR_BEEP:
			*text = ' ';
			if (!beep_done) /* beeps may be slow, so only do 1 per line */
			{
				beep_done = TRUE;
				if (!prefs.filterbeep)
					gdk_beep ();
			}
		default:
			text++;
			len++;
		}
	}
}
Esempio n. 29
0
static void doit_and_select(guint group_id, guint key_id)
{
	ScintillaObject *sci = scintilla_get_current();

	if (sci)
	{
		int before = sci_get_current_position(sci), after;

		if (key_id != GEANY_KEYS_GOTO_LINE || !geany_data->toolbar_prefs->visible)
			keybindings_send_command(group_id, key_id);
		else if (go_to_line1_item)
			g_signal_emit_by_name(go_to_line1_item, "activate");
		else
		{
			if (geany_data->prefs->beep_on_errors)
				gdk_beep();
			return;
		}

		after = sci_get_current_position(sci);
		if (before != after)
			sci_set_anchor(sci, before);
	}
}
Esempio n. 30
0
void update_debugger()
// Update debugger state and display.
// Should be called after each R4300 instruction.
{
	if(run==2) {
		if( check_breakpoints(PC->addr)==-1 ) {
			previousPC = PC->addr;
			return;
		}
		else {
			run = 0;
			switch_button_to_run();
			gdk_beep();
		}
	}

	if(registers_opened) {
		gdk_threads_enter();
		update_registers();
		gdk_threads_leave();
	}	
	if(desasm_opened) {
		gdk_threads_enter();
		update_desasm( PC->addr );
		gdk_threads_leave();
	}
	/*if(regTLB_opened) {
		gdk_threads_enter();
		update_TLBwindow();
		gdk_threads_leave();
	}*/
	previousPC = PC->addr;

	// Emulation thread is blocked until a button is clicked.
	pthread_cond_wait(&debugger_done_cond, &mutex);
}