/**
 * seahorse_widget_destroy:
 * @swidget: #SeahorseWidget to destroy
 *
 * Unrefs @swidget.
 **/
void
seahorse_widget_destroy (SeahorseWidget *swidget)
{
    GtkWidget *widget;
    gchar *widthkey, *heightkey;
    gint width, height;

    g_return_if_fail (swidget != NULL && SEAHORSE_IS_WIDGET (swidget));
    widget = seahorse_widget_get_toplevel (swidget);
    
    /* Don't save window size for dialogs */
    if (!GTK_IS_DIALOG (widget)) {

	    /* Save window size */
	    gtk_window_get_size (GTK_WINDOW (widget), &width, &height);
    
	    widthkey = g_strdup_printf ("%s%s%s", WINDOW_SIZE, swidget->name, "_width");
	    seahorse_gconf_set_integer (widthkey, width);
    
	    heightkey = g_strdup_printf ("%s%s%s", WINDOW_SIZE, swidget->name, "_height");
	    seahorse_gconf_set_integer (heightkey, height);
    
	    g_free (widthkey);
	    g_free (heightkey);
    }
    
    /* Destroy Widget */
    if (!swidget->destroying) {
        swidget->destroying = TRUE;
        g_object_unref (swidget);
    }
}
Beispiel #2
0
/*! \brief Internal GTK function modified from GTK+-2.4.14 gtkdialog.c
 *  to support gschem_dialog_new_with_buttons(...)
 *
 *  \par Function Description
 *  Convenience function which adds buttons to a pre-existing GtkDialog
 *
 *  \param [in]  dialog             The GtkDialog buttons are being added to
 *  \param [in]  first_button_text  The text string for the first button
 *  \param [in]  args               The va_list containging the remaining button strings
 */
static void gschem_dialog_add_buttons_valist (GtkDialog      *dialog,
                                              const gchar    *first_button_text,
                                              va_list         args)
{
  const gchar* text;
  gint response_id;

  g_return_if_fail (GTK_IS_DIALOG (dialog));

  if (first_button_text == NULL)
    return;

  text = first_button_text;
  response_id = va_arg (args, gint);

  while (text != NULL)
    {
      gtk_dialog_add_button (dialog, text, response_id);

      text = va_arg (args, gchar*);
      if (text == NULL)
        break;
      response_id = va_arg (args, int);
    }
}
Beispiel #3
0
static GtkWidget* my_gtk_dialog_get_widget_for_response (GtkDialog *dialog,gint       response_id) {
	GList *children;
	GList *tmp_list;

	g_return_val_if_fail (GTK_IS_DIALOG (dialog), NULL);

	children = gtk_container_get_children (GTK_CONTAINER (dialog->action_area));

	tmp_list = children;
	while (tmp_list != NULL) {
		GtkWidget *widget = tmp_list->data;
		ResponseData *rd = get_response_data (widget, FALSE);

		if (rd && rd->response_id == response_id) {
			g_list_free (children);
			return widget;
		}

		tmp_list = g_list_next (tmp_list);
	}

	g_list_free (children);

	return NULL;
}
static GObject*  
seahorse_widget_constructor (GType type, guint n_props, GObjectConstructParam* props)
{
    SeahorseWidget *swidget;
    GObject *obj;
    
    GtkWindow *window;
    gint width, height;
    gchar *widthkey, *heightkey;
    
    obj = G_OBJECT_CLASS (parent_class)->constructor (type, n_props, props);
    swidget = SEAHORSE_WIDGET (obj);

    /* Load window size for windows that aren't dialogs */
    window = GTK_WINDOW (seahorse_widget_get_toplevel (swidget));
    if (!GTK_IS_DIALOG (window)) {
	    widthkey = g_strdup_printf ("%s%s%s", WINDOW_SIZE, swidget->name, "_width");
	    width = seahorse_gconf_get_integer (widthkey);
    
	    heightkey = g_strdup_printf ("%s%s%s", WINDOW_SIZE, swidget->name, "_height");
	    height = seahorse_gconf_get_integer (heightkey);

	    if (width > 0 && height > 0)
		    gtk_window_resize (window, width, height);

	    g_free (widthkey);
	    g_free (heightkey);
    }
    
    return obj;
}
/**
* builder: The gtk builder to add the gku-prompt.ui to
*
* Create and set up the dialog
*
* Returns the new dialog
**/
static GtkDialog*
prepare_dialog (GtkBuilder *builder)
{
	GError *error = NULL;
	GtkDialog *dialog;

	if (!gtk_builder_add_from_file (builder, UIDIR "gku-prompt.ui", &error)) {
		g_warning ("couldn't load prompt ui file: %s", egg_error_message (error));
		g_clear_error (&error);
		return NULL;
	}

	dialog = GTK_DIALOG (gtk_builder_get_object (builder, "prompt_dialog"));
	g_return_val_if_fail (GTK_IS_DIALOG (dialog), NULL);

	prepare_visibility (builder, dialog);
	prepare_titlebar (builder, dialog);
	prepare_prompt (builder, dialog);
	prepare_buttons (builder, dialog);
	prepare_passwords (builder, dialog);
	prepare_security (builder, dialog);
	prepare_lock (builder, dialog);
	prepare_details (builder, dialog);

	return dialog;
}
Beispiel #6
0
static void
gail_window_real_initialize (AtkObject *obj,
                             gpointer  data)
{
  GtkWidget *widget = GTK_WIDGET (data);
  GailWindow *window;

  /*
   * A GailWindow can be created for a GtkHandleBox or a GtkWindow
   */
  if (!GTK_IS_WINDOW (widget) &&
      !GTK_IS_HANDLE_BOX (widget))
    gail_return_if_fail (FALSE);

  ATK_OBJECT_CLASS (gail_window_parent_class)->initialize (obj, data);

  window = GAIL_WINDOW (obj);
  window->name_change_handler = 0;
  window->previous_name = g_strdup (gtk_window_get_title (GTK_WINDOW (data)));

  g_signal_connect (data,
                    "window_state_event",
                    G_CALLBACK (gail_window_state_event_gtk),
                    NULL);
  g_object_set_data (G_OBJECT (obj), "atk-component-layer",
                     GINT_TO_POINTER (ATK_LAYER_WINDOW));

  if (GTK_IS_FILE_SELECTION (widget))
    obj->role = ATK_ROLE_FILE_CHOOSER;
  else if (GTK_IS_COLOR_SELECTION_DIALOG (widget))
    obj->role = ATK_ROLE_COLOR_CHOOSER;
  else if (GTK_IS_FONT_SELECTION_DIALOG (widget))
    obj->role = ATK_ROLE_FONT_CHOOSER;
  else if (GTK_IS_MESSAGE_DIALOG (widget))
    obj->role = ATK_ROLE_ALERT;
  else if (GTK_IS_DIALOG (widget))
    obj->role = ATK_ROLE_DIALOG;
  else
    {
      const gchar *name;

      name = gtk_widget_get_name (widget);
      if (name && (!strcmp (name, "gtk-tooltip") ||
                   !strcmp (name, "gtk-tooltips")))
        obj->role = ATK_ROLE_TOOL_TIP;
      else if (GTK_IS_PLUG (widget))
        obj->role = ATK_ROLE_PANEL;
      else if (GTK_WINDOW (widget)->type == GTK_WINDOW_POPUP)
        obj->role = ATK_ROLE_WINDOW;
      else
        obj->role = ATK_ROLE_FRAME;
    }

  /*
   * Notify that tooltip is showing
   */
  if (obj->role == ATK_ROLE_TOOL_TIP &&
      gtk_widget_get_mapped (widget))
    atk_object_notify_state_change (obj, ATK_STATE_SHOWING, 1);
}
Beispiel #7
0
/** The Filter dialog was closed.  Check to see if this was done via
 *  the OK button.  If so, make the changes permanent.  If not, revert
 *  any changes.
 *
 *  @param dialog A pointer to the "Filter By" dialog.
 *
 *  @param response The response code from closing the dialog.
 *
 *  @param fd A pointer to the owner filter dialog struct. */
void
gppot_filter_response_cb (GtkWidget *dialog,
                          gint       response,
                          OwnerFilterDialog *fd)
{
    gpointer gptemp;

    g_return_if_fail(GTK_IS_DIALOG(dialog));

    ENTER("dialog %p, response %d", dialog, response);

    if (response != GTK_RESPONSE_OK)
    {
        fd->show_inactive = fd->original_show_inactive;
        fd->show_zero_total = fd->original_show_zero_total;
        gnc_tree_view_owner_refilter(fd->tree_view);
    }

    /* Clean up and delete dialog */
    gptemp = (gpointer *)fd->dialog;
    g_atomic_pointer_compare_and_exchange(&gptemp,
                                          dialog, NULL);
    fd->dialog = gptemp;
    gtk_widget_destroy(dialog);
    LEAVE("");
}
Beispiel #8
0
void sg_make_resizable(GtkWidget *w)
{
  if (GTK_IS_DIALOG(w))
    {
      gtk_window_set_default_size(GTK_WINDOW(w), -1, -1);
      gtk_window_set_resizable(GTK_WINDOW(w), true);
    }
}
Beispiel #9
0
void
gtk_utils_show_and_forget_dialog (GtkDialog *dialog)
{
  g_return_if_fail (GTK_IS_DIALOG (dialog));

  g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
  gtk_window_present (GTK_WINDOW (dialog));
}
Beispiel #10
0
static void
e_webdav_discover_content_selection_changed_cb (GtkTreeSelection *selection,
						GtkDialog *dialog)
{
	g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
	g_return_if_fail (GTK_IS_DIALOG (dialog));

	gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_ACCEPT,
		gtk_tree_selection_count_selected_rows (selection) > 0);
}
Beispiel #11
0
static void
test_dialog_basic (void)
{
  GtkWidget *dialog;

  dialog = gtk_dialog_new();
  g_assert (GTK_IS_DIALOG (dialog));
  g_assert (gtk_dialog_get_content_area (GTK_DIALOG (dialog)) != NULL);

  gtk_widget_destroy (dialog);
}
static void
gsm_logout_tile_clicked (GtkWidget *tile,
                         gpointer   response_p)
{
    GtkWidget *dialog;

    dialog = gtk_widget_get_toplevel (tile);
    g_assert (GTK_IS_DIALOG (dialog));
    gtk_dialog_response (GTK_DIALOG (dialog),
                         GPOINTER_TO_UINT (response_p));
}
Beispiel #13
0
void
gtk_utils_standardize_dialog (GtkDialog *dialog, GtkWidget *contents)
{
  g_return_if_fail (GTK_IS_DIALOG (dialog));
  g_return_if_fail (GTK_IS_CONTAINER (contents));
 
  gtk_widget_set_name (GTK_WIDGET (dialog), "quarry-dialog");

  gtk_box_set_spacing (GTK_BOX (dialog->vbox), QUARRY_SPACING);
  gtk_box_pack_start_defaults (GTK_BOX (dialog->vbox), contents);
}
/**
 * gimp_color_profile_combo_box_new_with_model:
 * @dialog: a #GtkDialog to present when the user selects the
 *          "Select color profile from disk..." item
 * @model:  a #GimpColorProfileStore object
 *
 * This constructor is useful when you want to create several
 * combo-boxes for profile selection that all share the same
 * #GimpColorProfileStore. This is for example done in the
 * GIMP Preferences dialog.
 *
 * See also gimp_color_profile_combo_box_new().
 *
 * Return value: a new #GimpColorProfileComboBox.
 *
 * Since: GIMP 2.4
 **/
GtkWidget *
gimp_color_profile_combo_box_new_with_model (GtkWidget    *dialog,
                                             GtkTreeModel *model)
{
  g_return_val_if_fail (GTK_IS_DIALOG (dialog), NULL);
  g_return_val_if_fail (GIMP_IS_COLOR_PROFILE_STORE (model), NULL);

  return g_object_new (GIMP_TYPE_COLOR_PROFILE_COMBO_BOX,
                       "dialog", dialog,
                       "model",  model,
                       NULL);
}
Beispiel #15
0
void
glade_gtk_dialog_write_child (GladeWidgetAdaptor * adaptor,
                              GladeWidget * widget,
                              GladeXmlContext * context, GladeXmlNode * node)
{
  GladeWidget *parent = glade_widget_get_parent (widget);

  GWA_GET_CLASS (GTK_TYPE_CONTAINER)->write_child (adaptor, widget, context, node);

  if (parent && GTK_IS_DIALOG (glade_widget_get_object (parent)))
    glade_gtk_action_widgets_write_child (parent, context, node, "action_area");
}
Beispiel #16
0
static void
trust_prompt_listen_for_source_changes_cb (GtkDialog *dialog,
					   gpointer user_data)
{
	ESource *source = user_data;

	g_return_if_fail (GTK_IS_DIALOG (dialog));
	g_return_if_fail (E_IS_SOURCE (source));

	g_signal_connect (source, "notify::connection-status",
		G_CALLBACK (source_connection_status_changed_cb), dialog);
}
const gchar *
terminal_search_dialog_get_search_text (GtkWidget *dialog)
{
  TerminalSearchDialogPrivate *priv;

  g_return_val_if_fail (GTK_IS_DIALOG (dialog), NULL);

  priv = TERMINAL_SEARCH_DIALOG_GET_PRIVATE (dialog);
  g_return_val_if_fail (priv, NULL);

  return gtk_entry_get_text (GTK_ENTRY (priv->search_text_entry));
}
Beispiel #18
0
static void
source_connection_status_changed_cb (ESource *source,
				     GParamSpec *param,
				     GtkDialog *dialog)
{
	g_return_if_fail (GTK_IS_DIALOG (dialog));

	/* Do not close the prompt when the source is still waiting for the credentials. */
	if (e_source_get_connection_status (source) != E_SOURCE_CONNECTION_STATUS_AWAITING_CREDENTIALS &&
	    e_source_get_connection_status (source) != E_SOURCE_CONNECTION_STATUS_SSL_FAILED)
		gtk_dialog_response (dialog, GTK_RESPONSE_CANCEL);
}
Beispiel #19
0
/**
 * e_webdav_discover_dialog_get_content:
 * @dialog: a #GtkDialog returned by e_webdav_discover_dialog_new()
 *
 * Returns inner WebDAV discovery content, which can be further manipulated.
 *
 * Returns: (transfer none): inner WebDAV discovery content
 *
 * Since: 3.18
 **/
GtkWidget *
e_webdav_discover_dialog_get_content (GtkDialog *dialog)
{
	GtkWidget *content;

	g_return_val_if_fail (GTK_IS_DIALOG (dialog), NULL);

	content = g_object_get_data (G_OBJECT (dialog), WEBDAV_DISCOVER_CONTENT_KEY);
	g_return_val_if_fail (content != NULL, NULL);

	return content;
}
Beispiel #20
0
static void
test_message_dialog_basic (void)
{
  GtkWidget *dialog;

  dialog = gtk_message_dialog_new (NULL, 0,
				   GTK_MESSAGE_INFO,
				   GTK_BUTTONS_CLOSE,
				   "Do it hard !");
  g_assert (GTK_IS_DIALOG (dialog));
  gtk_widget_destroy (dialog);
}
Beispiel #21
0
static void
test_dialog_override_property (void)
{
  GtkWidget *dialog;

  dialog = g_object_new (GTK_TYPE_DIALOG,
			 "type-hint", GDK_WINDOW_TYPE_HINT_UTILITY,
			 NULL);
  g_assert (GTK_IS_DIALOG (dialog));
  g_assert (gtk_window_get_type_hint (GTK_WINDOW (dialog)) == GDK_WINDOW_TYPE_HINT_UTILITY);

  gtk_widget_destroy (dialog);
}
void
terminal_search_dialog_present (GtkWidget *dialog)
{
  TerminalSearchDialogPrivate *priv;

  g_return_if_fail (GTK_IS_DIALOG (dialog));

  priv = TERMINAL_SEARCH_DIALOG_GET_PRIVATE (dialog);
  g_return_if_fail (priv);

  gtk_window_present (GTK_WINDOW (dialog));
  gtk_widget_grab_focus (priv->search_text_entry);
}
Beispiel #23
0
/**
 * e_webdav_discover_dialog_refresh:
 * @dialog: a #GtkDialog returned by e_webdav_discover_dialog_new()
 *
 * Invokes refresh of the inner content of the WebDAV discovery dialog.
 *
 * Since: 3.18
 **/
void
e_webdav_discover_dialog_refresh (GtkDialog *dialog)
{
	GtkWidget *content;

	g_return_if_fail (GTK_IS_DIALOG (dialog));

	content = g_object_get_data (G_OBJECT (dialog), WEBDAV_DISCOVER_CONTENT_KEY);
	g_return_if_fail (content != NULL);

	e_webdav_discover_content_refresh (content, gtk_window_get_title (GTK_WINDOW (dialog)),
		NULL, e_webdav_discover_content_dialog_refresh_done_cb, NULL);
}
Beispiel #24
0
void
gimp_session_info_set_widget (GimpSessionInfo *info,
                              GtkWidget       *widget)
{
  g_return_if_fail (GIMP_IS_SESSION_INFO (info));

  if (GTK_IS_DIALOG (info->p->widget))
    g_signal_handlers_disconnect_by_func (info->p->widget,
                                          gimp_session_info_dialog_show,
                                          info);

  info->p->widget = widget;
}
Beispiel #25
0
static void
xydenoise_data_cb(GwyDataChooser *chooser,
                 GwyAppDataId *object)
{
    GtkWidget *dialog;

    gwy_data_chooser_get_active_id(chooser, object);
    gwy_debug("data: %d %d", object->datano, object->id);

    dialog = g_object_get_data(G_OBJECT(chooser), "dialog");
    g_assert(GTK_IS_DIALOG(dialog));
    gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_OK,
                                      object->datano);
}
void
title_entry_changed_cb (GtkEditable	*entry,
			gpointer	user_data)
{
	GtkDialog	*dialog;
	gboolean	sens;

	g_return_if_fail (GTK_IS_ENTRY (entry));
	g_return_if_fail (GTK_IS_DIALOG (user_data));

	dialog = GTK_DIALOG (user_data);
	sens = (gtk_entry_get_text_length (GTK_ENTRY (entry)) > 0);

	gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_OK, sens);
}
/**
 * gimp_color_profile_combo_box_new:
 * @dialog:  a #GtkDialog to present when the user selects the
 *           "Select color profile from disk..." item
 * @history: filename of the profilerc (or %NULL for no history)
 *
 * Create a combo-box widget for selecting color profiles. The combo-box
 * is populated from the file specified as @history. This filename is
 * typically created using the following code snippet:
 * <informalexample><programlisting>
 *  gchar *history = gimp_personal_rc_file ("profilerc");
 * </programlisting></informalexample>
 *
 * Return value: a new #GimpColorProfileComboBox.
 *
 * Since: GIMP 2.4
 **/
GtkWidget *
gimp_color_profile_combo_box_new (GtkWidget   *dialog,
                                  const gchar *history)
{
  GtkWidget    *combo;
  GtkListStore *store;

  g_return_val_if_fail (GTK_IS_DIALOG (dialog), NULL);

  store = gimp_color_profile_store_new (history);
  combo = gimp_color_profile_combo_box_new_with_model (dialog,
                                                       GTK_TREE_MODEL (store));
  g_object_unref (store);

  return combo;
}
Beispiel #28
0
/**********************************************************************
  This function handles new windows which are subwindows to the
  toplevel window. It must be called on every dialog in the game,
  so fullscreen windows are handled properly by the window manager.
***********************************************************************/
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
{
  if (gui_gtk3_dialogs_on_top || fullscreen_mode) {
    gtk_window_set_transient_for(GTK_WINDOW(shell),
                                 GTK_WINDOW(parent));
    gtk_window_set_type_hint(GTK_WINDOW(shell),
                             GDK_WINDOW_TYPE_HINT_DIALOG);
  } else {
    gtk_window_set_type_hint(GTK_WINDOW(shell),
                             GDK_WINDOW_TYPE_HINT_NORMAL);
  }

  /* Close dialog window on Escape keypress. */
  if (GTK_IS_DIALOG(shell)) {
    g_signal_connect_after(shell, "close", G_CALLBACK(close_callback), shell);
  }
}
GRegex *
terminal_search_dialog_get_regex (GtkWidget *dialog)
{
  TerminalSearchDialogPrivate *priv;
  GRegexCompileFlags compile_flags;
  const char *text, *pattern;

  g_return_val_if_fail (GTK_IS_DIALOG (dialog), NULL);

  priv = TERMINAL_SEARCH_DIALOG_GET_PRIVATE (dialog);
  g_return_val_if_fail (priv, NULL);

  pattern = text = terminal_search_dialog_get_search_text (dialog);

  compile_flags = G_REGEX_OPTIMIZE;

  if (!GET_FLAG (match_case_checkbutton))
    compile_flags |= G_REGEX_CASELESS;

  if (GET_FLAG (regex_checkbutton))
    compile_flags |= G_REGEX_MULTILINE;
  else
    pattern = g_regex_escape_string (text, -1);

  if (GET_FLAG (entire_word_checkbutton)) {
    const char *old_pattern = pattern;
    pattern = g_strdup_printf ("\\b%s\\b", pattern);
    if (old_pattern != text)
      g_free ((char *) old_pattern);
  }

  if (!priv->regex || priv->regex_compile_flags != compile_flags ||
      g_strcmp0 (pattern, g_regex_get_pattern (priv->regex)) != 0) {
    priv->regex_compile_flags = compile_flags;
    if (priv->regex)
      g_regex_unref (priv->regex);

    /* TODO Error handling */
    priv->regex = g_regex_new (pattern, compile_flags, 0, NULL);
  }

  if (pattern != text)
    g_free ((char *) pattern);

  return priv->regex;
}
void
terminal_search_dialog_set_search_text (GtkWidget   *dialog,
					const gchar *text)
{
  TerminalSearchDialogPrivate *priv;

  g_return_if_fail (GTK_IS_DIALOG (dialog));
  g_return_if_fail (text != NULL);

  priv = TERMINAL_SEARCH_DIALOG_GET_PRIVATE (dialog);
  g_return_if_fail (priv);

  gtk_entry_set_text (GTK_ENTRY (priv->search_text_entry), text);

  gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
				     GTK_RESPONSE_ACCEPT,
				     (*text != '\0'));
}