Ejemplo n.º 1
0
/* - Check for valid screen sizes ------------------------------------------- */
void fillScreens() {
	gint width, height;

	width = gdk_screen_width();
	height = gdk_screen_height();

	if(checkScreen("640x480", width, height))
		screensize = g_list_append(screensize, "640x480");
	if(checkScreen("800x600", width, height))
		screensize = g_list_append(screensize, "800x600");
	if(checkScreen("1024x768", width, height))
		screensize = g_list_append(screensize, "1024x768");
	if(checkScreen("1270x940", width, height))
		screensize = g_list_append(screensize, "1270x940");
	if(checkScreen("1280x1024", width, height))
		screensize = g_list_append(screensize, "1280x1024");
	if(checkScreen("1600x1280", width, height))
		screensize = g_list_append(screensize, "1600x1280");

	screensize = g_list_append(screensize, _("Fullscreen"));
}
Ejemplo n.º 2
0
/* Drill the window in the area where the ardesia bar is located. */
void 
drill_window_in_bar_area     (GtkWidget *widget)
{
  GtkWidget *bar= get_bar_window ();
  gint x, y, width, height;

  gtk_window_get_position (GTK_WINDOW (bar), &x, &y);
  gtk_window_get_size (GTK_WINDOW (bar), &width, &height);

  const cairo_rectangle_int_t widget_rect = { x+1, y+1, width-1, height-1 };               
  cairo_region_t *widget_reg = cairo_region_create_rectangle (&widget_rect);
                                  
  const cairo_rectangle_int_t ann_rect = { 0, 0, gdk_screen_width (), gdk_screen_height () };                        
  cairo_region_t *ann_reg = cairo_region_create_rectangle (&ann_rect);                              
                                  
  cairo_region_subtract (ann_reg, widget_reg);
                                                                                        
  gtk_widget_input_shape_combine_region (widget, ann_reg);
  cairo_region_destroy (ann_reg);
  cairo_region_destroy (widget_reg);
}
Ejemplo n.º 3
0
static void popup_position_func(GtkMenu* menu, gint* x, gint* y, gboolean* push_in, gpointer user_data)
{
	GtkRequisition req;
	GdkPoint* pos;

	pos = user_data;

	gtk_widget_size_request(GTK_WIDGET(menu), &req);

	*x = pos->x;
	*y = pos->y;

	if (meta_ui_get_direction() == META_UI_DIRECTION_RTL)
	{
		*x = MAX (0, *x - req.width);
	}

	/* Ensure onscreen */
	*x = CLAMP (*x, 0, MAX(0, gdk_screen_width() - req.width));
	*y = CLAMP (*y, 0, MAX(0, gdk_screen_height() - req.height));
}
Ejemplo n.º 4
0
/* Add the savepoint element. */
static void
add_savepoint (gint index)
{
  gint width = gdk_screen_width ();
  gint height = gdk_screen_height ();
  gchar *id = g_strdup_printf ("id%d", index +1);
  gchar *file = g_strdup_printf ("images/%s_%d_vellum.png", PACKAGE_NAME, index);

  open_svg ();

  fprintf (fp,
           "\t\t<svg:image id=\"%s\" xlink:href=\"%s\" x=\"0\" y=\"0\" width=\"%d\" height=\"%d\"/>\n",
           id,
           file,
           width,
           height);

  g_free (file);
  file = NULL;
  g_free (id);
  close_svg ();
}
Ejemplo n.º 5
0
// initiate get name window
int initializeGetNameWindow(GtkWidget **window) {
    // initialize window
    *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

    // set title
    char buf[50];
    sprintf(buf, "megasenha - type your name");
    gtk_window_set_title(GTK_WINDOW(*window), buf);

    // set size and position and connects close window with destroy function
    gtk_window_set_default_size(GTK_WINDOW(*window), 397, 107);
    gtk_container_set_border_width (GTK_CONTAINER (*window), 10);
    gtk_window_move(GTK_WINDOW(*window), gdk_screen_width()/2 - 397/2, gdk_screen_height()*9/20);
//    gtk_signal_connect (GTK_OBJECT(*window), "destroy", GTK_SIGNAL_FUNC (destroy), (gpointer) "1");

    // sets and creates icons for windows and tell windows manager not to put them together
    gtk_window_set_icon(GTK_WINDOW(*window), createPixbuf("info.jpg"));
    gtk_window_set_wmclass(GTK_WINDOW (*window), "infoWindow", "megasenha"); 

    gtk_widget_show_all(*window);

    return 1;
}
static void xhairs_length_add_marks (GtkScale *scale)
{
    gint length, quarter_length;
    GtkAdjustment *scale_model;

    /* Get maximum dimension of screen */
    length = MAX(gdk_screen_width(), gdk_screen_height());
    scale_model = gtk_range_get_adjustment (GTK_RANGE (scale));
    if (length < gtk_adjustment_get_upper(scale_model))
      {
        gtk_adjustment_set_upper (scale_model, length);
      }

    /* The crosshair is made up of four lines in pairs (top, bottom) and
       (left, right).  Stipulating: "quarter of the screen" means that the
       length of one hair is 25% of the screen. */
    quarter_length = length / 4;

    gtk_scale_add_mark (scale, 0, GTK_POS_BOTTOM, C_("Distance", "Short"));
    gtk_scale_add_mark (scale, quarter_length, GTK_POS_BOTTOM, C_("Distance", "¼ Screen"));
    gtk_scale_add_mark (scale, quarter_length * 2 , GTK_POS_BOTTOM, C_("Distance", "½ Screen"));
    gtk_scale_add_mark (scale, quarter_length * 3, GTK_POS_BOTTOM, C_("Distance", "¾ Screen"));
    gtk_scale_add_mark (scale, length, GTK_POS_BOTTOM, C_("Distance", "Long"));
}
Ejemplo n.º 7
0
static gboolean focus_in_handler(	GtkWidget *widget,
					GtkDirectionType direction,
					gpointer data )
{
	MainWindow *wnd = data;

	if(wnd->fullscreen)
	{
		gint width;
		gint height;

		gtk_window_get_size(	GTK_WINDOW(wnd->fs_control),
					&width,
					&height );

		gtk_window_move(	GTK_WINDOW(wnd->fs_control),
					(gdk_screen_width()/2)-(width/2),
					gdk_screen_height()-height );

		gtk_widget_show_all(wnd->fs_control);
	}

	return TRUE;
}
Ejemplo n.º 8
0
Archivo: pager.c Proyecto: g7/fbpanel
/* Upon realize and every resize creates a new backing pixmap of the appropriate size */
static gint
desk_configure_event (GtkWidget *widget, GdkEventConfigure *event, desk *d)
{
    int w, h;

    ENTER;
    w = widget->allocation.width;
    h = widget->allocation.height;

    DBG("d->no=%d %dx%d %dx%d\n", d->no, w, h, d->pg->daw, d->pg->dah);
    if (d->pix)
        g_object_unref(d->pix);
    if (d->gpix)
        g_object_unref(d->gpix);
    d->pix = gdk_pixmap_new(widget->window, w, h, -1);
    if (d->pg->wallpaper) {
        d->gpix = gdk_pixmap_new(widget->window, w, h, -1);
        desk_draw_bg(d->pg, d);
    }
    d->scalew = (gfloat)h / (gfloat)gdk_screen_height();
    d->scaleh = (gfloat)w / (gfloat)gdk_screen_width();
    desk_set_dirty(d);
    RET(FALSE);
}
Ejemplo n.º 9
0
//Gtk_widget initialization
void gtk_initialize()
{
	int i;
	window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_widget_set_size_request(window,200,75);
	gtk_window_set_opacity(GTK_WINDOW(window),.5);
	//gtk_window_set_modal(GTK_WINDOW(window),FALSE);	
	//gtk_window_set_keep_below(GTK_WINDOW(window),TRUE);
	gtk_window_set_decorated(GTK_WINDOW(window),FALSE);
	gtk_window_set_resizable(GTK_WINDOW(window),FALSE);
	gtk_window_set_skip_taskbar_hint(GTK_WINDOW(window),TRUE);
	gtk_window_stick(GTK_WINDOW(window));
	bg=gtk_image_new_from_file("./images/danger.png");
	power=gtk_image_new();
	gtk_window_move(GTK_WINDOW(window),gdk_screen_width()-200,gdk_screen_height()-200);
	vbox=gtk_vbox_new(0,0);
	layout=gtk_layout_new(NULL,NULL);
	for(i=0;i<2;i++)
	{
		label[i]=gtk_label_new("Initializing..");
	}
	close_event=gtk_event_box_new();
	close_img=gtk_image_new_from_file("./images/close.png");
}
Ejemplo n.º 10
0
void
nsCairoScreen::Init ()
{
#ifdef MOZ_ENABLE_GTK2
    mAvailRect = mRect = nsRect(0, 0, gdk_screen_width(), gdk_screen_height());
    // We need to account for the taskbar, etc in the available rect.
    // See http://freedesktop.org/Standards/wm-spec/index.html#id2767771

    // XXX It doesn't change that often, but we should probably
    // listen for changes to _NET_WORKAREA.
    // XXX do we care about _NET_WM_STRUT_PARTIAL?  That will
    // add much more complexity to the code here (our screen
    // could have a non-rectangular shape), but should
    // lead to greater accuracy.

#if GTK_CHECK_VERSION(2,2,0)
    GdkWindow *root_window = gdk_get_default_root_window();
#else
    GdkWindow *root_window = GDK_ROOT_PARENT();
#endif // GTK_CHECK_VERSION(2,2,0)

    long *workareas;
    GdkAtom type_returned;
    int format_returned;
    int length_returned;

#if GTK_CHECK_VERSION(2,0,0)
    GdkAtom cardinal_atom = gdk_x11_xatom_to_atom(XA_CARDINAL);
#else
    GdkAtom cardinal_atom = (GdkAtom) XA_CARDINAL;
#endif

    gdk_error_trap_push();

    // gdk_property_get uses (length + 3) / 4, hence G_MAXLONG - 3 here.
    if (!gdk_property_get(root_window,
                          gdk_atom_intern ("_NET_WORKAREA", FALSE),
                          cardinal_atom,
                          0, G_MAXLONG - 3, FALSE,
                          &type_returned,
                          &format_returned,
                          &length_returned,
                          (guchar **) &workareas)) {
        // This window manager doesn't support the freedesktop standard.
        // Nothing we can do about it, so assume full screen size.
        return;
    }

    // Flush the X queue to catch errors now.
    gdk_flush();

    if (!gdk_error_trap_pop() &&
        type_returned == cardinal_atom &&
        length_returned && (length_returned % 4) == 0 &&
        format_returned == 32) {
        int num_items = length_returned / sizeof(long);

        for (int i = 0; i < num_items; i += 4) {
            nsRect workarea(workareas[i],     workareas[i + 1],
                            workareas[i + 2], workareas[i + 3]);
            if (!mRect.Contains(workarea)) {
                NS_WARNING("Invalid bounds");
                continue;
            }

            mAvailRect.IntersectRect(mAvailRect, workarea);
        }
    }

#elif MOZ_ENABLE_XLIB
    mScreenNum = 0;
    mRect.x = mAvailRect.x = 0;
    mRect.y = mAvailRect.y = 0;
    mRect.width = mAvailRect.width = 1600;
    mRect.height = mAvailRect.height = 1200;
#endif
}
/* Create the background window. */
GtkWidget *
create_background_window     ()
{
  GError *error = (GError *) NULL;
  GObject *background_obj = (GObject *) NULL;

  background_data = allocate_background_data ();

  /* Initialize the background window. */
  background_data->background_window_gtk_builder = gtk_builder_new ();

  /* Load the gtk builder file created with glade. */
  gtk_builder_add_from_file (background_data->background_window_gtk_builder, BACKGROUND_UI_FILE, &error);

  if (error)
    {
      g_warning ("Failed to load builder file: %s", error->message);
      g_error_free (error);
      return background_data->background_window;
    }

  background_obj = gtk_builder_get_object (background_data->background_window_gtk_builder, "backgroundWindow");
  background_data->background_window = GTK_WIDGET (background_obj);
  gtk_window_set_keep_above (GTK_WINDOW (background_data->background_window), TRUE);

  /* This trys to set an alpha channel. */
  on_back_screen_changed (background_data->background_window, NULL, background_data);
  
  /* In the gtk 2.16.6 used for windows the gtkbuilder the double buffered property
   * is not parsed from glade and then I set this by hands. 
   */
  gtk_widget_set_double_buffered (background_data->background_window, FALSE);

  gtk_window_set_opacity (GTK_WINDOW (background_data->background_window), BACKGROUND_OPACITY);
  
  gtk_widget_set_size_request (background_data->background_window, gdk_screen_width (), gdk_screen_height ());

  /* Connect all the callback from gtkbuilder xml file. */
  gtk_builder_connect_signals (background_data->background_window_gtk_builder, (gpointer) background_data);
    
  //gtk_widget_show_all (background_data->background_window);

  /* This put in full screen; this will generate an exposure. */
  gtk_window_fullscreen (GTK_WINDOW (background_data->background_window));
  
  return  background_data->background_window;
}
Ejemplo n.º 12
0
static VALUE
gdk_s_screen_height(VALUE self)
{
    return INT2NUM(gdk_screen_height());
}
Ejemplo n.º 13
0
// Returns the height of the screen in pixels.
int
clip_GDK_SCREENHEIGHT(ClipMachine * ClipMachineMemory)
{
   _clip_retni(ClipMachineMemory, gdk_screen_height());
   return 0;
}
Ejemplo n.º 14
0
/**
 * gwy_app_recent_file_list_new:
 *
 * Creates document history browser.
 *
 * There should be at most one document history browser, so this function
 * fails if it already exists.
 *
 * Returns: The newly created document history browser window.
 **/
GtkWidget*
gwy_app_recent_file_list_new(void)
{
    GtkWidget *vbox, *filterbox, *buttonbox, *list, *scroll, *button;
    GtkTreeModelFilter *filter;
    GtkTreeSelection *selection;

    g_return_val_if_fail(gcontrols.store, gcontrols.window);
    g_return_val_if_fail(gcontrols.window == NULL, gcontrols.window);

    gcontrols.filter
        = gtk_tree_model_filter_new(GTK_TREE_MODEL(gcontrols.store),
                                    NULL);
    filter = GTK_TREE_MODEL_FILTER(gcontrols.filter);
    gtk_tree_model_filter_set_visible_func(filter,
                                           gwy_app_recent_file_list_filter,
                                           &gcontrols, NULL);

    gcontrols.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(gcontrols.window), _("Document History"));
    gtk_window_set_default_size(GTK_WINDOW(gcontrols.window), 400,
                                3*gdk_screen_height()/4);
    gwy_app_restore_window_position(GTK_WINDOW(gcontrols.window),
                                    "/app/document-history", FALSE);
    gwy_help_add_to_window(GTK_WINDOW(gcontrols.window),
                           "managing-files", "document-history",
                           GWY_HELP_DEFAULT);
    g_signal_connect(gcontrols.window, "unmap",
                     G_CALLBACK(gwy_app_recent_file_list_unmapped), NULL);

    vbox = gtk_vbox_new(FALSE, 0);
    gtk_container_add(GTK_CONTAINER(gcontrols.window), vbox);

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

    list = gwy_app_recent_file_list_construct(&gcontrols);
    gtk_container_add(GTK_CONTAINER(scroll), list);
    g_object_unref(gcontrols.filter);

    filterbox = gwy_app_recent_file_list_filter_construct(&gcontrols);
    gtk_box_pack_start(GTK_BOX(vbox), filterbox, FALSE, FALSE, 0);

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

    gcontrols.prune = gwy_stock_like_button_new(_("_Prune"),
                                                GTK_STOCK_FIND);
    gtk_box_pack_start(GTK_BOX(buttonbox), gcontrols.prune, TRUE, TRUE, 0);
    gtk_tooltips_set_tip(gwy_app_get_tooltips(), gcontrols.prune,
                         _("Remove entries of files that no longer exist"),
                         NULL);
    g_signal_connect_swapped(gcontrols.prune, "clicked",
                             G_CALLBACK(gwy_app_recent_file_list_prune),
                             &gcontrols);

    button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
    gtk_box_pack_start(GTK_BOX(buttonbox), button, TRUE, TRUE, 0);
    gtk_tooltips_set_tip(gwy_app_get_tooltips(), button,
                         _("Close file list"), NULL);
    g_signal_connect_swapped(button, "clicked",
                             G_CALLBACK(gtk_widget_destroy), gcontrols.window);

    gcontrols.open = gtk_button_new_from_stock(GTK_STOCK_OPEN);
    gtk_box_pack_start(GTK_BOX(buttonbox), gcontrols.open, TRUE, TRUE, 0);
    gtk_tooltips_set_tip(gwy_app_get_tooltips(), gcontrols.open,
                         _("Open selected file"), NULL);
    g_signal_connect_swapped(gcontrols.open, "clicked",
                             G_CALLBACK(gwy_app_recent_file_list_open), list);
    selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(list));
    gtk_widget_set_sensitive(gcontrols.open,
                             gtk_tree_selection_get_selected(selection,
                                                             NULL, NULL));

    g_signal_connect_swapped(gcontrols.window, "destroy",
                             G_CALLBACK(gwy_app_recent_file_list_destroyed),
                             &gcontrols);

    gwy_app_recent_file_list_filter_apply(GTK_ENTRY(gcontrols.filter_glob),
                                          &gcontrols);
    gtk_widget_show_all(vbox);

    return gcontrols.window;
}
Ejemplo n.º 15
0
static void blursk_init(void)
{
#if 0	
	if (blursk_window)
		return;
#endif
#ifdef DUMPCORE
	signal(SIGSEGV, SIG_DFL);
#endif
	/* Get the configuration and create the image buffers */
	//config_read(NULL, NULL);
	//preset_read();
	config_default(&config);
	img_resize(config.width, config.height);

#if 0
	/* Create the window */
	blursk_window = gtk_window_new(config.window_title ? GTK_WINDOW_TOPLEVEL
							   : GTK_WINDOW_DIALOG);
	gtk_window_set_title(GTK_WINDOW(blursk_window), PACKAGE);
	gtk_window_set_policy(GTK_WINDOW(blursk_window), TRUE, TRUE, TRUE);
	gtk_signal_connect(GTK_OBJECT(blursk_window), "destroy",
		GTK_SIGNAL_FUNC(blursk_destroy_cb), NULL);
	gtk_signal_connect(GTK_OBJECT(blursk_window), "destroy", 
		GTK_SIGNAL_FUNC(gtk_widget_destroyed), &blursk_window);
	gtk_signal_connect(GTK_OBJECT(blursk_window), "configure_event", 
		GTK_SIGNAL_FUNC(resize_cb), NULL);

	/* Put a drawing area in the window */
	area = gtk_drawing_area_new();
	gtk_drawing_area_size(GTK_DRAWING_AREA(area), img_physwidth, img_physheight);
	gtk_container_add(GTK_CONTAINER(blursk_window),area);
	gtk_widget_show(area);

	/* Arrange for key & mouse events to be detected */
	gtk_signal_connect(GTK_OBJECT(blursk_window), "selection_received",
		GTK_SIGNAL_FUNC(selection_cb), NULL);
	gtk_signal_connect(GTK_OBJECT(blursk_window), "key_press_event",
		GTK_SIGNAL_FUNC(key_cb), NULL);
	gtk_signal_connect(GTK_OBJECT(blursk_window), "button_press_event",
		GTK_SIGNAL_FUNC(mousebutton_cb), NULL);
	gtk_signal_connect(GTK_OBJECT(blursk_window), "button_release_event",
		GTK_SIGNAL_FUNC(mousebutton_cb), NULL);
	gtk_signal_connect(GTK_OBJECT(blursk_window), "motion_notify_event",
		GTK_SIGNAL_FUNC(mousemove_cb), NULL);
	gtk_widget_set_events(blursk_window, GDK_KEY_PRESS_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON1_MOTION_MASK);

	/* Initialize the drawing area */
	gtk_widget_realize(area);
	bg_pixmap = gdk_pixmap_create_from_xpm_d(area->window,
		NULL, NULL, blursk_xmms_logo_xpm);
	gdk_window_set_back_pixmap(area->window, bg_pixmap, 0);
	

	/* Move the window to its usual place, if any.  If portions are beyond
	 * the edge of the screen, then move it to make everything visible.
	 */
	if (config.x != -1 || config.y != -1)
	{
		if (config.x < 0)
			config.x = 0;
		else if (config.x + img_physwidth >= gdk_screen_width())
			config.x = gdk_screen_width() - img_physwidth;
		if (config.y < 0)
			config.y = 0;
		else if (config.y + img_physheight >= gdk_screen_height())
			config.y = gdk_screen_height() - img_physheight;
		gtk_widget_realize(blursk_window);
		gtk_window_reposition(GTK_WINDOW(blursk_window), config.x, config.y);
	}

	/* Show it! */
	gtk_widget_show(blursk_window);

	/* Determine whether fullscreen operation is supported. */
	can_fullscreen = xmms_fullscreen_init(blursk_window);
#endif
	if( blursk_bitmap == NULL )
		blursk_bitmap = new os::Bitmap( config.width, config.height, os::CS_RGB32 );
	color_genmap(TRUE);
}
Ejemplo n.º 16
0
void WinMaxScrollWindowSize (int *mx, int *my)
{
    *mx = gdk_screen_width();
    *my = gdk_screen_height();
}
Ejemplo n.º 17
0
int 
main (int argc, char **argv)
{
  GtkWidget *panel,
  	    *panel2,
  	    *button,
	    *button2,
	    *button3,
	    *button4,
	    *window,
	    *window2,
	    *window_t,
	    *socket,
	    *sbold;

  Display    *display;
  Window      win;
  Atom	      atoms[3];
       	
  gtk_init (&argc,&argv);

  socket  = g_object_new (STATUSBAR_TYPE_ITEM_SOCKET,NULL);
  window  = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  window2 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  window_t  = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  panel   = g_object_new (DESKTOP_TYPE_PANEL,NULL); 
  panel2  = g_object_new (DESKTOP_TYPE_PANEL,"orientation",GTK_ORIENTATION_VERTICAL,NULL);

  gtk_window_set_type_hint( GTK_WINDOW(window),GDK_WINDOW_TYPE_HINT_DOCK);
  gtk_window_set_type_hint( GTK_WINDOW(window2),GDK_WINDOW_TYPE_HINT_DOCK);
  gtk_window_set_type_hint( GTK_WINDOW(window_t),GDK_WINDOW_TYPE_HINT_DESKTOP);
  
  gtk_widget_realize (GTK_WIDGET (window_t)); 

  gtk_widget_set_size_request (GTK_WIDGET (window_t), gdk_screen_width (), gdk_screen_height ());

  gtk_window_set_decorated (GTK_WINDOW (window),FALSE);

  gtk_widget_realize (window);
  gtk_widget_realize (window2);
  
  gtk_widget_set_size_request (GTK_WIDGET (panel),300,40);
  gtk_widget_set_size_request (GTK_WIDGET (panel2),80,gdk_screen_height ()); 
   
  button  = gtk_button_new_with_label("Testing");
  button2 = GTK_WIDGET (statusbar_item_wrapper_new ("load","/usr/lib/hildon-status-bar/libload.so",FALSE));
  button4 = GTK_WIDGET (hn_app_switcher_new ());
  button3 = GTK_WIDGET (tasknavigator_item_wrapper_new ("contacts","/usr/lib/hildon-navigator/libosso-contact-plugin.so"));
  sbold   = gtk_button_new_with_label("Testing 4");
 
  gtk_box_pack_start (GTK_BOX (panel),button,  FALSE,FALSE,0);
  gtk_box_pack_start (GTK_BOX (panel),socket,  FALSE,FALSE,0);
  gtk_box_pack_start (GTK_BOX (panel),button2, FALSE,FALSE,0);
  gtk_box_pack_start (GTK_BOX (panel),sbold, FALSE,FALSE,0);
  gtk_box_pack_start (GTK_BOX (panel2),button3, FALSE,FALSE,0);
  gtk_box_pack_start (GTK_BOX (panel2),button4, FALSE,FALSE,0);

  gtk_container_add (GTK_CONTAINER (window),panel);
  gtk_container_add (GTK_CONTAINER (window2),panel2);

  gtk_widget_realize (socket);

  printf ("%d\n",hildon_desktop_item_socket_get_id (HILDON_DESKTOP_ITEM_SOCKET(socket)));

  gtk_widget_show_all (window_t); 
  gtk_widget_show_all (window);
  gtk_widget_show_all (window2);

  gdk_window_move (GDK_WINDOW (window->window), 400, 0);
   
  gtk_main();

  return 0;
}
Ejemplo n.º 18
0
Archivo: pager.c Proyecto: g7/fbpanel
static void
desk_draw_bg(pager_priv *pg, desk *d1)
{
    Pixmap xpix;
    GdkPixmap *gpix;
    GdkPixbuf *p1, *p2;
    gint width, height, depth;
    FbBg *bg = pg->fbbg;
    GtkWidget *widget = d1->da;

    ENTER;
    if (d1->no) {
        desk *d0 = d1->pg->desks[0];
        if (d0->gpix && d0->xpix != None
              && d0->da->allocation.width == widget->allocation.width
              && d0->da->allocation.height == widget->allocation.height) {
            gdk_draw_drawable(d1->gpix,
                  widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
                  d0->gpix,0, 0, 0, 0,
                  widget->allocation.width,
                  widget->allocation.height);
            d1->xpix = d0->xpix;
            DBG("copy gpix from d0 to d%d\n", d1->no);
            RET();
        }
    }
    xpix = fb_bg_get_xrootpmap(bg);
    d1->xpix = None;
    width = widget->allocation.width;
    height = widget->allocation.height;
    DBG("w %d h %d\n", width, height);
    if (width < 3 || height < 3)
        RET();

    // create new pix
    xpix = fb_bg_get_xrootpmap(bg);
    if (xpix == None)
        RET();
    depth = gdk_drawable_get_depth(widget->window);
    gpix = fb_bg_get_xroot_pix_for_area(bg, 0, 0, gdk_screen_width(), gdk_screen_height(), depth);
    if (!gpix) {
        ERR("fb_bg_get_xroot_pix_for_area failed\n");
        RET();
    }
    p1 = gdk_pixbuf_get_from_drawable(NULL, gpix, NULL, 0, 0, 0, 0,
          gdk_screen_width(), gdk_screen_height());
    if (!p1) {
        ERR("gdk_pixbuf_get_from_drawable failed\n");
        goto err_gpix;
    }
    p2 = gdk_pixbuf_scale_simple(p1, width, height,
          //GDK_INTERP_NEAREST
          //GDK_INTERP_TILES
          //GDK_INTERP_BILINEAR
          GDK_INTERP_HYPER
        );
    if (!p2) {
        ERR("gdk_pixbuf_scale_simple failed\n");
        goto err_p1;
    }
    gdk_draw_pixbuf(d1->gpix, widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
          p2, 0, 0, 0, 0, width, height,  GDK_RGB_DITHER_NONE, 0, 0);

    d1->xpix = xpix;
    g_object_unref(p2);
 err_p1:
    g_object_unref(p1);
 err_gpix:
    g_object_unref(gpix);
    RET();
}
Ejemplo n.º 19
0
int wxSystemSettingsNative::GetMetric( wxSystemMetric index, wxWindow* win )
{
    GdkWindow *window = NULL;
    if (win)
        window = gtk_widget_get_window(win->GetHandle());

    switch (index)
    {
        case wxSYS_BORDER_X:
        case wxSYS_BORDER_Y:
        case wxSYS_EDGE_X:
        case wxSYS_EDGE_Y:
        case wxSYS_FRAMESIZE_X:
        case wxSYS_FRAMESIZE_Y:
            if (win)
            {
                wxTopLevelWindow *tlw = wxDynamicCast(win, wxTopLevelWindow);
                if (!tlw)
                    return GetBorderWidth(index, win);
                else if (window)
                {
                    // Get the frame extents from the windowmanager.
                    // In most cases the top extent is the titlebar, so we use the bottom extent
                    // for the heights.
                    int right, bottom;
                    if (wxGetFrameExtents(window, NULL, &right, NULL, &bottom))
                    {
                        switch (index)
                        {
                            case wxSYS_BORDER_X:
                            case wxSYS_EDGE_X:
                            case wxSYS_FRAMESIZE_X:
                                return right; // width of right extent
                            default:
                                return bottom; // height of bottom extent
                        }
                    }
                }
            }

            return -1; // no window specified

        case wxSYS_CURSOR_X:
        case wxSYS_CURSOR_Y:
                return gdk_display_get_default_cursor_size(
                            window ? gdk_window_get_display(window)
                                   : gdk_display_get_default());

        case wxSYS_DCLICK_X:
        case wxSYS_DCLICK_Y:
            gint dclick_distance;
            g_object_get(GetSettingsForWindowScreen(window),
                            "gtk-double-click-distance", &dclick_distance, NULL);

            return dclick_distance * 2;

        case wxSYS_DCLICK_MSEC:
            gint dclick;
            g_object_get(GetSettingsForWindowScreen(window),
                            "gtk-double-click-time", &dclick, NULL);
            return dclick;

        case wxSYS_DRAG_X:
        case wxSYS_DRAG_Y:
            gint drag_threshold;
            g_object_get(GetSettingsForWindowScreen(window),
                            "gtk-dnd-drag-threshold", &drag_threshold, NULL);

            // The correct thing here would be to double the value
            // since that is what the API wants. But the values
            // are much bigger under GNOME than under Windows and
            // just seem to much in many cases to be useful.
            // drag_threshold *= 2;

            return drag_threshold;

        case wxSYS_ICON_X:
        case wxSYS_ICON_Y:
            return 32;

        case wxSYS_SCREEN_X:
            if (window)
                return gdk_screen_get_width(gdk_window_get_screen(window));
            else
                return gdk_screen_width();

        case wxSYS_SCREEN_Y:
            if (window)
                return gdk_screen_get_height(gdk_window_get_screen(window));
            else
                return gdk_screen_height();

        case wxSYS_HSCROLL_Y:
        case wxSYS_VSCROLL_X:
            return 15;

        case wxSYS_CAPTION_Y:
            if (!window)
                // No realized window specified, and no implementation for that case yet.
                return -1;

            wxASSERT_MSG( wxDynamicCast(win, wxTopLevelWindow),
                          wxT("Asking for caption height of a non toplevel window") );

            // Get the height of the top windowmanager border.
            // This is the titlebar in most cases. The titlebar might be elsewhere, and
            // we could check which is the thickest wm border to decide on which side the
            // titlebar is, but this might lead to interesting behaviours in used code.
            // Reconsider when we have a way to report to the user on which side it is.
            {
                int top;
                if (wxGetFrameExtents(window, NULL, NULL, &top, NULL))
                {
                    return top; // top frame extent
                }
            }

            // Try a default approach without a window pointer, if possible
            // ...

            return -1;

        case wxSYS_PENWINDOWS_PRESENT:
            // No MS Windows for Pen computing extension available in X11 based gtk+.
            return 0;

        default:
            return -1;   // metric is unknown
    }
}
Ejemplo n.º 20
0
int
main (int argc, char **argv)
{
  gchar *confdir;

  gchar *host = g_strdup ("localhost");
  gchar *port = g_strdup ("22");
  gchar *sshkey = NULL;

  gchar *user = NULL;
  gchar *password = NULL;

  gchar *session = g_strdup ("thinnx");
  gchar *type = g_strdup ("unix-gnome");
  gchar *cookie = NULL;

  gboolean use_ssl = 0;

  gchar *link = g_strdup ("adsl");
  gchar *kbdtype = g_strdup ("pc104/us");

  gchar *geometry = g_strdup ("fullscreen");
  gchar *screeninfo = NULL;

  gchar *session_id = NULL;
  gchar *session_display = NULL;
  gchar *pcookie = NULL;
  
  gchar **nxssh_argv = (gchar**) g_malloc (sizeof(gchar*) * 9);

  gchar *restore_id = NULL;

  pid_t pid;

  int parent_pipe[2];	/* For talking to the parent */
  int child_pipe[2];	/* For talking to the child */

  gint in = 0, out = 0;

  gtk_init (&argc, &argv);

  homedir = g_get_home_dir ();
  confdir = g_strdup_printf ("%s/.nx/", homedir);
  sshkey = g_strdup_printf ("%s/.ssh/id_dsa", homedir);

  {
    struct stat info;
    
    if (stat (confdir, &info) == -1)
      {
      if (mkdir (confdir, 0777) == -1)
	g_critical ("Could not create directory %s: %s\n", 
		    confdir, strerror (errno));
      }
  }    

  {
#if GTK_MAJOR_VERSION == 2
    GdkScreen *screen;

    screen = gdk_screen_get_default ();
    
    screeninfo = g_strdup_printf ("%dx%dx%d+render", 
				  gdk_screen_get_width (screen),
				  gdk_screen_get_height (screen),
				  gdk_visual_get_best_depth ());
#else
    screeninfo = g_strdup_printf ("%dx%dx%d+render",
				  gdk_screen_width (),
				  gdk_screen_height (),
				  gdk_visual_get_best_depth ());
#endif
  }

  { /* get X authentication cookie information */
    FILE *xauth_output;
    gchar xauth[256] = {0};

    gchar *tmp = NULL;
    gchar **tmpv = NULL;
    gchar *display = NULL;

    /* avoid problems with "network" DISPLAY's */
    display = g_strdup (getenv ("DISPLAY"));
    tmpv = g_strsplit (display, ":", 3);
    g_free (display);
  
    display = g_strdup_printf (":%s", tmpv[1]);
    g_strfreev (tmpv);

    /* get the authorization token */
    tmp = g_strdup_printf (XAUTHBINDIR"/xauth list %s | "
			   "grep 'MIT-MAGIC-COOKIE-1' | "
			   "cut -d ' ' -f 5",
			   display);

    if ((xauth_output = popen (tmp, "r")) == NULL)
      {
	g_critical ("Failed to obtain xauth key: %s", strerror(errno));
	exit (1);
      }

    fread (xauth, sizeof(char), 256, xauth_output);
    xauth[strlen(xauth) - 1] = '\0';
    pclose (xauth_output);
    g_free (tmp);

    if (!strcmp (xauth, ""))
      {
	message_dialog ("Não foi possível obter um cookie de autenticação\n"
			"do servidor X. Impossível continuar.");
	exit (1);
      }

    cookie = g_strdup (xauth);
  }


  { /* read configuration file */
    FILE *fconf;
    gint fconf_fd;
    gchar **tmp, *key, *value;
    struct stat info;
    
    if (stat (CONFFILE, &info) == -1)
      {
	g_warning ("WARNING: Could not stat %s: %s.\n", 
		   CONFFILE, strerror (errno));
      }

    fconf = fopen (CONFFILE, "r");
    if (fconf == NULL)
      {
	g_critical ("Could not open %s: %s.\n", 
		    CONFFILE, strerror (errno));
      }
    else
      {
	fconf_fd = fileno (fconf);

	while (!feof (fconf))
	  {

	    buffer = read_line (fconf_fd);
	    if (!buffer)
	      break;

	    /* remove comments */
	    tmp = g_strsplit (buffer, "#", 2);
	    g_free (buffer);

	    buffer = g_strdup (tmp[0]);
	    g_strfreev (tmp);

	    /* check if we still have a key/value pair */
	    tmp = g_strsplit (buffer, "=", 2);
	    g_free (buffer);
	    if (tmp[1] == NULL || tmp[0] == NULL)
	      {
		g_strfreev (tmp);
		continue;
	      }

	    key = tmp[0];
	    value = tmp[1];

	    g_strstrip (key);
	    g_strstrip (value);

	    if (!strcmp ("host", key))
	      {
		g_free (host);
		host = g_strdup (value);
	      }
	    else if (!strcmp ("port", key))
	      {
		g_free (port);
		port = g_strdup (value);
	      }
	    else if (!strcmp ("sshkey", key))
	      {
		g_free (sshkey);
		sshkey = g_strdup (value);
	      }
	    else if (!strcmp ("session", key))
	      {
		g_free (session);
		session = g_strdup (value);
	      }
	    else if (!strcmp ("ssl", key))
	      {
		if (!strcmp (value, "yes"))
		    use_ssl = 1;
	      }
	    else if (!strcmp ("type", key))
	      {
		g_free (type);
		type = g_strdup (value);
	      }
	    else if (!strcmp ("link", key))
	      {
		g_free (link);
		link = g_strdup (value);
	      }
	    else if (!strcmp ("kbdtype", key))
	      {
		g_free (kbdtype);
		kbdtype = g_strdup (value);
	      }
	    else if (!strcmp ("geometry", key))
	      {
		g_free (geometry);
		geometry = g_strdup (value);
	      }
	    else
	      g_warning ("Unknown option in %s: %s=%s\n", 
			 CONFFILE, key, value);

	    g_strfreev (tmp);
	  }
	fclose (fconf);
      }
  }

  /* grab auth information from the user before anything else */
  input_dialog (&user, &password);

  if (!strcmp (user, "root"))
    {
      message_dialog ("O usuário root não pode entrar por aqui!");
      exit (1);
    }

  pipe (parent_pipe);
  pipe (child_pipe);

  pid = fork ();
  if (pid == -1)
    {
      g_critical ("Could not fork!\n");
      exit (1);
    }
  else if (pid == 0)
    {
      close (child_pipe[1]);
      dup2 (child_pipe[0], STDIN_FILENO);
      dup2 (parent_pipe[1], STDOUT_FILENO);

      nxssh_argv[0] = g_strdup (BINDIR"/nxssh");
      nxssh_argv[1] = g_strdup ("-nx");
      nxssh_argv[2] = g_strdup_printf ("-p%s", port);
      nxssh_argv[3] = g_strdup ("-i");
      nxssh_argv[4] = g_strdup (sshkey);
      nxssh_argv[5] = g_strdup_printf ("[email protected]%s", host);
      nxssh_argv[6] = g_strdup ("-2");
      nxssh_argv[7] = g_strdup ("-S");
      nxssh_argv[8] = NULL;

      execv (nxssh_argv[0], nxssh_argv);
    }
  else
    {
      close(parent_pipe[1]);

      out = parent_pipe[0];
      in = child_pipe[1];

      /* Handle initial hand-shaking */
      {
	gboolean ssh_authed = FALSE;

	while (!ssh_authed)
	  {
	    buffer = read_code (out);
	    if (!strcmp (buffer, "NX> 205"))
	      {
		flush_buffer (buffer);
		drop_line (out);
		drop_line (out);
		drop_chars (out, 56);
		write_line (in, "yes");
		drop_line (out);
		drop_line (out);

		/* buffer != NULL? but why?! */
		buffer = NULL;
	      }
	    else if (!strcmp (buffer, "NX> 208"))
	      { 
		/* OK, authenticating... */
	      }
	    else if (!strcmp (buffer, "NX> 203") || 
		     (!strcmp (buffer, "NX> 285")) ||
		     (!strcmp (buffer, "NX> 200")) ||
		     (!strcmp (buffer, "NX> 202")))
	      {
		/* ignored stderr */
	      }
	    else if (!strncmp (buffer, "nxssh", 5))
	      {
		gchar *msg;

		flush_buffer (buffer);
		buffer = read_line (out);
		msg = get_info_after_colon (buffer);
		g_free (buffer);

		if (!strcmp (msg, "Name or service not known"))
		  message_dialog ("Não foi possível resolver o nome do servidor.");
		else if (!strcmp (msg, "Connection refused"))
		  message_dialog ("A conexão foi recusada!\n"
				  "Verifique a porta.");
		else if (!strcmp (msg, "Connection timed out"))
		  message_dialog ("Tempo limite da conexão expirou!\n"
				  "Verifique servidor e porta.");

		flush_buffer (msg);
		fprintf (stderr, "\n");
		exit (1);
	      }
	    else if (!strcmp (buffer, "NX> 204"))
	      {
		message_dialog ("Falha na autenticação inicial!\n"
				"Confira a chave privada.");
		g_critical ("Failed to authenticate to SSH using the public key!\n");
		exit (1);
	      }
	    else if (!strcmp (buffer, "HELLO N"))
	      {
		/* OK, time to say HELLO! */
		ssh_authed = TRUE;
	      }
	    else
	      protocol_error ("problems waiting for HELLO");

	    flush_buffer (buffer);

	    buffer = read_line (out);
	    flush_buffer (buffer);
	  }
      }

      /* Handle HELLO */
      buffer = read_code (out);
      if (!strcmp (buffer, "NX> 105"))
	{
	  flush_buffer (buffer);
	  drop_chars (out, 1);
	  write_line (in, "HELLO NXCLIENT - Version 1.4.0");
	  drop_line (out);
	}
      else
	protocol_error ("problems during HELLO");

      /* Handle Login */
      buffer = read_code (out);
      if (!strcmp (buffer, "NX> 134"))
	{
	  flush_buffer (buffer);
	  buffer = read_line (out);
	  flush_buffer (buffer);
	}
      else
	protocol_error ("HELLO failed?");

      buffer = read_code (out);
      if (!strcmp (buffer, "NX> 105"))
	{
	  flush_buffer (buffer);
	  drop_chars (out, 1);
	  write_line (in, "login");
	  drop_line (out);
	}
      else
	protocol_error ("No login? How come!");

      buffer = read_code (out);
      if (!strcmp (buffer, "NX> 101"))
	{
	  flush_buffer (buffer);
	  drop_chars (out, 7);
	  write_line (in, user);
	  drop_line (out);
	}
      else
	protocol_error ("who took my login prompt away?");

      buffer = read_code (out);
      if (!strcmp (buffer, "NX> 102"))
	{
	  flush_buffer (buffer);
	  drop_chars (out, 11);
	  write_line (in, password);
	  drop_line (out);
	}
      else
	protocol_error ("where is my password prompt?");

      buffer = read_code (out);
      if (!strcmp (buffer, "NX> 103"))
	{
	  flush_buffer (buffer);
	  drop_line (out);
	}
      else
	{
	  flush_buffer (buffer);
	  message_dialog ("Login ou senha incorretos!");
	  exit (1);
	}

      buffer = read_code (out);
      if (!strcmp (buffer, "NX> 105"))
	{
	  gchar *m;

	  flush_buffer (buffer);
	  drop_chars (out, 1);

	  m = g_strdup_printf ("list %s", user);
	  write_line (in, m);
	  g_free (m);

	  drop_lines (out, 5);

	  while (1)
	    {
	      buffer = read_code (out);
	      if (!strcmp (buffer, "NX> 105"))
		{
		  flush_buffer (buffer);
		  drop_chars (out, 1);
		  break;
		}

	      flush_buffer (buffer);
	      buffer = read_line (out);
	      restore_id = get_restore_id (buffer);
	    }
	}
      else
	protocol_error ("session startup, buddy, I don't want problems!");
      

      {
	gchar *cmdline;
	
	if (!restore_id)
	  cmdline = g_strdup_printf ("startsession --session=\"%s\" --type=\"%s\" --cache=\"8M\" --images=\"32M\" --cookie=\"%s\" --link=\"%s\" --kbtype=\"%s\" --nodelay=\"1\" --backingstore=\"never\" --geometry=\"%s\" --media=\"0\" --agent_server=\"\" --agent_user=\"\" --agent_password=\"\" --screeninfo=\"%s\" --encryption=\"%d\"", session, type, cookie, link, kbdtype, geometry, screeninfo, use_ssl);
	else
	  cmdline = g_strdup_printf ("restoresession --session=\"%s\" --type=\"%s\" --cache=\"8M\" --images=\"32M\" --cookie=\"%s\" --link=\"%s\" --kbtype=\"%s\" --nodelay=\"1\" --backingstore=\"never\" --geometry=\"%s\" --media=\"0\" --agent_server=\"\" --agent_user=\"\" --agent_password=\"\" --screeninfo=\"%s\" --encryption=\"%d\" --id=\"%s\"", session, type, cookie, link, kbdtype, geometry, screeninfo, use_ssl, restore_id);
	
	write_line (in, cmdline);
	g_free (cmdline);
	cmdline = NULL;
	
	drop_lines (out, 4);
      }

      session_id = get_session_info (out, "NX> 700");
      session_display = get_session_info (out, "NX> 705");
      drop_line (out); /* 703 (session type) */
      pcookie = get_session_info (out, "NX> 701");
      drop_line (out); /* 702 proxy ip */
      drop_line (out); /* 706 agent cookie */
      drop_line (out); /* 704 session cache */
      {
	gchar *tmp = get_session_info (out, "NX> 707"); /* 707 ssl tunneling */
	
	use_ssl = atoi (tmp);
	g_free (tmp);
      }
      drop_line (out); /* 710 session status: running */
      drop_line (out); /* 1002 commit */
      drop_line (out); /* 1006 session status: running */

      read_code (out);
      drop_chars (out, 1);

      /* now prepare to run nxproxy */
      {
	FILE *options;
		
	gchar *dirname;
	gchar *fname;
	gchar *cmdline;
		
	dirname = g_strdup_printf ("%s/.nx/S-%s", homedir, session_id);
	fname = g_strdup_printf ("%s/options", dirname);
		
	g_print ("Dir: %s\nFname: %s\n", dirname, fname);
		
	if (mkdir (dirname, 0777) == -1)
	  {
	    /* BOMB or handle 'directory already exists' */
	  }
	g_free (dirname);
		
	if (use_ssl)
	  buffer = g_strdup_printf ("cookie=%s,root=%s/.nx,session=%s,id=%s,listen=%d:%s", pcookie, homedir, session, session_id, 8008, session_display);
	else
	  buffer = g_strdup_printf ("cookie=%s,root=%s/.nx,session=%s,id=%s,connect=%s:%s", pcookie, homedir, session, session_id, host, session_display);
		
	options = fopen (fname, "w");
	fwrite (buffer, sizeof(char), strlen (buffer), options);
	fclose (options);
		
	g_free (buffer);
		
	cmdline = g_strdup_printf (BINDIR"/nxproxy -S options=%s:%s", fname, session_display);
	system (cmdline);
	g_free (cmdline);
		
	g_free (fname);
      }
    }

  write_line (in, "bye");
  drop_line (out);

  if (use_ssl)
    write_line (in, "switch");

  drop_line (out);
  drop_line (out);
  drop_line (out);

  return 0;
}
Ejemplo n.º 21
0
Installer::Installer(
	std::string app_name,
	std::string confirm_title,
	std::string message) :
		app_name(app_name),
		confirm_title(confirm_title),
		message(message),
		current_job(NULL),
		cancel(false),
		error("")
{

	this->download_finished = false;
	this->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_container_set_border_width(GTK_CONTAINER(this->window), 10);
	gtk_window_set_default_size(GTK_WINDOW(this->window), WINDOW_WIDTH, WINDOW_HEIGHT);
	gtk_window_resize(GTK_WINDOW(this->window), WINDOW_WIDTH, WINDOW_HEIGHT);
	gtk_window_set_gravity(GTK_WINDOW(this->window), GDK_GRAVITY_CENTER);

	std::string title = this->app_name + " - Installer";
	gtk_window_set_title(GTK_WINDOW(this->window), title.c_str());

	g_signal_connect (
		G_OBJECT(this->window),
		"destroy",
		G_CALLBACK(destroy_cb),
		(gpointer) this);

	gtk_window_move(
		GTK_WINDOW(this->window),
		gdk_screen_width()/2 - WINDOW_WIDTH/2,
		gdk_screen_height()/2 - WINDOW_HEIGHT/2);

	GdkColormap* colormap = gtk_widget_get_colormap(this->window);
	GdkBitmap *mask = NULL;
	GdkPixmap* icon = gdk_pixmap_colormap_create_from_xpm_d(
		NULL,
		colormap,
		&mask,
		NULL,
		(gchar**) titanium_xpm);
	GtkWidget* image = gtk_image_new_from_pixmap(icon, mask);
	this->label = gtk_label_new("Downloading packages..");

	GtkWidget* hbox = gtk_hbox_new(FALSE, 0);
	gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 5);
	gtk_box_pack_start(GTK_BOX(hbox), this->label, FALSE, FALSE, 0);

	this->bar = gtk_progress_bar_new();

	GtkWidget* hbox2 = gtk_hbox_new(FALSE, 0);
	GtkWidget* cancel_but = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
	gtk_box_pack_start(GTK_BOX(hbox2), cancel_but, TRUE, FALSE, 0);

	g_signal_connect (
		G_OBJECT(cancel_but),
		"clicked",
		G_CALLBACK(cancel_cb),
		(gpointer) this);

	GtkWidget* vbox = gtk_vbox_new(FALSE, 5);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), this->bar, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), hbox2, FALSE, FALSE, 10);

	gtk_container_add(GTK_CONTAINER(this->window), vbox);

}
Ejemplo n.º 22
0
void show_smileys_cb(smiley_callback_data *data)
{
	eb_local_account *account;
	LList *smileys = NULL;
	protocol_smiley *msmiley = NULL;
	GtkWidget *smileys_table = NULL;
	GtkWidget *button = NULL;
	GtkWidget *iconwid;
	GdkPixbuf *icon;
	GtkWidget *smiley_window;
	LList *done = NULL;
	LList *l;
	smiley *dsmile = NULL;
	int real_len = 0, x = -1, y = 0;
	int win_w = 0, win_h = 0, w, h;
	int win_x, win_y;
	int rows, cols;

	if (data && data->c_window)
		account = data->c_window->conv->local_user;
	else {
		eb_debug(DBG_CORE, "no chat* in data !\n");
		return;
	}

	/* close popup if open */
	if (data->c_window && data->c_window->smiley_window) {
		gtk_widget_destroy(data->c_window->smiley_window);
		data->c_window->smiley_window = NULL;
		return;
	}

	if (account && RUN_SERVICE(account)->get_smileys)
		smileys = RUN_SERVICE(account)->get_smileys();
	else
		return;
	for (; smileys; smileys = smileys->next) {
		gboolean already_done = FALSE;
		msmiley = smileys->data;
		for (l = done; l; l = l->next) {
			protocol_smiley *done_smiley = l->data;
			if (!strcmp(msmiley->name, done_smiley->name)) {
				already_done = TRUE;
				break;
			}
		}

		if (already_done || !get_smiley_by_name(msmiley->name))
			continue;

		done = l_list_append(done, msmiley);
		real_len++;
	}

	rows = fast_sqrt(real_len) - 1;
	if (rows < 5)
		rows = 5;
	cols = real_len / rows + !(!(real_len % rows));
	smileys_table = gtk_table_new(rows, cols, TRUE);

	for (l = done; l; l = l_list_next(l)) {
		msmiley = l->data;
		dsmile = get_smiley_by_name_and_service(msmiley->name,
			GET_SERVICE(account).name);
		if (dsmile != NULL) {
			GtkWidget *parent = NULL;
			if (data && data->c_window)
				parent = data->c_window->window;
			icon = gdk_pixbuf_new_from_xpm_data((const char **)
				dsmile->pixmap);
			iconwid = gtk_image_new_from_pixbuf(icon);

			sscanf(dsmile->pixmap[0], "%d %d", &w, &h);
			if (x < rows) {
				x++;
				if (y == 0)
					win_h += h + 2;
			}
			if (x == rows) {
				y++;
				x = 0;
				win_w += w + 2;
			}
			gtk_widget_show(iconwid);
			button = gtk_button_new();
			gtk_button_set_relief(GTK_BUTTON(button),
				GTK_RELIEF_NONE);
			gtk_container_add(GTK_CONTAINER(button), iconwid);
			gtk_widget_show(button);
			gtk_widget_set_name(button, msmiley->text);
			g_signal_connect(button, "clicked",
				G_CALLBACK(insert_smiley_cb), data);
			gtk_table_attach(GTK_TABLE(smileys_table), button, y,
				y + 1, x, x + 1, GTK_FILL, GTK_FILL, 0, 0);
		}
	}

	l_list_free(done);
	done = NULL;

	smiley_window = gtk_window_new(GTK_WINDOW_POPUP);
	gtk_window_set_transient_for(GTK_WINDOW(smiley_window),
		GTK_WINDOW(data->c_window->window));
	gtk_window_set_modal(GTK_WINDOW(smiley_window), FALSE);
	gtk_window_set_wmclass(GTK_WINDOW(smiley_window), "ayttm-chat",
		"Ayttm");
	gtk_window_set_title(GTK_WINDOW(smiley_window), "Smileys");
	gtk_window_set_resizable(GTK_WINDOW(smiley_window), FALSE);
	gtk_widget_realize(smiley_window);

	g_signal_connect(smiley_window, "delete-event",
		G_CALLBACK(delete_event_cb), (gpointer) data);

	gtk_container_add(GTK_CONTAINER(smiley_window), smileys_table);
	gtk_widget_show(smileys_table);

	/* move the window a bit after the cursor and in the screen */
	gdk_window_get_pointer(NULL, &win_x, &win_y, NULL);
	win_x += 5;
	win_y += 5;
	while ((win_x) + win_w > gdk_screen_width() - 30)
		win_x -= 20;
	while ((win_y) + win_h > gdk_screen_height() - 30)
		win_y -= 20;
	gtk_window_move(GTK_WINDOW(smiley_window), win_x, win_y);

	if (data && data->c_window)
		data->c_window->smiley_window = smiley_window;

	gtk_widget_show(smiley_window);

}
Ejemplo n.º 23
0
void wxDisplaySize( int *width, int *height )
{
    if (width) *width = gdk_screen_width();
    if (height) *height = gdk_screen_height();
}
Ejemplo n.º 24
0
app_struct *app_new(	gchar *title, 
			option_file_type *current_opt, 
			option_file_type *allowed_opt,
			gchar *options_file) {
// Initializes application

	app_struct *app;
	app = (app_struct *) x_malloc(sizeof(app_struct), "app_struct");

	app->main_bar_pos_x = MAIN_BAR_X*gdk_screen_width()/100;
	app->main_bar_pos_y = MAIN_BAR_Y*gdk_screen_height()/100;

	app->default_dir = (gchar *) x_malloc(strlen(HF_DIR)+1, "gchar (HF_DIR)");
	strcpy(app->default_dir, HF_DIR);
	app->file_on_cmdline = NULL;
	app->title = title;
	app->docs = doc_swap_new();
	app->new_doc_count = 0;

	app->rc_options_file = options_file;
	app->allowed_options = allowed_opt;
	app->current_options = current_opt;
	app->options_dialog = NULL;
	app->stack = stack_struct_new (NULL);

//	printf("APP: %p;  APP->STACK: %p\n",app, app->stack);

	check_integrated_interface (allowed_opt);

        app->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

	gtk_widget_realize(GTK_WIDGET(app->window));

	gtk_widget_set_uposition(GTK_WIDGET(app->window),
		app->main_bar_pos_x, app->main_bar_pos_y);

	app->types = instantiate_types(app->window);

	if (!INTEGRATED_INTERFACE)
		gtk_window_set_resizable(GTK_WINDOW(app->window),FALSE);
	
       	gtk_signal_connect (GTK_OBJECT (app->window), "delete_event",
                        GTK_SIGNAL_FUNC(app_menu_delete),
                        (gpointer) app);
        gtk_window_set_title (GTK_WINDOW (app->window), app->title);
        gtk_container_border_width (GTK_CONTAINER(app->window),DEF_PAD);

	app->accel_group = gtk_accel_group_new();
	gtk_window_add_accel_group (GTK_WINDOW(app->window), app->accel_group);

	app->tooltips = gtk_tooltips_new();

	if ((!INTEGRATED_INTERFACE) || (!MENU_IN_DOC_WINDOW))
		app->menu = menu_new(NBCOMMANDS,commands, app->accel_group, (gpointer) app);
	else
		app->menu = NULL;

	if ((!INTEGRATED_INTERFACE) || (!ICONS_IN_DOC_WINDOW))
		app->toolbar = standard_toolbar_new(NBCOMMANDS,
			commands,
			app->tooltips,
			app->window,
			(gpointer) app,
			GTK_ORIENTATION_HORIZONTAL,
			GTK_TOOLBAR_ICONS,
			FALSE);
	else
		app->toolbar = NULL;

	if (!INTEGRATED_INTERFACE) {
		creation_container_new(app->types);
		tools_container_new(app->types);
		// We need the accelerators for the tools window, 
		// but not for the creation window, which is modal
		if (GTK_IS_WINDOW(app->types->tools_container))
			gtk_window_add_accel_group (GTK_WINDOW(app->types->tools_container), app->accel_group);
	}
	return(app);
}
Ejemplo n.º 25
0
int WinScreenYSize ()
{
	return gdk_screen_height();
}
Ejemplo n.º 26
0
int main(int argc, char** argv)
{
  gdk_init(&argc, &argv);

#if defined(HAVE_LIBXSS) && defined(MOZ_WIDGET_GTK)
  int event_base, error_base;
  Bool have_xscreensaver =
    XScreenSaverQueryExtension(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
                               &event_base, &error_base);

  if (!have_xscreensaver) {
    fprintf(stderr, "No XScreenSaver extension on display\n");
  } else {
    XScreenSaverInfo* info = XScreenSaverAllocInfo();
    if (!info) {
      fprintf(stderr, "%s: Out of memory\n", argv[0]);
      return 1;
    }
    XScreenSaverQueryInfo(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
                          GDK_ROOT_WINDOW(), info);

    const char* state;
    const char* til_or_since = nullptr;
    switch (info->state) {
    case ScreenSaverOff:
      state = "Off";
      til_or_since = "XScreenSaver will activate after another %lu seconds idle time\n";
      break;
    case ScreenSaverOn:
      state = "On";
      if (info->til_or_since) {
        til_or_since = "XScreenSaver idle timer activated %lu seconds ago\n";
      } else {
        til_or_since = "XScreenSaver idle activation is disabled\n";
      }
      break;
    case ScreenSaverDisabled:
      state = "Disabled";
      break;
    default:
      state = "unknown";
    }

    const char* kind;
    switch (info->kind) {
    case ScreenSaverBlanked:
      kind = "Blanked";
      break;
    case ScreenSaverInternal:
      state = "Internal";
      break;
    case ScreenSaverExternal:
      state = "External";
      break;
    default:
      state = "unknown";
    }

    fprintf(stderr, "XScreenSaver state: %s\n", state);

    if (til_or_since) {
      fprintf(stderr, "XScreenSaver kind: %s\n", kind);
      fprintf(stderr, til_or_since, info->til_or_since / 1000);
    }

    fprintf(stderr, "User input has been idle for %lu seconds\n", info->idle / 1000);

    XFree(info);
  }
#endif

  GdkPixbuf* screenshot = nullptr;
  GdkWindow* window = gdk_get_default_root_window();
#if (MOZ_WIDGET_GTK == 2)
  screenshot = gdk_pixbuf_get_from_drawable(nullptr, window, nullptr,
                                            0, 0, 0, 0,
                                            gdk_screen_width(),
                                            gdk_screen_height());
#else
  screenshot = gdk_pixbuf_get_from_window(window, 0, 0,
                                          gdk_window_get_width(window),
                                          gdk_window_get_height(window));
#endif
  if (!screenshot) {
    fprintf(stderr, "%s: failed to create screenshot GdkPixbuf\n", argv[0]);
    return 1;
  }

  GError* error = nullptr;
  if (argc > 1) {
    gdk_pixbuf_save(screenshot, argv[1], "png", &error, nullptr);
  } else {
    gdk_pixbuf_save_to_callback(screenshot, save_to_stdout, nullptr,
                                "png", &error, nullptr);
  }
  if (error) {
    fprintf(stderr, "%s: failed to write screenshot as png: %s\n",
            argv[0], error->message);
    return error->code;
  }

  return 0;
}
Ejemplo n.º 27
0
void wControlSetBalloon( wControl_p b, wPos_t dx, wPos_t dy, const char * msg )
{
	PangoLayout * layout;
	wPos_t x, y;
	wPos_t w, h;
	wPos_t xx, yy;
	const char * msgConverted;	
	if (balloonVisible && balloonB == b &&
		balloonDx == dx && balloonDy == dy && balloonMsg == msg )
		return;

	if ( msg == NULL ) {
		if ( balloonF != NULL ) {
			gtk_widget_hide( balloonF );
			balloonVisible = FALSE;
		}
		balloonMsg = "";
		return;
	}
	msgConverted = gtkConvertInput(msg);
	if ( balloonF == NULL ) {
		balloonF = gtk_window_new( GTK_WINDOW_POPUP );
		gtk_window_set_policy( GTK_WINDOW (balloonF), FALSE, FALSE, TRUE );
		gtk_widget_realize( balloonF );
		balloonPI = gtk_label_new(msgConverted);
		gtk_container_add( GTK_CONTAINER(balloonF), balloonPI );
		gtk_container_border_width( GTK_CONTAINER(balloonF), 1 );
		gtk_widget_show( balloonPI );
	} else {
		gtk_label_set( GTK_LABEL(balloonPI), msgConverted );
	}
	balloonDx = dx;
	balloonDy = dy;
	balloonB = b;
	balloonMsg = msg;
	gtk_widget_hide( balloonF );
    layout = gtk_widget_create_pango_layout( balloonPI, msgConverted );
    pango_layout_get_pixel_size( layout, &w, &h );
	g_object_unref(G_OBJECT(layout));
	h = 16;
	gdk_window_get_position( GTK_WIDGET(b->parent->gtkwin)->window, &x, &y );
	gdk_window_get_origin( GTK_WIDGET(b->parent->gtkwin)->window, &x, &y );
	x += b->realX + dx;
	y += b->realY + b->h - dy;
	xx = gdk_screen_width();
	yy = gdk_screen_height();
	if ( x < 0 ) {
		x = 0;
	} else if ( x+w > xx ) {
		x = xx - w;
	}
	if ( y < 0 ) {
		y = 0;
	} else if ( y+h > yy ) {
		y = yy - h ;
	}
	gtk_widget_set_usize( balloonPI, w, h );
	gtk_widget_set_usize( balloonF, w+2, h+2 );
	gtk_widget_show( balloonF );
	gtk_widget_set_uposition( balloonF, x, y );
	/*gtk_widget_popup( balloonF, x, y );*/
	gdk_draw_rectangle( balloonF->window, balloonF->style->fg_gc[GTK_STATE_NORMAL], FALSE, 0, 0, w+1, h+1 );
	gtk_widget_queue_resize( GTK_WIDGET(balloonF) );
	/*gtk_widget_set_uposition( balloonF, x, y );*/
	balloonVisible = TRUE;
}
Ejemplo n.º 28
0
void prefswindow_open_full(const gchar *title, GSList *prefs_pages,
							 gpointer data, GDestroyNotify func,
							 gint *save_width, gint *save_height,
							 gboolean preload_pages,
							 PrefsOpenCallbackFunc open_cb,
							 PrefsApplyCallbackFunc apply_cb,
							 PrefsCloseCallbackFunc close_cb)
{
	PrefsWindow *prefswindow;
	gint x = gdk_screen_width();
	gint y = gdk_screen_height();
	static GdkGeometry geometry;
	GtkAdjustment *adj;

	prefswindow = g_new0(PrefsWindow, 1);

	prefswindow->data = data;
	prefswindow->func = func;
	prefswindow->prefs_pages = g_slist_copy(prefs_pages);
	prefswindow->save_width = save_width;
	prefswindow->save_height = save_height;
	prefswindow->open_cb = open_cb;
	prefswindow->apply_cb = apply_cb;
	prefswindow->close_cb = close_cb;
	prefswindow->dialog_response = PREFSWINDOW_RESPONSE_CANCEL;

	prefswindow->window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "prefswindow");
	gtk_window_set_title(GTK_WINDOW(prefswindow->window), title);

	gtk_window_set_position (GTK_WINDOW(prefswindow->window), GTK_WIN_POS_CENTER);
	gtk_window_set_modal (GTK_WINDOW (prefswindow->window), TRUE);
	gtk_window_set_resizable (GTK_WINDOW(prefswindow->window), TRUE);
	gtk_window_set_transient_for (GTK_WINDOW(prefswindow->window),
			GTK_WINDOW(mainwindow_get_mainwindow()->window));
	gtk_container_set_border_width(GTK_CONTAINER(prefswindow->window), 4);

	prefswindow->vbox = gtk_vbox_new(FALSE, 6);
	gtk_widget_show(prefswindow->vbox);
	
	prefswindow->paned = gtk_hpaned_new();
	gtk_widget_show(prefswindow->paned);

	gtk_container_add(GTK_CONTAINER(prefswindow->window), prefswindow->vbox);

	gtk_box_pack_start(GTK_BOX(prefswindow->vbox), prefswindow->paned, TRUE, TRUE, 0);

	prefswindow->scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
	gtk_widget_show(prefswindow->scrolledwindow1);
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(prefswindow->scrolledwindow1),
			GTK_SHADOW_IN);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(prefswindow->scrolledwindow1),
			GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
			
	gtk_paned_add1(GTK_PANED(prefswindow->paned), prefswindow->scrolledwindow1);

	prefswindow->tree_view = prefswindow_tree_view_create(prefswindow);
	gtk_widget_show(prefswindow->tree_view);
	gtk_container_add(GTK_CONTAINER(prefswindow->scrolledwindow1), 
			  prefswindow->tree_view);

	prefswindow->vbox2 = gtk_vbox_new(FALSE, 2);
	gtk_widget_show(prefswindow->vbox2);

	gtk_paned_add2(GTK_PANED(prefswindow->paned), prefswindow->vbox2);

	prefswindow->table2 = gtk_table_new(1, 2, FALSE);
	gtk_widget_show(prefswindow->table2);
	gtk_container_add(GTK_CONTAINER(prefswindow->vbox2), prefswindow->table2);

	prefswindow->labelframe = gtk_frame_new(NULL);
	gtk_widget_show(prefswindow->labelframe);
	gtk_frame_set_shadow_type(GTK_FRAME(prefswindow->labelframe), GTK_SHADOW_OUT);
	gtk_table_attach(GTK_TABLE(prefswindow->table2), prefswindow->labelframe,
			0, 1, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 1, 1);

	prefswindow->pagelabel = gtk_label_new("");
	gtk_widget_show(prefswindow->pagelabel);
	gtk_label_set_justify(GTK_LABEL(prefswindow->pagelabel), GTK_JUSTIFY_LEFT);
	gtk_misc_set_alignment(GTK_MISC(prefswindow->pagelabel), 0, 0.0);
	gtk_container_add(GTK_CONTAINER(prefswindow->labelframe), prefswindow->pagelabel);

	prefswindow->notebook = gtk_notebook_new();
	gtk_widget_show(prefswindow->notebook);
	gtk_notebook_set_scrollable(GTK_NOTEBOOK(prefswindow->notebook), TRUE);
	gtk_notebook_set_show_tabs(GTK_NOTEBOOK(prefswindow->notebook), FALSE);
	gtk_notebook_set_show_border(GTK_NOTEBOOK(prefswindow->notebook), FALSE);

	gtk_table_attach(GTK_TABLE(prefswindow->table2), prefswindow->notebook,
			0, 1, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 4);

	prefswindow->empty_page = gtk_label_new("");
	gtk_widget_show(prefswindow->empty_page);
	gtk_container_add(GTK_CONTAINER(prefswindow->notebook), prefswindow->empty_page);

	prefswindow_build_tree(prefswindow->tree_view, prefs_pages, prefswindow,
							preload_pages);

	if (open_cb)
		open_cb(prefswindow);

	gtk_widget_grab_focus(prefswindow->tree_view);

