Пример #1
0
static void
browse_button_clicked (GtkWidget *button, GtkUtilsBrowseButtonData *data)
{
  if (!data->browsing_dialog) {
    GtkEntry *entry
      = GTK_ENTRY (GTK_IS_ENTRY (data->associated_entry)
		   ? data->associated_entry
		   : GTK_BIN (data->associated_entry)->child);
    const gchar *current_entry_text = gtk_entry_get_text (entry);

    data->browsing_dialog
      = gtk_file_dialog_new (data->browsing_dialog_caption,
			     GTK_WINDOW (gtk_widget_get_toplevel (button)),
			     TRUE, GTK_STOCK_OPEN);

    g_signal_connect (data->browsing_dialog, "response",
		      G_CALLBACK (browsing_dialog_response), data);

    if (*current_entry_text) {
      if (data->is_command_line_entry) {
	gchar **argv;

	if (g_shell_parse_argv (current_entry_text, NULL, &argv, NULL)) {
	  gtk_file_dialog_set_filename (data->browsing_dialog, argv[0]);
	  g_strfreev (argv);
	}
      }
      else {
	gtk_file_dialog_set_filename (data->browsing_dialog,
				      current_entry_text);
      }
    }
  }

  gtk_window_present (GTK_WINDOW (data->browsing_dialog));
}
Пример #2
0
static void
sql_favorite_modify_mitem_cb (G_GNUC_UNUSED GtkMenuItem *mitem, QueryConsolePage *tconsole)
{
	TFavorites *tfav;
	TFavoritesAttributes fav;
	GError *error = NULL;

	memset (&fav, 0, sizeof (fav));
	fav.id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (mitem), "favid"));
	fav.type = T_FAVORITES_QUERIES;
	fav.contents = query_editor_get_all_text (tconsole->priv->editor);
	fav.name = g_object_get_data (G_OBJECT (mitem), "favname");

	tfav = t_connection_get_favorites (tconsole->priv->tcnc);

	if (! t_favorites_add (tfav, 0, &fav, ORDER_KEY_QUERIES, G_MAXINT, &error)) {
		ui_show_error ((GtkWindow*) gtk_widget_get_toplevel ((GtkWidget*) tconsole),
			       _("Could not add favorite: %s"),
			       error && error->message ? error->message : _("No detail"));
                if (error)
                        g_error_free (error);
	}
	g_free (fav.contents);
}
static void
delete_user (GtkButton *button, UmUserPanelPrivate *d)
{
    UmUser *user;
    GtkWidget *dialog;

    user = get_selected_user (d);
    if (user == NULL) {
        return;
    }
    else if (um_user_get_uid (user) == getuid ()) {
        dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (d->main_box)),
                                         0,
                                         GTK_MESSAGE_INFO,
                                         GTK_BUTTONS_CLOSE,
                                         _("You cannot delete your own account."));
        g_signal_connect (dialog, "response",
                          G_CALLBACK (gtk_widget_destroy), NULL);
    }
    else if (um_user_is_logged_in (user)) {
        dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (d->main_box)),
                                         0,
                                         GTK_MESSAGE_INFO,
                                         GTK_BUTTONS_CLOSE,
                                         _("%s is still logged in"),
                                         um_user_get_real_name (user));

        gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
                _("Deleting a user while they are logged in can leave the system in an inconsistent state."));
        g_signal_connect (dialog, "response",
                          G_CALLBACK (gtk_widget_destroy), NULL);
    }
    else {
        dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (d->main_box)),
                                         0,
                                         GTK_MESSAGE_QUESTION,
                                         GTK_BUTTONS_NONE,
                                         _("Do you want to keep %s's files?"),
                                         um_user_get_real_name (user));

        gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
                _("It is possible to keep the home directory, mail spool and temporary files around when deleting a user account."));

        gtk_dialog_add_buttons (GTK_DIALOG (dialog),
                                _("_Delete Files"), GTK_RESPONSE_NO,
                                _("_Keep Files"), GTK_RESPONSE_YES,
                                _("_Cancel"), GTK_RESPONSE_CANCEL,
                                NULL);

        gtk_window_set_icon_name (GTK_WINDOW (dialog), "system-users");

        g_signal_connect (dialog, "response",
                          G_CALLBACK (delete_user_response), d);
    }

    g_signal_connect (dialog, "close",
                      G_CALLBACK (gtk_widget_destroy), NULL);

    gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);

    gtk_window_present (GTK_WINDOW (dialog));

    g_object_unref (user);
}
Пример #4
0
void create_options( XfcePanelPlugin *plugin, CPUGraph *base )
{
	GtkWidget *dlg, *header;
	GtkBox *vbox, *vbox2;
	GtkWidget *label;
	GtkSizeGroup *sg;
	GtkWidget *Notebook;

	xfce_panel_plugin_block_menu( plugin );

	dlg = gtk_dialog_new_with_buttons( _("CPU Graph Properties"),
	                                   GTK_WINDOW( gtk_widget_get_toplevel( GTK_WIDGET( plugin ) ) ),
	                                   GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
	                                   GTK_STOCK_CLOSE,
	                                   GTK_RESPONSE_OK,
	                                   NULL
					 );

	g_signal_connect( dlg, "response", G_CALLBACK( response_cb ), base );

	gtk_container_set_border_width( GTK_CONTAINER( dlg ), 2 );

	header = xfce_create_header( NULL, _("CPU Graph") );
	gtk_widget_set_size_request( GTK_BIN( header )->child, -1, 32 );
	gtk_container_set_border_width( GTK_CONTAINER( header ), BORDER - 2 );
	gtk_widget_show( header );
	gtk_box_pack_start( GTK_BOX( GTK_DIALOG( dlg )->vbox ), header, FALSE, TRUE, 0 );

	sg = gtk_size_group_new( GTK_SIZE_GROUP_HORIZONTAL );

	vbox = create_tab();
	setup_update_interval_option( vbox, sg, base );
	setup_tracked_core_option( vbox, sg, base );
	setup_size_option( vbox, sg, plugin, base );
	create_check_box( vbox, sg, _("Use non-linear time-scale"), base->non_linear, change_time_scale, base );
	create_check_box( vbox, sg, _("Show frame"), base->has_frame, change_frame, base );
	create_check_box( vbox, sg, _("Show border"), base->has_border, change_border, base );
	create_check_box( vbox, sg, ngettext( "Show current usage bar", "Show current usage bars", base->nr_cores ), base->has_bars, change_bars, base );
	setup_command_option( vbox, sg, base );
	create_check_box( vbox, sg, _("Run in terminal"), base->in_terminal, change_in_terminal, base );
	create_check_box( vbox, sg, _("Use startup notification"), base->startup_notification, change_startup_notification, base );

	vbox2 = create_tab();
	setup_color_option( vbox2, sg, base, 1, _("Color 1:"), G_CALLBACK( change_color_1 ) );
	setup_color_option( vbox2, sg, base, 2, _("Color 2:"), G_CALLBACK( change_color_2 ) );
	setup_color_option( vbox2, sg, base, 3, _("Color 3:"), G_CALLBACK( change_color_3 ) );
	setup_color_option( vbox2, sg, base, 0, _("Background:"), G_CALLBACK( change_color_0 ) );
	select_active_colors( base );
	setup_mode_option( vbox2, sg, base );
	setup_color_mode_option( vbox2, sg, base );

	Notebook = gtk_notebook_new();
	gtk_container_set_border_width( GTK_CONTAINER( Notebook ), BORDER - 2 );
	label = gtk_label_new( _("Appearance") );
	gtk_notebook_append_page( GTK_NOTEBOOK( Notebook ), GTK_WIDGET( vbox2 ), GTK_WIDGET( label ) );
	label = gtk_label_new( _("Advanced") );
	gtk_notebook_append_page( GTK_NOTEBOOK( Notebook ), GTK_WIDGET( vbox ), GTK_WIDGET( label ) );
	gtk_widget_show( Notebook );

	gtk_box_pack_start( GTK_BOX( GTK_DIALOG( dlg )->vbox), GTK_WIDGET( Notebook ), TRUE, TRUE, 0 );

	gtk_widget_show( dlg );
}
Пример #5
0
/**************************************************************************
  Get the dialog's toplevel window.
**************************************************************************/
GtkWidget *gui_dialog_get_toplevel(struct gui_dialog *dlg)
{
  return gtk_widget_get_toplevel(dlg->vbox);
}
Пример #6
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));
}
Пример #7
0
/* Called when About is selected from right-click menu */
static void show_about_dialog(GtkMenuItem *menu_item, gpointer user_data) {
  /* This helps prevent multiple instances */
  if (!gtk_grab_get_current()) {
    const gchar* authors[] = {"Cristian Henzel <[email protected]>\n"
				"Gilberto \"Xyhthyx\" Miralla <[email protected]>\n"
				"Eugene Nikolsky <[email protected]>", NULL};
    const gchar* license =
      "This program is free software; you can redistribute it and/or modify\n"
      "it under the terms of the GNU General Public License as published by\n"
      "the Free Software Foundation; either version 3 of the License, or\n"
      "(at your option) any later version.\n"
      "\n"
      "This program is distributed in the hope that it will be useful,\n"
      "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
      "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
      "GNU General Public License for more details.\n"
      "\n"
      "You should have received a copy of the GNU General Public License\n"
      "along with this program.  If not, see <http://www.gnu.org/licenses/>.";

    /* Create the about dialog */
    GtkWidget* about_dialog = gtk_about_dialog_new();
    gtk_window_set_icon((GtkWindow*)about_dialog,
                        gtk_widget_render_icon(about_dialog, GTK_STOCK_ABOUT, GTK_ICON_SIZE_MENU, NULL));

    gtk_about_dialog_set_name((GtkAboutDialog*)about_dialog, "ClipIt");
    #ifdef HAVE_CONFIG_H
    gtk_about_dialog_set_version((GtkAboutDialog*)about_dialog, VERSION);
    #endif
    gtk_about_dialog_set_comments((GtkAboutDialog*)about_dialog,
                                _("Lightweight GTK+ clipboard manager."));

    gtk_about_dialog_set_website((GtkAboutDialog*)about_dialog,
                                 "http://clipit.rspwn.com/");

    gtk_about_dialog_set_copyright((GtkAboutDialog*)about_dialog, "Copyright (C) 2010-2012 Cristian Henzel");
    gtk_about_dialog_set_authors((GtkAboutDialog*)about_dialog, authors);
    gtk_about_dialog_set_translator_credits ((GtkAboutDialog*)about_dialog,
                                             "Guido Tabbernuk <[email protected]>\n"
                                             "Miloš Koutný <[email protected]>\n"
                                             "Kim Jensen <[email protected]>\n"
                                             "Eckhard M. Jäger <[email protected]>\n"
                                             "Michael Stempin <[email protected]>\n"
                                             "Benjamin 'sphax3d' Danon <[email protected]>\n"
                                             "Németh Tamás <[email protected]>\n"
                                             "Davide Truffa <[email protected]>\n"
                                             "Jiro Kawada <[email protected]>\n"
                                             "Øyvind Sæther <[email protected]>\n"
                                             "pankamyk <[email protected]>\n"
                                             "Tomasz Rusek <[email protected]>\n"
                                             "Phantom X <[email protected]>\n"
                                             "Ovidiu D. Niţan <[email protected]>\n"
                                             "Alexander Kazancev <[email protected]>\n"
                                             "Daniel Nylander <[email protected]>\n"
                                             "Hedef Türkçe <[email protected]>\n"
                                             "Lyman Li <[email protected]>\n"
                                             "Gilberto \"Xyhthyx\" Miralla <xyh[email protected]>");

    gtk_about_dialog_set_license((GtkAboutDialog*)about_dialog, license);
    gtk_about_dialog_set_logo_icon_name((GtkAboutDialog*)about_dialog, GTK_STOCK_PASTE);
    /* Run the about dialog */
    gtk_dialog_run((GtkDialog*)about_dialog);
    gtk_widget_destroy(about_dialog);
  } else {
    /* A window is already open, so we present it to the user */
    GtkWidget *toplevel = gtk_widget_get_toplevel(gtk_grab_get_current());
    gtk_window_present((GtkWindow*)toplevel);
  }
}
Пример #8
0
static void
close_callback (GtkAction *action,
                gpointer   data)
{
  gtk_widget_destroy (gtk_widget_get_toplevel (view));
}
Пример #9
0
void linphone_gtk_chat_close(GtkWidget *button){
	GtkWidget *w=gtk_widget_get_toplevel(button);
	gtk_widget_destroy(w);
}
Пример #10
0
static GtkWidget* getToplevel(GtkWidget* widget)
{
    GtkWidget* toplevel = gtk_widget_get_toplevel(widget);
    return gtk_widget_is_toplevel(toplevel) ? toplevel : 0;
}
Пример #11
0
/*
 * Sets the properties of the widget. This is used for both applying the
 * properties changed in the property editor, and also for loading.
 */
