static void
task_manager_dalog_disp_preview (TaskManagerDialog *dialog) 
{
  gint height;
  gint width;
  gint data_length;

  gint win_x,win_y,win_width,win_height;
  GtkAllocation allocation;
  GList * iter = NULL;
  gint win_count = 0;
  int i = 0;
  TaskManagerDialogPrivate * priv = GET_PRIVATE (dialog);
  GtkPositionType pos_type = awn_applet_get_pos_type (priv->applet);
  GtkOrientation current_orientation;
  gdouble scale;
  glong total_width = 0;
  glong screen_width = gdk_screen_get_width (gdk_screen_get_default ());
  glong screen_height = gdk_screen_get_height (gdk_screen_get_default ());
  
  
  current_orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (priv->items_box));
  if ( (current_orientation == GTK_ORIENTATION_VERTICAL) &&
      (( pos_type == GTK_POS_BOTTOM) || (pos_type == GTK_POS_TOP)) )
  {
    gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->items_box),GTK_ORIENTATION_HORIZONTAL);
  }
  else if ( (current_orientation == GTK_ORIENTATION_HORIZONTAL)&&
      (( pos_type == GTK_POS_LEFT) || (pos_type == GTK_POS_RIGHT)) )
  {
    gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->items_box),GTK_ORIENTATION_VERTICAL);
  }
  for (iter = g_list_first(priv->children); iter; iter=iter->next)
  {
    if (TASK_IS_WINDOW(iter->data))
    {
      win_count++;
    }
  }
  if (priv->data)
  {
    g_free (priv->data);
  }
  data_length =  win_count*6 +1;
  priv->data = g_new0 (long, data_length);
  priv->data[0] = (long) win_count;
  scale = priv->dialog_scale;

scaled_down:
  total_width = 0;
  if (screen_width && screen_height)
  {
    for (iter = g_list_first(priv->children); iter; iter=iter->next)
    {
      if (TASK_IS_WINDOW(iter->data))
      {
        wnck_window_get_geometry (task_window_get_window (iter->data),
                                  &win_x,
                                  &win_y,
                                  &win_width,
                                  &win_height);

        gtk_widget_get_allocation (GTK_WIDGET(iter->data), &allocation);
        if ((pos_type == GTK_POS_TOP) || (pos_type == GTK_POS_BOTTOM))
        {
          /*conditional operator alert*/
          height = gdk_screen_height () / (win_count?1.0/scale:1.0/scale+(win_count-2));

          width = ((float)win_width) / ((float)win_height) * height;
          total_width = total_width + width;
          if (total_width > screen_width * 0.9)
          {
            scale = scale * 0.9;
            goto scaled_down;
          }
        }
        else
        {
          /*conditional operator alert*/
          width = gdk_screen_width () / (win_count<4?1.0/scale+1:1.0/scale+1+(win_count-3));
          height = ((float)win_height) / ((float)win_width) * width;
          total_width = total_width + height;
          if (total_width > screen_height * 0.9)
          {
            scale = scale * 0.9;
            goto scaled_down;
          }
        }
      }
    }
  }
  
  for (iter = g_list_first(priv->children); iter; iter=iter->next)
  {
    if (TASK_IS_WINDOW(iter->data))
    {
      wnck_window_get_geometry (task_window_get_window (iter->data),
                                &win_x,
                                &win_y,
                                &win_width,
                                &win_height);

      gtk_widget_get_allocation (GTK_WIDGET(iter->data), &allocation);
      gtk_widget_set_tooltip_text (GTK_WIDGET (iter->data),
                                   task_window_get_name(TASK_WINDOW(iter->data)));
      /* Change these calculations. Ultimately we can be much smarter about
       layout.  After a certain point it will involve adding some more
       containers in our container....*/
      if ((pos_type == GTK_POS_TOP) || (pos_type == GTK_POS_BOTTOM))
      {
        /*conditional operator alert*/
        height = gdk_screen_height () / (win_count?1.0/scale:1.0/scale+(win_count-2));

        width = ((float)win_width) / ((float)win_height) * height;
        gtk_widget_set_size_request (GTK_WIDGET(iter->data), width, height);
      }
      else
      {
        /*conditional operator alert*/
        width = gdk_screen_width () / (win_count<4?1.0/scale+1:1.0/scale+1+(win_count-3));
        height = ((float)win_height) / ((float)win_width) * width;
        gtk_widget_set_size_request (GTK_WIDGET(iter->data), width, height);
      }      	
	    priv->data[i*6+1] = (long) 5;
	    priv->data[i*6+2] = (long) task_window_get_xid (TASK_WINDOW(iter->data));
	    priv->data[i*6+3] = (long) allocation.x+4;
	    priv->data[i*6+4] = (long) allocation.y+4;
	    priv->data[i*6+5] = (long) width-8;
	    priv->data[i*6+6] = (long) height-8;
      i++;
    }
  }

	gdk_property_change ((GTK_WIDGET(dialog))->window, 
					priv->kde_a,
 					priv->kde_a,
					32, 
					GDK_PROP_MODE_REPLACE, 
					(guchar*) priv->data,
					data_length);
}
int QDesktopWidget::height()
{
    return gdk_screen_get_height(gdk_screen_get_default());
}
char *iupdrvGetGlobal(const char *name)
{
  if (iupStrEqual(name, "VIRTUALSCREEN"))
  {
    GdkScreen *screen = gdk_screen_get_default();
    GdkWindow *root = gdk_screen_get_root_window(gdk_screen_get_default());
    int x = 0;
    int y = 0;
    int w = gdk_screen_get_width(screen);
    int h = gdk_screen_get_height(screen);
    gdk_window_get_root_origin(root, &x, &y);
    return iupStrReturnStrf("%d %d %d %d", x, y, w, h);
  }
  if (iupStrEqual(name, "MONITORSINFO"))
  {
    int i;
#if GTK_CHECK_VERSION(3, 22, 0)
    GdkDisplay *display = gdk_display_get_default();
    int monitors_count = gdk_display_get_n_monitors(display);
#else
    GdkScreen *screen = gdk_screen_get_default();
    int monitors_count = gdk_screen_get_n_monitors(screen);
#endif
    char *str = iupStrGetMemory(monitors_count * 50);
    char* pstr = str;
    GdkRectangle rect;

    for (i = 0; i < monitors_count; i++)
    {
#if GTK_CHECK_VERSION(3, 22, 0)
      GdkMonitor* monitor = gdk_display_get_monitor(display, i);
      gdk_monitor_get_geometry(monitor, &rect);
#else
      gdk_screen_get_monitor_geometry(screen, i, &rect);
#endif
      pstr += sprintf(pstr, "%d %d %d %d\n", rect.x, rect.y, rect.width, rect.height);
    }

    return str;
  }
  if (iupStrEqual(name, "MONITORSCOUNT"))
  {
#if GTK_CHECK_VERSION(3, 22, 0)
    GdkDisplay *display = gdk_display_get_default();
    int monitors_count = gdk_display_get_n_monitors(display);
#else
    GdkScreen *screen = gdk_screen_get_default();
    int monitors_count = gdk_screen_get_n_monitors(screen);
#endif
    return iupStrReturnInt(monitors_count);
  }
  if (iupStrEqual(name, "TRUECOLORCANVAS"))
  {
    return iupStrReturnBoolean(gdk_visual_get_best_depth() > 8);
  }
  if (iupStrEqual(name, "UTF8MODE"))
  {
    return iupStrReturnBoolean(iupgtkStrGetUTF8Mode());
  }
  if (iupStrEqual(name, "UTF8AUTOCONVERT"))
  {
    return iupStrReturnBoolean(!iupgtkStrGetUTF8Mode());
  }
#ifndef WIN32
  if (iupStrEqual(name, "EXEFILENAME"))
  {
    char* argv0 = IupGetGlobal("ARGV0");
    if (argv0)
    {
      char* exefilename = realpath(argv0, NULL);
      if (exefilename)
      {
        char* str = iupStrReturnStr(exefilename);
        free(exefilename);
        return str;
      }
    }
  }
#endif
  if (iupStrEqual(name, "SHOWMENUIMAGES"))
  {
    gboolean menu_images;
    g_object_get (gtk_settings_get_default (), "gtk-menu-images", &menu_images, NULL);
    return iupStrReturnBoolean(menu_images);
  }
  return NULL;
}
示例#4
0
void budgie_popover_present(BudgiePopover *self,
                            GtkWidget *parent,
                            GdkEvent *event)
{
        GtkWidget *real_parent;
        GdkWindow *parent_window;
        gint x, y, tx, ty, rx, margin;
        GdkScreen *screen;
        GtkAllocation alloc, our_alloc;
        GdkDeviceManager *manager;
        gint32 time;

        if (event && event->type == GDK_BUTTON_PRESS) {
                x = event->button.x;
                y = event->button.y;
        } else if (event && event->type == GDK_TOUCH_END) {
                x = event->touch.x;
                y = event->touch.y;
        }

        if (gtk_widget_get_visible(GTK_WIDGET(self))) {
                budgie_popover_hide(self);
                return;
        }
        if (!gtk_widget_get_realized(GTK_WIDGET(self)))
                gtk_widget_realize(GTK_WIDGET(self));

        /* Get position of parent widget on screen */
        real_parent = gtk_widget_get_toplevel(parent);
        parent_window = gtk_widget_get_window(real_parent);
        gdk_window_get_position(parent_window, &x, &y);
        gtk_widget_translate_coordinates(parent, real_parent, x, y, &tx, &ty);

        gtk_widget_get_allocation(parent, &alloc);
        gtk_widget_get_allocation(GTK_WIDGET(self), &our_alloc);
        screen = gtk_widget_get_screen(GTK_WIDGET(self));

        /* Ensure we're in a sensible position (under/over) */
        if (ty + our_alloc.height + 11 < gdk_screen_get_height(screen)) {
                self->top = TRUE;
                ty = y+alloc.y+alloc.height;
        } else {
                ty = (y+alloc.y)-our_alloc.height;
                self->top = FALSE;
        }

        /* Ensure widg_x is within bounds */
        if (event) {
                /* Point tip to mouse x,y */
                rx = x;
        } else {
                /* Center the tip when there is no event */
                rx = alloc.x + (alloc.width/2);
        }
        /* ensure margin is accounted for */
        g_object_get(parent, "margin", &margin, NULL);
        tx -= margin;
        rx -= margin;
        if (rx >= our_alloc.width)
                rx = our_alloc.width - 14;
        if (rx <= 14)
                rx = 14;
        self->widg_x = rx;


        gtk_window_move(GTK_WINDOW(self), tx-11, ty);
        gtk_widget_show_all(GTK_WIDGET(self));
        if (event) {
                if (event->type == GDK_BUTTON_PRESS) {
                        self->pointer = event->button.device;
                        time = event->button.time;
                } else {
                        self->pointer = event->touch.device;
                        time = event->touch.time;
                }
        } else {
                manager = gdk_display_get_device_manager(gdk_screen_get_display(screen));
                self->pointer = gdk_device_manager_get_client_pointer(manager);
                time = GDK_CURRENT_TIME;
        }
        self->parent_widget = real_parent;
        self->con_id = g_signal_connect(real_parent, "button-press-event", G_CALLBACK(button_press), self);
        self->con_id = 0;
        /* TODO: Handle keyboard grab too */
        popup_grab_on_window(gtk_widget_get_window(GTK_WIDGET(real_parent)),
                NULL, self->pointer, time);
}
示例#5
0
void initWidgets(void)
{
	guint i;
	GtkWidget *hboxWidget = NULL;
	GdkColor color = myTheme.win_bg_color;

	// TODO: Typ okna
	winWidget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_container_set_border_width(GTK_CONTAINER(winWidget), 8);
	gtk_window_set_title(GTK_WINDOW(winWidget), OBS_TITLE);
	gtk_widget_set_size_request(winWidget, myTheme.win_size_width, myTheme.win_size_heigh);
	if (myOptions.composite)
		gdk_color_parse("black", &color);
	gtk_widget_modify_bg(winWidget, GTK_STATE_NORMAL, &color);
	gtk_window_set_decorated(GTK_WINDOW(winWidget), myTheme.win_decor);
	gtk_window_set_skip_taskbar_hint(GTK_WINDOW(winWidget), TRUE);
	gtk_window_set_skip_pager_hint(GTK_WINDOW(winWidget), TRUE);
	GTK_WIDGET_SET_FLAGS(winWidget, GTK_CAN_FOCUS);

	gtk_widget_set_app_paintable(winWidget, TRUE);
	if (myTheme.win_pos == T_WIN_POS_CENTER) /* Window position - center */
		gtk_window_set_position(GTK_WINDOW(winWidget), GTK_WIN_POS_CENTER);
	else if (myTheme.win_pos == T_WIN_POS_CUSTOM) { /* Window position - custom */
		gtk_window_set_position(GTK_WINDOW(winWidget), GTK_WIN_POS_NONE);
		gtk_window_move(GTK_WINDOW(winWidget), myTheme.win_pos_x, myTheme.win_pos_y);
	}

	if (myTheme.win_size == T_WIN_SIZE_FULLSCREEN) /* Window size - fullscreen */
		gtk_window_resize(GTK_WINDOW(winWidget), gdk_screen_get_width(gdk_screen_get_default()), gdk_screen_get_height(gdk_screen_get_default()));
	else if (myTheme.win_size == T_WIN_SIZE_CUSTOM) /* Window size - custom */
		gtk_window_resize(GTK_WINDOW(winWidget), myTheme.win_size_width, myTheme.win_size_heigh);

	g_signal_connect(winWidget, "destroy", G_CALLBACK(onDestroy), NULL);
	g_signal_connect(winWidget, "key_press_event", G_CALLBACK(onKeyPress), NULL);
	g_signal_connect(winWidget, "window_state_event", G_CALLBACK(onWindowStateChange), NULL);
	g_signal_connect(winWidget, "show", G_CALLBACK(onWindowShow), NULL);

	if (myOptions.composite) {
		if (gtk_widget_is_composited(winWidget)) {
			printMessage(MSG_VERB, "Compositing enabled.\n");
			g_signal_connect(winWidget, "expose_event", G_CALLBACK(onExpose), NULL);
			g_signal_connect(winWidget, "screen-changed", G_CALLBACK(onScreenChanged), NULL);
			onScreenChanged(winWidget, NULL, NULL);
		} else {
			printMessage(MSG_WARN, "No compositing, enabling rendered effects!\n");
			myOptions.composite = FALSE;
		}

	}
	else {
		printMessage(MSG_VERB,  "Compositing disabled.\n");
	}

	hboxWidget = gtk_hbox_new(FALSE, 0);
	hboxButtonWidget = gtk_hbutton_box_new();
	/*gtk_hbutton_box_set_spacing_default(10);*/

	gtk_box_pack_start(GTK_BOX(hboxWidget), gtk_vbox_new(TRUE, 0), TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(hboxWidget), hboxButtonWidget, FALSE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(hboxWidget), gtk_vbox_new(TRUE, 0), TRUE, TRUE, 0);

	gtk_container_add(GTK_CONTAINER(winWidget), hboxWidget);

	if (myOptions.buttons[0] != ACTION_NONE) {
		for (i = 0; i <= 8; i++)
			if (myOptions.buttons[i] != ACTION_NONE)
				addButton(myOptions.buttons[i]);
	}
	else {
		addButton(ACTION_CANCEL);
		addButton(ACTION_LOGOUT);
		addButton(ACTION_RESTART);
		addButton(ACTION_SHUTDOWN);
	}
}
示例#6
0
文件: commands.c 项目: zdia/gnocl
/**
\brief      Screen and Display
            size - returns the physical screen size in millimeters
            geometry -returns the logicaL screen size in pixels
\author     William J Giddings
\date       03-Jan-2010
**/
int gnoclScreenCmd ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] )
{
	static const char *cmd[] = { "size", "geometry", "name", "screens", "composited", "windowList", "toplevels", NULL };
	enum optIdx { SizeIdx, GeometryIdx, NameIdx, ScreensIdx, CompositedIdx, WindowListIdx, TopLevelsIdx };
	int idx;


	if ( objc != 2 )
	{
		Tcl_WrongNumArgs ( interp, 1, objv, "option " );
		return TCL_ERROR;
	}

	if ( Tcl_GetIndexFromObj ( interp, objv[1], cmd, "option", TCL_EXACT, &idx ) != TCL_OK )
	{
		return TCL_ERROR;
	}

	/*
	display = gdk_display_get_default ();
	num_screen = gdk_display_get_n_screens (display);
	displayname = gdk_display_get_name (display);

	*/
	switch ( idx )
	{
		case TopLevelsIdx:
		case WindowListIdx:
			{
				gchar buffer[16];
				GdkScreen *screen;
				GSList *toplevels, *p;
				gchar *widgetName;

				screen = gdk_screen_get_default();

				toplevels = gdk_screen_get_toplevel_windows ( screen );

				/* check to see if the windows are registered with gnocl */
				for ( p = toplevels; p != NULL ; p = p->next )
				{

					/* this returns GDKWindow, not Gtk */
					widgetName = gnoclGetNameFromWidget ( GTK_WIDGET ( p->data ) );
					printf ( "toplevel %s\n", widgetName );

					if ( widgetName != NULL )
					{
						printf ( "toplevel %s\n", widgetName );
					}

					else
					{
						printf ( "Missed this one! List length = %d\n", g_slist_length ( toplevels ) );
						printf ( "toplevel %s\n", widgetName );
					}
				}

				gboolean state = 0;

				sprintf ( &buffer, "%d", state );
				Tcl_SetObjResult ( interp, Tcl_NewIntObj ( state ) );
			}
			break;
		case CompositedIdx:
			{
				gchar buffer[16];
				GdkScreen *screen;
				gboolean state;

				screen = gdk_screen_get_default();
				state =  gdk_screen_is_composited ( screen );

				sprintf ( &buffer, "%d", state );
				Tcl_SetObjResult ( interp, Tcl_NewIntObj ( state ) );
			}
			break;
		case ScreensIdx:
			{
				gchar buffer[16];
				GdkDisplay *display;

				display = gdk_display_get_default ();
				gint   screens =  gdk_display_get_n_screens ( display );

				sprintf ( &buffer, "%d", screens );
				Tcl_SetObjResult ( interp, Tcl_NewStringObj ( buffer, -1 ) );
			}
			break;
		case NameIdx:
			{
				gchar buffer[16];
				GdkDisplay *display;
				const gchar *name;

				display  = gdk_display_get_default ();
				name = gdk_display_get_name ( display );

				sprintf ( &buffer, "%s", name );
				Tcl_SetObjResult ( interp, Tcl_NewStringObj ( buffer, -1 ) );
			}
			break;
		case SizeIdx:
			{
				gchar buffer[16];
				gint width_mm = 0;
				gint height_mm = 0;
				GdkScreen *screen;

				screen = gdk_screen_get_default();
				width_mm = gdk_screen_get_width_mm ( screen );
				height_mm = gdk_screen_get_height_mm ( screen );

				sprintf ( &buffer, "%d %d", width_mm, height_mm );
				Tcl_SetObjResult ( interp, Tcl_NewStringObj ( buffer, -1 ) );
			}

			break;
		case GeometryIdx:
			{
				gchar buffer[16];

				gint width = 0;
				gint height = 0;
				GdkScreen *screen;
				screen = gdk_screen_get_default();

				width = gdk_screen_get_width ( screen );
				height = gdk_screen_get_height ( screen );

				sprintf ( &buffer, "%d %d", width, height );

				Tcl_SetObjResult ( interp, Tcl_NewStringObj ( buffer, -1 ) );
			}

			break;
	}

	return TCL_OK;
}
示例#7
0
void
panel_struts_set_window_hint (PanelToplevel *toplevel)
{
	GtkWidget  *widget;
	PanelStrut *strut;
	int         strut_size;
	int         monitor_x, monitor_y, monitor_width, monitor_height;
	int         screen_width, screen_height;
	int         leftmost, rightmost, topmost, bottommost;

	widget = GTK_WIDGET (toplevel);

	if (!gtk_widget_get_realized (widget))
		return;

	if (!(strut = panel_struts_find_strut (toplevel))) {
		panel_struts_unset_window_hint (toplevel);
		return;
	}

	strut_size = strut->allocated_strut_size;

	screen_width  = gdk_screen_get_width  (strut->screen);
	screen_height = gdk_screen_get_height (strut->screen);

	panel_struts_get_monitor_geometry (strut->screen,
					   strut->monitor,
					   &monitor_x,
					   &monitor_y,
					   &monitor_width,
					   &monitor_height);

        panel_multiscreen_is_at_visible_extreme (strut->monitor,
                                                 &leftmost,
                                                 &rightmost,
                                                 &topmost,
                                                 &bottommost);

	switch (strut->orientation) {
	case PANEL_ORIENTATION_TOP:
		if (monitor_y > 0)
			strut_size += monitor_y;
		if (!topmost) strut_size = 0;
		break;
	case PANEL_ORIENTATION_BOTTOM:
		if (monitor_y + monitor_height < screen_height)
			strut_size += screen_height - (monitor_y + monitor_height);
		if (!bottommost) strut_size = 0;
		break;
	case PANEL_ORIENTATION_LEFT:
		if (leftmost && monitor_x > 0)
			strut_size += monitor_x;
		if (!leftmost) strut_size = 0;
		break;
	case PANEL_ORIENTATION_RIGHT:
		if (monitor_x + monitor_width < screen_width)
			strut_size += screen_width - (monitor_x + monitor_width);
		if (!rightmost) strut_size = 0;
		break;
	default:
		g_assert_not_reached ();
		break;
	}

	panel_xutils_set_strut (gtk_widget_get_window (widget),
				strut->orientation,
				strut_size,
				strut->allocated_strut_start,
				strut->allocated_strut_end);
}
示例#8
0
static void
get_work_area (GdkScreen    *screen,
               GdkRectangle *area)
{
  GdkX11Screen   *x11_screen = GDK_X11_SCREEN (screen);
  Atom            workarea;
  Atom            type;
  Window          win;
  int             format;
  gulong          num;
  gulong          leftovers;
  gulong          max_len = 4 * 32;
  guchar         *ret_workarea = NULL;
  long           *workareas;
  int             result;
  int             disp_screen;
  int             desktop;
  Display        *display;

  display = GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen));
  disp_screen = GDK_SCREEN_XNUMBER (screen);
  workarea = XInternAtom (display, "_NET_WORKAREA", True);

  /* Defaults in case of error */
  area->x = 0;
  area->y = 0;
  area->width = gdk_screen_get_width (screen) / x11_screen->window_scale;
  area->height = gdk_screen_get_height (screen) / x11_screen->window_scale;

  if (!gdk_x11_screen_supports_net_wm_hint (screen,
                                            gdk_atom_intern_static_string ("_NET_WORKAREA")))
    return;

  if (workarea == None)
    return;

  win = XRootWindow (display, disp_screen);
  result = XGetWindowProperty (display,
                               win,
                               workarea,
                               0,
                               max_len,
                               False,
                               AnyPropertyType,
                               &type,
                               &format,
                               &num,
                               &leftovers,
                               &ret_workarea);
  if (result != Success ||
      type == None ||
      format == 0 ||
      leftovers ||
      num % 4 != 0)
    goto out;

  desktop = get_current_desktop (screen);
  if (desktop + 1 > num / 4) /* fvwm gets this wrong */
    goto out;

  workareas = (long *) ret_workarea;
  area->x = workareas[desktop * 4];
  area->y = workareas[desktop * 4 + 1];
  area->width = workareas[desktop * 4 + 2];
  area->height = workareas[desktop * 4 + 3];

  area->x /= x11_screen->window_scale;
  area->y /= x11_screen->window_scale;
  area->width /= x11_screen->window_scale;
  area->height /= x11_screen->window_scale;

