Exemple #1
0
void ACDProcCopyDetail(void)
{
  GtkWidget *menu, *active_item;
  menu = GTK_OPTION_MENU(optAC11)->menu;
  active_item = gtk_menu_get_active(GTK_MENU(menu));
  int srcact;
  srcact = 8 * g_list_index(GTK_MENU_SHELL(menu)->children, active_item);
  int i;
  for (i = 0; i <= 7; i++) {
    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(rbtnAC[0][i]))) {
      break;
    }
  }
  srcact += i;

  menu = GTK_OPTION_MENU(optAC12)->menu;
  active_item = gtk_menu_get_active(GTK_MENU(menu));
  int destact;
  destact = 8 * g_list_index(GTK_MENU_SHELL(menu)->children, active_item);
  for (i = 0; i <= 7; i++) {
    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(rbtnAC[1][i]))) {
      break;
    }
  }
  destact += i;

  actor->CopyAction(destact, srcact);
}
void
on_optionmenu1_changed                 (GtkOptionMenu   *optionmenu,
                                        gpointer         user_data)
{
	GtkWidget *optionmenu1 = lookup_widget( GTK_WIDGET( optionmenu ), "optionmenu1" );
	GtkWidget *menu = GTK_OPTION_MENU( optionmenu1 ) -> menu;
	GtkWidget *active_item = gtk_menu_get_active( GTK_MENU( menu ) );
	gint mode = g_list_index( GTK_MENU_SHELL( menu ) -> children, active_item );
	GtkWidget *entry1 = lookup_widget( GTK_WIDGET( optionmenu ), "entry1" );

	gint i;
	gchar str[1024];
	gchar c;

	switch( mode )
	{
		case  0 : printf( "read weight\n" ); break;
		case  1 : printf( "read unit_price\n" ); break;
		case  2 : printf( "read serial\n" ); break;
		case  3 : printf( "read prog_no\n" ); break;
		case  4 : printf( "read control\n" ); break;
		case  5 : printf( "read current_unit\n" ); break;
		case  6 : printf( "read tare\n" ); break;
		case  7 : printf( "read current_user\n" ); break;
		case  8 : printf( "read date_time\n" ); break;
		case  9 : printf( "read string_length\n" ); break;
	}
	fflush(stdout);
	while( ( c = getchar() ) != '\n' );
	for(i = 0;(c = getchar()) != '\n';i++)
		str[i] = c;
	str[i] = 0;
	while( ( getchar() ) != '\n' );
	gtk_entry_set_text( GTK_ENTRY( entry1 ), str );
}
Exemple #3
0
static void m_menu_position(GtkMenu *menu, 
                            gint *x, 
                            gint *y, 
                            gint *push_in, 
                            gpointer user_data) 
{
    GtkWidget *active = gtk_menu_get_active(menu);
    GdkEventButton *event = (GdkEventButton *) user_data;
    int menu_xpos = event->x;
    int menu_ypos = event->y;
    GtkAllocation allocation;
    GdkRectangle display_rect = m_get_monitor_geo();

    if (active) {
        gtk_menu_shell_select_item(GTK_MENU_SHELL(m_popup), active);
        gtk_widget_get_allocation(active, &allocation);
    }

    gtk_widget_get_allocation(GTK_WIDGET(menu), &allocation);
    if (display_rect.height - event->y_root < allocation.height)
        menu_ypos -= allocation.height;

    printf("DEBUG: %s (%d, %d)\n", __func__, menu_xpos, menu_ypos);
    gdk_window_get_root_coords(gtk_widget_get_window(m_window), 
        menu_xpos, menu_ypos, &menu_xpos, &menu_ypos);
    printf("DEBUG: %s (%d, %d)\n", __func__, menu_xpos, menu_ypos);
    *x = menu_xpos;
    *y = menu_ypos;
    *push_in = TRUE;
}
Exemple #4
0
static void
gdict_sidebar_menu_item_activate (GtkWidget *widget,
				  gpointer   user_data)
{
  GdictSidebar *sidebar = GDICT_SIDEBAR (user_data);
  GdictSidebarPrivate *priv = sidebar->priv;
  GtkWidget *menu_item;
  const gchar *id;
  SidebarPage *page;
  gint current_index;

  menu_item = gtk_menu_get_active (GTK_MENU (priv->menu));
  id = g_object_get_qdata (G_OBJECT (menu_item), sidebar_page_id_quark);
  g_assert (id != NULL);

  page = g_hash_table_lookup (priv->pages_by_id, id);
  g_assert (page != NULL);

  current_index = gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->notebook));
  if (current_index == page->index)
    return;

  gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook),
		  		 page->index);
  gtk_label_set_text (GTK_LABEL (priv->label), page->name);

  g_signal_emit (sidebar, sidebar_signals[PAGE_CHANGED], 0);
}
Exemple #5
0
static void selection_done(GtkMenu *menu, gpointer data)
{
	GxSelector *selector = GX_SELECTOR(data);
	GtkTreeIter iter;
	gboolean found;
	int n;
	const char *label = gtk_menu_item_get_label(GTK_MENU_ITEM(gtk_menu_get_active(menu)));
	n = 0;
	found = gtk_tree_model_get_iter_first(selector->model, &iter);
	while (found) {
		gchar *s;
		gtk_tree_model_get(selector->model, &iter, 0, &s, -1);
		if (strcmp(label, s) == 0) {
			g_free(s);
			if (n != get_selector_state(selector)) {
				set_value_from_selector_state(selector, n);
				gtk_widget_queue_draw(GTK_WIDGET(selector));
			}
			return;
		}
		g_free(s);
		n += 1;
		found = gtk_tree_model_iter_next(selector->model, &iter);
		}
	g_assert(FALSE);
}
Exemple #6
0
void ACDProcCopy4to8(bool cw)
{
  GtkWidget *opt = cw ? optAC2 : optAC3;

  GtkWidget *menu, *active_item;
  menu = GTK_OPTION_MENU(opt)->menu;
  active_item = gtk_menu_get_active(GTK_MENU(menu));
  int noact = g_list_index(GTK_MENU_SHELL(menu)->children, active_item);
  int numact = actor->GetNumAction() - noact * 8;
  if (numact < 8) {
    GtkWidget *mes;
    mes = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR,
            GTK_BUTTONS_OK, _("This act doesn't have 8 actions."));
    gtk_dialog_run(GTK_DIALOG(mes));
    gtk_widget_destroy(mes);
    return;
  }

  int baseact = noact * 8;
  for (int i=0; i<4; i++) {
    if (cw) {
      actor->CopyAction(baseact+i*2+1, baseact+i*2);
    } else {
      actor->CopyAction(baseact+i*2, baseact+i*2+1);
    }
  }
}
static void
wireless_applet_option_change (GtkWidget *widget, gpointer user_data)
{
	GtkWidget *entry;
	GtkWidget *menu = NULL;
	char *str;
	WirelessApplet *applet = (WirelessApplet *)user_data;

	/* Get all the properties and update the applet */
	entry = g_object_get_data (G_OBJECT (applet->prefs),
			"show-percent-button");
	wireless_applet_set_show_percent (applet,
			gtk_toggle_button_get_active
			(GTK_TOGGLE_BUTTON (entry)));

	entry = g_object_get_data (G_OBJECT (applet->prefs), "device-menu");

	menu = gtk_menu_get_active
		(GTK_MENU (gtk_option_menu_get_menu (GTK_OPTION_MENU (entry))));
	if (menu) {
		str = g_object_get_data (G_OBJECT (menu), "device-selected");
		wireless_applet_set_device (applet, str);
	}

	/* Save the properties */
	wireless_applet_save_properties (applet);
}
Exemple #8
0
static void
account_update(GtkWidget *widget, GtkOptionMenu *optmenu)
{
	PurpleAccount *account = NULL;

	account = g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(optmenu)))), "account");
	purple_account_set_int(account, "score", gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)));
}
Exemple #9
0
guint colorlabel_get_color_menu_active_item(GtkWidget *menu)
{
	GtkWidget *menuitem;
	guint color;

	menuitem = gtk_menu_get_active(GTK_MENU(menu));
	color = GPOINTER_TO_UINT
		(g_object_get_data(G_OBJECT(menuitem), "color"));
	return color;
}
/// gtk add on to get the rank in a pull down menu
uint8_t getRangeInMenu(GtkWidget * Menu)
{
    GtkWidget *br, *active;
    int mode;

    br = gtk_option_menu_get_menu(GTK_OPTION_MENU(Menu));
    active = gtk_menu_get_active(GTK_MENU(br));
    mode = g_list_index(GTK_MENU_SHELL(br)->children, active);
    return (uint8_t) mode;
}
Exemple #11
0
/**
 * Fetches the data set associated with the selected menu item in
 * the GtkOptionMenu m.
 */