static void
gb_radio_button_set_properties (GtkWidget * widget, GbWidgetSetArgData * data)
{
  gboolean state, indicator;
  gchar *group_name;
  GSList *group = NULL, *current_group;
  GbFindGroupData find_group_data;

  if (gb_toolbar_is_toolbar_button (widget))
    {
      gb_toolbar_input_child_label (widget, data, Label);
      gb_toolbar_input_child_icon (widget, data, Icon);
    }
  else
    {
      gb_widget_input_child_label (widget, data, Label);
    }

  state = gb_widget_input_bool (data, State);
  if (data->apply)
    {
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), state);
      if (state)
	data->widget_data->flags |= GLADE_ACTIVE;
      else
	data->widget_data->flags &= ~GLADE_ACTIVE;
    }

  indicator = gb_widget_input_bool (data, Indicator);
  if (data->apply)
    gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (widget), indicator);

  /* Find any widgets in given group and set this widgets group.
     If group is NULL try to find radiobuttons with same parent and use
     their group. If these don't succeed, set group to NULL. */
  group_name = gb_widget_input_combo (data, Group);
  if (data->apply)
    {
      if (group_name && group_name[0] == '\0')
	group_name = NULL;
      current_group = gtk_radio_button_group (GTK_RADIO_BUTTON (widget));

      if (group_name == NULL)
	gtk_container_foreach (GTK_CONTAINER (widget->parent),
			       (GtkCallback) find_parents_group, &group);
      else
	{
	  find_group_data.group_name = group_name;
	  find_group_data.group = NULL;
	  find_group (gtk_widget_get_toplevel (widget), &find_group_data);
	  group = find_group_data.group;
	}

      g_free (gtk_object_get_data (GTK_OBJECT (widget), Group));
      gtk_object_set_data (GTK_OBJECT (widget), Group, g_strdup (group_name));

      /* This crashes if we set the group to NULL, so we have to reset the
         group ourself. We only set the group if it has changed. */
      if (group)
	{
	  if (group != current_group)
	    {
	      if (current_group->data == widget)
		current_group = current_group->next;
	      gtk_radio_button_set_group (GTK_RADIO_BUTTON (widget), group);
	      gb_radio_button_update_radio_group (current_group);
	      gb_radio_button_update_radio_group (gtk_radio_button_group (GTK_RADIO_BUTTON (widget)));
	    }
	}
      else
	{
	  if (g_slist_length (current_group) != 1)
	    {
	      current_group = gb_radio_button_reset_radio_group (widget);
	      gb_radio_button_update_radio_group (current_group);
	      gb_radio_button_update_radio_group (gtk_radio_button_group (GTK_RADIO_BUTTON (widget)));
	    }
	}
    }
}
Пример #12
0
static G_CONST_RETURN gchar*
gail_menu_item_get_keybinding (AtkAction *action,
                               gint      i)
{
  /*
   * This function returns a string of the form A;B;C where
   * A is the keybinding for the widget; B is the keybinding to traverse
   * from the menubar and C is the accelerator.
   * The items in the keybinding to traverse from the menubar are separated
   * by ":".
   */
  GailMenuItem  *gail_menu_item;
  gchar *keybinding = NULL;
  gchar *item_keybinding = NULL;
  gchar *full_keybinding = NULL;
  gchar *accelerator = NULL;

  gail_menu_item = GAIL_MENU_ITEM (action);
  if (i == 0)
    {
      GtkWidget *item;
      GtkWidget *temp_item;
      GtkWidget *child;
      GtkWidget *parent;

      item = GTK_ACCESSIBLE (action)->widget;
      if (item == NULL)
        /* State is defunct */
        return NULL;

      temp_item = item;
      while (TRUE)
        {
          GdkModifierType mnemonic_modifier = 0;
          guint key_val;
          gchar *key, *temp_keybinding;

          child = gtk_bin_get_child (GTK_BIN (temp_item));
          if (child == NULL)
            {
              /* Possibly a tear off menu item; it could also be a menu 
               * separator generated by gtk_item_factory_create_items()
               */
              return NULL;
            }
          parent = gtk_widget_get_parent (temp_item);
          if (!parent)
            {
              /*
               * parent can be NULL when activating a window from the panel
               */
              return NULL;
            }
          g_return_val_if_fail (GTK_IS_MENU_SHELL (parent), NULL);
          if (GTK_IS_MENU_BAR (parent))
            {
              GtkWidget *toplevel;

              toplevel = gtk_widget_get_toplevel (parent);
              if (toplevel && GTK_IS_WINDOW (toplevel))
                mnemonic_modifier = gtk_window_get_mnemonic_modifier (
                                       GTK_WINDOW (toplevel));
            }
          if (GTK_IS_LABEL (child))
            {
              key_val = gtk_label_get_mnemonic_keyval (GTK_LABEL (child));
              if (key_val != GDK_VoidSymbol)
                {
                  key = gtk_accelerator_name (key_val, mnemonic_modifier);
                  if (full_keybinding)
                    temp_keybinding = g_strconcat (key, ":", full_keybinding, NULL);
                  else 
                    temp_keybinding = g_strconcat (key, NULL);
                  if (temp_item == item)
                    {
                      item_keybinding = g_strdup (key); 
                    }
                  g_free (key);
                  g_free (full_keybinding);
                  full_keybinding = temp_keybinding;
                }
              else
                {
                  /* No keybinding */
                  g_free (full_keybinding);
                  full_keybinding = NULL;
                  break;
                }        
            }        
          if (GTK_IS_MENU_BAR (parent))
            /* We have reached the menu bar so we are finished */
            break;
          g_return_val_if_fail (GTK_IS_MENU (parent), NULL);
          temp_item = gtk_menu_get_attach_widget (GTK_MENU (parent));
          if (!GTK_IS_MENU_ITEM (temp_item))
            {
              /* 
               * Menu is attached to something other than a menu item;
               * probably an option menu
               */
              g_free (full_keybinding);
              full_keybinding = NULL;
              break;
            }
        }

      parent = gtk_widget_get_parent (item);
      if (GTK_IS_MENU (parent))
        {
          GtkAccelGroup *group; 
          GtkAccelKey *key;

          group = gtk_menu_get_accel_group (GTK_MENU (parent));

          if (group)
            {
              key = gtk_accel_group_find (group, find_accel, item);
            }
          else
            {
              /*
               * If the menu item is created using GtkAction and GtkUIManager
               * we get here.
               */
              key = NULL;
              child = GTK_BIN (item)->child;
              if (GTK_IS_ACCEL_LABEL (child))
                {
                  GtkAccelLabel *accel_label;

                  accel_label = GTK_ACCEL_LABEL (child);
                  if (accel_label->accel_closure)
                    {
                      key = gtk_accel_group_find (accel_label->accel_group,
                                                  find_accel_new,
                                                  accel_label->accel_closure);
                    }
               
                }
            }

          if (key)
            {           
              accelerator = gtk_accelerator_name (key->accel_key,
                                                  key->accel_mods);
            }
        }
    }
  /*
   * Concatenate the bindings
   */
  if (item_keybinding || full_keybinding || accelerator)
    {
      gchar *temp;
      if (item_keybinding)
        {
          keybinding = g_strconcat (item_keybinding, KEYBINDING_SEPARATOR, NULL);
          g_free (item_keybinding);
        }
      else
        keybinding = g_strconcat (KEYBINDING_SEPARATOR, NULL);

      if (full_keybinding)
        {
          temp = g_strconcat (keybinding, full_keybinding, 
                              KEYBINDING_SEPARATOR, NULL);
          g_free (full_keybinding);
        }
      else
        temp = g_strconcat (keybinding, KEYBINDING_SEPARATOR, NULL);

      g_free (keybinding);
      keybinding = temp;
      if (accelerator)
        {
          temp = g_strconcat (keybinding, accelerator, NULL);
          g_free (accelerator);
          g_free (keybinding);
          keybinding = temp;
      }
    }
  g_free (gail_menu_item->click_keybinding);
  gail_menu_item->click_keybinding = keybinding;
  return keybinding;
}
static gboolean on_motion_notify_desklet (GtkWidget *pWidget,
	GdkEventMotion* pMotion,
	CairoDesklet *pDesklet)
{
	/*if (pMotion->state & GDK_BUTTON1_MASK && cairo_dock_desklet_is_free (pDesklet))
	{
		cd_debug ("root : %d;%d", (int) pMotion->x_root, (int) pMotion->y_root);
	}
	else*/  // le 'press-button' est local au sous-widget clique, alors que le 'motion-notify' est global a la fenetre; c'est donc par lui qu'on peut avoir a coup sur les coordonnees du curseur (juste avant le clic).
	{
		pDesklet->container.iMouseX = pMotion->x;
		pDesklet->container.iMouseY = pMotion->y;
		gboolean bStartAnimation = FALSE;
		gldi_object_notify (pDesklet, NOTIFICATION_MOUSE_MOVED, pDesklet, &bStartAnimation);
		if (bStartAnimation)
			cairo_dock_launch_animation (CAIRO_CONTAINER (pDesklet));
	}
	
	if (pDesklet->rotating && cairo_dock_desklet_is_free (pDesklet))
	{
		double alpha = atan2 (pDesklet->container.iHeight, - pDesklet->container.iWidth);
		pDesklet->fRotation = alpha - atan2 (.5*pDesklet->container.iHeight - pMotion->y, pMotion->x - .5*pDesklet->container.iWidth);
		while (pDesklet->fRotation > G_PI)
			pDesklet->fRotation -= 2 * G_PI;
		while (pDesklet->fRotation <= - G_PI)
			pDesklet->fRotation += 2 * G_PI;
		gtk_widget_queue_draw(pDesklet->container.pWidget);
	}
	else if (pDesklet->rotatingY && cairo_dock_desklet_is_free (pDesklet))
	{
		pDesklet->fDepthRotationY = G_PI * (pMotion->x - .5*pDesklet->container.iWidth) / pDesklet->container.iWidth;
		gtk_widget_queue_draw(pDesklet->container.pWidget);
	}
	else if (pDesklet->rotatingX && cairo_dock_desklet_is_free (pDesklet))
	{
		pDesklet->fDepthRotationX = G_PI * (pMotion->y - .5*pDesklet->container.iHeight) / pDesklet->container.iHeight;
		gtk_widget_queue_draw(pDesklet->container.pWidget);
	}
	else if (pMotion->state & GDK_BUTTON1_MASK && cairo_dock_desklet_is_free (pDesklet) && ! pDesklet->moving)
	{
		gtk_window_begin_move_drag (GTK_WINDOW (gtk_widget_get_toplevel (pWidget)),
			1/*pButton->button*/,
			pMotion->x_root/*pButton->x_root*/,
			pMotion->y_root/*pButton->y_root*/,
			pDesklet->time/*pButton->time*/);
		pDesklet->moving = TRUE;
	}
	else
	{
		gboolean bStartAnimation = FALSE;
		Icon *pIcon = gldi_desklet_find_clicked_icon (pDesklet);
		if (pIcon != NULL)
		{
			if (! pIcon->bPointed)
			{
				Icon *pPointedIcon = cairo_dock_get_pointed_icon (pDesklet->icons);
				if (pPointedIcon != NULL)
					pPointedIcon->bPointed = FALSE;
				pIcon->bPointed = TRUE;
				
				//g_print ("on survole %s\n", pIcon->cName);
				gldi_object_notify (pDesklet, NOTIFICATION_ENTER_ICON, pIcon, pDesklet, &bStartAnimation);
			}
		}
		else
		{
			Icon *pPointedIcon = cairo_dock_get_pointed_icon (pDesklet->icons);
			if (pPointedIcon != NULL)
			{
				pPointedIcon->bPointed = FALSE;
				
				//g_print ("kedal\n");
				//gldi_object_notify (pDesklet, NOTIFICATION_ENTER_ICON, pPointedIcon, pDesklet, &bStartAnimation);
			}
		}
		if (bStartAnimation)
		{
			cairo_dock_launch_animation (CAIRO_CONTAINER (pDesklet));
		}
	}
	
	gdk_device_get_state (pMotion->device, pMotion->window, NULL, NULL);  // pour recevoir d'autres MotionNotify.
	return FALSE;
}
Пример #14
0
void
create_orientmap_dialog (GtkWidget *parent)
{
  GtkWidget *tmpw, *tmpw2;
  GtkWidget *table1, *table2;
  GtkWidget *frame;
  GtkWidget *ebox, *hbox, *vbox;

  init_vectors ();

  if (orient_map_window)
    {
      update_vector_prev ();
      update_orient_map_preview_prev ();
      gtk_widget_show (orient_map_window);
      return;
    }

  orient_map_window =
    gimp_dialog_new (_("Orientation Map Editor"), PLUG_IN_BINARY,
                     gtk_widget_get_toplevel (parent), 0,
                     gimp_standard_help_func, PLUG_IN_PROC,

                     GTK_STOCK_APPLY,  GTK_RESPONSE_APPLY,
                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                     GTK_STOCK_OK,     GTK_RESPONSE_OK,

                     NULL);

  gtk_dialog_set_alternative_button_order (GTK_DIALOG (orient_map_window),
                                           GTK_RESPONSE_OK,
                                           GTK_RESPONSE_APPLY,
                                           GTK_RESPONSE_CANCEL,
                                           -1);

  g_signal_connect (orient_map_window, "response",
                    G_CALLBACK (orient_map_response),
                    orient_map_window);
  g_signal_connect (orient_map_window, "destroy",
                    G_CALLBACK (gtk_widget_destroyed),
                    &orient_map_window);

  table1 = gtk_table_new (2, 5, FALSE);
  gtk_container_set_border_width (GTK_CONTAINER (table1), 6);
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (orient_map_window))),
                      table1, TRUE, TRUE, 0);
  gtk_widget_show (table1);

  frame = gtk_frame_new (_("Vectors"));
  gtk_container_set_border_width (GTK_CONTAINER (frame), 2);
  gtk_table_attach (GTK_TABLE (table1), frame, 0, 1, 0, 1,
                    GTK_EXPAND, GTK_EXPAND, 0, 0);
  gtk_widget_show (frame);

  hbox = gtk_hbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER (frame), hbox);
  gtk_widget_show (hbox);

  ebox = gtk_event_box_new ();
  gimp_help_set_help_data (ebox,
                           _("The vector-field. "
                             "Left-click to move selected vector, "
                             "Right-click to point it towards mouse, "
                             "Middle-click to add a new vector."), NULL);
  gtk_box_pack_start (GTK_BOX (hbox), ebox, FALSE, FALSE, 0);

  tmpw = vector_preview = gimp_preview_area_new ();
  gtk_widget_set_size_request (tmpw, OMWIDTH, OMHEIGHT);
  gtk_container_add (GTK_CONTAINER (ebox), tmpw);
  gtk_widget_show (tmpw);
  gtk_widget_add_events (ebox, GDK_BUTTON_PRESS_MASK);
  g_signal_connect (ebox, "button-press-event",
                   G_CALLBACK (map_click_callback), NULL);
  gtk_widget_show (ebox);

  vector_preview_brightness_adjust =
    gtk_adjustment_new (50.0, 0.0, 100.0, 1.0, 1.0, 1.0);
  tmpw = gtk_vscale_new (GTK_ADJUSTMENT (vector_preview_brightness_adjust));
  gtk_scale_set_draw_value (GTK_SCALE (tmpw), FALSE);
  gtk_box_pack_start (GTK_BOX (hbox), tmpw, FALSE, FALSE,0);
  gtk_widget_show (tmpw);
  g_signal_connect (vector_preview_brightness_adjust, "value-changed",
                    G_CALLBACK (update_vector_prev), NULL);
  gimp_help_set_help_data (tmpw, _("Adjust the preview's brightness"), NULL);

  tmpw2 = tmpw = gtk_frame_new (_("Preview"));
  gtk_container_set_border_width (GTK_CONTAINER (tmpw), 2);
  gtk_table_attach (GTK_TABLE (table1), tmpw, 1,2, 0,1,
                    GTK_EXPAND, GTK_EXPAND, 0, 0);
  gtk_widget_show (tmpw);

  tmpw = orient_map_preview_prev = gimp_preview_area_new ();
  gtk_widget_set_size_request (tmpw, OMWIDTH, OMHEIGHT);;
  gtk_container_add (GTK_CONTAINER (tmpw2), tmpw);
  gtk_widget_show (tmpw);

  hbox = tmpw = gtk_hbox_new (TRUE,0);
  gtk_container_set_border_width (GTK_CONTAINER (tmpw), 2);
  gtk_table_attach_defaults (GTK_TABLE (table1), tmpw, 0,1, 1,2);
  gtk_widget_show (tmpw);

  prev_button = tmpw = gtk_button_new_with_mnemonic ("_<<");
  gtk_box_pack_start (GTK_BOX (hbox), tmpw, FALSE, TRUE, 0);
  gtk_widget_show (tmpw);
  g_signal_connect (tmpw, "clicked", G_CALLBACK (prev_click_callback), NULL);
  gimp_help_set_help_data (tmpw, _("Select previous vector"), NULL);

  next_button = tmpw = gtk_button_new_with_mnemonic ("_>>");
  gtk_box_pack_start (GTK_BOX (hbox),tmpw,FALSE,TRUE,0);
  gtk_widget_show (tmpw);
  g_signal_connect (tmpw, "clicked", G_CALLBACK (next_click_callback), NULL);
  gimp_help_set_help_data (tmpw, _("Select next vector"), NULL);

  add_button = tmpw = gtk_button_new_with_mnemonic ( _("A_dd"));
  gtk_box_pack_start (GTK_BOX (hbox), tmpw, FALSE, TRUE, 0);
  gtk_widget_show (tmpw);
  g_signal_connect (tmpw, "clicked", G_CALLBACK (add_click_callback), NULL);
  gimp_help_set_help_data (tmpw, _("Add new vector"), NULL);

  kill_button = tmpw = gtk_button_new_with_mnemonic ( _("_Kill"));
  gtk_box_pack_start (GTK_BOX (hbox), tmpw, FALSE, TRUE, 0);
  gtk_widget_show (tmpw);
  g_signal_connect (tmpw, "clicked", G_CALLBACK (delete_click_callback), NULL);
  gimp_help_set_help_data (tmpw, _("Delete selected vector"), NULL);

  hbox = gtk_hbox_new (FALSE, 0);
  gtk_box_set_spacing (GTK_BOX (hbox), 12);
  gtk_table_attach_defaults (GTK_TABLE (table1), hbox, 0, 2, 2, 3);
  gtk_widget_show (hbox);

  vbox = gtk_vbox_new (FALSE, 0);
  gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
  gtk_widget_show (vbox);

  frame = gimp_int_radio_group_new (TRUE, _("Type"),
                                    G_CALLBACK (vector_type_click_callback),
                                    &vector_type, 0,

                                    _("_Normal"),  0, &vector_types[0],
                                    _("Vorte_x"),  1, &vector_types[1],
                                    _("Vortex_2"), 2, &vector_types[2],
                                    _("Vortex_3"), 3, &vector_types[3],

                                    NULL);
  gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
  gtk_widget_show (frame);

  orient_voronoi = tmpw = gtk_check_button_new_with_mnemonic ( _("_Voronoi"));
  gtk_box_pack_start (GTK_BOX (vbox), tmpw, TRUE, TRUE, 0);
  gtk_widget_show (tmpw);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tmpw),
                                pcvals.orient_voronoi);
  g_signal_connect (tmpw, "clicked",
                    G_CALLBACK (angle_offset_adjust_move_callback), NULL);
  gimp_help_set_help_data (tmpw,
                          _("Voronoi-mode makes only the vector closest to the given point have any influence"),
                          NULL);

  table2 = gtk_table_new (4, 3, FALSE);
  gtk_table_set_col_spacings (GTK_TABLE (table2), 4);
  gtk_box_pack_start (GTK_BOX (hbox), table2, TRUE, TRUE, 0);
  gtk_widget_show (table2);

  angle_adjust =
    gimp_scale_entry_new (GTK_TABLE (table2), 0, 0,
                          _("A_ngle:"),
                          150, 6, 0.0,
                          0.0, 360.0, 1.0, 10.0, 1,
                          TRUE, 0, 0,
                          _("Change the angle of the selected vector"),
                          NULL);
  g_signal_connect (angle_adjust, "value-changed",
                    G_CALLBACK (angle_adjust_move_callback), NULL);

  angle_offset_adjust =
    gimp_scale_entry_new (GTK_TABLE (table2), 0, 1,
                          _("Ang_le offset:"),
                          150, 6, 0.0,
                          0.0, 360.0, 1.0, 10.0, 1,
                          TRUE, 0, 0,
                          _("Offset all vectors with a given angle"),
                          NULL);
  g_signal_connect (angle_offset_adjust, "value-changed",
                    G_CALLBACK (angle_offset_adjust_move_callback), NULL);

  strength_adjust =
    gimp_scale_entry_new (GTK_TABLE (table2), 0, 2,
                          _("_Strength:"),
                          150, 6, 1.0,
                          0.1, 5.0, 0.1, 1.0, 1,
                          TRUE, 0, 0,
                          _("Change the strength of the selected vector"),
                          NULL);
  g_signal_connect (strength_adjust, "value-changed",
                    G_CALLBACK (strength_adjust_move_callback), NULL);

  orient_map_str_exp_adjust =
    gimp_scale_entry_new (GTK_TABLE (table2), 0, 3,
                          _("S_trength exp.:"),
                          150, 6, 1.0,
                          0.1, 10.9, 0.1, 1.0, 1,
                          TRUE, 0, 0,
                          _("Change the exponent of the strength"),
                          NULL);
  g_signal_connect (orient_map_str_exp_adjust, "value-changed",
                    G_CALLBACK (strength_exponent_adjust_move_callback), NULL);

  gtk_widget_show (orient_map_window);

  update_vector_prev ();
  update_orient_map_preview_prev ();
}
void lightdash_configure (XfcePanelPlugin *plugin,
							LightdashPlugin *lightdash)
{
	GtkWidget *dialog;
	GtkWidget *hbox;
	GtkWidget *label;
	GtkWidget *entry;
	GtkWidget *opacity_slider;
	GtkWidget *show_desktop_button;
	GtkWidget *toplevel;
	GtkWindow *window;
	
	window = NULL;
	
	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (plugin));
	
	if (gtk_widget_is_toplevel (toplevel))
	{
		window = GTK_WINDOW (toplevel);
	}
	
	xfce_panel_plugin_block_menu (plugin);
	
	dialog = xfce_titled_dialog_new_with_buttons (_("lightdash"),
						window,
						GTK_DIALOG_DESTROY_WITH_PARENT 
							#if GTK_CHECK_VERSION (3, 0, 0)
							#else
							| GTK_DIALOG_NO_SEPARATOR
							#endif
						,
						GTK_STOCK_HELP, GTK_RESPONSE_HELP,
						GTK_STOCK_CLOSE, GTK_RESPONSE_OK,
						NULL);
	
	#if GTK_CHECK_VERSION (3, 0, 0)
	hbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	#else
	hbox = gtk_hbox_new (FALSE, 0);
	#endif
	
	label = gtk_label_new_with_mnemonic (_("_Title:"));
	
	entry = gtk_entry_new ();
	gtk_entry_set_text (GTK_ENTRY (entry), gtk_label_get_text (GTK_LABEL (lightdash->button_label)));
	
	g_signal_connect (G_OBJECT (entry), "changed",
      G_CALLBACK (lightdash_preferences_entry_changed), lightdash);
	
	gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 
		hbox, TRUE, TRUE, 6);
	
	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 6);
	
	gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 6);
	gtk_widget_show_all (hbox);
	
	
	
	#if GTK_CHECK_VERSION (3, 0, 0)
	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	#else
	hbox = gtk_hbox_new (FALSE, 0);
	#endif
	
	opacity_slider = gtk_hscale_new_with_range (0.0, 100.0, 1.0);
	gtk_scale_set_value_pos (GTK_SCALE (opacity_slider), GTK_POS_RIGHT);
	gtk_widget_set_size_request (GTK_WIDGET (opacity_slider), 200, -1);
	gtk_range_set_value (GTK_RANGE (opacity_slider), lightdash->opacity);
	
	gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 
		hbox, TRUE, TRUE, 6);
	
	label = gtk_label_new_with_mnemonic (_("Background opacit_y:"));
	
	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 6);
	
	gtk_box_pack_start (GTK_BOX (hbox), opacity_slider, TRUE, TRUE, 6);
	
	g_signal_connect (G_OBJECT (opacity_slider), "value-changed",
			G_CALLBACK (lightdash_opacity_slider_changed), lightdash);
	
	gtk_widget_show_all (hbox);
	
	show_desktop_button = gtk_check_button_new_with_label (_("Show desktop behind dashboard"));
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (show_desktop_button), lightdash->show_desktop);
	gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 
		show_desktop_button, TRUE, TRUE, 6);
	g_signal_connect (G_OBJECT (show_desktop_button), "toggled",
		G_CALLBACK (lightdash_show_desktop_button_toggled), lightdash);
	
	 				
	g_object_set_data (G_OBJECT (plugin), "dialog", dialog);
	
	g_signal_connect (G_OBJECT (dialog), "response",
			G_CALLBACK (lightdash_configure_response), lightdash);
						
	gtk_widget_show_all (dialog);
}
Пример #16
0
static void
do_save_calendar_rdf (FormatHandler *handler,
                      ESourceSelector *selector,
                      ECalClientSourceType type,
                      gchar *dest_uri)
{

	/*
	 * According to some documentation about CSV, newlines 'are' allowed
	 * in CSV-files. But you 'do' have to put the value between quotes.
	 * The helper 'string_needsquotes' will check for that
	 *
	 * http://www.creativyst.com/Doc/Articles/CSV/CSV01.htm
	 * http://www.creativyst.com/cgi-bin/Prod/15/eg/csv2xml.pl
	 */

	ESource *primary_source;
	EClient *source_client;
	GError *error = NULL;
	GSList *objects = NULL;
	gchar *temp = NULL;
	GOutputStream *stream;

	if (!dest_uri)
		return;

	/* open source client */
	primary_source = e_source_selector_ref_primary_selection (selector);
	source_client = e_cal_client_connect_sync (
		primary_source, type, NULL, &error);
	g_object_unref (primary_source);

	/* Sanity check. */
	g_return_if_fail (
		((source_client != NULL) && (error == NULL)) ||
		((source_client == NULL) && (error != NULL)));

	if (source_client == NULL) {
		display_error_message (
			gtk_widget_get_toplevel (GTK_WIDGET (selector)),
			error->message);
		g_error_free (error);
		return;
	}

	stream = open_for_writing (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (selector))), dest_uri, &error);

	if (stream && e_cal_client_get_object_list_as_comps_sync (E_CAL_CLIENT (source_client), "#t", &objects, NULL, NULL)) {
		GSList *iter;

		xmlBufferPtr buffer = xmlBufferCreate ();
		xmlDocPtr doc = xmlNewDoc ((xmlChar *) "1.0");
		xmlNodePtr fnode;

		doc->children = xmlNewDocNode (doc, NULL, (const guchar *)"rdf:RDF", NULL);
		xmlSetProp (doc->children, (const guchar *)"xmlns:rdf", (const guchar *)"http://www.w3.org/1999/02/22-rdf-syntax-ns#");
		xmlSetProp (doc->children, (const guchar *)"xmlns", (const guchar *)"http://www.w3.org/2002/12/cal/ical#");

		fnode = xmlNewChild (doc->children, NULL, (const guchar *)"Vcalendar", NULL);

		/* Should Evolution publicise these? */
		xmlSetProp (fnode, (const guchar *)"xmlns:x-wr", (const guchar *)"http://www.w3.org/2002/12/cal/prod/Apple_Comp_628d9d8459c556fa#");
		xmlSetProp (fnode, (const guchar *)"xmlns:x-lic", (const guchar *)"http://www.w3.org/2002/12/cal/prod/Apple_Comp_628d9d8459c556fa#");

		/* Not sure if it's correct like this */
		xmlNewChild (fnode, NULL, (const guchar *)"prodid", (const guchar *)"-//" PACKAGE_STRING "//iCal 1.0//EN");

		/* Assuming GREGORIAN is the only supported calendar scale */
		xmlNewChild (fnode, NULL, (const guchar *)"calscale", (const guchar *)"GREGORIAN");

		temp = calendar_config_get_timezone ();
		xmlNewChild (fnode, NULL, (const guchar *)"x-wr:timezone", (guchar *) temp);
		g_free (temp);

		xmlNewChild (fnode, NULL, (const guchar *)"method", (const guchar *)"PUBLISH");

		xmlNewChild (fnode, NULL, (const guchar *)"x-wr:relcalid", (guchar *) e_source_get_uid (primary_source));

		xmlNewChild (fnode, NULL, (const guchar *)"x-wr:calname", (guchar *) e_source_get_display_name (primary_source));

		/* Version of this RDF-format */
		xmlNewChild (fnode, NULL, (const guchar *)"version", (const guchar *)"2.0");

		for (iter = objects; iter; iter = iter->next) {
			ECalComponent *comp = iter->data;
			const gchar *temp_constchar;
			gchar *tmp_str = NULL;
			GSList *temp_list;
			ECalComponentDateTime temp_dt;
			struct icaltimetype *temp_time;
			gint *temp_int;
			ECalComponentText temp_comptext;
			xmlNodePtr c_node = xmlNewChild (fnode, NULL, (const guchar *)"component", NULL);
			xmlNodePtr node = xmlNewChild (c_node, NULL, (const guchar *)"Vevent", NULL);

			/* Getting the stuff */
			e_cal_component_get_uid (comp, &temp_constchar);
			tmp_str = g_strdup_printf ("#%s", temp_constchar);
			xmlSetProp (node, (const guchar *)"about", (guchar *) tmp_str);
			g_free (tmp_str);
			add_string_to_rdf (node, "uid",temp_constchar);

			e_cal_component_get_summary (comp, &temp_comptext);
			add_string_to_rdf (node, "summary", temp_comptext.value);

			e_cal_component_get_description_list (comp, &temp_list);
			add_list_to_rdf (node, "description", temp_list, ECALCOMPONENTTEXT);
			if (temp_list)
				e_cal_component_free_text_list (temp_list);

			e_cal_component_get_categories_list (comp, &temp_list);
			add_list_to_rdf (node, "categories", temp_list, CONSTCHAR);
			if (temp_list)
				e_cal_component_free_categories_list (temp_list);

			e_cal_component_get_comment_list (comp, &temp_list);
			add_list_to_rdf (node, "comment", temp_list, ECALCOMPONENTTEXT);

			if (temp_list)
				e_cal_component_free_text_list (temp_list);

			e_cal_component_get_completed (comp, &temp_time);
			add_time_to_rdf (node, "completed", temp_time);
			if (temp_time)
				e_cal_component_free_icaltimetype (temp_time);

			e_cal_component_get_created (comp, &temp_time);
			add_time_to_rdf (node, "created", temp_time);
			if (temp_time)
				e_cal_component_free_icaltimetype (temp_time);

			e_cal_component_get_contact_list (comp, &temp_list);
			add_list_to_rdf (node, "contact", temp_list, ECALCOMPONENTTEXT);
			if (temp_list)
				e_cal_component_free_text_list (temp_list);

			e_cal_component_get_dtstart (comp, &temp_dt);
			add_time_to_rdf (node, "dtstart", temp_dt.value ? temp_dt.value : NULL);
			e_cal_component_free_datetime (&temp_dt);

			e_cal_component_get_dtend (comp, &temp_dt);
			add_time_to_rdf (node, "dtend", temp_dt.value ? temp_dt.value : NULL);
			e_cal_component_free_datetime (&temp_dt);

			e_cal_component_get_due (comp, &temp_dt);
			add_time_to_rdf (node, "due", temp_dt.value ? temp_dt.value : NULL);
			e_cal_component_free_datetime (&temp_dt);

			e_cal_component_get_percent (comp, &temp_int);
			add_nummeric_to_rdf (node, "percentComplete", temp_int);

			e_cal_component_get_priority (comp, &temp_int);
			add_nummeric_to_rdf (node, "priority", temp_int);

			e_cal_component_get_url (comp, &temp_constchar);
			add_string_to_rdf (node, "URL", temp_constchar);

			if (e_cal_component_has_attendees (comp)) {
				e_cal_component_get_attendee_list (comp, &temp_list);
				add_list_to_rdf (node, "attendee", temp_list, ECALCOMPONENTATTENDEE);
				if (temp_list)
					e_cal_component_free_attendee_list (temp_list);
			}

			e_cal_component_get_location (comp, &temp_constchar);
			add_string_to_rdf (node, "location", temp_constchar);

			e_cal_component_get_last_modified (comp, &temp_time);
			add_time_to_rdf (node, "lastModified",temp_time);

			/* Important note!
			 * The documentation is not requiring this!
			 *
			 * if (temp_time) e_cal_component_free_icaltimetype (temp_time);
			 *
			 * Please uncomment and fix documentation if untrue
			 * http://www.gnome.org/projects/evolution/developer-doc/libecal/ECalComponent.html
			 *	#e-cal-component-get-last-modified
			 */
		}

		/* I used a buffer rather than xmlDocDump: I want gio support */
		xmlNodeDump (buffer, doc, doc->children, 2, 1);

		g_output_stream_write_all (stream, xmlBufferContent (buffer), xmlBufferLength (buffer), NULL, NULL, &error);
		g_output_stream_close (stream, NULL, NULL);

		e_cal_client_free_ecalcomp_slist (objects);

		xmlBufferFree (buffer);
		xmlFreeDoc (doc);
	}

	if (stream)
		g_object_unref (stream);

	g_object_unref (source_client);

	if (error != NULL) {
		display_error_message (
			gtk_widget_get_toplevel (GTK_WIDGET (selector)),
			error->message);
		g_error_free (error);
	}
}
Пример #17
0
static void
gimp_action_view_conflict_confirm (GimpActionView  *view,
                                   GtkAction       *action,
                                   guint            accel_key,
                                   GdkModifierType  accel_mask,
                                   const gchar     *accel_path)
{
  GimpActionGroup *group;
  gchar           *label;
  gchar           *accel_string;
  ConfirmData     *confirm_data;
  GtkWidget       *dialog;
  GimpMessageBox  *box;

  g_object_get (action, "action-group", &group, NULL);

  label = gimp_strip_uline (gtk_action_get_label (action));

  accel_string = gtk_accelerator_get_label (accel_key, accel_mask);

  confirm_data = g_slice_new (ConfirmData);

  confirm_data->manager    = view->manager;
  confirm_data->accel_path = g_strdup (accel_path);
  confirm_data->accel_key  = accel_key;
  confirm_data->accel_mask = accel_mask;

  dialog =
    gimp_message_dialog_new (_("Conflicting Shortcuts"),
                             GIMP_STOCK_WARNING,
                             gtk_widget_get_toplevel (GTK_WIDGET (view)), 0,
                             gimp_standard_help_func, NULL,

                             GTK_STOCK_CANCEL,         GTK_RESPONSE_CANCEL,
                             _("_Reassign shortcut"),  GTK_RESPONSE_OK,

                             NULL);

  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
                                           GTK_RESPONSE_OK,
                                           GTK_RESPONSE_CANCEL,
                                           -1);
  g_signal_connect (dialog, "response",
                    G_CALLBACK (gimp_action_view_conflict_response),
                    confirm_data);

  box = GIMP_MESSAGE_DIALOG (dialog)->box;

  gimp_message_box_set_primary_text (box,
                                     _("Shortcut \"%s\" is already taken "
                                       "by \"%s\" from the \"%s\" group."),
                                     accel_string, label, group->label);
  gimp_message_box_set_text (box,
                             _("Reassigning the shortcut will cause it "
                               "to be removed from \"%s\"."),
                             label);

  g_free (label);
  g_free (accel_string);

  g_object_unref (group);

  gtk_widget_show (dialog);
}
Пример #18
0
static void
e_webdav_discover_content_refresh_done_cb (GObject *source_object,
					   GAsyncResult *result,
					   gpointer user_data)
{
	RefreshData *rd = user_data;
	ESource *source;
	gchar *certificate_pem = NULL;
	GTlsCertificateFlags certificate_errors = 0;
	GSList *discovered_sources = NULL;
	GSList *calendar_user_addresses = NULL;
	GError *local_error = NULL;

	g_return_if_fail (E_IS_SOURCE (source_object));
	g_return_if_fail (rd != NULL);

	source = E_SOURCE (source_object);

	if (!e_webdav_discover_sources_finish (source, result,
		&certificate_pem, &certificate_errors, &discovered_sources,
		&calendar_user_addresses, &local_error)) {
		if (!g_cancellable_is_cancelled (rd->cancellable) && certificate_pem &&
		    g_error_matches (local_error, SOUP_HTTP_ERROR, SOUP_STATUS_SSL_FAILED)) {
			GtkWindow *parent;
			GtkWidget *widget;

			widget = gtk_widget_get_toplevel (rd->content);
			parent = widget ? GTK_WINDOW (widget) : NULL;

			e_trust_prompt_run_for_source (parent, source, certificate_pem, certificate_errors,
				NULL, FALSE, rd->cancellable, e_webdav_discover_content_trust_prompt_done_cb, rd);
			rd = NULL;
		} else if (g_cancellable_is_cancelled (rd->cancellable) ||
		    (!g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED) &&
		    !g_error_matches (local_error, SOUP_HTTP_ERROR, SOUP_STATUS_UNAUTHORIZED) &&
		    !g_error_matches (local_error, SOUP_HTTP_ERROR, SOUP_STATUS_FORBIDDEN))) {
			g_simple_async_result_take_error (rd->simple, local_error);
			local_error = NULL;
			g_simple_async_result_complete (rd->simple);
		} else {
			EWebDAVDiscoverContentData *data;

			data = g_object_get_data (G_OBJECT (rd->content), WEBDAV_DISCOVER_CONTENT_DATA_KEY);
			g_return_if_fail (data != NULL);

			e_credentials_prompter_prompt (data->credentials_prompter, source,
				local_error ? local_error->message : NULL,
				rd->credentials ? E_CREDENTIALS_PROMPTER_PROMPT_FLAG_NONE:
				E_CREDENTIALS_PROMPTER_PROMPT_FLAG_ALLOW_STORED_CREDENTIALS,
				e_webdav_discover_content_credentials_prompt_done_cb, rd);
			rd = NULL;
		}
	} else {
		EWebDAVDiscoverContentData *data;

		data = g_object_get_data (G_OBJECT (rd->content), WEBDAV_DISCOVER_CONTENT_DATA_KEY);
		g_warn_if_fail (data != NULL);

		if (data) {
			e_webdav_discover_content_fill_discovered_sources (data->sources_tree_view,
				data->supports_filter, discovered_sources);
			e_webdav_discover_content_fill_calendar_emails (data->email_addresses_combo,
				calendar_user_addresses);
		}

		g_simple_async_result_set_op_res_gboolean (rd->simple, TRUE);
		g_simple_async_result_complete (rd->simple);
	}

	g_free (certificate_pem);
	e_webdav_discover_free_discovered_sources (discovered_sources);
	g_slist_free_full (calendar_user_addresses, g_free);
	refresh_data_free (rd);
	g_clear_error (&local_error);
}
Пример #19
0
static GnmSolverResult *
run_solver (SolverState *state, GnmSolverParameters *param)
{
	GError *err = NULL;
	gboolean ok;
	GnmSheetRange sr;
	GOUndo *undo = NULL;
	GnmSolver *sol = NULL;
	GnmValue const *vinput;
	GtkWindow *top = GTK_WINDOW (gtk_widget_get_toplevel (state->dialog));
	GnmSolverResult *res = NULL;

	state->ref_count++;

	sol = gnm_solver_factory_functional (param->options.algorithm,
					     state->wbcg)
		? gnm_solver_factory_create (param->options.algorithm, param)
		: NULL;
	if (!sol) {
		go_gtk_notice_dialog (top, GTK_MESSAGE_ERROR,
				      _("The chosen solver is not functional."));
		goto fail;
	}

	gtk_notebook_set_current_page (GTK_NOTEBOOK (state->notebook), -1);

	state->run.solver = sol;

	vinput = gnm_solver_param_get_input (param);
	gnm_sheet_range_from_value (&sr, vinput);
	if (!sr.sheet) sr.sheet = param->sheet;
	undo = clipboard_copy_range_undo (sr.sheet, &sr.range);

	g_signal_connect_swapped (G_OBJECT (sol),
				  "notify::status",
				  G_CALLBACK (cb_notify_status),
				  state);
	g_signal_connect_swapped (G_OBJECT (sol),
				  "notify::reason",
				  G_CALLBACK (cb_notify_status),
				  state);
	cb_notify_status (state);

	g_signal_connect_swapped (G_OBJECT (sol),
				  "notify::result",
				  G_CALLBACK (cb_notify_result),
				  state);
	cb_notify_result (state);

	state->run.timer_source = g_timeout_add_seconds
		(1, (GSourceFunc)cb_timer_tick, state);
	cb_timer_tick (state);

	/* ---------------------------------------- */

	ok = gnm_solver_start (sol,
			       GNM_WBC (state->wbcg),
			       &err);
	if (ok) {
		state->run.in_main++;
		go_cmd_context_set_sensitive (GO_CMD_CONTEXT (state->wbcg), FALSE);
		gtk_main ();
		go_cmd_context_set_sensitive (GO_CMD_CONTEXT (state->wbcg), TRUE);
		state->run.in_main--;
		ok = gnm_solver_has_solution (sol);
	} else if (err) {
		gnm_solver_set_reason (sol, err->message);
	}
	g_clear_error (&err);

	remove_objective_value_source (state);
	remove_timer_source (state);

	/* ---------------------------------------- */

	if (ok) {
		GOUndo *redo;

		gnm_solver_store_result (sol);
		redo = clipboard_copy_range_undo (sr.sheet, &sr.range);

		if (param->options.program_report ||
		    param->options.sensitivity_report) {
			Workbook *wb = param->sheet->workbook;
			GOUndo *undo_report, *redo_report;

			undo_report = go_undo_binary_new
				(wb,
				 workbook_sheet_state_new (wb),
				 (GOUndoBinaryFunc)workbook_sheet_state_restore,
				 NULL,
				 (GFreeFunc)workbook_sheet_state_free);
			undo = go_undo_combine (undo, undo_report);

			create_report (sol, state);

			redo_report = go_undo_binary_new
				(wb,
				 workbook_sheet_state_new (wb),
				 (GOUndoBinaryFunc)workbook_sheet_state_restore,
				 NULL,
				 (GFreeFunc)workbook_sheet_state_free);
			redo = go_undo_combine (redo, redo_report);
		}

		cmd_generic (GNM_WBC (state->wbcg),
			     _("Running solver"),
			     undo, redo);
		res = g_object_ref (sol->result);
		undo = redo = NULL;
	}

fail:
	if (undo)
		g_object_unref (undo);

	if (state->run.solver) {
		g_object_unref (state->run.solver);
		state->run.solver = NULL;
	}

	unref_state (state);

	return res;
}
Пример #20
0
/* Creates a "goto date" dialog and runs it */
void
goto_dialog (GnomeCalendar *gcal)
{
	time_t start_time;
	struct icaltimetype tt;
	int b;
	char *gladefile;

	if (dlg) {
		return;
	}

	dlg = g_new0 (GoToDialog, 1);

	/* Load the content widgets */
	gladefile = g_build_filename (EVOLUTION_GLADEDIR,
				      "goto-dialog.glade",
				      NULL);
	dlg->xml = glade_xml_new (gladefile, NULL, NULL);
	g_free (gladefile);
	if (!dlg->xml) {
		g_message ("goto_dialog(): Could not load the Glade XML file!");
		g_free (dlg);
		return;
	}

	if (!get_widgets (dlg)) {
		g_message ("goto_dialog(): Could not find all widgets in the XML file!");
		g_free (dlg);
		return;
	}
	dlg->gcal = gcal;

	gnome_calendar_get_selected_time_range (dlg->gcal, &start_time, NULL);
	tt = icaltime_from_timet_with_zone (start_time, FALSE, gnome_calendar_get_timezone (gcal));
	dlg->year_val = tt.year;
	dlg->month_val = tt.month - 1;
	dlg->day_val = tt.day;

	gtk_option_menu_set_history (GTK_OPTION_MENU (dlg->month), dlg->month_val);
	gtk_spin_button_set_value (GTK_SPIN_BUTTON (dlg->year), dlg->year_val);

	create_ecal (dlg);

	goto_dialog_init_widgets (dlg);

	gtk_window_set_transient_for (GTK_WINDOW (dlg->dialog),
				      GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gcal))));

	/* set initial selection to current day */

	dlg->ecal->calitem->selection_set = TRUE;
	dlg->ecal->calitem->selection_start_month_offset = 0;
	dlg->ecal->calitem->selection_start_day = tt.day;
	dlg->ecal->calitem->selection_end_month_offset = 0;
	dlg->ecal->calitem->selection_end_day = tt.day;

	/* Set week_start_day. Convert it to 0 (Mon) to 6 (Sun), which is what we use. */
	dlg->ecal->calitem->week_start_day = (calendar_config_get_week_start_day () + 6) % 7;

	gnome_canvas_item_grab_focus (GNOME_CANVAS_ITEM (dlg->ecal->calitem));

	b = gtk_dialog_run (GTK_DIALOG (dlg->dialog));
	gtk_widget_destroy (dlg->dialog);

	if (b == 0)
		goto_today (dlg);

	g_object_unref (dlg->xml);
	g_free (dlg);
	dlg = NULL;
}
Пример #21
0
/*
 * Note that this is called every time the user clicks on an item,
 * whether it is already selected or not.
 */