out:
  if (ret_workarea)
    XFree (ret_workarea);
}
示例#9
0
void test_background_util()
{
	setup_fixture();


	Test({


	},"test_");
    typedef struct _xfade_data
    {
        //all in seconds.
        gdouble start_time;
        gdouble total_duration;
        gdouble interval;

        cairo_surface_t* fading_surface;
        GdkPixbuf* end_pixbuf;
        gdouble alpha;

        Pixmap pixmap;
    } xfade_data_t;


    GdkScreen *screen = NULL;
    Display *display = NULL;

    screen = gdk_screen_get_default();
    gint number = gdk_screen_get_number(screen);
    gint width = gdk_screen_get_width(screen);
    gint height = gdk_screen_get_height(screen);
    display = XOpenDisplay(gdk_display_get_name(gdk_screen_get_display(screen)));
    Pixmap pixmap = XCreatePixmap (display, RootWindow(display, number), width, height, DefaultDepth(display, number));

    cairo_surface_t *get_surface(Pixmap);
    xfade_data_t *data = g_slice_new(xfade_data_t);
    data->pixmap = pixmap;
    data->fading_surface = get_surface(pixmap);
    data->end_pixbuf = gdk_pixbuf_new_from_file(file1, NULL);

    // _update_rootpmap Successful.
    /* extern void _update_rootpmap(); */
    /* Test({ */
    /*     _update_rootpmap(pixmap); */
    /* }, "_update_rootpmap"); */

    // on_tick Successful.
    /* extern void on_tick(xfade_data_t *data); */
    /* Test({ */
    /*     on_tick(data); */
    /* }, "on_tick"); */

    // draw_background Successful.
    /* extern void draw_background(xfade_data_t *data); */
    /* Test({ */
    /*     draw_background(data); */
    /* }, "draw_background"); */

    g_object_unref(data->end_pixbuf);
    cairo_surface_destroy(data->fading_surface);
    g_free(data);

    // remove_timers Successful.
    /* extern void remove_timers(); */
    /* Test({ */
    /*     remove_timers(); */
    /* }, "remove_timers"); */

    // get_current_picture_path Successful.
    /* extern const char *get_current_picture_path(); */
    /* Test({ */
    /*     get_current_picture_path(); */
    /* }, "get_current_picture_path"); */

    // get_next_picture_index Successful.
    /* extern guint get_next_picture_index(); */
    /* Test({ */
    /*     get_next_picture_index(); */
    /* }, "get_next_picture_index"); */

    // get_next_picture_path Successful.
    /* extern const char *get_next_picture_path(); */
    /* Test({ */
    /*     get_next_picture_path(); */
    /* }, "get_next_picture_path"); */

    // get_xformed_gdk_pixbuf  Succcessful.
    extern GdkPixbuf *get_xformed_gdk_pixbuf(const char *path);
    /* Test({ */
    /*     const gchar *path = get_current_picture_path(); */
    /*     GdkPixbuf *pixbuf = get_xformed_gdk_pixbuf(path); */
    /*     g_object_unref(pixbuf); */
    /* }, "get_xformed_gdk_pixbuf"); */

    // on_bg_duration_tick Successful.
    extern gboolean on_bg_duration_tick(gpointer data);
    Test({
        on_bg_duration_tick(NULL);
    }, "on_bg_duration_tick");
示例#10
0
void
mate_panel_applet_position_menu (GtkMenu   *menu,
			    int       *x,
			    int       *y,
			    gboolean  *push_in,
			    GtkWidget *applet)
{
	GtkAllocation   allocation;
	GtkRequisition  requisition;
#if GTK_CHECK_VERSION(3, 0, 0)
	GdkDevice      *device;
#endif
	GdkScreen      *screen;
	GtkWidget      *parent;
	int             menu_x = 0;
	int             menu_y = 0;
	int             pointer_x;
	int             pointer_y;

	parent = gtk_widget_get_parent (applet);

	g_return_if_fail (PANEL_IS_WIDGET (parent));

	screen = gtk_widget_get_screen (applet);

#if GTK_CHECK_VERSION (3, 0, 0)
	gtk_widget_get_preferred_size (GTK_WIDGET (menu), &requisition, NULL);
#else
	gtk_widget_size_request (GTK_WIDGET (menu), &requisition);
#endif

	gdk_window_get_origin (gtk_widget_get_window (applet), &menu_x, &menu_y);
#if GTK_CHECK_VERSION (3, 0, 0)
	device = gdk_device_manager_get_client_pointer (gdk_display_get_device_manager (gtk_widget_get_display (applet)));
	gdk_window_get_device_position(gtk_widget_get_window (applet), device, &pointer_x, &pointer_y, NULL);
#else
	gtk_widget_get_pointer (applet, &pointer_x, &pointer_y);
#endif
	gtk_widget_get_allocation (applet, &allocation);

	if (!gtk_widget_get_has_window (applet)) {
		menu_x += allocation.x;
		menu_y += allocation.y;
	}

	if (PANEL_WIDGET (parent)->orient == GTK_ORIENTATION_HORIZONTAL) {
		if (gtk_widget_get_direction (GTK_WIDGET (menu)) != GTK_TEXT_DIR_RTL) {
			if (pointer_x < allocation.width &&
			    requisition.width < pointer_x)
				menu_x += MIN (pointer_x,
					       allocation.width - requisition.width);
		} else {
			menu_x += allocation.width - requisition.width;
			if (pointer_x > 0 && pointer_x < allocation.width &&
			    pointer_x < allocation.width - requisition.width) {
				menu_x -= MIN (allocation.width - pointer_x,
					       allocation.width - requisition.width);
			}
		}
		menu_x = MIN (menu_x, gdk_screen_get_width (screen) - requisition.width);

		if (menu_y > gdk_screen_get_height (screen) / 2)
			menu_y -= requisition.height;
		else
			menu_y += allocation.height;
	} else {
		if (pointer_y < allocation.height &&
		    requisition.height < pointer_y)
			menu_y += MIN (pointer_y, allocation.height - requisition.height);
		menu_y = MIN (menu_y, gdk_screen_get_height (screen) - requisition.height);

		if (menu_x > gdk_screen_get_width (screen) / 2)
			menu_x -= requisition.width;
		else
			menu_x += allocation.width;
	}

	*x = menu_x;
	*y = menu_y;
#if GTK_CHECK_VERSION (3, 0, 0)
	*push_in = FALSE;
#else
	*push_in = TRUE;
#endif
}
示例#11
0
static void
screen_get_work_area(GdkScreen      *screen,
                     HippoRectangle *work_area)
{
    /* Making two round trips to the X server everytime the code calls get_screen_info()
     * has a certain potential for performance problems. We might want to consider
     * caching the results for a small amount of time.
     */
    GdkDisplay *display = gdk_screen_get_display(screen);
    GdkWindow *root = gdk_screen_get_root_window(screen);
    Atom current_desktop_atom = gdk_x11_get_xatom_by_name_for_display(display, "_NET_CURRENT_DESKTOP");
    Atom workarea_atom = gdk_x11_get_xatom_by_name_for_display(display, "_NET_WORKAREA");
    int format;
    Atom type;
    unsigned long n_items;
    unsigned long bytes_after;
    unsigned char *data;
    guint current_desktop;
    guint n_desktops;
    
    if (XGetWindowProperty(GDK_WINDOW_XDISPLAY(root), GDK_WINDOW_XWINDOW(root),
                           current_desktop_atom, 
                           0, G_MAXLONG, False, XA_CARDINAL,
                           &type, &format, &n_items, &bytes_after, &data) != Success) {
        g_warning("Failed to get _NET_CURRENT_DESKTOP property");
        goto fail;
    }
        
    if (format != 32 || type != XA_CARDINAL || n_items != 1) {
        g_warning("Bad _NET_CURRENT_DESKTOP property");
        XFree(data);
        goto fail;
    }

    current_desktop = ((unsigned long *)data)[0];
    XFree(data);
    

    if (XGetWindowProperty(GDK_WINDOW_XDISPLAY(root), GDK_WINDOW_XWINDOW(root),
                           workarea_atom, 
                           0, G_MAXLONG, False, XA_CARDINAL,
                           &type, &format, &n_items, &bytes_after, &data) != Success) {
        g_warning("Failed to get _NET_WORKAREA property");
        goto fail;
    }
        
    if (format != 32 ||  type != XA_CARDINAL || n_items < 4 || (n_items % 4) != 0) {
        g_warning("Bad _NET_WORKAREA property");
        XFree(data);
        goto fail;
    }

    n_desktops = n_items / 4;
    if (current_desktop > n_desktops) {
        g_warning("Current desktop out of range");
        current_desktop = 0;
    }

    work_area->x = ((unsigned long *)data)[current_desktop * 4];
    work_area->y = ((unsigned long *)data)[current_desktop * 4 + 1];
    work_area->width = ((unsigned long *)data)[current_desktop * 4 + 2];
    work_area->height = ((unsigned long *)data)[current_desktop * 4 + 3];
    
    XFree(data);
    return;

 fail:
    work_area->x = 0;
    work_area->y = 0;
    work_area->width = gdk_screen_get_width(screen);
    work_area->height = gdk_screen_get_height(screen);
}
示例#12
0
Size pDesktop::size() {
  return {
    gdk_screen_get_width(gdk_screen_get_default()),
    gdk_screen_get_height(gdk_screen_get_default())
  };
}
示例#13
0
static gboolean
get_work_area (NotifyStack  *stack,
               GdkRectangle *rect)
{
        Atom            workarea;
        Atom            type;
        Window          win;
        int             format;
        gulong          num;
        gulong          leftovers;
        gulong          max_len = 4 * 32;
        guchar         *ret_workarea;
        long           *workareas;
        int             result;
        int             disp_screen;

	workarea = XInternAtom(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), "_NET_WORKAREA", True);


        disp_screen = GDK_SCREEN_XNUMBER (stack->screen);

        /* Defaults in case of error */
        rect->x = 0;
        rect->y = 0;
        rect->width = gdk_screen_get_width (stack->screen);
        rect->height = gdk_screen_get_height (stack->screen);

        if (workarea == None)
                return FALSE;


	win = XRootWindow(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), disp_screen);

	result = XGetWindowProperty(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
		win,
		workarea,
		0,
		max_len,
		False,
		AnyPropertyType,
		&type,
		&format,
		&num,
		&leftovers,
		&ret_workarea);


        if (result != Success
            || type == None
            || format == 0
            || leftovers
            || num % 4) {
                return FALSE;
        }

        workareas = (long *) ret_workarea;
        rect->x = workareas[disp_screen * 4];
        rect->y = workareas[disp_screen * 4 + 1];
        rect->width = workareas[disp_screen * 4 + 2];
        rect->height = workareas[disp_screen * 4 + 3];

        XFree (ret_workarea);

        return TRUE;
}
示例#14
0
void desktop_set_background (GtkWidget *desktop, gchar *wallpaper, FmWallpaperMode wallpaper_mode,
                             GdkColor *color_background)
{
    
    GdkPixbuf *pixbuf;

    
    GdkWindow *root = gdk_screen_get_root_window (gtk_widget_get_screen (desktop));
    GdkWindow *window = gtk_widget_get_window (desktop);

    if (wallpaper_mode == FM_WP_COLOR
       || !wallpaper
       || !*wallpaper
       || !(pixbuf = gdk_pixbuf_new_from_file (wallpaper, NULL)))
    {
        //GdkColor bg = color_background;

        //gdk_rgb_find_color (gdk_drawable_get_colormap (window), &bg);
        
        //gdk_window_set_back_pixmap (window, NULL, FALSE);
        gdk_window_set_background (window, color_background);
        
        //gdk_window_set_back_pixmap (root, NULL, FALSE);
        gdk_window_set_background (root, color_background);
        
        //gdk_window_clear (root);
        //gdk_window_clear (window);
        
        gdk_window_invalidate_rect (window, NULL, TRUE);
        
        return;
    }

//    #if 0
    
    int src_w = gdk_pixbuf_get_width (pixbuf);
    int src_h = gdk_pixbuf_get_height (pixbuf);
    
    
    cairo_surface_t *surface;
    int dest_w;
    int dest_h;
    
    if (wallpaper_mode == FM_WP_TILE)
    {
        dest_w = src_w;
        dest_h = src_h;
        
        //pixmap = gdk_pixmap_new (window, dest_w, dest_h, -1);
        surface = gdk_window_create_similar_surface (window, CAIRO_CONTENT_COLOR, dest_w, dest_h);
    
    }
    else
    {
        GdkScreen *screen = gtk_widget_get_screen (desktop);
        dest_w = gdk_screen_get_width (screen);
        dest_h = gdk_screen_get_height (screen);
        
        //pixmap = gdk_pixmap_new (window, dest_w, dest_h, -1);
        surface = gdk_window_create_similar_surface (window, CAIRO_CONTENT_COLOR, dest_w, dest_h);
    }

    //~ if (gdk_pixbuf_get_has_alpha (pixbuf)
        //~ || wallpaper_mode == FM_WP_CENTER
        //~ || wallpaper_mode == FM_WP_FIT)
    //~ {
        //~ gdk_gc_set_rgb_fg_color (desktop->gc, &color_background);
        //~ gdk_draw_rectangle (pixmap, desktop->gc, TRUE, 0, 0, dest_w, dest_h);
    //~ }

//    GdkPixbuf *scaled;

    cairo_t *cr;

    switch (wallpaper_mode)
    {
        case FM_WP_COLOR:
        break;
        
        case FM_WP_TILE:
        
            //gdk_draw_pixbuf (pixmap, desktop->gc, pixbuf, 0, 0, 0, 0, dest_w, dest_h, GDK_RGB_DITHER_NORMAL, 0, 0);
            
            cr = cairo_create (surface);
            gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
            cairo_paint (cr);
            cairo_destroy (cr);
            
        break;
        
        case FM_WP_STRETCH:
            //~ if (dest_w == src_w && dest_h == src_h)
                //~ scaled = (GdkPixbuf*) g_object_ref (pixbuf);
            //~ else
                //~ scaled = gdk_pixbuf_scale_simple (pixbuf, dest_w, dest_h, GDK_INTERP_BILINEAR);
            //~ 
            //~ gdk_draw_pixbuf (pixmap, desktop->gc, scaled, 0, 0, 0, 0, dest_w, dest_h, GDK_RGB_DITHER_NORMAL, 0, 0);
            //~ 
            //~ g_object_unref (scaled);
        break;
        
        case FM_WP_FIT:
            
            //~ if (dest_w != src_w || dest_h != src_h)
            //~ {
                //~ gdouble w_ratio = (float) dest_w / src_w;
                //~ gdouble h_ratio = (float) dest_h / src_h;
                //~ gdouble ratio = MIN (w_ratio, h_ratio);
                //~ 
                //~ if (ratio != 1.0)
                //~ {
                    //~ src_w *= ratio;
                    //~ src_h *= ratio;
                    //~ 
                    //~ scaled = gdk_pixbuf_scale_simple (pixbuf, src_w, src_h, GDK_INTERP_BILINEAR);
                    //~ 
                    //~ g_object_unref (pixbuf);
                    //~ pixbuf = scaled;
                //~ }
            //~ }
        
        case FM_WP_CENTER:
        {
            //~ int x;
            //~ int y;
            //~ x = (dest_w - src_w) / 2;
            //~ y = (dest_h - src_h) / 2;
            //~ 
            //~ gdk_draw_pixbuf (pixmap, desktop->gc, pixbuf, 0, 0, x, y, -1, -1, GDK_RGB_DITHER_NORMAL, 0, 0);
        }
        break;
    }
    
    
    Display *xdisplay;
    Pixmap xpixmap = 0;
    Window xroot;
    
    cairo_pattern_t *pattern = cairo_pattern_create_for_surface (surface);
    
    //gdk_window_set_back_pixmap (root, pixmap, FALSE);
	gdk_window_set_background_pattern (root, pattern);

    //gdk_window_set_back_pixmap (window, NULL, TRUE);
	gdk_window_set_background_pattern (window, pattern);

    cairo_pattern_destroy (pattern);
    
    Pixmap pixmap_id = cairo_xlib_surface_get_drawable (surface);
    
    XChangeProperty (GDK_WINDOW_XDISPLAY (root),
                     GDK_WINDOW_XID (root),
                     gdk_x11_get_xatom_by_name ("_XROOTPMAP_ID"),   //XA_XROOTMAP_ID,
                     XA_PIXMAP,
                     32,
                     PropModeReplace, 
                     (guchar*) &pixmap_id,
                     1);

    // Set root map here...
    xdisplay = GDK_WINDOW_XDISPLAY (root);
    xroot = GDK_WINDOW_XID (root);

    XGrabServer (xdisplay);

    if (surface)
    {
        xpixmap = cairo_xlib_surface_get_drawable (surface);

        XChangeProperty (xdisplay,
                         xroot,
                         gdk_x11_get_xatom_by_name ("_XROOTPMAP_ID"),
                         XA_PIXMAP,
                         32,
                         PropModeReplace,
                         (guchar *) &xpixmap,
                         1);

        XSetWindowBackgroundPixmap (xdisplay, xroot, xpixmap);
    }
    else
    {
        // Anyone knows how to handle this correctly ?
    }
    
    XClearWindow (xdisplay, xroot);

    XUngrabServer (xdisplay);
    XFlush (xdisplay);

    cairo_surface_destroy (surface);
    
    if (pixbuf)
        g_object_unref (pixbuf);

//    gdk_window_clear (root);
//    gdk_window_clear (window);
    
    gdk_window_invalidate_rect (window, NULL, TRUE);
//    #endif
}
示例#15
0
static void
replies_window_reset_geometry (GtkWidget *main_window)
{
	FwituxConf *conf;
	gint        x, y, w, h;
    GdkScreen  *screen;
    gint        screen_width, screen_height;

    /* get main window geometry from gconf */
	fwitux_debug (DEBUG_DOMAIN_SETUP, "Loading window geometry...");

	conf = fwitux_conf_get ();

	fwitux_conf_get_int (conf,
						 FWITUX_PREFS_UI_WINDOW_HEIGHT,
						 &h);

	fwitux_conf_get_int (conf,
						 FWITUX_PREFS_UI_WINDOW_WIDTH,
						 &w);

	fwitux_conf_get_int (conf,
						 FWITUX_PREFS_UI_WIN_POS_X,
						 &x);

	fwitux_conf_get_int (conf,
						 FWITUX_PREFS_UI_WIN_POS_Y,
						 &y);


    /* get screen geometry */
    screen = gdk_screen_get_default();
    screen_width = gdk_screen_get_width(screen);
    screen_height = gdk_screen_get_height(screen);

    /* set the reply list window */
	if (w >=1 && h >= 1) {
		/*
		 * Use the defaults from the glade file
		 * if we don't have good w, h geometry.
		 */
		 fwitux_debug (DEBUG_DOMAIN_SETUP,
					   "Configuring window default size w:%d, h: %d", w, h);
		 //gtk_window_resize (GTK_WINDOW (main_window), w, h);
         gtk_widget_set_size_request(main_window, w, h);
	}

	if (x >= 0 && y >= 0) {
		/*
		 * Let the window manager position it
		 * if we don't have good x, y coordinates.
		 */
		fwitux_debug (DEBUG_DOMAIN_SETUP,
					  "Configuring window default position x:%d, y:%d", x, y);
        if (x + w < screen_width) {
            gtk_window_move (GTK_WINDOW (main_window), x + w, y);
        }
        else if (x - w > 0) {
            gtk_window_move (GTK_WINDOW (main_window), x - w, y);
        }
	}
}
示例#16
0
文件: xiphos.c 项目: acli/xiphos
void frontend_display(const char *tabs)
{
	GdkScreen *screen = gdk_screen_get_default();
	gint screen_width = gdk_screen_get_width(screen);
	gint screen_height = gdk_screen_get_height(screen);

	XI_print(("%s\n", "Displaying Xiphos"));
	gui_show_main_window();

	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widgets.viewtexts_item),
				       settings.showtexts);
	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widgets.viewcomms_item),
				       settings.showcomms);
	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widgets.viewdicts_item),
				       settings.showdicts);
	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widgets.viewpreview_item),
				       settings.showpreview);
	gui_show_hide_preview(settings.showpreview);
	gui_show_hide_texts(settings.showtexts);
	gui_show_hide_dicts(settings.showdicts);
	gui_show_hide_comms(settings.showcomms);

	/*
	 * a little paranoia:
	 * clamp geometry values to a reasonable bound.
	 * sometimes xiphos gets insane reconfig events as it dies,
	 * especially if it's due to just shutting linux down.
	 */
	if (settings.app_x < 0)
		settings.app_x = 0;
	if (settings.app_x > (screen_width - 100))
		settings.app_x = screen_width - 100;
	if (settings.app_y < 0)
		settings.app_y = 0;
	if (settings.app_y > (screen_height - 100))
		settings.app_y = screen_height - 100;
	if (settings.maximized)
		gtk_window_maximize(GTK_WINDOW(widgets.app));

	gtk_window_move(GTK_WINDOW(widgets.app), settings.app_x,
			settings.app_y);

	/* gecko  needs the widgets to be visible before writing */
	sync_windows();

	// setup passage notebook
	//      if (settings.browsing) {
	gui_notebook_main_setup(settings.browsing, tabs);
	/*	} else {
		url = g_strdup_printf("sword://%s/%s",settings.DictWindowModule,
						      settings.dictkey);
		main_url_handler(url);
		g_free(url);

		gtk_widget_realize(widgets.html_book);
		url = g_strdup_printf("sword://%s/%d",settings.book_mod,
						      settings.book_offset);
		main_url_handler(url);
		g_free(url);

		settings.addhistoryitem = FALSE;
		url = g_strdup_printf("sword://%s/%s",settings.MainWindowModule,
						      settings.currentverse);
		main_url_handler(url);
		g_free(url);
	} */
	/* must be set after tab stuff is done */

	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widgets.parallel_tab_item),
				       settings.showparatab);
	g_signal_connect(G_OBJECT(widgets.parallel_tab_item),
			 "toggled",
			 G_CALLBACK(gui_parallel_tab_activate), NULL);
	gui_show_previewer_in_sidebar(settings.show_previewer_in_sidebar);

	/* open saved windows as needed */
	if (settings.display_parallel)
		on_undockInt_activate(NULL);
	if (settings.display_modmgr)
		gui_open_mod_mgr();
	if (settings.display_advsearch)
		main_open_search_dialog();
	if (settings.display_prefs)
		gui_setup_preferences_dialog();

	if (settings.showdevotional)
		main_display_devotional();
	else
		main_init_previewer();
	gtk_widget_grab_focus(sidebar.module_list);

	XI_print(("%s\n\n", "done"));
}
示例#17
0
文件: fish.c 项目: lanoxx/gnome-panel
static void 
display_fortune_dialog (FishApplet *fish)
{
	GError      *error = NULL;
	gboolean     user_command;
	int          output;
	const char  *charset;
	int          argc;
	char       **argv;
	GdkScreen   *screen;
	char        *display;

	/* if there is still a pipe, close it */
	if (fish->source_id)
		g_source_remove (fish->source_id);
	fish->source_id = 0;
	fish_close_channel (fish);

	user_command = locate_fortune_command (fish, &argc, &argv);
	if (!argv)
		return;

	if (!fish->fortune_dialog) {
		GtkWidget *scrolled;
		GtkWidget *vbox;
		GdkScreen *screen;
		int        screen_width;
		int        screen_height;
      
		fish->fortune_dialog = 
			gtk_dialog_new_with_buttons (
				"", NULL, 0,
				_("_Speak again"), FISH_RESPONSE_SPEAK,
				_("_Close"), GTK_RESPONSE_CLOSE,
				NULL);

		gtk_window_set_icon_name (GTK_WINDOW (fish->fortune_dialog),
					  FISH_ICON);

		gtk_dialog_set_default_response (
			GTK_DIALOG (fish->fortune_dialog), GTK_RESPONSE_CLOSE);

		g_signal_connect (fish->fortune_dialog, "delete_event",
				  G_CALLBACK (delete_event), fish);
		g_signal_connect (fish->fortune_dialog, "response",
				  G_CALLBACK (handle_fortune_response), fish);

		gtk_window_set_wmclass (GTK_WINDOW (fish->fortune_dialog), "fish", "Fish");

		screen = gtk_widget_get_screen (GTK_WIDGET (fish));

		screen_width  = gdk_screen_get_width (screen);
		screen_height = gdk_screen_get_height (screen);

		gtk_window_set_default_size (GTK_WINDOW (fish->fortune_dialog),
					     MIN (600, screen_width  * 0.9),
					     MIN (350, screen_height * 0.9));

		fish->fortune_view = gtk_text_view_new ();
		gtk_text_view_set_editable (GTK_TEXT_VIEW (fish->fortune_view), FALSE);
		gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (fish->fortune_view), FALSE);
		gtk_text_view_set_left_margin (GTK_TEXT_VIEW (fish->fortune_view), 10);
		gtk_text_view_set_right_margin (GTK_TEXT_VIEW (fish->fortune_view), 10);
		fish->fortune_buffer =
			gtk_text_view_get_buffer (GTK_TEXT_VIEW (fish->fortune_view));

		gtk_text_buffer_create_tag (GTK_TEXT_BUFFER (fish->fortune_buffer),
					    "monospace_tag", "family",
					    "Monospace", NULL);

		scrolled = gtk_scrolled_window_new (NULL, NULL);
		gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
						GTK_POLICY_AUTOMATIC,
						GTK_POLICY_AUTOMATIC);
		gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
						     GTK_SHADOW_IN);

		gtk_container_add (GTK_CONTAINER (scrolled), fish->fortune_view);

		fish->fortune_label = gtk_label_new ("");
		gtk_label_set_ellipsize (GTK_LABEL (fish->fortune_label),
					 PANGO_ELLIPSIZE_MIDDLE);
		fish->fortune_cmd_label = gtk_label_new ("");
		gtk_misc_set_alignment (GTK_MISC (fish->fortune_cmd_label),
					0, 0.5);

		vbox = gtk_dialog_get_content_area (GTK_DIALOG (fish->fortune_dialog));
		gtk_box_pack_start (GTK_BOX (vbox),
				    fish->fortune_label,
				    FALSE, FALSE, 6);

		gtk_box_pack_start (GTK_BOX (vbox),
				    scrolled,
				    TRUE, TRUE, 6);

		gtk_box_pack_start (GTK_BOX (vbox),
				    fish->fortune_cmd_label,
				    FALSE, FALSE, 6);

		update_fortune_dialog (fish);

		/* We don't show_all for the dialog since fortune_cmd_label
		 * might need to be hidden 
		 * The dialog will be shown with gtk_window_present later */
		gtk_widget_show (scrolled);
		gtk_widget_show (fish->fortune_view);
		gtk_widget_show (fish->fortune_label);
	}

	if (!user_command) {
		char *command;
		char * text;

		command = g_markup_printf_escaped ("<tt>%s</tt>", argv[0]);
		text = g_strdup_printf (_("The configured command is not "
					  "working and has been replaced by: "
					  "%s"), command);
		gtk_label_set_markup (GTK_LABEL (fish->fortune_cmd_label),
				      text);
		g_free (command);
		g_free (text);
		gtk_widget_show (fish->fortune_cmd_label);
	} else {
		gtk_widget_hide (fish->fortune_cmd_label);
	}

	clear_fortune_text (fish);

	screen = gtk_widget_get_screen (GTK_WIDGET (fish));
	display = gdk_screen_make_display_name (screen);

	g_spawn_async_with_pipes (NULL, /* working directory */
				  argv,
				  NULL, /* envp */
				  G_SPAWN_SEARCH_PATH|G_SPAWN_STDERR_TO_DEV_NULL,
				  set_environment,
				  &display,
				  NULL, /* child pid */
				  NULL, /* stdin */
				  &output,
				  NULL, /* stderr */
				  &error);

	g_free (display);

	if (error) {
		char *message;

		message = g_strdup_printf (_("Unable to execute '%s'\n\nDetails: %s"),
					   argv[0], error->message);
		something_fishy_going_on (fish, message);
		g_free (message);
		g_error_free (error);
		g_strfreev (argv);
		return;
	}

	fish->io_channel = g_io_channel_unix_new (output);
	/* set the correct encoding if the locale is not using UTF-8 */
	if (!g_get_charset (&charset))
		g_io_channel_set_encoding(fish->io_channel, charset, &error);
	if (error) {
		char *message;

		message = g_strdup_printf (_("Unable to read from '%s'\n\nDetails: %s"),
					   argv[0], error->message);
		something_fishy_going_on (fish, message);
		g_free (message);
		g_error_free (error);
		g_strfreev (argv);
		return;
	}

	g_strfreev (argv);

	fish->source_id = g_io_add_watch (fish->io_channel,
					  G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL,
					  fish_read_output, fish);

	gtk_window_set_screen (GTK_WINDOW (fish->fortune_dialog),
			       gtk_widget_get_screen (GTK_WIDGET (fish)));
	gtk_window_present (GTK_WINDOW (fish->fortune_dialog));
}
示例#18
0
static void CreateErrorWindow(void) {
    GtkWidget *hbox5;
    GtkWidget *view;
    GtkWidget *vscrollbar2;
    GdkPixbuf *Warning_icon_pixbuf;
    PangoContext *context;
    PangoFont *font;
    PangoFontMetrics *fm;
    int as, ds;
    GtkRequisition desired;

    errdata.gw = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_widget_set_name (errdata.gw, "Warnings");
    gtk_widget_set_events (errdata.gw, GDK_EXPOSURE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_PROPERTY_CHANGE_MASK);
    gtk_window_set_title (GTK_WINDOW (errdata.gw), _("Warnings"));
    Warning_icon_pixbuf = create_pixbuf ("fontview2.xbm");
    if (Warning_icon_pixbuf) {
	gtk_window_set_icon (GTK_WINDOW (errdata.gw), Warning_icon_pixbuf);
	gdk_pixbuf_unref (Warning_icon_pixbuf);
    }

    hbox5 = gtk_hbox_new (FALSE, 0);
    gtk_widget_set_name (hbox5, "hbox5");
    gtk_widget_show (hbox5);
    gtk_container_add (GTK_CONTAINER (errdata.gw), hbox5);

    view = gtk_drawing_area_new ();
    gtk_widget_set_name (view, "view");
    gtk_widget_show (view);
    gtk_box_pack_start (GTK_BOX (hbox5), view, TRUE, TRUE, 0);
    gtk_widget_set_size_request (view, 16*24+1, 4*24+1);

    vscrollbar2 = gtk_vscrollbar_new (GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, 0, 0, 0, 0)));
    gtk_widget_set_name (vscrollbar2, "vscrollbar2");
    gtk_widget_show (vscrollbar2);
    gtk_box_pack_start (GTK_BOX (hbox5), vscrollbar2, FALSE, TRUE, 0);

    g_signal_connect ((gpointer) errdata.gw, "delete_event",
		      G_CALLBACK (Warning_Hide),
		      NULL);
    g_signal_connect ((gpointer) vscrollbar2, "value_changed",
		      G_CALLBACK (Warning_VScroll),
		      NULL);

    g_signal_connect ((gpointer) view, "configure_event",
		      G_CALLBACK (Warning_Resize),
		      NULL);
    g_signal_connect ((gpointer) view, "expose_event",
		      G_CALLBACK (Warning_Expose),
		      NULL);

    errdata.v   = view;
    errdata.vsb = vscrollbar2;
    errdata.layout = gtk_widget_create_pango_layout( view, NULL );
    pango_layout_set_width(errdata.layout, -1);		/* Don't wrap long lines */

    context = gtk_widget_get_pango_context( view );
    font = pango_context_load_font( context, pango_context_get_font_description(context));
    fm = pango_font_get_metrics(font,NULL);
    as = pango_font_metrics_get_ascent(fm);
    ds = pango_font_metrics_get_descent(fm);
    errdata.as = as / PANGO_SCALE;
    errdata.fh = (as+ds) / PANGO_SCALE;

    gtk_widget_set_size_request(view, 40*errdata.fh, 5*errdata.fh );

    gtk_widget_size_request(errdata.gw,&desired);
    /* This function is deprecated, but I can find no other way to position */
    /*  a window in the bottom right corner (or at all). So I use it */
    gtk_widget_set_uposition(errdata.gw,
	    gdk_screen_get_width(gdk_screen_get_default())-desired.width-5,
	    gdk_screen_get_height(gdk_screen_get_default())-desired.height-errdata.fh-5);

    errdata.linecnt = 5;

    gtk_widget_show(errdata.gw);
}
示例#19
0
static void
aosd_osd_create ( void )
{
  gint max_width, layout_width, layout_height;
  PangoRectangle ink, log;
  GdkScreen *screen = gdk_screen_get_default();
  gint pos_x = 0, pos_y = 0;
  gint pad_left = 0 , pad_right = 0 , pad_top = 0 , pad_bottom = 0;
  gint screen_width, screen_height;
  aosd_deco_style_data_t style_data;

  /* calculate screen_width and screen_height */
  if ( osd_data->cfg_osd->position.multimon_id > -1 )
  {
    /* adjust coordinates and size according to selected monitor */
    GdkRectangle rect;
    gdk_screen_get_monitor_geometry( screen , osd_data->cfg_osd->position.multimon_id , &rect );
    pos_x = rect.x;
    pos_y = rect.y;
    screen_width = rect.width;
    screen_height = rect.height;
  }
  else
  {
    /* use total space available, even when composed by multiple monitor */
    screen_width = gdk_screen_get_width( screen );
    screen_height = gdk_screen_get_height( screen );
    pos_x = 0;
    pos_y = 0;
  }

  /* pick padding from selected decoration style */
  aosd_deco_style_get_padding( osd_data->cfg_osd->decoration.code ,
    &pad_top , &pad_bottom , &pad_left , &pad_right );

  if ( osd_data->cfg_osd->position.maxsize_width > 0 )
  {
    gint max_width_default = screen_width - pad_left - pad_right - abs(osd_data->cfg_osd->position.offset_x);
    max_width = osd_data->cfg_osd->position.maxsize_width - pad_left - pad_right;
    /* ignore user-defined max_width if it is too small or too large */
    if (( max_width < 1 ) || ( max_width > max_width_default ))
      max_width = max_width_default;
  }
  else
  {
    max_width = screen_width - pad_left - pad_right - abs(osd_data->cfg_osd->position.offset_x);
  }
  osd_data->pango_context = pango_cairo_font_map_create_context(
                              PANGO_CAIRO_FONT_MAP(pango_cairo_font_map_get_default()));
  osd_data->pango_layout = pango_layout_new(osd_data->pango_context);
  pango_layout_set_markup( osd_data->pango_layout, osd_data->markup_message , -1 );
  pango_layout_set_ellipsize( osd_data->pango_layout , PANGO_ELLIPSIZE_NONE );
  pango_layout_set_justify( osd_data->pango_layout , FALSE );
  pango_layout_set_width( osd_data->pango_layout , PANGO_SCALE * max_width );
  pango_layout_get_pixel_extents( osd_data->pango_layout , &ink , &log );
  layout_width = ink.width;
  layout_height = log.height;

  /* osd position */
  switch ( osd_data->cfg_osd->position.placement )
  {
    case AOSD_POSITION_PLACEMENT_TOP:
      pos_x += (screen_width - (layout_width + pad_left + pad_right)) / 2;
      pos_y += 0;
      break;
    case AOSD_POSITION_PLACEMENT_TOPRIGHT:
      pos_x += screen_width - (layout_width + pad_left + pad_right);
      pos_y += 0;
      break;
    case AOSD_POSITION_PLACEMENT_MIDDLELEFT:
      pos_x += 0;
      pos_y += (screen_height - (layout_height + pad_top + pad_bottom)) / 2;
      break;
    case AOSD_POSITION_PLACEMENT_MIDDLE:
      pos_x += (screen_width - (layout_width + pad_left + pad_right)) / 2;
      pos_y += (screen_height - (layout_height + pad_top + pad_bottom)) / 2;
      break;
    case AOSD_POSITION_PLACEMENT_MIDDLERIGHT:
      pos_x += screen_width - (layout_width + pad_left + pad_right);
      pos_y += (screen_height - (layout_height + pad_top + pad_bottom)) / 2;
      break;
    case AOSD_POSITION_PLACEMENT_BOTTOMLEFT:
      pos_x += 0;
      pos_y += screen_height - (layout_height + pad_top + pad_bottom);
      break;
    case AOSD_POSITION_PLACEMENT_BOTTOM:
      pos_x += (screen_width - (layout_width + pad_left + pad_right)) / 2;
      pos_y += screen_height - (layout_height + pad_top + pad_bottom);
      break;
    case AOSD_POSITION_PLACEMENT_BOTTOMRIGHT:
      pos_x += screen_width - (layout_width + pad_left + pad_right);
      pos_y += screen_height - (layout_height + pad_top + pad_bottom);
      break;
    case AOSD_POSITION_PLACEMENT_TOPLEFT:
    default:
      pos_x += 0;
      pos_y += 0;
      break;
  }

  /* add offset to position */
  pos_x += osd_data->cfg_osd->position.offset_x;
  pos_y += osd_data->cfg_osd->position.offset_y;

  ghosd_set_position( osd , pos_x , pos_y ,
    layout_width + pad_left + pad_right ,
    layout_height + pad_top + pad_bottom );

  ghosd_set_event_button_cb( osd , aosd_button_func , NULL );

  style_data.layout = osd_data->pango_layout;
  style_data.text = &(osd_data->cfg_osd->text);
  style_data.decoration = &(osd_data->cfg_osd->decoration);
  osd_data->fade_data.surface = NULL;
  osd_data->fade_data.user_data = &style_data;
  osd_data->fade_data.width = layout_width + pad_left + pad_right;
  osd_data->fade_data.height = layout_height + pad_top + pad_bottom;
  osd_data->fade_data.alpha = 0;
  osd_data->fade_data.deco_code = osd_data->cfg_osd->decoration.code;
  osd_data->dalpha_in = 1.0 / ( osd_data->cfg_osd->animation.timing_fadein / (gfloat)AOSD_TIMING );
  osd_data->dalpha_out = 1.0 / ( osd_data->cfg_osd->animation.timing_fadeout / (gfloat)AOSD_TIMING );
  osd_data->ddisplay_stay = 1.0 / ( osd_data->cfg_osd->animation.timing_display / (gfloat)AOSD_TIMING );
  ghosd_set_render( osd , (GhosdRenderFunc)aosd_fade_func , &(osd_data->fade_data) , NULL );

  /* show the osd (with alpha 0, invisible) */
  ghosd_show( osd );
  return;
}
示例#20
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
    }
}
示例#21
0
void
splash_create (gboolean be_verbose)
{
  GtkWidget          *frame;
  GtkWidget          *vbox;
  GdkPixbufAnimation *pixbuf;
  GdkScreen          *screen;

  g_return_if_fail (splash == NULL);

  pixbuf = splash_image_load (be_verbose);

  if (! pixbuf)
    return;

  splash = g_slice_new0 (GimpSplash);

  splash->window =
    g_object_new (GTK_TYPE_WINDOW,
                  "type",            GTK_WINDOW_TOPLEVEL,
                  "type-hint",       GDK_WINDOW_TYPE_HINT_SPLASHSCREEN,
                  "title",           _("GIMP Startup"),
                  "role",            "gimp-startup",
                  "window-position", GTK_WIN_POS_CENTER,
                  "resizable",       FALSE,
                  NULL);

  g_signal_connect_swapped (splash->window, "delete-event",
                            G_CALLBACK (exit),
                            GINT_TO_POINTER (0));

  screen = gtk_widget_get_screen (splash->window);

  splash->width  = MIN (gdk_pixbuf_animation_get_width (pixbuf),
                        gdk_screen_get_width (screen));
  splash->height = MIN (gdk_pixbuf_animation_get_height (pixbuf),
                        gdk_screen_get_height (screen));

  frame = gtk_frame_new (NULL);
  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
  gtk_container_add (GTK_CONTAINER (splash->window), frame);
  gtk_widget_show (frame);

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

  /*  If the splash image is static, we use a drawing area and set the
   *  image as back pixmap, otherwise a GtkImage is being used.
   */
  if (gdk_pixbuf_animation_is_static_image (pixbuf))
    {
      splash->area = gtk_drawing_area_new ();
    }
  else
    {
      splash->area = gtk_image_new_from_animation (pixbuf);
    }

  gtk_box_pack_start (GTK_BOX (vbox), splash->area, TRUE, TRUE, 0);
  gtk_widget_show (splash->area);

  gtk_widget_set_size_request (splash->area, splash->width, splash->height);

  /*  create the pango layouts  */
  splash->upper = gtk_widget_create_pango_layout (splash->area, "");
  splash->lower = gtk_widget_create_pango_layout (splash->area, "");
  gimp_pango_layout_set_scale (splash->lower, PANGO_SCALE_SMALL);

  /*  this sets the initial layout positions  */
  splash_position_layouts (splash, "", "", NULL);

  splash_average_text_area (splash,
                            gdk_pixbuf_animation_get_static_image (pixbuf),
                            &splash->color);

  gtk_widget_realize (splash->area);

  if (gdk_pixbuf_animation_is_static_image (pixbuf))
    {
      GdkPixbuf *static_pixbuf = gdk_pixbuf_animation_get_static_image (pixbuf);
      GdkPixmap *pixmap;
      cairo_t   *cr;

      pixmap = gdk_pixmap_new (gtk_widget_get_window (splash->area),
                               splash->width, splash->height, -1);

      cr = gdk_cairo_create (pixmap);
      gdk_cairo_set_source_pixbuf (cr, static_pixbuf, 0.0, 0.0);
      cairo_paint (cr);
      cairo_destroy (cr);

      gdk_window_set_back_pixmap (gtk_widget_get_window (splash->area),
                                  pixmap, FALSE);
      g_object_unref (pixmap);
    }

  g_object_unref (pixbuf);

  g_signal_connect_after (splash->area, "expose-event",
			  G_CALLBACK (splash_area_expose),
			  splash);

  /*  add a progress bar  */
  splash->progress = gtk_progress_bar_new ();
  gtk_box_pack_end (GTK_BOX (vbox), splash->progress, FALSE, FALSE, 0);
  gtk_widget_show (splash->progress);

  gtk_widget_show_now (splash->window);

#ifdef STARTUP_TIMER
  splash->timer = g_timer_new ();
#endif
}
示例#22
0
/**
 * gconf_bridge_bind_window
 * @bridge: A #GConfBridge
 * @key_prefix: The prefix of the GConf keys
 * @window: A #GtkWindow
 * @bind_size: TRUE to bind the size of @window
 * @bind_pos: TRUE to bind the position of @window
 *
 * On calling this function @window will be resized to the values
 * specified by "@key_prefix<!-- -->_width" and "@key_prefix<!-- -->_height"
 * and maximixed if "@key_prefix<!-- -->_maximized is TRUE if
 * @bind_size is TRUE, and moved to the values specified by
 * "@key_prefix<!-- -->_x" and "@key_prefix<!-- -->_y" if @bind_pos is TRUE.
 * The respective GConf values will be updated when the window is resized
 * and/or moved.
 *
 * Return value: The ID of the new binding.
 **/
