Exemplo n.º 1
0
static gboolean on_parallel_configure_event(GtkWidget *widget,
					    GdkEventConfigure *event,
					    gpointer user_data)
{
	gchar layout[10];
	gint x;
	gint y;

	gdk_window_get_root_origin(GDK_WINDOW(gtk_widget_get_window(dialog_parallel)), &x, &y);

	settings.parallel_width = event->width;
	settings.parallel_height = event->height;
	settings.parallel_x = x;
	settings.parallel_y = y;

	sprintf(layout, "%d", settings.parallel_width);
	xml_set_value("Xiphos", "layout", "parallel_width", layout);

	sprintf(layout, "%d", settings.parallel_height);
	xml_set_value("Xiphos", "layout", "parallel_height", layout);

	sprintf(layout, "%d", settings.parallel_x);
	xml_set_value("Xiphos", "layout", "parallel_x", layout);

	sprintf(layout, "%d", settings.parallel_y);
	xml_set_value("Xiphos", "layout", "parallel_y", layout);
	xml_save_settings_doc(settings.fnconfigure);

	return FALSE;
}
Exemplo n.º 2
0
gint layout_geometry_get_tools(LayoutWindow *lw, gint *x, gint *y, gint *w, gint *h, gint *divider_pos)
{
	if (!layout_valid(&lw)) return FALSE;

	if (!lw->tools || !GTK_WIDGET_VISIBLE(lw->tools))
		{
		/* use the stored values (sort of breaks success return value) */

		*divider_pos = lw->div_float;

		return FALSE;
		}

	gdk_window_get_root_origin(lw->tools->window, x, y);
	gdk_drawable_get_size(lw->tools->window, w, h);

	if (GTK_IS_VPANED(lw->tools_pane))
		{
		*divider_pos = GTK_PANED(lw->tools_pane)->child1->allocation.height;
		}
	else
		{
		*divider_pos = GTK_PANED(lw->tools_pane)->child1->allocation.width;
		}

	return TRUE;
}
Exemplo n.º 3
0
static VALUE
gdkwin_get_root_origin(VALUE self)
{
    int x, y;
    gdk_window_get_root_origin(_SELF(self), &x, &y);
    return rb_assoc_new(INT2FIX(x), INT2FIX(y));
}
Exemplo n.º 4
0
gint title_motion_event(GtkWidget *widget, GdkEventMotion *event)
{
	gint mov_x, mov_y;
	gint win_x, win_y;

	gint xp, yp;
	GdkModifierType mask;
	static GdkWindow *root_win = NULL;

	//LOG(LOG_DEBUG, "IN : title_motion_event()");

	if((event->state & GDK_BUTTON1_MASK) &&
	   bbutton_down){

		root_win = gdk_window_foreign_new (GDK_ROOT_WINDOW ());
		gdk_window_get_pointer (root_win, &xp, &yp, &mask);

	        mov_x = xp - prev_x;
	        mov_y = yp - prev_y;

 	        gdk_window_get_root_origin(popup->window, &win_x, &win_y);

		gtk_window_move(GTK_WINDOW(popup),
				win_x + mov_x,
				win_y + mov_y);
		prev_x = xp;
		prev_y = yp;
	}

	//LOG(LOG_DEBUG, "OUT : title_motion_event()");
	return(FALSE);
}
Exemplo n.º 5
0
static gboolean on_configure_event(GtkWidget *widget,
				   GdkEventConfigure *event,
				   gpointer user_data)
{
	gchar layout[80];
	gint x;
	gint y;

	gdk_window_get_root_origin(gtk_widget_get_window(widgets.app), &x, &y);

	settings.gs_width = event->width;
	settings.gs_height = event->height;
	settings.app_x = x;
	settings.app_y = y;

#ifdef HAVE_GTK_312
	sprintf(layout, "%d", gtk_window_is_maximized(GTK_WINDOW(widgets.app)));
	xml_set_value("Xiphos", "layout", "maximized", layout);
#endif

	sprintf(layout, "%d", settings.gs_width);
	xml_set_value("Xiphos", "layout", "width", layout);

	sprintf(layout, "%d", settings.gs_height);
	xml_set_value("Xiphos", "layout", "height", layout);

	sprintf(layout, "%d", settings.app_x);
	xml_set_value("Xiphos", "layout", "app_x", layout);

	sprintf(layout, "%d", settings.app_y);
	xml_set_value("Xiphos", "layout", "app_y", layout);
	xml_save_settings_doc(settings.fnconfigure);

	return FALSE;
}
Exemplo n.º 6
0
static void gtkDialogGetWindowDecor(Ihandle* ih, int *win_border, int *win_caption)
{
  int x, y, frame_x, frame_y;
  gdk_window_get_origin(iupgtkGetWindow(ih->handle), &x, &y);
  gdk_window_get_root_origin(iupgtkGetWindow(ih->handle), &frame_x, &frame_y);
  *win_border = x-frame_x;
  *win_caption = y-frame_y-*win_border;
}
Exemplo n.º 7
0
static int gtkDialogGetWindowDecor(Ihandle* ih, int *win_border, int *win_caption)
{
  int x, y, frame_x, frame_y;
  gdk_window_get_origin(ih->handle->window, &x, &y);
  gdk_window_get_root_origin(ih->handle->window, &frame_x, &frame_y);
  *win_border = x-frame_x;
  *win_caption = y-frame_y-*win_border;
  return 1;  /* just for compatibility with iupdrvGetWindowDecor */
}
Exemplo n.º 8
0
gint layout_geometry_get(LayoutWindow *lw, gint *x, gint *y, gint *w, gint *h)
{
	if (!layout_valid(&lw)) return FALSE;

	gdk_window_get_root_origin(lw->window->window, x, y);
	gdk_drawable_get_size(lw->window->window, w, h);

	return TRUE;
}
Exemplo n.º 9
0
static void fftscope_hide()
{
	gint x, y;

	if (scope_win) {
		gdk_window_get_root_origin(scope_win->window, &x, &y);
		gtk_widget_hide(scope_win);
		gtk_widget_set_uposition(scope_win, x, y);
	}
}
Exemplo n.º 10
0
void ShowDialog(UIDialog* dialog, gchar* default_widget) 
{
	gint sw, sh;
	gint px, py;
	gint pw, ph;
	gint cw, ch;
	gint ox, oy;

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

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

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

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

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

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

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

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

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

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

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

	gtk_widget_show(dialog->window);
	gtk_main();
}
Exemplo n.º 11
0
void HideDialog(UIDialog* dialog) 
{
	gint pos_x, pos_y;
	gdk_window_get_root_origin(dialog->window->window, &pos_x, &pos_y);

	dialog->pos_x = pos_x;
	dialog->pos_y = pos_y;

	gtk_widget_hide(GetTopWidget(dialog->window));
	gtk_main_quit();
}
Exemplo n.º 12
0
void
tasks_add_edit_window_close_cb (GtkWidget *widget, GdkEvent *event, gpointer user_data) {

    GUI *appGUI = (GUI *)user_data;

    gtk_window_get_size (GTK_WINDOW(appGUI->tsk->tasks_add_window),
                        &config.tasks_addedit_win_w, &config.tasks_addedit_win_h);
    gdk_window_get_root_origin (GDK_WINDOW(appGUI->tsk->tasks_add_window->window),
                             &config.tasks_addedit_win_x, &config.tasks_addedit_win_y);
    gtk_widget_destroy(appGUI->tsk->tasks_add_window);
}
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;
    GdkScreen *screen = gdk_screen_get_default();
    int monitors_count = gdk_screen_get_n_monitors(screen);
    char *str = iupStrGetMemory(monitors_count*50);
    char* pstr = str;
    GdkRectangle rect;

    for (i=0; i < monitors_count; i++)
    {
      gdk_screen_get_monitor_geometry(screen, i, &rect);
      pstr += sprintf(pstr, "%d %d %d %d\n", rect.x, rect.y, rect.width, rect.height);
    }

    return str;
  }
  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());
  }
  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;
}
Exemplo n.º 14
0
Arquivo: gtk.c Projeto: Airr/Claro
/* "borrowed" from http://mail.gnome.org/archives/gtk-app-devel-list/2004-November/msg00028.html */
static void widget_get_rect_in_screen( GtkWidget *widget, GdkRectangle *r )
{
	gint x,y,w,h;
	GdkRectangle extents;
	GdkWindow *window;
	window = gtk_widget_get_parent_window(widget); /* getting parent window */
	gdk_window_get_root_origin(window, &x,&y); /* parent's left-top screen coordinates */
	gdk_drawable_get_size(window, &w,&h); /* parent's width and height */
	gdk_window_get_frame_extents(window, &extents); /* parent's extents (including decorations) */
	r->x = x + (extents.width-w)/2 + widget->allocation.x; /* calculating x (assuming: left border size == right border size) */
	r->y = y + (extents.height-h)-(extents.width-w)/2 + widget->allocation.y; /* calculating y (assuming: left border size == right border size == bottom border size) */
	r->width = widget->allocation.width;
	r->height = widget->allocation.height;
}
JNIEXPORT void JNICALL 
Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWindowGetLocationOnScreenUnlocked
  (JNIEnv * env, jobject obj, jintArray jpoint)
{
  void *ptr;
  jint *point;

  ptr = gtkpeer_get_widget (env, obj);
  point = (*env)->GetIntArrayElements (env, jpoint, 0);

  gdk_window_get_root_origin (get_widget(GTK_WIDGET (ptr))->window, point, point+1);

  (*env)->ReleaseIntArrayElements(env, jpoint, point, 0);
}
Exemplo n.º 16
0
void
export_window_close_cb (GtkWidget *widget, GdkEvent *event, gpointer user_data) {

    GUI *appGUI = (GUI *)user_data;

    gtk_window_get_size (GTK_WINDOW(appGUI->cnt->export_window),
                        &config.contacts_export_win_w, &config.contacts_export_win_h);
    gdk_window_get_root_origin (GDK_WINDOW(appGUI->cnt->export_window->window),
                                &config.contacts_export_win_x, &config.contacts_export_win_y);

    gtk_widget_destroy(appGUI->cnt->export_window);
    appGUI->cnt->output_file_entry = NULL;
    appGUI->cnt->export_button = NULL;
}
Exemplo n.º 17
0
static gboolean configure_callback(GtkWidget * w, GdkEventConfigure *event,
                                   gpointer data)
  {
  visualizer_t * win;
  
  win = (visualizer_t*)data;
  win->x = event->x;
  win->y = event->y;
  win->width = event->width;
  win->height = event->height;
  gdk_window_get_root_origin(win->current_window->window->window,
                             &win->x, &win->y);
  return FALSE;
  }