static void
field_select_row_cb(GtkTreeSelection *sel, gpointer tree)
{
    GtkWidget *window                  = (GtkWidget *)gtk_widget_get_toplevel((GtkWidget *)tree);
    GtkWidget *relation_list           = (GtkWidget *)g_object_get_data(G_OBJECT(window),
                                               E_DFILTER_EXPR_RELATION_LIST_KEY);
    GtkWidget *range_label             = (GtkWidget *)g_object_get_data(G_OBJECT(window),
                                             E_DFILTER_EXPR_RANGE_LABEL_KEY);
    GtkWidget *range_entry             = (GtkWidget *)g_object_get_data(G_OBJECT(window),
                                             E_DFILTER_EXPR_RANGE_ENTRY_KEY);
    GtkWidget *value_label             = (GtkWidget *)g_object_get_data(G_OBJECT(window),
                                             E_DFILTER_EXPR_VALUE_LABEL_KEY);
    GtkWidget *value_entry             = (GtkWidget *)g_object_get_data(G_OBJECT(window),
                                             E_DFILTER_EXPR_VALUE_ENTRY_KEY);
    GtkWidget *value_list_label        = (GtkWidget *)g_object_get_data(G_OBJECT(window),
                                             E_DFILTER_EXPR_VALUE_LIST_LABEL_KEY);
    GtkWidget *value_list              = (GtkWidget *)g_object_get_data(G_OBJECT(window),
                                             E_DFILTER_EXPR_VALUE_LIST_KEY);
    GtkWidget *value_list_scrolled_win = (GtkWidget *)g_object_get_data(G_OBJECT(window),
                                             E_DFILTER_EXPR_VALUE_LIST_SW_KEY);
    GtkWidget *ok_bt                   = (GtkWidget *)g_object_get_data(G_OBJECT(window),
                                             E_DFILTER_EXPR_OK_BT_KEY);
    header_field_info *hfinfo, *cur_hfinfo;
    const char *value_type;
    char value_label_string[1024+1];   /* XXX - should be large enough */
    GtkTreeModel *model;
    GtkTreeIter   iter;

    if (!gtk_tree_selection_get_selected(sel, &model, &iter))
        return;
    gtk_tree_model_get(model, &iter, 0, &hfinfo, -1);

    /*
     * What was the item that was last selected?
     */
    cur_hfinfo = (header_field_info *)g_object_get_data(G_OBJECT(window), E_DFILTER_EXPR_CURRENT_VAR_KEY);
    if (cur_hfinfo == hfinfo) {
        /*
         * It's still selected; no need to change anything.
         */
        return;
    }

    /*
     * Mark it as currently selected.
     */
    g_object_set_data(G_OBJECT(window), E_DFILTER_EXPR_CURRENT_VAR_KEY, hfinfo);

    show_relations(relation_list, hfinfo->type);

    /*
     * Set the label for the value to indicate what type of value
     * it is.
     */
    value_type = ftype_pretty_name(hfinfo->type);
    if (value_type != NULL) {
        /*
         * Indicate what type of value it is.
         */
        g_snprintf(value_label_string, sizeof value_label_string,
                 "Value (%s)", value_type);
        gtk_label_set_text(GTK_LABEL(value_label), value_label_string);
    }

    /*
     * Clear the entry widget for the value, as whatever
     * was there before doesn't apply.
     */
    gtk_entry_set_text(GTK_ENTRY(value_entry), "");

    switch (hfinfo->type) {

    case FT_BOOLEAN:
        /*
         * The list of values should be the strings for "true"
         * and "false"; show them in the value list.
         */
        build_boolean_values(value_list_scrolled_win, value_list,
                             (const true_false_string *)hfinfo->strings);
        break;

    case FT_UINT8:
    case FT_UINT16:
    case FT_UINT24:
    case FT_UINT32:
    case FT_INT8:
    case FT_INT16:
    case FT_INT24:
    case FT_INT32:
        /*
         * If this has a value_string table (not a range_string table) associated with it,
         * fill up the list of values, otherwise clear the list of values.
         */
	/* XXX: ToDo: Implement "range-string" filter ?   */
        if ((hfinfo->strings != NULL) &&
            ! (hfinfo->display & BASE_RANGE_STRING) &&
            ! (hfinfo->display & BASE_VAL64_STRING) &&
            ! ((hfinfo->display & FIELD_DISPLAY_E_MASK) == BASE_CUSTOM)) {
            const value_string *vals = (const value_string *)hfinfo->strings;
            if (hfinfo->display & BASE_EXT_STRING)
                vals = VALUE_STRING_EXT_VS_P((const value_string_ext *)vals);
            build_enum_values(value_list_scrolled_win, value_list, vals);
        } else
            gtk_list_store_clear(GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(value_list))));
        break;

    default:
        /*
         * Clear the list of values.
         */
        gtk_list_store_clear(GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(value_list))));
        break;
    }

    /*
     * Display various items for the value, as appropriate.
     * The relation we start out with is never a comparison.
     */
    display_value_fields(hfinfo, FALSE, value_label, value_entry,
                         value_list_label, value_list, value_list_scrolled_win, range_label, range_entry);

    /*
     * XXX - in browse mode, there always has to be something
     * selected, so this should always be sensitive.
     */
    gtk_widget_set_sensitive(ok_bt, TRUE);
}
Пример #22
0
static gboolean
gtk_window_button_press_callback(GtkWidget* widget, GdkEventButton* gdk_event, wxMiniFrame* win)
{
    if (gdk_event->window != gtk_widget_get_window(widget))
        return false;
    if (g_blockEventsOnDrag) return TRUE;
    if (g_blockEventsOnScroll) return TRUE;

    if (win->m_isDragging) return TRUE;

    int style = win->GetWindowStyle();

    int y = (int)gdk_event->y;
    int x = (int)gdk_event->x;

    if ((style & wxRESIZE_BORDER) &&
        (x > win->m_width-14) && (y > win->m_height-14))
    {
        GtkWidget *ancestor = gtk_widget_get_toplevel( widget );

        GdkWindow *source = gtk_widget_get_window(widget);

        int org_x = 0;
        int org_y = 0;
        gdk_window_get_origin( source, &org_x, &org_y );

        gtk_window_begin_resize_drag (GTK_WINDOW (ancestor),
                                  GDK_WINDOW_EDGE_SOUTH_EAST,
                                  1,
                                  org_x + x,
                                  org_y + y,
                                  0);

        return TRUE;
    }

    if (win->m_miniTitle && (style & wxCLOSE_BOX))
    {
        if ((y > 3) && (y < 19) && (x > win->m_width-19) && (x < win->m_width-3))
        {
            win->Close();
            return TRUE;
        }
    }

    if (y >= win->m_miniEdge + win->m_miniTitle)
        return true;

    gdk_window_raise(gtk_widget_get_window(win->m_widget));

    const GdkEventMask mask = GdkEventMask(
        GDK_BUTTON_PRESS_MASK |
        GDK_BUTTON_RELEASE_MASK |
        GDK_POINTER_MOTION_MASK |
        GDK_POINTER_MOTION_HINT_MASK |
        GDK_BUTTON_MOTION_MASK |
        GDK_BUTTON1_MOTION_MASK);
#ifdef __WXGTK3__
    gdk_device_grab(
        gdk_event->device, gdk_event->window, GDK_OWNERSHIP_NONE,
        false, mask, NULL, gdk_event->time);
#else
    gdk_pointer_grab(gdk_event->window, false, mask, NULL, NULL, gdk_event->time);
#endif

    win->m_diffX = x;
    win->m_diffY = y;
    win->m_oldX = 0;
    win->m_oldY = 0;

    win->m_isDragging = true;

    return TRUE;
}
Пример #23
0
static void
charset_combo_box_run_dialog (ECharsetComboBox *combo_box)
{
	GtkDialog *dialog;
	GtkEntry *entry;
	GtkWidget *container;
	GtkWidget *widget;
	GObject *object;
	gpointer parent;
	const gchar *charset;

	/* FIXME Using a dialog for this is lame.  Selecting "Other..."
	 *       should unlock an entry directly in the Preferences tab.
	 *       Unfortunately space in Preferences is at a premium right
	 *       now, but we should revisit this when the space issue is
	 *       finally resolved. */

	parent = gtk_widget_get_toplevel (GTK_WIDGET (combo_box));
	parent = gtk_widget_is_toplevel (parent) ? parent : NULL;

	object = G_OBJECT (combo_box->priv->other_action);
	charset = g_object_get_data (object, "charset");

	widget = gtk_dialog_new_with_buttons (
		_("Character Encoding"), parent,
		GTK_DIALOG_DESTROY_WITH_PARENT,
		GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
		GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);

	/* Load the broken border width defaults so we can override them. */
	gtk_widget_ensure_style (widget);

	dialog = GTK_DIALOG (widget);

	//gtk_dialog_set_has_separator (dialog, FALSE);
	gtk_dialog_set_default_response (dialog, GTK_RESPONSE_OK);

	gtk_container_set_border_width (GTK_CONTAINER (dialog), 12);

	widget = gtk_dialog_get_action_area (dialog);
	gtk_container_set_border_width (GTK_CONTAINER (widget), 0);

	widget = gtk_dialog_get_content_area (dialog);
	gtk_box_set_spacing (GTK_BOX (widget), 12);
	gtk_container_set_border_width (GTK_CONTAINER (widget), 0);

	container = widget;

	widget = gtk_label_new (_("Enter the character set to use"));
	gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
	gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
	gtk_widget_show (widget);

	widget = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
	gtk_alignment_set_padding (GTK_ALIGNMENT (widget), 0, 0, 12, 0);
	gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
	gtk_widget_show (widget);

	container = widget;

	widget = gtk_entry_new ();
	entry = GTK_ENTRY (widget);
	gtk_entry_set_activates_default (entry, TRUE);
	gtk_container_add (GTK_CONTAINER (container), widget);
	gtk_widget_show (widget);

	g_signal_connect (
		entry, "changed",
		G_CALLBACK (charset_combo_box_entry_changed_cb), dialog);

	/* Set the default text -after- connecting the signal handler.
	 * This will initialize the "OK" button to the proper state. */
	gtk_entry_set_text (entry, charset);

	if (gtk_dialog_run (dialog) != GTK_RESPONSE_OK) {
		gint active;

		/* Revert to the previously selected character set. */
		combo_box->priv->block_dialog = TRUE;
		active = combo_box->priv->previous_index;
		gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), active);
		combo_box->priv->block_dialog = FALSE;

		goto exit;
	}

	charset = gtk_entry_get_text (entry);
	g_return_if_fail (charset != NULL && charset != '\0');

	g_object_set_data_full (
		object, "charset", g_strdup (charset),
		(GDestroyNotify) g_free);

exit:
	gtk_widget_destroy (GTK_WIDGET (dialog));
}
Пример #24
0
void
ags_machine_popup_destroy_activate_callback(GtkWidget *widget, AgsMachine *machine)
{
  AgsWindow *window;

  AgsAudio *audio;
  
  AgsRemoveAudio *remove_audio;

  AgsThread *gui_thread;

  AgsApplicationContext *application_context;
  
  GList *list, *list_start;

  window = (AgsWindow *) gtk_widget_get_toplevel((GtkWidget *) machine);

  application_context = (AgsApplicationContext *) window->application_context;
  
  /* destroy editor */
  list =
    list_start = gtk_container_get_children((GtkContainer *) window->notation_editor->machine_selector);

  list = list->next;

  while(list != NULL){
    if(AGS_IS_MACHINE_RADIO_BUTTON(list->data) && AGS_MACHINE_RADIO_BUTTON(list->data)->machine == machine){
      gtk_widget_destroy(list->data);
      break;
    }
    
    list = list->next;
  }

  g_list_free(list_start);

  /* destroy automation editor */  
  list =
    list_start = gtk_container_get_children((GtkContainer *) window->automation_window->automation_editor->machine_selector);

  list = list->next;

  while(list != NULL){
    if(AGS_IS_MACHINE_RADIO_BUTTON(list->data) && AGS_MACHINE_RADIO_BUTTON(list->data)->machine == machine){
      gtk_widget_destroy(list->data);
      break;
    }
    
    list = list->next;
  }

  g_list_free(list_start);

  /* destroy machine */
  audio = machine->audio;
  g_object_ref(audio);

  ags_connectable_disconnect(AGS_CONNECTABLE(machine));
  gtk_widget_destroy((GtkWidget *) machine);

  /* get task thread */
  gui_thread = ags_ui_provider_get_gui_thread(AGS_UI_PROVIDER(application_context));

  remove_audio = ags_remove_audio_new(application_context,
				      audio);
  
  ags_gui_thread_schedule_task((AgsGuiThread *) gui_thread,
			       (GObject *) remove_audio);
}
Пример #25
0
/**
 * @brief function for close button to destroy the toplevel widget
 */
static void close_window( GtkWidget *widget, gpointer data ){
	gtk_widget_destroy( gtk_widget_get_toplevel( widget ) );
}
Пример #26
0
void
ags_machine_open_extended_response_callback(GtkWidget *widget, gint response, AgsMachine *machine)
{
  GtkFileChooserDialog *file_chooser;
  AgsFileSelection *file_selection;
  GtkCheckButton *overwrite;
  GtkCheckButton *create;

  GSList *filenames;

  gchar *current_folder;

  GError *error;

  file_chooser = (GtkFileChooserDialog *) gtk_widget_get_toplevel(widget);

  if(response == GTK_RESPONSE_ACCEPT){
    filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(file_chooser));
    overwrite = g_object_get_data((GObject *) widget, "overwrite");
    create = g_object_get_data((GObject *) widget, "create");

    current_folder = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(file_chooser));
    //TODO:JK: you need to check against recently used
    //TODO:JK: add more file types to AgsFileSelection

    /* check for supported packed audio files */
    file_selection = (AgsFileSelection *) gtk_file_chooser_get_extra_widget(GTK_FILE_CHOOSER(file_chooser));

    if(file_selection != NULL && g_strcmp0(file_selection->directory, current_folder)){
      gtk_widget_destroy(GTK_WIDGET(file_selection));

      file_selection = NULL;
    }

    if(file_selection == NULL ||
       (AGS_FILE_SELECTION_COMPLETED & (file_selection->flags)) == 0){

      if((AGS_MACHINE_ACCEPT_SOUNDFONT2 & (machine->file_input_flags)) != 0){
	GDir *current_directory;

	GList *new_entry, *old_entry;	  
	GSList *slist;

	gchar *current_filename;
	
	slist = filenames;
	new_entry = NULL;
	
	while(slist != NULL){
	  if(g_str_has_suffix(slist->data,
			      ".sf2")){
	    AgsFileSelectionEntry *entry;
	    
	    
	    entry = ags_file_selection_entry_alloc();
	    entry->filename = slist->data;
	  
	    new_entry = g_list_prepend(new_entry,
				       entry);
	  }
	  
	  slist = slist->next;
	}
	
	old_entry = NULL;
	
	if(file_selection == NULL){
	  if(new_entry != NULL){
	    file_selection = ags_file_selection_new();
	    gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(file_chooser),
					      GTK_WIDGET(file_selection));

	    ags_file_selection_set_entry(file_selection,
					 new_entry);
	    ags_connectable_connect(AGS_CONNECTABLE(file_selection));

	    gtk_widget_show_all(GTK_WIDGET(file_selection));

	    return;
	  }
	}else if(AGS_IS_FILE_SELECTION(file_selection)){
	  GList *really_new_entry;
	  GList *list;
	  
	  old_entry = file_selection->entry;
	  list = new_entry;
	  really_new_entry = NULL;
	  
	  /* check against existing entries */
	  if(new_entry != NULL){
	    while(list != NULL){
	      if(g_list_find(old_entry, list->data) == NULL){
		really_new_entry = g_list_prepend(really_new_entry,
						  list->data);
	      }else{
		free(list->data);
	      }
	      
	      list = list->next;
	    }
	    
	    g_list_free(new_entry);
	  }
	  
	  ags_file_selection_set_entry(file_selection,
				       really_new_entry);

	  /* adding lost files */
	  //TODO:JK: figure out if you need to copy the GSList of filenames
	  gtk_file_chooser_select_all(GTK_FILE_CHOOSER(file_chooser));
	  
	  current_directory = g_dir_open(current_folder,
					 0,
					 &error);
	  
	  while((current_filename = (gchar *) g_dir_read_name(current_directory)) != NULL){
	    if(!g_strcmp0(".", current_filename) ||
	       !g_strcmp0("..", current_filename))
	      continue;

	    if(!ags_file_selection_contains_file(file_selection,
						 current_filename) &&
	       g_slist_find(filenames, current_filename) == NULL){
	      gtk_file_chooser_unselect_filename(GTK_FILE_CHOOSER(file_chooser),
						 current_filename);
	    }
	  }
	  
	  g_dir_close(current_directory);
	  
	  return;
	}
      }
    }
    
    //TODO:JK: fix GSList filenames memory leak
    ags_machine_open_files(machine,
			   filenames,
			   overwrite->toggle_button.active,
			   create->toggle_button.active);
  }
}
Пример #27
0
static void
vevent_reply(GObject * button, GtkWidget * box)
{
    LibBalsaVEvent *event =
	LIBBALSA_VEVENT(g_object_get_data(button, "event"));
    LibBalsaVCalPartStat pstat =
	GPOINTER_TO_INT(g_object_get_data(button, "mode"));
    gchar *rcpt;
    LibBalsaMessage *message;
    LibBalsaMessageBody *body;
    gchar *dummy;
    gchar **params;
    GError *error = NULL;
    LibBalsaMsgCreateResult result;
    LibBalsaIdentity *ident;

    g_return_if_fail(event != NULL);
    rcpt = (gchar *) g_object_get_data(G_OBJECT(event), "ev:sender");
    g_return_if_fail(rcpt != NULL);
    ident = g_object_get_data(G_OBJECT(event), "ev:ident");
    g_return_if_fail(ident != NULL);

    /* make the button box insensitive... */
    gtk_widget_set_sensitive(box, FALSE);

    /* create a message with the header set from the incoming message */
    message = libbalsa_message_new();
    message->headers->from = internet_address_list_new();
    internet_address_list_add(message->headers->from, ident->ia);
    message->headers->to_list = internet_address_list_parse_string(rcpt);
    message->headers->date = time(NULL);

    /* create the message subject */
    dummy = g_strdup_printf("%s: %s",
			    event->summary ? event->summary : _("iTIP Calendar Request"),
			    libbalsa_vcal_part_stat_to_str(pstat));
    libbalsa_message_set_subject(message, dummy);
    g_free(dummy);

    /* the only message part is the calendar object */
    body = libbalsa_message_body_new(message);
    body->buffer =
	libbalsa_vevent_reply(event,
			      INTERNET_ADDRESS_MAILBOX(ident->ia)->addr,
			      pstat);
    body->charset = g_strdup("utf-8");
    body->content_type = g_strdup("text/calendar");
    libbalsa_message_append_part(message, body);

    /* set the text/calendar parameters */
    params = g_new(gchar *, 3);
    params[0] = g_strdup("method");
    params[1] = g_strdup("reply");
    params[2] = NULL;
    message->parameters = g_list_prepend(message->parameters, params);

#if ENABLE_ESMTP
    result = libbalsa_message_send(message, balsa_app.outbox, NULL,
				   balsa_find_sentbox_by_url,
				   ident->smtp_server,
                                   GTK_WINDOW(gtk_widget_get_toplevel
                                              ((GtkWidget *) button)),
				   FALSE, balsa_app.debug, &error);
#else
    result = libbalsa_message_send(message, balsa_app.outbox, NULL,
				   balsa_find_sentbox_by_url,
                                   GTK_WINDOW(gtk_widget_get_toplevel
                                              ((GtkWidget *) button)),
				   FALSE, balsa_app.debug, &error);
#endif
    if (result != LIBBALSA_MESSAGE_CREATE_OK)
	libbalsa_information(LIBBALSA_INFORMATION_ERROR,
			     _("Sending the iTIP calendar reply failed: %s"),
			     error ? error->message : "?");
    if (error)
	g_error_free(error);
    g_object_unref(G_OBJECT(message));
}
Пример #28
0
static gboolean
tm_do_popup_menu(GtkWidget * toolbar, GdkEventButton * event,
                 toolbar_info * info)
{
    GtkWidget *menu;
#if !GTK_CHECK_VERSION(3, 22, 0)
    int button, event_time;
#endif                          /*GTK_CHECK_VERSION(3, 22, 0) */
    guint i;
    GSList *group = NULL;
    GtkToolbarStyle default_style = tm_default_style();

    if (info->menu)
        return FALSE;

    info->menu = menu = gtk_menu_new();
    g_signal_connect(menu, "deactivate",
                     G_CALLBACK(tm_popup_deactivated_cb), info);

    /* ... add menu items ... */
    for (i = 0; i < G_N_ELEMENTS(tm_toolbar_options); i++) {
        GtkWidget *item;

        if (!tm_toolbar_options[i].text)
            continue;

        item =
            gtk_radio_menu_item_new_with_mnemonic(group,
                                                  _(tm_toolbar_options[i].
                                                    text));
        group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(item));

        if (tm_toolbar_options[i].style == info->model->style)
            gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
                                           TRUE);

        gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
        g_object_set_data(G_OBJECT(item), BALSA_TOOLBAR_STYLE,
                          GINT_TO_POINTER(tm_toolbar_options[i].style));
        g_signal_connect(item, "toggled", G_CALLBACK(menu_item_toggled_cb),
                         info);
    }

    for (i = 0; i < G_N_ELEMENTS(tm_toolbar_options); i++) {

        if (!tm_toolbar_options[i].text)
            continue;

        if (tm_toolbar_options[i].style == default_style) {
            gchar *option_text, *text;
            GtkWidget *item;

            gtk_menu_shell_append(GTK_MENU_SHELL(menu),
                                  gtk_separator_menu_item_new());

            option_text =
                tm_remove_underscore(_(tm_toolbar_options[i].text));
            text =
                g_strdup_printf(_("Use Desktop _Default (%s)"),
                                option_text);
            g_free(option_text);

            item = gtk_radio_menu_item_new_with_mnemonic(group, text);
            g_free(text);

            if (info->model->style == (GtkToolbarStyle) (-1))
                gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM
                                               (item), TRUE);
            gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
            g_object_set_data(G_OBJECT(item), BALSA_TOOLBAR_STYLE,
                              GINT_TO_POINTER(-1));
            g_signal_connect(item, "toggled",
                             G_CALLBACK(menu_item_toggled_cb), info);
        }
    }

    if (gtk_widget_is_sensitive(toolbar)) {
        /* This is a real toolbar, not the template from the
         * toolbar-prefs dialog. */
        GtkWidget *item;

        gtk_menu_shell_append(GTK_MENU_SHELL(menu),
                              gtk_separator_menu_item_new());
        item =
            gtk_menu_item_new_with_mnemonic(_("_Customize Toolbars…"));
        g_signal_connect(item, "activate", G_CALLBACK(customize_dialog_cb),
                         gtk_widget_get_toplevel(toolbar));
        gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);

        /* Pass the model type to the customize widget, so that it can
         * show the appropriate notebook page. */
        g_object_set_data(G_OBJECT(item), BALSA_TOOLBAR_MODEL_TYPE,
                          GINT_TO_POINTER(info->model->type));
    }

    gtk_widget_show_all(menu);

#if GTK_CHECK_VERSION(3, 22, 0)
    gtk_menu_attach_to_widget(GTK_MENU(menu), toolbar, NULL);
    if (event)
        gtk_menu_popup_at_pointer(GTK_MENU(menu),
                                  (GdkEvent *) event);
    else
        gtk_menu_popup_at_widget(GTK_MENU(menu),
                                 GTK_WIDGET(toolbar),
                                 GDK_GRAVITY_CENTER, GDK_GRAVITY_CENTER,
                                 NULL);
#else                           /*GTK_CHECK_VERSION(3, 22, 0) */
    if (event) {
        button = event->button;
        event_time = event->time;
    } else {
        button = 0;
        event_time = gtk_get_current_event_time();
    }

    gtk_menu_attach_to_widget(GTK_MENU(menu), toolbar, NULL);
    if (button)
        gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, button,
                       event_time);
    else
        gtk_menu_popup(GTK_MENU(menu), NULL, NULL, tm_popup_position_func,
                       toolbar, button, event_time);
#endif                          /*GTK_CHECK_VERSION(3, 22, 0) */

    return TRUE;
}
Пример #29
0
static gboolean
prop_save_timeout (QueryFavoriteSelector *tsel)
{
	TFavorites *bfav;
	TFavoritesAttributes fav;
	GError *error = NULL;
	gboolean allok, actiondel = TRUE;

	bfav = t_connection_get_favorites (tsel->priv->tcnc);

	memset (&fav, 0, sizeof (TFavoritesAttributes));
	fav.id = tsel->priv->properties_id;
	fav.type = T_FAVORITES_QUERIES;
	fav.name = (gchar*) gtk_entry_get_text (GTK_ENTRY (tsel->priv->properties_name));
	fav.descr = NULL;
	fav.contents = query_editor_get_all_text (QUERY_EDITOR (tsel->priv->properties_text));

	allok = t_favorites_add (bfav, 0, &fav, ORDER_KEY_QUERIES,
				 tsel->priv->properties_position, &error);
	if (! allok) {
		ui_show_error ((GtkWindow*) gtk_widget_get_toplevel ((GtkWidget*) tsel),
			       _("Could not add favorite: %s"),
			       error && error->message ? error->message : _("No detail"));
		if (error)
			g_error_free (error);
	}
	g_free (fav.contents);

	if (allok && (fav.id >= 0)) {
		gboolean is_action;
		gint qid = fav.id;
		is_action = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tsel->priv->properties_action));
		if (is_action) {
			fav.id = -1;
			fav.type = T_FAVORITES_ACTIONS;
			fav.name = (gchar*) gtk_entry_get_text (GTK_ENTRY (tsel->priv->properties_name));
			fav.descr = NULL;
			fav.contents = g_strdup_printf ("QUERY%d", qid);
			allok = t_favorites_add (bfav, 0, &fav, -1,
						 tsel->priv->properties_position, &error);
			if (! allok) {
				ui_show_error ((GtkWindow*) gtk_widget_get_toplevel ((GtkWidget*) tsel),
					       _("Could not add action: %s"),
					       error && error->message ? error->message : _("No detail"));
				if (error)
					g_error_free (error);
			}
			else
				actiondel = FALSE;
			/*g_print ("ACTION_ADDED %d: %s\n", fav.id, fav.contents);*/
			g_free (fav.contents);
		}
	}

	if (actiondel && (tsel->priv->properties_id >= 0)) {
		/* remove action */
		gint id;
		gchar *tmp;
		tmp = g_strdup_printf ("QUERY%d", tsel->priv->properties_id);
		id = t_favorites_find (bfav, 0, tmp, &fav, NULL);
		if (id >= 0) {
			t_favorites_delete (bfav, 0, &fav, NULL);
			/*g_print ("ACTION_DELETED %d: %s\n", fav.id, tmp);*/
		}
		g_free (tmp);
	}

	tsel->priv->prop_save_timeout = 0;
	return FALSE; /* remove timeout */
}
Пример #30
0
static void
helper_toolbar_prop_list_update(GtkWidget *widget, gchar **lines)
{
    GtkWidget *button = NULL;
    guint i;
    gchar **cols;
    gchar *charset;
    const gchar *indication_id, *iconic_label, *label, *tooltip_str;
    const gchar *action_id, *is_selected;
    GList *prop_buttons, *tool_buttons;
    GtkSizeGroup *sg;
    char *display_time;
    gboolean is_hidden;
    GtkWidget *toplevel;

    if (prop_menu_showing)
        return;

    charset = get_charset(lines[1]);

    prop_buttons = g_object_get_data(G_OBJECT(widget), OBJECT_DATA_PROP_BUTTONS);
    tool_buttons = g_object_get_data(G_OBJECT(widget), OBJECT_DATA_TOOL_BUTTONS);
    sg  = g_object_get_data(G_OBJECT(widget), OBJECT_DATA_SIZE_GROUP);

    if (prop_buttons) {
        g_list_foreach(prop_buttons, prop_button_destroy, NULL);
        g_list_free(prop_buttons);
        g_object_set_data(G_OBJECT(widget), OBJECT_DATA_PROP_BUTTONS, NULL);
    }

    if (tool_buttons) {
        g_list_foreach(tool_buttons, tool_button_destroy, NULL);
        g_list_free(tool_buttons);
        g_object_set_data(G_OBJECT(widget), OBJECT_DATA_TOOL_BUTTONS, NULL);
    }

    display_time
        = uim_scm_c_symbol( uim_scm_symbol_value( "toolbar-display-time" ) );
    is_hidden = strcmp(display_time, "mode");
    for (i = 0; lines[i] && strcmp("", lines[i]); i++) {
        gchar *utf8_str = convert_charset(charset, lines[i]);

        if (utf8_str != NULL) {
            cols = g_strsplit(utf8_str, "\t", 0);
            g_free(utf8_str);
        } else {
            cols = g_strsplit(lines[i], "\t", 0);
        }

        if (cols && cols[0]) {
            if (!strcmp("branch", cols[0]) && has_n_strs(cols, 4)) {
                indication_id = cols[1];
                iconic_label  = safe_gettext(cols[2]);
                tooltip_str   = safe_gettext(cols[3]);
                button = prop_button_create(widget,
                                            indication_id, iconic_label, tooltip_str);
                append_prop_button(widget, button);

                if (!is_hidden && (!strcmp(indication_id, "direct")
                                   || g_str_has_suffix(indication_id, "_direct"))) {
                    is_hidden = TRUE;
                }
            } else if (!strcmp("leaf", cols[0]) && has_n_strs(cols, 7)) {
                indication_id = cols[1];
                iconic_label  = safe_gettext(cols[2]);
                label         = safe_gettext(cols[3]);
                tooltip_str   = safe_gettext(cols[4]);
                action_id     = cols[5];
                is_selected   = cols[6];
                prop_button_append_menu(button,
                                        indication_id, label, tooltip_str, action_id,
                                        is_selected);
            }
            g_strfreev(cols);
        }
    }
    toplevel = gtk_widget_get_toplevel(widget);
    is_hidden = (is_hidden && strcmp(display_time, "always"));
#if GTK_CHECK_VERSION(2, 18, 0)
    if (gtk_widget_get_visible(toplevel) == is_hidden) {
#else
    if (GTK_WIDGET_VISIBLE(toplevel) == is_hidden) {
#endif
        if (is_hidden) {
            gtk_widget_hide(toplevel);
        } else {
            gint x = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(toplevel),
                                     "position_x"));
            gint y = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(toplevel),
                                     "position_y"));
            gtk_window_move(GTK_WINDOW(toplevel), x, y);
            gtk_widget_show(toplevel);
        }
    }

    /* create tool buttons */
    /* FIXME! command menu and buttons should be customizable. */
    for (i = 0; i < command_entry_len; i++) {
        GtkWidget *tool_button;
        GtkWidget *img;

        if (!command_entry[i].show_button)
            continue;

        tool_button = gtk_button_new();

        set_button_style(tool_button,
                         GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget),
                                         OBJECT_DATA_TOOLBAR_TYPE)));

        g_object_set_data(G_OBJECT(tool_button), OBJECT_DATA_BUTTON_TYPE,
                          GINT_TO_POINTER(BUTTON_TOOL));
        g_object_set_data(G_OBJECT(tool_button), OBJECT_DATA_COMMAND,
                          (gpointer)command_entry[i].command);
        if (command_entry[i].icon)
            img = gtk_image_new_from_stock(command_entry[i].icon,
                                           GTK_ICON_SIZE_MENU);
        else {
            img = gtk_label_new("");
            gtk_label_set_markup(GTK_LABEL(img), command_entry[i].label);
        }
        if (img)
            gtk_container_add(GTK_CONTAINER(tool_button), img);
        gtk_button_set_relief(GTK_BUTTON(tool_button), GTK_RELIEF_NONE);
        gtk_size_group_add_widget(sg, tool_button);
        g_signal_connect(G_OBJECT(tool_button), "button-press-event",
                         G_CALLBACK(button_pressed), widget);
        g_signal_connect(G_OBJECT(tool_button), "clicked",
                         G_CALLBACK(tool_button_clicked_cb), widget);

        /* tooltip */
        gtk_widget_set_tooltip_text(tool_button, _(command_entry[i].desc));

        append_tool_button(widget, tool_button);
    }

    gtk_widget_show_all(widget);
    g_free(charset);
}

static void
helper_toolbar_check_custom()
{
    guint i;

    for (i = 0; i < command_entry_len; i++)
        command_entry[i].show_button =
            uim_scm_symbol_value_bool(command_entry[i].custom_button_show_symbol);

    with_dark_bg =
        uim_scm_symbol_value_bool("toolbar-icon-for-dark-background?");
}