Ejemplo n.º 1
0
void wxTopLevelWindowGTK::SetIcons( const wxIconBundle &icons )
{
    wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );

    wxTopLevelWindowBase::SetIcons( icons );

    if ( icons.IsEmpty() )
        return;

    GdkWindow* window = m_widget->window;
    if (!window)
        return;

    wxIcon icon = icons.GetIcon(-1);
    if (icon.IsOk())
    {
        wxMask *mask = icon.GetMask();
        GdkBitmap *bm = NULL;
        if (mask) bm = mask->GetBitmap();

        gdk_window_set_icon( m_widget->window, NULL, icon.GetPixmap(), bm );
    }

    wxSetIconsX11( (WXDisplay*)GDK_WINDOW_XDISPLAY( window ),
                   (WXWindow)GDK_WINDOW_XWINDOW( window ), icons );
}
Ejemplo n.º 2
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.º 3
0
G_GNUC_COLD void
icon_init(void)
{
    GtkPixmap *pixmap;
    pixmap = (GtkPixmap *) create_pixmap(gui_main_window(), "icon.xpm");
    gtk_pixmap_get(pixmap, &icon_map, &icon_mask);
    gdk_window_set_icon(gui_main_window()->window, NULL, icon_map, icon_mask);
}
Ejemplo n.º 4
0
static VALUE
gdkwin_set_icon(VALUE self, VALUE icon, VALUE pixmap, VALUE mask)
{
    gdk_window_set_icon(_SELF(self), NIL_P(icon) ? NULL :_SELF(icon),
                        NIL_P(pixmap) ? NULL : GDK_PIXMAP(RVAL2GOBJ(pixmap)),
                        NIL_P(mask) ? NULL : GDK_BITMAP(RVAL2GOBJ(mask)));
    return self;
}
Ejemplo n.º 5
0
static void
set_icon_bitmap(GtkWidget *w)
{
	GdkPixmap *icon_pixmap;

	gdk_window_set_icon_name(w->window, APPNAME);
	icon_pixmap = gdk_bitmap_create_from_data(
	    w->window, np2_bits, np2_width, np2_height);
	gdk_window_set_icon(w->window, NULL, icon_pixmap, NULL);
}
Ejemplo n.º 6
0
static void
set_icon_pixmap(GtkWidget *window, gchar **bits)
{
    GdkPixmap	*pixmap;
    GdkBitmap	*mask;
    GtkStyle	*style;

    style = gtk_widget_get_style(window);
    pixmap = gdk_pixmap_create_from_xpm_d(window->window,
					  &mask,
					  &style->bg[GTK_STATE_NORMAL],
					  bits);
    gdk_window_set_icon(window->window, NULL, pixmap, mask);
    gdk_window_set_icon_name(window->window, "TiMidity");
}
Ejemplo n.º 7
0
// Set ICON PIXMAP property for window
int
clip_GTK_WINDOWSETICONPIXMAP(ClipMachine * cm)
{
	C_widget *cwin = _fetch_cw_arg(cm);
	C_widget *cpix = _fetch_cwidget(cm,_clip_spar(cm,2));
        GdkPixmap *pix;
        GdkBitmap *bit;
	CHECKCWID(cwin,GTK_IS_WINDOW);
	CHECKARG2(2,MAP_t,NUMERIC_t); CHECKCWID(cpix,GTK_IS_PIXMAP);
	gtk_pixmap_get(GTK_PIXMAP(cpix->widget), &pix, &bit);
	gdk_window_set_icon(GDK_WINDOW(cwin->widget->window),
			    GDK_WINDOW(cpix->widget->window),
		pix, bit);
	return 0;
err:
	return 1;
}
Ejemplo n.º 8
0
void
wins_set_icon (GtkWidget *win)
{
#ifdef USE_XLIB
	GdkAtom icon_atom;
	glong data[2];

	gtk_widget_realize (win);

	data[0] = GDK_WINDOW_XWINDOW (pix_xchat_mini);
	data[1] = GDK_WINDOW_XWINDOW (mask_xchat_mini);
	icon_atom = gdk_atom_intern ("KWM_WIN_ICON", FALSE);
	gdk_property_change (win->window, icon_atom, icon_atom,
								32, GDK_PROP_MODE_REPLACE, (guchar *) data, 2);

	gdk_window_set_icon (win->window, NULL, pix_xchat, mask_xchat);
	gdk_window_set_icon_name (win->window, PACKAGE);
#endif
}
Ejemplo n.º 9
0
/* Set our window icon.  The GDK documentation doesn't provide any
   actual documentation for gdk_window_set_icon(), so we'll steal
   libgimp/gimpdialog.c:gimp_dialog_realize_callback() from the Gimp
   sources and assume it's safe.

   XXX - The current icon size is fixed at 16x16 pixels, which looks fine
   with kwm (KDE 1.x's window manager), Sawfish (the "default" window
   manager for GNOME?), and under Windows with Exceed putting X windows
   on the Windows desktop, using Exceed as the window manager, as those
   window managers put a 16x16 icon on the title bar.

   The window managers in some windowing environments (e.g. dtwm in CDE)
   and some stand-alone window managers have larger icon sizes (many window
   managers put the window icon on the desktop, in the Windows 3.x style,
   rather than in the titlebar, in the Windows 4.x style), so we need to
   find a way to size our icon appropriately.

   The X11 Inter-Client Communications Conventions Manual, Version 1.1,
   in X11R5, specifies that "a window manager that wishes to place
   constraints on the sizes of icon pixmaps and/or windows should
   place a property called WM_ICON_SIZE on the root"; that property
   contains minimum width and height, maximum width and height, and
   width and height increment values.  "XGetIconSizes()" retrieves
   that property; unfortunately, I've yet to find a window manager
   that sets it on the root window (kwm, AfterStep, and Exceed don't
   appear to set it).

   The X Desktop Group's Window Manager Standard specifies, in the section
   on Application Window Properties, an _NET_WM_ICON property, presumably
   set by the window manager, which is an array of possible icon sizes
   for the client.  There's no API in GTK+ 1.2[.x] for this; there may
   eventually be one either in GTK+ 2.0 or GNOME 2.0.

   Some window managers can be configured to take the window name
   specified by the WM_NAME property of a window or the resource
   or class name specified by the WM_CLASS property and base the
   choice of icon for the window on one of those; WM_CLASS for
   Wireshark's windows has a resource name of "wireshark" and a class
   name of "Wireshark".  However, the way that's done is window-manager-
   specific, and there's no way to determine what size a particular
   window manager would want, so there's no way to automate this as
   part of the installation of Wireshark.
   */
static void
window_icon_realize_cb (GtkWidget *win, gpointer data _U_)
{
#ifndef _WIN32
  static GdkPixmap *icon_pmap = NULL;
  static GdkBitmap *icon_mask = NULL;
  GtkStyle         *style;

  style = gtk_widget_get_style (win);

  if (icon_pmap == NULL) {
    icon_pmap = gdk_pixmap_create_from_xpm_d (win->window,
		&icon_mask, &style->bg[GTK_STATE_NORMAL],
		(gchar **) wsicon16_xpm);
  }

  gdk_window_set_icon (win->window, NULL, icon_pmap, icon_mask);
#endif
}
Ejemplo n.º 10
0
static void
gimp_dialog_realize_callback (GtkWidget *widget,
			      gpointer   data) 
{
  static GdkPixmap *wilber_pixmap = NULL;
  static GdkBitmap *wilber_mask   = NULL;
  GtkStyle         *style;

  style = gtk_widget_get_style (widget);

  if (wilber_pixmap == NULL)
    wilber_pixmap =
      gdk_pixmap_create_from_xpm_d (widget->window,
				    &wilber_mask,
				    &style->bg[GTK_STATE_NORMAL],
				    spot_icon_xpm);

  gdk_window_set_icon (widget->window, NULL,
		       wilber_pixmap, wilber_mask);
}
Ejemplo n.º 11
0
/**
 * @fn GtkWidget* create_mainwin (void)
 * Crea la ventana principal
 */
