Back to index

im-sdk  12.3.91
Functions
utils.c File Reference
#include <config.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkdrawingarea.h>
#include <gtk/gtkbutton.h>
#include <gtk/gtksignal.h>
#include <panel-applet.h>
#include <gnome.h>
#include "gnome-im-switcher.h"
#include "utils.h"

Go to the source code of this file.

Functions

void gimlet_util_show_error_dialog (GtkWindow *transient_parent, GtkWidget **weak_ptr, const char *message_format,...)
 gimlet_util_show_error_dialog: : parent of the future dialog window; : pointer to a #Widget pointer, to control the population.
void gimlet_util_show_help (const char *topic, GtkWindow *transient_parent)
void gimlet_util_set_unique_role (GtkWindow *window, const char *prefix)
GladeXML * gimlet_util_load_glade_file (const char *filename, const char *widget_root, GtkWindow *error_dialog_parent)

Function Documentation

GladeXML* gimlet_util_load_glade_file ( const char *  filename,
const char *  widget_root,
GtkWindow *  error_dialog_parent 
)

Definition at line 125 of file utils.c.

{
  char *path;
  GladeXML *xml;

  xml = NULL;
  path = g_strconcat ("./", filename, NULL);
  
  if (g_file_test (path,
                   G_FILE_TEST_EXISTS))
    {
      /* Try current dir, for debugging */
      xml = glade_xml_new (path,
                           widget_root,
                           GETTEXT_PACKAGE);
    }
  
  if (xml == NULL)
    {
      g_free (path);
      
      path = g_build_filename (GIMLET_GLADE_DIR, filename, NULL);

      xml = glade_xml_new (path,
                           widget_root,
                           GETTEXT_PACKAGE);
    }

  if (xml == NULL)
    {
      static GtkWidget *no_glade_dialog = NULL;

      gimlet_util_show_error_dialog (error_dialog_parent, &no_glade_dialog, 
                                 _("The file \"%s\" is missing. This indicates that the application is installed incorrectly."), path);
    }

  g_free (path);

  return xml;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gimlet_util_set_unique_role ( GtkWindow *  window,
const char *  prefix 
)

Definition at line 115 of file utils.c.

{
  char *role;

  role = g_strdup_printf ("%s-%d-%d-%d", prefix, getpid (), g_random_int (), (int) time (NULL));
  gtk_window_set_role (window, role);
  g_free (role);
}

Here is the caller graph for this function:

void gimlet_util_show_error_dialog ( GtkWindow *  transient_parent,
GtkWidget **  weak_ptr,
const char *  message_format,
  ... 
)

gimlet_util_show_error_dialog: : parent of the future dialog window; : pointer to a #Widget pointer, to control the population.

: printf() style format string

Create a #GtkMessageDialog window with the message, and present it, handling its buttons. If is not NULL, only create the dialog if <literal>*weap_ptr</literal> is NULL (and in that * case, set to be a weak pointer to the new dialog), otherwise just present <literal>*weak_ptr</literal>. Note that in this last case, the message <emph>will</emph> be changed.

Definition at line 50 of file utils.c.

{
  char *message;
  va_list args;

  if (message_format)
    {
      va_start (args, message_format);
      message = g_strdup_vprintf (message_format, args);
      va_end (args);
    }
  else message = NULL;

  if (weak_ptr == NULL || *weak_ptr == NULL)
    {
      GtkWidget *dialog;
      dialog = gtk_message_dialog_new (transient_parent,
                                       GTK_DIALOG_DESTROY_WITH_PARENT,
                                       GTK_MESSAGE_ERROR,
                                       GTK_BUTTONS_CLOSE,
                                       message);

      g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (gtk_widget_destroy), NULL);

      if (weak_ptr != NULL)
        {
        *weak_ptr = dialog;
        g_object_add_weak_pointer (G_OBJECT (dialog), (void**)weak_ptr);
        }

      gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
      
      gtk_widget_show_all (dialog);
    }
  else 
    {
      g_return_if_fail (GTK_IS_MESSAGE_DIALOG (*weak_ptr));

      gtk_label_set_text (GTK_LABEL (GTK_MESSAGE_DIALOG (*weak_ptr)->label), message);

      gtk_window_present (GTK_WINDOW (*weak_ptr));
    }
}

Here is the caller graph for this function:

void gimlet_util_show_help ( const char *  topic,
GtkWindow *  transient_parent 
)

Definition at line 95 of file utils.c.

{
  GError *err = NULL;

  gnome_help_display_desktop_on_screen (
         NULL, "imswitcher", "imswitcher", topic,
         gtk_widget_get_screen (GTK_WIDGET (transient_parent)),
         &err);

  if (err)
    {
      gimlet_util_show_error_dialog (GTK_WINDOW (transient_parent), NULL,
                                 _("There was an error displaying help: %s"),
                                 err->message);
      g_error_free (err);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function: