Ejemplo n.º 1
0
/**
 * e_cursor_set:
 * @widget: Any widget in a window, to which busy cursor has to be set
 * cursor: The type of cursor to be set defined in e-cursor.h
 *
 * Sets the cursor specified, to the top level window of the given widget.
 * It is not window aware, so if you popup a window, it will not have
 * busy cursor set. That has to be handled seperately with a new call to this
 * function.
 *
 * Return value:
 **/
void e_cursor_set (GtkWidget *widget, ECursorType cursor)
{
	GtkWidget *toplevel;
	GdkCursor *window_cursor;

	toplevel = gtk_widget_get_toplevel (widget);
	if (GTK_WIDGET_TOPLEVEL (toplevel) && toplevel->window) {

		switch (cursor) {
			case E_CURSOR_NORMAL :
				window_cursor = gdk_cursor_new (GDK_LEFT_PTR);
				break;
			case E_CURSOR_BUSY :
				window_cursor = gdk_cursor_new (GDK_WATCH);
				break;

			default :
				window_cursor = gdk_cursor_new (GDK_LEFT_PTR);
		}

		gdk_window_set_cursor (toplevel->window, window_cursor);
		gdk_cursor_unref (window_cursor);
	}

}
Ejemplo n.º 2
0
Archivo: print.c Proyecto: gdt/viking
static void page_setup_cb (GtkWidget *widget, CustomWidgetInfo *info)
{
  PrintData *data = info->data;
  GtkPrintOperation *operation = data->operation;
  GtkPrintSettings  *settings;
  GtkPageSetup      *page_setup;
  GtkWidget         *toplevel;

  toplevel = gtk_widget_get_toplevel (widget);
#if GTK_CHECK_VERSION (2,18,0)
  if (! gtk_widget_is_toplevel (toplevel))
#else
  if (! GTK_WIDGET_TOPLEVEL (toplevel))
#endif
    toplevel = NULL;

  settings = gtk_print_operation_get_print_settings (operation);
  if (! settings)
    settings = gtk_print_settings_new ();

  page_setup = gtk_print_operation_get_default_page_setup (operation);

  page_setup = gtk_print_run_page_setup_dialog (GTK_WINDOW (toplevel),
                                                page_setup, settings);

  gtk_print_operation_set_default_page_setup (operation, page_setup);

  vik_print_preview_set_page_setup (VIK_PRINT_PREVIEW (info->preview),
                                     page_setup);

  update_page_setup (info);

}
Ejemplo n.º 3
0
bool Buttons_release(ButtonMask& buttons, guint button, guint state)
{
  if(buttons != 0 && bitfield_disable(buttons, ButtonMask_for_event_button(button)) == 0)
  {
    ASSERT_MESSAGE(!g_accel_enabled, "Buttons_release: accelerators are enabled");
    g_accel_enabled = true;
    for(WindowSet::iterator i = g_accel_windows.begin(); i != g_accel_windows.end(); ++i)
    {
      GtkWindow* toplevel = *i;
      ASSERT_MESSAGE(!window_has_accel(toplevel), "ERROR");
      ASSERT_MESSAGE(GTK_WIDGET_TOPLEVEL(toplevel), "enabling accel for non-toplevel window");
      gtk_window_add_accel_group(toplevel, global_accel);
#if 0
      globalOutputStream() << reinterpret_cast<unsigned int>(toplevel) << ": enabled global accelerators\n";
#endif
#if 0
      accel_group_test(toplevel, global_accel);
#endif
    }
    GlobalQueuedAccelerators_commit();
  }
  buttons = bitfield_disable(buttons, ButtonMask_for_event_button(button));
#if 0
  globalOutputStream() << "Buttons_release: ";
  print_buttons(buttons);
#endif
  return false;
}
Ejemplo n.º 4
0
int
_gtk_paned_get_position2 (GtkPaned *paned)
{
	int             pos;
	GtkWidget      *w;
	GtkRequisition  requisition;
	int             size;

	if (! GTK_WIDGET_VISIBLE (paned))
		return 0;

	pos = gtk_paned_get_position (paned);
	if (pos == 0)
		return 0;

	w = gtk_widget_get_toplevel (GTK_WIDGET (paned));
	if (! GTK_WIDGET_TOPLEVEL (w))
		return 0;

	gtk_window_get_size (GTK_WINDOW (w), &(requisition.width), &(requisition.height));
	if (gtk_orientable_get_orientation (GTK_ORIENTABLE (paned)) == GTK_ORIENTATION_HORIZONTAL)
		size = requisition.width;
	else
		size = requisition.height;

	if (size == 0)
		return 0;

	return size - pos;
}
Ejemplo n.º 5
0
static gboolean
goo_canvas_item_accessible_grab_focus (AtkComponent    *component)
{
  GooCanvasItem *item;
  GooCanvas *canvas;
  GtkWidget *toplevel;
  GObject *object;

  g_return_val_if_fail (GOO_IS_CANVAS_ITEM_ACCESSIBLE (component), FALSE);

  object = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (component));
  if (!object)
    return FALSE;

  item = GOO_CANVAS_ITEM (object);

  canvas = goo_canvas_item_get_canvas (item);
  if (!canvas)
    return FALSE;

  goo_canvas_grab_focus (canvas, item);

  toplevel = gtk_widget_get_toplevel (GTK_WIDGET (canvas));
  if (GTK_WIDGET_TOPLEVEL (toplevel))
    gtk_window_present (GTK_WINDOW (toplevel));

  return TRUE;
}
Ejemplo n.º 6
0
bool Buttons_press(ButtonMask& buttons, guint button, guint state)
{
  if(buttons == 0 && bitfield_enable(buttons, ButtonMask_for_event_button(button)) != 0)
  {
    ASSERT_MESSAGE(g_accel_enabled, "Buttons_press: accelerators not enabled");
    g_accel_enabled = false;
    for(WindowSet::iterator i = g_accel_windows.begin(); i != g_accel_windows.end(); ++i)
    {
      GtkWindow* toplevel = *i;
      ASSERT_MESSAGE(window_has_accel(toplevel), "ERROR");
      ASSERT_MESSAGE(GTK_WIDGET_TOPLEVEL(toplevel), "disabling accel for non-toplevel window");
      gtk_window_remove_accel_group(toplevel,  global_accel);
#if 0
      globalOutputStream() << reinterpret_cast<unsigned int>(toplevel) << ": disabled global accelerators\n";
#endif
#if 0
      accel_group_test(toplevel, global_accel);
#endif
    }
  }
  buttons = bitfield_enable(buttons, ButtonMask_for_event_button(button));
#if 0
  globalOutputStream() << "Buttons_press: ";
  print_buttons(buttons);
#endif
  return false;
}
Ejemplo n.º 7
0
/* pass NULL as selection to paste to both clipboard & X11 text */
void
gtkutil_copy_to_clipboard (GtkWidget *widget, GdkAtom selection,
                           const gchar *str)
{
	GtkWidget *win;
	GtkClipboard *clip, *clip2;

	win = gtk_widget_get_toplevel (GTK_WIDGET (widget));
	if (GTK_WIDGET_TOPLEVEL (win))
	{
		int len = strlen (str);

		if (selection)
		{
			clip = gtk_widget_get_clipboard (win, selection);
			gtk_clipboard_set_text (clip, str, len);
		} else
		{
			/* copy to both primary X selection and clipboard */
			clip = gtk_widget_get_clipboard (win, GDK_SELECTION_PRIMARY);
			clip2 = gtk_widget_get_clipboard (win, GDK_SELECTION_CLIPBOARD);
			gtk_clipboard_set_text (clip, str, len);
			gtk_clipboard_set_text (clip2, str, len);
		}
	}
}
Ejemplo n.º 8
0
static void
advanced_button_clicked_cb (GtkWidget *button, gpointer user_data)
{
    L2tpPluginUiWidget *self = L2TP_PLUGIN_UI_WIDGET (user_data);
    L2tpPluginUiWidgetPrivate *priv = L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
    GtkWidget *dialog, *toplevel;

    toplevel = gtk_widget_get_toplevel (priv->widget);
    g_return_if_fail (GTK_WIDGET_TOPLEVEL (toplevel));

    dialog = advanced_dialog_new (priv->advanced);
    if (!dialog) {
        g_warning ("%s: failed to create the Advanced dialog!", __func__);
        return;
    }

    gtk_window_group_add_window (priv->window_group, GTK_WINDOW (dialog));
    if (!priv->window_added) {
        gtk_window_group_add_window (priv->window_group, GTK_WINDOW (toplevel));
        priv->window_added = TRUE;
    }

    gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (toplevel));
    g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (advanced_dialog_response_cb), self);
    g_signal_connect (G_OBJECT (dialog), "close", G_CALLBACK (advanced_dialog_close_cb), self);

    gtk_widget_show_all (dialog);
}
Ejemplo n.º 9
0
static void
gimp_dialog_factories_hide_foreach (gconstpointer      key,
                                    GimpDialogFactory *factory,
                                    gpointer           data)
{
  GList *list;

  for (list = factory->open_dialogs; list; list = g_list_next (list))
    {
      if (GTK_IS_WIDGET (list->data) && GTK_WIDGET_TOPLEVEL (list->data))
        {
          GimpDialogVisibilityState visibility = GIMP_DIALOG_VISIBILITY_UNKNOWN;

          if (GTK_WIDGET_VISIBLE (list->data))
            {
              visibility = GIMP_DIALOG_VISIBILITY_VISIBLE;

              gtk_widget_hide (GTK_WIDGET (list->data));
            }
          else
            {
              visibility = GIMP_DIALOG_VISIBILITY_INVISIBLE;
            }

          g_object_set_data (G_OBJECT (list->data),
                             GIMP_DIALOG_VISIBILITY_KEY,
                             GINT_TO_POINTER (visibility));
        }
    }
}
Ejemplo n.º 10
0
void ChromeClient::mouseDidMoveOverElement(const HitTestResult& hit, unsigned modifierFlags)
{
    // If a tooltip must be displayed it will be, afterwards, when
    // setToolTip is called; this is just a work-around to make sure
    // it updates its location correctly; see
    // https://bugs.webkit.org/show_bug.cgi?id=15793.
    g_object_set(m_webView, "has-tooltip", FALSE, NULL);

    GdkDisplay* gdkDisplay;
    GtkWidget* window = gtk_widget_get_toplevel(GTK_WIDGET(m_webView));
    if (GTK_WIDGET_TOPLEVEL(window))
        gdkDisplay = gtk_widget_get_display(window);
    else
        gdkDisplay = gdk_display_get_default();
    gtk_tooltip_trigger_tooltip_query(gdkDisplay);

    // check if the element is a link...
    bool isLink = hit.isLiveLink();
    if (isLink) {
        KURL url = hit.absoluteLinkURL();
        if (!url.isEmpty() && url != m_hoveredLinkURL) {
            TextDirection dir;
            CString titleString = hit.title(dir).utf8();
            CString urlString = url.prettyURL().utf8();
            g_signal_emit_by_name(m_webView, "hovering-over-link", titleString.data(), urlString.data());
            m_hoveredLinkURL = url;
        }
    } else if (!isLink && !m_hoveredLinkURL.isEmpty()) {
        g_signal_emit_by_name(m_webView, "hovering-over-link", 0, 0);
        m_hoveredLinkURL = KURL();
    }
}
Ejemplo n.º 11
0
//
// Get top level widget
//
GtkWidget *CPreview::GetTopLevel(void)
{
	GtkWidget *toplevel = gtk_widget_get_toplevel(m_Widget);
	if (GTK_WIDGET_TOPLEVEL(toplevel)) 
		return toplevel;
	return NULL;		
}
Ejemplo n.º 12
0
static void
gimp_dialog_factories_show_foreach (gconstpointer      key,
                                    GimpDialogFactory *factory,
                                    gpointer           data)
{
  GList *list;

  for (list = factory->open_dialogs; list; list = g_list_next (list))
    {
      GtkWidget *widget = list->data;

      if (GTK_IS_WIDGET (widget) && GTK_WIDGET_TOPLEVEL (widget))
        {
          GimpDialogVisibilityState visibility;

          visibility =
            GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget),
                                                GIMP_DIALOG_VISIBILITY_KEY));

          if (! GTK_WIDGET_VISIBLE (widget) &&
              visibility == GIMP_DIALOG_VISIBILITY_VISIBLE)
            {
              /* Don't use gtk_window_present() here, we don't want the
               * keyboard focus to move.
               */
              gtk_widget_show (widget);

              if (GTK_WIDGET_VISIBLE (widget))
                gdk_window_raise (widget->window);
            }
        }
    }
}
static gboolean
matecomponent_plug_button_event (GtkWidget      *widget,
			  GdkEventButton *event)
{
#if defined (GDK_WINDOWING_X11)
	XEvent xevent;
#endif

	g_return_val_if_fail (MATECOMPONENT_IS_PLUG (widget), FALSE);

	if (!MATECOMPONENT_PLUG (widget)->priv->forward_events || !GTK_WIDGET_TOPLEVEL (widget))
		return FALSE;

#if defined (GDK_WINDOWING_X11)

	if (event->type == GDK_BUTTON_PRESS) {
		xevent.xbutton.type = ButtonPress;

		/* X does an automatic pointer grab on button press
		 * if we have both button press and release events
		 * selected.
		 * We don't want to hog the pointer on our parent.
		 */
		gdk_display_pointer_ungrab
			(gtk_widget_get_display (widget),
			 GDK_CURRENT_TIME);
	} else
		xevent.xbutton.type = ButtonRelease;
    
	xevent.xbutton.display     = GDK_WINDOW_XDISPLAY (widget->window);
	xevent.xbutton.window      = GDK_WINDOW_XWINDOW (GTK_PLUG (widget)->socket_window);
	xevent.xbutton.root        = GDK_WINDOW_XWINDOW (gdk_screen_get_root_window
							 (gdk_drawable_get_screen (widget->window)));
	/*
	 * FIXME: the following might cause
	 *        big problems for non-GTK apps
	 */
	xevent.xbutton.x           = 0;
	xevent.xbutton.y           = 0;
	xevent.xbutton.x_root      = 0;
	xevent.xbutton.y_root      = 0;
	xevent.xbutton.state       = event->state;
	xevent.xbutton.button      = event->button;
	xevent.xbutton.same_screen = TRUE; /* FIXME ? */

	gdk_error_trap_push ();

	XSendEvent (GDK_WINDOW_XDISPLAY (widget->window),
		    GDK_WINDOW_XWINDOW (GTK_PLUG (widget)->socket_window),
		    False, NoEventMask, &xevent);

	gdk_flush ();
	gdk_error_trap_pop ();

#elif defined (GDK_WINDOWING_WIN32)
	/* FIXME: Need to do something? */
#endif
	return TRUE;
}
Ejemplo n.º 14
0
void
gmdb_about_cb(GtkWidget *button, gpointer data)
{
const gchar *authors[] = {
	"Brian Bruns",
	"Jeff Smith",
	"Filip Van Raemdonck",
	"Bernhard Reiter",
	"Nirgal Vourgère",
	NULL
};
const gchar *documenters[] = {
	"Brian Bruns",
	NULL
};
GtkWidget *parent;
GdkPixbuf *pixbuf=NULL;
FILE *flicense;
guint32 licenselen;
char *license;

	parent = gtk_widget_get_toplevel (button);
	if (!GTK_WIDGET_TOPLEVEL (parent))
		parent = NULL;

	if (!pixbuf)
		pixbuf = gdk_pixbuf_new_from_file (GMDB_ICONDIR "logo.xpm", NULL);

	flicense = fopen(GMDB_ICONDIR "COPYING", "r");
	if (flicense)
	{
		fseek(flicense, 0, SEEK_END);
		licenselen = ftell(flicense);
		fseek(flicense, 0, SEEK_SET);
		license = g_malloc(licenselen+1);
		fread(license, 1, licenselen, flicense);
		license[licenselen] = 0;
		fclose(flicense);
	} else {
		fprintf(stderr, "Can't open " GMDB_ICONDIR "COPYING\n");
		license = NULL;
	}

  	gtk_show_about_dialog ((GtkWindow*)parent,
   		"authors", authors,
		"comments", _("GNOME MDB Viewer is a grapical interface to "
			"MDB Tools. It lets you view and export data and schema "
			"from MDB files produced by MS Access 97/2000/XP/2003/2007/2010."),
		"copyright", _("Copyright 2002-2012 Brian Bruns and others"),
		"documenters", documenters,
		"logo", pixbuf,
		"program-name", _("GNOME MDB Viewer"),
		"version", MDB_VERSION_NO,
		"website", "http://mdbtools.sourceforge.net/",
		"license", license,
		NULL);
	g_free(license);
}
Ejemplo n.º 15
0
static void
gimp_dialog_factory_dispose (GObject *object)
{
  GimpDialogFactory *factory = GIMP_DIALOG_FACTORY (object);
  GList             *list;
  gpointer           key;

  /*  start iterating from the beginning each time we destroyed a
   *  toplevel because destroying a dock may cause lots of items
   *  to be removed from factory->open_dialogs
   */
  while (factory->open_dialogs)
    {
      for (list = factory->open_dialogs; list; list = g_list_next (list))
        {
          if (GTK_WIDGET_TOPLEVEL (list->data))
            {
              gtk_widget_destroy (GTK_WIDGET (list->data));
              break;
            }
        }

      /*  the list being non-empty without any toplevel is an error,
       *  so eek and chain up
       */
      if (! list)
        {
          g_warning ("%s: stale non-toplevel entries in factory->open_dialogs",
                     G_STRFUNC);
          break;
        }
    }

  if (factory->open_dialogs)
    {
      g_list_free (factory->open_dialogs);
      factory->open_dialogs = NULL;
    }

  if (factory->session_infos)
    {
      g_list_foreach (factory->session_infos, (GFunc) gimp_session_info_free,
                      NULL);
      g_list_free (factory->session_infos);
      factory->session_infos = NULL;
    }

  if (strcmp (GIMP_OBJECT (factory)->name, "toolbox") == 0)
    key = "";
  else
    key = GIMP_OBJECT (factory)->name;

  g_hash_table_remove (GIMP_DIALOG_FACTORY_GET_CLASS (object)->factories,
                       key);

  G_OBJECT_CLASS (parent_class)->dispose (object);
}
Ejemplo n.º 16
0
FloatRect ChromeClient::windowRect()
{
    GtkWidget* window = gtk_widget_get_toplevel(GTK_WIDGET(m_webView));
    if (GTK_WIDGET_TOPLEVEL(window)) {
        gint left, top, width, height;
        gtk_window_get_position(GTK_WINDOW(window), &left, &top);
        gtk_window_get_size(GTK_WINDOW(window), &width, &height);
        return IntRect(left, top, width, height);
    }
    return FloatRect();
}
Ejemplo n.º 17
0
NS_IMETHODIMP
EmbedWindow::FocusPrevElement()
{
  GtkWidget *toplevel;
  toplevel = gtk_widget_get_toplevel(GTK_WIDGET(mOwner->mOwningWidget));
  if (!GTK_WIDGET_TOPLEVEL(toplevel))
    return NS_OK;

  g_signal_emit_by_name(G_OBJECT(toplevel), "move_focus",
			GTK_DIR_TAB_BACKWARD);
  return NS_OK;
}
Ejemplo n.º 18
0
/*  The only toplevel widget in the toolbox factory is the toolbox  */
static GtkWidget *
gimp_dialog_factory_get_toolbox (GimpDialogFactory *toolbox_factory)
{
  GList *list;

  for (list = toolbox_factory->open_dialogs; list; list = list->next)
    {
      if (GTK_IS_WIDGET (list->data) && GTK_WIDGET_TOPLEVEL (list->data))
        return list->data;
    }

  return NULL;
}
Ejemplo n.º 19
0
static void
presence_chooser_set_status_editing (EmpathyPresenceChooser *self,
                                     gboolean editing)
{
	EmpathyPresenceChooserPriv *priv = GET_PRIV (self);
	GtkWidget *entry;

	if (priv->block_set_editing) {
		return;
	}

	entry = gtk_bin_get_child (GTK_BIN (self));
	if (editing) {
		priv->editing_status = TRUE;

		gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
					       GTK_ENTRY_ICON_SECONDARY,
					       GTK_STOCK_OK);
		gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
						 GTK_ENTRY_ICON_SECONDARY,
						 _("Set status"));
		gtk_entry_set_icon_sensitive (GTK_ENTRY (entry),
					      GTK_ENTRY_ICON_PRIMARY,
					      FALSE);
	} else {
		GtkWidget *window;

		presence_chooser_set_favorite_icon (self);
		gtk_entry_set_icon_sensitive (GTK_ENTRY (entry),
					      GTK_ENTRY_ICON_PRIMARY,
					      TRUE);

		/* attempt to get the toplevel for this widget */
		window = gtk_widget_get_toplevel (GTK_WIDGET (self));
		if (GTK_WIDGET_TOPLEVEL (window) && GTK_IS_WINDOW (window)) {
			/* unset the focus */
			gtk_window_set_focus (GTK_WINDOW (window), NULL);
		}

		/* see presence_chooser_entry_focus_out_cb ()
		 * for what this does */
		if (priv->focus_out_idle_source != 0) {
			g_source_remove (priv->focus_out_idle_source);
			priv->focus_out_idle_source = 0;
		}

		gtk_editable_set_position (GTK_EDITABLE (entry), 0);

		priv->editing_status = FALSE;
	}
}
Ejemplo n.º 20
0
static void
private_key_picker_helper (EAPMethod *parent, const char *filename, gboolean changed)
{
	NMSetting8021x *setting;
	NMSetting8021xCKFormat cert_format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
	const char *password;
	GtkWidget *widget;

	widget = glade_xml_get_widget (parent->xml, "eap_tls_private_key_password_entry");
	g_assert (widget);
	password = gtk_entry_get_text (GTK_ENTRY (widget));

	setting = (NMSetting8021x *) nm_setting_802_1x_new ();
	nm_setting_802_1x_set_private_key (setting, filename, password, NM_SETTING_802_1X_CK_SCHEME_PATH, &cert_format, NULL);
	g_object_unref (setting);

	/* With PKCS#12, the client cert must be the same as the private key */
	widget = glade_xml_get_widget (parent->xml, "eap_tls_user_cert_button");
	if (cert_format == NM_SETTING_802_1X_CK_FORMAT_PKCS12) {
		gtk_file_chooser_unselect_all (GTK_FILE_CHOOSER (widget));
		gtk_widget_set_sensitive (widget, FALSE);
	} else if (changed)
		gtk_widget_set_sensitive (widget, TRUE);

	/* Warn the user if the private key is unencrypted */
	if (!eap_method_is_encrypted_private_key (filename)) {
		GtkWidget *dialog;
		GtkWidget *toplevel;
		GtkWindow *parent_window = NULL;

		toplevel = gtk_widget_get_toplevel (parent->ui_widget);
#if GTK_CHECK_VERSION(2,18,0)
		if (gtk_widget_is_toplevel (toplevel))
#else
		if (GTK_WIDGET_TOPLEVEL (toplevel))
#endif
			parent_window = GTK_WINDOW (toplevel);

		dialog = gtk_message_dialog_new (parent_window,
		                                 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
		                                 GTK_MESSAGE_WARNING,
		                                 GTK_BUTTONS_OK,
		                                 "%s",
		                                 _("Unencrypted private keys are insecure"));
		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
		                                          "%s",
		                                          _("The selected private key does not appear to be protected by a password.  This could allow your security credentials to be compromised.  Please select a password-protected private key.\n\n(You can password-protect your private key with openssl)"));
		gtk_dialog_run (GTK_DIALOG (dialog));
		gtk_widget_destroy (dialog);
	}
}
Ejemplo n.º 21
0
static void hide_section_cb(GtkToggleToolButton *btn, GtkWidget *section)
{
	GtkWidget *toplevel;

	if (gtk_toggle_tool_button_get_active(btn)) {
		gtk_object_set(GTK_OBJECT(btn), "stock-id", "gtk-go-down", NULL);
		gtk_widget_show(section);
	} else {
		gtk_object_set(GTK_OBJECT(btn), "stock-id", "gtk-go-up", NULL);
		gtk_widget_hide(section);
		toplevel = gtk_widget_get_toplevel(GTK_WIDGET(btn));
		if (GTK_WIDGET_TOPLEVEL(toplevel))
			gtk_window_resize (GTK_WINDOW(toplevel), 1, 1);
	}
}
static void
matecomponent_plug_size_allocate (GtkWidget     *widget,
			   GtkAllocation *allocation)
{
	dbgprintf ("matecomponent_plug_size_allocate %p: (%d, %d), (%d, %d) %d! %s\n",
		 widget,
		 allocation->x, allocation->y,
		 allocation->width, allocation->height,
		 GTK_WIDGET_TOPLEVEL (widget),
		 GTK_BIN (widget)->child ?
		 g_type_name_from_instance ((gpointer)GTK_BIN (widget)->child):
		 "No child!");

	GTK_WIDGET_CLASS (matecomponent_plug_parent_class)->size_allocate (widget, allocation);
}
Ejemplo n.º 23
0
FloatRect screenRect(Widget* widget)
{
    GtkWidget* container = gtk_widget_get_toplevel(GTK_WIDGET(widget->root()->hostWindow()->platformWindow()));
    if (!GTK_WIDGET_TOPLEVEL(container))
        return FloatRect();

    GdkScreen* screen = gtk_widget_has_screen(container) ? gtk_widget_get_screen(container) : gdk_screen_get_default();
    if (!screen)
        return FloatRect();

    gint monitor = gdk_screen_get_monitor_at_window(screen, GTK_WIDGET(container)->window);
    GdkRectangle geometry;
    gdk_screen_get_monitor_geometry(screen, monitor, &geometry);
    
    return FloatRect(geometry.x, geometry.y, geometry.width, geometry.height);
}
Ejemplo n.º 24
0
static void
end_clicked_cb (GtkButton *button, JanaGtkRecurrence *self)
{
	GtkWidget *window, *datetime, *check, *toplevel, *vbox, *close, *align;
	JanaGtkRecurrencePrivate *priv = RECURRENCE_PRIVATE (self);
	JanaTime *time;
	
	/* Time-editing dialog */
	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (button));
	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	if (GTK_WIDGET_TOPLEVEL (toplevel))
		gtk_window_set_transient_for (GTK_WINDOW (window),
			GTK_WINDOW (toplevel));
	gtk_window_set_modal (GTK_WINDOW (window), TRUE);
	gtk_window_set_type_hint (GTK_WINDOW (window),
		GDK_WINDOW_TYPE_HINT_DIALOG);
	
	vbox = gtk_vbox_new (FALSE, 6);
	gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
	check = gtk_check_button_new_with_mnemonic ("Repeats _forever");
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check),
		priv->recur->end ? FALSE : TRUE);
	time = priv->recur->end ?
		jana_time_duplicate (priv->recur->end) :
		jana_time_duplicate (priv->time);
	jana_time_set_isdate (time, TRUE);
	datetime = jana_gtk_date_time_new (time);
	jana_gtk_date_time_set_editable (JANA_GTK_DATE_TIME (datetime), TRUE);
	gtk_widget_set_sensitive (datetime, priv->recur->end ? TRUE : FALSE);
	align = gtk_alignment_new (1.0, 0.5, 0.0, 1.0);
	gtk_alignment_set_padding (GTK_ALIGNMENT (align), 6, 0, 0, 0);
	close = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
	gtk_container_add (GTK_CONTAINER (align), close);
	
	gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (vbox), datetime, TRUE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, TRUE, 0);
	gtk_container_add (GTK_CONTAINER (window), vbox);
	
	g_object_set_data (G_OBJECT (window), "self", self);
	g_signal_connect (check, "toggled",
		G_CALLBACK (forever_toggled_cb), datetime);
	g_signal_connect (close, "clicked",
		G_CALLBACK (close_clicked_cb), datetime);
	
	gtk_widget_show_all (window);
}
Ejemplo n.º 25
0
GtkWidget *
dialogs_get_toolbox (void)
{
  GList *list;

  g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (global_toolbox_factory), NULL);

  for (list = global_toolbox_factory->open_dialogs;
       list;
       list = g_list_next (list))
    {
      if (GTK_WIDGET_TOPLEVEL (list->data))
        return list->data;
    }

  return NULL;
}
Ejemplo n.º 26
0
static void
gimp_dialog_factories_unset_busy_foreach (gconstpointer      key,
                                          GimpDialogFactory *factory,
                                          gpointer           data)
{
  GList *list;

  for (list = factory->open_dialogs; list; list = g_list_next (list))
    {
      GtkWidget *widget = list->data;

      if (GTK_IS_WIDGET (widget) && GTK_WIDGET_TOPLEVEL (widget))
        {
          if (widget->window)
            gdk_window_set_cursor (widget->window, NULL);
        }
    }
}
Ejemplo n.º 27
0
void
_gtk_paned_set_position2 (GtkPaned *paned,
			  int       pos)
{
	GtkWidget *top_level;
	int        size;

	top_level = gtk_widget_get_toplevel (GTK_WIDGET (paned));
	if (! GTK_WIDGET_TOPLEVEL (top_level))
		return;

	if (gtk_orientable_get_orientation (GTK_ORIENTABLE (paned)) == GTK_ORIENTATION_HORIZONTAL)
		size = top_level->allocation.width;
	else
		size = top_level->allocation.height;

	if (pos > 0)
		gtk_paned_set_position (paned, size - pos);
}
Ejemplo n.º 28
0
int screenDepth(Widget* widget)
{
    GtkWidget* container = GTK_WIDGET(widget->root()->hostWindow()->platformWindow());

    if (!container)
        return 24;

    if (!GTK_WIDGET_REALIZED(container)) {
        GtkWidget* toplevel = gtk_widget_get_toplevel(container);
        if (GTK_WIDGET_TOPLEVEL(toplevel))
            container = toplevel;
        else
            return 24;
    }


    GdkVisual* visual = gdk_drawable_get_visual(GDK_DRAWABLE(container->window));
    return visual->depth;
}
Ejemplo n.º 29
0
/**
 * called with a double-click on a date on a calendar
 * set the choosen date in the entry
 *
 * \param pCalendar
 * \param entry
 *
 * \return FALSE
 * */
