Sponsored Content
Top Forums Programming Combining Qt with GTK only one problem! Post 302663887 by Corona688 on Thursday 28th of June 2012 03:11:34 PM
Old 06-28-2012
You are forcing a conversion from a class member to a function call. Class members have this, function calls don't. So it crashes.

If you make the member function static, you'll be able to call it, since static member functions don't have 'this'. So you won't have this but you can make do -- that's what the data parameter in a GTK callback is for instead. You can pass a long a pointer for data you need later. Pass in the class itself and you can go datapointer->whatever.

Code:
// You'll have to change the definition in the header file too, if any
static void MainWindow::show_app(MainWindow *data){
    data->show();
    //crash here:
//    this->show();
    //this works fine:
    app_indicator_set_status(appindicator, APP_INDICATOR_STATUS_PASSIVE);
}

void MainWindow::make_indicator()
{
    if(appindicator){
        //appindicator has already been created
        return;
    }
    appindicator = app_indicator_new("Format Junkie Indicator", "formatjunkie", APP_INDICATOR_CATEGORY_APPLICATION_STATUS);
    GtkWidget* showapp_option;
    GtkWidget* add_audio_option;
    //GtkWidget* subitem3;
    GtkWidget* indicatormenu = gtk_menu_new();
    GtkWidget* item = gtk_menu_item_new_with_label("Format Junkie main menu");
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), indicatormenu);

    showapp_option = gtk_menu_item_new_with_label("Show App!");
    g_signal_connect(showapp_option, "activate", G_CALLBACK(&MainWindow::show_app), this);
    gtk_menu_shell_append(GTK_MENU_SHELL(indicatormenu), showapp_option);

    add_audio_option = gtk_menu_item_new_with_label("Add audio files");
    g_signal_connect(add_audio_option, "activate", G_CALLBACK(&MainWindow::add_audio_files), this);
    gtk_menu_shell_append(GTK_MENU_SHELL(indicatormenu), add_audio_option);
/*
    subitem3 = gtk_menu_item_new_with_label("Quit");
    g_signal_connect(subitem3, "activate", G_CALLBACK(quit_from_indicator), appindicator);
    gtk_menu_shell_append(GTK_MENU_SHELL(menu), subitem3);*/
    gtk_widget_show_all(indicatormenu);
    app_indicator_set_status(appindicator, APP_INDICATOR_STATUS_ACTIVE);
    app_indicator_set_attention_icon(appindicator, "dialog-warning");

    app_indicator_set_menu(appindicator, GTK_MENU (indicatormenu));
}

You'll have to do the same with add_audio_files, too.

Last edited by Corona688; 06-28-2012 at 04:16 PM..
This User Gave Thanks to Corona688 For This Post:
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to start my gtk+

hi, i am a total dummy of unix. i am not used to the unix convention and practice. currently i am trying to install and use the solaris GUI based ftp program called gtk+ (gtk+-1.2.10-sol8-sparc-local.gz). i downloaded it and installed it successfully on my Sun Solaris sparc version 8. ... (4 Replies)
Discussion started by: champion
4 Replies

2. Linux

GTK+ hates me

I am very new to the linux environment. I have been interested in it for years but have just recently had the courage to pop that install disk into my PC. Because of it's ease of installation, I installed Mandrake 9.1 and I'm running KDE3.1 for my GUI. Right now I'm trying to conquer the world... (5 Replies)
Discussion started by: n0data
5 Replies

3. Post Here to Contact Site Administrators and Moderators

GTK+ project

Hai, I am santhosh,I am fresher to this Forum,I want details about GTK+ Project(All Widgets--- I mean how they are programming in callback.c file). if it possible please send information regarding this Glade tool.I want to interface glade with Modbus protocol, Thankyou with best regards,... (0 Replies)
Discussion started by: santhosh.linux
0 Replies

4. Programming

GUI without GTK - Is it possible?

Is GUI programming without GTK possible? If so, how? Or what libraries should I #include? Google seems to tell me that GUI programming in C++ is much more popular then in C. I'm assuming because of the Object Orientedness (if that is even a word)? Before you say things like "Search the forums",... (5 Replies)
Discussion started by: Octal
5 Replies

