Esempio n. 1
0
void help_unknown_ref(const char *ref, const char *cmd, const char *error)
{
	int i;
	struct string_list suggested_refs = guess_refs(ref);

	fprintf_ln(stderr, _("%s: %s - %s"), cmd, ref, error);

	if (suggested_refs.nr > 0) {
		fprintf_ln(stderr,
			   Q_("\nDid you mean this?",
			      "\nDid you mean one of these?",
			      suggested_refs.nr));
		for (i = 0; i < suggested_refs.nr; i++)
			fprintf(stderr, "\t%s\n", suggested_refs.items[i].string);
	}

	string_list_clear(&suggested_refs, 0);
	exit(1);
}
Esempio n. 2
0
JoyIterator *
joy_iterator_next(JoyIterator *self)
{
	g_return_val_if_fail(JOY_IS_ITERATOR(self), NULL);
	gpointer next = NULL;
	JoyIteratorClass *klass = JOY_ITERATOR_GET_CLASS(self);
	if (G_LIKELY(klass->next_item)) {
		next = klass->next_item(self);
	} else {
		g_warning(Q_("%s: unsupported operation for type '%s'"),
				G_STRFUNC, G_OBJECT_TYPE_NAME(self));
	}
	if (next) {
		GET_PRIVATE(self)->item = next;
		return self;
	} else {
		g_object_unref(self);
		return NULL;
	}
}
Esempio n. 3
0
/****************************************************************************
  Initialize events. 
  Now also initialise sorted_events[].
****************************************************************************/
void events_init(void)
{
  int i;
  
  for (i = 0; i < ARRAY_SIZE(event_to_index); i++) {
    event_to_index[i] = 0;
  }

  for (i = 0; events[i].enum_name; i++) {
    int j;

    if (E_S_XYZZY > events[i].esn) {
      const char *event_format = Q_(event_sections[events[i].esn]);
      int l = 1 + strlen(event_format) + strlen(_(events[i].descr_orig));

      events[i].full_descr = fc_malloc(l);
      fc_snprintf(events[i].full_descr, l, event_format,
                  _(events[i].descr_orig));
    } else {
      /* No section part */
      events[i].full_descr = _(events[i].descr_orig);
    }

    event_to_index[events[i].event] = i;
    events[i].tag_name = fc_strdup(events[i].enum_name);
    for (j = 0; j < strlen(events[i].tag_name); j++) {
      events[i].tag_name[j] = fc_tolower(events[i].tag_name[j]);
    }
    log_debug("event[%d]=%d: name='%s' / '%s'\n"
              "\tdescr_orig='%s'\n"
              "\tdescr='%s'",
              i, events[i].event, events[i].enum_name, events[i].tag_name,
              events[i].descr_orig, events[i].full_descr);
  }

  for (i = 0; i < E_LAST; i++)  {
    sorted_events[i] = i;
  }
  qsort(sorted_events, E_LAST, sizeof(*sorted_events),
	compar_event_message_texts);
}
Esempio n. 4
0
static void *get_data_from_pack(struct object_entry *obj)
{
	off_t from = obj[0].idx.offset + obj[0].hdr_size;
	unsigned long len = obj[1].idx.offset - from;
	unsigned char *data, *inbuf;
	git_zstream stream;
	int status;

	data = xmalloc(obj->size);
	inbuf = xmalloc((len < 64*1024) ? len : 64*1024);

	memset(&stream, 0, sizeof(stream));
	git_inflate_init(&stream);
	stream.next_out = data;
	stream.avail_out = obj->size;

	do {
		ssize_t n = (len < 64*1024) ? len : 64*1024;
		n = pread(pack_fd, inbuf, n, from);
		if (n < 0)
			die_errno(_("cannot pread pack file"));
		if (!n)
			die(Q_("premature end of pack file, %lu byte missing",
			       "premature end of pack file, %lu bytes missing",
			       len),
			    len);
		from += n;
		len -= n;
		stream.next_in = inbuf;
		stream.avail_in = n;
		status = git_inflate(&stream, 0);
	} while (len && status == Z_OK && !stream.avail_in);

	/* This has been inflated OK when first encountered, so... */
	if (status != Z_STREAM_END || stream.total_out != obj->size)
		die(_("serious inflate inconsistency"));

	git_inflate_end(&stream);
	free(inbuf);
	return data;
}
Esempio n. 5
0
static gboolean
serial_read(QahiraFormat *self, GInputStream *stream, GCancellable *cancel,
		guchar *buffer, gsize size, GError **error)
{
	while (size) {
		gssize bytes = g_input_stream_read(stream, buffer, size,
				cancel, error);
		if (G_UNLIKELY(-1 == bytes)) {
			return FALSE;
		}
		if (G_UNLIKELY(size && !bytes)) {
			g_set_error(error, QAHIRA_ERROR,
					QAHIRA_ERROR_CORRUPT_IMAGE,
					Q_("serial: truncated format"));
			return FALSE;
		}
		size -= bytes;
		buffer += bytes;
	}
	return TRUE;
}
Esempio n. 6
0
static const gchar *
date_pattern_converter_convert(Log4gPatternConverter *base,
		Log4gLoggingEvent *event)
{
	struct DatePrivate *priv = GET_DATE_PRIVATE(base);
	const GTimeVal *tv = log4g_logging_event_get_time_stamp(event);
	if (!tv) {
		return NULL;
	}
	struct tm tm;
	time_t time = tv->tv_sec;
	if (!localtime_r(&time, &tm)) {
		log4g_log_error("localtime_r(): %s", g_strerror(errno));
		return NULL;
	}
	if (!strftime(priv->buffer, sizeof priv->buffer, priv->format, &tm)) {
		log4g_log_error(Q_("strftime() returned zero (0)"));
		return NULL;
	}
	return priv->buffer;
}
Esempio n. 7
0
void
FndbManager::ReadDirectory (/*[in]*/ const char *		lpszPath,
			    /*[out]*/ vector<string> &	subDirectoryNames,
			    /*[out]*/ vector<FILENAMEINFO> &	fileNames)
{
  if (! Directory::Exists(lpszPath))
    {
      traceStream->WriteFormattedLine ("core",
				       T_("the directory %s does not exist"),
				       Q_(lpszPath));
      return;
    }
  vector<string> filesToBeIgnored;
  GetIgnorableFiles (lpszPath, filesToBeIgnored);
  auto_ptr<DirectoryLister> pLister (DirectoryLister::Open(lpszPath));
  DirectoryEntry entry;
  while (pLister->GetNext(entry))
    {
      if (binary_search(filesToBeIgnored.begin(),
			filesToBeIgnored.end(),
			entry.name.c_str(),
			StringComparerIgnoringCase()))
	{
	  continue;
	}
      if (entry.isDirectory)
	{
	  subDirectoryNames.push_back (entry.name.c_str());
	}
      else
	{
	  FILENAMEINFO filenameinfo;
	  filenameinfo.FileName = entry.name;
	  fileNames.push_back (filenameinfo);
	}
    }
  pLister->Close ();
}
Esempio n. 8
0
static void
gq_display_clist_class_init(GQDisplayCListClass* self_class) {
	GQTypeDisplayClass* gtd_class = GQ_TYPE_DISPLAY_CLASS(self_class);
	GQDisplayBinaryGenericClass* gdbg_class = GQ_DISPLAY_BINARY_GENERIC_CLASS(self_class);

	gtd_class->name = Q_("displaytype|Column List");
	gtd_class->selectable = FALSE;
	gtd_class->show_in_search_result = FALSE;
	gtd_class->get_widget = dt_clist_get_widget;
	gtd_class->get_data = dt_clist_get_data;
	gtd_class->set_data = dt_generic_binary_set_data; // reused from dt_generic_binary
	gtd_class->buildLDAPMod = bervalLDAPMod;

	gdbg_class->encode = NULL;
	gdbg_class->decode = NULL;
	gdbg_class->get_data_widget = dt_clist_get_data_widget;
	gdbg_class->store_data = dt_clist_store_data;
	gdbg_class->delete_data = dt_clist_delete_data;
	gdbg_class->show_entries = dt_clist_show_entries;

	self_class->fill_clist = NULL;
	self_class->fill_details = NULL;
}
Esempio n. 9
0
DviDoc::DviFileStatus
DviDoc::GetDviFileStatus ()
{
  if (fileStatus == DVIFILE_LOADED)
    {
      if (! File::Exists(PathName(GetPathName())))
	{
	  fileStatus = DVIFILE_LOST;
	}
      else
	{
	  time_t timeMod = modificationTime;
	  modificationTime = File::GetLastWriteTime(PathName(GetPathName()));
	  if (timeMod != modificationTime)
	    {
	      YapLog (T_("%s has been modified"), Q_(TU_(GetPathName())));
	      modificationTime = timeMod;
	      fileStatus = DVIFILE_MODIFIED;
	    }
	}
    }
  return (fileStatus);
}
Esempio n. 10
0
bool
Directory::Exists (/*[in]*/ const PathName & path)
{
  struct stat statbuf;
  if (stat(path.Get(), &statbuf) == 0)
    {
      if (S_ISDIR(statbuf.st_mode) == 0)
	{
	  SessionImpl::theSession->trace_access->WriteFormattedLine
	    ("core",
	     T_("%s is not a directory"),
	     Q_(path));
	  return (false);
	}
      return (true);
    }
  int error = errno;
  if (error != ENOENT)
    {
      FATAL_CRT_ERROR ("stat", path.Get());
    }
  return (false);
}
Esempio n. 11
0
/*
 * Make sure at least "min" bytes are available in the buffer, and
 * return the pointer to the buffer.
 */
static void *fill(int min)
{
	if (min <= input_len)
		return input_buffer + input_offset;
	if (min > sizeof(input_buffer))
		die(Q_("cannot fill %d byte",
		       "cannot fill %d bytes",
		       min),
		    min);
	flush();
	do {
		ssize_t ret = xread(input_fd, input_buffer + input_len,
				sizeof(input_buffer) - input_len);
		if (ret <= 0) {
			if (!ret)
				die(_("early EOF"));
			die_errno(_("read error on input"));
		}
		input_len += ret;
		if (from_stdin)
			display_throughput(progress, consumed_bytes + input_len);
	} while (input_len < min);
	return input_buffer;
}
Esempio n. 12
0
static void
log4g_ttcc_layout_class_init(Log4gTTCCLayoutClass *klass)
{
	GObjectClass *object_class = G_OBJECT_CLASS(klass);
	object_class->finalize = finalize;
	object_class->set_property = set_property;
	Log4gLayoutClass *layout_class = LOG4G_LAYOUT_CLASS(klass);
	layout_class->format = format;
	g_type_class_add_private(klass, sizeof(struct Private));
	/* install properties */
	g_object_class_install_property(object_class, PROP_THREAD_PRINTING,
		g_param_spec_boolean("thread-printing", Q_("Thread Printing"),
			Q_("Toggle thread printing"), TRUE, G_PARAM_WRITABLE));
	g_object_class_install_property(object_class, PROP_CATEGORY_PREFIXING,
		g_param_spec_boolean("category-prefixing",
			Q_("Category Prefixing"),
			Q_("Toggle category prefixing"),
			TRUE, G_PARAM_WRITABLE));
	g_object_class_install_property(object_class, PROP_CONTEXT_PRINTING,
		g_param_spec_boolean("context-printing",
			Q_("Context Printing"), Q_("Toggle context printing"),
			TRUE, G_PARAM_WRITABLE));
}
Esempio n. 13
0
static void
log4g_level_range_filter_class_init(Log4gLevelRangeFilterClass *klass)
{
	Log4gFilterClass *filter_class = LOG4G_FILTER_CLASS(klass);
	GObjectClass *object_class = G_OBJECT_CLASS(klass);
	object_class->dispose = dispose;
	object_class->set_property = set_property;
	filter_class->decide = decide;
	g_type_class_add_private(klass, sizeof(struct Private));
	/* install properties */
	g_object_class_install_property(object_class, PROP_LEVEL_MIN,
		g_param_spec_string("level-min", Q_("Minimum Level"),
			Q_("Minimum log level to match"), NULL,
			G_PARAM_WRITABLE));
	g_object_class_install_property(object_class, PROP_LEVEL_MAX,
		g_param_spec_string("level-max", Q_("Maximum Level"),
			Q_("Maximum log level to match"), NULL,
			G_PARAM_WRITABLE));
	g_object_class_install_property(object_class, PROP_ACCEPT_ON_RANGE,
		g_param_spec_boolean("accept-on-range", Q_("Accept on Range"),
			Q_("Accept or deny on log level range match"),
			TRUE, G_PARAM_WRITABLE));
}
Esempio n. 14
0
void
confirm_box (void)
{
    const char *title = _("Confirmation");

    QuickWidget conf_widgets[] = {
        /* 0 */ QUICK_BUTTON (29, 46, 10, 13, N_("&Cancel"), B_CANCEL, NULL),
        /* 1 */ QUICK_BUTTON (12, 46, 10, 13, N_("&OK"), B_ENTER, NULL),
        /* TRANSLATORS: no need to translate 'Confirmation', it's just a context prefix */
        /* 2 */ QUICK_CHECKBOX (3, 46, 8, 13, N_("Confirmation|&History cleanup"),
                                &confirm_history_cleanup),
        /* 3 */ QUICK_CHECKBOX (3, 46, 7, 13, N_("Confirmation|Di&rectory hotlist delete"),
                                &confirm_directory_hotlist_delete),
        /* 4 */ QUICK_CHECKBOX (3, 46, 6, 13, N_("Confirmation|E&xit"), &confirm_exit),
        /* 5 */ QUICK_CHECKBOX (3, 46, 5, 13, N_("Confirmation|&Execute"), &confirm_execute),
        /* 6 */ QUICK_CHECKBOX (3, 46, 4, 13, N_("Confirmation|O&verwrite"), &confirm_overwrite),
        /* 7 */ QUICK_CHECKBOX (3, 46, 3, 13, N_("Confirmation|&Delete"), &confirm_delete),
        QUICK_END
    };

    const size_t w_num = sizeof (conf_widgets) / sizeof (conf_widgets[0]) - 1;

    /* dialog sizes */
    int dlg_width = 46;
    int dlg_height = w_num + 5;

    size_t i;
    int maxlen = 0;
    int cancel_len, ok_len, blen;

#ifdef ENABLE_NLS
    title = _(title);

    for (i = 0; i < 2; i++)
        conf_widgets[i].u.button.text = _(conf_widgets[i].u.button.text);
#endif /* ENABLE_NLS */

    for (i = 2; i < w_num; i++)
        conf_widgets[i].u.checkbox.text = Q_ (conf_widgets[i].u.checkbox.text);

    /* maximum length of checkboxes */
    for (i = 2; i < w_num; i++)
        maxlen = max (maxlen, str_term_width1 (conf_widgets[i].u.checkbox.text) + 4);

    /* length of buttons */
    cancel_len = str_term_width1 (conf_widgets[0].u.button.text) + 3;
    ok_len = str_term_width1 (conf_widgets[1].u.button.text) + 5;       /* default button */

    blen = cancel_len + ok_len + 2;

    dlg_width = max (maxlen, blen) + 6;
    dlg_width = max (dlg_width, str_term_width1 (title) + 4);

    /* correct widget parameters */
    for (i = 0; i < w_num; i++)
    {
        conf_widgets[i].x_divisions = dlg_width;
        conf_widgets[i].y_divisions = dlg_height;
    }

    conf_widgets[1].relative_x = dlg_width / 2 - blen / 2;
    conf_widgets[0].relative_x = conf_widgets[1].relative_x + ok_len + 2;

    {
        QuickDialog confirmation = {
            dlg_width, dlg_height, -1, -1, title,
            "[Confirmation]", conf_widgets, NULL, TRUE
        };

        (void) quick_dialog (&confirmation);
    }
}
static GtkWidget *
panel_place_menu_item_create_menu (PanelPlaceMenuItem *place_item)
{
	GtkWidget *places_menu;
	GtkWidget *item;
	char      *gconf_name;
	char      *name;
	char      *uri;
	GFile     *file;

	places_menu = panel_create_menu ();

	file = g_file_new_for_path (g_get_home_dir ());
	uri = g_file_get_uri (file);
	name = panel_util_get_label_for_uri (uri);
	g_object_unref (file);
	
	panel_menu_items_append_place_item (PANEL_ICON_HOME, NULL,
					    name,
					    _("Open your personal folder"),
					    places_menu,
					    G_CALLBACK (activate_home_uri),
					    uri);
	g_free (name);
	g_free (uri);

	if (!gconf_client_get_bool (panel_gconf_get_client (),
				    DESKTOP_IS_HOME_DIR_KEY,
				    NULL)) {
		file = g_file_new_for_path (g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP));
		uri = g_file_get_uri (file);
		g_object_unref (file);
		
		panel_menu_items_append_place_item (
				PANEL_ICON_DESKTOP, NULL,
				/* Translators: Desktop is used here as in
				 * "Desktop Folder" (this is not the Desktop
				 * environment). Do not keep "Desktop Folder|"
				 * in the translation */
				Q_("Desktop Folder|Desktop"),
				_("Open the contents of your desktop in a folder"),
				places_menu,
				G_CALLBACK (activate_desktop_uri),
				/* FIXME: if the dir changes, we'd need to update the drag data since the uri is not the same */
				uri);
		g_free (uri);
	}

	panel_place_menu_item_append_gtk_bookmarks (places_menu);
	add_menu_separator (places_menu);

	gconf_name = gconf_client_get_string (panel_gconf_get_client (),
					      COMPUTER_NAME_KEY,
					      NULL);
	panel_menu_items_append_from_desktop (places_menu,
					      "nautilus-computer.desktop",
					      gconf_name);
	if (gconf_name)
		g_free (gconf_name);

	panel_menu_items_append_from_desktop (places_menu,
					      "nautilus-cd-burner.desktop",
					      NULL);

	panel_place_menu_item_append_local_gio (place_item, places_menu);
	add_menu_separator (places_menu);

	panel_menu_items_append_from_desktop (places_menu,
					      "network-scheme.desktop",
					      NULL);
	panel_place_menu_item_append_remote_gio (place_item, places_menu);

	if (panel_is_program_in_path ("nautilus-connect-server")) {
		item = panel_menu_items_create_action_item (PANEL_ACTION_CONNECT_SERVER);
		if (item != NULL)
			gtk_menu_shell_append (GTK_MENU_SHELL (places_menu),
					       item);
	}

	add_menu_separator (places_menu);

	panel_menu_items_append_from_desktop (places_menu,
					      "gnome-search-tool.desktop",
					      NULL);

	panel_recent_append_documents_menu (places_menu,
					    place_item->priv->recent_manager);

	return places_menu;
}
void
panel_menu_items_append_lock_logout (GtkWidget *menu)
{
	gboolean    separator_inserted;
	GList      *children;
	GList      *last;
	GtkWidget  *item;
	const char *translate;
	char       *label;
	char       *tooltip;

	separator_inserted = FALSE;
	children = gtk_container_get_children (GTK_CONTAINER (menu));
	last = g_list_last (children);
	if (last != NULL) {
		separator_inserted = GTK_IS_SEPARATOR (GTK_WIDGET (last->data));
	}
	g_list_free (children);

	if (panel_lock_screen_action_available ("lock")) {
		item = panel_menu_items_create_action_item (PANEL_ACTION_LOCK);
		if (item != NULL) {
			if (!separator_inserted) {
				add_menu_separator (menu);
				separator_inserted = TRUE;
			}

			gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
		}
	}

	/* Translators: translate "panel:showusername|1" to anything
	 * but "1" if "Log Out %s" doesn't make any sense in your
	 * language (where %s is a username).
	 */
	translate = Q_("panel:showusername|1");
	if (strcmp (translate, "1") == 0) {
		const char *user_name;

		user_name = g_get_real_name ();
		if (!user_name || !user_name [0])
			user_name = g_get_user_name ();

		/* keep those strings in sync with the ones in
		 * panel-action-button.c */
		/* Translators: this string is used ONLY if you translated
		 * "panel:showusername|1" to "1" */
		label = g_strdup_printf (_("Log Out %s..."),
					 g_get_user_name ());
		/* Translators: this string is used ONLY if you translated
		 * "panel:showusername|1" to "1" */
		tooltip = g_strdup_printf (_("Log out %s of this session to "
					     "log in as a different user"),
					   user_name);
	} else {
		label   = NULL;
		tooltip = NULL;
	}

	item = panel_menu_items_create_action_item_full (PANEL_ACTION_LOGOUT,
							 label, tooltip);
	g_free (label);
	g_free (tooltip);

	if (item != NULL) {
		if (!separator_inserted)
			add_menu_separator (menu);

		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
	}

	item = panel_menu_items_create_action_item (PANEL_ACTION_SHUTDOWN);
	if (item != NULL) {
		if (!separator_inserted)
			add_menu_separator (menu);

		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
	}
}
void
gnc_stock_split_assistant_finish (GtkAssistant *assistant,
                                  gpointer user_data)
{
    StockSplitInfo *info = user_data;
    GList *account_commits;
    GList *node;

    gnc_numeric amount;
    Transaction *trans;
    Account *account;
    Split *split;
    time64 date;

    account = info->acct;
    g_return_if_fail (account != NULL);

    amount = gnc_amount_edit_get_amount
             (GNC_AMOUNT_EDIT (info->distribution_edit));
    g_return_if_fail (!gnc_numeric_zero_p (amount));

    gnc_suspend_gui_refresh ();

    trans = xaccMallocTransaction (gnc_get_current_book ());

    xaccTransBeginEdit (trans);

    xaccTransSetCurrency (trans, gnc_default_currency ());

    date = gnc_date_edit_get_date (GNC_DATE_EDIT (info->date_edit));
    xaccTransSetDatePostedSecsNormalized (trans, date);

    {
        const char *description;

        description = gtk_entry_get_text (GTK_ENTRY (info->description_entry));
        xaccTransSetDescription (trans, description);
    }

    split = xaccMallocSplit (gnc_get_current_book ());

    xaccAccountBeginEdit (account);
    account_commits = g_list_prepend (NULL, account);

    xaccTransAppendSplit (trans, split);

    xaccAccountInsertSplit (account, split);

    xaccSplitSetAmount (split, amount);
    xaccSplitMakeStockSplit (split);
    /* Set split-action with gnc_set_num_action which is the same as
     * xaccSplitSetAction with these arguments */
    /* Translators: This string has a disambiguation prefix */
    gnc_set_num_action (NULL, split, NULL, Q_("Action Column|Split"));

    amount = gnc_amount_edit_get_amount (GNC_AMOUNT_EDIT (info->price_edit));
    if (gnc_numeric_positive_p (amount))
    {
        QofBook *book;
        GNCPrice *price;
        GNCPriceDB *pdb;
        GNCCurrencyEdit *ce;
        Timespec ts;

        ce = GNC_CURRENCY_EDIT (info->price_currency_edit);

        ts.tv_sec = date;
        ts.tv_nsec = 0;

        price = gnc_price_create (gnc_get_current_book ());

        gnc_price_begin_edit (price);
        gnc_price_set_commodity (price, xaccAccountGetCommodity (account));
        gnc_price_set_currency (price, gnc_currency_edit_get_currency (ce));
        gnc_price_set_time (price, ts);
        gnc_price_set_source (price, PRICE_SOURCE_STOCK_SPLIT);
        gnc_price_set_typestr (price, PRICE_TYPE_UNK);
        gnc_price_set_value (price, amount);
        gnc_price_commit_edit (price);

        book = gnc_get_current_book ();
        pdb = gnc_pricedb_get_db (book);

        if (!gnc_pricedb_add_price (pdb, price))
            gnc_error_dialog (info->window, "%s", _("Error adding price."));

    }

    amount = gnc_amount_edit_get_amount (GNC_AMOUNT_EDIT (info->cash_edit));
    if (gnc_numeric_positive_p (amount))
    {
        const char *memo;

        memo = gtk_entry_get_text (GTK_ENTRY (info->memo_entry));

        /* asset split */
        account = gnc_tree_view_account_get_selected_account (GNC_TREE_VIEW_ACCOUNT(info->asset_tree));

        split = xaccMallocSplit (gnc_get_current_book ());

        xaccAccountBeginEdit (account);
        account_commits = g_list_prepend (account_commits, account);

        xaccAccountInsertSplit (account, split);

        xaccTransAppendSplit (trans, split);

        xaccSplitSetAmount (split, amount);
        xaccSplitSetValue (split, amount);

        xaccSplitSetMemo (split, memo);


        /* income split */
        account = gnc_tree_view_account_get_selected_account (GNC_TREE_VIEW_ACCOUNT(info->income_tree));

        split = xaccMallocSplit (gnc_get_current_book ());

        xaccAccountBeginEdit (account);
        account_commits = g_list_prepend (account_commits, account);

        xaccAccountInsertSplit (account, split);

        xaccTransAppendSplit (trans, split);

        xaccSplitSetAmount (split, gnc_numeric_neg (amount));
        xaccSplitSetValue (split, gnc_numeric_neg (amount));

        xaccSplitSetMemo (split, memo);
    }

    xaccTransCommitEdit (trans);

    for (node = account_commits; node; node = node->next)
        xaccAccountCommitEdit (node->data);
    g_list_free (account_commits);

    gnc_resume_gui_refresh ();

    gnc_close_gui_component_by_data (ASSISTANT_STOCK_SPLIT_CM_CLASS, info);
}
Esempio n. 18
0
double Qmatrix::operator()(int64_t a, int64_t b) const {
  return Q_(f2s(f2s_maps_[0], a), f2s(f2s_maps_[1], b));
}
Esempio n. 19
0
static void
egg_find_bar_init (EggFindBar *find_bar)
{
  EggFindBarPrivate *priv;
  GtkWidget *label;
  GtkWidget *alignment;
  GtkWidget *box;
  GtkToolItem *item;
  GtkWidget *arrow;

  /* Data */
  priv = EGG_FIND_BAR_GET_PRIVATE (find_bar);
  
  find_bar->priv = priv;  
  priv->search_string = NULL;

  gtk_toolbar_set_style (GTK_TOOLBAR (find_bar), GTK_TOOLBAR_BOTH_HORIZ);

  /* Find: |_____| */
  item = gtk_tool_item_new ();
  box = gtk_hbox_new (FALSE, 12);
  
  alignment = gtk_alignment_new (0.0, 0.5, 1.0, 0.0);
  gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 2, 2);

  label = gtk_label_new_with_mnemonic (_("Find:"));

  priv->find_entry = gtk_entry_new ();
  gtk_entry_set_width_chars (GTK_ENTRY (priv->find_entry), 32);
  gtk_entry_set_max_length (GTK_ENTRY (priv->find_entry), 512);
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), priv->find_entry);

  /* Prev */
  arrow = gtk_arrow_new (GTK_ARROW_LEFT, GTK_SHADOW_NONE);
  priv->previous_button = gtk_tool_button_new (arrow, Q_("Find Previous"));
  gtk_tool_item_set_is_important (priv->previous_button, TRUE);
  gtk_tool_item_set_tooltip (priv->previous_button, GTK_TOOLBAR (find_bar)->tooltips,
		             _("Find previous occurrence of the search string"),
		             NULL);

  /* Next */
  arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
  priv->next_button = gtk_tool_button_new (arrow, Q_("Find Next"));
  gtk_tool_item_set_is_important (priv->next_button, TRUE);
  gtk_tool_item_set_tooltip (priv->next_button, GTK_TOOLBAR (find_bar)->tooltips,
		             _("Find next occurrence of the search string"),
		             NULL);

  /* Separator*/
  priv->status_separator = gtk_separator_tool_item_new();

  /* Case button */
  priv->case_button = gtk_toggle_tool_button_new ();
  g_object_set (G_OBJECT (priv->case_button), "label", _("C_ase Sensitive"), NULL);
  gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (priv->case_button), TRUE);
  gtk_tool_item_set_is_important (priv->case_button, TRUE);
  gtk_tool_item_set_tooltip (priv->case_button, GTK_TOOLBAR (find_bar)->tooltips,
		             _("Toggle case sensitive search"),
		             NULL);
  /* Status */
  priv->status_item = gtk_tool_item_new();
  gtk_tool_item_set_expand (priv->status_item, TRUE);
  priv->status_label = gtk_label_new (NULL);
  gtk_label_set_ellipsize (GTK_LABEL (priv->status_label),
                           PANGO_ELLIPSIZE_END);
  gtk_misc_set_alignment (GTK_MISC (priv->status_label), 0.0, 0.5);


  g_signal_connect (priv->find_entry, "changed",
                    G_CALLBACK (entry_changed_callback),
                    find_bar);
  g_signal_connect (priv->find_entry, "activate",
                    G_CALLBACK (entry_activate_callback),
                    find_bar);
  g_signal_connect (priv->next_button, "clicked",
                    G_CALLBACK (next_clicked_callback),
                    find_bar);
  g_signal_connect (priv->previous_button, "clicked",
                    G_CALLBACK (previous_clicked_callback),
                    find_bar);
  g_signal_connect (priv->case_button, "toggled",
                    G_CALLBACK (case_sensitive_toggled_callback),
                    find_bar);

  gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
  gtk_box_pack_start (GTK_BOX (box), priv->find_entry, TRUE, TRUE, 0);
  gtk_container_add (GTK_CONTAINER (alignment), box);
  gtk_container_add (GTK_CONTAINER (item), alignment);
  gtk_toolbar_insert (GTK_TOOLBAR (find_bar), item, -1);
  gtk_toolbar_insert (GTK_TOOLBAR (find_bar), priv->previous_button, -1);
  gtk_toolbar_insert (GTK_TOOLBAR (find_bar), priv->next_button, -1);
  gtk_toolbar_insert (GTK_TOOLBAR (find_bar), priv->case_button, -1);
  gtk_toolbar_insert (GTK_TOOLBAR (find_bar), priv->status_separator, -1);
  gtk_container_add  (GTK_CONTAINER (priv->status_item), priv->status_label);
  gtk_toolbar_insert (GTK_TOOLBAR (find_bar), priv->status_item, -1);

  /* don't show status separator/label until they are set */

  gtk_widget_show_all (GTK_WIDGET (item));
  gtk_widget_show_all (GTK_WIDGET (priv->next_button));
  gtk_widget_show_all (GTK_WIDGET (priv->previous_button));
  gtk_widget_show (priv->status_label);
}
Esempio n. 20
0
static cb_ret_t
listbox_execute_cmd (WListbox * l, unsigned long command)
{
    cb_ret_t ret = MSG_HANDLED;
    int i;
    Widget *w = WIDGET (l);
    int length;

    if (l->list == NULL || g_queue_is_empty (l->list))
        return MSG_NOT_HANDLED;

    switch (command)
    {
    case CK_Up:
        listbox_back (l);
        break;
    case CK_Down:
        listbox_fwd (l);
        break;
    case CK_Top:
        listbox_select_first (l);
        break;
    case CK_Bottom:
        listbox_select_last (l);
        break;
    case CK_PageUp:
        for (i = 0; (i < w->lines - 1) && (l->pos > 0); i++)
            listbox_back (l);
        break;
    case CK_PageDown:
        length = g_queue_get_length (l->list);
        for (i = 0; i < w->lines - 1 && l->pos < length - 1; i++)
            listbox_fwd (l);
        break;
    case CK_Delete:
        if (l->deletable)
        {
            gboolean is_last, is_more;

            length = g_queue_get_length (l->list);

            is_last = (l->pos + 1 >= length);
            is_more = (l->top + w->lines >= length);

            listbox_remove_current (l);
            if ((l->top > 0) && (is_last || is_more))
                l->top--;
        }
        break;
    case CK_Clear:
        if (l->deletable && mc_global.widget.confirm_history_cleanup
            /* TRANSLATORS: no need to translate 'DialogTitle', it's just a context prefix */
            && (query_dialog (Q_ ("DialogTitle|History cleanup"),
                              _("Do you want clean this history?"),
                              D_ERROR, 2, _("&Yes"), _("&No")) == 0))
            listbox_remove_list (l);
        break;
    default:
        ret = MSG_NOT_HANDLED;
    }

    return ret;
}
Esempio n. 21
0
/**
 * Initialize the filter window.
 */
