Пример #1
0
static gboolean
draw_simple_image(GtkStyle       *style,
		  GdkWindow      *window,
		  GdkRectangle   *area,
		  GtkWidget      *widget,
		  ThemeMatchData *match_data,
		  gboolean        draw_center,
		  gboolean        allow_setbg,
		  gint            x,
		  gint            y,
		  gint            width,
		  gint            height)
{
  ThemeImage *image;
  gboolean setbg = FALSE;
  
  if ((width == -1) && (height == -1))
    {
      gdk_window_get_size(window, &width, &height);
      if (allow_setbg)
      	setbg = TRUE;
    }
  else if (width == -1)
    gdk_window_get_size(window, &width, NULL);
  else if (height == -1)
    gdk_window_get_size(window, NULL, &height);

  if (!(match_data->flags & THEME_MATCH_ORIENTATION))
    {
      match_data->flags |= THEME_MATCH_ORIENTATION;
      
      if (height > width)
	match_data->orientation = GTK_ORIENTATION_VERTICAL;
      else
	match_data->orientation = GTK_ORIENTATION_HORIZONTAL;
    }
    
  image = match_theme_image (style, match_data);
  if (image)
    {
      if (image->background)
	{
	  theme_pixbuf_render (image->background,
			       window, NULL, area,
			       draw_center ? COMPONENT_ALL : COMPONENT_ALL | COMPONENT_CENTER,
			       FALSE,
			       x, y, width, height);
	}
      
      if (image->overlay && draw_center)
	theme_pixbuf_render (image->overlay,
			     window, NULL, area, COMPONENT_ALL,
			     TRUE, 
			     x, y, width, height);

      return TRUE;
    }
  else
    return FALSE;
}
Пример #2
0
static void
_lib_geolocation_show_offset_window(GtkWidget *widget, dt_lib_module_t *self)
{
  dt_lib_geolocation_t *d = self->data;
  gint x, y;
  gint px, py, center_w, center_h, window_w, window_h;
  GtkWidget *window = dt_ui_main_window(darktable.gui->ui);
  GtkWidget *center = dt_ui_center(darktable.gui->ui);
  gdk_window_get_origin(gtk_widget_get_window(center), &px, &py);
  gdk_window_get_size(gtk_widget_get_window(center),&center_w,&center_h);

  d->floating_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  GTK_WIDGET_SET_FLAGS(d->floating_window, GTK_CAN_FOCUS);
  gtk_window_set_decorated(GTK_WINDOW(d->floating_window), FALSE);
  gtk_window_set_has_frame(GTK_WINDOW(d->floating_window), FALSE);
  gtk_window_set_type_hint(GTK_WINDOW(d->floating_window), GDK_WINDOW_TYPE_HINT_POPUP_MENU);
  gtk_window_set_transient_for(GTK_WINDOW(d->floating_window), GTK_WINDOW(window));
  gtk_window_set_opacity(GTK_WINDOW(d->floating_window), 0.8);
  gtk_window_set_modal(GTK_WINDOW(d->floating_window), TRUE);

  GtkWidget *alignment = gtk_alignment_new(0.5, 0.5, 1, 1);
  gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 0, 5, 5, 5);
  GtkWidget *vbox = gtk_vbox_new(TRUE, 5);
  gtk_container_add(GTK_CONTAINER(alignment), vbox);

  d->floating_window_entry = gtk_entry_new();
  gtk_widget_add_events(d->floating_window_entry, GDK_FOCUS_CHANGE_MASK);
  g_signal_connect_swapped(d->floating_window, "focus-out-event", G_CALLBACK(gtk_widget_destroy), d->floating_window);
  g_object_set(G_OBJECT(d->floating_window_entry), "tooltip-text", _("enter the time shown on the selected picture\nformat: hh:mm:ss"), (char *)NULL);

  gtk_editable_select_region(GTK_EDITABLE(d->floating_window_entry), 0, -1);
  gtk_box_pack_start(GTK_BOX(vbox), d->floating_window_entry, TRUE, TRUE, 0);
  g_signal_connect(d->floating_window_entry, "key-press-event", G_CALLBACK(_lib_geolocation_floating_key_press), self);

  GtkWidget *hbox = gtk_hbox_new(TRUE, 5);
  GtkWidget *cancel_button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
  GtkWidget *ok_button = gtk_button_new_from_stock(GTK_STOCK_OK);

  gtk_box_pack_start(GTK_BOX(hbox), cancel_button, TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(hbox), ok_button, TRUE, TRUE, 0);
  g_signal_connect_swapped(G_OBJECT(cancel_button), "clicked", G_CALLBACK(gtk_widget_destroy), d->floating_window);
  g_signal_connect(G_OBJECT(ok_button), "clicked", G_CALLBACK(_lib_geolocation_calculate_offset_callback), self);

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

  gtk_container_add(GTK_CONTAINER(d->floating_window), alignment);

  gtk_widget_show_all(d->floating_window);
  gtk_widget_grab_focus(d->floating_window_entry);

  gdk_window_get_size(gtk_widget_get_window(d->floating_window), &window_w, &window_h);
  x = px + 0.5*(center_w-window_w);
  y = py + center_h - 20 - window_h;
  gtk_window_move(GTK_WINDOW(d->floating_window), x, y);

  gtk_window_present(GTK_WINDOW(d->floating_window));
}
Пример #3
0
void ShowDialog(UIDialog* dialog, gchar* default_widget) 
{
	gint sw, sh;
	gint px, py;
	gint pw, ph;
	gint cw, ch;
	gint ox, oy;

	if( dialog->parent != NULL )
	{
		sw = gdk_screen_width();
		sh = gdk_screen_height();

		gtk_widget_realize(dialog->window);
		gtk_window_set_transient_for(GTK_WINDOW(dialog->window),
									GTK_WINDOW(dialog->parent->window));

		gdk_window_get_root_origin(dialog->parent->window->window, &px, &py);
		gdk_window_get_size(dialog->parent->window->window, &pw, &ph);
		gdk_window_get_size(dialog->window->window, &cw, &ch);

		ox = (pw - cw) / 2;
		if( ox < 20 )	ox = 20;

		oy = (ph - ch) / 2;
		if( oy < 20 )	oy = 20;

		if( px + ox + cw > sw ) 
			ox = sw - cw - px - 20;

		if( py + oy + ch > sh )
			oy = sh - ch - py - 20;

		if( dialog->pos_x == 0 )
			dialog->pos_x = px + ox;
		if( dialog->pos_y == 0 )
			dialog->pos_y = py + oy;
	}

	gtk_widget_set_uposition(dialog->window, dialog->pos_x, dialog->pos_y);

	if( default_widget )
	{
		GtkWidget* widget = LookupWidget(dialog->window, default_widget);

		if( widget )
		{
			gtk_widget_grab_focus(widget);
			gtk_widget_grab_default(widget);
		}
	}

	gtk_widget_show(dialog->window);
	gtk_main();
}
Пример #4
0
bool wxBitmap::CreateFromXpm( const char **bits )
{
    UnRef();

    wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid bitmap data") )

    GdkVisual *visual = wxTheApp->GetGdkVisual();

    m_refData = new wxBitmapRefData();

    GdkBitmap *mask = (GdkBitmap*) NULL;

    M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( wxGetRootWindow()->window, &mask, NULL, (gchar **) bits );

    wxCHECK_MSG( M_BMPDATA->m_pixmap, FALSE, wxT("couldn't create pixmap") );

    if (mask)
    {
        M_BMPDATA->m_mask = new wxMask();
        M_BMPDATA->m_mask->m_bitmap = mask;
    }

    gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) );

    M_BMPDATA->m_bpp = visual->depth;  // Can we get a different depth from create_from_xpm_d() ?

    return TRUE;
}
Пример #5
0
void
ui_signal_export (GtkMenuItem * item, gpointer data)
{
  GtkWidget *dialog;
  GtkWidget *window = GET_OBJECT("window");
  GtkFileFilter * filter_auto;
  GtkFileFilter * filter_pdf;
  GtkFileFilter * filter_svg;
  GtkFileFilter * filter_png;

  dialog = gtk_file_chooser_dialog_new (_("Export"),
                                        GTK_WINDOW(window),
                                        GTK_FILE_CHOOSER_ACTION_SAVE,
                                        GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                        GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
                                        NULL);
  /* Set filters */
  filter_auto = gtk_file_filter_new();
  filter_pdf = gtk_file_filter_new();
  filter_svg = gtk_file_filter_new();
  filter_png = gtk_file_filter_new();
  gtk_file_filter_add_pattern (filter_auto, "*");
  gtk_file_filter_add_mime_type (filter_pdf, "application/pdf");
  gtk_file_filter_add_mime_type (filter_svg, "image/svg+xml");
  gtk_file_filter_add_mime_type (filter_png, "image/png");
  gtk_file_filter_set_name (filter_pdf, "Portable Document Format (PDF)");
  gtk_file_filter_set_name (filter_svg, "Scalable Vector Graphcis (SVG)");
  gtk_file_filter_set_name (filter_png, "Portable Networks Graphcis (PNG)");
  gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
  gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter_png);
  gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter_pdf);
  gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter_svg);

  if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
    {
      char *filename;
      char * ext;
      gint width, height;
      GtkFileFilter * filter;
      gboolean successp;
      filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
      filter = gtk_file_chooser_get_filter (GTK_FILE_CHOOSER (dialog));
      gdk_window_get_size (hexboard->window, &width, &height);

      if (filter == filter_pdf)
        ext = "pdf";
      else if (filter == filter_png)
        ext = "png";
      else if (filter == filter_svg)
        ext = "svg";

      successp = hexboard_save_as_image (HEXBOARD(hexboard), filename, ext, width, height);
      if (!successp)
        g_message (_("An error ocurred while export the board."));

      g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, _("Board was exported to %s."), filename);
      g_free (filename);
    }
  gtk_widget_destroy (dialog);
}
Пример #6
0
/**
 * windows resize funtion
*/
static gboolean
resize_window (GtkWidget      *widget,
              GdkEventMotion *mev)
{
	int w,h;
	if(isFullSreen)
		gdk_window_get_size(widget->window,&w,&h);
	else {
		w = DEFAULT_WIDTH;	
		h = DEFAULT_HEIGHT;	
	}
		
	if(w!=window_w && h!=window_h){
		window_w = w;
		window_h = h;

		surface = cairo_surface_create_similar (
          surface, 
          CAIRO_CONTENT_COLOR_ALPHA,
          w, h);
		gtk_widget_set_size_request(widget,w,h);
		
		CleanPaint();
	}

  /* tell the canvas widget that it needs to redraw itself */
 	 gtk_widget_queue_draw (widget);
  return FALSE;
}
Пример #7
0
//do_draw will be executed in a separate thread whenever we would like to update
//our animation
void *do_draw(void * user_data){
	 //return false;
    currently_drawing = 1;

	 GtkWidget  * widget = (GtkWidget * ) user_data;

    int width, height;
    gdk_threads_enter();
    //gdk_drawable_get_size(canvas, &width, &height);
    gdk_window_get_size(widget->window,&width,&height);

    //cairo_t * cr = gdk_cairo_create (widget->window);
	 gdk_threads_leave();    

    //create a gtk-independant surface to draw on
    cairo_surface_t *cst = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
    cairo_t *cr = cairo_create(cst);
 	 


    // all drawing here 
    cairo_set_source_rgb (cr, 0.0,0.0,0.0);
	 cairo_paint (cr);

    //do some time-consuming drawing
    static int i = 0;
    ++i; i = i % 300;   //give a little movement to our animation

    int j,k;
    for(k=0; k<100; ++k){   //lets just redraw lots of times to use a lot of proc power
        for(j=0; j < 1000; ++j){
            cairo_set_source_rgb (cr, (double)j/1000.0, (double)j/1000.0, 1.0 - (double)j/1000.0);
            cairo_move_to(cr, i,j/2); 
            cairo_line_to(cr, i+100,j/2);
            cairo_stroke(cr);
        }
    }
    cairo_destroy(cr);


    //When dealing with gdkPixmap's, we need to make sure not to
    //access them from outside gtk_main().
    gdk_threads_enter();

    cairo_t *cr_pixmap = gdk_cairo_create(pixmap);
    cairo_set_source_surface (cr_pixmap, cst, 0, 0);
    cairo_paint(cr_pixmap);
    cairo_destroy(cr_pixmap);

    gdk_threads_leave();

	 //    cairo_surface_destroy(cst);
	 printf(":%d",i);

	 if(dtime!=time(NULL)) { printf("%d %d\n",(int) time(NULL),d_fps); dtime = time(NULL) ; d_fps = 1; } else { d_fps++; }

    currently_drawing = 0;

    return NULL;
}
Пример #8
0
void WinDraw_InitWindowSize(WORD width, WORD height)
{
	static BOOL inited = FALSE;

	if (!inited) {
		GdkWindow *t, *root = window->window;

		while ((t = gdk_window_get_parent(root)) != 0)
			root = t;
		gdk_window_get_size(root, &root_width, &root_height);
		inited = TRUE;
	}

	gdk_window_get_position(window->window, &winx, &winy);

	winw = width;
	winh = height;

	if (root_width < winw)
		winx = (root_width - winw) / 2;
	else if (winx < 0)
		winx = 0;
	else if ((winx + winw) > root_width)
		winx = root_width - winw;
	if (root_height < winh)
		winy = (root_height - winh) / 2;
	else if (winy < 0)
		winy = 0;
	else if ((winy + winh) > root_height)
		winy = root_height - winh;
}
Пример #9
0
void
menu_calc_popup_position (GtkMenu *menu, gint *x_ret, gint *y_ret,
                          gboolean *push_in,
                          gpointer data)
{
   GdkWindow *window = data;
   gint x = 0, y = 0, w = 0, h = 0, cursor_x = 0, cursor_y = 0;
   GdkModifierType mask;

   g_return_if_fail (x_ret && y_ret);
   g_return_if_fail (window);

   gdk_window_get_pointer (window, &cursor_x, &cursor_y, &mask);

   gdk_window_get_origin (window, &x, &y);
   gdk_window_get_size (window, &w, &h);

   if (cursor_x < 0 || cursor_x > w || cursor_y < 0 || cursor_y > h)
   {
      *x_ret = x + w / 2;
      *y_ret = y + h / 2;
   } else {
      *x_ret = x + cursor_x;
      *y_ret = y + cursor_y;
   }
}
Пример #10
0
void create_server_pixmap (GtkWidget *window, struct pixmap *stype, 
                                   int n, GdkPixmap **pix, GdkBitmap **mask) {
  GdkGC *white_gc;
  int hb, wb, hs, ws;

  if (!GTK_WIDGET_REALIZED (window))
    gtk_widget_realize (window);

  gdk_window_get_size (buddy_pix[1].pix, &wb, &hb);
  gdk_window_get_size (stype->pix, &ws, &hs);

  *pix  = gdk_pixmap_new (window->window, wb + ws, MAX (hs, hb), -1);
  *mask = gdk_pixmap_new (window->window, wb + ws, MAX (hs, hb), 1);

  white_gc = window->style->base_gc[GTK_STATE_NORMAL];

  if (!masks_gc) {
    masks_gc = gdk_gc_new (*mask);
    gdk_gc_set_exposures (masks_gc, FALSE);
  }

  mask_pattern.pixel = 0;
  gdk_gc_set_foreground (masks_gc, &mask_pattern);
  gdk_draw_rectangle (*mask, masks_gc, TRUE, 0, 0, -1, -1);

  mask_pattern.pixel = 1;
  gdk_gc_set_foreground (masks_gc, &mask_pattern);

  if (n) {
    ensure_buddy_pix (window, n);

    gdk_gc_set_clip_origin (white_gc, 0, 0);
    gdk_gc_set_clip_mask (white_gc, buddy_pix[n].mask);
    gdk_draw_pixmap (*pix, white_gc, buddy_pix[n].pix, 0, 0, 0, 0, wb, hb);

    gdk_draw_pixmap (*mask, masks_gc, buddy_pix[n].mask, 0, 0, 0, 0, wb, hb);
  }

  gdk_gc_set_clip_origin (white_gc, wb, 0);
  gdk_gc_set_clip_mask (white_gc, stype->mask);
  gdk_draw_pixmap (*pix, white_gc, stype->pix, 0, 0, wb, 0, ws, hs);

  gdk_draw_pixmap (*mask, masks_gc, stype->mask, 0, 0, wb, 0, ws, hs);

  gdk_gc_set_clip_origin (white_gc, 0, 0);
  gdk_gc_set_clip_mask (white_gc, NULL);
}
Пример #11
0
static GdkPixmap *
scale_pixmap (GdkWindow *window, GdkPixmap *pixmap, gdouble scale_x, gdouble scale_y)
{
  GdkGC *gc;
  GdkColormap *colormap;
  GdkColorContext *cc;
  GdkVisual *visual;
  GdkImage *image;
  GdkPixmap *new_pixmap;
  gint x, y, width, height, new_width, new_height;

  if(!pixmap) return NULL;
  if(!window) return NULL;

  gc = gdk_gc_new(pixmap);
  colormap = gdk_colormap_get_system ();
  visual = gdk_visual_get_system ();
  cc = gdk_color_context_new(visual, colormap);
  gdk_window_get_size(pixmap, &width, &height);

  if(scale_x == 1.0 && scale_y == 1.0){
    new_pixmap = gdk_pixmap_new(window, width, height, -1);
    gdk_draw_pixmap(new_pixmap,
                    gc,
                    pixmap,
                    0, 0,
                    0, 0,
                    width, height);
    return new_pixmap;
  }

  new_width = roundint(width * scale_x);
  new_height = roundint(height * scale_y);
  new_pixmap = gdk_pixmap_new(window, new_width, new_height, -1);

  image = gdk_image_get(pixmap,
                        0, 0,
                        width, height);

  for(x = 0; x < new_width; x++){
    for(y = 0; y < new_height; y++){
      GdkColor color;
      gint px, py;

      px = MIN(roundint(x / scale_x), width - 1);
      py = MIN(roundint(y / scale_y), height - 1);

      color.pixel = gdk_image_get_pixel(image, px, py);
      gdk_color_context_query_color(cc, &color);

      gdk_gc_set_foreground(gc, &color);
      gdk_draw_point(new_pixmap, gc, x, y);
    }
  }

  gdk_image_destroy(image);
  gdk_color_context_free(cc);
  return new_pixmap;
}
Пример #12
0
static void
gimv_zalbum_update_max_cell_size (GimvZAlbum *album, GimvZAlbumCell *cell)
{
   gint pix_width, pix_height, iwidth, iheight, cell_width, cell_height;
   gint string_area_width, str_width, str_height;

   g_return_if_fail (album);
   g_return_if_fail (cell);

   if (cell->ipix) {
      gdk_window_get_size (cell->ipix, &iwidth, &iheight);
   } else {
      iwidth  = album->max_pix_width;
      iheight = album->max_pix_height;
   }

   album->max_pix_width  = MAX(album->max_pix_width,  iwidth);
   album->max_pix_height = MAX(album->max_pix_height, iheight);

   if (cell->name) {
      get_string_area_size (album, cell->name,
                            &str_width, &str_height, NULL);
      /*
      str_width  = gdk_string_width (font, cell->name);
      str_height = gdk_string_height (font, cell->name);
      */
   } else {
      str_width  = 0;
      str_height = 0;
   }

   switch (album->label_pos) {
   case GIMV_ZALBUM_CELL_LABEL_LEFT:
   case GIMV_ZALBUM_CELL_LABEL_RIGHT:
   {
      pix_width  = album->max_pix_width;
      pix_height = album->max_pix_height;
      string_area_width = str_width + LABEL_HPADDING;

      break;
   }
   case GIMV_ZALBUM_CELL_LABEL_BOTTOM:
   case GIMV_ZALBUM_CELL_LABEL_TOP:
   default:
      pix_width  = iwidth;
      pix_height = iheight;
      string_area_width = 0;

      break;
   }

   cell_width  = pix_width + string_area_width;
   cell_height = MAX (pix_height, str_height);

   album->max_cell_width 
      = MAX (MAX(album->max_cell_width,  cell_width), album->max_pix_width);
   album->max_cell_height
      = MAX (MAX(album->max_cell_height, cell_height), album->max_pix_height);
}
Пример #13
0
/* configure_event:
 * React to a configure event, perhaps changing the backing image size. */
