Exemple #1
0
void wxTopLevelWindowGTK::GTKHandleRealized()
{
    wxNonOwnedWindow::GTKHandleRealized();

    GdkWindow* window = gtk_widget_get_window(m_widget);

    gdk_window_set_decorations(window, (GdkWMDecoration)m_gdkDecor);
    gdk_window_set_functions(window, (GdkWMFunction)m_gdkFunc);

    const wxIconBundle& icons = GetIcons();
    if (icons.GetIconCount())
        SetIcons(icons);

    GdkCursor* cursor = g_globalCursor.GetCursor();
    if (wxIsBusy() && !gtk_window_get_modal(GTK_WINDOW(m_widget)))
        cursor = g_busyCursor.GetCursor();

    if (cursor)
        gdk_window_set_cursor(window, cursor);

#ifdef __WXGTK3__
    if (gtk_window_get_has_resize_grip(GTK_WINDOW(m_widget)))
    {
        // Grip window can end up obscured, probably due to deferred show.
        // Reset grip to ensure it is visible.
        gtk_window_set_has_resize_grip(GTK_WINDOW(m_widget), false);
        gtk_window_set_has_resize_grip(GTK_WINDOW(m_widget), true);
    }
#endif
}
Exemple #2
0
static AtkStateSet*
gail_window_ref_state_set (AtkObject *accessible)
{
  AtkStateSet *state_set;
  GtkWidget *widget;
  GtkWindow *window;
  GdkWindowState state;

  state_set = ATK_OBJECT_CLASS (gail_window_parent_class)->ref_state_set (accessible);
  widget = GTK_ACCESSIBLE (accessible)->widget;
 
  if (widget == NULL)
    return state_set;

  window = GTK_WINDOW (widget);

  if (window->has_focus)
    atk_state_set_add_state (state_set, ATK_STATE_ACTIVE);

  if (widget->window)
    {
      state = gdk_window_get_state (widget->window);
      if (state & GDK_WINDOW_STATE_ICONIFIED)
        atk_state_set_add_state (state_set, ATK_STATE_ICONIFIED);
    } 
  if (gtk_window_get_modal (window))
    atk_state_set_add_state (state_set, ATK_STATE_MODAL);

  if (gtk_window_get_resizable (window))
    atk_state_set_add_state (state_set, ATK_STATE_RESIZABLE);
 
  return state_set;
}
/* Create the dialog and connects its buttons */
static void
ensure_dialog (GtkColorButton *button)
{
  GtkWidget *parent, *dialog;

  if (button->priv->cs_dialog != NULL)
    return;

  parent = gtk_widget_get_toplevel (GTK_WIDGET (button));

  button->priv->cs_dialog = dialog = gtk_color_chooser_dialog_new (button->priv->title, NULL);

  if (gtk_widget_is_toplevel (parent) && GTK_IS_WINDOW (parent))
  {
    if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (dialog)))
      gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));

    gtk_window_set_modal (GTK_WINDOW (dialog),
                            gtk_window_get_modal (GTK_WINDOW (parent)));
  }

  g_signal_connect (dialog, "response",
                    G_CALLBACK (dialog_response), button);
  g_signal_connect (dialog, "destroy",
                    G_CALLBACK (dialog_destroy), button);
}
Exemple #4
0
JNIEXPORT jboolean JNICALL
Java_org_gnome_gtk_GtkWindow_gtk_1window_1get_1modal
(
	JNIEnv* env,
	jclass cls,
	jlong _self
)
{
	gboolean result;
	jboolean _result;
	GtkWindow* self;

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

	// call function
	result = gtk_window_get_modal(self);

	// cleanup parameter self

	// translate return value to JNI type
	_result = (jboolean) result;

	// and finally
	return _result;
}
Exemple #5
0
static void display_credits_dialog(GtkWidget *button, Credits *credits)
{
    GtkWidget *dialog, *notebook;

    if (credits->dialog != NULL) {
        gtk_window_present(GTK_WINDOW(credits->dialog));
        return;
    }

    dialog = gtk_dialog_new_with_buttons(_("Credits"),
                                         GTK_WINDOW(gtk_widget_get_toplevel(button)),
                                         GTK_DIALOG_DESTROY_WITH_PARENT,
#	if GTK_CHECK_VERSION(2, 4, 0)
                                         GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
#	else
                                         GTK_STOCK_OK, GTK_RESPONSE_CLOSE,
#	endif
                                         NULL);
    gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE);