GtkWidget* create_mainwin (void)
{
	GtkWidget *app1;
	GtkWidget *dock1;
	GtkWidget *eventbox1;
	GtkWidget *viewport1;
	GtkWidget *vbox_main;
	GtkWidget *vbox_paned;
	GtkWidget *scrolledwindow;
	GtkWidget *paned;
	GtkWidget *text;
	GtkWidget *inputline;
	GtkWidget *sw;
	GtkWidget *ahbox;

	app1 = gnome_app_new ( PACKAGE, "Tenes Empanadas Graciela");
	gtk_object_set_data (GTK_OBJECT (app1), "app1", app1);
	gtk_window_set_default_size (GTK_WINDOW (app1), 664, 640);
	gtk_window_set_policy (GTK_WINDOW (app1), TRUE, TRUE, FALSE);

	dock1 = GNOME_APP (app1)->dock;
	gtk_widget_ref (dock1);
	gtk_object_set_data_full (GTK_OBJECT (app1), "dock1", dock1,
		(GtkDestroyNotify) gtk_widget_unref);
	gtk_widget_show (dock1);

	gnome_app_create_menus (GNOME_APP (app1), menubar_uiinfo);
	gnome_app_create_toolbar(GNOME_APP(app1), toolbar_main);

	/* TODO: ask in GNOME if this is wanted */
	/* gtk_menu_item_right_justify( GTK_MENU_ITEM(menubar_uiinfo[4].widget)); */

	gtk_widget_realize (app1);

	gtk_signal_connect ( GTK_OBJECT(app1), "destroy",
		GTK_SIGNAL_FUNC( on_exit_activate ), NULL );

	gtk_signal_connect ( GTK_OBJECT(app1), "delete_event",
		GTK_SIGNAL_FUNC( on_exit_activate ), NULL );


	SensiData.connect_button = toolbar_main[0].widget;
	SensiData.start_button = toolbar_main[1].widget;
	/* 2 is a separator */
	SensiData.enviarfichas_button = toolbar_main[3].widget;
	SensiData.reagrupe_button = toolbar_main[4].widget;
	SensiData.getcard_button = toolbar_main[5].widget;
	SensiData.endturn_button = toolbar_main[6].widget;
	/* 7 is a separator */
	SensiData.status_button = toolbar_main[8].widget;

	eventbox1 = gtk_event_box_new ();
	gtk_widget_ref (eventbox1);
	gtk_object_set_data_full (GTK_OBJECT (app1), "eventbox1", eventbox1,
		(GtkDestroyNotify) gtk_widget_unref);
	gtk_widget_show (eventbox1);
	gnome_app_set_contents (GNOME_APP (app1), eventbox1);

	viewport1 = gtk_viewport_new (NULL, NULL);
	gtk_widget_show (viewport1);
	gtk_container_add (GTK_CONTAINER (eventbox1), viewport1);

	vbox_main = gtk_vbox_new (FALSE, 0);
	gtk_widget_show (vbox_main);
	gtk_container_add (GTK_CONTAINER (viewport1), vbox_main);

	/* status map */
	if( mainstatus_create(&window_mainstatus) != TEG_STATUS_SUCCESS )
		goto error;
	gtk_box_pack_start( GTK_BOX(vbox_main), window_mainstatus, FALSE,FALSE,0);

	/* paned */
	paned = gtk_vpaned_new();
	gtk_box_pack_start( GTK_BOX( vbox_main ), paned, TRUE, TRUE, 0 );
	vbox_paned = gtk_vbox_new (FALSE, 0);
	gtk_paned_add1(GTK_PANED(paned), vbox_paned);
	gtk_widget_show (vbox_paned);

	/* map */
	scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(scrolledwindow),
			GTK_POLICY_AUTOMATIC,
			GTK_POLICY_AUTOMATIC);
	gtk_widget_set_usize(scrolledwindow, 640, 394);

	if( canvas_create_map() != TEG_STATUS_SUCCESS )
		goto error;

	gtk_container_add(GTK_CONTAINER(scrolledwindow), canvas_map);
	gtk_container_add(GTK_CONTAINER(vbox_paned),scrolledwindow);
	gtk_widget_show (canvas_map);
	gtk_widget_show (scrolledwindow);


	/* text */
	ahbox = gtk_hbox_new(FALSE, 2);
	gtk_paned_pack2(GTK_PANED(paned), ahbox, TRUE, TRUE);

	sw = gtk_scrolled_window_new(NULL, NULL);

	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC,
					 GTK_POLICY_ALWAYS);
	gtk_box_pack_start(GTK_BOX(ahbox), sw, TRUE, TRUE, 0);

	gtk_widget_set_size_request(sw, 620, 60);

	text = gtk_text_view_new();
	gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
	gtk_container_add(GTK_CONTAINER(sw), text);

	gtk_widget_set_name(text, "chatline");

	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
	gtk_widget_realize(text);
	gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 5);

	main_message_area = GTK_TEXT_VIEW(text);

/*	set_output_window_text(_("Tenes Empanadas Graciela")); */

	gtk_widget_show(text);
	gtk_widget_show(sw);
	gtk_widget_show(ahbox);
	gtk_widget_show(paned);

	/* the chat line */
	inputline = gtk_entry_new();
	gtk_box_pack_start( GTK_BOX( vbox_main ), inputline, FALSE, FALSE, 0 );
	gtk_widget_show(inputline);
	g_signal_connect(inputline, "activate", G_CALLBACK(inputline_return), NULL);


	chatline_init();


	/* status bar */
	statusbar = gnome_appbar_new (FALSE, TRUE, GNOME_PREFERENCES_NEVER);
	gtk_widget_ref (statusbar);
	gtk_object_set_data_full (GTK_OBJECT (app1), "statusbar", statusbar,
		(GtkDestroyNotify) gtk_widget_unref);
	gtk_widget_show (statusbar);
	gnome_app_set_statusbar (GNOME_APP (app1), statusbar);

	gtk_box_pack_start(GTK_BOX(statusbar),
		ministatus_build(), FALSE, TRUE, 0);


	gnome_appbar_set_status(GNOME_APPBAR(statusbar),
				_("Welcome to TEG!"));

	gnome_app_install_menu_hints( GNOME_APP(app1), menubar_uiinfo );

	/* icono */
	{
		GdkBitmap *mask;
		GdkPixmap *icono;
		#include "../teg_pix/teg_icono.xpm"
		gtk_widget_realize (app1);
		icono = gdk_pixmap_create_from_xpm_d( app1->window, &mask, &app1->style->bg[GTK_STATE_NORMAL],teg_icono_xpm );
		gdk_window_set_icon (app1->window, NULL, icono , mask );
	}

	gtk_widget_show(app1);
	return app1;

error:
	g_error(_("Unable to create map!"));
	return NULL;
}
Ejemplo n.º 12
0
main(int argc, char *argv[])
{
   int n;
   int rows, cols;
   int drawButtons;
   char *btn_font, *disp_font;
   /* GtkWidget *main_w; */
   GtkWidget *vbox;
   GtkWidget *menu;
   GtkWidget *mdisp;
   GtkWidget *lcd;
   GtkWidget *btns;
   GdkFont *new_font;
   GtkStyle *default_style, *new_style;
   GdkBitmap *icon_bitmap;
#ifdef USE_GNOME
   GnomeAppBar *appbar;
#endif

   setlocale(LC_ALL, "C");
#ifdef USE_GNOME
   gnome_init("grpn", "1.0", argc, argv);
   gnome_app_new("grpn", "grpn");
#else
   /* initialize gtk */
   gtk_init(&argc, &argv);
#endif

   /* initial values */
   drawButtons = 1;
   rows = 8;
   cols = 30;
   btn_font = disp_font = NULL;

   /* process command line args */
   n = 1;
   while(n < argc){
      if(0 == strcmp("-fn", argv[n])){
         n++;
         if(n >= argc){
            usage("Missing required argument for -fn.");
            exit(0);
         }
         btn_font = disp_font = argv[n];
      } else if(0 == strcmp("-btn-fn", argv[n])){
         n++;
         if(n >= argc){
            usage("Missing required argument for -btn-fn.");
            exit(0);
         }
         btn_font = argv[n];
      } else if(0 == strcmp("-disp-fn", argv[n])){
         n++;
         if(n >= argc){
            usage("Missing required argument for -disp-fn.");
            exit(0);
         }
         disp_font = argv[n];
      } else if(0 == strcmp("-rows", argv[n])){
         n++;
         if(n >= argc){
            usage("Missing required argument for -rows.");
            exit(0);
         }
         if(1 != sscanf(argv[n], "%d", &rows)){
            usage("Unable to read number or rows.");
            exit(0);
         }
      } else if(0 == strcmp("-cols", argv[n])){
         n++;
         if(n >= argc){
            usage("Missing required argument for -cols.");
            exit(0);
         }
         if(1 != sscanf(argv[n], "%d", &cols)){
            usage("Unable to read number or cols.");
            exit(0);
         }
      } else if(0 == strcmp("-b", argv[n])){
         drawButtons = 0;
      } else if(0 == strcmp("-bm", argv[n])){
         n++;
         if(n >= argc){
            usage("Missing required argument for -m.");
            exit(0);
         }
         if (0 == strcmp("dec", argv[n])){
             setBaseMode(DECIMAL);
	 } else if (0 == strcmp("eng", argv[n])){
             setBaseMode(DECIMAL_ENG);
	 } else if (0 == strcmp("bin", argv[n])){
             setBaseMode(BINARY);
	 } else if (0 == strcmp("oct", argv[n])){
             setBaseMode(OCTAL);
	 } else if (0 == strcmp("hex", argv[n])){
             setBaseMode(HEXADECIMAL);
	 } else {
             usage("Specify dec, eng, bin, oct or hex for -m.");
             exit(0);
         }
      } else {
         usage("Unknown Argument.");
         exit(0);
      }
      n++;
   }

   /* set up any constants we may use */
   setup_constant();

   /* initialize the undo system */
   initUndoSystem();

   /* setup the stack */
   if(0 == setup_stack()){
      fprintf(stderr, "Error: Could not initalize data structures.\n");
      exit(0);
   }

   /* set the font if told */
   if(btn_font != NULL){
      default_style = gtk_widget_get_default_style();
      if(NULL == (new_font = gdk_font_load(btn_font))){
         fprintf(stderr, "Unable to load font %s.\n", btn_font);
         exit(0);
      }
      new_style = gtk_style_copy(default_style);
      new_style->font_desc = new_font;
/* BDD - No longer in Gtk2.x */
/*      gtk_widget_set_default_style(new_style); */
   }
   

#ifdef USE_GNOME
   main_w = gnome_app_new("grpn", "grpn");
   setup_menu(main_w);

   appbar = GNOME_APPBAR(gnome_appbar_new(FALSE, FALSE, FALSE));
   gnome_app_set_statusbar(GNOME_APP(main_w), GTK_WIDGET(appbar));

   /*create the box that everyone goes in */
   vbox = gtk_vbox_new(FALSE, 0);
   gnome_app_set_contents(GNOME_APP(main_w), vbox);
   gtk_widget_show(vbox);

#else
   /* the main window contains the work area and the menubar */
   main_w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
   gtk_widget_set_name(main_w, "grpn");

   /*create the box that everyone goes in */
   vbox = gtk_vbox_new(FALSE, 0);
   gtk_container_add(GTK_CONTAINER(main_w), vbox);
   gtk_widget_show(vbox);

   /* set up the menu bar */
   menu = setup_menu(vbox);
#endif

   /* handle window manager close */
   gtk_signal_connect(GTK_OBJECT(main_w), "delete_event",
      GTK_SIGNAL_FUNC(delete_event), NULL);
   gtk_signal_connect(GTK_OBJECT(main_w), "destroy",
      GTK_SIGNAL_FUNC(destroy), NULL);

   /* create the varrious subsystems */
   mdisp = setupModeDisplay(vbox);
   if(drawButtons) btns = setupButtons(vbox);
   lcd = setupLCD(vbox, rows, cols, disp_font);

   /* Create pixmap of depth 1 (bitmap) for icon */
   gtk_widget_realize(main_w);
   icon_bitmap = gdk_bitmap_create_from_data(main_w->window,
      icon_bitmap_bits, icon_bitmap_width, icon_bitmap_height);
   gdk_window_set_icon(main_w->window, NULL, icon_bitmap, NULL);

   gtk_widget_show(main_w);

   gtk_main();

}
Ejemplo n.º 13
0
void 
about_dialog (gpointer data)
{
  GtkWidget * tempwid, * notebook, * box, * label, * view, * vscroll, * dialog;
  char *tempstr, *temp1str, *no_license_agreement, *str, buf[255], *share_dir;
  size_t len;
  FILE * fd;
#if GTK_MAJOR_VERSION > 1
  GtkTextBuffer * textbuf;
  GtkTextIter iter;
  gint textlen;
#endif

  share_dir = gftp_get_share_dir ();
  no_license_agreement = g_strdup_printf (_("Cannot find the license agreement file COPYING. Please make sure it is in either %s or in %s"), BASE_CONF_DIR, share_dir);

#if GTK_MAJOR_VERSION == 1
  dialog = gtk_dialog_new ();
  gtk_window_set_title (GTK_WINDOW (dialog), _("About gFTP"));
  gtk_container_border_width (GTK_CONTAINER
			      (GTK_DIALOG (dialog)->action_area), 5);
  gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->action_area), TRUE);
#else
  dialog = gtk_dialog_new_with_buttons (_("About gFTP"), NULL, 0,
                                        GTK_STOCK_CLOSE,
                                        GTK_RESPONSE_CLOSE,
                                        NULL);
#endif
  gtk_window_set_wmclass (GTK_WINDOW(dialog), "about", "gFTP");
  gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
  gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10);
  gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 5);
  gtk_widget_realize (dialog);

  if (gftp_icon != NULL)
    {
      gdk_window_set_icon (dialog->window, NULL, gftp_icon->pixmap,
                           gftp_icon->bitmap);
      gdk_window_set_icon_name (dialog->window, gftp_version);
    }

  notebook = gtk_notebook_new ();
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, TRUE,
		      TRUE, 0);
  gtk_widget_show (notebook);

  box = gtk_vbox_new (TRUE, 5);
  gtk_container_border_width (GTK_CONTAINER (box), 10);
  gtk_widget_show (box);

  tempwid = toolbar_pixmap (dialog, "gftp-logo.xpm");
  gtk_box_pack_start (GTK_BOX (box), tempwid, FALSE, FALSE, 0);
  gtk_widget_show (tempwid);

  tempstr = g_strdup_printf (_("%s\nCopyright (C) 1998-2007 Brian Masney <*****@*****.**>\nOfficial Homepage: http://www.gftp.org/\n"), gftp_version);
  str = _("Translated by");
  if (strcmp (str, "Translated by") != 0)
    {
      tempstr = g_realloc (tempstr,
                           (gulong) (strlen (tempstr) + strlen (str) + 1));
      strcat (tempstr, str);
    }
  tempwid = gtk_label_new (tempstr);
  g_free (tempstr);
  gtk_box_pack_start (GTK_BOX (box), tempwid, FALSE, FALSE, 0);
  gtk_widget_show (tempwid);

  label = gtk_label_new (_("About"));
  gtk_widget_show (label);

  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), box, label);

  box = gtk_vbox_new (FALSE, 5);
  gtk_container_border_width (GTK_CONTAINER (box), 10);
  gtk_widget_show (box);

  tempwid = gtk_table_new (1, 2, FALSE);
  gtk_box_pack_start (GTK_BOX (box), tempwid, TRUE, TRUE, 0);
  gtk_widget_show (tempwid);

#if GTK_MAJOR_VERSION == 1
  view = gtk_text_new (NULL, NULL);
  gtk_text_set_editable (GTK_TEXT (view), FALSE);
  gtk_text_set_word_wrap (GTK_TEXT (view), TRUE);

  gtk_table_attach (GTK_TABLE (tempwid), view, 0, 1, 0, 1,
                    GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK,
                    0, 0);
  gtk_widget_show (view);

  vscroll = gtk_vscrollbar_new (GTK_TEXT (view)->vadj);
  gtk_table_attach (GTK_TABLE (tempwid), vscroll, 1, 2, 0, 1,
                    GTK_FILL, GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0);
  gtk_widget_show (vscroll);
#else
  view = gtk_text_view_new ();
  gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
  gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
  gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD);

  vscroll = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (vscroll),
                                 GTK_POLICY_AUTOMATIC,
                                 GTK_POLICY_AUTOMATIC);

  gtk_container_add (GTK_CONTAINER (vscroll), view);
  gtk_widget_show (view);

  gtk_table_attach (GTK_TABLE (tempwid), vscroll, 0, 1, 0, 1,
                    GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK,
                    0, 0);
  gtk_widget_show (vscroll);

  textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
#endif

  label = gtk_label_new (_("License Agreement"));
  gtk_widget_show (label);

  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), box, label);

#if GTK_MAJOR_VERSION == 1
  tempwid = gtk_button_new_with_label (_("  Close  "));
  GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
		      FALSE, FALSE, 0);
  gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked",
			     GTK_SIGNAL_FUNC (gtk_widget_destroy),
			     GTK_OBJECT (dialog));
  gtk_widget_grab_default (tempwid);
  gtk_widget_show (tempwid);
#else
  g_signal_connect_swapped (GTK_OBJECT (dialog), "response",
                            G_CALLBACK (gtk_widget_destroy),
                            GTK_OBJECT (dialog));
#endif

  tempstr = g_strconcat ("/usr/share/common-licenses/GPL", NULL);
  if (access (tempstr, F_OK) != 0)
    {
      g_free (tempstr);
      temp1str = g_strconcat (share_dir, "/COPYING", NULL);
      tempstr = gftp_expand_path (NULL, temp1str);
      g_free (temp1str);
      if (access (tempstr, F_OK) != 0)
	{
	  g_free (tempstr);
          tempstr = gftp_expand_path (NULL, BASE_CONF_DIR "/COPYING");
	  if (access (tempstr, F_OK) != 0)
	    {
#if GTK_MAJOR_VERSION == 1
	      gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL,
			       no_license_agreement, -1);
#else
              textlen = gtk_text_buffer_get_char_count (textbuf);
              gtk_text_buffer_get_iter_at_offset (textbuf, &iter, textlen);
              gtk_text_buffer_insert (textbuf, &iter, no_license_agreement, -1);
#endif
	      gtk_widget_show (dialog);
	      return;
	    }
	}
    }

  if ((fd = fopen (tempstr, "r")) == NULL)
    {
#if GTK_MAJOR_VERSION == 1
      gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL,
		       no_license_agreement, -1);
#else
      textlen = gtk_text_buffer_get_char_count (textbuf);
      gtk_text_buffer_get_iter_at_offset (textbuf, &iter, textlen);
      gtk_text_buffer_insert (textbuf, &iter, no_license_agreement, -1);
#endif
      gtk_widget_show (dialog);
      g_free (tempstr);
      return;
    }
  g_free (tempstr);

  memset (buf, 0, sizeof (buf));
  while ((len = fread (buf, 1, sizeof (buf) - 1, fd)))
    {
      buf[len] = '\0';
#if GTK_MAJOR_VERSION == 1
      gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, buf, -1);
#else
      textlen = gtk_text_buffer_get_char_count (textbuf);
      gtk_text_buffer_get_iter_at_offset (textbuf, &iter, textlen);
      gtk_text_buffer_insert (textbuf, &iter, buf, -1);
#endif
    }
  fclose (fd);
  gtk_widget_show (dialog);
  g_free (no_license_agreement);
  gftp_free_pixmap ("gftp-logo.xpm");
}
Ejemplo n.º 14
0
void
chmod_dialog (gpointer data)
{
  GtkWidget *tempwid, *dialog, *hbox, *vbox;
  GList * templist, * filelist;
  gftp_window_data * wdata;
  gftp_file * tempfle;
  int num;

  wdata = data;
  if (!check_status (_("Chmod"), wdata, gftpui_common_use_threads (wdata->request), 0, 1, wdata->request->chmod != NULL))
    return;

#if GTK_MAJOR_VERSION == 1
  dialog = gtk_dialog_new ();
  gtk_window_set_title (GTK_WINDOW (dialog), _("Chmod"));
  gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area),
                              5);
  gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->action_area), TRUE);
#else
  dialog = gtk_dialog_new_with_buttons (_("Chmod"), NULL, 0,
                                        GTK_STOCK_CANCEL,
                                        GTK_RESPONSE_CANCEL,
                                        GTK_STOCK_OK,
                                        GTK_RESPONSE_OK,
                                        NULL);
#endif
  gtk_window_set_wmclass (GTK_WINDOW(dialog), "Chmod", "gFTP");
  gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
  gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 5);
  gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10);
  gtk_widget_realize (dialog);

  if (gftp_icon != NULL)
    {
      gdk_window_set_icon (dialog->window, NULL, gftp_icon->pixmap,
                           gftp_icon->bitmap);
      gdk_window_set_icon_name (dialog->window, gftp_version);
    }

  tempwid = gtk_label_new (_("You can now adjust the attributes of your file(s)\nNote: Not all ftp servers support the chmod feature"));
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), tempwid, FALSE,
		      FALSE, 0);
  gtk_widget_show (tempwid);

  hbox = gtk_hbox_new (TRUE, 5);
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, FALSE, FALSE,
		      0);
  gtk_widget_show (hbox);

  tempwid = gtk_frame_new (_("Special"));
  gtk_box_pack_start (GTK_BOX (hbox), tempwid, FALSE, FALSE, 0);
  gtk_widget_show (tempwid);

  vbox = gtk_vbox_new (TRUE, 5);
  gtk_container_add (GTK_CONTAINER (tempwid), vbox);
  gtk_widget_show (vbox);

  suid = gtk_check_button_new_with_label (_("SUID"));
  gtk_box_pack_start (GTK_BOX (vbox), suid, FALSE, FALSE, 0);
  gtk_widget_show (suid);

  sgid = gtk_check_button_new_with_label (_("SGID"));
  gtk_box_pack_start (GTK_BOX (vbox), sgid, FALSE, FALSE, 0);
  gtk_widget_show (sgid);

  sticky = gtk_check_button_new_with_label (_("Sticky"));
  gtk_box_pack_start (GTK_BOX (vbox), sticky, FALSE, FALSE, 0);
  gtk_widget_show (sticky);

  tempwid = gtk_frame_new (_("User"));
  gtk_box_pack_start (GTK_BOX (hbox), tempwid, FALSE, FALSE, 0);
  gtk_widget_show (tempwid);

  vbox = gtk_vbox_new (TRUE, 5);
  gtk_container_add (GTK_CONTAINER (tempwid), vbox);
  gtk_widget_show (vbox);

  ur = gtk_check_button_new_with_label (_("Read"));
  gtk_box_pack_start (GTK_BOX (vbox), ur, FALSE, FALSE, 0);
  gtk_widget_show (ur);

  uw = gtk_check_button_new_with_label (_("Write"));
  gtk_box_pack_start (GTK_BOX (vbox), uw, FALSE, FALSE, 0);
  gtk_widget_show (uw);

  ux = gtk_check_button_new_with_label (_("Execute"));
  gtk_box_pack_start (GTK_BOX (vbox), ux, FALSE, FALSE, 0);
  gtk_widget_show (ux);

  tempwid = gtk_frame_new (_("Group"));
  gtk_box_pack_start (GTK_BOX (hbox), tempwid, FALSE, FALSE, 0);
  gtk_widget_show (tempwid);

  vbox = gtk_vbox_new (TRUE, 5);
  gtk_container_add (GTK_CONTAINER (tempwid), vbox);
  gtk_widget_show (vbox);

  gr = gtk_check_button_new_with_label (_("Read"));
  gtk_box_pack_start (GTK_BOX (vbox), gr, FALSE, FALSE, 0);
  gtk_widget_show (gr);

  gw = gtk_check_button_new_with_label (_("Write"));
  gtk_box_pack_start (GTK_BOX (vbox), gw, FALSE, FALSE, 0);
  gtk_widget_show (gw);

  gx = gtk_check_button_new_with_label (_("Execute"));
  gtk_box_pack_start (GTK_BOX (vbox), gx, FALSE, FALSE, 0);
  gtk_widget_show (gx);

  tempwid = gtk_frame_new (_("Other"));
  gtk_box_pack_start (GTK_BOX (hbox), tempwid, FALSE, FALSE, 0);
  gtk_widget_show (tempwid);

  vbox = gtk_vbox_new (TRUE, 5);
  gtk_container_add (GTK_CONTAINER (tempwid), vbox);
  gtk_widget_show (vbox);

  or = gtk_check_button_new_with_label (_("Read"));
  gtk_box_pack_start (GTK_BOX (vbox), or, FALSE, FALSE, 0);
  gtk_widget_show (or);

  ow = gtk_check_button_new_with_label (_("Write"));
  gtk_box_pack_start (GTK_BOX (vbox), ow, FALSE, FALSE, 0);
  gtk_widget_show (ow);

  ox = gtk_check_button_new_with_label (_("Execute"));
  gtk_box_pack_start (GTK_BOX (vbox), ox, FALSE, FALSE, 0);
  gtk_widget_show (ox);

#if GTK_MAJOR_VERSION == 1
  tempwid = gtk_button_new_with_label (_("OK"));
  GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
		      TRUE, TRUE, 0);
  gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
		      GTK_SIGNAL_FUNC (dochmod), (gpointer) wdata);
  gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked",
			     GTK_SIGNAL_FUNC (gtk_widget_destroy),
			     GTK_OBJECT (dialog));
  gtk_widget_grab_default (tempwid);
  gtk_widget_show (tempwid);

  tempwid = gtk_button_new_with_label (_("  Cancel  "));
  GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
		      TRUE, TRUE, 0);
  gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked",
			     GTK_SIGNAL_FUNC (gtk_widget_destroy),
			     GTK_OBJECT (dialog));
  gtk_widget_show (tempwid);
#else
  g_signal_connect (GTK_OBJECT (dialog), "response",
                    G_CALLBACK (chmod_action), wdata);
#endif

  if (IS_ONE_SELECTED (wdata))
    {
      filelist = wdata->files;
      templist = gftp_gtk_get_list_selection (wdata);
      num = 0;
      templist = get_next_selection (templist, &filelist, &num);
      tempfle = filelist->data;

      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (suid),
                                    tempfle->st_mode & S_ISUID);
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ur),
                                    tempfle->st_mode & S_IRUSR);
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (uw),
                                    tempfle->st_mode & S_IWUSR);
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ux),
                                    tempfle->st_mode & S_IXUSR);

      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sgid),
                                    tempfle->st_mode & S_ISGID);
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gr),
                                    tempfle->st_mode & S_IRGRP);
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gw),
                                    tempfle->st_mode & S_IWGRP);
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gx),
                                    tempfle->st_mode & S_IXGRP);

      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sticky),
                                    tempfle->st_mode & S_ISVTX);
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (or),
                                    tempfle->st_mode & S_IROTH);
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ow),
                                    tempfle->st_mode & S_IWOTH);
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ox),
                                    tempfle->st_mode & S_IXOTH);
    }
  gtk_widget_show (dialog);
}
Ejemplo n.º 15
0
void
browser_create (void)
{
    GtkWidget *vbox;
    GdkPixmap *icon_pix;
    GdkBitmap *icon_mask;
    GtkAccelGroup *accel;
    GtkWidget *menu;
    GtkWidget *toolbar;
    GtkWidget *hpaned;
    GtkWidget *vpaned;
    GtkWidget *iconw;
    GtkWidget *hbox;
    GtkWidget *label;

    browser = g_new (Browser, 1);

    browser->current_path = g_string_new (conf.startup_dir);
    browser->last_path = g_string_new ("");
    browser->filelist = (FileList *) file_list_init ();

    browser->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title (GTK_WINDOW (browser->window), "PornView");
    gtk_widget_realize (browser->window);

    icon_pix =
	gdk_pixmap_create_from_xpm_d (G_WINDOW (browser->window), &icon_mask,
				      NULL, pornview_xpm);
    gdk_window_set_icon (G_WINDOW (browser->window), NULL, icon_pix,
			 icon_mask);

    gtk_signal_connect (GTK_OBJECT (browser->window), "delete_event",
			GTK_SIGNAL_FUNC (browser_destroy), NULL);

    gtk_window_set_default_size (GTK_WINDOW (browser->window),
				 conf.window_width, conf.window_height);

    vbox = gtk_vbox_new (FALSE, 0);
    gtk_widget_show (vbox);
    gtk_container_add (GTK_CONTAINER (browser->window), vbox);

    /*
     * main menu 
     */
    accel = gtk_accel_group_new ();
    browser->menu =
	gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<browser_menu>", accel);

#ifdef ENABLE_NLS
    gtk_item_factory_set_translate_func (browser->menu,
					 (GtkTranslateFunc) menu_translate,
					 NULL, NULL);
#endif

    gtk_item_factory_create_items (browser->menu, browser_menu_factory_count,
				   browser_menu_factory, NULL);
    menu = gtk_item_factory_get_widget (browser->menu, "<browser_menu>");

    gtk_box_pack_start (GTK_BOX (vbox), menu, FALSE, FALSE, 0);
    gtk_widget_show (menu);

#ifndef USE_GTK2
    gtk_accel_group_attach (accel, GTK_OBJECT (browser->window));
#endif

    /*
     * toolbar 
     */
#ifdef USE_GTK2
    toolbar = gtk_toolbar_new ();
#else
    toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS);
#endif

    gtk_box_pack_start (GTK_BOX (vbox), toolbar, FALSE, TRUE, 0);
    gtk_widget_show (toolbar);

    iconw = pixbuf_create_pixmap_from_xpm_data (exit_xpm);
    gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), NULL, _("Exit"), NULL,
			     iconw, (GtkSignalFunc) browser_destroy, NULL);

#ifndef USE_GTK2
    gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
#endif

    gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));

    iconw = pixbuf_create_pixmap_from_xpm_data (options_xpm);
    gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), NULL, _("Preference"),
			     NULL, iconw, (GtkSignalFunc) browser_prefs,
			     NULL);

    hpaned = gedo_hpaned_new ();
    gtk_container_add (GTK_CONTAINER (vbox), hpaned);
    gtk_widget_show (hpaned);

    vpaned = gedo_vpaned_new ();
    gtk_widget_show (vpaned);
    gedo_paned_add1 (GEDO_PANED (hpaned), vpaned);

    /*
     * dirtree 
     */
    dirview_create (conf.startup_dir, browser->window);

    gedo_paned_add1 (GEDO_PANED (vpaned), DIRVIEW_CONTAINER);

    commentview = comment_view_create ();

    browser->notebook = commentview->notebook;

    /*
     * videoplay 
     */
#ifdef ENABLE_MOVIE
    videoplay_create ();
    label = gtk_label_new (_(" Preview "));
    gtk_notebook_prepend_page (GTK_NOTEBOOK (browser->notebook),
			       VIDEOPLAY_CONTAINER, label);

    gtk_notebook_set_page (GTK_NOTEBOOK (browser->notebook), 0);

#endif

    /*
     * imageview
     */
    imageview_create ();
    label = gtk_label_new (_(" Preview "));
    gtk_notebook_prepend_page (GTK_NOTEBOOK (browser->notebook),
			       IMAGEVIEW_CONTAINER, label);

#ifndef ENABLE_MOVIE
    gtk_notebook_set_page (GTK_NOTEBOOK (browser->notebook), 0);
#endif

    gedo_paned_add2 (GEDO_PANED (hpaned), commentview->main_vbox);

    /*
     * thumbview 
     */
    thumbview_create (browser->window);
    gedo_paned_add2 (GEDO_PANED (vpaned), THUMBVIEW_CONTAINER);

    /*
     * statusbar 
     */
    hbox = gtk_hbox_new (FALSE, 0);
    gtk_widget_set_name (hbox, "StatusBarContainer");
    gtk_box_pack_end (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
    gtk_widget_show (hbox);

    browser->status_dir = gtk_statusbar_new ();
    gtk_widget_set_name (browser->status_dir, "StatusBar1");
    gtk_container_border_width (GTK_CONTAINER (browser->status_dir), 1);
    gtk_widget_set_usize (browser->status_dir, 80, 15);
    gtk_box_pack_start (GTK_BOX (hbox), browser->status_dir, FALSE, FALSE, 0);
    gtk_widget_show (browser->status_dir);

    browser->status_name = gtk_statusbar_new ();
    gtk_widget_set_name (browser->status_name, "StatusBar2");
    gtk_container_border_width (GTK_CONTAINER (browser->status_name), 1);
    gtk_widget_set_usize (browser->status_name, 150, -1);
    gtk_box_pack_start (GTK_BOX (hbox), browser->status_name, TRUE, TRUE, 0);
    gtk_widget_show (browser->status_name);

    browser->status_image = gtk_statusbar_new ();
    gtk_widget_set_name (browser->status_image, "StatusBar3");
    gtk_container_border_width (GTK_CONTAINER (browser->status_image), 1);
    gtk_widget_set_usize (browser->status_image, 150, -1);
    gtk_box_pack_start (GTK_BOX (hbox), browser->status_image, TRUE, TRUE, 0);
    gtk_widget_show (browser->status_image);

    browser->progress = gtk_progress_bar_new ();
    gtk_widget_set_name (browser->progress, "ProgressBar");
    gtk_box_pack_end (GTK_BOX (hbox), browser->progress, FALSE, FALSE, 0);
    gtk_widget_show (browser->progress);

    gtk_widget_show (browser->window);

#ifdef ENABLE_MOVIE
    gtk_widget_hide (gtk_notebook_get_nth_page
		     (GTK_NOTEBOOK (browser->notebook), 1));
    gtk_notebook_set_page (GTK_NOTEBOOK (browser->notebook), 0);
#endif

    dirview_scroll_center ();
    timer_id = gtk_timeout_add (100, cb_browser_select_dir, conf.startup_dir);
}
Ejemplo n.º 16
0
static void
gtk_ui_set_icon(Picture *icon) {
	gdk_window_set_icon(toplevel->window, NULL, icon->pix, icon->mask);
}
Ejemplo n.º 17
0
void
create_loglist(void)
{
  GtkWidget *mvb,*sw,*dhb,*dhw[30];
  GdkBitmap *mask;
  GdkPixmap *myicon;
  GtkStyle *style;
  GList *pt;
  int i;

  applet=gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size(GTK_WINDOW(applet),780,510);
  gtk_window_set_title (GTK_WINDOW (applet), "YAWMPPP Connection Log");
  gtk_window_set_wmclass(GTK_WINDOW(applet),"yawmppp","log");
  gtk_container_set_border_width(GTK_CONTAINER(applet),4);
  gtk_widget_show (applet);

  style=gtk_widget_get_style(applet);
  myicon = gdk_pixmap_create_from_xpm_d (applet->window, &mask,
				       &style->bg[GTK_STATE_NORMAL],
				       (gchar **) stepphone_xpm);
  gdk_window_set_icon (applet->window, NULL, myicon, mask);
  gdk_window_set_icon_name(applet->window,"The Log");

  mvb=gtk_vbox_new(FALSE,0);
  gtk_container_add(GTK_CONTAINER(applet),mvb);

  dhb=gtk_hbox_new(FALSE,0);
  gtk_box_pack_start(GTK_BOX(mvb),dhb,FALSE,TRUE,0);

  /* data */
  dhw[0]=gtk_label_new("Show summary for:");
  gtk_box_pack_start(GTK_BOX(dhb),dhw[0],FALSE,FALSE,4);

  dhw[1]=gtk_option_menu_new();
  gtk_box_pack_start(GTK_BOX(dhb),dhw[1],FALSE,FALSE,2);

  dhw[2]=gtk_menu_new();

  for(i=0;i<10;i++) {
    dhw[3]=gtk_menu_item_new_with_label(resumeo[i]);
    gtk_signal_connect(GTK_OBJECT(dhw[3]),"activate",
		       GTK_SIGNAL_FUNC(time_menu),&nsrc[i]);
    gtk_menu_append(GTK_MENU(dhw[2]),dhw[3]);
    gtk_widget_show(dhw[3]);
  }

  gtk_option_menu_set_menu(GTK_OPTION_MENU(dhw[1]),dhw[2]);

  dhw[12]=gtk_label_new("include entries from");
  gtk_box_pack_start(GTK_BOX(dhb),dhw[12],FALSE,FALSE,4);
  dhw[13]=gtk_option_menu_new();
  gtk_box_pack_start(GTK_BOX(dhb),dhw[13],FALSE,FALSE,2);

  dhw[14]=gtk_menu_new();

  for(i=0,pt=isps;pt!=NULL;pt=g_list_next(pt),i++) {
    dhw[3]=gtk_menu_item_new_with_label((char *)(pt->data));
    gtk_signal_connect(GTK_OBJECT(dhw[3]),"activate",
		       GTK_SIGNAL_FUNC(isp_menu),&nsrc[i]);
    gtk_menu_append(GTK_MENU(dhw[14]),dhw[3]);
    gtk_widget_show(dhw[3]);
  }

  gtk_option_menu_set_menu(GTK_OPTION_MENU(dhw[13]),dhw[14]);


  dhw[15]=gtk_label_new("include connections as");
  gtk_box_pack_start(GTK_BOX(dhb),dhw[15],FALSE,FALSE,4);
  dhw[16]=gtk_option_menu_new();
  gtk_box_pack_start(GTK_BOX(dhb),dhw[16],FALSE,FALSE,2);

  dhw[17]=gtk_menu_new();

  for(i=0,pt=users;pt!=NULL;pt=g_list_next(pt),i++) {
    dhw[3]=gtk_menu_item_new_with_label((char *)(pt->data));
    gtk_signal_connect(GTK_OBJECT(dhw[3]),"activate",
		       GTK_SIGNAL_FUNC(user_menu),&nsrc[i]);
    gtk_menu_append(GTK_MENU(dhw[17]),dhw[3]);
    gtk_widget_show(dhw[3]);
  }

  gtk_option_menu_set_menu(GTK_OPTION_MENU(dhw[16]),dhw[17]);

  dhw[5]=gtk_hseparator_new();
  gtk_box_pack_start(GTK_BOX(mvb),dhw[5],FALSE,FALSE,3);

  dhw[3]=gtk_hbox_new(FALSE,4);
  gtk_box_pack_start(GTK_BOX(mvb),dhw[3],FALSE,TRUE,3);

  dhw[4]=lresume[0]=gtk_label_new("\n\n\n\n\n");
  dhw[6]=lresume[1]=gtk_label_new("\n\n\n\n\n");

  for(i=0;i<2;i++)
    gtk_label_set_justify(GTK_LABEL(lresume[i]),GTK_JUSTIFY_LEFT);

  gtk_box_pack_start(GTK_BOX(dhw[3]),dhw[4],FALSE,TRUE,4);
  gtk_box_pack_start(GTK_BOX(dhw[3]),dhw[6],FALSE,TRUE,4);

  hgraph=dhw[7]=gtk_drawing_area_new();
  gtk_drawing_area_size(GTK_DRAWING_AREA(dhw[7]),24*9+2,120);
  gtk_widget_set_events(dhw[7],GDK_EXPOSURE_MASK);

  gtk_box_pack_start(GTK_BOX(dhw[3]),dhw[7],FALSE,FALSE,4);

  wgraph=dhw[8]=gtk_drawing_area_new();
  gtk_drawing_area_size(GTK_DRAWING_AREA(dhw[8]),7*20+2,120);
  gtk_widget_set_events(dhw[8],GDK_EXPOSURE_MASK);

  gtk_box_pack_start(GTK_BOX(dhw[3]),dhw[8],FALSE,FALSE,4);

  dhw[11]=gtk_hseparator_new();
  gtk_box_pack_start(GTK_BOX(mvb),dhw[11],FALSE,FALSE,4);

  dhw[9]=gtk_hbox_new(FALSE,2);
  dhw[10]=gtk_label_new("Raw log listing (unfiltered):");

  gtk_box_pack_start(GTK_BOX(mvb),dhw[9],FALSE,FALSE,4);
  gtk_box_pack_start(GTK_BOX(dhw[9]),dhw[10],FALSE,FALSE,2);

  /* list */

  sw=gtk_scrolled_window_new(NULL,NULL);
  gtk_box_pack_start(GTK_BOX(mvb),sw,TRUE,TRUE,4);
  gtk_widget_show(sw);
  gtk_container_set_border_width(GTK_CONTAINER(sw),0);

  loglist=gtk_clist_new(8);
  gtk_clist_set_shadow_type(GTK_CLIST(loglist),GTK_SHADOW_IN);
  gtk_clist_set_selection_mode(GTK_CLIST(loglist),GTK_SELECTION_SINGLE);
  for(i=0;i<8;i++) {
    gtk_clist_set_column_title(GTK_CLIST(loglist),i,titles[i]);
    gtk_clist_set_column_width(GTK_CLIST(loglist),i,colsize[i]);
  }
  gtk_clist_column_titles_passive(GTK_CLIST(loglist));
  gtk_clist_column_titles_show(GTK_CLIST(loglist));
  gtk_clist_set_row_height(GTK_CLIST(loglist),16);
  gtk_clist_set_column_auto_resize(GTK_CLIST(loglist),1,FALSE);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
				 GTK_POLICY_AUTOMATIC,
				 GTK_POLICY_ALWAYS);
  gtk_container_add(GTK_CONTAINER(sw),loglist);
  gtk_widget_show(loglist);

  /* bottom */

  dhw[18]=gtk_hseparator_new();
  gtk_box_pack_start(GTK_BOX(mvb),dhw[18],FALSE,FALSE,4);

  dhw[19]=gtk_table_new(1,6,TRUE);
  dhw[21]=gtk_button_new_with_label(" About... ");
  dhw[22]=gtk_button_new_with_label(" Close ");

  dhw[23]=gtk_hbox_new(TRUE,6);

  gtk_box_pack_start(GTK_BOX(mvb),dhw[19],FALSE,FALSE,4);

  gtk_table_attach_defaults(GTK_TABLE(dhw[19]),dhw[23],4,6,0,1);

  gtk_box_pack_start(GTK_BOX(dhw[23]),dhw[21],FALSE,TRUE,4);
  gtk_box_pack_start(GTK_BOX(dhw[23]),dhw[22],FALSE,TRUE,4);

  for(i=0;i<24;i++)
    if (i!=20)
      gtk_widget_show(dhw[i]);
  gtk_widget_show(dhb);
  gtk_widget_show(mvb);

  iconmap[0] = gdk_pixmap_create_from_xpm_d (applet->window, &maskmap[0],
					     &style->bg[GTK_STATE_NORMAL],
					     (gchar **) status_ok_xpm);
  iconmap[1] = gdk_pixmap_create_from_xpm_d (applet->window, &maskmap[1],
					     &style->bg[GTK_STATE_NORMAL],
					     (gchar **) status_error_xpm);
  iconmap[2] = gdk_pixmap_create_from_xpm_d (applet->window, &maskmap[2],
					     &style->bg[GTK_STATE_NORMAL],
					     (gchar **) status_crash_xpm);

  /* signal plumbing */
  gtk_signal_connect (GTK_OBJECT (applet), "delete_event",
		      GTK_SIGNAL_FUNC (applet_kill), NULL);
  gtk_signal_connect (GTK_OBJECT (applet), "destroy",
		      GTK_SIGNAL_FUNC (applet_destroy), NULL);
  gtk_signal_connect (GTK_OBJECT (hgraph), "expose_event",
		      GTK_SIGNAL_FUNC (hgra_expose), NULL);
  gtk_signal_connect (GTK_OBJECT (hgraph), "configure_event",
		      GTK_SIGNAL_FUNC (hgra_configure), NULL);
  gtk_signal_connect (GTK_OBJECT (wgraph), "expose_event",
		      GTK_SIGNAL_FUNC (wgra_expose), NULL);
  gtk_signal_connect (GTK_OBJECT (wgraph), "configure_event",
		      GTK_SIGNAL_FUNC (wgra_configure), NULL);

  gtk_signal_connect (GTK_OBJECT (dhw[21]), "clicked",
		      GTK_SIGNAL_FUNC (applet_about),
		      (gpointer)GTK_WINDOW(applet));
  gtk_signal_connect (GTK_OBJECT (dhw[22]), "clicked",
		      GTK_SIGNAL_FUNC (applet_destroy), NULL);
}
Ejemplo n.º 18
0
/*
** Create the window.
*/
static void create_changelog_window ()
{
  /*GtkTooltips *tooltips;*/
  GtkWidget *hbox, *textarea, *vscrollbar, *button;
  GtkWidget *vbox, *textview, *swindow, *ok_button;    // PV: +
  GtkTextBuffer *txbuf;                                // PV: +
  int txlen;                                           // PV: +
  GtkStyle *style;
  char msg[100];

  changelog_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_wmclass ( GTK_WINDOW ( changelog_window ), "GTimer", "gtimer" );
  sprintf ( msg, "GTimer: %s", gettext ("Change Log") );
  gtk_window_set_title (GTK_WINDOW (changelog_window), msg );
  gtk_window_set_position ( GTK_WINDOW(changelog_window), GTK_WIN_POS_MOUSE );
//  gtk_widget_realize ( changelog_window );
  gdk_window_set_icon ( GTK_WIDGET ( changelog_window )->window,
    NULL, appicon2, appicon2_mask );

  vbox = gtk_vbox_new ( FALSE, 2 );
  gtk_container_add ( GTK_CONTAINER (changelog_window), vbox);

  hbox = gtk_hbox_new ( FALSE, 2 );
  gtk_box_pack_start ( GTK_BOX ( vbox ), hbox, FALSE, FALSE, 2 );

  swindow = gtk_scrolled_window_new(NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(swindow),
                                  GTK_POLICY_AUTOMATIC,
                                  GTK_POLICY_AUTOMATIC);
  gtk_box_pack_start ( GTK_BOX(vbox), swindow, TRUE, TRUE, 0);

//  style = gtk_style_new ();
// PV: -
/*
  gdk_font_unref ( style->font );
  style->font = gdk_font_load (
    "-adobe-courier-medium-r-*-*-12-*-*-*-*-*-*-*" );
  if ( style->font == NULL )
    style->font = gdk_font_load ( "fixed" );
*/
//  gtk_widget_push_style ( style );

  txbuf = gtk_text_buffer_new(NULL);
  txlen = strlen(changelog_text);
  gtk_text_buffer_set_text (GTK_TEXT_BUFFER(txbuf), changelog_text, txlen);
  textview = gtk_text_view_new_with_buffer(txbuf);
  gtk_text_view_set_editable(GTK_TEXT_VIEW(textview),0);                   
  gtk_container_add (GTK_CONTAINER (swindow), textview);
  ok_button = gtk_button_new_with_label(gettext("Ok"));
  gtk_box_pack_start(GTK_BOX(vbox), ok_button, FALSE, FALSE, 0);
  g_signal_connect(G_OBJECT(ok_button), "clicked",
                   G_CALLBACK (changelog_ok_callback), NULL);
  g_signal_connect(G_OBJECT(changelog_window), "delete-event",
                   G_CALLBACK (changelog_X_callback), NULL);


//  gtk_widget_show (button);
  gtk_window_set_default_size ( changelog_window, 600, 600 );
  /*gdk_window_resize ( GTK_WIDGET ( changelog_window )->window, 600, 400 );*/
  gtk_widget_show (changelog_window);
  gtk_widget_show_all(changelog_window);

  GTK_WIDGET_SET_FLAGS (ok_button, GTK_CAN_DEFAULT);
  gtk_widget_grab_default (ok_button);

}
Ejemplo n.º 19
0
void
view_file (char *filename, int fd, unsigned int viewedit, unsigned int del_file,
           unsigned int start_pos, unsigned int dontupload,
           char *remote_filename, gftp_window_data * wdata)
{
  GtkWidget * dialog, * view, * table, * tempwid;
  char buf[8192], *view_program, *edit_program;
  gftp_config_list_vars * tmplistvar;
  gftp_file_extensions * tempext;
  gftp_viewedit_data * newproc;
  GtkAdjustment * vadj;
  GList * templist;
  size_t stlen;
  int doclose;
  ssize_t n;
  char * non_utf8;
  GtkTextBuffer * textbuf;
  GtkTextIter iter;

  doclose = 1;
  stlen = strlen (filename);
  gftp_lookup_global_option ("ext", &tmplistvar);
  for (templist = tmplistvar->list; templist != NULL; templist = templist->next)
    {
      tempext = templist->data;
      if (stlen >= tempext->stlen &&
          strcmp (&filename[stlen - tempext->stlen], tempext->ext) == 0)
        {
          if (*tempext->view_program == '\0')
            break;
          ftp_log (gftp_logging_misc, NULL, _("Opening %s with %s\n"),
                   filename, tempext->view_program);
          fork_process (tempext->view_program, filename, fd, remote_filename,
                        viewedit, del_file, dontupload, wdata);
          return;
        }
    }

  if (wdata != NULL)
    {
      gftp_lookup_request_option (wdata->request, "view_program", &view_program);
      gftp_lookup_request_option (wdata->request, "edit_program", &edit_program);
      if ((non_utf8 = gftp_filename_from_utf8 (wdata->request, filename, NULL)) == NULL) /* freeme later! */
        non_utf8 = filename;
    }
  else
    {
      gftp_lookup_global_option ("view_program", &view_program);
      gftp_lookup_global_option ("edit_program", &edit_program);
      non_utf8 = filename;
    }

  if (viewedit && *view_program != '\0')
    {
      /* Open the file with the default file viewer */
      fork_process (view_program, filename, fd, remote_filename, viewedit,
                    del_file, dontupload, wdata);
      if (non_utf8 != filename && non_utf8)
        g_free (non_utf8);
      return;
    }
  else if (!viewedit && *edit_program != '\0')
    {
      /* Open the file with the default file editor */
      newproc = fork_process (edit_program, filename, fd, remote_filename, 
                              viewedit, del_file, dontupload, wdata);
      stat (non_utf8, &newproc->st);
      if (non_utf8 != filename && non_utf8)
        g_free (non_utf8);
      return;
    }

  ftp_log (gftp_logging_misc, NULL, _("Viewing file %s\n"), filename);

  if (fd == 0)
    {
      if ((fd = open (non_utf8, O_RDONLY)) < 0)
        {
          ftp_log (gftp_logging_error, NULL, 
                   _("View: Cannot open file %s: %s\n"), non_utf8, 
                   g_strerror (errno));
          if (non_utf8 != filename && non_utf8)
            g_free (non_utf8);
          return;
        }
      doclose = 1;
    }
  else
    {
      lseek (fd, 0, SEEK_SET);
      doclose = 0;
    }

  if (del_file)
    {
      if (unlink (non_utf8) == 0)
        ftp_log (gftp_logging_misc, NULL, _("Successfully removed %s\n"), 
                 filename);
      else
        ftp_log (gftp_logging_error, NULL,
                 _("Error: Could not remove file %s: %s\n"), filename, 
                 g_strerror (errno));
    }

  if (non_utf8 != filename && non_utf8)
    g_free (non_utf8);

  dialog = gtk_dialog_new_with_buttons (filename, NULL, 0,
                                        GTK_STOCK_CLOSE,
                                        GTK_RESPONSE_CLOSE,
                                        NULL);

  gtk_window_set_wmclass (GTK_WINDOW(dialog), "fileview", "gFTP");
  gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 5);
  gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 5);
  gtk_widget_realize (dialog);

  if (gftp_icon != NULL)
    {
      gdk_window_set_icon (dialog->window, NULL, gftp_icon->pixmap,
                           gftp_icon->bitmap);
      gdk_window_set_icon_name (dialog->window, gftp_version);
    }

  table = gtk_table_new (1, 2, FALSE);
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), table, TRUE, TRUE, 0);

  view = gtk_text_view_new ();
  gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
  gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
  gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD);

  tempwid = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tempwid),
                                 GTK_POLICY_AUTOMATIC,
                                 GTK_POLICY_AUTOMATIC);

  gtk_container_add (GTK_CONTAINER (tempwid), view);
  gtk_widget_show (view);

  gtk_table_attach (GTK_TABLE (table), tempwid, 0, 1, 0, 1,
		    GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK,
		    0, 0);
  gtk_widget_show (tempwid);

  vadj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (tempwid));
  gtk_widget_set_size_request (table, 500, 400);
  gtk_widget_show (table);

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

  buf[sizeof (buf) - 1] = '\0';
  while ((n = read (fd, buf, sizeof (buf) - 1)) > 0)
    {
      buf[n] = '\0';
      textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
      gtk_text_buffer_get_iter_at_offset (textbuf, &iter, -1);
      gtk_text_buffer_insert (textbuf, &iter, buf, -1);
    }

  if (doclose)
    close (fd);

  gtk_widget_show (dialog);

  if (!start_pos)
    gtk_adjustment_set_value (vadj, vadj->upper);
}