void configure_event(GtkWidget *widget, GdkEvent *event, gpointer data) {
    if (darea) drawable = darea->window;
    gdk_window_get_size(drawable, &width, &height);
    if (!backing_image || backing_image->width != width || backing_image->height != height)
        make_backing_image();

    update_window();
}
Пример #14
0
static void
_preset_popup_posistion(GtkMenu *menu, gint *x,gint *y,gboolean *push_in, gpointer data)
{
  gint w,h;
  gint ww,wh;
  GtkRequisition requisition;
  gdk_window_get_size(GTK_WIDGET(data)->window,&w,&h);
  gdk_window_get_size(dt_ui_main_window(darktable.gui->ui)->window,&ww,&wh);
  gdk_window_get_origin (GTK_WIDGET(data)->window, x, y);

  gtk_widget_size_request (GTK_WIDGET (menu), &requisition);

  /* align left panel popupmenu to right edge */
  if (*x < ww/2)
    (*x)+=w-requisition.width;

  (*y)+=GTK_WIDGET(data)->allocation.height;
}
Пример #15
0
int pixmap_width (GdkPixmap *pixmap) {
  int height, width;

  if (!pixmap)
    return 0;

  gdk_window_get_size (pixmap, &width, &height);
  return width;
}
Пример #16
0
static void
gtk_ui_popup_dialog(int index) {
	GtkWidget *popup;
	int tx, ty, tw, th;
	int px, py, pw, ph;

	popup = dialogs[index];

	gdk_window_get_origin(toplevel->window, &tx, &ty);
	gdk_window_get_size(toplevel->window, &tw, &th);
	gdk_window_get_size(popup->window, &pw, &ph);
	px = tx + (tw - pw) / 2;
	py = ty + (th - ph) / 2;
	gtk_window_set_position(GTK_WINDOW(popup), GTK_WIN_POS_NONE);
	gtk_widget_set_uposition(popup, px, py);
	gtk_widget_show_all(popup);
	gtk_main();
}
Пример #17
0
static void save_options()
{
   char filename[256];
   FILE *fd;
   int i, numchans;
   int x,y,w,h;

   sprintf(filename, "%s/%s", getenv("HOME"), ".studio");
   chk_dir(filename);
   sprintf(filename, "%s/%s/%s.tv-conf",getenv("HOME"),".studio", tv_config_file);
   fd = fopen(filename, "w");
   if (!fd)
   {
      printf("WARNING: cannot open config file: %s\n", filename);
      return;
   }

   gdk_window_get_size(window->window, &w, &h);
   gdk_window_get_origin(window->window, &x, &y);
   fprintf(fd, "[StudioTV]\n");
   fprintf(fd, "default_port = %d\n", port);
   fprintf(fd, "default_width = %d\n", w);
   fprintf(fd, "default_height = %d\n", h);
   fprintf(fd, "default_x = %d\n", x);
   fprintf(fd, "default_y = %d\n", y);

   fprintf(fd, "default_encoding_id = %d\n", encoding_id);

#ifdef OSS
   fprintf(fd, "default_mixer_dev = %s\n", mixer_dev);
   fprintf(fd, "default_audio_src = %d\n", audio_src);
#endif

#ifdef HAVE_LIRC
   fprintf(fd, "default_lirc_dev = %s\n", lirc_dev);
   for(i=0;i<RC_NUM_KEYS;i++)
      fprintf(fd, "remote_control_key_%d = %s\n",
         i, remote_buttons[i]);
#endif

   if (channels)
   {
      numchans = 0;
      for (i=0;channels[i];i++)
      {
         fprintf(fd, "channel_frequency_%d = %d\n", i, channels[i]->frequency);
         fprintf(fd, "channel_name_%d = %s\n", i, channels[i]->name);
         numchans = i;
      }
      fprintf(fd, "num_chans = %d\n", numchans+1);
   }

   fclose(fd);

   if (verbose) g_print("Configuration saved to %s\n", filename);
}
Пример #18
0
/** \brief concatenate two pixmaps
 *
 * horizontal concatenation
 * @param window
 * @param dest destination pixmap
 * @param s1 first pixmap
 * @param s2 second pixmap
 * @returns dest for convenience
 */