static void init_filter(void)
{
	static struct Hook filter_construct_hook;
	static struct Hook filter_destruct_hook;
	static struct Hook filter_display_hook;
	static struct Hook move_objstr_hook, move_strobj_hook;
	Object *ok_button, *cancel_button, *save_button;
	Object *filter_move_popobject, *filter_remote_label;

	init_hook(&filter_construct_hook,(HOOKFUNC)filter_construct);
	init_hook(&filter_destruct_hook,(HOOKFUNC)filter_destruct);
	init_hook(&filter_display_hook,(HOOKFUNC)filter_display);
	init_hook(&move_objstr_hook, (HOOKFUNC)move_objstr);
	init_hook(&move_strobj_hook, (HOOKFUNC)move_strobj);

	filter_wnd = WindowObject,
		MUIA_Window_ID, MAKE_ID('F','I','L','T'),
		MUIA_Window_Title, _("SimpleMail - Edit Filter"),
		WindowContents, VGroup,
			Child, VGroup,
				Child, HGroup,
					Child, VGroup,
						MUIA_HorizWeight,40,
						Child, VGroup,
							MUIA_Group_Spacing, 0,
							Child, NListviewObject,
								MUIA_NListview_NList, filter_list = FilterListObject,
									MUIA_NList_AutoVisible, 1, /* keep the active filter visible */
									MUIA_NList_ConstructHook, &filter_construct_hook,
									MUIA_NList_DestructHook, &filter_destruct_hook,
									MUIA_NList_DisplayHook, &filter_display_hook,
									End,
								End,
							Child, HGroup,
								Child, filter_name_string = UTF8StringObject,
									StringFrame,
									End,
								End,
							End,
						Child, ColGroup(2),
							Child, filter_new_button = MakeButton(_("_New")),
							Child, filter_remove_button = MakeButton(_("_Remove")),
							Child, filter_moveup_button = MakeButton(_("Move up")),
							Child, filter_movedown_button = MakeButton(_("Move Down")),
							End,
						End,
					Child, BalanceObject, End,
					Child, VGroup,
						Child, HorizLineTextObject(_("Activity")),
						Child, HGroup,
							Child, RectangleObject,MUIA_Weight,25,End,
							Child, ColGroup(5),
								Child, MakeLabel(_("On request")),
								Child, filter_request_check = MakeCheck(NULL,FALSE),
								Child, RectangleObject,MUIA_Weight,200,End,
								Child, MakeLabel(_("On sent mails")),
								Child, filter_sent_check = MakeCheck(NULL,FALSE),

								Child, filter_remote_label = MakeLabel(_("Remotly on POP3 server")),
								Child, filter_remote_check = MakeCheck(NULL,FALSE),
								Child, RectangleObject,MUIA_Weight,200,End,
								Child, MakeLabel(_("On new mails")),
								Child, filter_new_check = MakeCheck(NULL,FALSE),
								End,
							Child, RectangleObject,MUIA_Weight,25,End,
							End,
						Child, HorizLineTextObject(_("Rules")),
						Child, VGroupV,
							Child, filter_rule_group = ColGroup(2),
								Child, HVSpace,
								Child, HVSpace,
								End,
							End,
						Child, HGroup,
							Child, filter_add_rule_button = MakeButton(_("Add new rule")),
							Child, filter_apply_now_button = MakeButton(_("Apply now")),
							End,
						Child, HorizLineTextObject(_("Action")),
						Child, VGroup,
							Child, ColGroup(3),
								Child, MakeLabel(_("Move to Folder")),
								Child, filter_move_check = MakeCheck(_("Move to Folder"),FALSE),
								Child, filter_move_popobject = PopobjectObject,
									MUIA_Disabled, TRUE,
									MUIA_Popstring_Button, PopButton(MUII_PopUp),
									MUIA_Popstring_String, filter_move_text = TextObject, TextFrame, MUIA_Background, MUII_TextBack, End,
									MUIA_Popobject_ObjStrHook, &move_objstr_hook,
									MUIA_Popobject_StrObjHook, &move_strobj_hook,
									MUIA_Popobject_Object, NListviewObject,
										MUIA_NListview_NList, filter_folder_list = FolderTreelistObject,
											End,
										End,
									End,

								Child, MakeLabel(_("Execute ARexx Script")),
								Child, filter_arexx_check = MakeCheck(_("Execute ARexx Script"),FALSE),
								Child, filter_arexx_popasl = PopaslObject,
									MUIA_Disabled, TRUE,
									MUIA_Popstring_Button, PopButton(MUII_PopFile),
									MUIA_Popstring_String, filter_arexx_string = BetterStringObject,
										StringFrame,
										MUIA_CycleChain,1,
										MUIA_String_Acknowledge, TRUE,
										End,
									End,

								Child, MakeLabel(_("Play Sound")),
								Child, filter_sound_check = MakeCheck(_("Play Sound"),FALSE),
								Child, filter_sound_string = AudioSelectGroupObject, MUIA_Disabled, TRUE, End,

								End,
							End,
						End,
					End,
				End,
			Child, HorizLineObject,
			Child, HGroup,
				Child, save_button = MakeButton(Q_("?filter:_Save")),
				Child, ok_button = MakeButton(_("_Use")),
				Child, cancel_button = MakeButton(_("_Cancel")),
				End,
			End,
		End;

	if (filter_wnd)
	{
		char *short_help_txt = _("If activated the filter will be used remotly on POP3 servers\n"
                             "which support the TOP command. Mails which matches the filter\n"
														 "are presented to the user and automatically marked as to be ignored.");

		set(filter_remote_label, MUIA_ShortHelp, short_help_txt);
		set(filter_remote_check, MUIA_ShortHelp, short_help_txt);

		DoMethod(App, OM_ADDMEMBER, (ULONG)filter_wnd);
		DoMethod(filter_wnd, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (ULONG)filter_wnd, 3, MUIM_CallHook, (ULONG)&hook_standard, (ULONG)filter_cancel);
		DoMethod(ok_button, MUIM_Notify, MUIA_Pressed, FALSE, (ULONG)filter_wnd, 3, MUIM_CallHook, (ULONG)&hook_standard, (ULONG)filter_ok);
		DoMethod(save_button, MUIM_Notify, MUIA_Pressed, FALSE, (ULONG)filter_wnd, 3, MUIM_CallHook, (ULONG)&hook_standard, (ULONG)filter_ok);
		DoMethod(save_button, MUIM_Notify, MUIA_Pressed, FALSE, (ULONG)filter_wnd, 3, MUIM_CallHook, (ULONG)&hook_standard, (ULONG)save_filter);
		DoMethod(cancel_button, MUIM_Notify, MUIA_Pressed, FALSE, (ULONG)filter_wnd, 3, MUIM_CallHook, (ULONG)&hook_standard, (ULONG)filter_cancel);

		DoMethod(filter_new_button, MUIM_Notify, MUIA_Pressed, FALSE, (ULONG)filter_wnd, 3, MUIM_CallHook, (ULONG)&hook_standard, (ULONG)filter_new);
		DoMethod(filter_remove_button, MUIM_Notify, MUIA_Pressed, FALSE, (ULONG)filter_wnd, 3, MUIM_CallHook, (ULONG)&hook_standard, (ULONG)filter_remove);
		DoMethod(filter_moveup_button, MUIM_Notify, MUIA_Pressed, FALSE, (ULONG)filter_list, 3, MUIM_NList_Move, MUIV_NList_Move_Active, MUIV_NList_Move_Previous);
		DoMethod(filter_movedown_button, MUIM_Notify, MUIA_Pressed, FALSE, (ULONG)filter_list, 3, MUIM_NList_Move, MUIV_NList_Move_Active, MUIV_NList_Move_Next);

		set(filter_name_string, MUIA_String_AttachedList, (ULONG)filter_list);
		DoMethod(filter_list, MUIM_Notify, MUIA_NList_Active, MUIV_EveryTime, (ULONG)filter_list, 3, MUIM_CallHook, (ULONG)&hook_standard, (ULONG)filter_active);
		DoMethod(filter_name_string, MUIM_Notify, MUIA_String_Contents, MUIV_EveryTime, (ULONG)filter_list, 3, MUIM_CallHook, (ULONG)&hook_standard, (ULONG)filter_name);

		DoMethod(filter_add_rule_button, MUIM_Notify, MUIA_Pressed, FALSE, (ULONG)filter_wnd, 3, MUIM_CallHook, (ULONG)&hook_standard, (ULONG)filter_add_rule_gui);
		DoMethod(filter_apply_now_button, MUIM_Notify, MUIA_Pressed, FALSE, (ULONG)filter_wnd, 3, MUIM_CallHook, (ULONG)&hook_standard, (ULONG)filter_apply);
		DoMethod(filter_move_check, MUIM_Notify, MUIA_Selected, MUIV_EveryTime, (ULONG)filter_move_popobject, 3, MUIM_Set, MUIA_Disabled, MUIV_NotTriggerValue);
		DoMethod(filter_sound_check, MUIM_Notify, MUIA_Selected, MUIV_EveryTime, (ULONG)filter_sound_string, 3, MUIM_Set, MUIA_Disabled, MUIV_NotTriggerValue);
		DoMethod(filter_arexx_check, MUIM_Notify, MUIA_Selected, MUIV_EveryTime, (ULONG)filter_arexx_popasl, 3, MUIM_Set, MUIA_Disabled, MUIV_NotTriggerValue);
		DoMethod(filter_folder_list, MUIM_Notify, MUIA_NList_DoubleClick, TRUE, (ULONG)filter_move_popobject, 2, MUIM_Popstring_Close, 1);

		filter_update_folder_list();
	}
}
Esempio n. 22
0
const char *api_intl_Q_(const char *untranslated) {
    SCRIPT_ASSERT(NULL != untranslated, NULL);
    return Q_(untranslated);
}
Esempio n. 23
0
File: help.c Progetto: CSRedRat/git
const char *help_unknown_cmd(const char *cmd)
{
	int i, n, best_similarity = 0;
	struct cmdnames main_cmds, other_cmds;

	memset(&main_cmds, 0, sizeof(main_cmds));
	memset(&other_cmds, 0, sizeof(other_cmds));
	memset(&aliases, 0, sizeof(aliases));

	git_config(git_unknown_cmd_config, NULL);

	load_command_list("git-", &main_cmds, &other_cmds);

	add_cmd_list(&main_cmds, &aliases);
	add_cmd_list(&main_cmds, &other_cmds);
	qsort(main_cmds.names, main_cmds.cnt,
	      sizeof(*main_cmds.names), cmdname_compare);
	uniq(&main_cmds);

	/* This abuses cmdname->len for levenshtein distance */
	for (i = 0, n = 0; i < main_cmds.cnt; i++) {
		int cmp = 0; /* avoid compiler stupidity */
		const char *candidate = main_cmds.names[i]->name;

		/*
		 * An exact match means we have the command, but
		 * for some reason exec'ing it gave us ENOENT; probably
		 * it's a bad interpreter in the #! line.
		 */
		if (!strcmp(candidate, cmd))
			die(_(bad_interpreter_advice), cmd, cmd);

		/* Does the candidate appear in common_cmds list? */
		while (n < ARRAY_SIZE(common_cmds) &&
		       (cmp = strcmp(common_cmds[n].name, candidate)) < 0)
			n++;
		if ((n < ARRAY_SIZE(common_cmds)) && !cmp) {
			/* Yes, this is one of the common commands */
			n++; /* use the entry from common_cmds[] */
			if (starts_with(candidate, cmd)) {
				/* Give prefix match a very good score */
				main_cmds.names[i]->len = 0;
				continue;
			}
		}

		main_cmds.names[i]->len =
			levenshtein(cmd, candidate, 0, 2, 1, 3) + 1;
	}

	qsort(main_cmds.names, main_cmds.cnt,
	      sizeof(*main_cmds.names), levenshtein_compare);

	if (!main_cmds.cnt)
		die(_("Uh oh. Your system reports no Git commands at all."));

	/* skip and count prefix matches */
	for (n = 0; n < main_cmds.cnt && !main_cmds.names[n]->len; n++)
		; /* still counting */

	if (main_cmds.cnt <= n) {
		/* prefix matches with everything? that is too ambiguous */
		best_similarity = SIMILARITY_FLOOR + 1;
	} else {
		/* count all the most similar ones */
		for (best_similarity = main_cmds.names[n++]->len;
		     (n < main_cmds.cnt &&
		      best_similarity == main_cmds.names[n]->len);
		     n++)
			; /* still counting */
	}
	if (autocorrect && n == 1 && SIMILAR_ENOUGH(best_similarity)) {
		const char *assumed = main_cmds.names[0]->name;
		main_cmds.names[0] = NULL;
		clean_cmdnames(&main_cmds);
		fprintf_ln(stderr,
			   _("WARNING: You called a Git command named '%s', "
			     "which does not exist.\n"
			     "Continuing under the assumption that you meant '%s'"),
			cmd, assumed);
		if (autocorrect > 0) {
			fprintf_ln(stderr, _("in %0.1f seconds automatically..."),
				(float)autocorrect/10.0);
			poll(NULL, 0, autocorrect * 100);
		}
		return assumed;
	}

	fprintf_ln(stderr, _("git: '%s' is not a git command. See 'git --help'."), cmd);

	if (SIMILAR_ENOUGH(best_similarity)) {
		fprintf_ln(stderr,
			   Q_("\nDid you mean this?",
			      "\nDid you mean one of these?",
			   n));

		for (i = 0; i < n; i++)
			fprintf(stderr, "\t%s\n", main_cmds.names[i]->name);
	}

	exit(1);
}
Esempio n. 24
0
static int checkout_paths(const struct checkout_opts *opts,
			  const char *revision)
{
	int pos;
	struct checkout state = CHECKOUT_INIT;
	static char *ps_matched;
	struct object_id rev;
	struct commit *head;
	int errs = 0;
	struct lock_file lock_file = LOCK_INIT;
	int nr_checkouts = 0, nr_unmerged = 0;

	trace2_cmd_mode(opts->patch_mode ? "patch" : "path");

	if (opts->track != BRANCH_TRACK_UNSPECIFIED)
		die(_("'%s' cannot be used with updating paths"), "--track");

	if (opts->new_branch_log)
		die(_("'%s' cannot be used with updating paths"), "-l");

	if (opts->force && opts->patch_mode)
		die(_("'%s' cannot be used with updating paths"), "-f");

	if (opts->force_detach)
		die(_("'%s' cannot be used with updating paths"), "--detach");

	if (opts->merge && opts->patch_mode)
		die(_("'%s' cannot be used with %s"), "--merge", "--patch");

	if (opts->force && opts->merge)
		die(_("'%s' cannot be used with %s"), "-f", "-m");

	if (opts->new_branch)
		die(_("Cannot update paths and switch to branch '%s' at the same time."),
		    opts->new_branch);

	if (opts->patch_mode)
		return run_add_interactive(revision, "--patch=checkout",
					   &opts->pathspec);

	repo_hold_locked_index(the_repository, &lock_file, LOCK_DIE_ON_ERROR);
	if (read_cache_preload(&opts->pathspec) < 0)
		return error(_("index file corrupt"));

	if (opts->source_tree)
		read_tree_some(opts->source_tree, &opts->pathspec);

	ps_matched = xcalloc(opts->pathspec.nr, 1);

	/*
	 * Make sure all pathspecs participated in locating the paths
	 * to be checked out.
	 */
	for (pos = 0; pos < active_nr; pos++)
		if (opts->overlay_mode)
			mark_ce_for_checkout_overlay(active_cache[pos],
						     ps_matched,
						     opts);
		else
			mark_ce_for_checkout_no_overlay(active_cache[pos],
							ps_matched,
							opts);

	if (report_path_error(ps_matched, &opts->pathspec, opts->prefix)) {
		free(ps_matched);
		return 1;
	}
	free(ps_matched);

	/* "checkout -m path" to recreate conflicted state */
	if (opts->merge)
		unmerge_marked_index(&the_index);

	/* Any unmerged paths? */
	for (pos = 0; pos < active_nr; pos++) {
		const struct cache_entry *ce = active_cache[pos];
		if (ce->ce_flags & CE_MATCHED) {
			if (!ce_stage(ce))
				continue;
			if (opts->force) {
				warning(_("path '%s' is unmerged"), ce->name);
			} else if (opts->writeout_stage) {
				errs |= check_stage(opts->writeout_stage, ce, pos, opts->overlay_mode);
			} else if (opts->merge) {
				errs |= check_stages((1<<2) | (1<<3), ce, pos);
			} else {
				errs = 1;
				error(_("path '%s' is unmerged"), ce->name);
			}
			pos = skip_same_name(ce, pos) - 1;
		}
	}
	if (errs)
		return 1;

	/* Now we are committed to check them out */
	state.force = 1;
	state.refresh_cache = 1;
	state.istate = &the_index;

	enable_delayed_checkout(&state);
	for (pos = 0; pos < active_nr; pos++) {
		struct cache_entry *ce = active_cache[pos];
		if (ce->ce_flags & CE_MATCHED) {
			if (!ce_stage(ce)) {
				errs |= checkout_entry(ce, &state,
						       NULL, &nr_checkouts);
				continue;
			}
			if (opts->writeout_stage)
				errs |= checkout_stage(opts->writeout_stage,
						       ce, pos,
						       &state,
						       &nr_checkouts, opts->overlay_mode);
			else if (opts->merge)
				errs |= checkout_merged(pos, &state,
							&nr_unmerged);
			pos = skip_same_name(ce, pos) - 1;
		}
	}
	remove_marked_cache_entries(&the_index, 1);
	remove_scheduled_dirs();
	errs |= finish_delayed_checkout(&state, &nr_checkouts);

	if (opts->count_checkout_paths) {
		if (nr_unmerged)
			fprintf_ln(stderr, Q_("Recreated %d merge conflict",
					      "Recreated %d merge conflicts",
					      nr_unmerged),
				   nr_unmerged);
		if (opts->source_tree)
			fprintf_ln(stderr, Q_("Updated %d path from %s",
					      "Updated %d paths from %s",
					      nr_checkouts),
				   nr_checkouts,
				   find_unique_abbrev(&opts->source_tree->object.oid,
						      DEFAULT_ABBREV));
		else if (!nr_unmerged || nr_checkouts)
			fprintf_ln(stderr, Q_("Updated %d path from the index",
					      "Updated %d paths from the index",
					      nr_checkouts),
				   nr_checkouts);
	}

	if (write_locked_index(&the_index, &lock_file, COMMIT_LOCK))
		die(_("unable to write new index file"));

	read_ref_full("HEAD", 0, &rev, NULL);
	head = lookup_commit_reference_gently(the_repository, &rev, 1);

	errs |= post_checkout_hook(head, head, 0);
	return errs;
}
Esempio n. 25
0
File: date.c Progetto: Brian1176/git
void show_date_relative(unsigned long time, int tz,
			       const struct timeval *now,
			       struct strbuf *timebuf)
{
	unsigned long diff;
	if (now->tv_sec < time) {
		strbuf_addstr(timebuf, _("in the future"));
		return;
	}
	diff = now->tv_sec - time;
	if (diff < 90) {
		strbuf_addf(timebuf,
			 Q_("%lu second ago", "%lu seconds ago", diff), diff);
		return;
	}
	/* Turn it into minutes */
	diff = (diff + 30) / 60;
	if (diff < 90) {
		strbuf_addf(timebuf,
			 Q_("%lu minute ago", "%lu minutes ago", diff), diff);
		return;
	}
	/* Turn it into hours */
	diff = (diff + 30) / 60;
	if (diff < 36) {
		strbuf_addf(timebuf,
			 Q_("%lu hour ago", "%lu hours ago", diff), diff);
		return;
	}
	/* We deal with number of days from here on */
	diff = (diff + 12) / 24;
	if (diff < 14) {
		strbuf_addf(timebuf,
			 Q_("%lu day ago", "%lu days ago", diff), diff);
		return;
	}
	/* Say weeks for the past 10 weeks or so */
	if (diff < 70) {
		strbuf_addf(timebuf,
			 Q_("%lu week ago", "%lu weeks ago", (diff + 3) / 7),
			 (diff + 3) / 7);
		return;
	}
	/* Say months for the past 12 months or so */
	if (diff < 365) {
		strbuf_addf(timebuf,
			 Q_("%lu month ago", "%lu months ago", (diff + 15) / 30),
			 (diff + 15) / 30);
		return;
	}
	/* Give years and months for 5 years or so */
	if (diff < 1825) {
		unsigned long totalmonths = (diff * 12 * 2 + 365) / (365 * 2);
		unsigned long years = totalmonths / 12;
		unsigned long months = totalmonths % 12;
		if (months) {
			struct strbuf sb = STRBUF_INIT;
			strbuf_addf(&sb, Q_("%lu year", "%lu years", years), years);
			strbuf_addf(timebuf,
				 /* TRANSLATORS: "%s" is "<n> years" */
				 Q_("%s, %lu month ago", "%s, %lu months ago", months),
				 sb.buf, months);
			strbuf_release(&sb);
		} else
			strbuf_addf(timebuf,
				 Q_("%lu year ago", "%lu years ago", years), years);
		return;
	}
	/* Otherwise, just years. Centuries is probably overkill. */
	strbuf_addf(timebuf,
		 Q_("%lu year ago", "%lu years ago", (diff + 183) / 365),
		 (diff + 183) / 365);
}
Esempio n. 26
0
extern GList *
formatGS(const statcontext * psc, const int nMatchTo, const enum _formatgs fg)
{

    GList *list = NULL;
    char **aasz;
    float aaaar[3][2][2][2];

    getMWCFromError(psc, aaaar);

    switch (fg) {
    case FORMATGS_CHEQUER:
        {

            static int ai[4] = { SKILL_NONE, SKILL_DOUBTFUL,
                SKILL_BAD, SKILL_VERYBAD
            };
            static const char *asz[4] = {
                N_("Unmarked moves"),
                N_("Moves marked doubtful"),
                N_("Moves marked bad"),
                N_("Moves marked very bad")
            };
            int i;

            /* chequer play part */

            list = g_list_append(list, numberEntry(_("Total moves"), psc->anTotalMoves[0], psc->anTotalMoves[1]));

            list = g_list_append(list, numberEntry(_("Unforced moves"),
                                                   psc->anUnforcedMoves[0], psc->anUnforcedMoves[1]));
            for (i = 0; i < 4; ++i)
                list = g_list_append(list,
                                     numberEntry(gettext(asz[i]), psc->anMoves[0][ai[i]], psc->anMoves[1][ai[i]]));

            /* total error rate */

            aasz = g_malloc(3 * sizeof(*aasz));

            aasz[0] = g_strdup_printf(_("Error total %s"), total_text(nMatchTo));

            for (i = 0; i < 2; ++i)
                aasz[i + 1] = errorRate(-aaaar[CHEQUERPLAY][TOTAL][i][NORMALISED],
                                        -aaaar[CHEQUERPLAY][TOTAL][i][UNNORMALISED], nMatchTo);

            list = g_list_append(list, aasz);

            /* error rate per move */

            aasz = g_malloc(3 * sizeof(*aasz));

            aasz[0] = g_strdup_printf(_("Error rate %s"), rate_text(nMatchTo));

            for (i = 0; i < 2; ++i)
                aasz[i + 1] = errorRateMP(-aaaar[CHEQUERPLAY][PERMOVE][i][NORMALISED],
                                          -aaaar[CHEQUERPLAY][PERMOVE][i][UNNORMALISED], nMatchTo);

            list = g_list_append(list, aasz);

            /* chequer play rating */

            aasz = g_malloc(3 * sizeof(*aasz));

            aasz[0] = g_strdup(_("Chequerplay rating"));

            for (i = 0; i < 2; ++i)
                if (psc->anUnforcedMoves[i])
                    aasz[i + 1] = g_strdup(Q_(aszRating[GetRating(aaaar[CHEQUERPLAY][PERMOVE][i][NORMALISED])]));
                else
                    aasz[i + 1] = g_strdup(_("n/a"));

            list = g_list_append(list, aasz);

        }

        break;

    case FORMATGS_CUBE:
        {
            static const char *asz[] = {
                N_("Total cube decisions"),
                N_("Close or actual cube decisions"),
                N_("Doubles"),
                N_("Takes"),
                N_("Passes")
            };

            static const char *asz2[] = {
                N_("Missed doubles below CP"),
                N_("Missed doubles above CP"),
                N_("Wrong doubles below DP"),
                N_("Wrong doubles above TG"),
                N_("Wrong takes"),
                N_("Wrong passes")
            };

            int i, j;

            const int *ai[5], *ai2[6];
            const float *af2[2][6];

            ai[0] = psc->anTotalCube;
            ai[1] = psc->anCloseCube;
            ai[2] = psc->anDouble;
            ai[3] = psc->anTake;
            ai[4] = psc->anPass;

            ai2[0] = psc->anCubeMissedDoubleDP;
            ai2[1] = psc->anCubeMissedDoubleTG;
            ai2[2] = psc->anCubeWrongDoubleDP;
            ai2[3] = psc->anCubeWrongDoubleTG;
            ai2[4] = psc->anCubeWrongTake;
            ai2[5] = psc->anCubeWrongPass;

            af2[0][0] = psc->arErrorMissedDoubleDP[0];
            af2[0][1] = psc->arErrorMissedDoubleTG[0];
            af2[0][2] = psc->arErrorWrongDoubleDP[0];
            af2[0][3] = psc->arErrorWrongDoubleTG[0];
            af2[0][4] = psc->arErrorWrongTake[0];
            af2[0][5] = psc->arErrorWrongPass[0];
            af2[1][0] = psc->arErrorMissedDoubleDP[1];
            af2[1][1] = psc->arErrorMissedDoubleTG[1];
            af2[1][2] = psc->arErrorWrongDoubleDP[1];
            af2[1][3] = psc->arErrorWrongDoubleTG[1];
            af2[1][4] = psc->arErrorWrongTake[1];
            af2[1][5] = psc->arErrorWrongPass[1];

            for (i = 0; i < 5; ++i)
                list = g_list_append(list, numberEntry(gettext(asz[i]), ai[i][0], ai[i][1]));
            for (i = 0; i < 6; ++i) {
                aasz = g_malloc(3 * sizeof(*aasz));

                aasz[0] = g_strdup_printf("%s (%s)", gettext(asz2[i]), total_text(nMatchTo));

                for (j = 0; j < 2; ++j)
                    aasz[j + 1] = cubeEntry(ai2[i][j], -af2[j][i][0], -af2[j][i][1], nMatchTo);

                list = g_list_append(list, aasz);

            }

            /* total error rate */

            aasz = g_malloc(3 * sizeof(*aasz));

            aasz[0] = g_strdup_printf(_("Error total %s"), total_text(nMatchTo));

            for (i = 0; i < 2; ++i)
                aasz[i + 1] = errorRate(-aaaar[CUBEDECISION][TOTAL][i][NORMALISED],
                                        -aaaar[CUBEDECISION][TOTAL][i][UNNORMALISED], nMatchTo);

            list = g_list_append(list, aasz);

            /* error rate per cube decision */

            aasz = g_malloc(3 * sizeof(*aasz));

            aasz[0] = g_strdup_printf(_("Error rate %s"), rate_text(nMatchTo));

            for (i = 0; i < 2; ++i)
                aasz[i + 1] = errorRateMP(-aaaar[CUBEDECISION][PERMOVE][i][NORMALISED],
                                          -aaaar[CUBEDECISION][PERMOVE][i][UNNORMALISED], nMatchTo);

            list = g_list_append(list, aasz);

            /* cube decision rating */

            aasz = g_malloc(3 * sizeof(*aasz));

            aasz[0] = g_strdup(_("Cube decision rating"));

            for (i = 0; i < 2; ++i)
                if (psc->anCloseCube[i])
                    aasz[i + 1] = g_strdup(Q_(aszRating[GetRating(aaaar[CUBEDECISION][PERMOVE][i][NORMALISED])]));
                else
                    aasz[i + 1] = g_strdup(_("n/a"));

            list = g_list_append(list, aasz);



        }
        break;

    case FORMATGS_LUCK:
        {

            static const char *asz[] = {
                N_("Rolls marked very lucky"),
                N_("Rolls marked lucky"),
                N_("Rolls unmarked"),
                N_("Rolls marked unlucky"),
                N_("Rolls marked very unlucky")
            };
            int i;

            for (i = 0; i < 5; ++i)
                list = g_list_append(list, numberEntry(gettext(asz[i]), psc->anLuck[0][4 - i], psc->anLuck[1][4 - i]));


            /* total luck */

            aasz = g_malloc(3 * sizeof(*aasz));

            aasz[0] = g_strdup_printf(_("Luck total %s"), total_text(nMatchTo));

            for (i = 0; i < 2; ++i)
                aasz[i + 1] = errorRate(psc->arLuck[i][0], psc->arLuck[i][1], nMatchTo);

            list = g_list_append(list, aasz);

            /* luck rate per move */

            aasz = g_malloc(3 * sizeof(*aasz));

            aasz[0] = g_strdup_printf(_("Luck rate %s"), rate_text(nMatchTo));

            for (i = 0; i < 2; ++i)
                if (psc->anTotalMoves[i])
                    aasz[i + 1] = errorRateMP(psc->arLuck[i][0] /
                                              psc->anTotalMoves[i], psc->arLuck[i][1] / psc->anTotalMoves[i], nMatchTo);
                else
                    aasz[i + 1] = g_strdup(_("n/a"));

            list = g_list_append(list, aasz);

            /* chequer play rating */

            aasz = g_malloc(3 * sizeof(*aasz));

            aasz[0] = g_strdup(_("Luck rating"));

            for (i = 0; i < 2; ++i)
                if (psc->anTotalMoves[i])
                    aasz[i + 1] = g_strdup(Q_(aszLuckRating[getLuckRating(psc->arLuck[i][0] / psc->anTotalMoves[i])]));
                else
                    aasz[i + 1] = g_strdup(_("n/a"));

            list = g_list_append(list, aasz);

        }
        break;

    case FORMATGS_OVERALL:

        {
            int i, n;

            /* total error rate */

            aasz = g_malloc(3 * sizeof(*aasz));

            if (psc->fCube || psc->fMoves) {

                aasz[0] = g_strdup_printf(_("Error total %s"), total_text(nMatchTo));

                for (i = 0; i < 2; ++i)
                    aasz[i + 1] = errorRate(-aaaar[COMBINED][TOTAL][i][NORMALISED],
                                            -aaaar[COMBINED][TOTAL][i][UNNORMALISED], nMatchTo);

                list = g_list_append(list, aasz);

                /* error rate per decision */

                aasz = g_malloc(3 * sizeof(*aasz));

                aasz[0] = g_strdup_printf(_("Error rate %s"), rate_text(nMatchTo));

                for (i = 0; i < 2; ++i)
                    aasz[i + 1] = errorRateMP(-aaaar[COMBINED][PERMOVE][i][NORMALISED],
                                              -aaaar[COMBINED][PERMOVE][i][UNNORMALISED], nMatchTo);

                list = g_list_append(list, aasz);

                /* eq. snowie error rate */

                aasz = g_malloc(3 * sizeof(*aasz));

                aasz[0] = g_strdup(_("Snowie error rate"));

                for (i = 0; i < 2; ++i)
                    if ((n = psc->anTotalMoves[0] + psc->anTotalMoves[1]) > 0)
                        aasz[i + 1] = errorRateMP(-aaaar[COMBINED][TOTAL][i][NORMALISED] / n, 0.0f, nMatchTo);
                    else
                        aasz[i + 1] = g_strdup(_("n/a"));

                list = g_list_append(list, aasz);

                /* rating */

                aasz = g_malloc(3 * sizeof(*aasz));

                aasz[0] = g_strdup(_("Overall rating"));

                for (i = 0; i < 2; ++i)
                    if (psc->anCloseCube[i] + psc->anUnforcedMoves[i])
                        aasz[i + 1] = g_strdup(Q_(aszRating[GetRating(aaaar[COMBINED][PERMOVE][i][NORMALISED])]));
                    else
                        aasz[i + 1] = g_strdup(_("n/a"));

                list = g_list_append(list, aasz);

            }

            if (psc->fDice) {

                /* luck adj. result */

                if ((psc->arActualResult[0] > 0.0f || psc->arActualResult[1] > 0.0f) && psc->fDice) {

                    list = g_list_append(list, luckAdjust(_("Actual result"), psc->arActualResult, nMatchTo));

                    list = g_list_append(list, luckAdjust(_("Luck adjusted result"), psc->arLuckAdj, nMatchTo));

                    if (nMatchTo) {

                        /* luck based fibs rating */

                        float r = 0.5f + psc->arActualResult[0] - psc->arLuck[0][1] + psc->arLuck[1][1];

                        aasz = g_malloc(3 * sizeof(*aasz));

                        aasz[0] = g_strdup(_("Luck based FIBS rating diff."));
                        aasz[2] = g_strdup("");

                        if (r > 0.0f && r < 1.0f)
                            aasz[1] = g_strdup_printf("%+7.2f", relativeFibsRating(r, ms.nMatchTo));
                        else
                            aasz[1] = g_strdup_printf(_("n/a"));

                        list = g_list_append(list, aasz);

                    }

                }

            }

            if (psc->fCube || psc->fMoves) {

                /* error based fibs rating */

                if (nMatchTo) {

                    aasz = g_malloc(3 * sizeof(*aasz));
                    aasz[0] = g_strdup(_("Error based abs. FIBS rating"));

                    for (i = 0; i < 2; ++i)
                        if (psc->anCloseCube[i] + psc->anUnforcedMoves[i])
                            aasz[i + 1] = g_strdup_printf("%6.1f",
                                                          absoluteFibsRating(aaaar[CHEQUERPLAY][PERMOVE][i][NORMALISED],
                                                                             aaaar[CUBEDECISION][PERMOVE][i]
                                                                             [NORMALISED], nMatchTo, rRatingOffset));
                        else
                            aasz[i + 1] = g_strdup_printf(_("n/a"));

                    list = g_list_append(list, aasz);

                    /* chequer error fibs rating */

                    aasz = g_malloc(3 * sizeof(*aasz));
                    aasz[0] = g_strdup(_("Chequerplay errors rating loss"));

                    for (i = 0; i < 2; ++i)
                        if (psc->anUnforcedMoves[i])
                            aasz[i + 1] = g_strdup_printf("%6.1f",
                                                          absoluteFibsRatingChequer(aaaar[CHEQUERPLAY][PERMOVE][i]
                                                                                    [NORMALISED], nMatchTo));
                        else
                            aasz[i + 1] = g_strdup_printf(_("n/a"));

                    list = g_list_append(list, aasz);

                    /* cube error fibs rating */

                    aasz = g_malloc(3 * sizeof(*aasz));
                    aasz[0] = g_strdup(_("Cube errors rating loss"));

                    for (i = 0; i < 2; ++i)
                        if (psc->anCloseCube[i])
                            aasz[i + 1] = g_strdup_printf("%6.1f",
                                                          absoluteFibsRatingCube(aaaar[CUBEDECISION][PERMOVE][i]
                                                                                 [NORMALISED], nMatchTo));
                        else
                            aasz[i + 1] = g_strdup_printf(_("n/a"));

                    list = g_list_append(list, aasz);

                }

            }

            if (psc->fDice && !nMatchTo && psc->nGames > 1) {

                static const char *asz[2][2] = {
                    {N_("Advantage (actual) in ppg"),
                     /* xgettext: no-c-format */
                     N_("95% confidence interval (ppg)")},
                    {N_("Advantage (luck adjusted) in ppg"),
                     /* xgettext: no-c-format */
                     N_("95% confidence interval (ppg)")}
                };
                int i, j;
                const float *af[2][2];
                af[0][0] = psc->arActualResult;
                af[0][1] = psc->arVarianceActual;
                af[1][0] = psc->arLuckAdj;
                af[1][1] = psc->arVarianceLuckAdj;

                for (i = 0; i < 2; ++i) {

                    /* ppg */

                    aasz = g_malloc(3 * sizeof(*aasz));
                    aasz[0] = g_strdup(gettext(asz[i][0]));

                    for (j = 0; j < 2; ++j)
                        aasz[j + 1] =
                            g_strdup_printf("%+*.*f", fOutputDigits + 3, fOutputDigits, af[i][0][j] / psc->nGames);

                    list = g_list_append(list, aasz);

                    /* std dev. */

                    aasz = g_malloc(3 * sizeof(*aasz));
                    aasz[0] = g_strdup(gettext(asz[i][1]));

                    for (j = 0; j < 2; ++j) {
                        float ci = 1.95996f * sqrtf(af[i][1][j] / psc->nGames);
                        float max = af[i][0][j] + ci;
                        float min = af[i][0][j] - ci;
                        aasz[j + 1] = g_strdup_printf("[%*.*f,%*.*f]",
                                                      fOutputDigits + 3, fOutputDigits, min,
                                                      fOutputDigits + 3, fOutputDigits, max);
                    }
                    list = g_list_append(list, aasz);

                }


            }

        }

        break;

    default:

        g_assert_not_reached();
        break;

    }

    return list;


}
Esempio n. 27
0
/* event callback */
gboolean
help_interactive_display (const gchar * event_group_name, const gchar * event_name,
                          gpointer init_data, gpointer data)
{
    const dlg_colors_t help_colors = {
        HELP_NORMAL_COLOR,      /* common text color */
        0,                      /* unused in help */
        HELP_BOLD_COLOR,        /* bold text color */
        0,                      /* unused in help */
        HELP_TITLE_COLOR        /* title color */
    };

    WButtonBar *help_bar;
    Widget *md;
    char *hlpfile = NULL;
    char *filedata;
    ev_help_t *event_data = (ev_help_t *) data;

    (void) event_group_name;
    (void) event_name;
    (void) init_data;

    if (event_data->filename != NULL)
        g_file_get_contents (event_data->filename, &filedata, NULL, NULL);
    else
        filedata = load_mc_home_file (mc_global.share_data_dir, MC_HELP, &hlpfile);

    if (filedata == NULL)
        message (D_ERROR, MSG_ERROR, _("Cannot open file %s\n%s"),
                 event_data->filename ? event_data->filename : hlpfile, unix_error_string (errno));

    g_free (hlpfile);

    if (filedata == NULL)
        return TRUE;

    translate_file (filedata);

    g_free (filedata);

    if (fdata == NULL)
        return TRUE;

    if ((event_data->node == NULL) || (*event_data->node == '\0'))
        event_data->node = "[main]";

    main_node = search_string (fdata, event_data->node);

    if (main_node == NULL)
    {
        message (D_ERROR, MSG_ERROR, _("Cannot find node %s in help file"), event_data->node);

        /* Fallback to [main], return if it also cannot be found */
        main_node = search_string (fdata, "[main]");
        if (main_node == NULL)
        {
            interactive_display_finish ();
            return TRUE;
        }
    }

    help_lines = min (LINES - 4, max (2 * LINES / 3, 18));

    whelp =
        dlg_create (TRUE, 0, 0, help_lines + 4, HELP_WINDOW_WIDTH + 4,
                    help_colors, help_callback, NULL, "[Help]", _("Help"),
                    DLG_TRYUP | DLG_CENTER | DLG_WANT_TAB);

    selected_item = search_string_node (main_node, STRING_LINK_START) - 1;
    currentpoint = main_node + 1;       /* Skip the newline following the start of the node */

    for (history_ptr = HISTORY_SIZE; history_ptr;)
    {
        history_ptr--;
        history[history_ptr].page = currentpoint;
        history[history_ptr].link = selected_item;
    }

    help_bar = buttonbar_new (TRUE);
    WIDGET (help_bar)->y -= WIDGET (whelp)->y;
    WIDGET (help_bar)->x -= WIDGET (whelp)->x;

    md = mousedispatch_new (1, 1, help_lines, HELP_WINDOW_WIDTH - 2);

    add_widget (whelp, md);
    add_widget (whelp, help_bar);

    buttonbar_set_label (help_bar, 1, Q_ ("ButtonBar|Help"), help_map, NULL);
    buttonbar_set_label (help_bar, 2, Q_ ("ButtonBar|Index"), help_map, NULL);
    buttonbar_set_label (help_bar, 3, Q_ ("ButtonBar|Prev"), help_map, NULL);
    buttonbar_set_label (help_bar, 4, "", help_map, NULL);
    buttonbar_set_label (help_bar, 5, "", help_map, NULL);
    buttonbar_set_label (help_bar, 6, "", help_map, NULL);
    buttonbar_set_label (help_bar, 7, "", help_map, NULL);
    buttonbar_set_label (help_bar, 8, "", help_map, NULL);
    buttonbar_set_label (help_bar, 9, "", help_map, NULL);
    buttonbar_set_label (help_bar, 10, Q_ ("ButtonBar|Quit"), help_map, NULL);

    dlg_run (whelp);
    interactive_display_finish ();
    dlg_destroy (whelp);
    return TRUE;
}
Esempio n. 28
0
File: display.c Progetto: artzub/mc
static void
mcview_set_buttonbar (mcview_t * view)
{
    Dlg_head *h = view->widget.owner;
    WButtonBar *b = find_buttonbar (h);
    const global_keymap_t *keymap = view->hex_mode ? viewer_hex_map : viewer_map;

    buttonbar_set_label (b, 1, Q_ ("ButtonBar|Help"), keymap, (Widget *) view);

    if (view->hex_mode)
    {
        if (view->hexedit_mode)
            buttonbar_set_label (b, 2, Q_ ("ButtonBar|View"), keymap, (Widget *) view);
        else if (view->datasource == DS_FILE)
            buttonbar_set_label (b, 2, Q_ ("ButtonBar|Edit"), keymap, (Widget *) view);
        else
            buttonbar_set_label (b, 2, "", keymap, (Widget *) view);

        buttonbar_set_label (b, 4, Q_ ("ButtonBar|Ascii"), keymap, (Widget *) view);
        buttonbar_set_label (b, 6, Q_ ("ButtonBar|Save"), keymap, (Widget *) view);
        buttonbar_set_label (b, 7, Q_ ("ButtonBar|HxSrch"), keymap, (Widget *) view);

    }
    else
    {
        buttonbar_set_label (b, 2, view->text_wrap_mode ? Q_ ("ButtonBar|UnWrap")
                             : Q_ ("ButtonBar|Wrap"), keymap, (Widget *) view);
        buttonbar_set_label (b, 4, Q_ ("ButtonBar|Hex"), keymap, (Widget *) view);
        buttonbar_set_label (b, 6, "", keymap, (Widget *) view);
        buttonbar_set_label (b, 7, Q_ ("ButtonBar|Search"), keymap, (Widget *) view);
    }

    buttonbar_set_label (b, 5, Q_ ("ButtonBar|Goto"), keymap, (Widget *) view);
    buttonbar_set_label (b, 8, view->magic_mode ? Q_ ("ButtonBar|Raw")
                         : Q_ ("ButtonBar|Parse"), keymap, (Widget *) view);

    if (mcview_is_in_panel (view))
        buttonbar_set_label (b, 10, "", keymap, (Widget *) view);
    else
    {
        /* don't override some panel buttonbar keys  */
        buttonbar_set_label (b, 3, Q_ ("ButtonBar|Quit"), keymap, (Widget *) view);
        buttonbar_set_label (b, 9, view->text_nroff_mode ? Q_ ("ButtonBar|Unform")
                             : Q_ ("ButtonBar|Format"), keymap, (Widget *) view);
        buttonbar_set_label (b, 10, Q_ ("ButtonBar|Quit"), keymap, (Widget *) view);
    }
}
Esempio n. 29
0
void
VFont::ReadFontDef (/*[in]*/ InputStream &	inputStream,
		    /*[in]*/ short		fntDefX)
{
  int fontNum;

  switch (fntDefX)
    {
    case fnt_def1:
      fontNum = inputStream.ReadByte();
      break;
    case fnt_def2:
      fontNum = inputStream.ReadPair();
      break;
    case fnt_def3:
      fontNum = inputStream.ReadTrio();
      break;
    case fnt_def4:
      fontNum = inputStream.ReadSignedQuad();
      break;
    default:
      FATAL_DVI_ERROR ("VFont::ReadFontDef",
		       T_("Bad VF file."),
		       dviInfo.fileName.c_str());
      break;
    }

  trace_vfont->WriteFormattedLine
    ("libdvi",
     T_("defining font %d"),
     fontNum);

  int cs = inputStream.ReadSignedQuad();
  int ss = inputStream.ReadSignedQuad();
  int ds = inputStream.ReadSignedQuad();

  int areaNameSize = inputStream.ReadByte();
  int fontNameSize = inputStream.ReadByte();

  char szArea[256];
  inputStream.Read (szArea, areaNameSize);
  szArea[areaNameSize] = 0;

  char szName[256];
  inputStream.Read (szName, fontNameSize);
  szName[fontNameSize] = 0;

  trace_vfont->WriteFormattedLine
    ("libdvi",
     "areaname: %s",
     szArea);
  trace_vfont->WriteFormattedLine
    ("libdvi",
     "fontname: %s",
     szName);
  trace_vfont->WriteFormattedLine
    ("libdvi",
     "checkSum: 0%o",
     cs);
  trace_vfont->WriteFormattedLine
    ("libdvi",
     "scaledSize: %d",
     ss);
  trace_vfont->WriteFormattedLine
    ("libdvi",
     "designSize: %d",
     ds);
  
  DviFont * pFont;
  PathName fileName;
  if (SessionWrapper(true)->FindFile(szName, FileType::VF, fileName))
    {
      trace_vfont->WriteFormattedLine
	("libdvi",
	 T_("found vf file %s"),
	 Q_(fileName));
      pFont =
	new VFont (pDviImpl,
		   cs,
		   ScaleFix(ss, scaledAt),
		   static_cast<int>(ds * tfmConv),
		   szArea,
		   szName,
		   fileName.Get(),
		   tfmConv,
		   conv,
		   mag,
		   metafontMode.c_str(),
		   baseDpi);
    }
  else if (pDviImpl->GetPageMode() != DviPageMode::Dvips)
    {
      pFont =
	new PkFont (pDviImpl,
		    cs,
		    ScaleFix(ss, scaledAt),
		    static_cast<int>(ds * tfmConv),
		    szArea,
		    szName,
		    "",
		    tfmConv,
		    conv,
		    mag,
		    metafontMode.c_str(),
		    baseDpi);
    }
  else
    {
      pFont =
	new Tfm (pDviImpl,
		 cs,
		 ScaleFix(ss, scaledAt),
		 static_cast<int>(ds * tfmConv),
		 szArea,
		 szName,
		 "",
		 tfmConv,
		 conv);
    }

  fontMap[fontNum] = pFont;
}
Esempio n. 30
0
namespace Widget {

//===================================================

const struct rdf_license_t _proprietary_license =
{_("Proprietary"), "", 0};

const struct rdf_license_t _other_license =
{Q_("MetadataLicence|Other"), "", 0};

class LicenseItem : public Gtk::RadioButton {
public:
    LicenseItem (struct rdf_license_t const* license, EntityEntry* entity, Registry &wr);
protected:
    void on_toggled();
    struct rdf_license_t const *_lic;
    EntityEntry                *_eep;
    Registry                   &_wr;
};

LicenseItem::LicenseItem (struct rdf_license_t const* license, EntityEntry* entity, Registry &wr)
    : Gtk::RadioButton(_(license->name)), _lic(license), _eep(entity), _wr(wr)
{
    static Gtk::RadioButtonGroup group = get_group();
    static bool first = true;
    if (first) first = false;
    else       set_group (group);
}

/// \pre it is assumed that the license URI entry is a Gtk::Entry
void
LicenseItem::on_toggled()
{
    if (_wr.isUpdating()) return;

    _wr.setUpdating (true);
    rdf_set_license (SP_ACTIVE_DOCUMENT, _lic->details ? _lic : 0);
    sp_document_done (SP_ACTIVE_DOCUMENT, SP_VERB_NONE,
                      /* TODO: annotate */ "licensor.cpp:65");
    _wr.setUpdating (false);
    static_cast<Gtk::Entry*>(_eep->_packable)->set_text (_lic->uri);
    _eep->on_changed();
}

//---------------------------------------------------

Licensor::Licensor()
    : Gtk::VBox(false,4)
{
}

Licensor::~Licensor()
{
    if (_eentry) delete _eentry;
}

void
Licensor::init (Gtk::Tooltips& tt, Registry& wr)
{
    /* add license-specific metadata entry areas */
    rdf_work_entity_t* entity = rdf_find_entity ( "license_uri" );
    _eentry = EntityEntry::create (entity, tt, wr);

    LicenseItem *i;
    wr.setUpdating (true);
    i = manage (new LicenseItem (&_proprietary_license, _eentry, wr));
    add (*i);
    LicenseItem *pd = i;

    for (struct rdf_license_t * license = rdf_licenses;
            license && license->name;
            license++) {
        i = manage (new LicenseItem (license, _eentry, wr));
        add(*i);
    }
    // add Other at the end before the URI field for the confused ppl.
    LicenseItem *io = manage (new LicenseItem (&_other_license, _eentry, wr));
    add (*io);

    pd->set_active();
    wr.setUpdating (false);

    Gtk::HBox *box = manage (new Gtk::HBox);
    pack_start (*box, true, true, 0);

    box->pack_start (_eentry->_label, false, false, 5);
    box->pack_start (*_eentry->_packable, true, true, 0);

    show_all_children();
}

void
Licensor::update (SPDocument *doc)
{
    /* identify the license info */
    struct rdf_license_t * license = rdf_get_license (doc);

    if (license) {
        int i;
        for (i=0; rdf_licenses[i].name; i++)
            if (license == &rdf_licenses[i])
                break;
        static_cast<LicenseItem*>(children()[i+1].get_widget())->set_active();
    }
    else {
        static_cast<LicenseItem*>(children()[0].get_widget())->set_active();
    }

    /* update the URI */
    _eentry->update (doc);
}

} // namespace Dialog