Exemplo n.º 18
0
static gboolean list_motion_notify(GtkWidget *widget, GdkEventMotion *event,
				   gpointer user_data)
{
     gint mx,my;
     gint wx,wy,ww,wh;
     
     gdk_window_get_root_origin(widget->window,&wx,&wy);
     gdk_window_get_size(widget->window,&ww,&wh);
     mx = (gint) (event->x_root);
     my = (gint) (event->y_root);

     /*printf("mouse: <%d,%d>, window: <%d,%d>+<%d,%d>\n",mx,my,wx,wy,ww,wh);*/
     if (mx < wx || mx > wx+ww || my < wy || my > wy+wh)
	  gtk_signal_emit_stop_by_name(GTK_OBJECT(widget),
				       "motion-notify-event");
     return FALSE;
}
Exemplo n.º 19
0
static gboolean
popup_button_press_event_cb (GtkWidget          *popup_window,
			     GdkEventButton     *event,
			     PlannerPopupButton *popup_button)
{
	GtkAllocation           alloc;
	gdouble                 x, y;
	gint                    xoffset, yoffset;
	gint                    x1, y1;
	gint                    x2, y2;

	/* Popdown the window if the click is outside of it. */

	if (event->button != 1) {
		return FALSE;
	}

	x = event->x_root;
	y = event->y_root;

	gdk_window_get_root_origin (popup_window->window,
				    &xoffset,
				    &yoffset);

	xoffset += popup_window->allocation.x;
	yoffset += popup_window->allocation.y;

	alloc = popup_window->allocation;
	x1 = alloc.x + xoffset;
	y1 = alloc.y + yoffset;
	x2 = x1 + alloc.width;
	y2 = y1 + alloc.height;

	if (x > x1 && x < x2 && y > y1 && y < y2) {
		return FALSE;
	}

	planner_popup_button_popdown (popup_button, FALSE);

	return FALSE;
}
Exemplo n.º 20
0
JNIEXPORT void JNICALL
Java_org_gnome_gdk_GdkWindow_gdk_1window_1get_1root_1origin
(
	JNIEnv* env,
	jclass cls,
	jlong _self,
	jintArray _x,
	jintArray _y
)
{
	GdkWindow* self;
	gint* x;
	gint* y;

	// convert parameter self
	self = (GdkWindow*) _self;

	// convert parameter x
	x = (gint*) (*env)->GetIntArrayElements(env, _x, NULL);
	if (x == NULL) {
		return; // Java Exception already thrown
	}

	// convert parameter y
	y = (gint*) (*env)->GetIntArrayElements(env, _y, NULL);
	if (y == NULL) {
		return; // Java Exception already thrown
	}

	// call function
	gdk_window_get_root_origin(self, x, y);

	// cleanup parameter self

	// cleanup parameter x
	(*env)->ReleaseIntArrayElements(env, _x, (jint*)x, 0);

	// cleanup parameter y
	(*env)->ReleaseIntArrayElements(env, _y, (jint*)y, 0);
}
Exemplo n.º 21
0
static gint
gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxTopLevelWindowGTK *win )
{
    if (g_isIdle)
        wxapp_install_idle_handler();

    if (!win->m_hasVMT || !win->IsShown())
        return FALSE;


    int x = 0;
    int y = 0;
    gdk_window_get_root_origin( win->m_widget->window, &x, &y );
    win->m_x = x;
    win->m_y = y;

    wxMoveEvent mevent( wxPoint(win->m_x,win->m_y), win->GetId() );
    mevent.SetEventObject( win );
    win->HandleWindowEvent( mevent );

    return FALSE;
}
Exemplo n.º 22
0
    static gboolean
    gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget),
                                  GdkEventConfigure *WXUNUSED(event),
                                  wxTopLevelWindowGTK *win )
    {
        // don't need to install idle handler, its done from "event" signal

        if (!win->m_hasVMT || !win->IsShown())
            return FALSE;


        int x = 0;
        int y = 0;
        gdk_window_get_root_origin( win->m_widget->window, &x, &y );
        win->m_x = x;
        win->m_y = y;

        wxMoveEvent mevent( wxPoint(win->m_x,win->m_y), win->GetId() );
        mevent.SetEventObject( win );
        win->GetEventHandler()->ProcessEvent( mevent );

        return FALSE;
    }