gboolean gsb_calendar_entry_select_date ( GtkCalendar *pCalendar,
					  GtkWidget *entry )
{
    guint year, month, day;
    GtkWidget *pTopLevelWidget;

    /* get the popup to destroy it if we are in a popup */
    pTopLevelWidget = gtk_widget_get_toplevel ( GTK_WIDGET ( pCalendar ) );

    gtk_calendar_get_date ( pCalendar, &year, &month, &day);

    gtk_entry_set_text ( GTK_ENTRY ( entry ),
			 gsb_format_date ( day, month + 1, year ));
    gsb_form_widget_set_empty ( entry, FALSE );
    if ( GTK_WIDGET_TOPLEVEL ( pTopLevelWidget ) )
        gtk_widget_destroy ( pTopLevelWidget );

    return FALSE;
}
Ejemplo n.º 30
0
static void
gtk_font_button_clicked (GtkButton *button)
{
  GtkFontSelectionDialog *font_dialog;
  GtkFontButton    *font_button = GTK_FONT_BUTTON (button);
  
  if (!font_button->priv->font_dialog) 
    {
      GtkWidget *parent;
      
      parent = gtk_widget_get_toplevel (GTK_WIDGET (font_button));
      
      font_button->priv->font_dialog = gtk_font_selection_dialog_new (font_button->priv->title);
      
      font_dialog = GTK_FONT_SELECTION_DIALOG (font_button->priv->font_dialog);
      
      if (GTK_WIDGET_TOPLEVEL (parent) && GTK_IS_WINDOW (parent))
        {
          if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (font_dialog)))
 	    gtk_window_set_transient_for (GTK_WINDOW (font_dialog), GTK_WINDOW (parent));
	       
	  gtk_window_set_modal (GTK_WINDOW (font_dialog),
				gtk_window_get_modal (GTK_WINDOW (parent)));
	}

      g_signal_connect (font_dialog->ok_button, "clicked",
                        G_CALLBACK (dialog_ok_clicked), font_button);
      g_signal_connect (font_dialog->cancel_button, "clicked",
			G_CALLBACK (dialog_cancel_clicked), font_button);
      g_signal_connect (font_dialog, "destroy",
                        G_CALLBACK (dialog_destroy), font_button);
    }
  
  if (!GTK_WIDGET_VISIBLE (font_button->priv->font_dialog)) 
    {
      font_dialog = GTK_FONT_SELECTION_DIALOG (font_button->priv->font_dialog);
      
      gtk_font_selection_dialog_set_font_name (font_dialog, font_button->priv->fontname);
      
    } 

  gtk_window_present (GTK_WINDOW (font_button->priv->font_dialog));
}