Ejemplo n.º 1
0
/**
 * For details of what is expected from an icon window and what it
 * should expect.
 *
 * See --
 *    http://tronche.com/gui/x/icccm/sec-4.html#s-4.1.9
 */
G_GNUC_COLD void
icon_init(void)
{
    create_icon();

	gtk_widget_realize(icon);

    /*
     * For some reason, when a window is the icon for another
     * window, none of its subwindows get mapped.  This is not
     * because of GTK, but seems to be either the window manager
     * or X itself that does this.
     *
     * Also note the canvas widget is never unmapped, regardless
     * of whether the icon window is visible or not.
     */
    gtk_widget_map(canvas);
	/* FIXME: This causes a crash with twm when iconizing the main window. */
#if 0
    gdk_window_set_icon(gui_main_window()->window, icon->window, NULL, NULL);
#endif
    icon_just_mapped_fg = icon_visible_fg = icon_close_fg = FALSE;

    /*   load images   */
    con_pixbuf = create_pixbuf("smallserver.xpm");
    up_pixbuf = create_pixbuf("upload.xpm");
    down_pixbuf = create_pixbuf("download.xpm");

	status_icon_init();

	main_gui_add_timer(icon_timer);
}
Ejemplo n.º 2
0
gboolean update(struct Icon_data *data)
{
  if( pread(data-> fd,data-> text_buff, data-> len_to_read, data-> offset) <= 0) { /* Try to read from the file. */
      /* Error enter. */
      fprintf(stderr, "*** Filemon first reading error, try to reopen ***\n");

      /* If pread return error, try to open it again(Due to suspend and so on). */
      if((data-> fd = open((const char*)data-> saved_file, O_RDONLY)) <= 0) {
          fprintf(stderr, "Cant reopen the file, exit.\n");
          file2mon_exit(data);
      } else if( pread(data-> fd,data-> text_buff, data-> len_to_read, data-> offset) <= 0) { /* Try to read from the file again. */
          /* Second reading was fail too. */
          fprintf(stderr, "Filemon Reading error, exit.\n");
          file2mon_exit(data);
      }
  }

#ifdef DEBUG
  fprintf(stdout, "TEXT: [%s]\n", data-> text_buff);	        /* Debug. */
  fprintf(stdout, "TMP: [%s]\n", data-> tmp_buff);		/* Debug. */
#endif

  /* If current buffer is the same like previous (tmp_buffer), do nothign.
   * Or if it's different, create new icon and reset the icon.
   * Also copy current text to temporary buffer for future comparisons.
   */
  if(strcmp( (const char*)data-> text_buff, (const char*)data-> tmp_buff) != 0) {
      create_icon(data);						/* Create new icon. 			*/
      gtk_status_icon_set_from_file(data-> icon, data-> path_to_file);	/* Reset the icon.  			*/
      strcpy( (char*)data-> tmp_buff, (const char*)data-> text_buff);	/* Copy new lalue to temporary buffer. 	*/
  }

  return TRUE;	/* Keeep running. */
}
Ejemplo n.º 3
0
void
mini_control_cover_set(minicontrol *mc, const char* path)
{
    if (!path)
        elm_object_part_content_set(mc->layout, "swallow.cover", create_icon(mc->layout, "background_cone.png"));
    else
        elm_object_part_content_set(mc->layout, "swallow.cover", create_image(mc->layout, path));
}
Ejemplo n.º 4
0
static WindowckPlugin * windowck_new(XfcePanelPlugin *plugin)
{
    WindowckPlugin *wckp;

    GtkOrientation orientation;
    GtkWidget *label;

    /* allocate memory for the plugin structure */
    wckp = g_slice_new0 (WindowckPlugin);

    /* pointer to plugin */
    wckp->plugin = plugin;

    /* read the user settings */
    windowck_read(wckp);

    /* get the current orientation */
    orientation = xfce_panel_plugin_get_orientation(plugin);

    /* not needed for shrink mode */
    if (!wckp->prefs->size_mode == SHRINK)
        xfce_panel_plugin_set_shrink (plugin, TRUE);

    /* create some panel widgets */
    wckp->ebox = gtk_event_box_new();
    gtk_event_box_set_visible_window(GTK_EVENT_BOX(wckp->ebox), FALSE);
    gtk_widget_set_name(wckp->ebox, "XfceWindowckPlugin");

    wckp->alignment = gtk_alignment_new (0.5, 0.5, 0, 0);

    wckp->hvbox = xfce_hvbox_new(orientation, FALSE, 2);

    /* some wckp widgets */
    label = gtk_label_new("");
    wckp->title = GTK_LABEL (label);

    create_icon (wckp);

    gtk_box_pack_start (GTK_BOX(wckp->hvbox), label, TRUE, TRUE, 0);

    if (wckp->prefs->icon_on_right)
    {
        gtk_box_reorder_child (GTK_BOX (wckp->hvbox), GTK_WIDGET(wckp->icon->eventbox), 1);
    }

    gtk_container_add(GTK_CONTAINER(wckp->alignment), GTK_WIDGET(wckp->hvbox));
    gtk_container_add(GTK_CONTAINER(wckp->ebox), wckp->alignment);

    /* show widgets */
    gtk_widget_show(wckp->ebox);
    gtk_widget_show(wckp->alignment);
    gtk_widget_show(wckp->hvbox);
    gtk_widget_show(label);

    return wckp;
}
Ejemplo n.º 5
0
void 
shelm_simple_dialog(const char *window_title, const char *window_text, int window_width, int window_height, const char *window_background, const char *window_icccm_name, const char *window_default_title, const char *window_default_icon)
{
  Evas_Object *window, *background, *frame, *box, *hbox, *icon, *button_ok;
  char buf[PATH_MAX];

  snprintf(buf, sizeof(buf), "shellementary-%s", window_icccm_name);
  if (window_title)
    window = create_window(buf, window_title, destroy);
  else
    window = create_window(buf, window_default_title, destroy);

  background = create_background(window, window_background, EINA_FALSE);
  elm_win_resize_object_add(window, background);
  evas_object_show(background);

  frame = create_frame(window, EINA_FALSE);
  elm_win_resize_object_add(window, frame);
  evas_object_show(frame);

  box = create_box(window, EINA_FALSE);
  elm_object_content_set(frame, box);
  evas_object_show(box);

  hbox = create_box(window, EINA_TRUE);
  elm_box_pack_end(box, hbox);
  evas_object_show(hbox);

  icon = create_icon(window, window_default_icon);
  elm_box_pack_start(hbox, icon);
  evas_object_show(icon);

  if (window_text)
    {
      Evas_Object *label;
      label = create_label(window, window_text);
      elm_box_pack_end(hbox, label);
      evas_object_show(label);
    }

  snprintf(buf, sizeof(buf), "%s/icon-ok.png", PACKAGE_DATA_DIR);
  button_ok = create_button(window, buf, _("OK"));
  evas_object_smart_callback_add(button_ok, "clicked", destroy, NULL);
  elm_box_pack_end(box, button_ok);
  evas_object_show(button_ok);

  if (!window_width)
    evas_object_geometry_get(window, NULL, NULL, &window_width, NULL);
  if (!window_height)
    evas_object_geometry_get(window, NULL, NULL, NULL, &window_height);

  evas_object_resize(window, window_width, window_height);

  evas_object_show(window);
}
Ejemplo n.º 6
0
static Evas_Object*
gl_content_get_cb(void *data, Evas_Object *obj, const char *part)
{
    settings_internal_data *sd = data;

    if (!sd || !sd->item || !part)
        return NULL;

    const Elm_Genlist_Item_Class *itc = elm_genlist_item_item_class_get(sd->item);

    if (!itc)
        return NULL;

    Evas_Object *content = NULL;

    /* Check the item class style and add the object needed in the item class*/
    /* Here, puts the icon in the item class to add it to genlist items */
    if (itc->item_style && !strcmp(itc->item_style, "1line")) {
        if (part && !strcmp(part, "elm.icon.1") && sd->selected.menu[sd->selected.index].icon != NULL) {
            content = elm_layout_add(obj);
            elm_layout_theme_set(content, "layout", "list/B/type.3", "default");
            Evas_Object *icon = create_icon(content, sd->selected.menu[sd->selected.index].icon);
            elm_layout_content_set(content, "elm.swallow.content", icon);
        }
        if (sd->selected.menu[sd->selected.index].type == SETTINGS_TYPE_TOGGLE)
        {
            if (part && !strcmp(part, "elm.icon.right")) {
                Evas_Object *icon;
                content = elm_layout_add(obj);
                elm_layout_theme_set(content, "layout", "list/A/right.icon", "default");
                if (sd->selected.menu[sd->selected.index].toggled)
                    icon = create_icon(sd->parent, "toggle_on.png");
                else
                    icon = create_icon(sd->parent, "toggle_off.png");
                elm_layout_content_set(content, "elm.swallow.content", icon);
            }
        }
    }

    return content;
}
Ejemplo n.º 7
0
Archivo: ftmenu.c Proyecto: taq/ftmenu
static void create_tray(void){
	GtkStatusIcon *icon;
	char menu_file[PATH_MAX];
	char icon_f[PATH_MAX];

	icon = create_icon();
	g_signal_connect(G_OBJECT(icon),"button-press-event",G_CALLBACK(menu_popup),NULL);

	create_menu(menu_file);
	if(icon_file(menu_file,icon_f)!=NULL && access(icon_f,R_OK)==0){
		g_print("Setting Fluxbox Tray Menu icon to %s\n",icon_f);
		gtk_status_icon_set_from_file(icon,icon_f);
	}
}
/**
 * @brief Returns the data of an item.
 *
 * Reimplemented from QStandardItemModel to create sprite icons lazily.
 *
 * @param index Index of the item to get.
 * @param role The wanted role.
 * @return The corresponding data.
 */
QVariant ResourceModel::data(const QModelIndex& index, int role) const {

  // Don't use QStandardItemModel storage features for icons.
  // Load them on-demand instead.
  if (role == Qt::DecorationRole) {

    const QStandardItem* item = itemFromIndex(index);
    if (item == nullptr) {
      // Invalid index;
      return QVariant();
    }

    const QString& element_id = item->data(Qt::UserRole).toString();
    if (element_id.isEmpty()) {
      // Not a resource element: maybe a directory.
      if (rowCount(index) > 0) {
        return directory_icon;  // Directory item.
      }
      return QIcon();
    }

    if (!get_quest().get_resources().exists(resource_type, element_id)) {
      // Special item.
      return QIcon();
    }

    // Resource elemnt item.
    Q_ASSERT(!element_id.isEmpty());
    auto it = icons.find(element_id);
    if (it != icons.end()) {
      // Icon already loaded.
      return it.value();
    }
    else {
      // Icon not loaded yet.
      QIcon icon = create_icon(element_id);
      icons.insert(element_id, icon);
      return icon;
    }
  }

  return QStandardItemModel::data(index, role);
}
Ejemplo n.º 9
0
void 
shelm_about_dialog()
{
  Evas_Object *window, *background, *frame, *box, *icon, *label, *sublabel, *scroller, *textinfo, *buttonbar, *button_close;
  char buf[PATH_MAX];

  window = create_window("shellementary-about", _("About Shellementary"), destroy);

  background = create_background(window, NULL, EINA_TRUE);
  elm_win_resize_object_add(window, background);
  evas_object_show(background);

  frame = create_frame(window, EINA_FALSE);
  elm_win_resize_object_add(window, frame);
  evas_object_show(frame);

  box = create_box(window, EINA_FALSE);
  elm_object_content_set(frame, box);
  evas_object_show(box);

  snprintf(buf, sizeof(buf), "%s/logo.png", PACKAGE_DATA_DIR);
  icon = create_icon(window, buf);
  elm_box_pack_start(box, icon);
  evas_object_show(icon);

  snprintf(buf, sizeof(buf), "<b>Shellementary %s</>", PACKAGE_VERSION);
  label = create_label(window, buf);
  elm_object_scale_set(label, 1.6);
  elm_box_pack_end(box, label);
  evas_object_show(label);

  sublabel = create_label(window, _("<b>Display dialogs from shell scripts</><br>Written as a zenity replacement, supports the same arguments<br><b>http://svn.enlightenment.org/svn/e/trunk/PROTO/shellementary</><br>Based on great Elementary toolkit by <b>raster</> and C programming language.<br><b>License:</> MIT"));
  elm_box_pack_end(box, sublabel);
  evas_object_show(sublabel);

  scroller = create_scroller(window, EINA_TRUE);
  elm_box_pack_end(box, scroller);
  evas_object_show(scroller);

  textinfo = create_entry(window, EINA_TRUE, NULL, EINA_FALSE, EINA_FALSE, EINA_FALSE);
  elm_entry_entry_set(textinfo, _("<b>Author:</> quaker ([email protected])<br>"
			"<br>"
			"<b>Credits:</><br>"
			"<b>Carsten Haitzler (raster)</> "
			"for Enlightenment DR17, great Elementary toolkit and help with developenment<br>"
			"<b>Christopher Michael (devilhorns)</> "
			"for help with developenment<br>"));
  elm_object_content_set(scroller, textinfo);
  evas_object_show(textinfo);

  buttonbar = create_box(window, EINA_TRUE);
  elm_box_pack_end(box, buttonbar);
  evas_object_show(buttonbar);

  snprintf(buf, sizeof(buf), "%s/icon-cancel.png", PACKAGE_DATA_DIR);
  button_close = create_button(window, buf, _("Close"));
  evas_object_smart_callback_add(button_close, "clicked", destroy, NULL);
  elm_box_pack_end(buttonbar, button_close);
  evas_object_show(button_close);



  evas_object_show(window);
}
Ejemplo n.º 10
0
minicontrol*
mini_control_view_create(playback_service *p_ps, application *p_app)
{
    minicontrol *mc = calloc(1, sizeof(*mc));
    mc->p_ps = p_ps;
    mc->p_app = p_app;
    ps = p_ps;

    const Evas_Coord width = 720;
    const Evas_Coord height = 120;

    /* main widget */
    mc->win = minicontrol_create_window("quickpanel", MINICONTROL_TARGET_VIEWER_QUICK_PANEL, mini_control_event_cb);
    evas_object_resize(mc->win, width, height);
    evas_object_hide(mc->win);

    /* Create layout and set the theme */
    Evas_Object *wlayout = elm_layout_add(mc->win);
    evas_object_resize(wlayout, width, height);
    //elm_win_resize_object_add(mc->win, layout);
    elm_layout_theme_set(wlayout, "layout", "application", "default");
    evas_object_show(wlayout);

    /* Create the background */
    Evas_Object *bg = elm_bg_add(wlayout);
    elm_bg_color_set(bg, 255, 255, 255);
    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
    evas_object_show(bg);

    /* Set the background to the theme */
    elm_object_part_content_set(wlayout, "elm.swallow.bg", bg);

    /* */
    Evas_Object *layout = mc->layout = elm_layout_add(mc->win);
    elm_object_part_content_set(wlayout, "elm.swallow.content", layout);

    /* */
    elm_layout_file_set(layout, QUICKPANELCONTROLS_EDJ, "quick_panel_controls");
    evas_object_show(layout);

    mc->play_button = create_icon(layout, "ic_play_circle_normal_o.png");
    mc->next_button = create_icon(layout, "ic_widget_next_normal.png");
    mc->prev_button = create_icon(layout, "ic_widget_previous_normal.png");
    mc->cover = create_icon(layout, "background_cone.png");

    elm_object_part_content_set(layout, "swallow.play", mc->play_button);
    elm_object_part_content_set(layout, "swallow.cover", mc->cover);
    elm_object_part_content_set(layout, "swallow.previous", mc->prev_button);
    elm_object_part_content_set(layout, "swallow.next", mc->next_button);

    evas_object_event_callback_add(mc->play_button, EVAS_CALLBACK_MOUSE_UP, mini_control_action_cb, mc);
    evas_object_event_callback_add(mc->next_button, EVAS_CALLBACK_MOUSE_UP, mini_control_action_cb, mc);
    evas_object_event_callback_add(mc->prev_button, EVAS_CALLBACK_MOUSE_UP, mini_control_action_cb, mc);

    Evas_Object *edje = elm_layout_edje_get(layout);
    edje_object_signal_callback_add(edje, "mouse,clicked,1", "hub_background", mini_control_background_action_cb, mc);

    /* */
    Evas_Object *progress = mc->progress = elm_slider_add(layout);
    elm_slider_horizontal_set(progress, EINA_TRUE);
    elm_object_disabled_set(progress, EINA_TRUE);
    elm_object_part_content_set(layout, "swallow.progress", progress);

    return mc;
}
Ejemplo n.º 11
0
void color_button::set_paint_server (const renderer_paint_server *server)
{
  setIcon (create_icon (server));
}
Ejemplo n.º 12
0
int
main(int argc, char **argv)
{
    int c;
    bool list_mode = false;
    bool extract_mode = false;
    bool create_mode = false;
    FILE *in;
    char *inname;
    int raw_filec = 0;
    char** raw_filev = 0;

    set_program_name(argv[0]);

#ifdef ENABLE_NLS
    if (setlocale(LC_ALL, "") == NULL)
	warn(_("%s: cannot set locale: %s"), program_name, errstr);
    if (bindtextdomain(PACKAGE, LOCALEDIR) == NULL)
	warn(_("%s: bindtextdomain failed: %s"), program_name, errstr);
    if (textdomain(PACKAGE) == NULL)
	warn(_("%s: cannot set message domain: %s"), program_name, errstr);
#endif

    while ((c = getopt_long(argc, argv, short_opts, long_opts, NULL)) != -1) {
	switch (c) {
	case 'x':
	    extract_mode = true;
	    break;
	case 'l':
	    list_mode = true;
	    break;
	case 'c':
	    create_mode = true;
	    break;
	case VERSION_OPT:
	    version_etc(stdout, PROGRAM, PACKAGE, VERSION, "Oskar Liljeblad", NULL);
	    exit(0);
	case HELP_OPT:
	    display_help();
	    exit(0);
	case 'o':
	    output = optarg;
	    break;
	case 'i':
	    if (!parse_int32(optarg, &image_index) || image_index < 0)
		die(_("invalid index value: %s"), optarg);
	    break;
	case 'w':
	    if (!parse_int32(optarg, &width) || width < 0)
		die(_("invalid width value: %s"), optarg);
	    break;
	case 'h':
	    if (!parse_int32(optarg, &height) || height < 0)
		die(_("invalid height value: %s"), optarg);
	    break;
	case 'p':
	    if (!parse_int32(optarg, &palettesize) || palettesize < 0)
		die(_("invalid palette-size value: %s"), optarg);
	    break;
	case 'b':
	    if (!parse_int32(optarg, &bitdepth) || bitdepth < 0)
		die(_("invalid bit-depth value: %s"), optarg);
	    break;
        /*case 'm':
            if (!parse_uint32(optarg, &minbitdepth))
                die(_("invalid minimum bit-depth value: %s"), optarg);
            break;*/
	case 'X':
	    if (!parse_int32(optarg, &hotspot_x) || hotspot_x < 0)
		die(_("invalid hotspot-x value: %s"), optarg);
	    hotspot_x_set = true;
	    break;
	case 'Y':
	    if (!parse_int32(optarg, &hotspot_y) || hotspot_y < 0)
		die(_("invalid hotspot-y value: %s"), optarg);
	    hotspot_y_set = true;
	    break;
	case 't':
	    if (!parse_int32(optarg, &alpha_threshold) || alpha_threshold < 0)
		die(_("invalid alpha-threshold value: %s"), optarg);
	    break;
	case 'r':
	    raw_filev = realloc (raw_filev, (raw_filec+1)*sizeof (char*));
	    raw_filev[raw_filec] = optarg;
	    raw_filec++;
	    break;
	case ICON_OPT:
	    icon_only = true;
	    break;
	case CURSOR_OPT:
	    cursor_only = true;
	    break;
	case '?':
	    exit(1);
	}
    }

    if (extract_mode + create_mode + list_mode > 1)
	die(_("multiple commands specified"));
    if (extract_mode + create_mode + list_mode == 0) {
	warn(_("missing argument"));
	display_help();
	exit (1);
    }
    if (icon_only && cursor_only)
	die(_("only one of --icon and --cursor may be specified"));

    if (list_mode) {
	if (argc-optind <= 0)
	    die(_("missing file argument"));
	for (c = optind ; c < argc ; c++) {
	    if (open_file_or_stdin(argv[c], &in, &inname)) {
		if (!extract_icons(in, inname, true, NULL, filter))
		    exit(1);
		if (in != stdin)
		    fclose(in);
	    }
	}
    }

    if (extract_mode) {
	if (argc-optind <= 0)
	    die(_("missing arguments"));

        for (c = optind ; c < argc ; c++) {
            int matched;

	    if (open_file_or_stdin(argv[c], &in, &inname)) {
	        matched = extract_icons(in, inname, false, extract_outfile_gen, filter);
	        if (matched == -1)
	            exit(1);
                if (matched == 0)
                    fprintf(stderr, _("%s: no images matched\n"), inname);
                if (in != stdin)
                    fclose(in);
            }
        }
    }

    if (create_mode) {
        if (argc-optind+raw_filec <= 0)
	    die(_("missing arguments"));
        if (!create_icon(argc-optind, argv+optind, raw_filec, raw_filev, create_outfile_gen, (icon_only ? true : !cursor_only), hotspot_x, hotspot_y, alpha_threshold, bitdepth))
            exit(1);
    }

    exit(0);
}
Ejemplo n.º 13
0
/* Parse args and go */
int
main(int argc, char *argv[])
{
    XtAppContext context;

#ifndef HAVE_XTVAOPENAPPLICATION
    Display *display;
#endif
    XTickertapeRec rc;
    elvin_handle_t handle;
    elvin_error_t error;
    const char *user;
    const char *domain;
    const char *ticker_dir;
    const char *config_file;
    const char *groups_file;
    const char *usenet_file;
    const char *keys_file;
    const char *keys_dir;
    Widget top;
    const char *names[AN_MAX + 1];
    int i;

    /* Determine the name of the executable. */
    progname = xbasename(argv[0]);

#ifdef HAVE_XTVAOPENAPPLICATION
    /* Create the toplevel widget */
    top = XtVaOpenApplication(
        &context, "XTickertape",
        NULL, 0,
        &argc, argv, NULL,
        applicationShellWidgetClass,
        XtNborderWidth, 0,
        NULL);
#else
    /* Initialize the X Toolkit */
    XtToolkitInitialize();

    /* Create an application context */
    context = XtCreateApplicationContext();

    /* Open the display */
    display = XtOpenDisplay(context, NULL, NULL, "XTickertape",
                            NULL, 0, &argc, argv);
    if (display == NULL) {
        fprintf(stderr, "Error: Can't open display\n");
        exit(1);
    }

    /* Create the toplevel widget */
    top = XtAppCreateShell(NULL, "XTickertape", applicationShellWidgetClass,
                           display, NULL, 0);
#endif

    /* Load the application shell resources */
    XtGetApplicationResources(top, &rc, resources, XtNumber(resources),
                              NULL, 0);

    /* Make sure our app-defaults file has a version number */
    if (rc.version_tag == NULL) {
        app_defaults_version_error("app-defaults file not found or "
                                   "out of date");
        exit(1);
    }

    /* Make sure that version number is the one we want */
    if (strcmp(rc.version_tag, PACKAGE "-" VERSION) != 0) {
        app_defaults_version_error("app-defaults file has the wrong "
                                   "version number");
        exit(1);
    }

    /* Add a calback for when it gets destroyed */
    XtAppAddActions(context, actions, XtNumber(actions));

#if !defined(ELVIN_VERSION_AT_LEAST)
    /* Initialize the elvin client library */
    error = elvin_xt_init(context);
    if (error == NULL) {
        fprintf(stderr, "*** elvin_xt_init(): failed\n");
        exit(1);
    }

    /* Double-check that the initialization worked */
    if (elvin_error_is_error(error)) {
        eeprintf(error, "elvin_xt_init failed\n");
        exit(1);
    }

    /* Create a new elvin connection handle */
    handle = elvin_handle_alloc(error);
    if (handle == NULL) {
        eeprintf(error, "elvin_handle_alloc failed\n");
        exit(1);
    }

#elif ELVIN_VERSION_AT_LEAST(4, 1, -1)
    /* Allocate an error context */
    error = elvin_error_alloc(NULL, NULL);
    if (error == NULL) {
        fprintf(stderr, "%s: error: elvin_error_alloc failed\n", progname);
        exit(1);
    }

    /* Initialize the elvin client library */
    client = elvin_xt_init_default(context, error);
    if (client == NULL) {
        eeprintf(error, "elvin_xt_init failed\n");
        exit(1);
    }

    /* Create a new elvin connection handle */
    handle = elvin_handle_alloc(client, error);
    if (handle == NULL) {
        eeprintf(error, "elvin_handle_alloc failed\n");
        exit(1);
    }
#else /* ELVIN_VERSION_AT_LEAST */
# error "Unsupported Elvin library version"
#endif /* ELVIN_VERSION_AT_LEAST */

    /* Scan what's left of the arguments */
    parse_args(argc, argv, handle, &user, &domain,
               &ticker_dir, &config_file,
               &groups_file, &usenet_file,
               &keys_file, &keys_dir,
               error);

    /* Intern a bunch of atoms.  We jump through a few hoops in order
     * in order to do this in a single RPC to the X server. */
#ifdef USE_ASSERT
    memset(names, 0, sizeof(names));
#endif /* USE_ASSERT */
    for (i = 0; i <= AN_MAX; i++) {
        ASSERT(names[atom_list[i].index] == NULL);
        names[atom_list[i].index] = atom_list[i].name;
    }

    /* Make sure we've specified a name for each atom. */
    for (i = 0; i <= AN_MAX; i++) {
        ASSERT(names[i] != NULL);
    }

    /* Intern the atoms. */
    if (!XInternAtoms(XtDisplay(top), (char **)names, AN_MAX + 1,
                      False, atoms)) {
        fprintf(stderr, "%s: error: XInternAtoms failed\n", progname);
        exit(1);
    }

    /* Create an Icon for the root shell */
    XtVaSetValues(top, XtNiconWindow, create_icon(top), NULL);

    /* Create a tickertape */
    tickertape = tickertape_alloc(
        &rc, handle,
        user, domain,
        ticker_dir, config_file,
        groups_file, usenet_file,
        keys_file, keys_dir,
        top,
        error);

    /* Set up SIGHUP to reload the subscriptions */
    signal(SIGHUP, reload_subs);

#ifdef USE_VALGRIND
    /* Set up SIGUSR1 to invoke valgrind. */
    signal(SIGUSR1, count_leaks);
#endif /* USE_VALGRIND */

#ifdef HAVE_LIBXMU
    /* Enable editres support */
    XtAddEventHandler(top, (EventMask)0, True, _XEditResCheckMessages, NULL);
#endif /* HAVE_LIBXMU */

    /* Let 'er rip! */
    XtAppMainLoop(context);

    /* Keep the compiler happy */
    return 0;
}
Ejemplo n.º 14
0
static bool UseIShellLink( bool uninstall )
/*****************************************/
{
    WORD                dir_index, icon_number;
    int                 i, num_icons, num_groups;
    int                 num_installed, num_total_install;
    DWORD               temp;
    char                prog_name[_MAX_PATH], prog_desc[_MAX_PATH];
    char                icon_name[_MAX_PATH], working_dir[_MAX_PATH];
    char                group[_MAX_PATH], prog_arg[_MAX_PATH], tmp[_MAX_PATH];
    BOOL                rc;

    if( uninstall ) {
        num_groups = SimGetNumPMGroups();
        for( i = 0; i < num_groups; i++ ) {
            SimGetPMGroupName( i, group );
            if( *group != '\0' ) {
                // Delete the PM Group box
                remove_group( group );
            }
        }
        return( TRUE );
    }

    SimGetPMGroup( group );
    if( group[0] == '\0' ) {
        return( TRUE );
    }

    CoInitialize( NULL );

    // Create the PM Group box.
    if( !create_group( group ) ) {
        CoUninitialize();
        return( FALSE );
    }

    // Add the individual PM files to the Group box.
    num_icons = SimGetNumPMProgs();
    StatusLines( STAT_CREATEPROGRAMFOLDER, "" );
    num_total_install = 0;
    for( i = 0; i < num_icons; i++ ) {
        if( SimCheckPMCondition( i ) ) {
            ++num_total_install;
        }
    }
    num_installed = 0;
    StatusAmount( 0, num_total_install );
    for( i = 0; i < num_icons; i++ ) {
        if( !SimCheckPMCondition( i ) ) {
            continue;
        }
        SimGetPMDesc( i, prog_desc );
        dir_index = SimGetPMProgName( i, prog_name );
        if( strcmp( prog_name, "GROUP" ) == 0 ) {
            /* creating a new group */
            strcpy( group, prog_desc );
            if( !create_group( group ) ) {
                CoUninitialize();
                return( FALSE );
            }
        } else {
            // Adding item to group
            if( dir_index == SIM_INIT_ERROR ) {
                working_dir[ 0 ] = '\0';
                ReplaceVars( tmp, prog_name );
                strcpy( prog_name, tmp );
            } else {
                SimDirNoSlash( dir_index, working_dir );
            }

            // Get parameters
            SimGetPMParms( i, tmp );
            ReplaceVars( prog_arg, tmp );

            // Append the subdir where the icon file is and the icon file's name.
            temp = SimGetPMIconInfo( i, icon_name );
            dir_index = LOWORD( temp );
            icon_number = HIWORD( temp );
            if( icon_number == SIM_INIT_ERROR ) icon_number = 0;
            if( dir_index != SIM_INIT_ERROR ) {
                SimGetDir( dir_index, tmp );
                strcat( tmp, icon_name );
                strcpy( icon_name, tmp );
            }
            // Add the new file to the already created PM Group.
            rc = create_icon( group, prog_name, prog_desc, prog_arg, working_dir,
                              icon_name, icon_number );
            if( rc == FALSE ) {
                CoUninitialize();
                return( FALSE );
            }
        }
        ++num_installed;
        StatusAmount( num_installed, num_total_install );
        if( StatusCancelled() )
            break;
    }
    StatusAmount( num_total_install, num_total_install );

    CoUninitialize();
    return( TRUE );
}