Exemplo n.º 23
0
Arquivo: gui.c Projeto: rosedu/osmo
void
gui_window_close_cb (GtkWidget *widget, gpointer data) {

    gui_url_remove_links (&about_links_list, &about_link_index);
    gui_url_remove_links (&contacts_links_list, &contacts_link_index);

    if (calendar_only == FALSE) {
        if (current_tab == PAGE_CALENDAR || current_tab == PAGE_TASKS || current_tab == PAGE_CONTACTS) {
            config.latest_tab = current_tab;
        }

        config.find_mode = gtk_combo_box_get_active (GTK_COMBO_BOX(contacts_find_combobox));

        gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON(notes_button), FALSE);

        gtk_window_get_size (GTK_WINDOW(main_window),
                            &config.window_size_x, &config.window_size_y);
    }

    gdk_window_get_root_origin (main_window->window,
                        &config.window_x, &config.window_y);

    pango_font_description_free(fd_day_name);
    pango_font_description_free(fd_calendar);
    pango_font_description_free(fd_notes);

    if (calendar_only == FALSE) {
        calendar_update_note (day, month, year);
        write_notes ();
        write_tasks_entries();
        write_tasks_entries();
        write_contacts_entries();
    }

    gtk_main_quit ();
}
Exemplo n.º 24
0
/**
 * gimp_session_info_read_geometry:
 * @info:  A #GimpSessionInfo
 * @cevent A #GdkEventConfigure. If set, use the size from here
 *         instead of from the window allocation.
 *
 * Read geometry related information from the associated widget.
 **/