guint
gconf_bridge_bind_window (GConfBridge *bridge,
                          const gchar *key_prefix,
                          GtkWindow *window,
                          gboolean bind_size,
                          gboolean bind_pos)
{
	WindowBinding *binding;

	g_return_val_if_fail (bridge != NULL, 0);
	g_return_val_if_fail (key_prefix != NULL, 0);
	g_return_val_if_fail (GTK_IS_WINDOW (window), 0);

        /* Create new binding. */
	binding = g_new (WindowBinding, 1);

	binding->type = BINDING_WINDOW;
	binding->id = new_id ();
	binding->bind_size = bind_size;
	binding->bind_pos = bind_pos;
	binding->key_prefix = g_strdup (key_prefix);
	binding->window = window;
	binding->sync_timeout_id = 0;

        /* Set up GConf keys & sync window to GConf values */
	if (bind_size) {
		gchar *key;
		GConfValue *width_val, *height_val, *maximized_val;

                key = g_strconcat (key_prefix, "_width", NULL);
		width_val = gconf_client_get (bridge->client, key, NULL);
		g_free (key);

                key = g_strconcat (key_prefix, "_height", NULL);
		height_val = gconf_client_get (bridge->client, key, NULL);
		g_free (key);

                key = g_strconcat (key_prefix, "_maximized", NULL);
		maximized_val = gconf_client_get (bridge->client, key, NULL);
		g_free (key);

		if (width_val && height_val) {
			gtk_window_resize (window,
					   gconf_value_get_int (width_val),
					   gconf_value_get_int (height_val));

			gconf_value_free (width_val);
			gconf_value_free (height_val);
		} else if (width_val) {
			gconf_value_free (width_val);
		} else if (height_val) {
			gconf_value_free (height_val);
		}

		if (maximized_val) {
			if (gconf_value_get_bool (maximized_val)) {
				/* Maximize is not done immediately, but to
				 * count with proper window size, resize it
				 * before. The previous size is restored
				 * after the maximization is changed,
				 * in window_binding_state_event_cb(). */
				gint width = 0, height = 0;
				GdkScreen *screen;

				gtk_window_get_size (window, &width, &height);
				g_object_set_data (
					G_OBJECT (window),
					"binding-premax-width",
					GINT_TO_POINTER (width));
				g_object_set_data (
					G_OBJECT (window),
					"binding-premax-height",
					GINT_TO_POINTER (height));

				screen = gtk_window_get_screen (window);
				gtk_window_resize (window,
					gdk_screen_get_width (screen),
					gdk_screen_get_height (screen));

				gtk_window_maximize (window);
			}
			gconf_value_free (maximized_val);
		}
	}

	if (bind_pos) {
		gchar *key;
		GConfValue *x_val, *y_val;

                key = g_strconcat (key_prefix, "_x", NULL);
		x_val = gconf_client_get (bridge->client, key, NULL);
		g_free (key);

                key = g_strconcat (key_prefix, "_y", NULL);
		y_val = gconf_client_get (bridge->client, key, NULL);
		g_free (key);

		if (x_val && y_val) {
			gtk_window_move (window,
					 gconf_value_get_int (x_val),
					 gconf_value_get_int (y_val));

			gconf_value_free (x_val);
			gconf_value_free (y_val);
		} else if (x_val) {
			gconf_value_free (x_val);
		} else if (y_val) {
			gconf_value_free (y_val);
		}
	}

        /* Connect to window size change notifications */
	binding->configure_event_id =
		g_signal_connect (window,
                                  "configure-event",
				  G_CALLBACK
					(window_binding_configure_event_cb),
				  binding);

	binding->window_state_event_id =
		g_signal_connect (window,
                                  "window_state_event",
				  G_CALLBACK
					(window_binding_state_event_cb),
				  binding);
	binding->unmap_id =
		g_signal_connect (window,
                                  "unmap",
				  G_CALLBACK (window_binding_unmap_cb),
				  binding);

        /* Handle case where window gets destroyed */
	g_object_weak_ref (G_OBJECT (window),
			   window_binding_window_destroyed, binding);

        /* Insert binding */
	g_hash_table_insert (bridge->bindings,
			     GUINT_TO_POINTER (binding->id), binding);

        /* Done */
	return binding->id;
}
示例#23
0
nux::Geometry UScreen::GetScreenGeometry() const
{
  int width = gdk_screen_get_width(screen_);
  int height = gdk_screen_get_height(screen_);
  return nux::Geometry(0, 0, width, height);
}
示例#24
0
static void
gimp_tag_popup_constructed (GObject *object)
{
  GimpTagPopup        *popup = GIMP_TAG_POPUP (object);
  GimpTaggedContainer *container;
  GtkWidget           *entry;
  GtkAllocation        entry_allocation;
  GtkStyle            *frame_style;
  gint                 x;
  gint                 y;
  gint                 width;
  gint                 height;
  gint                 popup_height;
  GHashTable          *tag_hash;
  GList               *tag_list;
  GList               *tag_iterator;
  gint                 i;
  gint                 max_height;
  gint                 screen_height;
  gchar              **current_tags;
  gint                 current_count;
  GdkRectangle         popup_rects[2]; /* variants of popup placement */
  GdkRectangle         popup_rect; /* best popup rect in screen coordinates */

  G_OBJECT_CLASS (parent_class)->constructed (object);

  entry = GTK_WIDGET (popup->combo_entry);

  gtk_window_set_screen (GTK_WINDOW (popup), gtk_widget_get_screen (entry));

  popup->context = gtk_widget_create_pango_context (GTK_WIDGET (popup));
  popup->layout  = pango_layout_new (popup->context);

  gtk_widget_get_allocation (entry, &entry_allocation);

  gtk_widget_style_get (GTK_WIDGET (popup),
                        "scroll-arrow-vlength", &popup->scroll_arrow_height,
                        NULL);

  pango_layout_set_attributes (popup->layout,
                               popup->combo_entry->normal_item_attr);

  current_tags  = gimp_tag_entry_parse_tags (GIMP_TAG_ENTRY (popup->combo_entry));
  current_count = g_strv_length (current_tags);

  container = GIMP_TAG_ENTRY (popup->combo_entry)->container;

  tag_hash = container->tag_ref_counts;
  tag_list = g_hash_table_get_keys (tag_hash);
  tag_list = g_list_sort (tag_list, gimp_tag_compare_func);

  popup->tag_count = g_list_length (tag_list);
  popup->tag_data  = g_new0 (PopupTagData, popup->tag_count);

  for (i = 0, tag_iterator = tag_list;
       i < popup->tag_count;
       i++, tag_iterator = g_list_next (tag_iterator))
    {
      PopupTagData *tag_data = &popup->tag_data[i];
      gint          j;

      tag_data->tag   = tag_iterator->data;
      tag_data->state = GTK_STATE_NORMAL;

      for (j = 0; j < current_count; j++)
        {
          if (! gimp_tag_compare_with_string (tag_data->tag, current_tags[j]))
            {
              tag_data->state = GTK_STATE_SELECTED;
              break;
            }
        }
    }

  g_list_free (tag_list);
  g_strfreev (current_tags);

  if (GIMP_TAG_ENTRY (popup->combo_entry)->mode == GIMP_TAG_ENTRY_MODE_QUERY)
    {
      for (i = 0; i < popup->tag_count; i++)
        {
          if (popup->tag_data[i].state != GTK_STATE_SELECTED)
            {
              popup->tag_data[i].state = GTK_STATE_INSENSITIVE;
            }
        }

      gimp_container_foreach (GIMP_CONTAINER (container),
                              (GFunc) gimp_tag_popup_check_can_toggle,
                              popup);
    }

  frame_style = gtk_widget_get_style (popup->frame);

  width  = (entry_allocation.width -
            2 * frame_style->xthickness);
  height = (gimp_tag_popup_layout_tags (popup, width) +
            2 * frame_style->ythickness);

  gdk_window_get_origin (gtk_widget_get_window (entry), &x, &y);

  max_height = entry_allocation.height * 10;

  screen_height = gdk_screen_get_height (gtk_widget_get_screen (entry));

  popup_height = MIN (height, max_height);

  popup_rects[0].x      = x;
  popup_rects[0].y      = 0;
  popup_rects[0].width  = entry_allocation.width;
  popup_rects[0].height = y + entry_allocation.height;

  popup_rects[1].x      = x;
  popup_rects[1].y      = y;
  popup_rects[1].width  = popup_rects[0].width;
  popup_rects[1].height = screen_height - popup_rects[0].height;

  if (popup_rects[0].height >= popup_height)
    {
      popup_rect = popup_rects[0];
      popup_rect.y += popup_rects[0].height - popup_height;
      popup_rect.height = popup_height;
    }
  else if (popup_rects[1].height >= popup_height)
    {
      popup_rect = popup_rects[1];
      popup_rect.height = popup_height;
    }
  else
    {
      if (popup_rects[0].height >= popup_rects[1].height)
        {
          popup_rect = popup_rects[0];
          popup_rect.y += popup->scroll_arrow_height + frame_style->ythickness;
        }
      else
        {
          popup_rect = popup_rects[1];
          popup_rect.y -= popup->scroll_arrow_height + frame_style->ythickness;
        }

      popup_height = popup_rect.height;
    }

  if (popup_height < height)
    {
      popup->arrows_visible    = TRUE;
      popup->upper_arrow_state = GTK_STATE_INSENSITIVE;

      gtk_alignment_set_padding (GTK_ALIGNMENT (popup->alignment),
                                 popup->scroll_arrow_height + 2,
                                 popup->scroll_arrow_height + 2, 0, 0);

      popup_height -= 2 * popup->scroll_arrow_height + 4;

      popup->scroll_height = height - popup_rect.height;
      popup->scroll_y      = 0;
      popup->scroll_step   = 0;
    }

  gtk_widget_set_size_request (popup->tag_area, width, popup_height);

  gtk_window_move (GTK_WINDOW (popup), popup_rect.x, popup_rect.y);
  gtk_window_resize (GTK_WINDOW (popup), popup_rect.width, popup_rect.height);
}
示例#25
0
int main(int argc, char *argv[])
{
	GtkWidget *window;
	GtkWidget *image;
	GtkWidget *fixed;
	// GtkWidget *item;
	GtkWidget *mainWindow;
	GdkScreen*  scr;
	GdkBitmap *window_mask;
	GdkPixmap *pixmap;
	GdkBitmap *pixmap_mask;
	int lang = get_lang();
	switch(lang)
	{
		case 0:
			item_labels[0] = g_strdup_printf("重启");
			item_labels[1] = g_strdup_printf("待机");
			item_labels[2] = g_strdup_printf("关机");
			item_labels[3] = g_strdup_printf("取消");
		break;
		case 1:
			item_labels[0] = g_strdup_printf("Restart");
			item_labels[1] = g_strdup_printf("Stand By");
			item_labels[2] = g_strdup_printf("Turn off");
			item_labels[3] = g_strdup_printf("Cancel");
		break;
		case 2:
			item_labels[0] = g_strdup_printf("再起動");
			item_labels[1] = g_strdup_printf("スタンバイ");
			item_labels[2] = g_strdup_printf("電源を切る");
			item_labels[3] = g_strdup_printf("キャンセル");
		break;
	}
	gtk_init(&argc, &argv);
//----------------------------------------------
	mainWindow = gtk_window_new( GTK_WINDOW_POPUP);
	scr = gtk_window_get_screen( GTK_WINDOW( mainWindow));
   GdkColor white;
gdk_color_parse("#9c9c9c",&white);
gtk_widget_modify_bg(mainWindow,GTK_STATE_NORMAL,&white);	
	gtk_window_set_default_size( GTK_WINDOW( mainWindow), 
		gdk_screen_get_width( scr), 
		gdk_screen_get_height( scr));
//gtk_widget_set_size_request(mainWindow, window_width, window_height);
	gtk_window_fullscreen( GTK_WINDOW( mainWindow));
	gtk_widget_show_all( mainWindow);
	gtk_widget_realize(GTK_WIDGET(mainWindow));
	Display *xdpy = XOpenDisplay(getenv("DISPLAY"));
  	GdkWindow *gdkwin = GTK_WIDGET(mainWindow)->window;
  	Window xwin = GDK_WINDOW_XID(gdkwin);

  	unsigned int opacity = (unsigned int) (0.70 * OPAQUE);
  
  	XChangeProperty(xdpy, xwin, XInternAtom(xdpy, OPACITY, False), 
		    XA_CARDINAL, 32, PropModeReplace, 
		    (unsigned char *) &opacity, 1L);
  	// XSync(xdpy, False);
//----------------------------------------------
	window = gtk_window_new(GTK_WINDOW_POPUP);
	g_signal_connect(G_OBJECT(window), "destroy",
						G_CALLBACK(destroy), NULL);

	gtk_window_set_default_size(GTK_WINDOW(window), window_width, window_height);
//gtk_widget_set_size_request(window, window_width, window_height);
	 //gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
	gtk_window_move(GTK_WINDOW(window), 249,163);
	gtk_window_set_modal(window,FALSE);
	gtk_window_set_decorated(GTK_WINDOW(window), FALSE);
	gtk_window_set_title (GTK_WINDOW (window),"CloseWindow");
	
	/*gdk_pointer_grab (window->window, FALSE,
			(GdkEventMask)EVENT_MASKS, 0,
			NULL,
			GDK_CURRENT_TIME);*/



	gdk_pixmap_create_from_xpm(window->window, &window_mask, NULL, background_png);
	gtk_widget_shape_combine_mask (window, window_mask, 0, 0);

 gtk_widget_realize(GTK_WIDGET(window));

  Display *xdpy2 = XOpenDisplay(getenv("DISPLAY"));
  GdkWindow *gdkwin2 = GTK_WIDGET(window)->window;
  Window xwin2 = GDK_WINDOW_XID(gdkwin2);

  unsigned int opacity2 = (unsigned int) (0.80 * OPAQUE);
  
  XChangeProperty(xdpy2, xwin2, XInternAtom(xdpy2, OPACITY, False), 
		    XA_CARDINAL, 32, PropModeReplace, 
		    (unsigned char *) &opacity2, 1L);
  
gtk_widget_show_all(window);

	fixed = gtk_fixed_new();
	gtk_container_add(GTK_CONTAINER(window), fixed);
	gtk_widget_show(fixed);

	pixmap = gdk_pixmap_create_from_xpm(window->window, &pixmap_mask, NULL, background_png);
	image = gtk_image_new_from_pixmap(pixmap, pixmap_mask);
	gtk_fixed_put(GTK_FIXED(fixed), image, 0, 0);
	gtk_widget_show(image);

	make_icon_area(fixed);

	//make_cancel_button(fixed);
	XSync(xdpy, False);XSync(xdpy2, False);
	gtk_main();

	return 0;
}
示例#26
0
void init_stuff (int argc, char *argv[])
{
  GtkWidget *w;
  GList *dev_list;
  GdkDevice *device;
  GdkScreen *screen;
  int i, j;
  struct Brush *b;
  gboolean can_xinput, success;
  gchar *tmppath, *tmpfn;

  // create some data structures needed to populate the preferences
  ui.default_page.bg = g_new(struct Background, 1);

  // initialize config file names
  tmppath = g_build_filename(g_get_home_dir(), CONFIG_DIR, NULL);
  mkdir(tmppath, 0700); // safer (MRU data may be confidential)
  ui.mrufile = g_build_filename(tmppath, MRU_FILE, NULL);
  ui.configfile = g_build_filename(tmppath, CONFIG_FILE, NULL);
  g_free(tmppath);

  // initialize preferences
  init_config_default();
  load_config_from_file();
  ui.font_name = g_strdup(ui.default_font_name);
  ui.font_size = ui.default_font_size;
  ui.hiliter_alpha_mask = 0xffffff00 + (guint)(255*ui.hiliter_opacity);

  // we need an empty canvas prior to creating the journal structures
  canvas = GNOME_CANVAS (gnome_canvas_new_aa ());

  // initialize data
  ui.default_page.bg->canvas_item = NULL;
  ui.layerbox_length = 0;

  if (argc > 2 || (argc == 2 && argv[1][0] == '-')) {
    printf(_("Invalid command line parameters.\n"
           "Usage: %s [filename.xoj]\n"), argv[0]);
    gtk_exit(0);
  }
   
  undo = NULL; redo = NULL;
  journal.pages = NULL;
  bgpdf.status = STATUS_NOT_INIT;

  new_journal();  
  
  ui.cur_item_type = ITEM_NONE;
  ui.cur_item = NULL;
  ui.cur_path.coords = NULL;
  ui.cur_path_storage_alloc = 0;
  ui.cur_path.ref_count = 1;
  ui.cur_widths = NULL;
  ui.cur_widths_storage_alloc = 0;

  ui.selection = NULL;
  ui.cursor = NULL;
  ui.pen_cursor_pix = ui.hiliter_cursor_pix = NULL;

  ui.cur_brush = &(ui.brushes[0][ui.toolno[0]]);
  for (j=0; j<=NUM_BUTTONS; j++)
    for (i=0; i < NUM_STROKE_TOOLS; i++) {
      b = &(ui.brushes[j][i]);
      b->tool_type = i;
      if (b->color_no>=0) {
        b->color_rgba = predef_colors_rgba[b->color_no];
        if (i == TOOL_HIGHLIGHTER) {
          b->color_rgba &= ui.hiliter_alpha_mask;
        }
      }
      b->thickness = predef_thickness[i][b->thickness_no];
    }
  for (i=0; i<NUM_STROKE_TOOLS; i++)
    g_memmove(ui.default_brushes+i, &(ui.brushes[0][i]), sizeof(struct Brush));

  ui.cur_mapping = 0;
  ui.which_unswitch_button = 0;
  
  reset_recognizer();

  // initialize various interface elements
  
  gtk_window_set_default_size(GTK_WINDOW (winMain), ui.window_default_width, ui.window_default_height);
  if (ui.maximize_at_start) gtk_window_maximize(GTK_WINDOW (winMain));
  update_toolbar_and_menu();
  update_font_button();

  gtk_check_menu_item_set_active(
    GTK_CHECK_MENU_ITEM(GET_COMPONENT("journalApplyAllPages")), ui.bg_apply_all_pages);
  if (ui.fullscreen) {
    gtk_check_menu_item_set_active(
      GTK_CHECK_MENU_ITEM(GET_COMPONENT("viewFullscreen")), TRUE);
    gtk_toggle_tool_button_set_active(
      GTK_TOGGLE_TOOL_BUTTON(GET_COMPONENT("buttonFullscreen")), TRUE);
    gtk_window_fullscreen(GTK_WINDOW(winMain));
  }
  gtk_button_set_relief(GTK_BUTTON(GET_COMPONENT("buttonColorChooser")), GTK_RELIEF_NONE);

  allow_all_accels();
  add_scroll_bindings();

  // prevent interface items from stealing focus
  // glade doesn't properly handle can_focus, so manually set it
  gtk_combo_box_set_focus_on_click(GTK_COMBO_BOX(GET_COMPONENT("comboLayer")), FALSE);
  g_signal_connect(GET_COMPONENT("spinPageNo"), "activate",
          G_CALLBACK(handle_activate_signal), NULL);
  gtk_container_forall(GTK_CONTAINER(winMain), unset_flags, (gpointer)GTK_CAN_FOCUS);
  GTK_WIDGET_SET_FLAGS(GTK_WIDGET(canvas), GTK_CAN_FOCUS);
  GTK_WIDGET_SET_FLAGS(GTK_WIDGET(GET_COMPONENT("spinPageNo")), GTK_CAN_FOCUS);
  
  // install hooks on button/key/activation events to make the spinPageNo lose focus
  gtk_container_forall(GTK_CONTAINER(winMain), install_focus_hooks, NULL);

  // set up and initialize the canvas

  gtk_widget_show (GTK_WIDGET (canvas));
  w = GET_COMPONENT("scrolledwindowMain");
  gtk_container_add (GTK_CONTAINER (w), GTK_WIDGET (canvas));
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (w), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_widget_set_events (GTK_WIDGET (canvas), GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
  gnome_canvas_set_pixels_per_unit (canvas, ui.zoom);
  gnome_canvas_set_center_scroll_region (canvas, TRUE);
  gtk_layout_get_hadjustment(GTK_LAYOUT (canvas))->step_increment = ui.scrollbar_step_increment;
  gtk_layout_get_vadjustment(GTK_LAYOUT (canvas))->step_increment = ui.scrollbar_step_increment;

  // set up the page size and canvas size
  update_page_stuff();

  g_signal_connect ((gpointer) canvas, "button_press_event",
                    G_CALLBACK (on_canvas_button_press_event),
                    NULL);
  g_signal_connect ((gpointer) canvas, "button_release_event",
                    G_CALLBACK (on_canvas_button_release_event),
                    NULL);
  g_signal_connect ((gpointer) canvas, "enter_notify_event",
                    G_CALLBACK (on_canvas_enter_notify_event),
                    NULL);
  g_signal_connect ((gpointer) canvas, "leave_notify_event",
                    G_CALLBACK (on_canvas_leave_notify_event),
                    NULL);
  g_signal_connect ((gpointer) canvas, "expose_event",
                    G_CALLBACK (on_canvas_expose_event),
                    NULL);
  g_signal_connect ((gpointer) canvas, "key_press_event",
                    G_CALLBACK (on_canvas_key_press_event),
                    NULL);
  g_signal_connect ((gpointer) canvas, "motion_notify_event",
                    G_CALLBACK (on_canvas_motion_notify_event),
                    NULL);
  g_signal_connect ((gpointer) gtk_layout_get_vadjustment(GTK_LAYOUT(canvas)),
                    "value-changed", G_CALLBACK (on_vscroll_changed),
                    NULL);
  g_signal_connect ((gpointer) gtk_layout_get_hadjustment(GTK_LAYOUT(canvas)),
                    "value-changed", G_CALLBACK (on_hscroll_changed),
                    NULL);
  g_object_set_data (G_OBJECT (winMain), "canvas", canvas);

  screen = gtk_widget_get_screen(winMain);
  ui.screen_width = gdk_screen_get_width(screen);
  ui.screen_height = gdk_screen_get_height(screen);
  
  can_xinput = FALSE;
  dev_list = gdk_devices_list();
  while (dev_list != NULL) {
    device = (GdkDevice *)dev_list->data;
    if (device != gdk_device_get_core_pointer() && device->num_axes >= 2) {
      /* get around a GDK bug: map the valuator range CORRECTLY to [0,1] */
#ifdef ENABLE_XINPUT_BUGFIX
      gdk_device_set_axis_use(device, 0, GDK_AXIS_IGNORE);
      gdk_device_set_axis_use(device, 1, GDK_AXIS_IGNORE);
#endif
      gdk_device_set_mode(device, GDK_MODE_SCREEN);
      if (g_strrstr(device->name, "raser"))
        gdk_device_set_source(device, GDK_SOURCE_ERASER);
      can_xinput = TRUE;
    }
    dev_list = dev_list->next;
  }
  if (!can_xinput)
    gtk_widget_set_sensitive(GET_COMPONENT("optionsUseXInput"), FALSE);

  ui.use_xinput = ui.allow_xinput && can_xinput;

  gtk_check_menu_item_set_active(
    GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsProgressiveBG")), ui.progressive_bg);
  gtk_check_menu_item_set_active(
    GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsPrintRuling")), ui.print_ruling);
  gtk_check_menu_item_set_active(
    GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsAutoloadPdfXoj")), ui.autoload_pdf_xoj);
  gtk_check_menu_item_set_active(
    GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsLeftHanded")), ui.left_handed);
  gtk_check_menu_item_set_active(
    GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsShortenMenus")), ui.shorten_menus);
  gtk_check_menu_item_set_active(
    GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsAutoSavePrefs")), ui.auto_save_prefs);
  gtk_check_menu_item_set_active(
    GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsButtonSwitchMapping")), ui.button_switch_mapping);
  gtk_check_menu_item_set_active(
    GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsPenCursor")), ui.pen_cursor);
  
  hide_unimplemented();

  update_undo_redo_enabled();
  update_copy_paste_enabled();
  update_vbox_order(ui.vertical_order[ui.fullscreen?1:0]);
  gtk_widget_grab_focus(GTK_WIDGET(canvas));

  // show everything...
  
  gtk_widget_show (winMain);
  update_cursor();

  /* this will cause extension events to get enabled/disabled, but
     we need the windows to be mapped first */
  gtk_check_menu_item_set_active(
    GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsUseXInput")), ui.use_xinput);

  /* fix a bug in GTK+ 2.16 and 2.17: scrollbars shouldn't get extended
     input events from pointer motion when cursor moves into main window */

  if (!gtk_check_version(2, 16, 0)) {
    g_signal_connect (
      GET_COMPONENT("menubar"),
      "event", G_CALLBACK (filter_extended_events),
      NULL);
    g_signal_connect (
      GET_COMPONENT("toolbarMain"),
      "event", G_CALLBACK (filter_extended_events),
      NULL);
    g_signal_connect (
      GET_COMPONENT("toolbarPen"),
      "event", G_CALLBACK (filter_extended_events),
      NULL);
    g_signal_connect (
      GET_COMPONENT("statusbar"),
      "event", G_CALLBACK (filter_extended_events),
      NULL);
    g_signal_connect (
      (gpointer)(gtk_scrolled_window_get_vscrollbar(GTK_SCROLLED_WINDOW(w))),
      "event", G_CALLBACK (filter_extended_events),
      NULL);
    g_signal_connect (
      (gpointer)(gtk_scrolled_window_get_hscrollbar(GTK_SCROLLED_WINDOW(w))),
      "event", G_CALLBACK (filter_extended_events),
      NULL);
  }

  // load the MRU
  
  init_mru();

  // and finally, open a file specified on the command line
  // (moved here because display parameters weren't initialized yet...)
  
  if (argc == 1) return;
  set_cursor_busy(TRUE);
  if (g_path_is_absolute(argv[1]))
    tmpfn = g_strdup(argv[1]);
  else {
    tmppath = g_get_current_dir();
    tmpfn = g_build_filename(tmppath, argv[1], NULL);
    g_free(tmppath);
  }
  success = open_journal(tmpfn);
  g_free(tmpfn);
  set_cursor_busy(FALSE);
  if (!success) {
    w = gtk_message_dialog_new(GTK_WINDOW (winMain), GTK_DIALOG_DESTROY_WITH_PARENT,
       GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Error opening file '%s'"), argv[1]);
    gtk_dialog_run(GTK_DIALOG(w));
    gtk_widget_destroy(w);
  }
}
示例#27
0
/* erstellt die Bedienungsoberfläche */
GtkWidget *gui_create(void)
{
    gint i, scr_width, scr_height;
    GdkScreen *screen;
    GtkWidget *window, *box[N_BOXES];

    /* ruft die Abmessungen des Bildschirms (screen) ab */
    screen = gdk_screen_get_default();
    scr_width = gdk_screen_get_width(screen);
    scr_height = gdk_screen_get_height(screen);

    /* erstellt das Hauptfenster, und setzt Größe,
       Namen und Randabstand */
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_default_size(GTK_WINDOW(window),
                                scr_width * 0.85, scr_height * 0.85);
    gtk_window_set_title(GTK_WINDOW(window),
                         _("Simulation of radioactive decay"));
    gtk_container_set_border_width(GTK_CONTAINER(window), 5);

    /* verknüpft das Hauptfenster mit Callback-Funktionen */
    g_signal_connect(G_OBJECT(window),
                     "delete_event",
                     G_CALLBACK(gui_delete),
                     NULL);

    g_signal_connect(G_OBJECT(window),
                     "destroy",
                     G_CALLBACK(gui_destroy),
                     NULL);

    /* erstellt Layout

       Skizze der Kästen (box)
       |-0---------------------------------------------------|
       | |-1-----------------------------------------------| |
       | |                               |-2-------------| | |
       | |                               |               | | |
       | |                               |               | | |
       | |                               |               | | |
       | |                               |               | | |
       | |                               | |-3---------| | | |
       | |                               | |           | | | |
       | |                               | |-----------| | | |
       | |                               |---------------| | |
       | |-------------------------------------------------| |
       |                                                     |
       | |-4-----------------------------------------------| |
       | | |-5---| |-6------------------------| |-7------| | |
       | | |     | |                          | |        | | |
       | | |-----| |--------------------------| |--------| | |
       | |-------------------------------------------------| |
       |-----------------------------------------------------|
    */

    box[0] = gtk_vbox_new(FALSE, 0);
    gtk_container_add(GTK_CONTAINER(window), box[0]);

    box[1] = gtk_hbox_new(FALSE, 0);
    gtk_box_pack_start(GTK_BOX(box[0]), box[1], TRUE, TRUE, 0);

    box[2] = gtk_vbox_new(FALSE, 0);

    /* erstellt die beiden Zeichenbereiche */
    create_dareas(window, box[1], box[2]);

    box[3] = gtk_vbox_new(FALSE, 0);
    gtk_box_pack_start(GTK_BOX(box[2]), box[3], FALSE, FALSE, 0);

    /* erstellt die Status-Anzeigen */
    create_status(window, box[3]);

    box[4] = gtk_hbox_new(FALSE, 20);
    gtk_box_pack_start(GTK_BOX(box[0]), box[4], FALSE, FALSE, 0);

    box[5] = gtk_vbox_new(FALSE, 0);
    gtk_box_pack_start(GTK_BOX(box[4]), box[5], FALSE, FALSE, 0);

    /* erstellt die Eingabefelder */
    create_sim_input(window, box[5]);

    box[6] = gtk_vbox_new(FALSE, 0);
    gtk_box_pack_start(GTK_BOX(box[4]), box[6], FALSE, FALSE, 0);

    /* erstellt die Graphen-Auswahl */
    create_graph_input(window, box[6]);

    box[7] = gtk_vbox_new(FALSE, 0);
    gtk_box_pack_start(GTK_BOX(box[4]), box[7], TRUE, TRUE, 0);

    toggle_states(g_object_get_data(G_OBJECT(window), "spin_states"),
                  window);

    /* erstellt die Buttons */
    create_buttons(window, box[7]);

    /* gibt die Widgets zum Zeichnen auf dem Bildschirm frei */
    for (i = 0; i < N_BOXES; i++)
        gtk_widget_show(box[i]);
    gtk_widget_show(window);

    /* erstellt eine Liste mit ein paar Farben, die dann
       später im Programm benutzt werden (das _muss_ nach
       dem Zeichnen auf den Bildschirm passieren) */
    create_colors(window);

    /* setzt die Farben der Checkboxen der Graphen */
    color_graph_input(window);
    
    return window;
}
示例#28
0
bool wxTopLevelWindowGTK::ShowFullScreen(bool show, long)
{
    if (show == m_fsIsShowing)
        return false; // return what?

    m_fsIsShowing = show;

#ifdef GDK_WINDOWING_X11
    GdkScreen* screen = gtk_widget_get_screen(m_widget);
    GdkDisplay* display = gdk_screen_get_display(screen);
    Display* xdpy = NULL;
    Window xroot = None;
    wxX11FullScreenMethod method = wxX11_FS_WMSPEC;

    if (GDK_IS_X11_DISPLAY(display))
    {
        xdpy = GDK_DISPLAY_XDISPLAY(display);
        xroot = GDK_WINDOW_XID(gdk_screen_get_root_window(screen));
        method = wxGetFullScreenMethodX11(xdpy, (WXWindow)xroot);
    }

    // NB: gtk_window_fullscreen() uses freedesktop.org's WMspec extensions
    //     to switch to fullscreen, which is not always available. We must
    //     check if WM supports the spec and use legacy methods if it
    //     doesn't.
    if ( method == wxX11_FS_WMSPEC )
#endif // GDK_WINDOWING_X11
    {
        if (show)
            gtk_window_fullscreen( GTK_WINDOW( m_widget ) );
        else
            gtk_window_unfullscreen( GTK_WINDOW( m_widget ) );
    }
#ifdef GDK_WINDOWING_X11
    else if (xdpy != NULL)
    {
        GdkWindow* window = gtk_widget_get_window(m_widget);
        Window xid = GDK_WINDOW_XID(window);

        if (show)
        {
            GetPosition( &m_fsSaveFrame.x, &m_fsSaveFrame.y );
            GetSize( &m_fsSaveFrame.width, &m_fsSaveFrame.height );

            const int screen_width = gdk_screen_get_width(screen);
            const int screen_height = gdk_screen_get_height(screen);

            gint client_x, client_y, root_x, root_y;
            gint width, height;

            m_fsSaveGdkFunc = m_gdkFunc;
            m_fsSaveGdkDecor = m_gdkDecor;
            m_gdkFunc = m_gdkDecor = 0;
            gdk_window_set_decorations(window, (GdkWMDecoration)0);
            gdk_window_set_functions(window, (GdkWMFunction)0);

            gdk_window_get_origin(window, &root_x, &root_y);
            gdk_window_get_geometry(window, &client_x, &client_y, &width, &height);

            gdk_window_move_resize(
                window, -client_x, -client_y, screen_width + 1, screen_height + 1);

            wxSetFullScreenStateX11(xdpy,
                                    (WXWindow)xroot,
                                    (WXWindow)xid,
                                    show, &m_fsSaveFrame, method);
        }
        else // hide
        {
            m_gdkFunc = m_fsSaveGdkFunc;
            m_gdkDecor = m_fsSaveGdkDecor;
            gdk_window_set_decorations(window, (GdkWMDecoration)m_gdkDecor);
            gdk_window_set_functions(window, (GdkWMFunction)m_gdkFunc);

            wxSetFullScreenStateX11(xdpy,
                                    (WXWindow)xroot,
                                    (WXWindow)xid,
                                    show, &m_fsSaveFrame, method);

            SetSize(m_fsSaveFrame.x, m_fsSaveFrame.y,
                    m_fsSaveFrame.width, m_fsSaveFrame.height);
        }
    }
#endif // GDK_WINDOWING_X11

    // documented behaviour is to show the window if it's still hidden when
    // showing it full screen
    if (show)
        Show();

    return true;
}
/**
 * gsc_utils_move_to_iter:
 * @window: the #GtkWindow to move
 * @view: the view
 * @iter: the iter to move @window to
 *
 */
void
gsc_utils_move_to_iter (GtkWindow     *window,
                        GtkTextView *view,
                        GtkTextIter   *iter)
{
    gint x;
    gint y;
    gint w;
    gint h;
    gint cx;
    gint cy;
    gint oy;
    gint height;
    GdkScreen *screen;
    gboolean overlapup;

    gint sw = gdk_screen_width();
    gint sh = gdk_screen_height();

    if (window != NULL)
    {
        screen = gtk_window_get_screen (window);
    }
    else
    {
        screen = gdk_screen_get_default ();
    }

    sw = gdk_screen_get_width (screen);
    sh = gdk_screen_get_height (screen);

    get_iter_pos (view, iter, &x, &y, &height);
    gtk_window_get_size (window, &w, &h);

    oy = y;
    compensate_for_gravity (window, &cx, &cy, w, h);

    /* Push window inside screen */
    if (x - cx + w > sw)
    {
        x = (sw - w) + cx;
    }
    else if (x - cx < 0)
    {
        x = cx;
    }

    if (y - cy + h > sh)
    {
        y = (sh - h) + cy;
        overlapup = TRUE;
    }
    else if (y - cy < 0)
    {
        y = cy;
        overlapup = FALSE;
    }
    else
    {
        overlapup = TRUE;
    }

    /* Make sure that text is still readable */
    move_overlap (&x, &y, w, h, oy, cx, cy, height, overlapup);

    gtk_window_move (window, x, y);
}