gpointer
option_menu_get_selected_data(GtkOptionMenu *option_menu)
{
    GtkWidget *menu;

    g_assert(GTK_IS_OPTION_MENU(option_menu));

    menu = gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(option_menu)));
    return menu ? gtk_object_get_user_data(GTK_OBJECT(menu)) : NULL;
}
static GtkhtmlFace *
face_chooser_menu_get_current_face (GtkhtmlFaceChooser *chooser)
{
	GtkWidget *item;

	item = gtk_menu_get_active (GTK_MENU (chooser));
	if (item == NULL)
		return NULL;

	return g_object_get_data (G_OBJECT (item), "face");
}
static EEmoticon *
emoticon_chooser_menu_get_current_emoticon (EEmoticonChooser *chooser)
{
	GtkWidget *item;

	item = gtk_menu_get_active (GTK_MENU (chooser));
	if (item == NULL)
		return NULL;

	return g_object_get_data (G_OBJECT (item), "emoticon");
}
Exemple #14
0
project_parameters_t *
load_selected_predefined_projection_parameters(int is_source, int projection,
                                               datum_type_t *datum,
					       spheroid_type_t *spheroid)
{
    GtkWidget * predefined_projection_option_menu;
    GtkWidget * menu;
    GtkWidget * selected_item;
    gchar filename[256];
    gchar * path;
    gchar * path_and_filename;
    project_parameters_t * ret;
    projection_type_t type;
    char *err=NULL;

    predefined_projection_option_menu = is_source ?
      get_widget_checked("source_predefined_projection_option_menu") :
      get_widget_checked("target_predefined_projection_option_menu");

    menu =
        gtk_option_menu_get_menu(
        GTK_OPTION_MENU(predefined_projection_option_menu));

    selected_item =
        gtk_menu_get_active(GTK_MENU(menu));

    sprintf(filename, "%s.proj", (char *)g_object_get_data(
        G_OBJECT(selected_item), "file"));

    if (out_of_sync(filename, projection))
        return NULL;

    path = projection_directory(projection);

    path_and_filename = (gchar *)
        g_malloc(sizeof(gchar *) * (strlen(path) + strlen(filename) + 5));

    sprintf(path_and_filename, "%s/%s", path, filename);

    ret = (project_parameters_t *) g_malloc(sizeof(project_parameters_t));
    if (!parse_proj_args_file(path_and_filename, ret, &type, datum, spheroid,
			      &err))
    {
        message_box(err);
        free(err);
        return NULL;
    }

    g_free(path);
    g_free(path_and_filename);

    return ret;
}
Exemple #15
0
/* Callback used when a month button is toggled */
static void
month_changed (GtkToggleButton *toggle, gpointer data)
{
	GoToDialog *dlg = data;
	GtkWidget *menu, *active;

	menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (dlg->month));
	active = gtk_menu_get_active (GTK_MENU (menu));
	dlg->month_val = g_list_index (GTK_MENU_SHELL (menu)->children, active);

	e_calendar_item_set_first_month (dlg->ecal->calitem, dlg->year_val, dlg->month_val);
}
void
on_optionmenu3_changed                 (GtkOptionMenu   *optionmenu,
                                        gpointer         user_data)
{
	GtkWidget *optionmenu3 = lookup_widget( GTK_WIDGET( optionmenu ), "optionmenu3" );
	GtkWidget *menu = GTK_OPTION_MENU( optionmenu3 ) -> menu;
	GtkWidget *active_item = gtk_menu_get_active( GTK_MENU( menu ) );
	gint mode = g_list_index( GTK_MENU_SHELL( menu ) -> children, active_item );

	GtkWidget *spinbutton1 = lookup_widget( GTK_WIDGET( optionmenu ), "spinbutton1" );
	gint channel = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON( spinbutton1 ) );

	GtkWidget *textview1 = lookup_widget( GTK_WIDGET( optionmenu ), "textview1" );
	GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview1));

	gchar str[1024];
	gchar c;
	gint i;
//	gint fd;
	
	union get_plu plu;

	switch( mode )
	{
		case 0 : fprintf( stdout, "read format_length %d\n", channel ); break;
		case 1 : fprintf( stdout, "read plu %d\n", channel ); break;
		case 2 : fprintf( stdout, "read label %d\n", channel ); break;
		case 3 : fprintf( stdout, "read string %d\n", channel ); break;
	}
	fflush( stdout );

	while( ( c = getchar() ) != '\n' );
//	fd  = open( "/dev/stdin", O_RDONLY | O_NOCTTY );
//	i = read( fd, &plu.seg, sizeof( plu.seg ));
	fread( &plu, sizeof( plu ), 1, stdin);

	
	for( i = 0; i < 136 ; i++ )
		fprintf( stderr, "%c",plu.seg[ i ]);
		
        fflush( stderr);

/*
	for(i = 0;(c = getchar()) != '^' ;i++)
	{	str[i] = c; }
//		fprintf(stderr,"%c",c);
	str[i] = '\0';*/
	// fprintf(stderr,"\n%s\n",str);
	while( ( getchar() ) != '\n' );
//	gtk_text_buffer_set_text (buffer, g_locale_to_utf8( str, -1, NULL, NULL, NULL ), -1);
}
void
on_optionmenu2_changed                 (GtkOptionMenu   *optionmenu,
                                        gpointer         user_data)
{

	GtkWidget *spinbutton2 = lookup_widget( GTK_WIDGET( optionmenu ), "spinbutton2" );
	gint channel = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON( spinbutton2 ) );
	
	GtkWidget *optionmenu2 = lookup_widget( GTK_WIDGET( optionmenu ), "optionmenu2" );
	GtkWidget *menu = GTK_OPTION_MENU( optionmenu2 ) -> menu;
	GtkWidget *active_item = gtk_menu_get_active( GTK_MENU( menu ) );
	gint mode = g_list_index( GTK_MENU_SHELL( menu ) -> children, active_item );

	GtkWidget *textview1 = lookup_widget( GTK_WIDGET( optionmenu ), "textview1" );
	GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview1));
	
	gchar str[1024];
	//一定要指定為空,因為一開始的時候連接時是沒有東西
	gchar take_str[1024];
	gint i;
	gchar *str_p;
	GtkTextIter start, end;

	//把在緩衝區的兩邊邊界抓取
	gtk_text_buffer_get_bounds( buffer, &start, &end );
	//轉換utf8的格式為當地並拷貝至指定位置
	strcpy( str , g_locale_from_utf8( gtk_text_buffer_get_text( buffer, &start, &end, TRUE), -1, NULL, NULL, NULL ) );

	while(	str_p =  strchr( str, '\n' ) ) 
	{
		strcpy( take_str,  str_p + 1 );
		i = strcspn( str, "\n");
		str[ i ] = '\\';
		str[ ++i ] = 'n';
		str[ ++i ] = '\0';
		strcat( str, take_str );
	}
//	fprintf(stderr,"%s\n",str);
	switch( mode )
	{
		case 0 : fprintf( stdout, "write tare %s\n", str ); break;
		case 1 : break;
		case 2 : fprintf( stdout, "write string %d %s\n", channel, str ); break;
		case 3 : fprintf( stdout, "write strapp %d %s\n", channel, str ); break;
		case 4 : break;
	}
	fflush( stdout );
	while( ( getchar() ) != '\n' );
	while( ( getchar() ) != '\n' );
}
Exemple #18
0
/**
 * Test whether we can move off format page.
 * \return <i>TRUE</i> if OK to move off page.
 */
static gboolean exp_html_move_format( void ) {
	gboolean retVal = FALSE;
	GtkWidget *menu, *menuItem;
	gint id;

	/* Set stylesheet */
	menu = gtk_option_menu_get_menu( GTK_OPTION_MENU( exphtml_dlg.optmenuCSS ) );
	menuItem = gtk_menu_get_active( GTK_MENU( menu ) );
	id = GPOINTER_TO_INT( gtk_object_get_user_data(GTK_OBJECT(menuItem)) );
	exporthtml_set_stylesheet( _exportCtl_, id );

	/* Set name format */
	menu = gtk_option_menu_get_menu( GTK_OPTION_MENU( exphtml_dlg.optmenuName ) );
	menuItem = gtk_menu_get_active( GTK_MENU( menu ) );
	id = GPOINTER_TO_INT( gtk_object_get_user_data(GTK_OBJECT(menuItem)) );
	exporthtml_set_name_format( _exportCtl_, id );

	exporthtml_set_banding( _exportCtl_,
		gtk_toggle_button_get_active(
			GTK_TOGGLE_BUTTON( exphtml_dlg.checkBanding ) ) );
	exporthtml_set_link_email( _exportCtl_,
		gtk_toggle_button_get_active(
			GTK_TOGGLE_BUTTON( exphtml_dlg.checkLinkEMail ) ) );
	exporthtml_set_attributes( _exportCtl_,
		gtk_toggle_button_get_active(
			GTK_TOGGLE_BUTTON( exphtml_dlg.checkAttributes ) ) );

	/* Process export */
	exporthtml_process( _exportCtl_, _addressCache_ );
	if( _exportCtl_->retVal == MGU_SUCCESS ) {
		retVal = TRUE;
	}
	else {
		export_html_status_show( _( "Error creating HTML file" ) );
	}
	return retVal;
}
static gint
property_dialog_get_selected (GtkWidget *option_menu)
{
	GtkWidget *menu;
	GtkWidget *item;
	gint       ret;

	menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (option_menu));

	item = gtk_menu_get_active (GTK_MENU (menu));

	ret = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "data"));

	return ret;
}
static void
gb_option_menu_on_option_selected (GtkWidget *menu,
				   GtkWidget *option_menu)
{
  GtkWidget *active_item;
  gint item_index;
  
  if (property_get_widget () != option_menu)
    return;

  active_item = gtk_menu_get_active (GTK_MENU (menu));
  item_index = g_list_index (GTK_MENU_SHELL (menu)->children, active_item);

  property_set_auto_apply (FALSE);
  property_set_int (Choice, item_index);
  property_set_auto_apply (TRUE);
}
Exemple #21
0
static void
gr_edit (GtkWidget */*button*/, GtkWidget *widget)
{
    GtkWidget *om = (GtkWidget *) g_object_get_data (G_OBJECT(widget), "menu");

    spinbutton_defocus(GTK_OBJECT(widget));

    if (om) {
        GtkWidget *i = gtk_menu_get_active (GTK_MENU (gtk_option_menu_get_menu (GTK_OPTION_MENU (om))));
        SPGradient *gr = (SPGradient *) g_object_get_data (G_OBJECT(i), "gradient");

        if (gr) {
            GtkWidget *dialog = sp_gradient_vector_editor_new (gr);
            gtk_widget_show (dialog);
        }
    }
}
Exemple #22
0
static gboolean gtkMenuKeyPressEvent(GtkWidget *widget, GdkEventKey *evt, Ihandle *ih)
{
  if (evt->keyval == GDK_F1)
  {
    Ihandle* child;
    GtkWidget* active = gtk_menu_get_active((GtkMenu*)widget);
    for (child=ih->firstchild; child; child=child->brother)
    {
      if (child->handle == active)
        iupgtkShowHelp(NULL, NULL, child);
    }
  }

  (void)widget;
  (void)evt;
  return FALSE;
}
/**
 * nma_utils_update_password_storage:
 * @passwd_entry: #GtkEntry with the password
 * @secret_flags: secret flags to set
 * @setting: #NMSetting containing the password, or NULL
 * @password_flags_name: name of the secret flags (like psk-flags), or NULL
 *
 * Updates secret flags in the password storage popup menu and also
 * in the @setting (if @setting and @password_flags_name are not NULL).
 *
 */
void
nma_utils_update_password_storage (GtkWidget *passwd_entry,
                                   NMSettingSecretFlags secret_flags,
                                   NMSetting *setting,
                                   const char *password_flags_name)
{
    GList *menu_list, *iter;
    GtkWidget *menu = NULL;

    /* Update secret flags (WEP_KEY_FLAGS, PSK_FLAGS, ...) in the security setting */
    if (setting && password_flags_name)
        nm_setting_set_secret_flags (setting, password_flags_name, secret_flags, NULL);

    /* Update password-storage popup menu to reflect secret flags */
    menu_list = gtk_menu_get_for_attach_widget (passwd_entry);
    for (iter = menu_list; iter; iter = g_list_next (iter)) {
        if (g_object_get_data (G_OBJECT (iter->data), PASSWORD_STORAGE_MENU_TAG)) {
            menu = iter->data;
            break;
        }
    }

    if (menu) {
        GtkRadioMenuItem *item;
        MenuItem idx;
        GSList *group;
        gboolean with_not_required;
        int i, last;

        /* radio menu group list contains the menu items in reverse order */
        item = (GtkRadioMenuItem *) gtk_menu_get_active (GTK_MENU (menu));
        group = gtk_radio_menu_item_get_group (item);
        with_not_required = !!g_object_get_data (G_OBJECT (menu), MENU_WITH_NOT_REQUIRED_TAG);

        idx = secret_flags_to_menu_item (secret_flags, with_not_required);
        last = g_slist_length (group) - idx - 1;
        for (i = 0; i < last; i++)
            group = g_slist_next (group);

        gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (group->data), TRUE);
        change_password_storage_icon (passwd_entry, idx);
    }
}
static void dologin(GtkWidget *widget, GtkWidget *w)
{
	GaimAccount *account;
	GtkWidget *item;
	const char *password = gtk_entry_get_text(GTK_ENTRY(pass));

	item = gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(GTK_OPTION_MENU(name))));
	account = g_object_get_data(G_OBJECT(item), "account");

	if (!account) {
		gaim_notify_error(NULL, NULL, _("Please create an account."), NULL);
		return;
	}

	gaim_account_set_password(account, (*password != '\0') ? password : NULL);

#ifdef GAIM_SMALL_SCREEN
    account->ui_data = vbox_toplevel;
#endif    
	gaim_account_connect(account);
}
Exemple #25
0
void ACDDetailComboChange(GtkOptionMenu *optionmenu, gpointer user_data)
{
  if (actor->IsReady() == false)  return;

  GtkWidget *menu, *active_item;
  menu = GTK_OPTION_MENU(optionmenu)->menu;
  active_item = gtk_menu_get_active(GTK_MENU(menu));
  int i = g_list_index(GTK_MENU_SHELL(menu)->children, active_item);
  int ID = (int)user_data;

  if (ID == 11) {
    ACDSetInitial_Radio(i, true);
  } else {
    ACDSetInitial_Radio(i, false);
  }
  if (ID == 11 || ID == 12) {
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rbtnDETAIL), (gboolean)true);
  } else if (ID == 2) {
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rbtnCW), (gboolean)true);
  } else if (ID == 3) {
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rbtnCCW), (gboolean)true);
  }
}
static void
toolbar_button_clicked (GtkToolButton *button,
			FoldingTabPane *pane)
{
     GtkMenu *menu = GTK_MENU (gtk_menu_tool_button_get_menu (GTK_MENU_TOOL_BUTTON (button)));
     GtkWidget *selected = gtk_menu_get_active (menu);
     if (selected != NULL){
	  gpointer data = g_object_get_data (G_OBJECT (selected), TOOL_BAR_MENU_ITEM_STRUCT_PTR);
	  if (data == NULL)
	       return;
	  ToolBarButtonMenuItemStruct *item = (ToolBarButtonMenuItemStruct*)data;
	  if (item->create_widget_func != NULL){
	       GtkWidget* widget = item->create_widget_func();
	       if (widget != NULL){
		    const gchar *name  = gtk_widget_get_name (widget);
		    GtkWidget *label = gtk_label_new (name);
		    folding_tab_pane_append_page (pane, widget, label);
	       }
	  }

     }

}
static void
choiceSelected (GtkMenuShell *menuShell, GChoicePeerData *data)
{
	jobject this = ((GComponentPeerData *)data)->peerGlobalRef;
	jobject target;
	JNIEnv *env;
	GtkWidget *active;
	GList *children;
	int index;
	
	if ((*JVM)->AttachCurrentThread (JVM, (void **) &env, NULL) != 0)
		return;
		
	awt_gtk_callbackEnter();
		
	active = gtk_menu_get_active (GTK_MENU(menuShell));
	children = gtk_container_children (GTK_CONTAINER(menuShell));
	index = g_list_index (children, (gpointer)active);
	
	if (index != -1)
	{
		GtkOptionMenu *optionMenu;
	
		target = (*env)->GetObjectField (env, this, GCachedIDs.GComponentPeer_targetFID);
		(*env)->SetIntField (env, target, GCachedIDs.java_awt_Choice_selectedIndexFID, (jint)index);
		(*env)->CallVoidMethod (env, this, GCachedIDs.GChoicePeer_postItemEventMID, (jint)index);

		/*
		** Workaround:
		** the popup is gone now, let's set the focus back to the optionMenu
		*/
		optionMenu = GTK_OPTION_MENU(((GComponentPeerData *)data)->widget);
		gtk_widget_grab_focus((GtkWidget *)optionMenu);
	}
	
	awt_gtk_callbackLeave();
}
Exemple #28
0
/* Keep track of the last menu item selected. (For the purposes
 * of the option menu */
int
clip_GTK_MENUGETACTIVE(ClipMachine * ClipMachineMemory)
{
   C_widget *cmnu = _fetch_cw_arg(ClipMachineMemory);

   GtkWidget *item;

   C_widget *citem;

   CHECKCWID(cmnu, GTK_IS_MENU);
   item = gtk_menu_get_active(GTK_MENU(cmnu->widget));
   citem = _list_get_cwidget(ClipMachineMemory, item);
   if (!citem)
      citem = _register_widget(ClipMachineMemory, item, NULL);
   if (citem)
    {
       ClipVar  *ret = RETPTR(ClipMachineMemory);

       _clip_mclone(ClipMachineMemory, ret, &citem->obj);
    }
   return 0;
 err:
   return 1;
}
SIGNAL_CALLBACK void
on_add_file_with_ancillary_ok_button_clicked(GtkWidget * w)
{
  const char *type = get_string_from_label("add_with_ancillary_format_label");
  int sel = -1;
  if (strcmp_case(type, "GAMMA") == 0)
    sel = ADD_FILE_WITH_ANCILLARY_FORMAT_GAMMA;
  else if (strcmp_case(type, "PolSARPro") == 0)
    sel = ADD_FILE_WITH_ANCILLARY_FORMAT_POLSARPRO;
  else if (strcmp_case(type, "UAVSAR") == 0)
    sel = ADD_FILE_WITH_ANCILLARY_FORMAT_UAVSAR;
  GtkTreeIter iter;
  int ok = TRUE;
  char *dataFile = NULL, *data = NULL, *ceos = NULL;
  char *aux_info = "";

  switch (sel) {
  case ADD_FILE_WITH_ANCILLARY_FORMAT_POLSARPRO:
    {
      GtkWidget *ok_button =
        get_widget_checked("add_file_with_ancillary_ok_button");
      gtk_widget_set_sensitive(ok_button, FALSE);
      dataFile = get_string_from_entry("add_file_with_ancillary_polsarpro_image_entry");
      char *matrixType=NULL, *error, *decompositionType, *derror;
      char *serror, *perror;
      int is_polsarpro_matrix =
        isPolsarproMatrix(dataFile, &matrixType, &error);
      int is_polsarpro_decomposition =
        isPolsarproDecomposition(dataFile, &decompositionType, &derror);
      int is_polsarpro_segmentation =
        isPolsarproSegmentation(dataFile, &serror);
      int is_polsarpro_parameter = isPolsarproParameter(dataFile, &perror);
      if (is_polsarpro_matrix && !is_polsarpro_decomposition &&
          !is_polsarpro_segmentation && !is_polsarpro_parameter) {
        data = (char *) MALLOC(sizeof(char) * (strlen(dataFile) + 15));
        if (!is_dir(dataFile)) {
          char *tmp = (char *) MALLOC(sizeof(char) * (strlen(dataFile) + 1));
          tmp = get_dirname(dataFile);
          dataFile[strlen(tmp) - 1] = '\0';
          FREE(tmp);
        }
        if (strcmp(matrixType, "T3") == 0 || strcmp(matrixType, "T4") == 0)
          sprintf(data, "%s/T11.bin", dataFile);
        else if (strcmp(matrixType, "C2") == 0 ||
                 strcmp(matrixType, "C3") == 0 ||
                 strcmp(matrixType, "C4") == 0)
          sprintf(data, "%s/C11.bin", dataFile);
      }
      else
        data = STRDUP(dataFile);
      FREE(matrixType);
      int is_geocoded = isGeocoded(data);
      if (!is_geocoded)
        ceos =
          get_string_from_entry
          ("add_file_with_ancillary_polsarpro_ceos_entry");
      if (!is_geocoded && (strlen(ceos) == 0 || strlen(data) == 0)) {
        put_string_to_label("add_with_ancillary_error_label",
                            "Please choose all required files!");
        return;
      }
      else {
        GtkWidget *browse_option_menu =
          get_widget_checked("browse_select_colormap_optionmenu");
        GtkWidget *menu =
          gtk_option_menu_get_menu(GTK_OPTION_MENU(browse_option_menu));
        GtkWidget *selected_item = gtk_menu_get_active(GTK_MENU(menu));
        GtkWidget *combo =
          get_widget_checked("browse_select_image_data_type_optionmenu");
        int image_data_type = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
        char *lut_basename =
          g_object_get_data(G_OBJECT(selected_item), "file");
        aux_info = encode_polsarpro_aux_info(image_data_type, lut_basename);
        put_string_to_label("add_with_ancillary_error_label", "");
        ok = add_to_files_list_iter(data, ceos, NULL, aux_info, NULL,
                                    NULL, NULL, NULL, NULL, &iter);

        free(aux_info);
      }
      break;
    }

  case ADD_FILE_WITH_ANCILLARY_FORMAT_GAMMA:
    {
      GtkWidget *ok_button =
        get_widget_checked("add_file_with_ancillary_ok_button");
      gtk_widget_set_sensitive(ok_button, TRUE);
      data =
        get_string_from_entry("add_file_with_ancillary_gamma_data_entry");
      char *meta =
        get_string_from_entry("add_file_with_ancillary_gamma_metadata_entry");
      if (strlen(data) == 0 || strlen(meta) == 0) {
        put_string_to_label("add_with_ancillary_error_label",
                            "Please choose all required files!");
        return;
      }
      else {
        put_string_to_label("add_with_ancillary_error_label", "");
        char *interferogram, *coherence, *slave_metadata, *baseline;
        interferogram = get_string_from_entry("add_file_with_ancillary_gamma_igram_entry");
        coherence = get_string_from_entry("add_file_with_ancillary_gamma_coh_entry");
        slave_metadata = get_string_from_entry("add_file_with_ancillary_gamma_slave_entry");
        baseline = get_string_from_entry("add_file_with_ancillary_gamma_baseline_entry");
        if (strlen(interferogram) == 0) {
          FREE(interferogram);
          interferogram = NULL;
        }
        if (strlen(coherence) == 0) {
          FREE(coherence);
          coherence = NULL;
        }
        if (strlen(slave_metadata) == 0) {
          FREE(slave_metadata);
          slave_metadata = NULL;
        }
        if (strlen(baseline) == 0) {
          FREE(baseline);
          baseline = NULL;
        }
        ok = add_to_files_list_iter(data, ceos, meta, aux_info, NULL,
                                    interferogram, coherence,
                                    slave_metadata, baseline, &iter);
      }
      break;
    }

    case ADD_FILE_WITH_ANCILLARY_FORMAT_UAVSAR:
    {
      GtkWidget *ok_button =
        get_widget_checked("add_file_with_ancillary_ok_button");
      gtk_widget_set_sensitive(ok_button, TRUE);

      GtkWidget *ann_file_entry = get_widget_checked("add_file_with_ancillary_uavsar_annotation_file_entry");
      const gchar *annotation_file = gtk_entry_get_text(GTK_ENTRY(ann_file_entry));

      GList *l, *uavsar_proc_types = get_widgets_prefix_checked("uavsar_proc_type_");
      for(l = uavsar_proc_types; l; l = l->next) {
        gpointer proc_type_check_button = l->data;
        if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(proc_type_check_button))) {
          const gchar *name = gtk_widget_get_name(GTK_WIDGET(proc_type_check_button));
          ok = add_to_files_list_iter(annotation_file, NULL, NULL, NULL, name + strlen("uavsar_proc_types_") - 1,
              NULL, NULL, NULL, NULL, &iter);
          if(!ok)
            break;
        }
      }
      g_list_free(uavsar_proc_types);
    }
    break;
  }
  if (!ok) {
    if (data) {
      char *msg = MALLOC(sizeof(char) * (strlen(data) + 128));
      sprintf(msg, "Unrecognized file:\n  %s\n\n"
              "The file may be of a type not supported by MapReady.\n", data);
      message_box(msg);
      free(msg);
    }
    else {
      char *msg = MALLOC(sizeof(char) * 256);
      sprintf(msg, "Unrecognized file!\n\n"
              "The file may be of a type not supported by MapReady.\n");
      message_box(msg);
      free(msg);
    }
  }
  else {
    show_widget("add_file_with_ancillary_dialog", FALSE);
    clear_entries();
  }
}
Exemple #30
0
static GtkWidget *
get_config_frame(PurplePlugin *plugin)
{
	GtkWidget *ret = NULL, *hbox = NULL, *frame = NULL, *vbox = NULL;
	GtkWidget *label = NULL, *spin = NULL, *check = NULL;
	GtkWidget *optmenu = NULL;
	GtkObject *adj = NULL;
	GtkSizeGroup *sg = NULL;
	PurpleAccount *account = NULL;
	int i;

	gboolean last_match = purple_prefs_get_bool("/purple/contact/last_match");

	sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);

	ret = gtk_vbox_new(FALSE, 18);
	gtk_container_set_border_width(GTK_CONTAINER(ret), 12);

	frame = pidgin_make_frame(ret, _("Point values to use when..."));

	vbox = gtk_vbox_new(FALSE, 5);
	gtk_container_add(GTK_CONTAINER(frame), vbox);

	/* Status Spinboxes */
	for (i = 0 ; statuses[i].id != NULL && statuses[i].description != NULL ; i++)
	{
		char *pref = g_strconcat("/purple/status/scores/", statuses[i].id, NULL);

		hbox = gtk_hbox_new(FALSE, 5);
		gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);

		label = gtk_label_new_with_mnemonic(_(statuses[i].description));
		gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
		gtk_size_group_add_widget(sg, label);
		gtk_misc_set_alignment(GTK_MISC(label), 0, 0);

		adj = gtk_adjustment_new(purple_prefs_get_int(pref), -500, 500, 1, 1, 1);
		spin = gtk_spin_button_new((GtkAdjustment *)adj, 1, 0);
		g_signal_connect(G_OBJECT(spin), "value-changed", G_CALLBACK(pref_update), pref);
		gtk_box_pack_start(GTK_BOX(hbox), spin, FALSE, FALSE, 0);

		g_free(pref);
	}

	/* Explanation */
	label = gtk_label_new(NULL);
	gtk_label_set_markup(GTK_LABEL(label), _("The buddy with the <i>largest score</i> is the buddy who will have priority in the contact.\n"));
	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);

	/* Last match */
	hbox = gtk_hbox_new(FALSE, 5);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);

	check = gtk_check_button_new_with_label(_("Use last buddy when scores are equal"));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), last_match);
	g_signal_connect(G_OBJECT(check), "toggled", G_CALLBACK(pref_update), "/purple/contact/last_match");
	gtk_box_pack_start(GTK_BOX(hbox), check, FALSE, FALSE, 0);

	frame = pidgin_make_frame(ret, _("Point values to use for account..."));

	vbox = gtk_vbox_new(FALSE, 5);
	gtk_container_add(GTK_CONTAINER(frame), vbox);

	/* Account */
	hbox = gtk_hbox_new(FALSE, 5);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);

	/* make this here so I can use it in the option menu callback, we'll
	 * actually set it up later */
	adj = gtk_adjustment_new(0, -500, 500, 1, 1, 1);
	spin = gtk_spin_button_new((GtkAdjustment *)adj, 1, 0);

	optmenu = pidgin_account_option_menu_new(NULL, TRUE,
																						 G_CALLBACK(select_account),
																						 NULL, spin);
	gtk_box_pack_start(GTK_BOX(hbox), optmenu, FALSE, FALSE, 0);

	/* this is where we set up the spin button we made above */
	account = g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu))))),
															"account");
	gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin),
														(gdouble)purple_account_get_int(account, "score", 0));
	gtk_spin_button_set_adjustment(GTK_SPIN_BUTTON(spin), GTK_ADJUSTMENT(adj));
	g_signal_connect(G_OBJECT(spin), "value-changed",
									 G_CALLBACK(account_update), optmenu);
	gtk_box_pack_start(GTK_BOX(hbox), spin, FALSE, FALSE, 0);

	gtk_widget_show_all(ret);
	g_object_unref(sg);

	return ret;
}