void
gimp_session_info_read_geometry (GimpSessionInfo   *info,
                                 GdkEventConfigure *cevent)
{
  GdkWindow *window;

  g_return_if_fail (GIMP_IS_SESSION_INFO (info));
  g_return_if_fail (GTK_IS_WINDOW (info->p->widget));

  window = gtk_widget_get_window (info->p->widget);

  if (window)
    {
      gint x, y;

      gdk_window_get_root_origin (window, &x, &y);

      /* Don't write negative values to the sessionrc, they are
       * interpreted as relative to the right, respective bottom edge
       * of the screen.
       */
      info->p->x = MAX (0, x);
      info->p->y = MAX (0, y);

      if (gimp_session_info_get_remember_size (info))
        {
          int width;
          int height;

          if (cevent)
            {
              width  = cevent->width;
              height = cevent->height;
            }
          else
            {
              GtkAllocation allocation;

              gtk_widget_get_allocation (info->p->widget, &allocation);

              width  = allocation.width;
              height = allocation.height;
            }

          info->p->width  = width;
          info->p->height = height;
        }
      else
        {
          info->p->width  = 0;
          info->p->height = 0;
        }
    }

  info->p->open = FALSE;

  if (gimp_session_info_get_remember_if_open (info))
    {
      GimpDialogVisibilityState visibility;

      visibility =
        GPOINTER_TO_INT (g_object_get_data (G_OBJECT (info->p->widget),
                                            GIMP_DIALOG_VISIBILITY_KEY));

      switch (visibility)
        {
        case GIMP_DIALOG_VISIBILITY_UNKNOWN:
          info->p->open = gtk_widget_get_visible (info->p->widget);
          break;

        case GIMP_DIALOG_VISIBILITY_INVISIBLE:
          info->p->open = FALSE;
          break;

        case GIMP_DIALOG_VISIBILITY_HIDDEN:
        case GIMP_DIALOG_VISIBILITY_VISIBLE:
          /* Even if a dialog is hidden (with Windows->Hide docks) it
           * is still considered open. It will be restored the next
           * time GIMP starts
           */
          info->p->open = TRUE;
          break;
        }
    }

  info->p->screen = DEFAULT_SCREEN;

  if (info->p->open)
    {
      GdkDisplay *display = gtk_widget_get_display (info->p->widget);
      GdkScreen  *screen  = gtk_widget_get_screen (info->p->widget);

      if (screen != gdk_display_get_default_screen (display))
        info->p->screen = gdk_screen_get_number (screen);
    }
}
Exemplo n.º 25
0
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;
}
Exemplo n.º 26
0
Arquivo: init.c Projeto: UIKit0/eXtace
void save_config(GtkWidget *widget)
{
	gchar *filename;
	ConfigFile *cfgfile;
	gint x;
	gint y;
	filename = g_strconcat(g_get_home_dir(), "/.eXtace/config", NULL);
	cfgfile = cfg_open_file(filename);
	if (!cfgfile)
		cfgfile = cfg_new();

	cfg_write_int(cfgfile, "Global", "major_ver", _MAJOR_);
	cfg_write_int(cfgfile, "Global", "minor_ver", _MINOR_);
	cfg_write_int(cfgfile, "Global", "micro_ver", _MICRO_);
	if (Color_map.filename)
		cfg_write_string(cfgfile, "Global", "last_colormap", Color_map.filename);
	else
		cfg_write_string(cfgfile, "Global", "last_colormap",g_strconcat(g_get_home_dir(),"/.eXtace/ColorMaps/","Default",NULL));
	cfg_write_int(cfgfile, "Global", "mode", mode);
	cfg_write_int(cfgfile, "Global", "data_source", data_source);
	cfg_write_int(cfgfile, "Global", "decimation_factor", decimation_factor);
	cfg_write_int(cfgfile, "Global", "fft_signal_source", fft_signal_source);
	cfg_write_float(cfgfile, "Global", "scope_zoom", scope_zoom);
	cfg_write_int(cfgfile, "Global", "refresh_rate", refresh_rate);
	cfg_write_int(cfgfile, "Global", "landflip", landflip);
	cfg_write_int(cfgfile, "Global", "spikeflip", spikeflip);
	cfg_write_boolean(cfgfile, "Global", "outlined", outlined);
	cfg_write_int(cfgfile, "Global", "sub_mode_3D", sub_mode_3D);
	cfg_write_int(cfgfile, "Global", "scope_sub_mode", scope_sub_mode);
	cfg_write_boolean(cfgfile, "Global", "dir_win_present", dir_win_present);
	cfg_write_int(cfgfile, "Global", "nsamp", nsamp);
	cfg_write_int(cfgfile, "Global", "window_func", window_func);
	cfg_write_int(cfgfile, "Global", "win_width", win_width);
	cfg_write_int(cfgfile, "Global", "axis_type", axis_type);
	cfg_write_int(cfgfile, "Global", "bands", bands);
	cfg_write_int(cfgfile, "Global", "lag", lag);
	cfg_write_float(cfgfile, "Global", "noise_floor", noise_floor);
	cfg_write_int(cfgfile, "Global", "seg_height", seg_height);
	cfg_write_int(cfgfile, "Global", "seg_space", seg_space);
	cfg_write_boolean(cfgfile, "Global", "bar_decay", bar_decay);
	cfg_write_boolean(cfgfile, "Global", "peak_decay", peak_decay);
	cfg_write_boolean(cfgfile, "Global", "stabilized", stabilized);
	cfg_write_boolean(cfgfile, "Global", "show_graticule", show_graticule);
	cfg_write_int(cfgfile, "Global", "decay_speed", bar_decay_speed);
	cfg_write_int(cfgfile, "Global", "peak_decay_speed", peak_decay_speed);
	cfg_write_int(cfgfile, "Global", "peak_hold_time", peak_hold_time);
	cfg_write_int(cfgfile, "Global", "tape_scroll", tape_scroll);
	cfg_write_int(cfgfile, "Global", "xdet_scroll", xdet_scroll);
	cfg_write_int(cfgfile, "Global", "zdet_scroll", zdet_scroll);
	cfg_write_float(cfgfile, "Global", "xdet_start", xdet_start);
	cfg_write_float(cfgfile, "Global", "xdet_end", xdet_end);
	cfg_write_float(cfgfile, "Global", "ydet_start", ydet_start);
	cfg_write_float(cfgfile, "Global", "ydet_end", ydet_end);
	cfg_write_float(cfgfile, "Global", "x3d_start", x3d_start);
	cfg_write_float(cfgfile, "Global", "x3d_end", x3d_end);
	cfg_write_float(cfgfile, "Global", "y3d_start", y3d_start);
	cfg_write_float(cfgfile, "Global", "y3d_end", y3d_end);
	cfg_write_float(cfgfile, "Global", "multiplier", multiplier);
	cfg_write_int(cfgfile, "Global", "horiz_spec_start", horiz_spec_start);
	cfg_write_int(cfgfile, "Global", "vert_spec_start", vert_spec_start);
	cfg_write_int(cfgfile, "Global", "x3d_scroll", x3d_scroll);
	cfg_write_int(cfgfile, "Global", "z3d_scroll", z3d_scroll);
	cfg_write_boolean(cfgfile, "Global", "show_leader", show_leader);
	cfg_write_int(cfgfile, "Global", "scope_sync_source", scope_sync_source);
	cfg_write_boolean(cfgfile, "Global", "landtilt",landtilt);
	cfg_write_boolean(cfgfile, "Global", "spiketilt", spiketilt);
	cfg_write_float(cfgfile, "Global", "low_freq", low_freq);
	cfg_write_float(cfgfile, "Global", "high_freq", high_freq);
	cfg_write_int(cfgfile, "Window", "width", width);
	cfg_write_int(cfgfile, "Window", "height", height+22);
	gdk_window_get_root_origin(widget->window, &x, &y);
	cfg_write_int(cfgfile, "Window", "main_x_origin", x);
	cfg_write_int(cfgfile, "Window", "main_y_origin", y);
	//    cfg_write_boolean(cfgfile, "Window", "grad_win_present", grad_win_present);
	if (grad_win_present)
	{
		gdk_window_get_root_origin((gpointer) grad_win_ptr->window, &x, &y);
		cfg_write_int(cfgfile, "Window", "grad_x_origin", x);
		cfg_write_int(cfgfile, "Window", "grad_y_origin", y);
	}
	if (dir_win_present)
	{
		gdk_window_get_root_origin((gpointer) dir_win_ptr->window, &x, &y);
		cfg_write_int(cfgfile, "Window", "dir_x_origin", x);
		cfg_write_int(cfgfile, "Window", "dir_y_origin", y);
	}

	cfg_write_file(cfgfile, filename);
	cfg_free(cfgfile);

	g_free(filename);

}
Exemplo n.º 27
0
/*
 * Import record display and choice.
 * Put up the record for viewing and ask if it should be imported.
 */
int import_record_ask(GtkWidget *main_window, GtkWidget *pane,
                      char *text, struct CategoryAppInfo *cai,
                      char *old_cat_name,
                      int priv, int suggested_cat_num, int *new_cat_num)
{
   GtkWidget *button;
   GtkWidget *vbox;
   GtkWidget *temp_hbox;
   GtkWidget *textw;
   GObject   *textw_buffer;
   GtkWidget *label;
   GtkWidget *scrolled_window;
   int pw, ph;
   gint px, py;
   char str[100];
   char *l;
   long char_set;

   /* There is no support yet for changing the suggested category */
   /* A menu for selecting cat to be imported into is desirable */
   *new_cat_num = suggested_cat_num;

   glob_import_record_ask_button_pressed = DIALOG_SAID_IMPORT_QUIT;

   gdk_window_get_size(main_window->window, &pw, &ph);
   gdk_window_get_root_origin(main_window->window, &px, &py);
   pw = gtk_paned_get_position(GTK_PANED(pane));
   px+=40;

   import_record_ask_window = gtk_widget_new(GTK_TYPE_WINDOW,
                                             "type", GTK_WINDOW_TOPLEVEL,
                                             "title", _("Import"),
                                             NULL);
   gtk_window_set_default_size(GTK_WINDOW(import_record_ask_window), pw, ph);
   gtk_widget_set_uposition(GTK_WIDGET(import_record_ask_window), px, py);
   gtk_container_set_border_width(GTK_CONTAINER(import_record_ask_window), 5);
   gtk_window_set_modal(GTK_WINDOW(import_record_ask_window), TRUE);
   gtk_window_set_transient_for(GTK_WINDOW(import_record_ask_window), GTK_WINDOW(main_window));

   gtk_signal_connect(GTK_OBJECT(import_record_ask_window), "destroy",
                      GTK_SIGNAL_FUNC(cb_import_record_ask_destroy),
                      import_record_ask_window);

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

   /* Private */
   if (priv) {
      g_snprintf(str, sizeof(str), _("Record was marked as private"));
   } else {
      g_snprintf(str, sizeof(str), _("Record was not marked as private"));
   }
   label = gtk_label_new(str);
   gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
   gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);

   /* Category */
   get_pref(PREF_CHAR_SET, &char_set, NULL);
   l = charset_p2newj(old_cat_name, 16, char_set);
   g_snprintf(str, sizeof(str), _("Category before import was: [%s]"), l);
   g_free(l);
   label = gtk_label_new(str);
   gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
   gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);


   l = charset_p2newj(cai->name[suggested_cat_num], 16, char_set);
   g_snprintf(str, sizeof(str), _("Record will be put in category [%s]"), l);
   g_free(l);
   label = gtk_label_new(str);
   gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
   gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);

   /* Text window with scrollbar to display record */
   temp_hbox = gtk_hbox_new(FALSE, 0);
   gtk_box_pack_start(GTK_BOX(vbox), temp_hbox, TRUE, TRUE, 0);

   textw = gtk_text_view_new();
   textw_buffer = G_OBJECT(gtk_text_view_get_buffer(GTK_TEXT_VIEW(textw)));
   gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(textw), FALSE);
   gtk_text_view_set_editable(GTK_TEXT_VIEW(textw), FALSE);
   gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textw), GTK_WRAP_WORD);

   scrolled_window = gtk_scrolled_window_new(NULL, NULL);
   gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
                                  GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
   gtk_container_set_border_width(GTK_CONTAINER(scrolled_window), 1);
   gtk_container_add(GTK_CONTAINER(scrolled_window), textw);
   gtk_box_pack_start_defaults(GTK_BOX(temp_hbox), scrolled_window);

   if (text) {
      gtk_text_buffer_set_text(GTK_TEXT_BUFFER(textw_buffer), text, -1);
   }

   temp_hbox = gtk_hbutton_box_new();
   gtk_button_box_set_spacing(GTK_BUTTON_BOX(temp_hbox), 6);
   gtk_container_set_border_width(GTK_CONTAINER(temp_hbox), 6);
   gtk_box_pack_start(GTK_BOX(vbox), temp_hbox, FALSE, FALSE, 0);

   /* Import button */
   button = gtk_button_new_with_label(_("Import"));
   gtk_box_pack_start(GTK_BOX(temp_hbox), button, TRUE, TRUE, 0);
   gtk_signal_connect(GTK_OBJECT(button), "clicked",
                      GTK_SIGNAL_FUNC(cb_import_record_ask_quit),
                      GINT_TO_POINTER(DIALOG_SAID_IMPORT_YES));

   /* Import All button */
   button = gtk_button_new_with_label(_("Import All"));
   gtk_box_pack_start(GTK_BOX(temp_hbox), button, TRUE, TRUE, 0);
   gtk_signal_connect(GTK_OBJECT(button), "clicked",
                      GTK_SIGNAL_FUNC(cb_import_record_ask_quit),
                      GINT_TO_POINTER(DIALOG_SAID_IMPORT_ALL));

   /* Skip button */
   button = gtk_button_new_with_label(_("Skip"));
   gtk_box_pack_start(GTK_BOX(temp_hbox), button, TRUE, TRUE, 0);
   gtk_signal_connect(GTK_OBJECT(button), "clicked",
                      GTK_SIGNAL_FUNC(cb_import_record_ask_quit),
                      GINT_TO_POINTER(DIALOG_SAID_IMPORT_SKIP));

   /* Quit button */
   button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
   gtk_box_pack_start(GTK_BOX(temp_hbox), button, TRUE, TRUE, 0);
   gtk_signal_connect(GTK_OBJECT(button), "clicked",
                      GTK_SIGNAL_FUNC(cb_import_record_ask_quit),
                      GINT_TO_POINTER(DIALOG_SAID_IMPORT_QUIT));

   gtk_widget_show_all(import_record_ask_window);

   gtk_main();

   return glob_import_record_ask_button_pressed;
}
Exemplo n.º 28
0
void import_gui(GtkWidget *main_window, GtkWidget *main_pane,
                char *type_desc[], int type_int[],
                int (*import_callback)(GtkWidget *parent_window,
                const char *file_path, int type))
{
   GtkWidget *button;
   GtkWidget *vbox, *hbox;
   GtkWidget *label;
   char title[256];
   const char *svalue;
   GSList *group;
   int i;
   int pw, ph, px, py;

   if (filew) return;
   
   line_selected = -1;

   gdk_window_get_size(main_window->window, &pw, &ph);
   gdk_window_get_root_origin(main_window->window, &px, &py);
   pw = gtk_paned_get_position(GTK_PANED(main_pane));
   px+=40;

   g_snprintf(title, sizeof(title), "%s %s", PN, _("Import"));

   filew = gtk_widget_new(GTK_TYPE_FILE_SELECTION,
                          "type", GTK_WINDOW_TOPLEVEL,
                          "title", title,
                          NULL);
   gtk_window_set_default_size(GTK_WINDOW(filew), pw, ph);
   gtk_widget_set_uposition(filew, px, py);
   gtk_window_set_modal(GTK_WINDOW(filew), TRUE);
   gtk_window_set_transient_for(GTK_WINDOW(filew), GTK_WINDOW(main_window));

   get_pref(PREF_MEMO_IMPORT_PATH, NULL, &svalue);
   if (svalue && svalue[0]) {
      gtk_file_selection_set_filename(GTK_FILE_SELECTION(filew), svalue);
   }

   glob_import_callback=import_callback;

   /* Set the type to match the first button, which will be set */
   glob_type_selected=type_int[0];

   gtk_widget_hide((GTK_FILE_SELECTION(filew)->cancel_button));
   gtk_signal_connect(GTK_OBJECT(filew), "destroy",
                      GTK_SIGNAL_FUNC(cb_destroy), filew);

   /* Even though I hide the ok button I still want to connect its signal */
   /* because a double click on the file name also calls this callback */
   gtk_widget_hide(GTK_WIDGET(GTK_FILE_SELECTION(filew)->ok_button));
   gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filew)->ok_button),
                      "clicked", GTK_SIGNAL_FUNC(cb_import), filew);

   label = gtk_label_new(_("To change to a hidden directory type it below and hit TAB"));
   gtk_box_pack_start(GTK_BOX(GTK_FILE_SELECTION(filew)->main_vbox),
                      label, FALSE, FALSE, 0);
   gtk_widget_show(label);


   /* Quit/Import buttons */
   button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
   gtk_box_pack_start(GTK_BOX(GTK_FILE_SELECTION(filew)->ok_button->parent),
                      button, TRUE, TRUE, 0);
   gtk_signal_connect(GTK_OBJECT(button),
                      "clicked", GTK_SIGNAL_FUNC(cb_quit), filew);
   gtk_widget_show(button);

   button = gtk_button_new_with_label(_("Import"));
   gtk_box_pack_start(GTK_BOX(GTK_FILE_SELECTION(filew)->ok_button->parent),
                      button, TRUE, TRUE, 0);
   gtk_signal_connect(GTK_OBJECT(button),
                      "clicked", GTK_SIGNAL_FUNC(cb_import), filew);
   gtk_widget_show(button);

   /* File Type radio buttons */
   vbox=gtk_vbox_new(FALSE, 0);
   hbox=gtk_hbox_new(FALSE, 0);
   gtk_box_pack_start(GTK_BOX(GTK_FILE_SELECTION(filew)->action_area),
                      vbox, TRUE, TRUE, 0);
   gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
   label = gtk_label_new(_("Import File Type"));
   gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);

   group = NULL;
   for (i=0; i<MAX_IMPORT_TYPES; i++) {
      if (type_desc[i]==NULL) break;
      radio_types[i] = gtk_radio_button_new_with_label(group, _(type_desc[i]));
      radio_file_types[i] = type_int[i];
      group = gtk_radio_button_group(GTK_RADIO_BUTTON(radio_types[i]));
      gtk_box_pack_start(GTK_BOX(vbox), radio_types[i], TRUE, TRUE, 0);
      gtk_signal_connect(GTK_OBJECT(radio_types[i]), "clicked",
                         GTK_SIGNAL_FUNC(cb_type), GINT_TO_POINTER(type_int[i]));
   }
   radio_types[i]=NULL;
   radio_file_types[i]=0;

   /* This callback is for a file guess algorithm and to pre-push
    * the type buttons */
   gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filew)->file_list),
                      "cursor_changed", GTK_SIGNAL_FUNC(cb_import_select_row), NULL);

   gtk_widget_show_all(vbox);

   gtk_widget_show(filew);
}
Exemplo n.º 29
0
gboolean xmms_fullscreen_enter(GtkWidget * win, gint * w, gint * h)
{
	gint i, close, how_close = -1, t, dummy;
	gboolean retval = FALSE;
	fullscreen_window_t *fwin;

	FULL_LOCK();
	fwin = getwindow(win);

	if (!fwin->display->is_full && !fwin->is_full
	    && fwin->display->can_full)
	{
		for (close = 0; close < fwin->display->num_modes; close++)
		{
			if ((fwin->display->modes[close]->hdisplay >= *w) &&
			    (fwin->display->modes[close]->vdisplay >= *h))
			{
				how_close = fwin->display->modes[close]->hdisplay - *w;
				break;
			}
		}

		for (i = close + 1; i < fwin->display->num_modes; i++)
		{
			if (fwin->display->modes[i]->vdisplay < *h)
				continue;
			t = fwin->display->modes[i]->hdisplay - *w;
			if (t >= 0 && t < how_close)
			{
				close = i;
				how_close = t;
			}
		}

		if (close < fwin->display->num_modes)
		{
			*w = fwin->display->modes[close]->hdisplay;
			*h = fwin->display->modes[close]->vdisplay;

			/* Save the old position/size */
			gdk_window_get_root_origin(fwin->window->window, &fwin->ox, &fwin->oy);
			gdk_window_get_size(fwin->window->window, &fwin->owidth, &fwin->oheight);

			/* Move it. */
			gdk_window_move_resize(fwin->window->window, 0, 0,
					       fwin->display->modes[close]->hdisplay,
					       fwin->display->modes[close]->vdisplay);

			/* Tell the WM not to mess with this window (no more decor) */
			gdk_window_hide(fwin->window->window);
			gdk_window_set_override_redirect(fwin->window->window, TRUE);
			gdk_window_show(fwin->window->window);

			/*
			 * XXX: HACK
			 * Something is ungrabbing the pointer shortly
			 * after the above unmap/override_redirect=TRUE/map
			 * is done.  I don't know what at this time, only
			 * that it's not XMMS, and that it's very very evil.
			 */
			gdk_flush();
			xmms_usleep(50000);

			/* Steal the keyboard/mouse */
			/* XXX: FIXME, use timeouts.. */
			for (t = 0; t < 10; t++)
			{
				dummy = gdk_pointer_grab(fwin->window->window,
							 TRUE, 0,
							 fwin->window->window,
							 NULL,
							 GDK_CURRENT_TIME);

				if (dummy == GrabSuccess)
					break;

				gtk_main_iteration_do(FALSE);
				xmms_usleep(10000);
			}
			gdk_keyboard_grab(fwin->window->window, TRUE,
					  GDK_CURRENT_TIME);

			/* Do the video mode switch.. */
			XF86VidModeSwitchToMode(fwin->display->display,
						DefaultScreen(fwin->display->display),
						fwin->display->modes[close]);

			XF86VidModeSetViewPort(fwin->display->display,
					       DefaultScreen(fwin->display->display),
					       0, 0);

			retval = TRUE;

			fwin->is_full = TRUE;
			fwin->display->is_full = TRUE;
		}
	}

	FULL_UNLOCK();

	return retval;
}
Exemplo n.º 30
0
gint delete_event (GtkWidget *widget,
                   GdkEvent *event, GtkWidget *parent)
{
    static GtkWidget *dialog_window = NULL;
    GtkWidget *label;
    GtkWidget *button;
    gint x, y;

    if (dialog_window == NULL) {
        gint flag = TRUE;
        dialog_window = gtk_dialog_new ();

        gtk_signal_connect (GTK_OBJECT (dialog_window),
                            "delete_event",
                            GTK_SIGNAL_FUNC (gtk_false), NULL);
        gtk_signal_connect (GTK_OBJECT (dialog_window),
                            "destroy",
                            GTK_SIGNAL_FUNC (gtk_main_quit), NULL);

        gtk_window_set_title (GTK_WINDOW (dialog_window),
                              "Exit Hello World");
        gtk_container_set_border_width (
            GTK_CONTAINER (dialog_window), 0);
        gtk_widget_set_usize (dialog_window, 250, 110);


        label = gtk_label_new ("真的要退出程序?");
        gtk_box_pack_start (GTK_BOX
                            (GTK_DIALOG(dialog_window)->vbox),
                            label, TRUE, TRUE, 0);
        gtk_widget_show (label);


        button = gtk_button_new_with_label ("确认");
        gtk_signal_connect (GTK_OBJECT (button), "clicked",
                            GTK_SIGNAL_FUNC (dialog_yes), &flag);
        gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
                                   GTK_SIGNAL_FUNC (gtk_widget_destroy),
                                   GTK_OBJECT (dialog_window));
        GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
        gtk_box_pack_start (GTK_BOX
                            (GTK_DIALOG (dialog_window)->action_area),
                            button, TRUE, TRUE, 0);
        gtk_widget_grab_default (button);
        gtk_widget_show (button);


        button = gtk_button_new_with_label ("取消");
        gtk_signal_connect (GTK_OBJECT (button), "clicked",
                            GTK_SIGNAL_FUNC (dialog_no), &flag);
        gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
                                   GTK_SIGNAL_FUNC (gtk_widget_destroy),
                                   GTK_OBJECT (dialog_window));
        GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
        gtk_box_pack_start (GTK_BOX
                            (GTK_DIALOG (dialog_window)->action_area),
                            button, TRUE, TRUE, 0);
        gtk_widget_show (button);

        //设置窗口锁定状态
        gtk_window_set_modal (GTK_WINDOW(dialog_window), TRUE);
        //设置为临时窗口状态
        gtk_window_set_transient_for(GTK_WINDOW (dialog_window),
                                     GTK_WINDOW (parent));

        //取得根窗口的位置
        gdk_window_get_root_origin (parent->window, &x, &y);
        //设置对话框窗口的位置
        gtk_widget_set_uposition (dialog_window, x+40, y+40);

        gtk_widget_show (dialog_window);
        gtk_main ();

        dialog_window = NULL;

        return flag;
    }
    return TRUE;
}