struct pixmap* cat_pixmaps (GtkWidget *window, struct pixmap *dest, struct pixmap* s1, struct pixmap* s2)
{
  GdkGC *white_gc;
  int h1, w1, h2, w2;

  if (!GTK_WIDGET_REALIZED (window))
    gtk_widget_realize (window);

  gdk_window_get_size (s1->pix, &w1, &h1);
  gdk_window_get_size (s2->pix, &w2, &h2);

  dest->pix  = gdk_pixmap_new (window->window, w1 + w2, MAX (h1, h2), -1);
  dest->mask = gdk_pixmap_new (window->window, w1 + w2, MAX (h1, h2), 1);

  white_gc = window->style->base_gc[GTK_STATE_NORMAL];

  if (!masks_gc) {
    masks_gc = gdk_gc_new (dest->mask);
    gdk_gc_set_exposures (masks_gc, FALSE);
  }

  mask_pattern.pixel = 0;
  gdk_gc_set_foreground (masks_gc, &mask_pattern);
  gdk_draw_rectangle (dest->mask, masks_gc, TRUE, 0, 0, -1, -1);

  mask_pattern.pixel = 1;
  gdk_gc_set_foreground (masks_gc, &mask_pattern);

  gdk_gc_set_clip_origin (white_gc, 0, 0);
  gdk_gc_set_clip_mask (white_gc, s1->mask);
  gdk_draw_pixmap (dest->pix, white_gc, s1->pix, 0, 0, 0, 0, w1, h1);
  gdk_draw_pixmap (dest->mask, masks_gc, s1->mask, 0, 0, 0, 0, w1, h1);