#	if GTK_CHECK_VERSION(2, 4, 0)
    gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
    gtk_container_set_border_width(GTK_CONTAINER(dialog), 5);
    gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), 2);
#	endif

    credits->dialog = dialog;
    gtk_window_set_default_size(GTK_WINDOW(dialog), 360, 260);
    gtk_window_set_modal(GTK_WINDOW(dialog),
                         gtk_window_get_modal(GTK_WINDOW(gtk_widget_get_toplevel(button))));
    g_signal_connect(G_OBJECT(dialog), "response",
                     G_CALLBACK(gtk_widget_destroy), dialog);
    g_signal_connect(G_OBJECT(dialog), "destroy",
                     G_CALLBACK(gtk_widget_destroyed), &(credits->dialog));

    notebook = gtk_notebook_new();
#	if GTK_CHECK_VERSION(2, 4, 0)
    gtk_container_set_border_width(GTK_CONTAINER(notebook), 5);
#	else
    gtk_container_set_border_width(GTK_CONTAINER(notebook), 8);
#	endif
    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
                       notebook, TRUE, TRUE, 0);
    if (credits->authors != NULL)
        add_credits_page(notebook,
                         _("Written by"), credits->authors);
    if (credits->documenters[0] != NULL)
        add_credits_page(notebook,
                         _("Documented by"), credits->documenters);
    if (credits->translator_credits != NULL) {
        gchar *translators[2];
        translators[0] = credits->translator_credits;
        translators[1] = NULL;
        add_credits_page(notebook,
                         _("Translated by"), translators);
    }

    gtk_widget_show_all(dialog);
}
/* Create the dialog and connects its buttons */
static void
ensure_dialog (GtkSourceStyleSchemeChooserButton *button)
{
	GtkSourceStyleSchemeChooserButtonPrivate *priv = GET_PRIV (button);
	GtkWidget *parent, *dialog, *scrolled_window;
	GtkWidget *content_area;

	if (priv->dialog != NULL)
	{
		return;
	}

	parent = gtk_widget_get_toplevel (GTK_WIDGET (button));

	/* TODO: have a ChooserDialog? */
	priv->dialog = dialog = gtk_dialog_new_with_buttons (_("Select a Style"),
	                                                     GTK_WINDOW (parent),
	                                                     GTK_DIALOG_DESTROY_WITH_PARENT |
	                                                     GTK_DIALOG_USE_HEADER_BAR,
	                                                     _("_Cancel"), GTK_RESPONSE_CANCEL,
	                                                     _("_Select"), GTK_RESPONSE_OK,
	                                                     NULL);
	gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);

	scrolled_window = gtk_scrolled_window_new (NULL, NULL);
	gtk_widget_set_size_request (scrolled_window, 325, 450);
	gtk_widget_show (scrolled_window);
	gtk_widget_set_hexpand (scrolled_window, TRUE);
	gtk_widget_set_vexpand (scrolled_window, TRUE);
	content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
	gtk_container_add (GTK_CONTAINER (content_area), scrolled_window);

	priv->chooser = GTK_SOURCE_STYLE_SCHEME_CHOOSER_WIDGET (gtk_source_style_scheme_chooser_widget_new ());
	gtk_widget_show (GTK_WIDGET (priv->chooser));
	gtk_source_style_scheme_chooser_set_style_scheme (GTK_SOURCE_STYLE_SCHEME_CHOOSER (priv->chooser),
	                                                  priv->scheme);

	gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (priv->chooser));

	if (gtk_widget_is_toplevel (parent) && GTK_IS_WINDOW (parent))
	{
		if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (dialog)))
		{
			gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
		}

		gtk_window_set_modal (GTK_WINDOW (dialog),
		                      gtk_window_get_modal (GTK_WINDOW (parent)));
	}

	g_signal_connect (dialog, "response",
	                  G_CALLBACK (dialog_response), button);
	g_signal_connect (dialog, "destroy",
	                  G_CALLBACK (dialog_destroy), button);
}
Exemple #7
0
static void
mate_color_button_clicked (GtkButton *button)
{
  MateColorButton *color_button = MATE_COLOR_BUTTON (button);
  MateColorSelectionDialog *color_dialog;

  /* if dialog already exists, make sure it's shown and raised */
  if (!color_button->priv->cs_dialog) 
    {
      /* Create the dialog and connects its buttons */
      GtkWidget *parent;
      
      parent = gtk_widget_get_toplevel (GTK_WIDGET (color_button));
      
      color_button->priv->cs_dialog = mate_color_selection_dialog_new (color_button->priv->title);
      
      color_dialog = MATE_COLOR_SELECTION_DIALOG (color_button->priv->cs_dialog);

      if (gtk_widget_is_toplevel (parent) && GTK_IS_WINDOW (parent))
        {
          if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (color_dialog)))
 	    gtk_window_set_transient_for (GTK_WINDOW (color_dialog), GTK_WINDOW (parent));
	       
	  gtk_window_set_modal (GTK_WINDOW (color_dialog),
				gtk_window_get_modal (GTK_WINDOW (parent)));
	}
      
      g_signal_connect (color_dialog->ok_button, "clicked",
                        G_CALLBACK (dialog_ok_clicked), color_button);
      g_signal_connect (color_dialog->cancel_button, "clicked",
			G_CALLBACK (dialog_cancel_clicked), color_button);
      g_signal_connect (color_dialog, "destroy",
                        G_CALLBACK (dialog_destroy), color_button);
    }

  color_dialog = MATE_COLOR_SELECTION_DIALOG (color_button->priv->cs_dialog);

  mate_color_selection_set_has_opacity_control (MATE_COLOR_SELECTION (color_dialog->colorsel),
                                               color_button->priv->use_alpha);

  mate_color_selection_set_has_palette (MATE_COLOR_SELECTION (color_dialog->colorsel), TRUE);
  
  mate_color_selection_set_previous_color (MATE_COLOR_SELECTION (color_dialog->colorsel), 
					  &color_button->priv->color);
  mate_color_selection_set_previous_alpha (MATE_COLOR_SELECTION (color_dialog->colorsel), 
					  color_button->priv->alpha);

  mate_color_selection_set_current_color (MATE_COLOR_SELECTION (color_dialog->colorsel), 
					 &color_button->priv->color);
  mate_color_selection_set_current_alpha (MATE_COLOR_SELECTION (color_dialog->colorsel), 
					 color_button->priv->alpha);

  gtk_window_present (GTK_WINDOW (color_button->priv->cs_dialog));
}
static gint
gsm_color_button_clicked (GtkWidget * widget, GdkEventButton * event)
{
  GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
  GtkColorSelectionDialog *color_dialog;

  /* if dialog already exists, make sure it's shown and raised */
  if (!color_button->priv->cs_dialog)
    {
      /* Create the dialog and connects its buttons */
      GtkWidget *parent;

      parent = gtk_widget_get_toplevel (GTK_WIDGET (color_button));

      color_button->priv->cs_dialog =
	gtk_color_selection_dialog_new (color_button->priv->title);

      color_dialog =
	GTK_COLOR_SELECTION_DIALOG (color_button->priv->cs_dialog);

      if (gtk_widget_is_toplevel (parent) && GTK_IS_WINDOW (parent))
	{
	  if (GTK_WINDOW (parent) !=
	      gtk_window_get_transient_for (GTK_WINDOW (color_dialog)))
	    gtk_window_set_transient_for (GTK_WINDOW (color_dialog),
					  GTK_WINDOW (parent));

	  gtk_window_set_modal (GTK_WINDOW (color_dialog),
				gtk_window_get_modal (GTK_WINDOW (parent)));
	}

      g_signal_connect (color_dialog, "response",
                        G_CALLBACK (dialog_response), color_button);

      g_signal_connect (color_dialog, "destroy",
			G_CALLBACK (dialog_destroy), color_button);
    }

  color_dialog = GTK_COLOR_SELECTION_DIALOG (color_button->priv->cs_dialog);

  gtk_color_selection_set_previous_color (GTK_COLOR_SELECTION
                                          (gtk_color_selection_dialog_get_color_selection (color_dialog)),
					  &color_button->priv->color);

  gtk_color_selection_set_current_color (GTK_COLOR_SELECTION
                                         (gtk_color_selection_dialog_get_color_selection (color_dialog)),
					 &color_button->priv->color);

  gtk_window_present (GTK_WINDOW (color_button->priv->cs_dialog));
  return 0;
}
Exemple #9
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));
}
/*
 * There's a race condition that can freeze the UI if a dialog appears
 * between a HildonAppMenu and its parent window, see NB#100468
 */
static gboolean
hildon_app_menu_find_intruder                   (gpointer data)
{
    GtkWidget *widget = GTK_WIDGET (data);
    HildonAppMenuPrivate *priv = HILDON_APP_MENU_GET_PRIVATE (widget);

    priv->find_intruder_idle_id = 0;

    /* If there's a modal window between the menu and its parent window, hide the menu */
    if (priv->parent_window) {
        gboolean intruder_found = FALSE;
        GdkScreen *screen = gtk_widget_get_screen (widget);
        GList *stack = gdk_screen_get_window_stack (screen);
        GList *parent_pos = g_list_find (stack, GTK_WIDGET (priv->parent_window)->window);
        GList *toplevels = gtk_window_list_toplevels ();
        GList *i;

        for (i = toplevels; i != NULL && !intruder_found; i = i->next) {
            if (i->data != widget && i->data != priv->parent_window) {
                if (g_list_find (parent_pos, GTK_WIDGET (i->data)->window)) {
                    /* HildonBanners are not closed automatically when
                     * a new window appears, so we must close them by
                     * hand to make the AppMenu work as expected.
                     * Yes, this is a hack. See NB#111027 */
                    if (HILDON_IS_BANNER (i->data)) {
                        gtk_widget_hide (i->data);
                    } else if (GTK_IS_WINDOW (i->data)) {
                        intruder_found = gtk_window_get_modal (i->data);
                    }
                }
            }
        }

        g_list_foreach (stack, (GFunc) g_object_unref, NULL);
        g_list_free (stack);
        g_list_free (toplevels);

        if (intruder_found)
            gtk_widget_hide (widget);
    }

    return FALSE;
}
Exemple #11
0
static void	ug_selector_filter_show (struct UgSelectorFilter* filter, UgSelectorPage* page)
{
	GtkWindow* parent;

	gtk_tree_view_set_model (filter->host_view,
			GTK_TREE_MODEL (page->filter.host));
	gtk_tree_view_set_model (filter->ext_view,
			GTK_TREE_MODEL (page->filter.ext));

	// disable sensitive of parent window
	// enable sensitive in function on_filter_dialog_response()
	parent = gtk_window_get_transient_for ((GtkWindow*) filter->dialog);
	if (parent)
		gtk_widget_set_sensitive ((GtkWidget*) parent, FALSE);
	// create filter dialog
	if (gtk_window_get_modal (parent))
		gtk_dialog_run (filter->dialog);
	else
		gtk_widget_show ((GtkWidget*) filter->dialog);
}
Exemple #12
0
void description_window_create(DescriptionWindow *dwindow)
{
	if (!dwindow->window) {
		description_create(dwindow);
	
		gtk_window_set_transient_for(GTK_WINDOW(dwindow->window), GTK_WINDOW(dwindow->parent));
		dwindow->parent_modal = gtk_window_get_modal(GTK_WINDOW(dwindow->parent));
#ifndef G_OS_WIN32
		gtk_window_set_modal(GTK_WINDOW(dwindow->parent), TRUE);
#else
		gtk_window_set_modal(GTK_WINDOW(dwindow->window), TRUE);
#endif
		gtk_window_set_destroy_with_parent(GTK_WINDOW(dwindow->window), TRUE);
		gtk_widget_show(dwindow->window);

		/* in case the description window is closed using the WM's [X] button */
		g_signal_connect(G_OBJECT(dwindow->window), "destroy",
				G_CALLBACK(gtk_widget_destroyed), &dwindow->window);

	} else g_print("windows exist\n");
}
Exemple #13
0
static void on_select_post (GtkEntry* entry, GtkEntryIconPosition icon_pos, GdkEvent* event, UgtkDownloadForm* dform)
{
	GtkWidget*	chooser;
	gchar*		path;
	gchar*		title;

	// disable sensitive of parent window
	// enable sensitive in function on_file_chooser_response()
	if (dform->parent)
		gtk_widget_set_sensitive ((GtkWidget*) dform->parent, FALSE);

	title = g_strconcat (UGTK_APP_NAME " - ", _("Select Post File"), NULL);
	chooser = gtk_file_chooser_dialog_new (title, dform->parent,
			GTK_FILE_CHOOSER_ACTION_OPEN,
			GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
			GTK_STOCK_OK,     GTK_RESPONSE_OK,
			NULL);
	g_free (title);
	gtk_window_set_transient_for ((GtkWindow*) chooser, dform->parent);
	gtk_window_set_destroy_with_parent ((GtkWindow*) chooser, TRUE);

	path = (gchar*) gtk_entry_get_text ((GtkEntry*) dform->post_entry);
	if (*path) {
		path = g_filename_from_utf8 (path, -1, NULL, NULL, NULL);
		gtk_file_chooser_select_filename (GTK_FILE_CHOOSER (chooser), path);
		g_free (path);
	}
	g_signal_connect (chooser, "response",
			G_CALLBACK (on_select_post_response), dform);

	if (gtk_window_get_modal (dform->parent))
		gtk_dialog_run ((GtkDialog*) chooser);
	else {
		gtk_window_set_modal ((GtkWindow*) chooser, FALSE);
		gtk_widget_show (chooser);
	}
}
static void
other_application_item_activated_cb (GtkAppChooserButton *self)
{
  GtkWidget *dialog, *widget;
  GtkWindow *toplevel;

  toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self)));
  dialog = gtk_app_chooser_dialog_new_for_content_type (toplevel, GTK_DIALOG_DESTROY_WITH_PARENT,
                                                        self->priv->content_type);

  gtk_window_set_modal (GTK_WINDOW (dialog), gtk_window_get_modal (toplevel));
  gtk_app_chooser_dialog_set_heading (GTK_APP_CHOOSER_DIALOG (dialog),
                                      self->priv->heading);

  widget = gtk_app_chooser_dialog_get_widget (GTK_APP_CHOOSER_DIALOG (dialog));
  g_object_set (widget,
                "show-fallback", TRUE,
                "show-other", TRUE,
                NULL);
  gtk_widget_show (dialog);

  g_signal_connect (dialog, "response",
                    G_CALLBACK (other_application_dialog_response_cb), self);
}
Exemple #15
0
bool gMainWindow::isModal() const
{
	if (!isTopLevel()) return false;

	return gtk_window_get_modal(GTK_WINDOW(border));
}
/*  private function of gimp_unit_menu_callback ()  */
static void
gimp_unit_menu_create_selection (GimpUnitMenu *menu)
{
  GtkWidget        *parent = gtk_widget_get_toplevel (GTK_WIDGET (menu));
  GtkWidget        *vbox;
  GtkWidget        *scrolled_win;
  GtkListStore     *list;
  GtkTreeSelection *sel;
  GtkTreeIter       iter;
  GtkTreePath      *path;
  GtkDialogFlags    flags  = GTK_DIALOG_DESTROY_WITH_PARENT;
  GimpUnit          unit;
  gint              num_units;

  if (gtk_window_get_modal (GTK_WINDOW (parent)))
    flags |= GTK_DIALOG_MODAL;

  menu->selection = gimp_dialog_new (_("Unit Selection"), "gimp-unit-selection",
                                     parent, flags,
                                     gimp_standard_help_func,
                                     "gimp-unit-dialog",

                                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                     GTK_STOCK_OK,     GTK_RESPONSE_OK,

                                     NULL);

  gtk_dialog_set_alternative_button_order (GTK_DIALOG (menu->selection),
                                           GTK_RESPONSE_OK,
                                           GTK_RESPONSE_CANCEL,
                                           -1);

  g_object_add_weak_pointer (G_OBJECT (menu->selection),
                             (gpointer) &menu->selection);

  g_signal_connect (menu->selection, "response",
                    G_CALLBACK (gimp_unit_menu_selection_response),
                    menu);

  g_signal_connect_object (menu, "unmap",
                           G_CALLBACK (gtk_widget_destroy),
                           menu->selection, G_CONNECT_SWAPPED);

  /*  the main vbox  */
  vbox = gtk_vbox_new (FALSE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (menu->selection))),
                      vbox, TRUE, TRUE, 0);
  gtk_widget_show (vbox);

  /*  the selection list  */
  scrolled_win = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win),
                                       GTK_SHADOW_ETCHED_IN);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
                                  GTK_POLICY_NEVER,
                                  GTK_POLICY_ALWAYS);
  gtk_box_pack_start (GTK_BOX (vbox), scrolled_win, TRUE, TRUE, 0);
  gtk_widget_show (scrolled_win);

  list = gtk_list_store_new (NUM_COLUMNS, G_TYPE_STRING, G_TYPE_STRING,
                             G_TYPE_INT);
  menu->tv = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list));
  g_object_unref (list);

  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (menu->tv),
                                               -1, _("Unit"),
                                               gtk_cell_renderer_text_new (),
                                               "text", UNIT_COLUMN, NULL);
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (menu->tv),
                                               -1, _("Factor"),
                                               gtk_cell_renderer_text_new (),
                                               "text", FACTOR_COLUMN, NULL);

  /*  the unit lines  */
  num_units = gimp_unit_get_number_of_units ();
  for (unit = GIMP_UNIT_END; unit < num_units; unit++)
    {
      gchar *string;

      gtk_list_store_append (list, &iter);

      string = gimp_unit_format_string (menu->format, unit);
      gtk_list_store_set (list, &iter,
                          UNIT_COLUMN, string,
                          -1);
      g_free (string);

      string = gimp_unit_format_string ("(%f)", unit);
      gtk_list_store_set (list, &iter,
                          FACTOR_COLUMN, string,
                          -1);
      g_free (string);

      gtk_list_store_set (list, &iter, DATA_COLUMN, unit, -1);
    }

  gtk_widget_set_size_request (menu->tv, -1, 150);

  gtk_container_add (GTK_CONTAINER (scrolled_win), menu->tv);

  g_signal_connect (menu->tv, "row-activated",
                    G_CALLBACK (gimp_unit_menu_selection_row_activated_callback),
                    menu);

  gtk_widget_show (menu->tv);

  g_signal_connect (menu->tv, "destroy",
                    G_CALLBACK (gtk_widget_destroyed),
                    &menu->tv);

  gtk_widget_show (vbox);
  gtk_widget_show (menu->selection);

  if (menu->unit >= GIMP_UNIT_END)
    {
      path = gtk_tree_path_new ();
      gtk_tree_path_append_index (path, menu->unit - GIMP_UNIT_END);

      sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (menu->tv));
      gtk_tree_selection_select_path (sel, path);

      gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (menu->tv), path, NULL,
                                    FALSE, 0.0, 0.0);
    }
}
Exemple #17
0
static void
gnm_font_button_clicked (GtkButton *button)
{
  GtkFontChooser *font_dialog;
  GnmFontButton  *font_button = GNM_FONT_BUTTON (button);
  GnmFontButtonPrivate *priv = font_button->priv;

  if (!font_button->priv->font_dialog)
    {
      GtkWidget *parent;

      parent = gtk_widget_get_toplevel (GTK_WIDGET (font_button));

      priv->font_dialog = g_object_new (priv->dialog_type, NULL);
      font_dialog = GTK_FONT_CHOOSER (font_button->priv->font_dialog);

      gtk_font_chooser_set_show_preview_entry (font_dialog, priv->show_preview_entry);

      if (priv->preview_text)
        {
          gtk_font_chooser_set_preview_text (font_dialog, priv->preview_text);
          g_free (priv->preview_text);
          priv->preview_text = NULL;
        }

      if (priv->font_filter)
        {
          gtk_font_chooser_set_filter_func (font_dialog,
                                            priv->font_filter,
                                            priv->font_filter_data,
                                            priv->font_filter_data_destroy);
          priv->font_filter = NULL;
          priv->font_filter_data = NULL;
          priv->font_filter_data_destroy = NULL;
        }

      if (gtk_widget_is_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, "notify",
                        G_CALLBACK (gnm_font_button_font_chooser_notify), button);

      g_signal_connect (font_dialog, "response",
                        G_CALLBACK (response_cb), font_button);

      g_signal_connect (font_dialog, "destroy",
                        G_CALLBACK (dialog_destroy), font_button);
    }

  if (!gtk_widget_get_visible (font_button->priv->font_dialog))
    {
      font_dialog = GTK_FONT_CHOOSER (font_button->priv->font_dialog);
      gtk_font_chooser_set_font_desc (font_dialog, font_button->priv->font_desc);
    }

  gtk_window_present (GTK_WINDOW (font_button->priv->font_dialog));
}
Exemple #18
0
void
ask_whether_to_trim (GtkWindow        *parent_window,
		     FileData         *file,
		     TrimResponseFunc  done_func,
		     gpointer          done_data)
{
	AskTrimData *data;
	char        *display_name;
	char        *msg;
	
	/* If the user disabled the warning dialog trim the image */

	if (! eel_gconf_get_boolean (PREF_MSG_JPEG_MCU_WARNING, TRUE)) {
		if (done_func != NULL)
			done_func (JPEG_MCU_ACTION_TRIM, done_data);
		return;
	}

	/*
	 * Image dimensions are not multiples of the jpeg minimal coding unit (mcu).
	 * Warn about possible image distortions along one or more edges.
	 */

	data = g_new0 (AskTrimData, 1);
	data->done_func = done_func;
	data->done_data = done_data;
	data->parent_window = parent_window;
	data->parent_is_modal = FALSE;
	
	if (parent_window != NULL) {
		data->parent_is_modal = gtk_window_get_modal (parent_window);
		if (data->parent_is_modal)
			gtk_window_set_modal (data->parent_window, FALSE);
	}

	display_name = basename_for_display (file->path);
	msg = g_strdup_printf (_("Problem transforming the image: %s"), display_name);
	data->dialog = _gtk_message_dialog_with_checkbutton_new (parent_window,
								 GTK_DIALOG_MODAL,
								 GTK_STOCK_DIALOG_WARNING,
								 msg,
								 _("This transformation may introduce small image distortions along "
		  						   "one or more edges, because the image dimensions are not multiples of 8.\n\nThe distortion "
		  						   "is reversible, however. If the resulting image is unacceptable, simply apply the reverse "
		  						   "transformation to return to the original image.\n\nYou can also choose to discard (or trim) any "
		  						   "untransformable edge pixels. For practical use, this mode gives the best looking results, "
		  						   "but the transformation is not strictly lossless anymore."),
 								 PREF_MSG_JPEG_MCU_WARNING,
								 _("_Do not display this message again"),
								 _("_Trim"), RESPONSE_TRIM,
								 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
								 GTK_STOCK_OK, GTK_RESPONSE_OK,
								 NULL);
	g_free (display_name);
	g_free (msg);

	g_signal_connect (G_OBJECT (data->dialog), "response",
			  G_CALLBACK (ask_whether_to_trim_response_cb),
			  data);
	gtk_widget_show (data->dialog);
}