5. Shell Programming and Scripting

Problem combining two variables into one

Hello, I have a problem combining two variables into one. I did the following: in my env variables i had set PATH_DESTINATION_1=/root/path_one PATH_DESTINATION_2=/root/path_two #!/usr/bin/ksh count=1 count_path=2 while do (3 Replies)
Discussion started by: Eraser
3 Replies

6. Programming

curses.h not found , gtk/gtk.h not found

i have downloaded <libncurses5-dev_5.7+20101128-1_i386.deb> and <ndk++-0.0.1alpha4.tar.bz2> which contains the header files curses.h and gtk/gtk.h .. i have also included them using .. #include "/home/ball/Desktop/Sudoku/project/libncurses5-dev_5.7+20101128-1_i386/usr/include/curses.h" ... (2 Replies)
Discussion started by: upvan111
2 Replies

7. UNIX for Dummies Questions & Answers

Gtk-WARNING **:

Hi all, I want to run a 32 bit program on a 64 bit linux machine. Installing the program was no issue but when I try to run it I get Warnings that look like this: Gtk-WARNING **: Unable to locate theme engine in module_path: "oxygen-gtk" Gtk-WARNING **: Unable to locate theme engine in... (3 Replies)
Discussion started by: friend
3 Replies

8. Shell Programming and Scripting

awk problem - combining awk statements

i have a datafile that has several lines that look like this: 2,dataflow,Sun Mar 17 16:50:01 2013,1363539001,2990,excelsheet,660,mortar,660,4 using the following command: awk -F, '{$3=strftime("%a %b %d %T %Y,%s",$3)}1' OFS=, $DATAFILE | egrep -v "\-OLDISSUES," | ${AWK} "/${MONTH} ${DAY}... (7 Replies)
Discussion started by: SkySmart
7 Replies

9. Fedora

GTK Themes

Hi, So, I have a GTK based GUI app. I used GTKdevel-2.24 to develop and compile it on two different distros of linux: Fedora 14 and Linaro (tablet). All of my code was the same for each but compiled on each platform separately (32bit and ARM). Both distros run the application. On Fedora 14... (0 Replies)
Discussion started by: fedora18
0 Replies
MainWindow(3)						User Contributed Perl Documentation					     MainWindow(3)

NAME
Tk::MainWindow - Root widget of a widget tree SYNOPSIS
use Tk; my $mw = MainWindow->new( ... options ... ); my $this = $mw->ThisWidget -> pack ; my $that = $mw->ThatWidget; ... MainLoop; DESCRIPTION
Perl/Tk applications (which have windows associated with them) create one or more MainWindows which act as the containers and parents of the other widgets. Tk::MainWindow is a special kind of Toplevel widget. It is the root of a widget tree. Therefore "$mw->Parent" returns "undef". The default title of a MainWindow is the basename of the script (actually the Class name used for options lookup, i.e. with basename with inital caps) or 'Ptk' as the fallback value. If more than one MainWindow is created or several instances of the script are running at the same time the string " #n" is appended where the number "n" is set to get a unique value. Unlike the standard Tcl/Tk's wish, perl/Tk allows you to create several MainWindows. When the last MainWindow is destroyed the Tk eventloop exits (the eventloop is entered with the call of "MainLoop"). Various resources (bindings, fonts, images, colors) are maintained or cached for each MainWindow, so each MainWindow consumes more resources than a Toplevel. However multiple MainWindows can make sense when the user can destroy them independently. METHODS
You can apply all methods that a Toplevel widget accepts. The method $w->MainWindow applied to any widget will return the MainWindow to which the widget belongs (the MainWindow belongs to itself). MISSING
Documentation is incomplete. Here are some missing items that should be explained in more detail: o The new mechanism for MainWindows is slightly different to other widgets. o There no explanation about what resources are bound to a MainWindow (e.g., ClassInit done per MainWindow) o Passing of command line options to override or augment arguments of the "new" method (see Tk::CmdLine). SEE ALSO
Tk::Toplevel Tk::CmdLine perl v5.16.3 2014-06-10 MainWindow(3)
All times are GMT -4. The time now is 04:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy