Example #1
0
static void
buoh_view_init (BuohView *buoh_view)
{
        GtkWidget *label;
        GtkWidget *swindow;

	gtk_widget_set_can_focus (GTK_WIDGET (buoh_view), TRUE);
	
        buoh_view->priv = BUOH_VIEW_GET_PRIVATE (buoh_view);

	buoh_view->priv->status = STATE_MESSAGE_WELCOME;

	/* Image view */
        swindow = gtk_scrolled_window_new (NULL, NULL);
        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
                                        GTK_POLICY_AUTOMATIC,
                                        GTK_POLICY_AUTOMATIC);
	buoh_view->priv->comic = buoh_view_comic_new (buoh_view);
	gtk_container_add (GTK_CONTAINER (swindow),
			   buoh_view->priv->comic);
	gtk_widget_show (buoh_view->priv->comic);
	
        gtk_notebook_insert_page (GTK_NOTEBOOK (buoh_view), swindow,
                                  NULL, VIEW_PAGE_IMAGE);
        gtk_widget_show (swindow);

        /* Message view */
	swindow = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
					GTK_POLICY_NEVER,
					GTK_POLICY_NEVER);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swindow),
					     GTK_SHADOW_NONE);
	buoh_view->priv->message = buoh_view_message_new ();
	buoh_view_message_set_title (BUOH_VIEW_MESSAGE (buoh_view->priv->message),
				     _("Buoh online comic strips reader"));
	buoh_view_message_set_text (BUOH_VIEW_MESSAGE (buoh_view->priv->message),
				    _("Welcome to <b>Buoh</b>, the online comics reader for GNOME Desktop.\n"
				      "The list on the left panel contains your favourite comic strips "
				      "to add or remove comics to the list click on Comic -> Add. "
				      "Just select a comic from the list, and it will be displayed "
				      "on the right side. Thanks for using Buoh."));
	buoh_view_message_set_icon (BUOH_VIEW_MESSAGE (buoh_view->priv->message), "buoh");
	gtk_container_add (GTK_CONTAINER (swindow),
			   buoh_view->priv->message);
	gtk_widget_show (buoh_view->priv->message);
	
        gtk_notebook_insert_page (GTK_NOTEBOOK (buoh_view), swindow,
                                  NULL, VIEW_PAGE_MESSAGE);
        gtk_widget_show (swindow);

        /* Empty view */
        label = gtk_label_new (NULL);
        gtk_notebook_insert_page (GTK_NOTEBOOK (buoh_view), label,
                                  NULL, VIEW_PAGE_EMPTY);
        gtk_widget_show (label);

	
        gtk_notebook_set_current_page (GTK_NOTEBOOK (buoh_view), VIEW_PAGE_MESSAGE);

        /* Callbacks */
        g_signal_connect (G_OBJECT (buoh_view), "notify::status",
                          G_CALLBACK (buoh_view_status_changed_cb),
                          NULL);
	g_signal_connect (G_OBJECT (buoh_view->priv->comic),
			  "notify::scale",
			  G_CALLBACK (buoh_view_scale_changed_cb),
			  (gpointer) buoh_view);

        gtk_widget_show (GTK_WIDGET (buoh_view));
}
Example #2
0
static virNetSocketPtr virNetSocketNew(virSocketAddrPtr localAddr,
                                       virSocketAddrPtr remoteAddr,
                                       bool isClient,
                                       int fd, int errfd, pid_t pid)
{
    virNetSocketPtr sock;
    int no_slow_start = 1;

    VIR_DEBUG("localAddr=%p remoteAddr=%p fd=%d errfd=%d pid=%lld",
              localAddr, remoteAddr,
              fd, errfd, (long long) pid);

    if (virSetCloseExec(fd) < 0) {
        virReportSystemError(errno, "%s",
                             _("Unable to set close-on-exec flag"));
       return NULL;
    }
    if (virSetNonBlock(fd) < 0) {
        virReportSystemError(errno, "%s",
                             _("Unable to enable non-blocking flag"));
        return NULL;
    }

    if (VIR_ALLOC(sock) < 0) {
        virReportOOMError();
        return NULL;
    }

    if (virMutexInit(&sock->lock) < 0) {
        virReportSystemError(errno, "%s",
                             _("Unable to initialize mutex"));
        VIR_FREE(sock);
        return NULL;
    }
    sock->refs = 1;

    if (localAddr)
        sock->localAddr = *localAddr;
    if (remoteAddr)
        sock->remoteAddr = *remoteAddr;
    sock->fd = fd;
    sock->errfd = errfd;
    sock->pid = pid;

    /* Disable nagle for TCP sockets */
    if (sock->localAddr.data.sa.sa_family == AF_INET ||
        sock->localAddr.data.sa.sa_family == AF_INET6) {
        if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY,
                       &no_slow_start,
                       sizeof(no_slow_start)) < 0) {
            virReportSystemError(errno, "%s",
                                 _("Unable to disable nagle algorithm"));
            goto error;
        }
    }


    if (localAddr &&
        !(sock->localAddrStr = virSocketAddrFormatFull(localAddr, true, ";")))
        goto error;

    if (remoteAddr &&
        !(sock->remoteAddrStr = virSocketAddrFormatFull(remoteAddr, true, ";")))
        goto error;

    sock->client = isClient;

    PROBE(RPC_SOCKET_NEW,
          "sock=%p refs=%d fd=%d errfd=%d pid=%lld localAddr=%s, remoteAddr=%s",
          sock, sock->refs, fd, errfd, (long long) pid,
          NULLSTR(sock->localAddrStr), NULLSTR(sock->remoteAddrStr));

    return sock;

error:
    sock->fd = sock->errfd = -1; /* Caller owns fd/errfd on failure */
    virNetSocketFree(sock);
    return NULL;
}
Example #3
0
int virNetSocketNewListenUNIX(const char *path,
                              mode_t mask,
                              uid_t user,
                              gid_t grp,
                              virNetSocketPtr *retsock)
{
    virSocketAddr addr;
    mode_t oldmask;
    int fd;

    *retsock = NULL;

    memset(&addr, 0, sizeof(addr));

    addr.len = sizeof(addr.data.un);

    if ((fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
        virReportSystemError(errno, "%s", _("Failed to create socket"));
        goto error;
    }

    addr.data.un.sun_family = AF_UNIX;
    if (virStrcpyStatic(addr.data.un.sun_path, path) == NULL) {
        virReportSystemError(ENAMETOOLONG,
                             _("Path %s too long for unix socket"), path);
        goto error;
    }
    if (addr.data.un.sun_path[0] == '@')
        addr.data.un.sun_path[0] = '\0';
    else
        unlink(addr.data.un.sun_path);

    oldmask = umask(~mask);

    if (bind(fd, &addr.data.sa, addr.len) < 0) {
        umask(oldmask);
        virReportSystemError(errno,
                             _("Failed to bind socket to '%s'"),
                             path);
        goto error;
    }
    umask(oldmask);

    /* chown() doesn't work for abstract sockets but we use them only
     * if libvirtd runs unprivileged
     */
    if (grp != 0 && chown(path, user, grp)) {
        virReportSystemError(errno,
                             _("Failed to change ownership of '%s' to %d:%d"),
                             path, (int) user, (int) grp);
        goto error;
    }

    if (!(*retsock = virNetSocketNew(&addr, NULL, false, fd, -1, 0)))
        goto error;

    return 0;

error:
    if (path[0] != '@')
        unlink(path);
    VIR_FORCE_CLOSE(fd);
    return -1;
}
Example #4
0
/* Draws the help screen */
void
help_screen (void)
{
  enum {
    MOVE_UP,
    MOVE_DOWN,
    MOVE_LEFT,
    MOVE_RIGHT,
    DIRECTIONS
  };
  struct scrollwin hwin;
  int need_resize;
  enum key ch = KEY_GENERIC_HELP;
  int page, oldpage;
  help_page_t hscr[HELPSCREENS];
  char keystr[DIRECTIONS][BUFSIZ];

  hscr[HELP_MAIN].title =
    _("       Welcome to Calcurse. This is the main help screen.\n");
  (void)snprintf (hscr[HELP_MAIN].text, HELPTEXTSIZ,
    _("Moving around:  Press '%s' or '%s' to scroll text upward or downward\n"
      "                inside help screens, if necessary.\n\n"
      "    Exit help:  When finished, press '%s' to exit help and go back to\n"
      "                the main Calcurse screen.\n\n"
      "   Help topic:  At the bottom of this screen you can see a panel with\n"
      "                different fields, represented by a letter and a short\n"
      "                title. This panel contains all the available actions\n"
      "                you can perform when using Calcurse.\n"
      "                By pressing one of the letters appearing in this\n"
      "                panel, you will be shown a short description of the\n"
      "                corresponding action. At the top right side of the\n"
      "                description screen are indicated the user-defined key\n"
      "                bindings that lead to the action.\n\n"
      "      Credits:  Press '%s' for credits."),
            keys_action_firstkey (KEY_GENERIC_SCROLL_UP),
            keys_action_firstkey (KEY_GENERIC_SCROLL_DOWN),
            keys_action_firstkey (KEY_GENERIC_QUIT),
            keys_action_firstkey (KEY_GENERIC_CREDITS));

  hscr[HELP_SAVE].title = _("Save\n");
  (void)snprintf (hscr[HELP_SAVE].text, HELPTEXTSIZ,
    _("Save calcurse data.\n"
      "Data are splitted into four different files which contain :"
      "\n\n"
      "         / ~/.calcurse/conf -> user configuration\n"
      "        |                      (layout, color, general options)\n"
      "        |  ~/.calcurse/apts -> data related to the appointments\n"
      "        |  ~/.calcurse/todo -> data related to the todo list\n"
      "         \\ ~/.calcurse/keys -> user-defined key bindings\n"
      "\nIn the config menu, you can choose to save the Calcurse data\n"
      "automatically before quitting."));

  hscr[HELP_IMPORT].title = _("Import\n");
  (void)snprintf (hscr[HELP_IMPORT].text, HELPTEXTSIZ,
    _("Import data from an icalendar file.\n"
      "You will be asked to enter the file name from which to load ical\n"
      "items. At the end of the import process, and if the general option\n"
      "'skip_system_dialogs' is not set to 'yes', a report indicating how\n"
      "many items were imported is shown.\n"
      "This report contains the total number of lines read, the number of\n"
      "appointments, events and todo items which were successfully imported,\n"
      "together with the number of items for which problems occured and that\n"
      "were skipped, if any.\n\n"
      "If one or more items could not be imported, one has the possibility to\n"
      "read the import process report in order to identify which problems\n"
      "occured.\n"
      "In this report is shown one item per line, with the line in the input\n"
      "stream at which this item begins, together with the description of why\n"
      "the item could not be imported.\n"));

  hscr[HELP_EXPORT].title = _("Export\n");
  (void)snprintf (hscr[HELP_EXPORT].text, HELPTEXTSIZ,
    _("Export calcurse data (appointments, events and todos).\n"
      "This leads to the export submenu, from which you can choose between\n"
      "two different export formats: 'ical' and 'pcal'. Choosing one of\n"
      "those formats lets you export calcurse data to icalendar or pcal\n"
      "format.\n\n"
      "You first need to specify the file to which the data will be exported.\n"
      "By default, this file is:\n\n"
      "     ~/calcurse.ics\n\n"
      "for an ical export, and:\n\n"
      "     ~/calcurse.txt\n\n"
      "for a pcal export.\n\n"
      "Calcurse data are exported in the following order:\n"
      "     events, appointments, todos.\n"));

  (void)strncpy (keystr[MOVE_UP], keys_action_allkeys (KEY_MOVE_UP), BUFSIZ);
  (void)strncpy (keystr[MOVE_DOWN], keys_action_allkeys (KEY_MOVE_DOWN),
                 BUFSIZ);
  (void)strncpy (keystr[MOVE_LEFT], keys_action_allkeys (KEY_MOVE_LEFT),
                 BUFSIZ);
  (void)strncpy (keystr[MOVE_RIGHT], keys_action_allkeys (KEY_MOVE_RIGHT),
                 BUFSIZ);
  hscr[HELP_DISPLACEMENT].title = _("Displacement keys\n");
  (void)snprintf (hscr[HELP_DISPLACEMENT].text, HELPTEXTSIZ,
    _("Move around inside calcurse screens.\n"
      "The following scheme summarizes how to get around:\n\n"
      "                               move up\n"
      "                        move to previous week\n"
      "\n"
      "                                 %s\n"
      "       move left                  ^  \n"
      " move to previous day             |\n"
      "                      %s\n"
      "                            <--   +  -->\n"
      "                                           %s\n"
      "                                  |            move right\n"
      "                                  v         move to next day\n"
      "                                 %s\n"
      "\n"
      "                          move to next week\n"
      "                              move down\n"
      "\nMoreover, while inside the calendar panel, the '%s' key moves\n"
      "to the first day of the week, and the '%s' key selects the last day of\n"
      "the week.\n"),
            keystr[MOVE_UP], keystr[MOVE_LEFT],
            keystr[MOVE_RIGHT], keystr[MOVE_DOWN],
            keys_action_firstkey (KEY_START_OF_WEEK),
            keys_action_firstkey (KEY_END_OF_WEEK));

  hscr[HELP_VIEW].title = _("View\n");
  (void)snprintf (hscr[HELP_VIEW].text, HELPTEXTSIZ,
    _("View the item you select in either the Todo or Appointment panel.\n"
      "\nThis is usefull when an event description is longer than the "
      "available\nspace to display it. "
      "If that is the case, the description will be\n"
      "shortened and its end replaced by '...'. To be able to read the entire\n"
      "description, just press '%s' and a popup window will appear, containing\n"
      "the whole event.\n"
      "\nPress any key to close the popup window and go back to the main\n"
      "Calcurse screen."),
      keys_action_firstkey (KEY_VIEW_ITEM));

  hscr[HELP_PIPE].title = _("Pipe\n");
  (void)snprintf (hscr[HELP_PIPE].text, HELPTEXTSIZ,
    _("Pipe the selected item to an external program.\n"
      "\nPress the '%s' key to pipe the currently selected appointment or\n"
      "todo entry to an external program.\n"
      "\nYou will be driven back to calcurse as soon as the program exits.\n"),
      keys_action_firstkey (KEY_PIPE_ITEM));

  hscr[HELP_TAB].title = _("Tab\n");
  (void)snprintf (hscr[HELP_TAB].text, HELPTEXTSIZ,
    _("Switch between panels.\n"
      "The panel currently in use has its border colorized.\n"
      "\nSome actions are possible only if the right panel is selected.\n"
      "For example, if you want to add a task in the TODO list, you need first"
      "\nto press the '%s' key to get the TODO panel selected. Then you can\n"
      "press '%s' to add your item.\n"
      "\nNotice that at the bottom of the screen the list of possible actions\n"
      "change while pressing '%s', so you always know what action can be\n"
      "performed on the selected panel."),
            keys_action_firstkey (KEY_GENERIC_CHANGE_VIEW),
            keys_action_firstkey (KEY_ADD_ITEM),
            keys_action_firstkey (KEY_GENERIC_CHANGE_VIEW));

  hscr[HELP_GOTO].title = _("Goto\n");
  (void)snprintf (hscr[HELP_GOTO].text, HELPTEXTSIZ,
    _("Jump to a specific day in the calendar.\n"
      "\nUsing this command, you do not need to travel to that day using\n"
      "the displacement keys inside the calendar panel.\n"
      "If you hit [ENTER] without specifying any date, Calcurse checks the\n"
      "system current date and you will be taken to that date.\n"
      "\nNotice that pressing '%s', whatever panel is\n"
      "selected, will select current day in the calendar."),
            keys_action_firstkey (KEY_GENERIC_GOTO_TODAY));

  hscr[HELP_DELETE].title = _("Delete\n");
  (void)snprintf (hscr[HELP_DELETE].text, HELPTEXTSIZ,
    _("Delete an element in the ToDo or Appointment list.\n"
      "\nDepending on which panel is selected when you press the delete key,\n"
      "the hilighted item of either the ToDo or Appointment list will be \n"
      "removed from this list.\n"
      "\nIf the item to be deleted is recurrent, you will be asked if you\n"
      "wish to suppress all of the item occurences or just the one you\n"
      "selected.\n"
      "\nIf the general option 'confirm_delete' is set to 'YES', then you will"
      "\nbe asked for confirmation before deleting the selected event.\n"
      "Do not forget to save the calendar data to retrieve the modifications\n"
      "next time you launch Calcurse."));

  hscr[HELP_ADD].title = _("Add\n");
  (void)snprintf (hscr[HELP_ADD].text, HELPTEXTSIZ,
    _("Add an item in either the ToDo or Appointment list, depending on which\n"
      "panel is selected when you press '%s'.\n"
      "\nTo enter a new item in the TODO list, you will need first to enter the"
      "\ndescription of this new item. Then you will be asked to specify the "
      "todo\npriority. This priority is represented by a number going from 9 "
      "for the\nlowest priority, to 1 for the highest one. It is still "
      "possible to\nchange the item priority afterwards, by using the '%s' and "
      "'%s' keys\ninside the todo panel.\n"
      "\nIf the APPOINTMENT panel is selected while pressing '%s', you will be\n"
      "able to enter either a new appointment or a new all-day long event.\n"
      "To enter a new event, press [ENTER] instead of the item start time, "
      "and\njust fill in the event description.\n"
      "To enter a new appointment to be added in the APPOINTMENT list, you\n"
      "will need to enter successively the time at which the appointment\n"
      "begins, the appointment length (either by specifying the duration in\n"
      "minutes, or the end time in [hh:mm] or [h:mm] format), and the\n"
      "description of the event.\n"
      "\nThe day at which occurs the event or appointment is the day currently"
      "\nselected in the calendar, so you need to move to the desired day "
      "before\npressing '%s'.\n" "\nNotes:\n"
      "     o if an appointment lasts for such a long time that it continues\n"
      "       on the next days, this event will be indicated on all the\n"
      "       corresponding days, and the beginning or ending hour will be\n"
      "       replaced by '..' if the event does not begin or end on the day.\n"
      "     o if you only press [ENTER] at the APPOINTMENT or TODO event\n"
      "       description prompt, without any description, no item will be\n"
      "       added.\n"
      "     o do not forget to save the calendar data to retrieve the new\n"
      "       event next time you launch Calcurse."),
            keys_action_firstkey (KEY_ADD_ITEM),
            keys_action_firstkey (KEY_RAISE_PRIORITY),
            keys_action_firstkey (KEY_LOWER_PRIORITY),
            keys_action_firstkey (KEY_ADD_ITEM),
            keys_action_firstkey (KEY_ADD_ITEM));

  hscr[HELP_CUT_PASTE].title = _("Cut and Paste\n");
  (void)snprintf (hscr[HELP_CUT_PASTE].text, HELPTEXTSIZ,
  _("Cut and paste the currently selected item. This is useful to quickly\n"
    "move an item from one date to another.\n"
    "To do so, one must first highlight the item that needs to be moved,\n"
    "then press '%s' to cut this item. It will be removed from the panel.\n"
    "Once the new date is chosen in the calendar, the appointment panel must\n"
    "be selected and the '%s' key must be pressed to paste the item.\n"
    "The item will appear again in the appointment panel, assigned to the\n"
    "newly selected date.\n\n"
    "Be careful that if two cuts are performed successively without pasting\n"
    "between them, the item that was cut at first will be lost, together\n"
    "with its associated note if it had one."),
                  keys_action_firstkey (KEY_GENERIC_CUT),
                  keys_action_firstkey (KEY_GENERIC_PASTE));

  hscr[HELP_EDIT].title = _("Edit Item\n");
  (void)snprintf (hscr[HELP_EDIT].text, HELPTEXTSIZ,
    _("Edit the item which is currently selected.\n"
      "Depending on the item type (appointment, event, or todo), and if it is\n"
      "repeated or not, you will be asked to choose one of the item properties"
      "\nto modify. An item property is one of the following: the start time, "
      "the\nend time, the description, or the item repetition.\n"
      "Once you have chosen the property you want to modify, you will be shown"
      "\nits actual value, and you will be able to change it as you like.\n"
      "\nNotes:\n"
      "     o if you choose to edit the item repetition properties, you will\n"
      "       be asked to re-enter all of the repetition characteristics\n"
      "       (repetition type, frequence, and ending date). Moreover, the\n"
      "       previous data concerning the deleted occurences will be lost.\n"
      "     o do not forget to save the calendar data to retrieve the\n"
      "       modified properties next time you launch Calcurse."));

  hscr[HELP_ENOTE].title = _("EditNote\n");
  (void)snprintf (hscr[HELP_ENOTE].text, HELPTEXTSIZ,
    _("Attach a note to any type of item, or edit an already existing note.\n"
      "This feature is useful if you do not have enough space to store all\n"
      "of your item description, or if you would like to add sub-tasks to an\n"
      "already existing todo item for example.\n"
      "Before pressing the '%s' key, you first need to highlight the item you\n"
      "want the note to be attached to. Then you will be driven to an\n"
      "external editor to edit your note. This editor is chosen the following\n"
      "way:\n"
      "     o if the 'VISUAL' environment variable is set, then this will be\n"
      "       the default editor to be called.\n"
      "     o if 'VISUAL' is not set, then the 'EDITOR' environment variable\n"
      "       will be used as the default editor.\n"
      "     o if none of the above environment variables is set, then\n"
      "       '/usr/bin/vi' will be used.\n"
      "\nOnce the item note is edited and saved, quit your favorite editor.\n"
      "You will then go back to Calcurse, and the '>' sign will appear in front"
      "\nof the highlighted item, meaning there is a note attached to it."),
    keys_action_firstkey (KEY_EDIT_NOTE));

  hscr[HELP_VNOTE].title = _("ViewNote\n");
  (void)snprintf (hscr[HELP_VNOTE].text, HELPTEXTSIZ,
    _("View a note which was previously attached to an item (an item which\n"
      "owns a note has a '>' sign in front of it).\n"
      "This command only permits to view the note, not to edit it (to do so,\n"
      "use the 'EditNote' command, by pressing the '%s' key).\n"
      "Once you highlighted an item with a note attached to it, and the '%s' key"
      "\nwas pressed, you will be driven to an external pager to view that "
      "note.\n"
      "The default pager is chosen the following way:\n"
      "     o if the 'PAGER' environment variable is set, then this will be\n"
      "       the default viewer to be called.\n"
      "     o if the above environment variable is not set, then\n"
      "       '/usr/bin/less' will be used.\n"
      "As for editing a note, quit the pager and you will be driven back to\n"
      "Calcurse."),
            keys_action_firstkey (KEY_EDIT_NOTE),
            keys_action_firstkey (KEY_VIEW_NOTE));

  hscr[HELP_PRIORITY].title = _("Priority\n");
  (void)snprintf (hscr[HELP_PRIORITY].text, HELPTEXTSIZ,
    _("Change the priority of the currently selected item in the ToDo list.\n"
      "Priorities are represented by the number appearing in front of the\n"
      "todo description. This number goes from 9 for the lowest priority to\n"
      "1 for the highest priority.\n"
      "Todo having higher priorities are placed first (at the top) inside the\n"
      "todo panel.\n\n"
      "If you want to raise the priority of a todo item, you need to press "
      "'%s'.\n"
      "In doing so, the number in front of this item will decrease, "
      "meaning its\npriority increases. The item position inside the todo "
      "panel may change,\ndepending on the priority of the items above it.\n\n"
      "At the opposite, to lower a todo priority, press '%s'. The todo position"
      "\nmay also change depending on the priority of the items below."),
            keys_action_firstkey (KEY_RAISE_PRIORITY),
            keys_action_firstkey (KEY_LOWER_PRIORITY));

  hscr[HELP_REPEAT].title = _("Repeat\n");
  (void)snprintf (hscr[HELP_REPEAT].text, HELPTEXTSIZ,
    _("Repeat an event or an appointment.\n"
      "You must first select the item to be repeated by moving inside the\n"
      "appointment panel. Then pressing '%s' will lead you to a set of three\n"
      "questions, with which you will be able to specify the repetition\n"
      "characteristics:\n\n"
      "  o        type: you can choose between a daily, weekly, monthly or\n"
      "                 yearly repetition by pressing 'D', 'W', 'M' or 'Y'\n"
      "                 respectively.\n\n"
      "  o   frequence: this indicates how often the item shall be repeated.\n"
      "                 For example, if you want to remember an anniversary,\n"
      "                 choose a 'yearly' repetition with a frequence of '1',\n"
      "                 which means it must be repeated every year. Another\n"
      "                 example: if you go to the restaurant every two days,\n"
      "                 choose a 'daily' repetition with a frequence of '2'.\n\n"
      "  o ending date: this specifies when to stop repeating the selected\n"
      "                 event or appointment. To indicate an endless \n"
      "                 repetition, enter '0' and the item will be repeated\n"
      "                 forever.\n" "\nNotes:\n"
      "       o repeated items are marked with an '*' inside the appointment\n"
      "         panel, to be easily recognizable from non-repeated ones.\n"
      "       o the 'Repeat' and 'Delete' command can be mixed to create\n"
      "         complicated configurations, as it is possible to delete only\n"
      "         one occurence of a repeated item."),
            keys_action_firstkey (KEY_REPEAT_ITEM));

  hscr[HELP_FLAG].title = _("Flag Item\n");
  (void)snprintf (hscr[HELP_FLAG].text, HELPTEXTSIZ,
    _("Toggle an appointment's 'important' flag or a todo's 'completed' flag.\n"
      "If a todo is flagged as completed, its priority number will be replaced\n"
      "by an 'X' sign. Completed tasks will no longer appear in exported data\n"
      "or when using the '-t' command line flag (unless specifying '0' as the\n"
      "priority number, in which case only completed tasks will be shown).\n\n"
      "If an appointment is flagged as important, an exclamation mark appears\n"
      "in front of it, and you will be warned if time gets closed to the\n"
      "appointment start time.\n"
      "To customize the way one gets notified, the configuration submenu lets\n"
      "you choose the command launched to warn user of an upcoming appointment,"
      "\nand how long before it he gets notified."));

  hscr[HELP_CONFIG].title = _("Config\n");
  (void)snprintf (hscr[HELP_CONFIG].text, HELPTEXTSIZ,
    _("Open the configuration submenu.\n"
      "From this submenu, you can select between color, layout, notification\n"
      "and general options, and you can also configure your keybindings.\n"
      "\nThe color submenu lets you choose the color theme.\n"
      "The layout submenu lets you choose the Calcurse screen layout, in other"
      "\nwords where to place the three different panels on the screen.\n"
      "The general options submenu brings a screen with the different options"
      "\nwhich modifies the way Calcurse interacts with the user.\n"
      "The notify submenu allows you to change the notify-bar settings.\n"
      "The keys submenu lets you define your own key bindings.\n"
      "\nDo not forget to save the calendar data to retrieve your configuration"
      "\nnext time you launch Calcurse."));

  hscr[HELP_GENERAL].title = _("Generic keybindings\n");
  (void)snprintf (hscr[HELP_GENERAL].text, HELPTEXTSIZ,
    _("Some of the keybindings apply whatever panel is selected. They are\n"
      "called generic keybinding.\n"
      "Here is the list of all the generic key bindings, together with their\n"
      "corresponding action:\n\n"
      " '%s' : Redraw function -> redraws calcurse panels, this is useful if\n"
      "                           you resize your terminal screen or when\n"
      "                           garbage appears inside the display\n"
      " '%s' : Add Appointment -> add an appointment or an event\n"
      " '%s' : Add ToDo        -> add a todo\n"
      " '%s' : -1 Day          -> move to previous day\n"
      " '%s' : +1 Day          -> move to next day\n"
      " '%s' : -1 Week         -> move to previous week\n"
      " '%s' : +1 Week         -> move to next week\n"
      " '%s' : Goto today      -> move to current day\n"
      "\nThe '%s' and '%s' keys are used to scroll text upward or downward\n"
      "when inside specific screens such the help screens for example.\n"
      "They are also used when the calendar screen is selected to switch\n"
      "between the available views (monthly and weekly calendar views)."),
            keys_action_firstkey (KEY_GENERIC_REDRAW),
            keys_action_firstkey (KEY_GENERIC_ADD_APPT),
            keys_action_firstkey (KEY_GENERIC_ADD_TODO),
            keys_action_firstkey (KEY_GENERIC_PREV_DAY),
            keys_action_firstkey (KEY_GENERIC_NEXT_DAY),
            keys_action_firstkey (KEY_GENERIC_PREV_WEEK),
            keys_action_firstkey (KEY_GENERIC_NEXT_WEEK),
            keys_action_firstkey (KEY_GENERIC_GOTO_TODAY),
            keys_action_firstkey (KEY_GENERIC_SCROLL_UP),
            keys_action_firstkey (KEY_GENERIC_SCROLL_DOWN));

  hscr[HELP_OTHER].title = _("OtherCmd\n");
  (void)snprintf (hscr[HELP_OTHER].text, HELPTEXTSIZ,
    _("Switch between status bar help pages.\n"
      "Because the terminal screen is too narrow to display all of the\n"
      "available commands, you need to press '%s' to see the next set of\n"
      "commands together with their keybindings.\n"
      "Once the last status bar page is reached, pressing '%s' another time\n"
      "leads you back to the first page."),
            keys_action_firstkey (KEY_GENERIC_OTHER_CMD),
            keys_action_firstkey (KEY_GENERIC_OTHER_CMD));

  hscr[HELP_CREDITS].title = _("Calcurse - text-based organizer");
  (void)snprintf (hscr[HELP_CREDITS].text, HELPTEXTSIZ,
    _("\nCopyright (c) 2004-2011 calcurse Development Team\n"
      "All rights reserved.\n"
      "\n"
      "Redistribution and use in source and binary forms, with or without\n"
      "modification, are permitted provided that the following conditions\n"
      "are met:\n"
      "\n"
      "\t- Redistributions of source code must retain the above\n"
      "\t  copyright notice, this list of conditions and the\n"
      "\t  following disclaimer.\n"
      "\n"
      "\t- Redistributions in binary form must reproduce the above\n"
      "\t  copyright notice, this list of conditions and the\n"
      "\t  following disclaimer in the documentation and/or other\n"
      "\t  materials provided with the distribution.\n"
      "\n\n"
      "Send your feedback or comments to : misc@calcurse.org\n"
      "Calcurse home page : http://calcurse.org"));

  help_wins_init (&hwin, 0, 0, (notify_bar ()) ? row - 3 : row - 2, col);
  oldpage = HELP_MAIN;
  need_resize = 0;

  /* Display the help screen related to user input. */
  while (ch != KEY_GENERIC_QUIT)
    {
      erase_window_part (hwin.win.p, 1, hwin.pad.y, col - 2,
                         hwin.win.h - 2);

      switch (ch) {
        case KEY_GENERIC_SCROLL_DOWN:
          wins_scrollwin_down (&hwin, 1);
          break;

        case KEY_GENERIC_SCROLL_UP:
          wins_scrollwin_up (&hwin, 1);
          break;

        default:
          page = wanted_page (ch);
          if (page != NOPAGE) {
            hwin.first_visible_line = 0;
            hwin.total_lines = help_write_pad (&hwin.pad, hscr[page].title,
                                               hscr[page].text, ch);
            oldpage = page;
          }
      }

      if (resize)
        {
          resize = 0;
          wins_get_config ();
          help_wins_reset (&hwin);
          hwin.first_visible_line = 0;
          hwin.total_lines = help_write_pad (&hwin.pad, hscr[oldpage].title,
                                             hscr[oldpage].text, ch);
          need_resize = 1;
        }

      wins_scrollwin_display (&hwin);
      ch = keys_getch (win[STA].p);
    }
  wins_scrollwin_delete (&hwin);
  if (need_resize)
    wins_reset ();
}
Example #5
0
void cTestPanel::CreateControls()
{    
////@begin cTestPanel content construction
    cTestPanel* itemPanel1 = this;

    wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
    itemPanel1->SetSizer(itemBoxSizer2);

    m_Button1 = new wxButton( itemPanel1, ID_BUTTON, _("Button"), wxDefaultPosition, wxDefaultSize, 0 );
    itemBoxSizer2->Add(m_Button1, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

    wxButton* itemButton4 = new wxButton( itemPanel1, ID_BUTTON1, _("Button"), wxDefaultPosition, wxDefaultSize, 0 );
    itemBoxSizer2->Add(itemButton4, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

    wxButton* itemButton5 = new wxButton( itemPanel1, ID_BUTTON2, _("Button"), wxDefaultPosition, wxDefaultSize, 0 );
    itemBoxSizer2->Add(itemButton5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

    wxButton* itemButton6 = new wxButton( itemPanel1, ID_BUTTON3, _("Button"), wxDefaultPosition, wxDefaultSize, 0 );
    itemBoxSizer2->Add(itemButton6, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

    wxButton* itemButton7 = new wxButton( itemPanel1, ID_BUTTON4, _("Button"), wxDefaultPosition, wxDefaultSize, 0 );
    itemBoxSizer2->Add(itemButton7, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

    wxButton* itemButton8 = new wxButton( itemPanel1, ID_BUTTON5, _("Button"), wxDefaultPosition, wxDefaultSize, 0 );
    itemBoxSizer2->Add(itemButton8, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

    wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxHORIZONTAL);
    itemBoxSizer2->Add(itemBoxSizer9, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

    wxButton* itemButton10 = new wxButton( itemPanel1, ID_BUTTON6, _("Button"), wxDefaultPosition, wxDefaultSize, 0 );
    itemBoxSizer9->Add(itemButton10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

    wxButton* itemButton11 = new wxButton( itemPanel1, ID_BUTTON7, _("Button"), wxDefaultPosition, wxDefaultSize, 0 );
    itemBoxSizer9->Add(itemButton11, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

    wxButton* itemButton12 = new wxButton( itemPanel1, ID_BUTTON8, _("Button"), wxDefaultPosition, wxDefaultSize, 0 );
    itemBoxSizer9->Add(itemButton12, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

    wxButton* itemButton13 = new wxButton( itemPanel1, ID_BUTTON9, _("Button"), wxDefaultPosition, wxDefaultSize, 0 );
    itemBoxSizer9->Add(itemButton13, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

    wxButton* itemButton14 = new wxButton( itemPanel1, ID_BUTTON10, _("Button"), wxDefaultPosition, wxDefaultSize, 0 );
    itemBoxSizer9->Add(itemButton14, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

    wxBoxSizer* itemBoxSizer15 = new wxBoxSizer(wxHORIZONTAL);
    itemBoxSizer2->Add(itemBoxSizer15, 1, wxGROW|wxALL, 5);

    wxButton* itemButton16 = new wxButton( itemPanel1, ID_BUTTON11, _("Button"), wxDefaultPosition, wxDefaultSize, 0 );
    itemBoxSizer15->Add(itemButton16, 1, wxGROW|wxALL, 5);

    wxButton* itemButton17 = new wxButton( itemPanel1, ID_BUTTON12, _("Button"), wxDefaultPosition, wxDefaultSize, 0 );
    itemBoxSizer15->Add(itemButton17, 1, wxGROW|wxALL, 5);

    wxBitmapButton* itemBitmapButton18 = new wxBitmapButton( itemPanel1, ID_BITMAPBUTTON, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
    itemBoxSizer15->Add(itemBitmapButton18, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

    wxStaticBitmap* itemStaticBitmap19 = new wxStaticBitmap( itemPanel1, wxID_STATIC, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
    itemBoxSizer15->Add(itemStaticBitmap19, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

////@end cTestPanel content construction
}
Example #6
0
static void _properties_window(Camera * camera)
{
	GtkWidget * dialog;
	GtkSizeGroup * group;
	GtkWidget * vbox;
	GtkWidget * hbox;
	char buf[64];
	const struct
	{
		unsigned int capability;
		char const * name;
	} capabilities[] =
	{
		{ V4L2_CAP_VIDEO_CAPTURE,	"capture"	},
		{ V4L2_CAP_VIDEO_OUTPUT,	"output"	},
		{ V4L2_CAP_VIDEO_OVERLAY,	"overlay"	},
		{ V4L2_CAP_TUNER,		"tuner"		},
		{ V4L2_CAP_AUDIO,		"audio"		},
		{ V4L2_CAP_STREAMING,		"streaming"	},
		{ 0,				NULL		}
	};
	unsigned int i;
	char const * sep = "";

	dialog = gtk_message_dialog_new(GTK_WINDOW(camera->window),
			GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
			GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
#if GTK_CHECK_VERSION(2, 6, 0)
			"%s", _("Properties"));
	gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
#endif
			"");
	camera->pp_window = dialog;
#if GTK_CHECK_VERSION(2, 10, 0)
	gtk_message_dialog_set_image(GTK_MESSAGE_DIALOG(dialog),
			gtk_image_new_from_stock(GTK_STOCK_PROPERTIES,
				GTK_ICON_SIZE_DIALOG));
#endif
	gtk_window_set_title(GTK_WINDOW(dialog), _("Properties"));
	g_signal_connect_swapped(dialog, "response", G_CALLBACK(
				_properties_on_response), camera);
	group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
#if GTK_CHECK_VERSION(2, 14, 0)
	vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
#else
	vbox = dialog->vbox;
#endif
	/* driver */
	snprintf(buf, sizeof(buf), "%-16s", (char *)camera->cap.driver);
	hbox = _properties_label(camera, group, _("Driver: "), buf);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
	/* card */
	snprintf(buf, sizeof(buf), "%-32s", (char *)camera->cap.card);
	hbox = _properties_label(camera, group, _("Card: "), buf);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
	/* bus info */
	snprintf(buf, sizeof(buf), "%-32s", (char *)camera->cap.bus_info);
	hbox = _properties_label(camera, group, _("Bus info: "), buf);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
	/* version */
	snprintf(buf, sizeof(buf), "0x%x", camera->cap.version);
	hbox = _properties_label(camera, group, _("Version: "), buf);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
	/* capabilities */
	buf[0] = '\0';
	for(i = 0; capabilities[i].name != NULL; i++)
		if(camera->cap.capabilities & capabilities[i].capability)
		{
			strncat(buf, sep, sizeof(buf) - strlen(buf));
			strncat(buf, capabilities[i].name, sizeof(buf)
					- strlen(buf));
			sep = ", ";
		}
	buf[sizeof(buf) - 1] = '\0';
	hbox = _properties_label(camera, group, _("Capabilities: "), buf);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
	gtk_widget_show_all(vbox);
}
Example #7
0

#include <linux/stddef.h>
#include <linux/proc_fs.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/fs.h>
#include <linux/init.h>

#define _(addr) (volatile unsigned char *)(addr)
#if defined(CONFIG_H83007) || defined(CONFIG_H83068)
#include <asm/regs306x.h>
static volatile unsigned char *ddrs[] = {
	_(P1DDR),_(P2DDR),_(P3DDR),_(P4DDR),_(P5DDR),_(P6DDR),
	NULL,    _(P8DDR),_(P9DDR),_(PADDR),_(PBDDR),
};
#define MAX_PORT 11
#endif

 #if defined(CONFIG_H83002) || defined(CONFIG_H8048)
#include <asm/regs306x.h>
static volatile unsigned char *ddrs[] = {
	_(P1DDR),_(P2DDR),_(P3DDR),_(P4DDR),_(P5DDR),_(P6DDR),
	NULL,    _(P8DDR),_(P9DDR),_(PADDR),_(PBDDR),
};
#define MAX_PORT 11
#endif

#if defined(CONFIG_H8S2678)
#include <asm/regs267x.h>
static volatile unsigned char *ddrs[] = {
Example #8
0
static RejillaBurnResult
rejilla_vcd_imager_set_argv (RejillaProcess *process,
			     GPtrArray *argv,
			     GError **error)
{
	RejillaVcdImagerPrivate *priv;
	RejillaBurnResult result;
	RejillaJobAction action;
	RejillaMedia medium;
	gchar *output;
	gchar *image;
	gchar *toc;

	priv = REJILLA_VCD_IMAGER_PRIVATE (process);

	rejilla_job_get_action (REJILLA_JOB (process), &action);
	if (action != REJILLA_JOB_ACTION_IMAGE)
		REJILLA_JOB_NOT_SUPPORTED (process);

	g_ptr_array_add (argv, g_strdup ("vcdxbuild"));

	g_ptr_array_add (argv, g_strdup ("--progress"));
	g_ptr_array_add (argv, g_strdup ("-v"));

	/* specifies output */
	image = toc = NULL;
	rejilla_job_get_image_output (REJILLA_JOB (process),
				      &image,
				      &toc);

	g_ptr_array_add (argv, g_strdup ("-c"));
	g_ptr_array_add (argv, toc);
	g_ptr_array_add (argv, g_strdup ("-b"));
	g_ptr_array_add (argv, image);

	/* get temporary file to write XML */
	result = rejilla_job_get_tmp_file (REJILLA_JOB (process),
					   NULL,
					   &output,
					   error);
	if (result != REJILLA_BURN_OK)
		return result;

	g_ptr_array_add (argv, output);

	rejilla_job_get_media (REJILLA_JOB (process), &medium);
	if (medium & REJILLA_MEDIUM_CD) {
		GValue *value = NULL;

		rejilla_job_tag_lookup (REJILLA_JOB (process),
					REJILLA_VCD_TYPE,
					&value);
		if (value)
			priv->svcd = (g_value_get_int (value) == REJILLA_SVCD);
	}

	result = rejilla_vcd_imager_generate_xml_file (process, output, error);
	if (result != REJILLA_BURN_OK)
		return result;
	
	rejilla_job_set_current_action (REJILLA_JOB (process),
					REJILLA_BURN_ACTION_CREATING_IMAGE,
					_("Creating file layout"),
					FALSE);
	return REJILLA_BURN_OK;
}
/* Store at least register REGNO, or all regs if REGNO == -1.  */
void
gnu_store_registers (int regno)
{
  struct regcache *regcache = current_regcache;
  struct proc *thread;

  /* Make sure we know about new threads.  */
  inf_update_procs (current_inferior);

  thread = inf_tid_to_thread (current_inferior, PIDGET (inferior_ptid));
  if (!thread)
    error (_("Couldn't store registers into thread %d: No such thread"),
	   PIDGET (inferior_ptid));

  if (regno < I386_NUM_GREGS || regno == -1)
    {
      thread_state_t state;
      thread_state_data_t old_state;
      int was_aborted = thread->aborted;
      int was_valid = thread->state_valid;
      int trace;

      if (!was_aborted && was_valid)
	memcpy (&old_state, &thread->state, sizeof (old_state));

      state = proc_get_state (thread, 1);
      if (!state)
	{
	  warning (_("Couldn't store registers into %s"), proc_string (thread));
	  return;
	}

      /* Save the T bit.  We might try to restore the %eflags register
         below, but changing the T bit would seriously confuse GDB.  */
      trace = ((struct i386_thread_state *)state)->efl & 0x100;

      if (!was_aborted && was_valid)
	/* See which registers have changed after aborting the thread.  */
	{
	  int check_regno;

	  for (check_regno = 0; check_regno < I386_NUM_GREGS; check_regno++)
	    if ((thread->fetched_regs & (1 << check_regno))
		&& memcpy (REG_ADDR (&old_state, check_regno),
			   REG_ADDR (state, check_regno),
			   register_size (current_gdbarch, check_regno)))
	      /* Register CHECK_REGNO has changed!  Ack!  */
	      {
		warning (_("Register %s changed after the thread was aborted"),
			 REGISTER_NAME (check_regno));
		if (regno >= 0 && regno != check_regno)
		  /* Update GDB's copy of the register.  */
		  regcache_raw_supply (regcache, check_regno,
				       REG_ADDR (state, check_regno));
		else
		  warning (_("... also writing this register!  Suspicious..."));
	      }
	}

      if (regno == -1)
	{
	  int i;

	  proc_debug (thread, "storing all registers");

	  for (i = 0; i < I386_NUM_GREGS; i++)
	    if (regcache_valid_p (regcache, i))
	      regcache_raw_collect (regcache, i, REG_ADDR (state, i));
	}
      else
	{
	  proc_debug (thread, "storing register %s", REGISTER_NAME (regno));

	  gdb_assert (regcache_valid_p (regcache, regno));
	  regcache_raw_collect (regcache, regno, REG_ADDR (state, regno));
	}

      /* Restore the T bit.  */
      ((struct i386_thread_state *)state)->efl &= ~0x100;
      ((struct i386_thread_state *)state)->efl |= trace;
    }

  if (regno >= I386_NUM_GREGS || regno == -1)
    {
      proc_debug (thread, "storing floating-point registers");

      store_fpregs (thread, regno);
    }
}
Example #10
0
bool ClientLauncher::launch_game(std::string &error_message,
		bool reconnect_requested, GameParams &game_params,
		const Settings &cmd_args)
{
	// Initialize menu data
	MainMenuData menudata;
	menudata.address                         = address;
	menudata.name                            = playername;
	menudata.port                            = itos(game_params.socket_port);
	menudata.script_data.errormessage        = error_message;
	menudata.script_data.reconnect_requested = reconnect_requested;

	error_message.clear();

	if (cmd_args.exists("password"))
		menudata.password = cmd_args.get("password");

	menudata.enable_public = g_settings->getBool("server_announce");

	// If a world was commanded, append and select it
	if (game_params.world_path != "") {
		worldspec.gameid = getWorldGameId(game_params.world_path, true);
		worldspec.name = _("[--world parameter]");

		if (worldspec.gameid == "") {	// Create new
			worldspec.gameid = g_settings->get("default_game");
			worldspec.name += " [new]";
		}
		worldspec.path = game_params.world_path;
	}

	/* Show the GUI menu
	 */
	if (!skip_main_menu) {
		main_menu(&menudata);

		// Skip further loading if there was an exit signal.
		if (*porting::signal_handler_killstatus())
			return false;

		address = menudata.address;
		int newport = stoi(menudata.port);
		if (newport != 0)
			game_params.socket_port = newport;

		simple_singleplayer_mode = menudata.simple_singleplayer_mode;

		std::vector<WorldSpec> worldspecs = getAvailableWorlds();

		if (menudata.selected_world >= 0
				&& menudata.selected_world < (int)worldspecs.size()) {
			g_settings->set("selected_world_path",
					worldspecs[menudata.selected_world].path);
			worldspec = worldspecs[menudata.selected_world];
		}
	}

	if (!menudata.script_data.errormessage.empty()) {
		/* The calling function will pass this back into this function upon the
		 * next iteration (if any) causing it to be displayed by the GUI
		 */
		error_message = menudata.script_data.errormessage;
		return false;
	}

	if (menudata.name == "")
		menudata.name = std::string("Guest") + itos(myrand_range(1000, 9999));
	else
		playername = menudata.name;

	password = menudata.password;

	g_settings->set("name", playername);

	current_playername = playername;
	current_password   = password;
	current_address    = address;
	current_port       = game_params.socket_port;

	// If using simple singleplayer mode, override
	if (simple_singleplayer_mode) {
		assert(skip_main_menu == false);
		current_playername = "singleplayer";
		current_password = "";
		current_address = "";
		current_port = myrand_range(49152, 65535);
	} else if (address != "") {
		ServerListSpec server;
		server["name"] = menudata.servername;
		server["address"] = menudata.address;
		server["port"] = menudata.port;
		server["description"] = menudata.serverdescription;
		ServerList::insert(server);
	}

	infostream << "Selected world: " << worldspec.name
	           << " [" << worldspec.path << "]" << std::endl;

	if (current_address == "") { // If local game
		if (worldspec.path == "") {
			error_message = gettext("No world selected and no address "
					"provided. Nothing to do.");
			errorstream << error_message << std::endl;
			return false;
		}

		if (!fs::PathExists(worldspec.path)) {
			error_message = gettext("Provided world path doesn't exist: ")
					+ worldspec.path;
			errorstream << error_message << std::endl;
			return false;
		}

		// Load gamespec for required game
		gamespec = findWorldSubgame(worldspec.path);
		if (!gamespec.isValid() && !game_params.game_spec.isValid()) {
			error_message = gettext("Could not find or load game \"")
					+ worldspec.gameid + "\"";
			errorstream << error_message << std::endl;
			return false;
		}

		if (porting::signal_handler_killstatus())
			return true;

		if (game_params.game_spec.isValid() &&
				game_params.game_spec.id != worldspec.gameid) {
			warningstream << "Overriding gamespec from \""
			            << worldspec.gameid << "\" to \""
			            << game_params.game_spec.id << "\"" << std::endl;
			gamespec = game_params.game_spec;
		}

		if (!gamespec.isValid()) {
			error_message = gettext("Invalid gamespec.");
			error_message += " (world.gameid=" + worldspec.gameid + ")";
			errorstream << error_message << std::endl;
			return false;
		}
	}

	return true;
}
Example #11
0
int
gui_key_read_cb (void *data, int fd)
{
    int ret, i, accept_paste, cancel_paste, text_added_to_buffer, pos;
    unsigned char buffer[4096];

    /* make C compiler happy */
    (void) data;
    (void) fd;

    accept_paste = 0;
    cancel_paste = 0;
    text_added_to_buffer = 0;

    ret = read (STDIN_FILENO, buffer, sizeof (buffer));
    if (ret == 0)
    {
        /* no data on stdin, terminal lost */
        log_printf (_("Terminal lost, exiting WeeChat..."));
        hook_signal_send ("quit", WEECHAT_HOOK_SIGNAL_STRING, NULL);
        weechat_quit = 1;
        return WEECHAT_RC_OK;
    }
    if (ret < 0)
        return WEECHAT_RC_OK;

    for (i = 0; i < ret; i++)
    {
        /*
         * add all chars, but ignore a newline ('\r' or '\n') after
         * another one)
         */
        if ((i == 0)
            || ((buffer[i] != '\r') && (buffer[i] != '\n'))
            || ((buffer[i - 1] != '\r') && (buffer[i - 1] != '\n')))
        {
            if (gui_key_paste_pending)
            {
                if (buffer[i] == 25)
                {
                    /* ctrl-Y: accept paste */
                    accept_paste = 1;
                }
                else if (buffer[i] == 14)
                {
                    /* ctrl-N: cancel paste */
                    cancel_paste = 1;
                }
            }
            else
            {
                gui_key_buffer_add (buffer[i]);
                text_added_to_buffer = 1;
            }
        }
    }

    if (gui_key_paste_pending)
    {
        if (accept_paste)
        {
            /* user is OK for pasting text, let's paste! */
            gui_key_paste_accept ();
        }
        else if (cancel_paste)
        {
            /* user doesn't want to paste text: clear whole buffer! */
            gui_key_paste_cancel ();
        }
        else if (text_added_to_buffer)
        {
            /* new text received while asking for paste, update message */
            gui_input_paste_pending_signal ();
        }
    }
    else
    {
        if (!gui_key_paste_bracketed)
        {
            pos = gui_key_buffer_search (0, -1, GUI_KEY_BRACKETED_PASTE_START);
            if (pos >= 0)
            {
                gui_key_buffer_remove (pos, GUI_KEY_BRACKETED_PASTE_LENGTH);
                gui_key_paste_bracketed_start ();
            }
        }

        if (!gui_key_paste_bracketed)
            gui_key_paste_check (0);
    }

    gui_key_flush ((accept_paste) ? 1 : 0);

    if (gui_key_paste_bracketed)
    {
        pos = gui_key_buffer_search (0, -1, GUI_KEY_BRACKETED_PASTE_END);
        if (pos >= 0)
        {
            /* remove the code for end of bracketed paste (ESC[201~) */
            gui_key_buffer_remove (pos, GUI_KEY_BRACKETED_PASTE_LENGTH);

            /* remove final newline (if needed) */
            gui_key_paste_remove_newline ();

            /* replace tabs by spaces */
            gui_key_paste_replace_tabs ();

            /* stop bracketed mode */
            gui_key_paste_bracketed_timer_remove ();
            gui_key_paste_bracketed_stop ();

            /* if paste confirmation not displayed, flush buffer now */
            if (!gui_key_paste_pending)
                gui_key_flush (1);
        }
    }

    return WEECHAT_RC_OK;
}
Example #12
0
File: lpd.c Project: ezeep/cups
static int				/* O - Zero on success, non-zero on failure */
lpd_queue(const char      *hostname,	/* I - Host to connect to */
          http_addrlist_t *addrlist,	/* I - List of host addresses */
          const char      *printer,	/* I - Printer/queue name */
	  int             print_fd,	/* I - File to print */
	  int             snmp_fd,	/* I - SNMP socket */
	  int             mode,		/* I - Print mode */
          const char      *user,	/* I - Requesting user */
	  const char      *title,	/* I - Job title */
	  int             copies,	/* I - Number of copies */
	  int             banner,	/* I - Print LPD banner? */
          int             format,	/* I - Format specifier */
          int             order,	/* I - Order of data/control files */
	  int             reserve,	/* I - Reserve ports? */
	  int             manual_copies,/* I - Do copies by hand... */
	  int             timeout,	/* I - Timeout... */
	  int             contimeout,	/* I - Connection timeout */
	  const char      *orighost)	/* I - job-originating-host-name */
{
  char			localhost[255];	/* Local host name */
  int			error;		/* Error number */
  struct stat		filestats;	/* File statistics */
  int			lport;		/* LPD connection local port */
  int			fd;		/* LPD socket */
  char			control[10240],	/* LPD control 'file' */
			*cptr;		/* Pointer into control file string */
  char			status;		/* Status byte from command */
  int			delay;		/* Delay for retries... */
  char			addrname[256];	/* Address name */
  http_addrlist_t	*addr;		/* Socket address */
  int			have_supplies;	/* Printer supports supply levels? */
  int			copy;		/* Copies written */
  time_t		start_time;	/* Time of first connect */
  ssize_t		nbytes;		/* Number of bytes written */
  off_t			tbytes;		/* Total bytes written */
  char			buffer[32768];	/* Output buffer */
#ifdef WIN32
  DWORD			tv;		/* Timeout in milliseconds */
#else
  struct timeval	tv;		/* Timeout in secs and usecs */
#endif /* WIN32 */


 /*
  * Remember when we started trying to connect to the printer...
  */

  start_time = time(NULL);

 /*
  * Loop forever trying to print the file...
  */

  while (!abort_job)
  {
   /*
    * First try to reserve a port for this connection...
    */

    fprintf(stderr, "DEBUG: Connecting to %s:%d for printer %s\n", hostname,
            httpAddrPort(&(addrlist->addr)), printer);
    _cupsLangPrintFilter(stderr, "INFO", _("Connecting to printer."));

    for (lport = reserve == RESERVE_RFC1179 ? 732 : 1024, addr = addrlist,
             delay = 5;;
         addr = addr->next)
    {
     /*
      * Stop if this job has been canceled...
      */

      if (abort_job)
        return (CUPS_BACKEND_FAILED);

     /*
      * Choose the next priviledged port...
      */

      if (!addr)
        addr = addrlist;

      lport --;

      if (lport < 721 && reserve == RESERVE_RFC1179)
	lport = 731;
      else if (lport < 1)
	lport = 1023;

#ifdef HAVE_GETEUID
      if (geteuid() || !reserve)
#else
      if (getuid() || !reserve)
#endif /* HAVE_GETEUID */
      {
       /*
	* Just create a regular socket...
	*/

	if ((fd = socket(addr->addr.addr.sa_family, SOCK_STREAM, 0)) < 0)
	{
	  perror("DEBUG: Unable to create socket");
	  sleep(1);

          continue;
	}

        lport = 0;
      }
      else
      {
       /*
	* We're running as root and want to comply with RFC 1179.  Reserve a
	* priviledged lport between 721 and 731...
	*/

	if ((fd = rresvport_af(&lport, addr->addr.addr.sa_family)) < 0)
	{
	  perror("DEBUG: Unable to reserve port");
	  sleep(1);

	  continue;
	}
      }

     /*
      * Connect to the printer or server...
      */

      if (abort_job)
      {
	close(fd);

	return (CUPS_BACKEND_FAILED);
      }

      if (!connect(fd, &(addr->addr.addr), (socklen_t)httpAddrLength(&(addr->addr))))
	break;

      error = errno;
      close(fd);

      if (addr->next)
        continue;

      if (getenv("CLASS") != NULL)
      {
       /*
        * If the CLASS environment variable is set, the job was submitted
	* to a class and not to a specific queue.  In this case, we want
	* to abort immediately so that the job can be requeued on the next
	* available printer in the class.
	*/

        _cupsLangPrintFilter(stderr, "INFO",
			     _("Unable to contact printer, queuing on next "
			       "printer in class."));

       /*
        * Sleep 5 seconds to keep the job from requeuing too rapidly...
	*/

	sleep(5);

        return (CUPS_BACKEND_FAILED);
      }

      fprintf(stderr, "DEBUG: Connection error: %s\n", strerror(error));

      if (error == ECONNREFUSED || error == EHOSTDOWN ||
          error == EHOSTUNREACH)
      {
        if (contimeout && (time(NULL) - start_time) > contimeout)
	{
	  _cupsLangPrintFilter(stderr, "ERROR",
			       _("The printer is not responding."));
	  return (CUPS_BACKEND_FAILED);
	}

	switch (error)
	{
	  case EHOSTDOWN :
	      _cupsLangPrintFilter(stderr, "WARNING",
			           _("The printer may not exist or "
			             "is unavailable at this time."));
	      break;

	  case EHOSTUNREACH :
	      _cupsLangPrintFilter(stderr, "WARNING",
			           _("The printer is unreachable at "
				     "this time."));
	      break;

	  case ECONNREFUSED :
	  default :
	      _cupsLangPrintFilter(stderr, "WARNING",
	                           _("The printer is in use."));
	      break;
        }

	sleep((unsigned)delay);

	if (delay < 30)
	  delay += 5;
      }
      else if (error == EADDRINUSE)
      {
       /*
	* Try on another port...
	*/

	sleep(1);
      }
      else
      {
	_cupsLangPrintFilter(stderr, "ERROR",
	                     _("The printer is not responding."));
	sleep(30);
      }
    }

   /*
    * Set the timeout...
    */

#ifdef WIN32
    tv = (DWORD)(timeout * 1000);

    setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv));
    setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, sizeof(tv));
#else
    tv.tv_sec  = timeout;
    tv.tv_usec = 0;

    setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
    setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));
#endif /* WIN32 */

    fputs("STATE: -connecting-to-device\n", stderr);
    _cupsLangPrintFilter(stderr, "INFO", _("Connected to printer."));

    fprintf(stderr, "DEBUG: Connected to %s:%d (local port %d)...\n",
	    httpAddrString(&(addr->addr), addrname, sizeof(addrname)),
	    httpAddrPort(&(addr->addr)), lport);

   /*
    * See if the printer supports SNMP...
    */

    if (snmp_fd >= 0)
      have_supplies = !backendSNMPSupplies(snmp_fd, &(addrlist->addr), NULL,
                                           NULL);
    else
      have_supplies = 0;

   /*
    * Check for side-channel requests...
    */

    backendCheckSideChannel(snmp_fd, &(addrlist->addr));

   /*
    * Next, open the print file and figure out its size...
    */

    if (print_fd)
    {
     /*
      * Use the size from the print file...
      */

      if (fstat(print_fd, &filestats))
      {
	close(fd);

	perror("DEBUG: unable to stat print file");
	return (CUPS_BACKEND_FAILED);
      }

      filestats.st_size *= manual_copies;
    }
    else
    {
     /*
      * Use a "very large value" for the size so that the printer will
      * keep printing until we close the connection...
      */

#ifdef _LARGEFILE_SOURCE
      filestats.st_size = (size_t)(999999999999.0);
#else
      filestats.st_size = 2147483647;
#endif /* _LARGEFILE_SOURCE */
    }

   /*
    * Send a job header to the printer, specifying no banner page and
    * literal output...
    */

    if (lpd_command(fd, "\002%s\n",
                    printer))		/* Receive print job(s) */
    {
      close(fd);
      return (CUPS_BACKEND_FAILED);
    }

    if (orighost && _cups_strcasecmp(orighost, "localhost"))
      strlcpy(localhost, orighost, sizeof(localhost));
    else
      httpGetHostname(NULL, localhost, sizeof(localhost));

    snprintf(control, sizeof(control),
             "H%.31s\n"		/* RFC 1179, Section 7.2 - host name <= 31 chars */
	     "P%.31s\n"		/* RFC 1179, Section 7.2 - user name <= 31 chars */
	     "J%.99s\n",	/* RFC 1179, Section 7.2 - job name <= 99 chars */
	     localhost, user, title);
    cptr = control + strlen(control);

    if (banner)
    {
      snprintf(cptr, sizeof(control) - (size_t)(cptr - control),
               "C%.31s\n"	/* RFC 1179, Section 7.2 - class name <= 31 chars */
	       "L%s\n",
               localhost, user);
      cptr   += strlen(cptr);
    }

    while (copies > 0)
    {
      snprintf(cptr, sizeof(control) - (size_t)(cptr - control), "%cdfA%03d%.15s\n",
               format, (int)getpid() % 1000, localhost);
      cptr   += strlen(cptr);
      copies --;
    }

    snprintf(cptr, sizeof(control) - (size_t)(cptr - control),
             "UdfA%03d%.15s\n"
	     "N%.131s\n",	/* RFC 1179, Section 7.2 - sourcefile name <= 131 chars */
             (int)getpid() % 1000, localhost, title);

    fprintf(stderr, "DEBUG: Control file is:\n%s", control);

    if (order == ORDER_CONTROL_DATA)
    {
     /*
      * Check for side-channel requests...
      */

      backendCheckSideChannel(snmp_fd, &(addr->addr));

     /*
      * Send the control file...
      */

      if (lpd_command(fd, "\002%d cfA%03.3d%.15s\n", strlen(control),
                      (int)getpid() % 1000, localhost))
      {
	close(fd);

        return (CUPS_BACKEND_FAILED);
      }

      fprintf(stderr, "DEBUG: Sending control file (%u bytes)\n",
	      (unsigned)strlen(control));

      if ((size_t)lpd_write(fd, control, strlen(control) + 1) < (strlen(control) + 1))
      {
	status = (char)errno;
	perror("DEBUG: Unable to write control file");

      }
      else
      {
        if (read(fd, &status, 1) < 1)
	{
	  _cupsLangPrintFilter(stderr, "WARNING",
	                       _("The printer did not respond."));
	  status = (char)errno;
	}
      }

      if (status != 0)
	_cupsLangPrintFilter(stderr, "ERROR",
			     _("Remote host did not accept control file (%d)."),
			     status);
      else
	_cupsLangPrintFilter(stderr, "INFO",
	                     _("Control file sent successfully."));
    }
    else
      status = 0;

    if (status == 0)
    {
     /*
      * Check for side-channel requests...
      */

      backendCheckSideChannel(snmp_fd, &(addr->addr));

     /*
      * Send the print file...
      */

      if (lpd_command(fd, "\003" CUPS_LLFMT " dfA%03.3d%.15s\n",
                      CUPS_LLCAST filestats.st_size, (int)getpid() % 1000,
		      localhost))
      {
	close(fd);

        return (CUPS_BACKEND_FAILED);
      }

      fprintf(stderr, "DEBUG: Sending data file (" CUPS_LLFMT " bytes)\n",
	      CUPS_LLCAST filestats.st_size);

      tbytes = 0;
      for (copy = 0; copy < manual_copies; copy ++)
      {
	lseek(print_fd, 0, SEEK_SET);

	while ((nbytes = read(print_fd, buffer, sizeof(buffer))) > 0)
	{
	  _cupsLangPrintFilter(stderr, "INFO",
			       _("Spooling job, %.0f%% complete."),
			       100.0 * tbytes / filestats.st_size);

	  if (lpd_write(fd, buffer, (size_t)nbytes) < nbytes)
	  {
	    perror("DEBUG: Unable to send print file to printer");
            break;
	  }
	  else
            tbytes += nbytes;
	}
      }

      if (mode == MODE_STANDARD)
      {
	if (tbytes < filestats.st_size)
	  status = (char)errno;
	else if (lpd_write(fd, "", 1) < 1)
	{
	  perror("DEBUG: Unable to send trailing nul to printer");
	  status = (char)errno;
	}
	else
	{
	 /*
          * Read the status byte from the printer; if we can't read the byte
	  * back now, we should set status to "errno", however at this point
	  * we know the printer got the whole file and we don't necessarily
	  * want to requeue it over and over...
	  */

          if (recv(fd, &status, 1, 0) < 1)
	  {
	    _cupsLangPrintFilter(stderr, "WARNING",
			         _("The printer did not respond."));
	    status = 0;
          }
	}
      }
      else
        status = 0;

      if (status != 0)
	_cupsLangPrintFilter(stderr, "ERROR",
			     _("Remote host did not accept data file (%d)."),
			     status);
      else
	_cupsLangPrintFilter(stderr, "INFO",
	                     _("Data file sent successfully."));
    }

    if (status == 0 && order == ORDER_DATA_CONTROL)
    {
     /*
      * Check for side-channel requests...
      */

      backendCheckSideChannel(snmp_fd, &(addr->addr));

     /*
      * Send control file...
      */

      if (lpd_command(fd, "\002%d cfA%03.3d%.15s\n", strlen(control),
                      (int)getpid() % 1000, localhost))
      {
	close(fd);

        return (CUPS_BACKEND_FAILED);
      }

      fprintf(stderr, "DEBUG: Sending control file (%lu bytes)\n",
	      (unsigned long)strlen(control));

      if ((size_t)lpd_write(fd, control, strlen(control) + 1) < (strlen(control) + 1))
      {
	status = (char)errno;
	perror("DEBUG: Unable to write control file");
      }
      else
      {
        if (read(fd, &status, 1) < 1)
	{
	  _cupsLangPrintFilter(stderr, "WARNING",
			       _("The printer did not respond."));
	  status = (char)errno;
	}
      }

      if (status != 0)
	_cupsLangPrintFilter(stderr, "ERROR",
			     _("Remote host did not accept control file (%d)."),
			     status);
      else
	_cupsLangPrintFilter(stderr, "INFO",
	                     _("Control file sent successfully."));
    }

    fputs("STATE: +cups-waiting-for-job-completed\n", stderr);

   /*
    * Collect the final supply levels as needed...
    */

    if (have_supplies)
      backendSNMPSupplies(snmp_fd, &(addr->addr), NULL, NULL);

   /*
    * Close the socket connection and input file...
    */

    close(fd);

    if (status == 0)
      return (CUPS_BACKEND_OK);

   /*
    * Waiting for a retry...
    */

    sleep(30);
  }

 /*
  * If we get here, then the job has been canceled...
  */

  return (CUPS_BACKEND_FAILED);
}
Example #13
0
File: lpd.c Project: ezeep/cups
int					/* O - Exit status */
main(int  argc,				/* I - Number of command-line arguments (6 or 7) */
     char *argv[])			/* I - Command-line arguments */
{
  const char	*device_uri;		/* Device URI */
  char		scheme[255],		/* Scheme in URI */
		hostname[1024],		/* Hostname */
		username[255],		/* Username info */
		resource[1024],		/* Resource info (printer name) */
		*options,		/* Pointer to options */
		*name,			/* Name of option */
		*value,			/* Value of option */
		sep,			/* Separator character */
		*filename,		/* File to print */
		title[256];		/* Title string */
  int		port;			/* Port number */
  char		portname[256];		/* Port name (string) */
  http_addrlist_t *addrlist;		/* List of addresses for printer */
  int		snmp_enabled = 1;	/* Is SNMP enabled? */
  int		snmp_fd;		/* SNMP socket */
  int		fd;			/* Print file */
  int		status;			/* Status of LPD job */
  int		mode;			/* Print mode */
  int		banner;			/* Print banner page? */
  int		format;			/* Print format */
  int		order;			/* Order of control/data files */
  int		reserve;		/* Reserve priviledged port? */
  int		sanitize_title;		/* Sanitize title string? */
  int		manual_copies,		/* Do manual copies? */
		timeout,		/* Timeout */
		contimeout,		/* Connection timeout */
		copies;			/* Number of copies */
  ssize_t	bytes = 0;		/* Initial bytes read */
  char		buffer[16384];		/* Initial print buffer */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
  struct sigaction action;		/* Actions for POSIX signals */
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
  int		num_jobopts;		/* Number of job options */
  cups_option_t	*jobopts = NULL;	/* Job options */


 /*
  * Make sure status messages are not buffered...
  */

  setbuf(stderr, NULL);

 /*
  * Ignore SIGPIPE and catch SIGTERM signals...
  */

#ifdef HAVE_SIGSET
  sigset(SIGPIPE, SIG_IGN);
  sigset(SIGTERM, sigterm_handler);
#elif defined(HAVE_SIGACTION)
  memset(&action, 0, sizeof(action));
  action.sa_handler = SIG_IGN;
  sigaction(SIGPIPE, &action, NULL);

  sigemptyset(&action.sa_mask);
  sigaddset(&action.sa_mask, SIGTERM);
  action.sa_handler = sigterm_handler;
  sigaction(SIGTERM, &action, NULL);
#else
  signal(SIGPIPE, SIG_IGN);
  signal(SIGTERM, sigterm_handler);
#endif /* HAVE_SIGSET */

 /*
  * Check command-line...
  */

  if (argc == 1)
  {
    printf("network lpd \"Unknown\" \"%s\"\n",
           _cupsLangString(cupsLangDefault(), _("LPD/LPR Host or Printer")));
    return (CUPS_BACKEND_OK);
  }
  else if (argc < 6 || argc > 7)
  {
    _cupsLangPrintf(stderr,
                    _("Usage: %s job-id user title copies options [file]"),
                    argv[0]);
    return (CUPS_BACKEND_FAILED);
  }

  num_jobopts = cupsParseOptions(argv[5], 0, &jobopts);

 /*
  * Extract the hostname and printer name from the URI...
  */

  while ((device_uri = cupsBackendDeviceURI(argv)) == NULL)
  {
    _cupsLangPrintFilter(stderr, "INFO", _("Unable to locate printer."));
    sleep(10);

    if (getenv("CLASS") != NULL)
      return (CUPS_BACKEND_FAILED);
  }

  httpSeparateURI(HTTP_URI_CODING_ALL, device_uri, scheme, sizeof(scheme),
                  username, sizeof(username), hostname, sizeof(hostname), &port,
		  resource, sizeof(resource));

  if (!port)
    port = 515;				/* Default to port 515 */

  if (!username[0])
  {
   /*
    * If no username is in the device URI, then use the print job user...
    */

    strlcpy(username, argv[2], sizeof(username));
  }

 /*
  * See if there are any options...
  */

  mode          = MODE_STANDARD;
  banner        = 0;
  format        = 'l';
  order         = ORDER_CONTROL_DATA;
  reserve       = RESERVE_ANY;
  manual_copies = 1;
  timeout       = 300;
  contimeout    = 7 * 24 * 60 * 60;

#ifdef __APPLE__
 /*
  * We want to pass UTF-8 characters by default, not re-map them (3071945)
  */

  sanitize_title = 0;
#else
 /*
  * Otherwise we want to re-map UTF-8 to "safe" characters by default...
  */

  sanitize_title = 1;
#endif /* __APPLE__ */

  if ((options = strchr(resource, '?')) != NULL)
  {
   /*
    * Yup, terminate the device name string and move to the first
    * character of the options...
    */

    *options++ = '\0';

   /*
    * Parse options...
    */

    while (*options)
    {
     /*
      * Get the name...
      */

      name = options;

      while (*options && *options != '=' && *options != '+' && *options != '&')
        options ++;

      if ((sep = *options) != '\0')
        *options++ = '\0';

      if (sep == '=')
      {
       /*
        * Get the value...
	*/

        value = options;

	while (*options && *options != '+' && *options != '&')
	  options ++;

        if (*options)
	  *options++ = '\0';
      }
      else
        value = (char *)"";

     /*
      * Process the option...
      */

      if (!_cups_strcasecmp(name, "banner"))
      {
       /*
        * Set the banner...
	*/

        banner = !value[0] || !_cups_strcasecmp(value, "on") ||
		 !_cups_strcasecmp(value, "yes") || !_cups_strcasecmp(value, "true");
      }
      else if (!_cups_strcasecmp(name, "format") && value[0])
      {
       /*
        * Set output format...
	*/

        if (strchr("cdfglnoprtv", value[0]))
	  format = value[0];
	else
	  _cupsLangPrintFilter(stderr, "ERROR",
	                       _("Unknown format character: \"%c\"."),
			       value[0]);
      }
      else if (!_cups_strcasecmp(name, "mode") && value[0])
      {
       /*
        * Set control/data order...
	*/

        if (!_cups_strcasecmp(value, "standard"))
	  mode = MODE_STANDARD;
	else if (!_cups_strcasecmp(value, "stream"))
	  mode = MODE_STREAM;
	else
	  _cupsLangPrintFilter(stderr, "ERROR",
	                       _("Unknown print mode: \"%s\"."), value);
      }
      else if (!_cups_strcasecmp(name, "order") && value[0])
      {
       /*
        * Set control/data order...
	*/

        if (!_cups_strcasecmp(value, "control,data"))
	  order = ORDER_CONTROL_DATA;
	else if (!_cups_strcasecmp(value, "data,control"))
	  order = ORDER_DATA_CONTROL;
	else
	  _cupsLangPrintFilter(stderr, "ERROR",
	                       _("Unknown file order: \"%s\"."), value);
      }
      else if (!_cups_strcasecmp(name, "reserve"))
      {
       /*
        * Set port reservation mode...
	*/

        if (!value[0] || !_cups_strcasecmp(value, "on") ||
	    !_cups_strcasecmp(value, "yes") ||
	    !_cups_strcasecmp(value, "true") ||
	    !_cups_strcasecmp(value, "rfc1179"))
	  reserve = RESERVE_RFC1179;
	else if (!_cups_strcasecmp(value, "any"))
	  reserve = RESERVE_ANY;
	else
	  reserve = RESERVE_NONE;
      }
      else if (!_cups_strcasecmp(name, "manual_copies"))
      {
       /*
        * Set manual copies...
	*/

        manual_copies = !value[0] || !_cups_strcasecmp(value, "on") ||
	 		!_cups_strcasecmp(value, "yes") ||
	 		!_cups_strcasecmp(value, "true");
      }
      else if (!_cups_strcasecmp(name, "sanitize_title"))
      {
       /*
        * Set sanitize title...
	*/

        sanitize_title = !value[0] || !_cups_strcasecmp(value, "on") ||
	 		 !_cups_strcasecmp(value, "yes") ||
	 		 !_cups_strcasecmp(value, "true");
      }
      else if (!_cups_strcasecmp(name, "snmp"))
      {
        /*
         * Enable/disable SNMP stuff...
         */

         snmp_enabled = !value[0] || !_cups_strcasecmp(value, "on") ||
                        !_cups_strcasecmp(value, "yes") ||
                        !_cups_strcasecmp(value, "true");
      }
      else if (!_cups_strcasecmp(name, "timeout"))
      {
       /*
        * Set the timeout...
	*/

	if (atoi(value) > 0)
	  timeout = atoi(value);
      }
      else if (!_cups_strcasecmp(name, "contimeout"))
      {
       /*
        * Set the connection timeout...
	*/

	if (atoi(value) > 0)
	  contimeout = atoi(value);
      }
    }
  }

  if (mode == MODE_STREAM)
    order = ORDER_CONTROL_DATA;

 /*
  * Find the printer...
  */

  snprintf(portname, sizeof(portname), "%d", port);

  fputs("STATE: +connecting-to-device\n", stderr);
  fprintf(stderr, "DEBUG: Looking up \"%s\"...\n", hostname);

  while ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, portname)) == NULL)
  {
    _cupsLangPrintFilter(stderr, "INFO",
			 _("Unable to locate printer \"%s\"."), hostname);
    sleep(10);

    if (getenv("CLASS") != NULL)
    {
      fputs("STATE: -connecting-to-device\n", stderr);
      exit(CUPS_BACKEND_FAILED);
    }
  }

  if (snmp_enabled)
    snmp_fd = _cupsSNMPOpen(addrlist->addr.addr.sa_family);
  else
    snmp_fd = -1;

 /*
  * Wait for data from the filter...
  */

  if (argc == 6)
  {
    if (!backendWaitLoop(snmp_fd, &(addrlist->addr), 0, backendNetworkSideCB))
      return (CUPS_BACKEND_OK);
    else if (mode == MODE_STANDARD &&
             (bytes = read(0, buffer, sizeof(buffer))) <= 0)
      return (CUPS_BACKEND_OK);
  }

 /*
  * If we have 7 arguments, print the file named on the command-line.
  * Otherwise, copy stdin to a temporary file and print the temporary
  * file.
  */

  if (argc == 6 && mode == MODE_STANDARD)
  {
   /*
    * Copy stdin to a temporary file...
    */

    if ((fd = cupsTempFd(tmpfilename, sizeof(tmpfilename))) < 0)
    {
      perror("DEBUG: Unable to create temporary file");
      return (CUPS_BACKEND_FAILED);
    }

    _cupsLangPrintFilter(stderr, "INFO", _("Copying print data."));

    if (bytes > 0)
      write(fd, buffer, (size_t)bytes);

    backendRunLoop(-1, fd, snmp_fd, &(addrlist->addr), 0, 0,
		   backendNetworkSideCB);
  }
  else if (argc == 6)
  {
   /*
    * Stream from stdin...
    */

    filename = NULL;
    fd       = 0;
  }
  else
  {
    filename = argv[6];
    fd       = open(filename, O_RDONLY);

    if (fd == -1)
    {
      _cupsLangPrintError("ERROR", _("Unable to open print file"));
      return (CUPS_BACKEND_FAILED);
    }
  }

 /*
  * Sanitize the document title...
  */

  strlcpy(title, argv[3], sizeof(title));

  if (sanitize_title)
  {
   /*
    * Sanitize the title string so that we don't cause problems on
    * the remote end...
    */

    char *ptr;

    for (ptr = title; *ptr; ptr ++)
      if (!isalnum(*ptr & 255) && !isspace(*ptr & 255))
	*ptr = '_';
  }

 /*
  * Queue the job...
  */

  if (argc > 6)
  {
    if (manual_copies)
    {
      manual_copies = atoi(argv[4]);
      copies        = 1;
    }
    else
    {
      manual_copies = 1;
      copies        = atoi(argv[4]);
    }

    status = lpd_queue(hostname, addrlist, resource + 1, fd, snmp_fd, mode,
                       username, title, copies, banner, format, order, reserve,
		       manual_copies, timeout, contimeout,
		       cupsGetOption("job-originating-host-name", num_jobopts,
		                     jobopts));

    if (!status)
      fprintf(stderr, "PAGE: 1 %d\n", atoi(argv[4]));
  }
  else
    status = lpd_queue(hostname, addrlist, resource + 1, fd, snmp_fd, mode,
                       username, title, 1, banner, format, order, reserve, 1,
		       timeout, contimeout,
		       cupsGetOption("job-originating-host-name", num_jobopts,
		                     jobopts));

 /*
  * Remove the temporary file if necessary...
  */

  if (tmpfilename[0])
    unlink(tmpfilename);

  if (fd)
    close(fd);

  if (snmp_fd >= 0)
    _cupsSNMPClose(snmp_fd);

 /*
  * Return the queue status...
  */

  return (status);
}
Example #14
0
ApplicationIcons::ApplicationIcons(wxWizard* parent, wxWizardPageSimple* prev)
{
  //(*Initialize(ApplicationIcons)
  wxBoxSizer* BoxSizer4;
  wxBoxSizer* BoxSizer6;
  wxBoxSizer* BoxSizer19;
  wxBoxSizer* BoxSizer5;
  wxBoxSizer* BoxSizer10;
  wxBoxSizer* BoxSizer7;
  wxBoxSizer* BoxSizer8;
  wxStaticText* StaticText2;
  wxBoxSizer* BoxSizer13;
  wxStaticBitmap* StaticBitmap1;
  wxStaticText* StaticText8;
  wxStaticText* StaticText1;
  wxBoxSizer* BoxSizer2;
  wxStaticText* StaticText3;
  wxBoxSizer* BoxSizer11;
  wxBoxSizer* BoxSizer12;
  wxBoxSizer* BoxSizer14;
  wxStaticText* StaticText7;
  wxBoxSizer* BoxSizer1;
  wxBoxSizer* BoxSizer9;
  wxBoxSizer* BoxSizer3;

  Create(parent, prev);
  BoxSizer1 = new wxBoxSizer(wxVERTICAL);
  Panel1 = new wxPanel(this, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL1"));
  Panel1->SetBackgroundColour( wxColour( 255, 255, 255));
  BoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
  BoxSizer5 = new wxBoxSizer(wxVERTICAL);
  BoxSizer6 = new wxBoxSizer(wxHORIZONTAL);
  BoxSizer6->Add(35,20,0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  StaticText2 = new wxStaticText(Panel1, ID_STATICTEXT2, _("Application Icons"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT2"));
  wxFont StaticText2Font(10,wxFONTFAMILY_SWISS,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD,false,wxEmptyString,wxFONTENCODING_DEFAULT);
  StaticText2->SetFont(StaticText2Font);
  BoxSizer6->Add(StaticText2, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer5->Add(BoxSizer6, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer7 = new wxBoxSizer(wxHORIZONTAL);
  BoxSizer7->Add(35,20,0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  StaticText1 = new wxStaticText(Panel1, ID_STATICTEXT1, _("    Please specify which icons should be created for your application."), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1"));
  BoxSizer7->Add(StaticText1, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer5->Add(BoxSizer7, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer4->Add(BoxSizer5, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer4->Add(-1,-1,1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  StaticBitmap1 = new wxStaticBitmap(Panel1, wxID_ANY, wxBitmap(LinksOben_xpm), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
  BoxSizer4->Add(StaticBitmap1, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  Panel1->SetSizer(BoxSizer4);
  BoxSizer4->Fit(Panel1);
  BoxSizer4->SetSizeHints(Panel1);
  BoxSizer1->Add(Panel1, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  StaticLine1 = new wxStaticLine(this, ID_STATICLINE1, wxDefaultPosition, wxSize(10,-1), wxLI_HORIZONTAL, _T("ID_STATICLINE1"));
  BoxSizer1->Add(StaticLine1, 0, wxBOTTOM|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
  BoxSizer2->Add(75,20,0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  StaticText3 = new wxStaticText(this, ID_STATICTEXT3, _("Application Start Menu folder name:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT3"));
  wxFont StaticText3Font(8,wxFONTFAMILY_SWISS,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD,false,wxEmptyString,wxFONTENCODING_DEFAULT);
  StaticText3->SetFont(StaticText3Font);
  BoxSizer2->Add(StaticText3, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer2->Add(-1,-1,1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer1->Add(BoxSizer2, 0, wxLEFT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer11 = new wxBoxSizer(wxHORIZONTAL);
  BoxSizer11->Add(75,20,0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  txtMenuFolder = new wxTextCtrl(this, ID_TEXTCTRL2, wxEmptyString, wxDefaultPosition, wxSize(221,21), 0, wxDefaultValidator, _T("ID_TEXTCTRL2"));
  BoxSizer11->Add(txtMenuFolder, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer11->Add(-1,-1,1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer1->Add(BoxSizer11, 0, wxTOP|wxLEFT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer10 = new wxBoxSizer(wxHORIZONTAL);
  BoxSizer10->Add(75,20,0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  cbChangeStartMenu = new wxCheckBox(this, ID_CHECKBOX4, _("Allow user to change the Start Menu folder name"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX4"));
  cbChangeStartMenu->SetValue(true);
  BoxSizer10->Add(cbChangeStartMenu, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer10->Add(-1,-1,1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer1->Add(BoxSizer10, 0, wxTOP|wxLEFT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer8 = new wxBoxSizer(wxHORIZONTAL);
  BoxSizer8->Add(75,20,0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  cbDisableStartMenu = new wxCheckBox(this, ID_CHECKBOX3, _("Allow user to disable Start Menu folder creation"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX3"));
  cbDisableStartMenu->SetValue(false);
  BoxSizer8->Add(cbDisableStartMenu, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer8->Add(-1,-1,1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer1->Add(BoxSizer8, 0, wxTOP|wxLEFT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
  BoxSizer3->Add(75,20,0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  cbInternetShort = new wxCheckBox(this, ID_CHECKBOX1, _("Create an Internet shortcut in the Start Menu folder"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX1"));
  cbInternetShort->SetValue(false);
  BoxSizer3->Add(cbInternetShort, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer3->Add(-1,-1,1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer1->Add(BoxSizer3, 0, wxTOP|wxLEFT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer9 = new wxBoxSizer(wxHORIZONTAL);
  BoxSizer9->Add(75,20,0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  cbUninstallShortCut = new wxCheckBox(this, ID_CHECKBOX2, _("Create an Uninstall icon in the Start Menu folder"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX2"));
  cbUninstallShortCut->SetValue(false);
  BoxSizer9->Add(cbUninstallShortCut, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer9->Add(-1,-1,1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer1->Add(BoxSizer9, 0, wxTOP|wxLEFT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer12 = new wxBoxSizer(wxHORIZONTAL);
  BoxSizer12->Add(75,20,0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  text2 = new wxStaticText(this, ID_STATICTEXT4, _("Other main executable icons:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT4"));
  BoxSizer12->Add(text2, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer12->Add(-1,-1,1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer1->Add(BoxSizer12, 0, wxTOP|wxLEFT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer14 = new wxBoxSizer(wxHORIZONTAL);
  BoxSizer14->Add(75,20,0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  cbDesktopIcon = new wxCheckBox(this, ID_CHECKBOX6, _("Allow user to create a desktop icon"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX6"));
  cbDesktopIcon->SetValue(true);
  BoxSizer14->Add(cbDesktopIcon, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer14->Add(-1,-1,1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer1->Add(BoxSizer14, 0, wxTOP|wxLEFT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer13 = new wxBoxSizer(wxHORIZONTAL);
  BoxSizer13->Add(75,20,0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  cbQuickLunchShortCut = new wxCheckBox(this, ID_CHECKBOX5, _("Allow user to create a Quick Launch icon"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX5"));
  cbQuickLunchShortCut->SetValue(false);
  BoxSizer13->Add(cbQuickLunchShortCut, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer13->Add(-1,-1,1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer1->Add(BoxSizer13, 0, wxTOP|wxLEFT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer19 = new wxBoxSizer(wxHORIZONTAL);
  BoxSizer19->Add(75,20,0, wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  StaticText7 = new wxStaticText(this, ID_STATICTEXT7, _("bold"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT7"));
  StaticText7->Disable();
  wxFont StaticText7Font(8,wxFONTFAMILY_SWISS,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD,false,_T("Arial"),wxFONTENCODING_DEFAULT);
  StaticText7->SetFont(StaticText7Font);
  BoxSizer19->Add(StaticText7, 0, wxLEFT|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  StaticText8 = new wxStaticText(this, ID_STATICTEXT8, _("= required"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT8"));
  StaticText8->Disable();
  BoxSizer19->Add(StaticText8, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  BoxSizer1->Add(BoxSizer19, 0, wxLEFT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  SetSizer(BoxSizer1);
  SetSizer(BoxSizer1);
  Layout();

  Connect(ID_CHECKBOX4,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&ApplicationIcons::OncbChangeStartMenuClick);
  //*)
  SetSize( wxSize(480,320));
}
Example #15
0
wxString wxGetStockHelpString(wxWindowID id, wxStockHelpStringClient client)
{
    wxString stockHelp;

    #define STOCKITEM(stockid, ctx, helpstr)             \
        case stockid:                                    \
            if (client==ctx) stockHelp = helpstr;        \
            break;

    switch (id)
    {
        // NB: these help string should be not too specific as they could be used
        //     in completely different programs!
        STOCKITEM(wxID_ABOUT,    wxSTOCK_MENU, _("Show about dialog"))
        STOCKITEM(wxID_COPY,     wxSTOCK_MENU, _("Copy selection"))
        STOCKITEM(wxID_CUT,      wxSTOCK_MENU, _("Cut selection"))
        STOCKITEM(wxID_DELETE,   wxSTOCK_MENU, _("Delete selection"))
        STOCKITEM(wxID_REPLACE,  wxSTOCK_MENU, _("Replace selection"))
        STOCKITEM(wxID_PASTE,    wxSTOCK_MENU, _("Paste selection"))
        STOCKITEM(wxID_EXIT,     wxSTOCK_MENU, _("Quit this program"))
        STOCKITEM(wxID_REDO,     wxSTOCK_MENU, _("Redo last action"))
        STOCKITEM(wxID_UNDO,     wxSTOCK_MENU, _("Undo last action"))
        STOCKITEM(wxID_CLOSE,    wxSTOCK_MENU, _("Close current document"))
        STOCKITEM(wxID_SAVE,     wxSTOCK_MENU, _("Save current document"))
        STOCKITEM(wxID_SAVEAS,   wxSTOCK_MENU, _("Save current document with a different filename"))

        default:
            // there's no stock help string for this ID / client
            break;
    }

    #undef STOCKITEM

    return stockHelp;
}
Example #16
0
int
fe_args (int argc, char *argv[])
{
	GError *error = NULL;
	GOptionContext *context;

#ifdef ENABLE_NLS
	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
#endif

	context = g_option_context_new (NULL);
	g_option_context_add_main_entries (context, gopt_entries, GETTEXT_PACKAGE);
	g_option_context_parse (context, &argc, &argv, &error);
	
	if (error)
	{
		if (error->message)
			printf ("%s\n", error->message);
		return 1;
	}

	g_option_context_free (context);

	if (arg_show_version)
	{
		printf (PACKAGE_TARNAME" "PACKAGE_VERSION"\n");
		return 0;
	}

	if (arg_show_autoload)
	{
#ifdef WIN32
		/* see the chdir() below */
		char *sl, *exe = strdup (argv[0]);
		sl = strrchr (exe, '\\');
		if (sl)
		{
			*sl = 0;
			printf ("%s\\plugins\n", exe);
		}
		free (exe);
#else
		printf ("%s\n", HEXCHATLIBDIR"/plugins");
#endif
		return 0;
	}

	if (arg_show_config)
	{
		printf ("%s\n", get_xdir ());
		return 0;
	}

	if (arg_cfgdir)	/* we want filesystem encoding */
	{
		if (xdir)
			g_free (xdir);
		xdir = strdup (arg_cfgdir);
		if (xdir[strlen (xdir) - 1] == '/')
			xdir[strlen (xdir) - 1] = 0;
		g_free (arg_cfgdir);
	}

	g_type_init ();
	
#ifndef WIN32
#ifndef __EMX__
		/* OS/2 uses UID 0 all the time */
		if (getuid () == 0)
			fe_message (_("* Running IRC as root is stupid! You should\n"
							"  create a User Account and use that to login.\n"), FE_MSG_WARN|FE_MSG_WAIT);
#endif
#endif /* !WIN32 */

	return -1;
}
Example #17
0
static void _preferences_window(Camera * camera)
{
	GtkWidget * dialog;
	GtkWidget * notebook;
	GtkWidget * vbox;
	GtkWidget * widget;
	GtkListStore * store;
	GtkTreeIter iter;
	GtkCellRenderer * renderer;
	const struct {
		GdkInterpType type;
		char const * name;
	} interp[] =
	{
		{ GDK_INTERP_NEAREST, N_("Nearest") },
		{ GDK_INTERP_TILES, N_("Tiles") },
		{ GDK_INTERP_BILINEAR, N_("Bilinear") },
		{ GDK_INTERP_HYPER, N_("Hyperbolic") },
	};
	const struct {
		CameraSnapshotFormat format;
		char const * name;
	} sformats[CSF_COUNT - 1] =
	{
		{ CSF_JPEG, "JPEG" },
		{ CSF_PNG, "PNG" }
	};
	size_t i;

	dialog = gtk_dialog_new_with_buttons(_("Preferences"),
			GTK_WINDOW(camera->window),
			GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
			GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
			GTK_STOCK_APPLY, GTK_RESPONSE_APPLY,
			GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
	gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
	camera->pr_window = dialog;
	g_signal_connect(dialog, "response", G_CALLBACK(
				_preferences_on_response), camera);
	notebook = gtk_notebook_new();
	/* picture */
#if GTK_CHECK_VERSION(3, 0, 0)
	vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
#else
	vbox = gtk_vbox_new(FALSE, 4);
#endif
	camera->pr_hflip = gtk_check_button_new_with_mnemonic(
			_("Flip _horizontally"));
	gtk_box_pack_start(GTK_BOX(vbox), camera->pr_hflip, FALSE, TRUE, 0);
	camera->pr_vflip = gtk_check_button_new_with_mnemonic(
			_("Flip _vertically"));
	gtk_box_pack_start(GTK_BOX(vbox), camera->pr_vflip, FALSE, TRUE, 0);
	camera->pr_ratio = gtk_check_button_new_with_mnemonic(
			_("Keep aspect _ratio"));
	gtk_box_pack_start(GTK_BOX(vbox), camera->pr_ratio, FALSE, TRUE, 0);
	/* interpolation */
#if GTK_CHECK_VERSION(3, 0, 0)
	widget = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
#else
	widget = gtk_hbox_new(FALSE, 4);
#endif
	gtk_box_pack_start(GTK_BOX(widget), gtk_label_new(_("Interpolation: ")),
			FALSE, TRUE, 0);
	store = gtk_list_store_new(2, G_TYPE_UINT, G_TYPE_STRING);
	for(i = 0; i < sizeof(interp) / sizeof(*interp); i++)
	{
		gtk_list_store_append(store, &iter);
		gtk_list_store_set(store, &iter, 0, interp[i].type,
				1, _(interp[i].name), -1);
	}
	camera->pr_interp = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
	renderer = gtk_cell_renderer_text_new();
	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(camera->pr_interp), renderer,
			TRUE);
	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(camera->pr_interp),
			renderer, "text", 1, NULL);
	gtk_box_pack_start(GTK_BOX(widget), camera->pr_interp, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), widget, FALSE, TRUE, 0);
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
			gtk_label_new(_("Picture")));
	/* snapshots */
#if GTK_CHECK_VERSION(3, 0, 0)
	vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
#else
	vbox = gtk_vbox_new(FALSE, 4);
#endif
	/* format */
#if GTK_CHECK_VERSION(3, 0, 0)
	widget = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
#else
	widget = gtk_hbox_new(FALSE, 4);
#endif
	gtk_box_pack_start(GTK_BOX(widget), gtk_label_new(_("Format: ")),
			FALSE, TRUE, 0);
	store = gtk_list_store_new(2, G_TYPE_UINT, G_TYPE_STRING);
	for(i = 0; i < sizeof(sformats) / sizeof(*sformats); i++)
	{
		gtk_list_store_append(store, &iter);
		gtk_list_store_set(store, &iter, 0, sformats[i].format,
				1, sformats[i].name, -1);
	}
	camera->pr_sformat = gtk_combo_box_new_with_model(
			GTK_TREE_MODEL(store));
	renderer = gtk_cell_renderer_text_new();
	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(camera->pr_sformat),
			renderer, TRUE);
	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(camera->pr_sformat),
			renderer, "text", 1, NULL);
	gtk_box_pack_start(GTK_BOX(widget), camera->pr_sformat, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), widget, FALSE, TRUE, 0);
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
			gtk_label_new(_("Snapshots")));
#if GTK_CHECK_VERSION(2, 14, 0)
	vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
#else
	vbox = dialog->vbox;
#endif
	gtk_box_set_spacing(GTK_BOX(vbox), 4);
	gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);
	gtk_widget_show_all(vbox);
	_preferences_cancel(camera);
}
static void
gth_file_tool_rotate_right_init (GthFileToolRotateRight *self)
{
	gth_file_tool_construct (GTH_FILE_TOOL (self), "object-rotate-right-symbolic", _("Rotate Right"), NULL, TRUE);
	gtk_widget_set_tooltip_text (GTK_WIDGET (self), _("Rotate the image by 90 degrees clockwise"));
}
Example #19
0
static void got_buddy_list_cb(FacebookAccount *fba, gchar *data,
                              gsize data_len, gpointer userdata)
{
    GSList *buddies_list;
    GSList *online_buddies_list = NULL;
    PurpleBuddy *buddy;
    FacebookBuddy *fbuddy;
    gchar *uid;
    gchar *name;
    gchar *status_text;
    gchar *status_time_text;
    gchar *buddy_icon_url;
    gboolean idle;
    guint32 error_number;

    gchar *search_start;
    gchar *search_tmp;
    gchar *tmp;
    gchar *largest_buddy_search_point = NULL;

    PurpleGroup *fb_group = NULL;

    gboolean current_buddy_online = FALSE;

    purple_debug_info("facebook", "parsing buddy list\n");
    purple_debug_misc("facebook", "buddy list\n%s\n", data);

    if (fba == NULL)
        return;

    if (data == NULL) {
        purple_connection_error_reason(fba->pc,
                                       PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
                                       _("Could not retrieve buddy list"));
        return;
    }

    /* Check if the facebook group already exists (fixes #13) */
    fb_group = purple_find_group("Facebook");

    /* if logged out, this comes up */
    /* for (;;);{"error":1357001,"errorSummary":"Not Logged In",
    	"errorDescription":"You must be logged in to do that.",
    	"payload":null,"bootload":[{"name":"js\/common.js.pkg.php",
    	"type":"js","src":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/pkg\/59\
    	/98561\/js\/common.js.pkg.php"}]} */
    tmp = g_strstr_len(data, data_len, "\"error\":");
    if (tmp != NULL)
    {
        tmp += 9;
        tmp = g_strndup(tmp, strchr(tmp, ',')-tmp);
        error_number = atoi(tmp);
        g_free(tmp);
        if (error_number)
        {
            /* error :( */
            tmp = g_strstr_len(data, data_len, "\"errorDescription\":");
            tmp += 20;
            tmp = g_strndup(tmp, strchr(tmp, '"')-tmp);
            /* TODO: Use purple_connection_error_reason() */
            purple_connection_error(fba->pc, tmp);
            g_free(tmp);
            return;
        }
    }

    /* look for "userInfos":{ ... }, */
    search_start = strstr(data, "\"userInfos\":{");
    if (search_start == NULL)
        return;
    search_start += 13;

    while (*search_start != '}' && (search_start - data < data_len))
    {
        tmp = strchr(search_start, ':');
        uid = g_strndup(search_start+1, tmp-search_start-2);
        /* purple_debug_misc("facebook", "uid: %s\n", uid); */

        search_start += strlen(uid) + 2;

        search_tmp = strstr(search_start, "\"name\":") + 8;
        if (search_tmp > largest_buddy_search_point)
            largest_buddy_search_point = search_tmp;
        search_tmp = g_strndup(search_tmp, strchr(search_tmp, '"')-search_tmp);
        name = fb_convert_unicode(search_tmp);
        g_free(search_tmp);
        /* purple_debug_misc("facebook", "name: %s\n", name); */

        /* try updating the alias, just in case it was removed locally */
        serv_got_alias(fba->pc, uid, name);

        /* look for "uid":{"i":_____} */
        tmp = g_strdup_printf("\"%s\":{\"i\":", uid);
        search_tmp = g_strstr_len(data, data_len, tmp);
        if (search_tmp != NULL)
        {
            search_tmp += strlen(tmp);
            if (search_tmp > largest_buddy_search_point)
                largest_buddy_search_point = search_tmp;
            search_tmp = g_strndup(search_tmp, strchr(search_tmp, '}')-search_tmp);
            /* purple_debug_misc("facebook", "buddy idle: %s\n", search_tmp); */
            buddy = purple_find_buddy(fba->account, uid);
            idle = g_str_equal(search_tmp, "true");
            g_free(search_tmp);
            current_buddy_online = TRUE;
        } else {
            /* if we're here, the buddy's info has been sent, but they're not actually online */
            current_buddy_online = FALSE;
            idle = FALSE;
        }
        g_free(tmp);

        /* Set the buddy status text and time */
        search_tmp = strstr(search_start, "\"status\":");
        if (search_tmp != NULL && *(search_tmp + 9) == '"')
        {
            search_tmp += 10;
            if (search_tmp > largest_buddy_search_point)
                largest_buddy_search_point = strstr(search_tmp, ",\"statusTime");
            search_tmp = g_strndup(search_tmp, strstr(search_tmp, ",\"statusTime")-1-search_tmp);
            status_text = fb_convert_unicode(search_tmp);
            g_free(search_tmp);
        } else {
            status_text = NULL;
        }

        /* is this us? */
        if (atoi(uid) == fba->uid)
        {
            purple_connection_set_display_name(fba->pc, name);

            /* set our last known status so that we don't re-set it */
            if (status_text && !fba->last_status_message)
                fba->last_status_message = g_strdup(status_text);

            /* check that we don't want to show ourselves */
            if (purple_account_get_bool(fba->account, "facebook_hide_self", TRUE))
            {
                g_free(status_text);
                g_free(name);
                g_free(uid);

                /* Move pointer to the end of the buddy entry */
                search_start = strchr(largest_buddy_search_point, '}') + 1;
                while (*search_start == ',' && (search_start - data < data_len))
                    search_start++;
                /* go on to the next buddy */
                continue;
            } else {
                current_buddy_online = TRUE;
            }
        }

        /* Is this a new buddy? */
        buddy = purple_find_buddy(fba->account, uid);
        if (buddy == NULL)
        {
            buddy = purple_buddy_new(fba->account, uid, NULL);
            if (fb_group == NULL)
            {
                fb_group = purple_group_new("Facebook");
                purple_blist_add_group(fb_group, NULL);
            }
            purple_blist_add_buddy(buddy, NULL, fb_group, NULL);
        }
        serv_got_alias(fba->pc, uid, name);
        purple_presence_set_idle(purple_buddy_get_presence(buddy), idle, 0);

        /* Set the FacebookBuddy structure */
        if (buddy->proto_data == NULL)
        {
            fbuddy = g_new0(FacebookBuddy, 1);
            fbuddy->buddy = buddy;
            fbuddy->fba = fba;
            fbuddy->uid = atoi(uid);
            fbuddy->name = g_strdup(name);

            /* load the old buddy icon from the account settings */
            tmp = g_strdup_printf("buddy_icon_%d_cache", fbuddy->uid);
            fbuddy->thumb_url = g_strdup(purple_account_get_string(fba->account, tmp, ""));
            g_free(tmp);

            buddy->proto_data = fbuddy;
        } else {
            fbuddy = buddy->proto_data;
        }

        g_free(uid);
        g_free(name);

        if (status_text != NULL)
        {
            tmp = fb_strdup_withhtml(status_text);
            g_free(status_text);
            status_text = tmp;
            /* purple_debug_misc("facebook", "status: %s\n", status_text); */

            search_tmp = strstr(search_start, "\"statusTimeRel\":") + 17;
            if (search_tmp > largest_buddy_search_point)
                largest_buddy_search_point = strchr(search_tmp, '"');
            search_tmp = g_strndup(search_tmp, strchr(search_tmp, '"')-search_tmp);
            status_time_text = fb_convert_unicode(search_tmp);
            g_free(search_tmp);

            if (g_str_equal(status_time_text, "ull,"))
            {
                g_free(status_time_text);
                status_time_text = NULL;
            }
            g_free(fbuddy->status_rel_time);
            if (status_time_text != NULL)
            {
                fbuddy->status_rel_time = fb_strdup_withhtml(status_time_text);
                g_free(status_time_text);
                /* purple_debug_misc("facebook", "status time: %s\n", fbuddy->status_rel_time); */
            } else {
                fbuddy->status_rel_time = NULL;
            }

            /* if the buddy status has changed, update the contact list */
            if (fbuddy->status == NULL || !g_str_equal(fbuddy->status, status_text))
            {
                tmp = fbuddy->status;
                fbuddy->status = status_text;
                g_free(tmp);
                if (current_buddy_online)
                    purple_prpl_got_user_status(fba->account, buddy->name, purple_primitive_get_id_from_type(PURPLE_STATUS_AVAILABLE), NULL);
            } else {
                g_free(status_text);
            }
        } else {
            if (fbuddy->status != NULL)
            {
                g_free(fbuddy->status);
                fbuddy->status = NULL;
                if (current_buddy_online)
                {
                    /* update the status in the contact list */
                    purple_prpl_got_user_status(fba->account, buddy->name, purple_primitive_get_id_from_type(PURPLE_STATUS_AVAILABLE), NULL);
                }
            }
        }

        /* Set the buddy icon (if it hasn't changed) */
        search_tmp = strstr(search_start, "\"thumbSrc\":") + 12;
        if (search_tmp > largest_buddy_search_point)
            largest_buddy_search_point = search_tmp;
        buddy_icon_url = g_strndup(search_tmp, strchr(search_tmp, '"')-search_tmp);
        if (fbuddy->thumb_url == NULL || !g_str_equal(fbuddy->thumb_url, buddy_icon_url))
        {
            g_free(fbuddy->thumb_url);
            fbuddy->thumb_url = g_strdup(buddy_icon_url);

            /* Save the buddy icon so that they don't all need to be reloaded at startup */
            tmp = g_strdup_printf("buddy_icon_%d_cache", fbuddy->uid);
            purple_account_set_string(fba->account, tmp, buddy_icon_url);
            g_free(tmp);

            /* Turn the \/ into / */
            tmp = g_strcompress(buddy_icon_url);

            /* small icon at http://profile.ak.facebook.com/profile6/1845/74/q800753867_2878.jpg */
            /* bigger icon at http://profile.ak.facebook.com/profile6/1845/74/n800753867_2878.jpg */
            search_tmp = strstr(tmp, "/q");
            if (search_tmp)
                *(search_tmp + 1) = 'n';

            if (g_str_equal(tmp, "http://static.ak.fbcdn.net/pics/q_silhouette.gif"))
                /* User has no icon */
                purple_buddy_icons_set_for_user(fba->account,
                                                purple_buddy_get_name(buddy), NULL, 0, NULL);
            else
                /* Fetch their icon */
                fb_post_or_get(fba, FB_METHOD_GET, "profile.ak.facebook.com",
                               tmp + strlen("http://profile.ak.facebook.com"), NULL,
                               buddy_icon_cb, g_strdup(purple_buddy_get_name(buddy)),
                               FALSE);
            g_free(tmp);
        }
        g_free(buddy_icon_url);

        if (current_buddy_online)
        {
            /* Add buddy to the list of online buddies */
            online_buddies_list = g_slist_append(online_buddies_list, buddy);

            /* Update the display of the buddy in the buddy list and make the user online */
            if (!PURPLE_BUDDY_IS_ONLINE(buddy))
                purple_prpl_got_user_status(fba->account, buddy->name, purple_primitive_get_id_from_type(PURPLE_STATUS_AVAILABLE), NULL);
        }

        /* Move pointer after any user configurable data */
        search_start = search_tmp;
        /* Move pointer to the end of the buddy entry */
        search_start = strchr(largest_buddy_search_point, '}') + 1;
        while (*search_start == ',' && (search_start - data < data_len))
            search_start++;
    }

    buddies_list = purple_find_buddies(fba->account, NULL);
    if (buddies_list != NULL)
    {
        g_slist_foreach(buddies_list, (GFunc)set_buddies_offline, online_buddies_list);
        g_slist_free(buddies_list);
    }
    g_slist_free(online_buddies_list);
}
Example #20
0
HeaderView *headerview_create(void)
{
	HeaderView *headerview;
	GtkWidget *hbox;
	GtkWidget *vbox;
	GtkWidget *hbox1;
	GtkWidget *hbox2;
	GtkWidget *hbox3;
	GtkWidget *from_header_label;
	GtkWidget *from_body_label;
	GtkWidget *to_header_label;
	GtkWidget *to_body_label;
	GtkWidget *ng_header_label;
	GtkWidget *ng_body_label;
	GtkWidget *subject_header_label;
	GtkWidget *subject_body_label;
	GtkWidget *tags_header_label;
	GtkWidget *tags_body_label;

	debug_print("Creating header view...\n");
	headerview = g_new0(HeaderView, 1);

	hbox = gtk_hbox_new(FALSE, 0);
	gtk_container_set_border_width(GTK_CONTAINER(hbox), 2);
	vbox = gtk_vbox_new(FALSE, 2);
	gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);

	hbox1 = gtk_hbox_new(FALSE, 4);
	gtk_box_pack_start(GTK_BOX(vbox), hbox1, FALSE, FALSE, 0);
	hbox2 = gtk_hbox_new(FALSE, 4);
	gtk_box_pack_start(GTK_BOX(vbox), hbox2, FALSE, FALSE, 0);
	hbox3 = gtk_hbox_new(FALSE, 4);
	gtk_box_pack_start(GTK_BOX(vbox), hbox3, FALSE, FALSE, 0);

	from_header_label    = gtk_label_new(prefs_common_translated_header_name("From:"));
	from_body_label      = gtk_label_new("");
	to_header_label      = gtk_label_new(prefs_common_translated_header_name("To:"));
	to_body_label        = gtk_label_new("");
	ng_header_label      = gtk_label_new(prefs_common_translated_header_name("Newsgroups:"));
	ng_body_label        = gtk_label_new("");
	subject_header_label = gtk_label_new(prefs_common_translated_header_name("Subject:"));
	subject_body_label   = gtk_label_new("");
	tags_header_label = gtk_label_new(_("Tags:"));
	tags_body_label   = gtk_label_new("");

	gtk_label_set_selectable(GTK_LABEL(from_body_label), TRUE);
	gtk_label_set_selectable(GTK_LABEL(to_body_label), TRUE);
	gtk_label_set_selectable(GTK_LABEL(ng_body_label), TRUE);
	gtk_label_set_selectable(GTK_LABEL(subject_body_label), TRUE);
	gtk_label_set_selectable(GTK_LABEL(tags_body_label), TRUE);

	gtkut_widget_set_can_focus(from_body_label, FALSE);
	gtkut_widget_set_can_focus(to_body_label, FALSE);
	gtkut_widget_set_can_focus(ng_body_label, FALSE);
	gtkut_widget_set_can_focus(subject_body_label, FALSE);
	gtkut_widget_set_can_focus(tags_body_label, FALSE);

	gtk_box_pack_start(GTK_BOX(hbox1), from_header_label, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(hbox1), from_body_label, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(hbox1), to_header_label, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(hbox1), to_body_label, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(hbox1), ng_header_label, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(hbox1), ng_body_label, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(hbox2), subject_header_label, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(hbox2), subject_body_label, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(hbox3), tags_header_label, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(hbox3), tags_body_label, TRUE, TRUE, 0);

	gtk_misc_set_alignment(GTK_MISC(to_body_label), 0, 0.5);
	gtk_misc_set_alignment(GTK_MISC(ng_body_label), 0, 0.5);
	gtk_misc_set_alignment(GTK_MISC(subject_body_label), 0, 0.5);
	gtk_misc_set_alignment(GTK_MISC(tags_body_label), 0, 0.5);
	gtk_label_set_ellipsize(GTK_LABEL(to_body_label), PANGO_ELLIPSIZE_END);
	gtk_label_set_ellipsize(GTK_LABEL(ng_body_label), PANGO_ELLIPSIZE_END);
	gtk_label_set_ellipsize(GTK_LABEL(subject_body_label), PANGO_ELLIPSIZE_END);
	gtk_label_set_ellipsize(GTK_LABEL(tags_body_label), PANGO_ELLIPSIZE_END);

	headerview->hbox = hbox;
	headerview->from_header_label    = from_header_label;
	headerview->from_body_label      = from_body_label;
	headerview->to_header_label      = to_header_label;
	headerview->to_body_label        = to_body_label;
	headerview->ng_header_label      = ng_header_label;
	headerview->ng_body_label        = ng_body_label;
	headerview->subject_header_label = subject_header_label;
	headerview->subject_body_label   = subject_body_label;
	headerview->tags_header_label = tags_header_label;
	headerview->tags_body_label   = tags_body_label;
	headerview->image = NULL;

	gtk_widget_show_all(hbox);

	return headerview;
}
Example #21
0
/* Loop though files in a package and perform full file property checking. */
int check_pkg_full(alpm_pkg_t *pkg)
{
	const char *root, *pkgname;
	size_t errors = 0;
	size_t rootlen;
	struct archive *mtree;
	struct archive_entry *entry = NULL;
	size_t file_count = 0;
	const alpm_list_t *lp;

	root = alpm_option_get_root(config->handle);
	rootlen = strlen(root);
	if(rootlen + 1 > PATH_MAX) {
		/* we are in trouble here */
		pm_printf(ALPM_LOG_ERROR, _("path too long: %s%s\n"), root, "");
		return 1;
	}

	pkgname = alpm_pkg_get_name(pkg);
	mtree = alpm_pkg_mtree_open(pkg);
	if(mtree == NULL) {
		/* TODO: check error to confirm failure due to no mtree file */
		if(!config->quiet) {
			printf(_("%s: no mtree file\n"), pkgname);
		}
		return 0;
	}

	while(alpm_pkg_mtree_next(pkg, mtree, &entry) == ARCHIVE_OK) {
		struct stat st;
		const char *path = archive_entry_pathname(entry);
		char filepath[PATH_MAX];
		int filepath_len;
		mode_t type;
		size_t file_errors = 0;
		int backup = 0;
		int exists;

		/* strip leading "./" from path entries */
		if(path[0] == '.' && path[1] == '/') {
			path += 2;
		}

		if(*path == '.') {
			const char *dbfile = NULL;

			if(strcmp(path, ".INSTALL") == 0) {
				dbfile = "install";
			} else if(strcmp(path, ".CHANGELOG") == 0) {
				dbfile = "changelog";
			} else {
				continue;
			}

			/* Do not append root directory as alpm_option_get_dbpath is already
			 * an absoute path */
			filepath_len = snprintf(filepath, PATH_MAX, "%slocal/%s-%s/%s",
					alpm_option_get_dbpath(config->handle),
					pkgname, alpm_pkg_get_version(pkg), dbfile);
			if(filepath_len >= PATH_MAX) {
				pm_printf(ALPM_LOG_WARNING, _("path too long: %slocal/%s-%s/%s\n"),
						alpm_option_get_dbpath(config->handle),
						pkgname, alpm_pkg_get_version(pkg), dbfile);
				continue;
			}
		} else {
			filepath_len = snprintf(filepath, PATH_MAX, "%s%s", root, path);
			if(filepath_len >= PATH_MAX) {
				pm_printf(ALPM_LOG_WARNING, _("path too long: %s%s\n"), root, path);
				continue;
			}
		}

		file_count++;

		exists = check_file_exists(pkgname, filepath, rootlen, &st);
		if(exists == 1) {
			errors++;
			continue;
		} else if(exists == -1) {
			/* NoExtract */
			continue;
		}

		type = archive_entry_filetype(entry);

		if(type != AE_IFDIR && type != AE_IFREG && type != AE_IFLNK) {
			pm_printf(ALPM_LOG_WARNING, _("file type not recognized: %s%s\n"), root, path);
			continue;
		}

		if(check_file_type(pkgname, filepath, &st, entry) == 1) {
			errors++;
			continue;
		}

		file_errors += check_file_permissions(pkgname, filepath, &st, entry);

		if(type == AE_IFLNK) {
			file_errors += check_file_link(pkgname, filepath, &st, entry);
		}

		/* the following checks are expected to fail if a backup file has been
		   modified */
		for(lp = alpm_pkg_get_backup(pkg); lp; lp = lp->next) {
			alpm_backup_t *bl = lp->data;

			if(strcmp(path, bl->name) == 0) {
				backup = 1;
				break;
			}
		}

		if(type != AE_IFDIR) {
			/* file or symbolic link */
			file_errors += check_file_time(pkgname, filepath, &st, entry, backup);
		}

		if(type == AE_IFREG) {
			file_errors += check_file_size(pkgname, filepath, &st, entry, backup);
			/* file_errors += check_file_md5sum(pkgname, filepath, &st, entry, backup); */
		}

		if(config->quiet && file_errors) {
			printf("%s %s\n", pkgname, filepath);
		}

		errors += (file_errors != 0 ? 1 : 0);
	}

	alpm_pkg_mtree_close(pkg, mtree);

	if(!config->quiet) {
		printf(_n("%s: %jd total file, ", "%s: %jd total files, ",
					(unsigned long)file_count), pkgname, (intmax_t)file_count);
		printf(_n("%jd altered file\n", "%jd altered files\n",
					(unsigned long)errors), (intmax_t)errors);
	}

	return (errors != 0 ? 1 : 0);
}
Example #22
0
INT_PTR TcodecsPage::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg) {
        case WM_DESTROY:
            cfgSet(IDFF_lvCodecsWidth0,ListView_GetColumnWidth(hlv,0));
            cfgSet(IDFF_lvCodecsWidth1,ListView_GetColumnWidth(hlv,1));
            cfgSet(IDFF_lvCodecsWidth2,ListView_GetColumnWidth(hlv,2));
            cfgSet(IDFF_lvCodecsSelected,lvGetSelItem(IDC_LV_INCODECS));
            break;
        case WM_COMMAND:
            switch (LOWORD(wParam)) {
                case IDC_CBX_INCODECS:
                    if (HIWORD(wParam)==CBN_SELCHANGE && IsWindowVisible(hcbx)) {
                        int ii=lvGetSelItem(IDC_LV_INCODECS);
                        int idff=formats[ii].idff;
                        cfgSet(idff,(int)cbxGetCurItemData(IDC_CBX_INCODECS));
                        options2dlg(ii);
                        return TRUE;
                    }
                    break;
                case IDC_CHB_CODEC_OPT1:
                case IDC_CHB_CODEC_OPT2:
                case IDC_CHB_CODEC_OPT3:
                case IDC_CHB_CODEC_OPT4:
                    dlg2options(LOWORD(wParam));
                    return TRUE;
            }
            break;
        case WM_NOTIFY: {
            NMHDR *nmhdr=LPNMHDR(lParam);
            if (nmhdr->hwndFrom==hlv && nmhdr->idFrom==IDC_LV_INCODECS)
                switch (nmhdr->code) {
                    case LVN_GETDISPINFO: {
                        NMLVDISPINFO *nmdi=(NMLVDISPINFO*)lParam;
                        int i=nmdi->item.iItem;
                        if (i==-1) {
                            break;
                        }
                        if (nmdi->item.mask&LVIF_TEXT)
                            switch (nmdi->item.iSubItem) {
                                case 0:
                                    strcpy(nmdi->item.pszText,_(IDC_LV_INCODECS,formats[i].descr));
                                    break;
                                case 1:
                                    strcpy(nmdi->item.pszText,_(IDC_LV_INCODECS,formats[i].getDecoderName(cfgGet(formats[i].idff))));
                                    break;
                                case 2:
                                    strcpy(nmdi->item.pszText,_(IDC_LV_INCODECS,formats[i].hint));
                                    break;
                            }
                        return TRUE;
                    }
                    case LVN_GETINFOTIP: {
                        NMLVGETINFOTIP *nmit=(NMLVGETINFOTIP*)lParam;
                        if (nmit->iItem!=-1 && nmit->iSubItem==0) {
                            ff_strncpy(nmit->pszText,formats[nmit->iItem].hint,nmit->cchTextMax);
                        }
                        return TRUE;
                    }
                    case LVN_ITEMCHANGED: {
                        NMLISTVIEW *nmlv=LPNMLISTVIEW(lParam);
                        if (nmlv->iItem!=curitem) {
                            curitem=-1;
                            show(false,IDC_CBX_INCODECS);
                            options2dlg(nmlv->iItem);
                        }
                        return TRUE;
                    }
                    case NM_CLICK: {
                        NMITEMACTIVATE *nmia=LPNMITEMACTIVATE(lParam);
                        if (nmia->iItem!=-1 && nmia->iSubItem==1) {
                            beginCodecChange(nmia->iItem);
                        } else {
                            show(false,IDC_CBX_INCODECS);
                        }
                        return TRUE;
                    }
                }
            break;
        }
    }
    return TconfPageBase::msgProc(uMsg,wParam,lParam);
}
Example #23
0
File: revert.c Project: jjuran/git
static int do_pick_commit(void)
{
	unsigned char head[20];
	struct commit *base, *next, *parent;
	const char *base_label, *next_label;
	struct commit_message msg = { NULL, NULL, NULL, NULL, NULL };
	char *defmsg = NULL;
	struct strbuf msgbuf = STRBUF_INIT;
	int res;

	if (no_commit) {
		/*
		 * We do not intend to commit immediately.  We just want to
		 * merge the differences in, so let's compute the tree
		 * that represents the "current" state for merge-recursive
		 * to work on.
		 */
		if (write_cache_as_tree(head, 0, NULL))
			die (_("Your index file is unmerged."));
	} else {
		if (get_sha1("HEAD", head))
			die (_("You do not have a valid HEAD"));
		if (index_differs_from("HEAD", 0))
			die_dirty_index(me);
	}
	discard_cache();

	if (!commit->parents) {
		parent = NULL;
	}
	else if (commit->parents->next) {
		/* Reverting or cherry-picking a merge commit */
		int cnt;
		struct commit_list *p;

		if (!mainline)
			die(_("Commit %s is a merge but no -m option was given."),
			    sha1_to_hex(commit->object.sha1));

		for (cnt = 1, p = commit->parents;
		     cnt != mainline && p;
		     cnt++)
			p = p->next;
		if (cnt != mainline || !p)
			die(_("Commit %s does not have parent %d"),
			    sha1_to_hex(commit->object.sha1), mainline);
		parent = p->item;
	} else if (0 < mainline)
		die(_("Mainline was specified but commit %s is not a merge."),
		    sha1_to_hex(commit->object.sha1));
	else
		parent = commit->parents->item;

	if (allow_ff && parent && !hashcmp(parent->object.sha1, head))
		return fast_forward_to(commit->object.sha1, head);

	if (parent && parse_commit(parent) < 0)
		/* TRANSLATORS: The first %s will be "revert" or
		   "cherry-pick", the second %s a SHA1 */
		die(_("%s: cannot parse parent commit %s"),
		    me, sha1_to_hex(parent->object.sha1));

	if (get_message(commit->buffer, &msg) != 0)
		die(_("Cannot get commit message for %s"),
				sha1_to_hex(commit->object.sha1));

	/*
	 * "commit" is an existing commit.  We would want to apply
	 * the difference it introduces since its first parent "prev"
	 * on top of the current HEAD if we are cherry-pick.  Or the
	 * reverse of it if we are revert.
	 */

	defmsg = git_pathdup("MERGE_MSG");

	if (action == REVERT) {
		base = commit;
		base_label = msg.label;
		next = parent;
		next_label = msg.parent_label;
		strbuf_addstr(&msgbuf, "Revert \"");
		strbuf_addstr(&msgbuf, msg.subject);
		strbuf_addstr(&msgbuf, "\"\n\nThis reverts commit ");
		strbuf_addstr(&msgbuf, sha1_to_hex(commit->object.sha1));

		if (commit->parents && commit->parents->next) {
			strbuf_addstr(&msgbuf, ", reversing\nchanges made to ");
			strbuf_addstr(&msgbuf, sha1_to_hex(parent->object.sha1));
		}
		strbuf_addstr(&msgbuf, ".\n");
	} else {
		base = parent;
		base_label = msg.parent_label;
		next = commit;
		next_label = msg.label;
		add_message_to_msg(&msgbuf, msg.message);
		if (no_replay) {
			strbuf_addstr(&msgbuf, "(cherry picked from commit ");
			strbuf_addstr(&msgbuf, sha1_to_hex(commit->object.sha1));
			strbuf_addstr(&msgbuf, ")\n");
		}
		if (!no_commit)
			write_cherry_pick_head();
	}

	if (!strategy || !strcmp(strategy, "recursive") || action == REVERT) {
		res = do_recursive_merge(base, next, base_label, next_label,
					 head, &msgbuf);
		write_message(&msgbuf, defmsg);
	} else {
		struct commit_list *common = NULL;
		struct commit_list *remotes = NULL;

		write_message(&msgbuf, defmsg);

		commit_list_insert(base, &common);
		commit_list_insert(next, &remotes);
		res = try_merge_command(strategy, xopts_nr, xopts, common,
					sha1_to_hex(head), remotes);
		free_commit_list(common);
		free_commit_list(remotes);
	}

	if (res) {
		error(action == REVERT
		      ? _("could not revert %s... %s")
		      : _("could not apply %s... %s"),
		      find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV),
		      msg.subject);
		print_advice();
		rerere(allow_rerere_auto);
	} else {
		if (!no_commit)
			res = run_git_commit(defmsg);
	}

	free_message(&msg);
	free(defmsg);

	return res;
}
Example #24
0
GtkWidget *
offset_dialog_new (GimpDrawable *drawable,
                   GimpContext  *context,
                   GtkWidget    *parent)
{
  GimpItem      *item;
  OffsetDialog  *dialog;
  GtkWidget     *main_vbox;
  GtkWidget     *vbox;
  GtkWidget     *hbox;
  GtkWidget     *button;
  GtkWidget     *spinbutton;
  GtkWidget     *frame;
  GtkWidget     *radio_button;
  GtkAdjustment *adjustment;
  gdouble        xres;
  gdouble        yres;
  const gchar   *title = NULL;

  g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
  g_return_val_if_fail (GTK_IS_WIDGET (parent), NULL);

  dialog = g_slice_new0 (OffsetDialog);

  dialog->context   = context;
  dialog->fill_type = gimp_drawable_has_alpha (drawable) | WRAP_AROUND;
  item = GIMP_ITEM (drawable);
  dialog->image     = gimp_item_get_image (item);

  gimp_image_get_resolution (dialog->image, &xres, &yres);

  if (GIMP_IS_LAYER (drawable))
    title = _("Offset Layer");
  else if (GIMP_IS_LAYER_MASK (drawable))
    title = _("Offset Layer Mask");
  else if (GIMP_IS_CHANNEL (drawable))
    title = _("Offset Channel");
  else
    g_warning ("%s: unexpected drawable type", G_STRFUNC);

  dialog->dialog =
    gimp_viewable_dialog_new (GIMP_VIEWABLE (drawable), context,
                              _("Offset"), "gimp-drawable-offset",
                              GIMP_STOCK_TOOL_MOVE,
                              title,
                              parent,
                              gimp_standard_help_func,
                              GIMP_HELP_LAYER_OFFSET,

                              GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                              /*  offset, used as a verb  */
                              _("_Offset"),     GTK_RESPONSE_OK,

                              NULL);

  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog->dialog),
                                           GTK_RESPONSE_OK,
                                           GTK_RESPONSE_CANCEL,
                                           -1);

  gtk_window_set_resizable (GTK_WINDOW (dialog->dialog), FALSE);

  g_object_weak_ref (G_OBJECT (dialog->dialog),
                     (GWeakNotify) offset_dialog_free, dialog);

  g_signal_connect (dialog->dialog, "response",
                    G_CALLBACK (offset_response),
                    dialog);

  main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
  gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog->dialog))),
                      main_vbox, TRUE, TRUE, 0);
  gtk_widget_show (main_vbox);

  /*  The offset frame  */
  frame = gimp_frame_new (_("Offset"));
  gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
  gtk_widget_show (frame);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
  gtk_container_add (GTK_CONTAINER (frame), vbox);
  gtk_widget_show (vbox);

  adjustment = (GtkAdjustment *)
    gtk_adjustment_new (1, 1, 1, 1, 10, 0);
  spinbutton = gtk_spin_button_new (adjustment, 1.0, 2);
  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
  gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 10);

  dialog->off_se = gimp_size_entry_new (1, GIMP_UNIT_PIXEL, "%a",
                                        TRUE, TRUE, FALSE, 10,
                                        GIMP_SIZE_ENTRY_UPDATE_SIZE);

  gtk_table_set_col_spacing (GTK_TABLE (dialog->off_se), 0, 4);
  gtk_table_set_col_spacing (GTK_TABLE (dialog->off_se), 1, 4);
  gtk_table_set_row_spacing (GTK_TABLE (dialog->off_se), 0, 2);

  gimp_size_entry_add_field (GIMP_SIZE_ENTRY (dialog->off_se),
                             GTK_SPIN_BUTTON (spinbutton), NULL);
  gtk_table_attach_defaults (GTK_TABLE (dialog->off_se), spinbutton,
                             1, 2, 0, 1);
  gtk_widget_show (spinbutton);

  gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (dialog->off_se),
                                _("_X:"), 0, 0, 0.0);
  gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (dialog->off_se),
                                _("_Y:"), 1, 0, 0.0);

  gtk_box_pack_start (GTK_BOX (vbox), dialog->off_se, FALSE, FALSE, 0);
  gtk_widget_show (dialog->off_se);

  gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (dialog->off_se), GIMP_UNIT_PIXEL);

  gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (dialog->off_se), 0,
                                  xres, FALSE);
  gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (dialog->off_se), 1,
                                  yres, FALSE);

  gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (dialog->off_se), 0,
                                         - gimp_item_get_width (item),
                                         gimp_item_get_width (item));
  gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (dialog->off_se), 1,
                                         - gimp_item_get_height (item),
                                         gimp_item_get_height (item));

  gimp_size_entry_set_size (GIMP_SIZE_ENTRY (dialog->off_se), 0,
                            0, gimp_item_get_width (item));
  gimp_size_entry_set_size (GIMP_SIZE_ENTRY (dialog->off_se), 1,
                            0, gimp_item_get_height (item));

  gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (dialog->off_se), 0, 0);
  gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (dialog->off_se), 1, 0);

  button = gtk_button_new_with_mnemonic (_("By width/_2, height/2"));
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
  gtk_widget_show (button);

  g_signal_connect (button, "clicked",
                    G_CALLBACK (offset_half_xy_callback),
                    dialog);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
  gtk_widget_show (hbox);

  button = gtk_button_new_with_mnemonic ("By _width/2");
  gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
  gtk_widget_show (button);

  g_signal_connect (button, "clicked",
                    G_CALLBACK (offset_half_x_callback),
                    dialog);

  button = gtk_button_new_with_mnemonic ("By _height/2");
  gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
  gtk_widget_show (button);

  g_signal_connect (button, "clicked",
                    G_CALLBACK (offset_half_y_callback),
                    dialog);

  /*  The edge behavior frame  */
  frame = gimp_int_radio_group_new (TRUE, _("Edge Behavior"),
                                    G_CALLBACK (gimp_radio_button_update),
                                    &dialog->fill_type, dialog->fill_type,

                                    _("W_rap around"),
                                    WRAP_AROUND, NULL,

                                    _("Fill with _background color"),
                                    GIMP_OFFSET_BACKGROUND, NULL,

                                    _("Make _transparent"),
                                    GIMP_OFFSET_TRANSPARENT, &radio_button,
                                    NULL);

  if (! gimp_drawable_has_alpha (drawable))
    gtk_widget_set_sensitive (radio_button, FALSE);

  gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
  gtk_widget_show (frame);

  return dialog->dialog;
}
Example #25
0
error:
    if (path[0] != '@')
        unlink(path);
    VIR_FORCE_CLOSE(fd);
    return -1;
}
#else
int virNetSocketNewListenUNIX(const char *path ATTRIBUTE_UNUSED,
                              mode_t mask ATTRIBUTE_UNUSED,
                              uid_t user ATTRIBUTE_UNUSED,
                              gid_t grp ATTRIBUTE_UNUSED,
                              virNetSocketPtr *retsock ATTRIBUTE_UNUSED)
{
    virReportSystemError(ENOSYS, "%s",
                         _("UNIX sockets are not supported on this platform"));
    return -1;
}
#endif


int virNetSocketNewConnectTCP(const char *nodename,
                              const char *service,
                              virNetSocketPtr *retsock)
{
    struct addrinfo *ai = NULL;
    struct addrinfo hints;
    int fd = -1;
    virSocketAddr localAddr;
    virSocketAddr remoteAddr;
    struct addrinfo *runp;
Example #26
0
int AboutPrefs::create_objects()
{
	int x, y;

	BC_Resources *resources = BC_WindowBase::get_resources();

// 	add_subwindow(new BC_Title(mwindow->theme->preferencestitle_x, 
// 		mwindow->theme->preferencestitle_y, 
// 		_("About"), 
// 		LARGEFONT, 
// 		resources->text_default));
	
	x = mwindow->theme->preferencesoptions_x;
	y = mwindow->theme->preferencesoptions_y +
		get_text_height(LARGEFONT);

	set_font(LARGEFONT);
	set_color(resources->text_default);
	draw_text(x, y, PROGRAM_NAME " " CINELERRA_VERSION);

	y += get_text_height(LARGEFONT);

	set_font(MEDIUMFONT);
	draw_text(x, y, COPYRIGHTTEXT1
#if defined(COPYRIGHTTEXT2)
	"\n" COPYRIGHTTEXT2
#endif
#if defined(REPOMAINTXT)
	"\n" REPOMAINTXT
#endif
	);



	y += get_text_height(MEDIUMFONT) * 4;

	char versions[BCTEXTLEN];
	sprintf(versions, 
_("Quicktime version %d.%d.%d (%s)\n"
"Libmpeg3 version %d.%d.%d\n"),
quicktime_major(),
quicktime_minor(),
quicktime_release(),
FFMPEG_EXTERNALTEXT,
mpeg3_major(),
mpeg3_minor(),
mpeg3_release());
	draw_text(x, y, versions);



	y += get_text_height(MEDIUMFONT) * 3;
	set_font(LARGEFONT);
	draw_text(x, y, "Credits:");
	y += get_text_height(LARGEFONT);
	set_font(MEDIUMFONT);

	char credits[BCTEXTLEN];
	sprintf(credits,

"Jack Crossfire\n"
"Richard Baverstock\n"
"Karl Bielefeldt\n"
"Kevin Brosius\n"
"Jean-Luc Coulon\n"
"Jean-Michel POURE\n"
"Jerome Cornet\n"
"Pierre Marc Dumuid\n"
"Alex Ferrer\n"
"Jan Gerber\n"
"Koen Muylkens\n"
"Stefan de Konink\n"
"Nathan Kurz\n"
"Greg Mekkes\n"
"Eric Seigne\n"
"Joe Stewart\n"
"Dan Streetman\n"
#ifdef X_HAVE_UTF8_STRING
"Gustavo Iñiguez\n"
#else
"Gustavo I\361iguez\n"
#endif
"Johannes Sixt\n"
"Mark Taraba\n"
"Andraz Tori\n"
"Jonas Wulff\n"
"David Arendt\n"

);
	draw_utf8_text(x, y, credits);

	int x_indented;
	x_indented = x + get_text_width(MEDIUMFONT, "Pierre Marc Dumuid") + 20;

	char credits_cont1[BCTEXTLEN];
	sprintf(credits_cont1,

#ifdef X_HAVE_UTF8_STRING
"Einar Rünkaru\n"
#else
"Einar R\374nkaru\n"
#endif
"Monty Montgomery\n"

);
	draw_utf8_text(x_indented, y, credits_cont1);

	y = get_h() - 135;

	set_font(LARGEFONT);
	draw_text(x, y, "License:");
	y += get_text_height(LARGEFONT);

	set_font(MEDIUMFONT);

	char license3[BCTEXTLEN];
	sprintf(license3, _(
"This program is free software; you can redistribute it and/or modify it under the terms\n"
"of the GNU General Public License as published by the Free Software Foundation; either version\n"
"2 of the License, or (at your option) any later version.\n"
"\n"
"This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;\n"
"without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n"
"PURPOSE.  See the GNU General Public License for more details.\n"
"\n"));
	draw_text(x, y, license3);

	x = get_w() - mwindow->theme->about_bg->get_w() - 10;
	y = mwindow->theme->preferencesoptions_y;
	BC_Pixmap *temp_pixmap = new BC_Pixmap(this, 
		mwindow->theme->about_bg,
		PIXMAP_ALPHA);
	draw_pixmap(temp_pixmap, 
		x, 
		y);

	delete temp_pixmap;


	x += mwindow->theme->about_bg->get_w() + 10;
	y += get_text_height(LARGEFONT) * 2;


	flash();
	flush();
	return 0;
}
Example #27
0
int virNetSocketNewListenTCP(const char *nodename,
                             const char *service,
                             virNetSocketPtr **retsocks,
                             size_t *nretsocks)
{
    virNetSocketPtr *socks = NULL;
    size_t nsocks = 0;
    struct addrinfo *ai = NULL;
    struct addrinfo hints;
    int fd = -1;
    int i;
    int addrInUse = false;

    *retsocks = NULL;
    *nretsocks = 0;

    memset(&hints, 0, sizeof(hints));
    hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
    hints.ai_socktype = SOCK_STREAM;

    int e = getaddrinfo(nodename, service, &hints, &ai);
    if (e != 0) {
        virNetError(VIR_ERR_SYSTEM_ERROR,
                    _("Unable to resolve address '%s' service '%s': %s"),
                    nodename, service, gai_strerror(e));
        return -1;
    }

    struct addrinfo *runp = ai;
    while (runp) {
        virSocketAddr addr;

        memset(&addr, 0, sizeof(addr));

        if ((fd = socket(runp->ai_family, runp->ai_socktype,
                         runp->ai_protocol)) < 0) {
            virReportSystemError(errno, "%s", _("Unable to create socket"));
            goto error;
        }

        int opt = 1;
        if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) {
            virReportSystemError(errno, "%s", _("Unable to enable port reuse"));
            goto error;
        }

#ifdef IPV6_V6ONLY
        if (runp->ai_family == PF_INET6) {
            int on = 1;
            /*
             * Normally on Linux an INET6 socket will bind to the INET4
             * address too. If getaddrinfo returns results with INET4
             * first though, this will result in INET6 binding failing.
             * We can trivially cope with multiple server sockets, so
             * we force it to only listen on IPv6
             */
            if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY,
                           (void*)&on, sizeof(on)) < 0) {
                virReportSystemError(errno, "%s",
                                     _("Unable to force bind to IPv6 only"));
                goto error;
            }
        }
#endif

        if (bind(fd, runp->ai_addr, runp->ai_addrlen) < 0) {
            if (errno != EADDRINUSE) {
                virReportSystemError(errno, "%s", _("Unable to bind to port"));
                goto error;
            }
            addrInUse = true;
            VIR_FORCE_CLOSE(fd);
            runp = runp->ai_next;
            continue;
        }

        addr.len = sizeof(addr.data);
        if (getsockname(fd, &addr.data.sa, &addr.len) < 0) {
            virReportSystemError(errno, "%s", _("Unable to get local socket name"));
            goto error;
        }

        VIR_DEBUG("%p f=%d f=%d", &addr, runp->ai_family, addr.data.sa.sa_family);

        if (VIR_EXPAND_N(socks, nsocks, 1) < 0) {
            virReportOOMError();
            goto error;
        }

        if (!(socks[nsocks-1] = virNetSocketNew(&addr, NULL, false, fd, -1, 0)))
            goto error;
        runp = runp->ai_next;
        fd = -1;
    }

    if (nsocks == 0 &&
        addrInUse) {
        virReportSystemError(EADDRINUSE, "%s", _("Unable to bind to port"));
        goto error;
    }

    freeaddrinfo(ai);

    *retsocks = socks;
    *nretsocks = nsocks;
    return 0;

error:
    for (i = 0 ; i < nsocks ; i++)
        virNetSocketFree(socks[i]);
    VIR_FREE(socks);
    freeaddrinfo(ai);
    VIR_FORCE_CLOSE(fd);
    return -1;
}
Example #28
0
wxString wxGetStockLabel(wxWindowID id, long flags)
{
    wxString stockLabel;

#ifdef __WXMSW__
    // special case: the "Cancel" button shouldn't have a mnemonic under MSW
    // for consistency with the native dialogs (which don't use any mnemonic
    // for it because it is already bound to Esc implicitly)
    if ( id == wxID_CANCEL )
        flags &= ~wxSTOCK_WITH_MNEMONIC;
#endif // __WXMSW__


    #define STOCKITEM(stockid, labelWithMnemonic, labelPlain)                 \
        case stockid:                                                         \
            if(flags & wxSTOCK_WITH_MNEMONIC)                                 \
                stockLabel = labelWithMnemonic;                               \
            else                                                              \
                stockLabel = labelPlain;                                      \
            break

    switch (id)
    {
        STOCKITEM(wxID_ABOUT,               _("&About"),           _("About"));
        STOCKITEM(wxID_ADD,                 _("Add"),                 _("Add"));
        STOCKITEM(wxID_APPLY,               _("&Apply"),              _("Apply"));
        STOCKITEM(wxID_BACKWARD,            _("&Back"),               _("Back"));
        STOCKITEM(wxID_BOLD,                _("&Bold"),               _("Bold"));
        STOCKITEM(wxID_BOTTOM,              _("&Bottom"),             _("Bottom"));
        STOCKITEM(wxID_CANCEL,              _("&Cancel"),             _("Cancel"));
        STOCKITEM(wxID_CDROM,               _("&CD-Rom"),             _("CD-Rom"));
        STOCKITEM(wxID_CLEAR,               _("&Clear"),              _("Clear"));
        STOCKITEM(wxID_CLOSE,               _("&Close"),              _("Close"));
        STOCKITEM(wxID_CONVERT,             _("&Convert"),            _("Convert"));
        STOCKITEM(wxID_COPY,                _("&Copy"),               _("Copy"));
        STOCKITEM(wxID_CUT,                 _("Cu&t"),                _("Cut"));
        STOCKITEM(wxID_DELETE,              _("&Delete"),             _("Delete"));
        STOCKITEM(wxID_DOWN,                _("&Down"),               _("Down"));
        STOCKITEM(wxID_EDIT,                _("&Edit"),               _("Edit"));
        STOCKITEM(wxID_EXECUTE,             _("&Execute"),            _("Execute"));
        STOCKITEM(wxID_EXIT,                _("&Quit"),               _("Quit"));
        STOCKITEM(wxID_FILE,                _("&File"),               _("File"));
        STOCKITEM(wxID_FIND,                _("&Find"),               _("Find"));
        STOCKITEM(wxID_FIRST,               _("&First"),              _("First"));
        STOCKITEM(wxID_FLOPPY,              _("&Floppy"),             _("Floppy"));
        STOCKITEM(wxID_FORWARD,             _("&Forward"),            _("Forward"));
        STOCKITEM(wxID_HARDDISK,            _("&Harddisk"),           _("Harddisk"));
        STOCKITEM(wxID_HELP,                _("&Help"),               _("Help"));
        STOCKITEM(wxID_HOME,                _("&Home"),               _("Home"));
        STOCKITEM(wxID_INDENT,              _("Indent"),              _("Indent"));
        STOCKITEM(wxID_INDEX,               _("&Index"),              _("Index"));
        STOCKITEM(wxID_INFO,                _("&Info"),               _("Info"));
        STOCKITEM(wxID_ITALIC,              _("&Italic"),             _("Italic"));
        STOCKITEM(wxID_JUMP_TO,             _("&Jump to"),            _("Jump to"));
        STOCKITEM(wxID_JUSTIFY_CENTER,      _("Centered"),            _("Centered"));
        STOCKITEM(wxID_JUSTIFY_FILL,        _("Justified"),           _("Justified"));
        STOCKITEM(wxID_JUSTIFY_LEFT,        _("Align Left"),          _("Align Left"));
        STOCKITEM(wxID_JUSTIFY_RIGHT,       _("Align Right"),         _("Align Right"));
        STOCKITEM(wxID_LAST,                _("&Last"),               _("Last"));
        STOCKITEM(wxID_NETWORK,             _("&Network"),            _("Network"));
        STOCKITEM(wxID_NEW,                 _("&New"),                _("New"));
        STOCKITEM(wxID_NO,                  _("&No"),                 _("No"));
        STOCKITEM(wxID_OK,                  _("&OK"),                 _("OK"));
        STOCKITEM(wxID_OPEN,                _("&Open..."),            _("Open..."));
        STOCKITEM(wxID_PASTE,               _("&Paste"),              _("Paste"));
        STOCKITEM(wxID_PREFERENCES,         _("&Preferences"),        _("Preferences"));
        STOCKITEM(wxID_PREVIEW,             _("Print previe&w..."),   _("Print preview..."));
        STOCKITEM(wxID_PRINT,               _("&Print..."),           _("Print..."));
        STOCKITEM(wxID_PROPERTIES,          _("&Properties"),         _("Properties"));
        STOCKITEM(wxID_REDO,                _("&Redo"),               _("Redo"));
        STOCKITEM(wxID_REFRESH,             _("Refresh"),             _("Refresh"));
        STOCKITEM(wxID_REMOVE,              _("Remove"),              _("Remove"));
        STOCKITEM(wxID_REPLACE,             _("Rep&lace"),            _("Replace"));
        STOCKITEM(wxID_REVERT_TO_SAVED,     _("Revert to Saved"),     _("Revert to Saved"));
        STOCKITEM(wxID_SAVE,                _("&Save"),               _("Save"));
        STOCKITEM(wxID_SAVEAS,              _("&Save as"),            _("Save as"));
        STOCKITEM(wxID_SELECTALL,           _("Select &All"),         _("Select All"));
        STOCKITEM(wxID_SELECT_COLOR,        _("&Color"),              _("Color"));
        STOCKITEM(wxID_SELECT_FONT,         _("&Font"),               _("Font"));
        STOCKITEM(wxID_SORT_ASCENDING,      _("&Ascending"),          _("Ascending"));
        STOCKITEM(wxID_SORT_DESCENDING,     _("&Descending"),         _("Descending"));
        STOCKITEM(wxID_SPELL_CHECK,         _("&Spell Check"),        _("Spell Check"));
        STOCKITEM(wxID_STOP,                _("&Stop"),               _("Stop"));
        STOCKITEM(wxID_STRIKETHROUGH,       _("&Strikethrough"),      _("Strikethrough"));
        STOCKITEM(wxID_TOP,                 _("&Top"),                _("Top"));
        STOCKITEM(wxID_UNDELETE,            _("Undelete"),            _("Undelete"));
        STOCKITEM(wxID_UNDERLINE,           _("&Underline"),          _("Underline"));
        STOCKITEM(wxID_UNDO,                _("&Undo"),               _("Undo"));
        STOCKITEM(wxID_UNINDENT,            _("&Unindent"),           _("Unindent"));
        STOCKITEM(wxID_UP,                  _("&Up"),                 _("Up"));
        STOCKITEM(wxID_YES,                 _("&Yes"),                _("Yes"));
        STOCKITEM(wxID_ZOOM_100,            _("&Actual Size"),        _("Actual Size"));
        STOCKITEM(wxID_ZOOM_FIT,            _("Zoom to &Fit"),        _("Zoom to Fit"));
        STOCKITEM(wxID_ZOOM_IN,             _("Zoom &In"),            _("Zoom In"));
        STOCKITEM(wxID_ZOOM_OUT,            _("Zoom &Out"),           _("Zoom Out"));

        default:
            wxFAIL_MSG( wxT("invalid stock item ID") );
            break;
    };

    #undef STOCKITEM

    if ( flags & wxSTOCK_WITHOUT_ELLIPSIS )
    {
        wxString baseLabel;
        if ( stockLabel.EndsWith("...", &baseLabel) )
            stockLabel = baseLabel;

        // accelerators only make sense for the menu items which should have
        // ellipsis too while wxSTOCK_WITHOUT_ELLIPSIS is mostly useful for
        // buttons which shouldn't have accelerators in their labels
        wxASSERT_MSG( !(flags & wxSTOCK_WITH_ACCELERATOR),
                        "labels without ellipsis shouldn't use accelerators" );
    }

#if wxUSE_ACCEL
    if ( !stockLabel.empty() && (flags & wxSTOCK_WITH_ACCELERATOR) )
    {
        wxAcceleratorEntry accel = wxGetStockAccelerator(id);
        if (accel.IsOk())
            stockLabel << wxT('\t') << accel.ToString();
    }
#endif // wxUSE_ACCEL

    return stockLabel;
}
/**
 * cong_node_properties_dialog_new:
 * @doc: The document being displayed.
 * @node: The node to display.
 * @parent_window: The parent window of the document.
 *
 * Create a dialog window which displays, and allows the user to edit,
 * the properties of the supplied node. The format of the dialog
 * depends on the node type. 
 *
 * The main interest will be for nodes of type CONG_NODE_TYPE_ELEMENT.
 * If there is a plugin registered for this node then the plugin will be
 * used, otherwise the attributes of the node will be displayed. In the
 * later case, the attributes will be displayed in a "raw" form (as
 * a set of name and value pairs) and, if a DTD associated with this file,
 * using an interface that follows the DTD (e.g. will limit enumerated
 * values to the allowable choices only).
 *
 * For CONG_NODE_TYPE_TEXT nodes the properties of the parent node will
 * be displayed. This is primarily so that users can access the attributes
 * of span nodes, but it will work for any text node. Should there be
 * a way to indicate that this has happened (i.e. some indication
 * in the dialog that we are actually displaying the parent's
 * properties)?
 *
 * Other node types result in a dialog which only lists the name
 * and the XPath location of the node.
 *
 * At present the returned dialog window should be displayed using
 * gtk_widget_show() rather than gtk_dialog_run().
 *
 * Returns: a #GtkWidget displaying the properties of the node.
 */
GtkWidget*
cong_node_properties_dialog_new (CongDocument *doc, 
				 CongNodePtr node, 
				 GtkWindow *parent_window)
{
	g_return_val_if_fail (doc, NULL);
	g_return_val_if_fail (node, NULL);

	/*
	 * If this is a text node then display the properties of its
	 * parent node instead. I do not think this can recurse "wildly"
	 * (presumably a text node can not have a text node as its
	 * parent).
	 */
	if (cong_node_type(node)==CONG_NODE_TYPE_TEXT) {
		return cong_node_properties_dialog_new (doc,
							cong_node_parent(node),
							parent_window);
	}

	/* Should we use a plugin for this node?: */
	if (cong_node_type(node)==CONG_NODE_TYPE_ELEMENT) {
		CongDispspecElement *element;
		const gchar *service_id;

		element = cong_document_get_dispspec_element_for_node (doc,
								       node);
		if (element) {
			service_id = cong_dispspec_element_get_property_dialog_service_id(element);

			/* Is there a plugin for this type of node? */
			if (service_id) {
				CongServiceNodePropertyDialog *dialog_factory = cong_plugin_manager_locate_custom_property_dialog_by_id (cong_app_get_plugin_manager (cong_app_singleton()), 
																	 service_id);

				if (dialog_factory) {
					GtkWidget *dialog = cong_custom_property_dialog_make (dialog_factory, 
											      doc, 
											      node);
					return dialog;
				}
			}
		}
	}


	/* Otherwise: */
	{
		GtkWidget* dtd_page;

		GtkWidget *dialog, *vbox;
		GtkWidget *advanced_properties;

		dialog = gtk_dialog_new_with_buttons(_("Properties"),
						     parent_window,
						     GTK_DIALOG_MODAL,
						     GTK_STOCK_CLOSE, GTK_RESPONSE_OK,
						     NULL);		

		gtk_container_set_border_width(GTK_CONTAINER(dialog), 6);

		vbox = GTK_DIALOG(dialog)->vbox;

		dtd_page = cong_node_properties_dtd_new (doc, 
							 node,
							 TRUE);

		advanced_properties = cong_node_properties_dialog_advanced_new (doc, 
										node,
										(dtd_page!=NULL));
			
		gtk_widget_show (advanced_properties);

		if (dtd_page) {
			GtkWidget *notebook = gtk_notebook_new ();

			gtk_widget_show (notebook);

			gtk_box_pack_start (GTK_BOX(vbox), 
					    notebook, 
					    TRUE, 
					    TRUE, 
					    0);

			gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
						 dtd_page,
						 gtk_label_new(_("DTD"))
						 );		

			gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
						 advanced_properties,
						 gtk_label_new(_("Advanced"))
						 );
		} else {
			gtk_box_pack_start (GTK_BOX(vbox), 
					    advanced_properties, 
					    TRUE, 
					    TRUE, 
					    0);
		}

		g_signal_connect_swapped (G_OBJECT (dialog), 
					  "response", G_CALLBACK (gtk_widget_destroy),
					  GTK_OBJECT (dialog));


		return GTK_WIDGET(dialog);
	}
}
Example #30
0
void DIALOG_CVPCB_CONFIG::OnAddOrInsertPath( wxCommandEvent& event )
{
    wxString path = wxGetApp().ReturnLastVisitedLibraryPath();

    bool     select = EDA_DirectorySelector( _( "Default Path for Libraries" ),
                                             path,
                                             wxDD_DEFAULT_STYLE,
                                             this,
                                             wxDefaultPosition );

    if( !select )
        return;

    if( !wxFileName::DirExists( path ) )     // Should not occurs
        return;

    // Add or insert path if not already in list
    if( m_listUserPaths->FindString( path ) == wxNOT_FOUND )
    {
        int ipos = m_listUserPaths->GetCount();

        if( event.GetId() == ID_INSERT_PATH )
        {
            if( ipos  )
                ipos--;

            int jj = m_listUserPaths->GetSelection();

            if( jj >= 0 )
                ipos = jj;
        }

        // Ask the user if this is a relative path
        int diag = wxMessageBox( _( "Use a relative path?" ),
                                 _( "Path type" ),
                                 wxYES_NO | wxICON_QUESTION, this );

        if( diag == wxYES )
        {   // Make it relative
            wxFileName fn = path;
            fn.MakeRelativeTo( wxT( "." ) );
            path = fn.GetPathWithSep() + fn.GetFullName();
        }

        m_listUserPaths->Insert( path, ipos );
        m_LibPathChanged = true;
        wxGetApp().InsertLibraryPath( path, ipos + 1 );

        // Display actual libraries paths:
        wxPathList libpaths = wxGetApp().GetLibraryPathList();
        m_DefaultLibraryPathslistBox->Clear();

        for( unsigned ii = 0; ii < libpaths.GetCount(); ii++ )
        {
            m_DefaultLibraryPathslistBox->Append( libpaths[ii] );
        }
    }
    else
    {
        DisplayError( this, _( "Path already in use" ) );
    }

    wxGetApp().SaveLastVisitedLibraryPath( path );
}