#ifndef GENERIC_UMPC
	gtkut_stock_button_set_create(&prefswindow->confirm_area,
				      &prefswindow->apply_btn,	GTK_STOCK_APPLY,
				      &prefswindow->cancel_btn,	GTK_STOCK_CANCEL,
				      &prefswindow->ok_btn,	GTK_STOCK_OK);
#else
	gtkut_stock_button_set_create(&prefswindow->confirm_area,
				      &prefswindow->apply_btn,	GTK_STOCK_APPLY,
				      &prefswindow->ok_btn,	GTK_STOCK_CLOSE,
				      NULL,			NULL);
#endif
	gtk_widget_show_all(prefswindow->confirm_area);
	gtk_widget_show(prefswindow->vbox);
	gtk_widget_show(prefswindow->scrolledwindow1);

	gtk_box_pack_start(GTK_BOX(prefswindow->vbox), prefswindow->confirm_area, FALSE, FALSE, 0);

#ifndef GENERIC_UMPC
	g_signal_connect(G_OBJECT(prefswindow->ok_btn), "clicked", 
			 G_CALLBACK(ok_button_clicked), prefswindow);
	g_signal_connect(G_OBJECT(prefswindow->cancel_btn), "clicked", 
			 G_CALLBACK(cancel_button_clicked), prefswindow);
	g_signal_connect(G_OBJECT(prefswindow->apply_btn), "clicked", 
			 G_CALLBACK(apply_button_clicked), prefswindow);