  gdk_gc_set_clip_origin (white_gc, w1, 0);
  gdk_gc_set_clip_mask (white_gc, s2->mask);
  gdk_draw_pixmap (dest->pix, white_gc, s2->pix, 0, 0, w1, 0, w2, h2);
  gdk_draw_pixmap (dest->mask, masks_gc, s2->mask, 0, 0, w1, 0, w2, h2);

  gdk_gc_set_clip_origin (white_gc, 0, 0);
  gdk_gc_set_clip_mask (white_gc, NULL);

  return dest;
}
Пример #19
0
Файл: xqf-ui.c Проект: IR4T4/xqf
int calculate_clist_row_height (GtkWidget *clist, GdkPixmap *pixmap) {
	int pix_h, pix_w;
	int height;

	gdk_window_get_size (pixmap, &pix_w, &pix_h);

	height=pix_h+1;

	return height;
}
Пример #20
0
/* The following is based on a similar routine found in most 
 * GTK2 engines, I have no idea which one came up with it first...
 */
gboolean
sanitize_parameters(GtkStyle * style,
  	            GdkWindow * window,
	            gint * width,
	            gint * height)
{
  if (!style) return FALSE;
  if (!window) return FALSE;

  if ((width) && (height)) {
    if ((*width == -1) && (*height == -1))
      gdk_window_get_size(window, width, height);
    else if (*width == -1)
      gdk_window_get_size(window, width, NULL);
    else if (*height == -1)
      gdk_window_get_size(window, NULL, height);  
  }
  return TRUE;  
}
Пример #21
0
void show_splash()
{
	gint x, y;
	GdkWindow *root_win = NULL;
	gint root_x, root_y;
	GtkWidget *vbox;
	GtkWidget *label;
	GtkWidget *frame;

#ifdef __WIN32__
	root_x = GetSystemMetrics(SM_CXSCREEN);
	root_y = GetSystemMetrics(SM_CYSCREEN);
#else
	root_win = gdk_window_foreign_new (GDK_ROOT_WINDOW ());
	gdk_window_get_size(root_win, &root_x, &root_y);
#endif

	x = (root_x - SPLASH_WIDTH) /2;
	y = (root_y - SPLASH_HEIGHT) /2;

	splash = gtk_window_new (GTK_WINDOW_POPUP);
	gtk_widget_set_size_request(splash, SPLASH_WIDTH, SPLASH_HEIGHT);
	gtk_window_move(GTK_WINDOW(splash), x, y);

	frame = gtk_frame_new(NULL);
	gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_OUT);
	gtk_container_add (GTK_CONTAINER (splash), frame);

	vbox = gtk_vbox_new(FALSE, 0);
	gtk_container_add (GTK_CONTAINER (frame), vbox);


	label = gtk_label_new(NULL);
	gtk_label_set_markup(GTK_LABEL(label), "<span size=\"x-large\" foreground=\"#a04040\" weight=\"ultrabold\">Welcome to EBView</span>");
	gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(label), TRUE, TRUE, 0);

	label = gtk_label_new(_("Loading dictionary..."));
	gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(label), TRUE, TRUE, 0);

	splash_label = gtk_label_new("");
	gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(splash_label), TRUE, TRUE, 0);

	gtk_widget_show_all(splash);

	loading_dictgroup = 1;

	tag_timeout = gtk_timeout_add(200, load_watch_thread, NULL);
	load_dictgroup_background();

	gtk_main();
}
Пример #22
0
void ensure_buddy_pix (GtkWidget *window, int n) {
  int width, height;
  GdkGC *white_gc;
  int pri;
  int sec;

  if (!buddy_pix[1].pix)	/* not initialized */
    return;

  if (n < 0 || n > 9 || buddy_pix[n].pix)
    return;

  sec = ((n & 0x04) != 0)? 0x04 : 0x02;
  pri = n & ~sec;

  ensure_buddy_pix (window, pri);

  if (!pri || !sec)
    return;

  if (!GTK_WIDGET_REALIZED (window))
    gtk_widget_realize (window);

  gdk_window_get_size (buddy_pix[1].pix, &width, &height);

  buddy_pix[n].pix = gdk_pixmap_new (window->window, width, height, -1);
  buddy_pix[n].mask = gdk_pixmap_new (window->window, width, height, 1);

  white_gc = window->style->white_gc;

  if (!masks_gc) {
    masks_gc = gdk_gc_new (buddy_pix[n].mask);
    gdk_gc_set_exposures (masks_gc, FALSE);
  }

  gdk_gc_set_foreground (masks_gc, &window->style->white);

  gdk_draw_pixmap (buddy_pix[n].pix, white_gc, buddy_pix[pri].pix,
                                                   0, 0, 0, 0, width, height);
  gdk_draw_pixmap (buddy_pix[n].mask, masks_gc, buddy_pix[pri].mask,
                                                   0, 0, 0, 0, width, height);

  gdk_gc_set_clip_mask (white_gc, buddy_pix[sec].mask);
  gdk_draw_pixmap (buddy_pix[n].pix, white_gc, buddy_pix[sec].pix,
                                                   0, 0, 0, 0, width, height);
  gdk_gc_set_clip_mask (white_gc, NULL);

  gdk_gc_set_clip_mask (masks_gc, buddy_pix[sec].mask);
  gdk_draw_rectangle (buddy_pix[n].mask, masks_gc, TRUE, 0, 0, width, height);
  gdk_gc_set_clip_mask (masks_gc, NULL);
}
Пример #23
0
static void
view_resize (View *view)
{
  gint width, height;
  gdk_window_get_size (GTK_WIDGET(view->context)->window, &width, &height);

  gl_drawing_area_make_current (view->context);

  glViewport(0, 0, width, height);
  glMatrixMode (GL_PROJECTION);
  glLoadIdentity ();
  gluPerspective (45.0, (float)width / (float)height, 0.1, 2500.0);
  glMatrixMode (GL_MODELVIEW);
  glLoadIdentity ();
  glDepthRange (0.1, 2000.0);
}
Пример #24
0
void DrawPixmap(GdkWindow* window, GdkGC* gc,
			 gint dstx, gint dsty, GdkPixmap* pixmap, GdkBitmap* mask)
{
	gint map_w, map_h;

	gdk_window_get_size(pixmap, &map_w, &map_h);

	gdk_gc_set_clip_mask(gc, mask);
	gdk_gc_set_clip_origin(gc, dstx, dsty);

	gdk_draw_pixmap(window, gc, pixmap,
					0,0,			// srcx, srcy
					dstx, dsty,
					map_w, map_h);

	gdk_gc_set_clip_mask(gc, NULL);
}
Пример #25
0
void wxDropSource::PrepareIcon( int action, GdkDragContext *context )
{
    // get the right icon to display
    wxIcon *icon = NULL;
    if ( action & GDK_ACTION_MOVE )
        icon = &m_iconMove;
    else if ( action & GDK_ACTION_COPY )
        icon = &m_iconCopy;
    else
        icon = &m_iconNone;

    GdkBitmap *mask;
    if ( icon->GetMask() )
        mask = icon->GetMask()->GetBitmap();
    else
        mask = NULL;

    GdkPixmap *pixmap = icon->GetPixmap();

    gint width,height;
    gdk_window_get_size (pixmap, &width, &height);

    GdkColormap *colormap = gtk_widget_get_colormap( m_widget );
    gtk_widget_push_visual (gdk_colormap_get_visual (colormap));
    gtk_widget_push_colormap (colormap);

    m_iconWindow = gtk_window_new (GTK_WINDOW_POPUP);
    gtk_widget_set_events (m_iconWindow, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
    gtk_widget_set_app_paintable (GTK_WIDGET (m_iconWindow), TRUE);

    gtk_widget_pop_visual ();
    gtk_widget_pop_colormap ();

    gtk_widget_set_usize (m_iconWindow, width, height);
    gtk_widget_realize (m_iconWindow);

    gtk_signal_connect( GTK_OBJECT(m_iconWindow), "configure_event",
                        GTK_SIGNAL_FUNC(gtk_dnd_window_configure_callback), (gpointer)this );

    gdk_window_set_back_pixmap (m_iconWindow->window, pixmap, FALSE);

    if (mask)
        gtk_widget_shape_combine_mask (m_iconWindow, mask, 0, 0);

    gtk_drag_set_icon_widget( context, m_iconWindow, 0, 0 );
}
Пример #26
0
static gboolean list_motion_notify(GtkWidget *widget, GdkEventMotion *event,
				   gpointer user_data)
{
     gint mx,my;
     gint wx,wy,ww,wh;
     
     gdk_window_get_root_origin(widget->window,&wx,&wy);
     gdk_window_get_size(widget->window,&ww,&wh);
     mx = (gint) (event->x_root);
     my = (gint) (event->y_root);

     /*printf("mouse: <%d,%d>, window: <%d,%d>+<%d,%d>\n",mx,my,wx,wy,ww,wh);*/
     if (mx < wx || mx > wx+ww || my < wy || my > wy+wh)
	  gtk_signal_emit_stop_by_name(GTK_OBJECT(widget),
				       "motion-notify-event");
     return FALSE;
}
Пример #27
0
static void
gtk_ui_make_main_window(int size) {
	GdkWindowHints flags;
	GdkGeometry geom;
	gint winwidth, winheight;

	screensize = size;

	base = gtk_vbox_new(FALSE, 0);
	gtk_container_add(GTK_CONTAINER(toplevel), base);

	menubar = CreateMenuBar();
	gtk_box_pack_start(GTK_BOX(base), menubar, FALSE, FALSE, 0);

	field = CreateDrawingArea(size, size);
	gtk_box_pack_start(GTK_BOX(base), field, FALSE, FALSE, 0);

	gtk_signal_connect(GTK_OBJECT(field), "button-press-event",
			   GTK_SIGNAL_FUNC(button_press), NULL);
	gtk_signal_connect(GTK_OBJECT(field), "button-release-event",
			   GTK_SIGNAL_FUNC(button_release), NULL);
	gtk_signal_connect(GTK_OBJECT(field), "enter-notify-event",
			   GTK_SIGNAL_FUNC(enter_window), NULL);
	gtk_signal_connect(GTK_OBJECT(field), "leave-notify-event",
			   GTK_SIGNAL_FUNC(leave_window), NULL);
	gtk_signal_connect(GTK_OBJECT(field), "expose-event",
			   GTK_SIGNAL_FUNC(redraw_window), NULL);
	gtk_widget_set_events(field, GDK_BUTTON_PRESS_MASK |
			      GDK_BUTTON_RELEASE_MASK |
			      GDK_ENTER_NOTIFY_MASK |
			      GDK_LEAVE_NOTIFY_MASK |
			      GDK_EXPOSURE_MASK);

	gtk_widget_show_all(toplevel);

	gdk_window_get_size(toplevel->window, &winwidth, &winheight);
	geom.min_width = geom.max_width = geom.base_width = winwidth;
	geom.min_height = geom.max_height = geom.base_height = winheight;
	geom.width_inc = geom.height_inc = 0;
	flags = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | GDK_HINT_BASE_SIZE |
		GDK_HINT_RESIZE_INC;
	gdk_window_set_geometry_hints(toplevel->window, &geom, flags);

	gdk_color_parse("white", &white);
	gdk_color_parse("black", &black);
}
Пример #28
0
void
on_window1_size_request(GtkWidget * widget,
			GtkRequisition * requisition, gpointer user_data)
{
	static gint old_h;
	gint w, h;

	if (widget->window == NULL)
		gtk_window_get_default_size(GTK_WINDOW(main_wnd), &w, &h);
	else
		gdk_window_get_size(widget->window, &w, &h);

	if (h == old_h)
		return;
	old_h = h;

	gtk_paned_set_position(GTK_PANED(vpaned), 2 * h / 3);
}
Пример #29
0
static GdkPixmap *
scale_pixmap (GdkWindow *window, GdkPixmap *pixmap, gdouble scale_x, gdouble scale_y)
{
  GdkGC *gc = NULL;
  GdkPixmap *new_pixmap;
  gint width, height, new_width, new_height;
  GdkPixbuf *pixbuf = NULL;
  GdkPixbuf *aux_pixbuf = NULL;

  if(!pixmap) return NULL;
  if(!window) return NULL;

  gdk_window_get_size(pixmap, &width, &height);

  gc = gdk_gc_new(window);

  if(scale_x == 1.0 && scale_y == 1.0){
    new_pixmap = gdk_pixmap_new(window, width, height, -1);
    gdk_draw_pixmap(new_pixmap,
                    gc,
                    pixmap,
                    0, 0,
                    0, 0,
                    width, height);
    gdk_gc_unref(gc);
    return new_pixmap;
  }

  new_width = roundint(width * scale_x);
  new_height = roundint(height * scale_y);

  pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, gdk_drawable_get_colormap(window), 0, 0, 0, 0, width, height);
  aux_pixbuf = gdk_pixbuf_scale_simple(pixbuf, new_width, new_height, GDK_INTERP_BILINEAR);
  new_pixmap = gdk_pixmap_new(pixmap, new_width, new_height, -1);
  gdk_draw_pixbuf(new_pixmap, gc, aux_pixbuf, 0, 0, 0, 0, new_width, new_height, GDK_RGB_DITHER_MAX, 0, 0);

  gdk_pixbuf_unref(pixbuf);
  gdk_pixbuf_unref(aux_pixbuf);

  gdk_gc_unref(gc);

  return new_pixmap;
}
Пример #30
0
void UpdateDialog(UIDialog* dialog, GdkRectangle* rect)
{
	gint window_w, window_h;
	GdkRectangle window_rect;

	if( dialog->window->window != NULL )
	{
		if( rect == NULL )
		{
			gdk_window_get_size(dialog->window->window, &window_w, &window_h);
			window_rect.x = 0;
			window_rect.y = 0;
			window_rect.width = window_w;
			window_rect.height = window_h;
			rect = &window_rect;
		}
		gtk_widget_draw(dialog->window, rect);
	}
}