#else
	g_signal_connect(G_OBJECT(prefswindow->ok_btn), "clicked", 
			 G_CALLBACK(ok_button_clicked), prefswindow);
	g_signal_connect(G_OBJECT(prefswindow->apply_btn), "clicked", 
			 G_CALLBACK(apply_button_clicked), prefswindow);
#endif

	g_signal_connect(G_OBJECT(prefswindow->window), "delete_event", 
			 G_CALLBACK(window_closed), prefswindow);
	g_signal_connect(G_OBJECT(prefswindow->window), "key_press_event",
			   G_CALLBACK(prefswindow_key_pressed), &(prefswindow->window));

	/* connect to callback only if we have non-NULL pointers to store size to */
	if (prefswindow->save_width && prefswindow->save_height) {
		g_signal_connect(G_OBJECT(prefswindow->window), "size_allocate",
				 G_CALLBACK(prefs_size_allocate_cb), prefswindow);
	}

	MANAGE_WINDOW_SIGNALS_CONNECT(prefswindow->window);

	if (!geometry.min_height) {
		
		if (x < 800 && y < 600) {
			geometry.min_width = 600;
			geometry.min_height = 440;
		} else {
			geometry.min_width = 700;
			geometry.min_height = 550;
		}
	}
	gtk_window_set_geometry_hints(GTK_WINDOW(prefswindow->window), NULL, &geometry,
				      GDK_HINT_MIN_SIZE);
	if (prefswindow->save_width && prefswindow->save_height) {
		gtk_widget_set_size_request(prefswindow->window, *(prefswindow->save_width),
					    *(prefswindow->save_height));
	}

#ifdef GENERIC_UMPC
	prefs_show_sections(prefswindow);
#endif
	gtk_widget_show(prefswindow->window);
	adj = gtk_scrolled_window_get_vadjustment(
			GTK_SCROLLED_WINDOW(prefswindow->scrolledwindow1));
	gtk_adjustment_set_value(adj, gtk_adjustment_get_lower(adj));
	gtk_adjustment_changed(adj);
}
Ejemplo n.º 29
0
static void
setup_tooltip_window_position(gpointer data, int w, int h)
{
	int sig;
	int scr_w, scr_h, x, y, dy;
#if GTK_CHECK_VERSION(2,2,0)
	int mon_num;
	GdkScreen *screen = NULL;
#endif
	GdkRectangle mon_size;
	GtkWidget *tipwindow = pidgin_tooltip.tipwindow;
	
#if GTK_CHECK_VERSION(2,2,0)
	gdk_display_get_pointer(gdk_display_get_default(), &screen, &x, &y, NULL);
	mon_num = gdk_screen_get_monitor_at_point(screen, x, y);
	gdk_screen_get_monitor_geometry(screen, mon_num, &mon_size);

	scr_w = mon_size.width + mon_size.x;
	scr_h = mon_size.height + mon_size.y;
#else
	scr_w = gdk_screen_width();
	scr_h = gdk_screen_height();
	gdk_window_get_pointer(NULL, &x, &y, NULL);
	mon_size.x = 0;
	mon_size.y = 0;
#endif

#if GTK_CHECK_VERSION(2,4,0)
	dy = gdk_display_get_default_cursor_size(gdk_display_get_default()) / 2;
#else
	dy = 0;
#endif

#if GTK_CHECK_VERSION(2,2,0)
	if (w > mon_size.width)
		w = mon_size.width - 10;

	if (h > mon_size.height)
		h = mon_size.height - 10;
#endif
	x -= ((w >> 1) + 4);

	if ((y + h + 4) > scr_h)
		y = y - h - dy - 5;
	else
		y = y + dy + 6;

	if (y < mon_size.y)
		y = mon_size.y;

	if (y != mon_size.y) {
		if ((x + w) > scr_w)
			x -= (x + w + 5) - scr_w;
		else if (x < mon_size.x)
			x = mon_size.x;
	} else {
		x -= (w / 2 + 10);
		if (x < mon_size.x)
			x = mon_size.x;
	}

	gtk_widget_set_size_request(tipwindow, w, h);
	gtk_window_move(GTK_WINDOW(tipwindow), x, y);
	gtk_widget_show(tipwindow);

	g_signal_connect(G_OBJECT(tipwindow), "expose_event",
			G_CALLBACK(pidgin_tooltip_expose_event), data);

	/* Hide the tooltip when the widget is destroyed */
	sig = g_signal_connect(G_OBJECT(pidgin_tooltip.widget), "destroy", G_CALLBACK(pidgin_tooltip_destroy), NULL);
	g_signal_connect_swapped(G_OBJECT(tipwindow), "destroy", G_CALLBACK(g_source_remove), GINT_TO_POINTER(sig));
}
Ejemplo n.º 30
0
static GtkWidget *
pop_calendar_window(GtkWidget *parent, int orientation)
{
    GtkWidget *window;
    GtkWidget *cal;
    gint parent_x, parent_y, parent_w, parent_h;
    gint root_w, root_h;
    gint width, height, x, y;
    GtkRequisition requisition;
    GtkAllocation allocation;

    window = gtk_window_new(GTK_WINDOW_POPUP);

    cal = gtk_calendar_new();
    gtk_container_add(GTK_CONTAINER(window), cal);

    gdk_window_get_origin(GDK_WINDOW(parent->window), &parent_x, &parent_y);
    gdk_drawable_get_size(GDK_DRAWABLE(parent->window), &parent_w, &parent_h);

    root_w = gdk_screen_width();
    root_h = gdk_screen_height();

    gtk_widget_realize(GTK_WIDGET(window));

    gtk_widget_size_request(GTK_WIDGET(cal), &requisition);

    allocation.x = requisition.width;
    allocation.y = requisition.height;
    gtk_widget_size_allocate(GTK_WIDGET(cal), &allocation);

    gtk_widget_size_request(GTK_WIDGET(cal), &requisition);
    width = requisition.width;
    height = requisition.height;

    g_print("parent: %dx%d +%d+%d\n", parent_w, parent_h, parent_x, parent_y);
    g_print("root: %dx%d\n", root_w, root_h);
    g_print("calendar: %dx%d\n", width, height);

    if (orientation == GTK_ORIENTATION_VERTICAL) {
        if (parent_x < root_w / 2) {
            if (parent_y < root_h / 2) {
                /* upper left */
                x = parent_x + parent_w;
                y = parent_y;
            } else {
                /* lower left */
                x = parent_x + parent_w;
                y = parent_y + parent_h - height;
            }
        } else {
            if (parent_y < root_h / 2) {
                /* upper right */
                x = parent_x - width;
                y = parent_y;
            } else {
                /* lower right */
                x = parent_x - width;
                y = parent_y + parent_h - height;
            }
        }
    } else {
        if (parent_x < root_w / 2) {
            if (parent_y < root_h / 2) {
                /* upper left */
                x = parent_x;
                y = parent_y + parent_h;
            } else {
                /* lower left */
                x = parent_x;
                y = parent_y - height;
            }
        } else {
            if (parent_y < root_h / 2) {
                /* upper right */
                x = parent_x + parent_w - width;
                y = parent_y + parent_h;
            } else {
                /* lower right */
                x = parent_x + parent_w - width;
                y = parent_y - height;
            }
        }
    }

    gtk_window_move(GTK_WINDOW(window), x, y);
    gtk_widget_show(cal);
    gtk_widget_show(window);

    return window;
}